diff --git a/Cargo.lock b/Cargo.lock index 49b506c..37d9c21 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -799,6 +799,13 @@ version = "1.20.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1261fe7e33c73b354eab43b1273a57c8f967d0391e80353e51f764ac02cf6775" +[[package]] +name = "openzeppelin-fungible-token" +version = "0.0.0" +dependencies = [ + "soroban-sdk", +] + [[package]] name = "openzeppelin-pausable" version = "0.0.0" diff --git a/Cargo.toml b/Cargo.toml index d87b8c7..c3cd886 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -2,6 +2,7 @@ resolver = "2" members = [ "contracts/utils/*", + "contracts/token/*", "examples/*", ] diff --git a/contracts/token/fungible/Cargo.toml b/contracts/token/fungible/Cargo.toml new file mode 100644 index 0000000..f44bb4c --- /dev/null +++ b/contracts/token/fungible/Cargo.toml @@ -0,0 +1,17 @@ +[package] +name = "openzeppelin-fungible-token" +edition.workspace = true +license.workspace = true +repository.workspace = true +publish = false +version.workspace = true + +[lib] +crate-type = ["lib", "cdylib"] +doctest = false + +[dependencies] +soroban-sdk = { workspace = true } + +[dev-dependencies] +soroban-sdk = { workspace = true, features = ["testutils"] } diff --git a/contracts/token/fungible/src/fungible.rs b/contracts/token/fungible/src/fungible.rs new file mode 100644 index 0000000..f7010a9 --- /dev/null +++ b/contracts/token/fungible/src/fungible.rs @@ -0,0 +1,238 @@ +use soroban_sdk::{contractclient, contracterror, symbol_short, Address, Env, String}; + +/// Vanilla Fungible Token Trait +/// +/// The `FungibleToken` trait defines the core functionality for fungible +/// tokens, adhering to SEP-41. It provides a standard interface for managing +/// balances, allowances, and metadata associated with fungible tokens. +/// Additionally, this trait includes the `total_supply()` function, which is +/// not part of SEP-41 but is commonly used in token contracts. +/// +/// To fully comply with the SEP-41 specification one have to implement the +/// `Burnable` trait in addition to this one. SEP-41 mandates support for token +/// burning to be considered compliant. +#[contractclient(name = "FungibleTokenClient")] +pub trait FungibleToken { + /// Returns the total amount of tokens in circulation. + /// + /// # Arguments + /// + /// * `e` - Access to the Soroban environment. + /// + /// # Notes + /// + /// We recommend using the [`crate::storage::total_supply()`] function from + /// the `storage` module when implementing this function. + fn total_supply(e: Env) -> i128; + + /// Returns the amount of tokens held by `account`. + /// + /// # Arguments + /// + /// * `e` - Access to the Soroban environment. + /// * `account` - The address for which the balance is being queried. + /// + /// # Notes + /// + /// We recommend using the [`crate::storage::balance()`] function from + /// the `storage` module when implementing this function. + fn balance(e: Env, account: Address) -> i128; + + /// Returns the amount of tokens a `spender` is allowed to spend on behalf + /// of an `owner`. + /// + /// # Arguments + /// + /// * `e` - Access to Soroban environment. + /// * `owner` - The address holding the tokens. + /// * `spender` - The address authorized to spend the tokens. + /// + /// # Notes + /// + /// We recommend using the [`crate::storage::allowance()`] function from + /// the `storage` module when implementing this function. + fn allowance(e: Env, owner: Address, spender: Address) -> i128; + + /// Transfers a `value` amount of tokens from `from` to `to`. + /// + /// # Arguments + /// + /// * `e` - Access to Soroban environment. + /// * `from` - The address holding the tokens. + /// * `to` - The address receiving the transferred tokens. + /// * `value` - The value of tokens to be transferred. + /// + /// # Errors + /// + /// * [`FungibleTokenError::InsufficientBalance`] - When attempting to + /// transfer more tokens than `from` current balance. + /// + /// # Events + /// + /// * topics - `["transfer", from: Address, to: Address]` + /// * data - `[value: i128]` + /// + /// # Notes + /// + /// We recommend using the [`crate::storage::transfer()`] function from + /// the `storage` module when implementing this function. + fn transfer(e: Env, from: Address, to: Address, value: i128); + + /// Transfers a `value` amount of tokens from `from` to `to` using the + /// allowance mechanism. `value` is then deducted from `spender allowance. + /// + /// # Arguments + /// + /// * `e` - Access to Soroban environment. + /// * `spender` - The address authorizing the transfer, and having its + /// allowance consumed during the transfer. + /// * `from` - The address holding the tokens which will be transferred. + /// * `to` - The address receiving the transferred tokens. + /// * `value` - The amount of tokens to be transferred. + /// + /// # Errors + /// + /// * [`FungibleTokenError::InsufficientBalance`] - When attempting to + /// transfer more tokens than `from` current balance. + /// * [`FungibleTokenError::InsufficientAllowance`] - When attempting to + /// transfer more tokens than `spender` current allowance. + /// + /// + /// # Events + /// + /// * topics - `["transfer", from: Address, to: Address]` + /// * data - `[value: i128]` + /// + /// # Notes + /// + /// We recommend using the [`crate::storage::transfer_from()`] function from + /// the `storage` module when implementing this function. + fn transfer_from(e: Env, spender: Address, from: Address, to: Address, value: i128); + + /// Sets the amount of tokens a `spender` is allowed to spend on behalf of + /// an `owner`. Overrides any existing allowance set between `spender` and + /// `owner`. + /// + /// # Arguments + /// + /// * `e` - Access to Soroban environment. + /// * `owner` - The address holding the tokens. + /// * `spender` - The address authorized to spend the tokens. + /// * `value` - The amount of tokens made available to `spender`. + /// * `live_until_ledger` - The ledger number at which the allowance + /// expires. + /// + /// # Errors + /// + /// * [`FungibleTokenError::InvalidLiveUntilLedger`] - Occurs when + /// attempting to set `live_until_ledger` that is less than the current + /// ledger number and greater than `0`. + /// + /// # Events + /// + /// * topics - `["approve", from: Address, spender: Address]` + /// * data - `[value: i128, live_until_ledger: u32]` + /// + /// # Notes + /// + /// We recommend using the [`crate::storage::approve()`] function from + /// the `storage` module when implementing this function. + fn approve(e: Env, owner: Address, spender: Address, value: i128, live_until_ledger: u32); + + /// Returns the number of decimals used to represent amounts of this token. + /// + /// # Arguments + /// + /// * `e` - Access to Soroban environment. + /// + /// # Notes + /// + /// We recommend using the [`crate::metadata::decimals()`] function from + /// the `metadata` module when implementing this function. + fn decimals(e: Env) -> u32; + + /// Returns the name for this token. + /// + /// # Arguments + /// + /// * `e` - Access to Soroban environment. + /// + /// # Notes + /// + /// We recommend using the [`crate::metadata::name()`] function from + /// the `metadata` module when implementing this function. + fn name(e: Env) -> String; + + /// Returns the symbol for this token. + /// + /// # Arguments + /// + /// * `e` - Access to Soroban environment. + /// + /// # Notes + /// + /// We recommend using the [`crate::metadata::symbol()`] function from + /// the `metadata` module when implementing this function. + fn symbol(e: Env) -> String; +} + +// ################## ERRORS ################## + +#[contracterror] +#[repr(u32)] +pub enum FungibleTokenError { + /// Indicates an error related to the current balance of account from which + /// tokens are expected to be transferred. + InsufficientBalance = 1, + /// Indicates a failure with the allowance mechanism when a given spender + /// doesn't have enough allowance. + InsufficientAllowance = 2, + /// Indicates an invalid value for `live_until_ledger` when setting an + /// allowance. + InvalidLiveUntilLedger = 3, +} + +// ################## EVENTS ################## + +/// Emits an event indicating a transfer of tokens. +/// +/// # Arguments +/// +/// * `e` - Access to Soroban environment. +/// * `from` - The address holding the tokens. +/// * `to` - The address receiving the transferred tokens. +/// * `value` - The value of tokens to be transferred. +/// +/// # Events +/// +/// * topics - `["transfer", from: Address, to: Address]` +/// * data - `[value: i128]` +pub fn emit_transfer(e: &Env, from: &Address, to: &Address, value: i128) { + let topics = (symbol_short!("transfer"), from, to); + e.events().publish(topics, value) +} + +/// Emits an event indicating an allowance was set. +/// +/// # Arguments +/// +/// * `e` - Access to Soroban environment. +/// * `owner` - The address holding the tokens. +/// * `spender` - The address authorized to spend the tokens. +/// * `value` - The amount of tokens made available to `spender`. +/// * `live_until_ledger` - The ledger number at which the allowance expires. +/// +/// # Events +/// +/// * topics - `["approve", owner: Address, spender: Address]` +/// * data - `[value: i128, live_until_ledger: u32]` +pub fn emit_approve( + e: &Env, + owner: &Address, + spender: &Address, + value: i128, + live_until_ledger: u32, +) { + let topics = (symbol_short!("approve"), owner, spender); + e.events().publish(topics, (value, live_until_ledger)) +} diff --git a/contracts/token/fungible/src/lib.rs b/contracts/token/fungible/src/lib.rs new file mode 100644 index 0000000..a45ba9d --- /dev/null +++ b/contracts/token/fungible/src/lib.rs @@ -0,0 +1,64 @@ +//! # Fungible Token Contract Module. +//! +//! Implements utilities for handling fungible tokens in a Soroban contract. +//! +//! This module provides essential storage functionalities required for managing +//! balances, allowances, and total supply of fungible tokens. +//! +//! ## Design Overview +//! +//! This module is structured to provide flexibility to developers by splitting +//! functionalities into higher-level and lower-level operations: +//! +//! - **High-Level Functions**: These include all necessary checks, +//! verifications, authorizations, state-changing logic, and event emissions. +//! They simplify usage by handling core logic securely. Users can directly +//! call these functions for typical token operations without worrying about +//! implementation details. +//! +//! - **Low-Level Functions**: These offer granular control for developers who +//! need to compose their own workflows. Such functions expose internal +//! mechanisms and require the caller to handle verifications and +//! authorizations manually. +//! +//! By offering this dual-layered approach, developers can choose between +//! convenience and customization, depending on their project requirements. +//! +//! ## Base Module and Extensions +//! +//! The base module implements: +//! +//! - Total supply management +//! - Transfers and allowances +//! +//! To extend functionality, the module supports the following optional +//! features: +//! +//! - Metadata: Provides additional information about the token, such as name, +//! symbol, and decimals. +//! - Mintable: Allows authorized entities to mint new tokens and increase the +//! total supply. +//! - Burnable: Enables token holders to destroy their tokens, reducing the +//! total supply. +//! +//! ## Compatibility and Compliance +//! +//! The module is designed to ensure full compatibility with SEP-0041, making it +//! easy to integrate into Soroban-based applications. It also closely mirrors +//! the Ethereum ERC-20 standard, facilitating cross-ecosystem familiarity and +//! ease of use. +//! +//! ## Notes for Developers +//! +//! - **Security Considerations**: While high-level functions handle necessary +//! checks, users of low-level functions must take extra care to ensure +//! correctness and security. +//! - **Composable Design**: The modular structure encourages developers to +//! extend functionality by combining provided primitives or creating custom +//! extensions. +#![no_std] + +pub mod fungible; +pub mod storage; + +mod test; diff --git a/contracts/token/fungible/src/storage.rs b/contracts/token/fungible/src/storage.rs new file mode 100644 index 0000000..1d6c244 --- /dev/null +++ b/contracts/token/fungible/src/storage.rs @@ -0,0 +1,421 @@ +use soroban_sdk::{contracttype, panic_with_error, Address, Env}; + +use crate::fungible::{emit_approve, emit_transfer, FungibleTokenError}; + +// Same values as in Stellar Asset Contract (SAC) implementation: +// https://github.com/stellar/rs-soroban-env/blob/main/soroban-env-host/src/builtin_contracts/stellar_asset_contract/storage_types.rs +pub const DAY_IN_LEDGERS: u32 = 17280; + +pub const INSTANCE_EXTEND_AMOUNT: u32 = 7 * DAY_IN_LEDGERS; +pub const INSTANCE_TTL_THRESHOLD: u32 = INSTANCE_EXTEND_AMOUNT - DAY_IN_LEDGERS; + +pub const BALANCE_EXTEND_AMOUNT: u32 = 30 * DAY_IN_LEDGERS; +pub const BALANCE_TTL_THRESHOLD: u32 = BALANCE_EXTEND_AMOUNT - DAY_IN_LEDGERS; + +/// Storage key that maps to [`AllowanceData`] +#[contracttype] +pub struct AllowanceKey { + pub owner: Address, + pub spender: Address, +} + +/// Storage container for the amount of tokens for which an allowance is granted +/// and the ledger number at which this allowance expires. +#[contracttype] +pub struct AllowanceData { + pub value: i128, + pub live_until_ledger: u32, +} + +/// Storage keys for the data associated with `FungibleToken` +#[contracttype] +pub enum StorageKey { + TotalSupply, + Balance(Address), + Allowance(AllowanceKey), +} + +// ################## QUERY STATE ################## + +/// Returns the total amount of tokens in circulation. If no supply is recorded, +/// it defaults to `0`. +/// +/// # Arguments +/// +/// * `e` - Access to the Soroban environment. +pub fn total_supply(e: &Env) -> i128 { + e.storage().instance().extend_ttl(INSTANCE_TTL_THRESHOLD, INSTANCE_EXTEND_AMOUNT); + e.storage().instance().get(&StorageKey::TotalSupply).unwrap_or(0) +} + +/// Returns the amount of tokens held by `account`. Defaults to `0` if no +/// balance is stored. +/// +/// # Arguments +/// +/// * `e` - Access to the Soroban environment. +/// * `account` - The address for which the balance is being queried. +pub fn balance(e: &Env, account: &Address) -> i128 { + let key = StorageKey::Balance(account.clone()); + if let Some(balance) = e.storage().persistent().get::<_, i128>(&key) { + e.storage().persistent().extend_ttl(&key, BALANCE_TTL_THRESHOLD, BALANCE_EXTEND_AMOUNT); + balance + } else { + 0 + } +} + +/// Returns the amount of tokens a `spender` is allowed to spend on behalf of an +/// `owner` and the ledger number at which this allowance expires. Both values +/// default to `0`. +/// +/// # Arguments +/// +/// * `e` - Access to Soroban environment. +/// * `owner` - The address holding the tokens. +/// * `spender` - The address authorized to spend the tokens. +/// +/// # Notes +/// +/// Attention is required when `live_until_ledger` is less than the current +/// ledger number, as this indicates the entry has expired. In such cases, the +/// allowance should be treated as `0`. +pub fn allowance_data(e: &Env, owner: &Address, spender: &Address) -> AllowanceData { + let key = AllowanceKey { owner: owner.clone(), spender: spender.clone() }; + let default = AllowanceData { value: 0, live_until_ledger: 0 }; + e.storage().temporary().get(&StorageKey::Allowance(key)).unwrap_or(default) +} + +/// Returns the amount of tokens a `spender` is allowed to spend on behalf of an +/// `owner`. +/// +/// # Arguments +/// +/// * `e` - Access to Soroban environment. +/// * `owner` - The address holding the tokens. +/// * `spender` - The address authorized to spend the tokens. +/// +/// # Notes +/// +/// An allowance entry where `live_until_ledger` is less than the current +/// ledger number is treated as an allowance with value `0`. +pub fn allowance(e: &Env, owner: &Address, spender: &Address) -> i128 { + let allowance = allowance_data(e, owner, spender); + + if allowance.value > 0 && allowance.live_until_ledger < e.ledger().sequence() { + return 0; + } + + allowance.value +} + +// ################## CHANGE STATE ################## + +/// Sets the amount of tokens a `spender` is allowed to spend on behalf of an +/// `owner`. Overrides any existing allowance set between `spender` and `owner`. +/// +/// # Arguments +/// +/// * `e` - Access to Soroban environment. +/// * `owner` - The address holding the tokens. +/// * `spender` - The address authorized to spend the tokens. +/// * `value` - The amount of tokens made available to `spender`. +/// * `live_until_ledger` - The ledger number at which the allowance expires. +/// +/// # Errors +/// +/// * [`FungibleTokenError::InvalidLiveUntilLedger`] - Occurs when attempting to +/// set `live_until_ledger` that is less than the current ledger number and +/// greater than `0`. +/// +/// # Events +/// +/// * topics - `["approve", from: Address, spender: Address]` +/// * data - `[value: i128, live_until_ledger: u32]` +/// +/// # Notes +/// +/// Authorization for `owner` is required. +pub fn approve(e: &Env, owner: &Address, spender: &Address, value: i128, live_until_ledger: u32) { + owner.require_auth(); + set_allowance(e, owner, spender, value, live_until_ledger, true); +} + +/// Sets the amount of tokens a `spender` is allowed to spend on behalf of an +/// `owner`. Overrides any existing allowance set between `spender` and `owner`. +/// Variant of [`approve()`] that doesn't handle authorization, but controls +/// event emission. That can be useful in operatioins like spending allowance +/// during [`transfer_from()`]. +/// +/// # Arguments +/// +/// * `e` - Access to Soroban environment. +/// * `owner` - The address holding the tokens. +/// * `spender` - The address authorized to spend the tokens. +/// * `value` - The amount of tokens made available to `spender`. +/// * `live_until_ledger` - The ledger number at which the allowance expires. +/// * `emit` - A flag to enable or disable event emission. +/// +/// # Errors +/// +/// * [`FungibleTokenError::InvalidLiveUntilLedger`] - Occurs when attempting to +/// set `live_until_ledger` that is less than the current ledger number and +/// greater than `0`. +/// +/// # Events +/// +/// Emits an event if `emit` is `true`. +/// * topics - `["approve", from: Address, spender: Address]` +/// * data - `[value: i128, live_until_ledger: u32]` +/// +/// # Notes +/// +/// No authorization is required. +pub fn set_allowance( + e: &Env, + owner: &Address, + spender: &Address, + value: i128, + live_until_ledger: u32, + emit: bool, +) { + if value < 0 { + panic!("value cannot be negative") + } + + let allowance = AllowanceData { value, live_until_ledger }; + + if value > 0 && live_until_ledger < e.ledger().sequence() { + panic_with_error!(e, FungibleTokenError::InvalidLiveUntilLedger); + } + + let key = + StorageKey::Allowance(AllowanceKey { owner: owner.clone(), spender: spender.clone() }); + e.storage().temporary().set(&key, &allowance); + + if value > 0 { + // NOTE: can't underflow because of the check above. + let live_for = live_until_ledger - e.ledger().sequence(); + + e.storage().temporary().extend_ttl(&key, live_for, live_for) + } + + if emit { + emit_approve(e, owner, spender, value, live_until_ledger); + } +} + +/// Deducts the amount of tokens a `spender` is allowed to spend on behalf of an +/// `owner`. +/// +/// # Arguments +/// +/// * `e` - Access to Soroban environment. +/// * `owner` - The address holding the tokens. +/// * `spender` - The address authorized to spend the tokens. +/// * `value` - The amount of tokens to be deducted from `spender` allowance. +/// +/// # Errors +/// +/// * [`FungibleTokenError::InsufficientAllowance`] - When attempting to +/// transfer more tokens than `spender` current allowance. +/// +/// # Notes +/// +/// No authorization is required. +pub fn spend_allowance(e: &Env, owner: &Address, spender: &Address, value: i128) { + let allowance = allowance_data(e, owner, spender); + + if allowance.value < value { + panic_with_error!(e, FungibleTokenError::InsufficientAllowance); + } + + if value > 0 { + set_allowance( + e, + owner, + spender, + allowance.value - value, + allowance.live_until_ledger, + false, + ); + } +} + +/// TODO: move to mintable +/// Creates a `value` amount of tokens and assigns them to `account`. Updates +/// the total supply accordingly. +/// +/// # Arguments +/// +/// * `e` - Access to the Soroban environment. +/// * `account` - The address receiving the new tokens. +/// * `value` - The amount of tokens to mint. +/// +/// # Errors +/// TODO +/// +/// # Events +/// TODO +pub fn mint(e: &Env, account: &Address, value: i128) { + update(e, None, Some(account), value) + // TODO: emit_mint +} + +/// TODO: move to burnable +/// Destroys a `value` amount of tokens from `account`. Updates the total +/// supply accordingly. +/// +/// # Arguments +/// +/// * `e` - Access to the Soroban environment. +/// * `account` - The address whose tokens are destroyed. +/// * `value` - The amount of tokens to burn. +/// +/// # Errors +/// TODO +/// +/// # Events +/// TODO +pub fn burn(e: &Env, account: &Address, value: i128) { + update(e, Some(account), None, value) + // TODO: emit_burn +} + +/// Transfers a `value` amount of tokens from `from` to `to`. +/// +/// # Arguments +/// +/// * `e` - Access to Soroban environment. +/// * `from` - The address holding the tokens. +/// * `to` - The address receiving the transferred tokens. +/// * `value` - The value of tokens to be transferred. +/// +/// # Errors +/// +/// * [`FungibleTokenError::InsufficientBalance`] - When attempting to transfer +/// more tokens than `from` current balance. +/// +/// # Events +/// +/// * topics - `["transfer", from: Address, to: Address]` +/// * data - `[value: i128]` +/// +/// # Notes +/// +/// Authorization for `from` is required. +pub fn transfer(e: &Env, from: &Address, to: &Address, value: i128) { + from.require_auth(); + do_transfer(e, from, to, value); +} + +/// Transfers a `value` amount of tokens from `from` to `to` using the +/// allowance mechanism. `value` is then deducted from `spender` allowance. +/// +/// # Arguments +/// +/// * `e` - Access to Soroban environment. +/// * `spender` - The address authorizing the transfer, and having its allowance +/// consumed during the transfer. +/// * `from` - The address holding the tokens which will be transferred. +/// * `to` - The address receiving the transferred tokens. +/// * `value` - The amount of tokens to be transferred. +/// +/// # Errors +/// +/// * [`FungibleTokenError::InsufficientBalance`] - When attempting to transfer +/// more tokens than `from` current balance. +/// * [`FungibleTokenError::InsufficientAllowance`] - When attempting to +/// transfer more tokens than `spender` current allowance. +/// +/// +/// # Events +/// +/// * topics - `["transfer", from: Address, to: Address]` +/// * data - `[value: i128]` +/// +/// # Notes +/// +/// Authorization for `spender` is required. +pub fn transfer_from(e: &Env, spender: &Address, from: &Address, to: &Address, value: i128) { + spender.require_auth(); + spend_allowance(e, from, spender, value); + do_transfer(e, from, to, value); +} + +/// Equivalent to [`transfer()`] but doesn't handle authorization. +/// +/// # Arguments +/// +/// * `e` - Access to Soroban environment. +/// * `from` - The address holding the tokens. +/// * `to` - The address receiving the transferred tokens. +/// * `value` - The value of tokens to be transferred. +/// +/// # Errors +/// +/// * [`FungibleTokenError::InsufficientBalance`] - When attempting to transfer +/// more tokens than `from` current balance. +/// +/// # Events +/// +/// * topics - `["transfer", from: Address, to: Address]` +/// * data - `[value: i128]` +/// +/// # Notes +/// +/// No authorization is required. +pub fn do_transfer(e: &Env, from: &Address, to: &Address, value: i128) { + update(e, Some(from), Some(to), value); + + emit_transfer(e, from, to, value); +} + +/// Transfers a `value` amount of tokens from `from` to `to` or alternatively +/// mints (or burns) tokens if `from` (or `to`) is `None`. Updates the total +/// supply accordingly. +/// +/// # Arguments +/// +/// * `e` - Access to Soroban environment. +/// * `from` - The address holding the tokens. +/// * `to` - The address receiving the transferred tokens. +/// * `value` - The value of tokens to be transferred. +/// +/// # Errors +/// +/// * [`FungibleTokenError::InsufficientBalance`] - When attempting to transfer +/// more tokens than `from` current balance. +/// +/// # Notes +/// +/// No authorization is required. +pub fn update(e: &Env, from: Option<&Address>, to: Option<&Address>, value: i128) { + if value <= 0 { + panic!("value must be > 0") + } + + if let Some(account) = from { + let mut from_balance = balance(e, account); + if from_balance < value { + panic_with_error!(e, FungibleTokenError::InsufficientBalance); + } + // NOTE: can't underflow because of the check above. + from_balance -= value; + e.storage().persistent().set(&StorageKey::Balance(account.clone()), &from_balance); + } else { + let mut total_supply = total_supply(e); + total_supply = total_supply.checked_add(value).expect("total_supply overflow"); + e.storage().instance().set(&StorageKey::TotalSupply, &total_supply); + } + + if let Some(account) = to { + let mut to_balance = balance(e, account); + to_balance = to_balance.checked_add(value).expect("to_balance overflow"); + e.storage().persistent().set(&StorageKey::Balance(account.clone()), &to_balance); + } else { + let mut total_supply = total_supply(e); + total_supply = total_supply.checked_sub(value).expect("total_supply underflow"); + e.storage().instance().set(&StorageKey::TotalSupply, &total_supply); + } +} diff --git a/contracts/token/fungible/src/test.rs b/contracts/token/fungible/src/test.rs new file mode 100644 index 0000000..52ba594 --- /dev/null +++ b/contracts/token/fungible/src/test.rs @@ -0,0 +1,372 @@ +#![cfg(test)] + +extern crate std; + +use soroban_sdk::{ + contract, symbol_short, + testutils::{ + storage::{Instance, Persistent}, + Address as _, Events, Ledger, + }, + vec, Address, Env, IntoVal, +}; + +use crate::storage::{ + allowance, approve, balance, burn, mint, set_allowance, spend_allowance, total_supply, + transfer, transfer_from, update, StorageKey, BALANCE_EXTEND_AMOUNT, INSTANCE_EXTEND_AMOUNT, +}; + +#[contract] +struct MockContract; + +#[test] +fn initial_state() { + let e = Env::default(); + let address = e.register(MockContract, ()); + let account = Address::generate(&e); + e.as_contract(&address, || { + assert_eq!(total_supply(&e), 0); + assert_eq!(balance(&e, &account), 0); + }); +} + +#[test] +fn bump_instance_works() { + let e = Env::default(); + + e.ledger().with_mut(|l| { + // Minimum TTL for persistent entries - new persistent (and instance) + // entries will have this TTL when created. + l.min_persistent_entry_ttl = 500; + }); + + let address = e.register(MockContract, ()); + + e.as_contract(&address, || { + let ttl = e.storage().instance().get_ttl(); + // Note, that TTL doesn't include the current ledger, but when entry + // is created the current ledger is counted towards the number of + // ledgers specified by `min_persistent_entry_ttl`, thus + // the TTL is 1 ledger less than the respective setting. + assert_eq!(ttl, 499); + + let current = e.ledger().sequence(); + e.ledger().set_sequence_number(current + ttl); + + total_supply(&e); + assert_eq!(e.storage().instance().get_ttl(), INSTANCE_EXTEND_AMOUNT); + }); +} + +#[test] +fn mint_works() { + let e = Env::default(); + let address = e.register(MockContract, ()); + let account = Address::generate(&e); + e.as_contract(&address, || { + mint(&e, &account, 100); + assert_eq!(balance(&e, &account), 100); + assert_eq!(total_supply(&e), 100); + }); +} + +#[test] +fn burn_works() { + let e = Env::default(); + let address = e.register(MockContract, ()); + let account = Address::generate(&e); + e.as_contract(&address, || { + mint(&e, &account, 100); + burn(&e, &account, 50); + assert_eq!(balance(&e, &account), 50); + assert_eq!(total_supply(&e), 50); + }); +} + +#[test] +fn approve_with_event() { + let e = Env::default(); + e.mock_all_auths(); + let address = e.register(MockContract, ()); + let owner = Address::generate(&e); + let spender = Address::generate(&e); + + e.as_contract(&address, || { + let allowance_data = (50, 1000); + approve(&e, &owner, &spender, allowance_data.0, allowance_data.1); + let allowance_val = allowance(&e, &owner, &spender); + assert_eq!(allowance_val, 50); + + let events = e.events().all(); + assert_eq!(events.len(), 1); + assert_eq!( + events, + vec![ + &e, + ( + address.clone(), + vec![ + &e, + symbol_short!("approve").into_val(&e), + owner.into_val(&e), + spender.into_val(&e) + ], + allowance_data.into_val(&e) + ) + ] + ); + }); +} + +#[test] +fn approve_handles_expiry() { + let e = Env::default(); + e.mock_all_auths(); + let address = e.register(MockContract, ()); + let owner = Address::generate(&e); + let spender = Address::generate(&e); + + e.as_contract(&address, || { + approve(&e, &owner, &spender, 50, 2); + e.ledger().set_sequence_number(3); + + let expired_allowance = allowance(&e, &owner, &spender); + assert_eq!(expired_allowance, 0); + }); +} + +#[test] +fn spend_allowance_reduces_value() { + let e = Env::default(); + e.mock_all_auths(); + let address = e.register(MockContract, ()); + let owner = Address::generate(&e); + let spender = Address::generate(&e); + + e.as_contract(&address, || { + approve(&e, &owner, &spender, 50, 1000); + + spend_allowance(&e, &owner, &spender, 20); + + let updated_allowance = allowance(&e, &owner, &spender); + assert_eq!(updated_allowance, 30); + }); +} + +#[test] +#[should_panic(expected = "Error(Contract, #2)")] +fn spend_allowance_insufficient_allowance_fails() { + let e = Env::default(); + e.mock_all_auths(); + let address = e.register(MockContract, ()); + let owner = Address::generate(&e); + let spender = Address::generate(&e); + + e.as_contract(&address, || { + approve(&e, &owner, &spender, 10, 1000); + spend_allowance(&e, &owner, &spender, 20); + }); +} + +#[test] +#[should_panic(expected = "Error(Contract, #3)")] +fn set_allowance_with_expired_ledger_fails() { + let e = Env::default(); + let address = e.register(MockContract, ()); + let owner = Address::generate(&e); + let spender = Address::generate(&e); + + e.as_contract(&address, || { + e.ledger().set_sequence_number(10); + set_allowance(&e, &owner, &spender, 50, 5, true); + }); +} + +#[test] +fn set_allowance_with_zero_value() { + let e = Env::default(); + let address = e.register(MockContract, ()); + let owner = Address::generate(&e); + let owner2 = Address::generate(&e); + let spender = Address::generate(&e); + + e.as_contract(&address, || { + set_allowance(&e, &owner, &spender, 0, 5, false); + let allowance_val = allowance(&e, &owner, &spender); + assert_eq!(allowance_val, 0); + + // should pass for a past ledger + e.ledger().set_sequence_number(10); + set_allowance(&e, &owner2, &spender, 0, 5, false); + let allowance_val = allowance(&e, &owner2, &spender); + assert_eq!(allowance_val, 0); + }); +} + +#[test] +fn transfer_works() { + let e = Env::default(); + e.mock_all_auths(); + let address = e.register(MockContract, ()); + let from = Address::generate(&e); + let recipient = Address::generate(&e); + + e.as_contract(&address, || { + mint(&e, &from, 100); + transfer(&e, &from, &recipient, 50); + assert_eq!(balance(&e, &from), 50); + assert_eq!(balance(&e, &recipient), 50); + + let events = e.events().all(); + assert_eq!(events.len(), 1); + }); +} + +#[test] +fn extend_balance_ttl_thru_transfer() { + let e = Env::default(); + e.mock_all_auths(); + let address = e.register(MockContract, ()); + let from = Address::generate(&e); + let recipient = Address::generate(&e); + + e.as_contract(&address, || { + mint(&e, &from, 100); + + let key = StorageKey::Balance(from.clone()); + + let ttl = e.storage().persistent().get_ttl(&key); + e.ledger().with_mut(|l| { + l.sequence_number += ttl; + }); + transfer(&e, &from, &recipient, 50); + let ttl = e.storage().persistent().get_ttl(&key); + assert_eq!(ttl, BALANCE_EXTEND_AMOUNT); + }); +} + +#[test] +fn approve_and_transfer_from() { + let e = Env::default(); + e.mock_all_auths(); + let address = e.register(MockContract, ()); + let owner = Address::generate(&e); + let spender = Address::generate(&e); + let recipient = Address::generate(&e); + + e.as_contract(&address, || { + mint(&e, &owner, 100); + approve(&e, &owner, &spender, 50, 1000); + + let allowance_val = allowance(&e, &owner, &spender); + assert_eq!(allowance_val, 50); + + transfer_from(&e, &spender, &owner, &recipient, 30); + assert_eq!(balance(&e, &owner), 70); + assert_eq!(balance(&e, &recipient), 30); + + let updated_allowance = allowance(&e, &owner, &spender); + assert_eq!(updated_allowance, 20); + }); +} + +#[test] +#[should_panic(expected = "Error(Contract, #1)")] +fn transfer_insufficient_balance_fails() { + let e = Env::default(); + e.mock_all_auths(); + let address = e.register(MockContract, ()); + let from = Address::generate(&e); + let recipient = Address::generate(&e); + + e.as_contract(&address, || { + mint(&e, &from, 50); + transfer(&e, &from, &recipient, 100); + }); +} + +#[test] +#[should_panic(expected = "Error(Contract, #2)")] +fn transfer_from_insufficient_allowance_fails() { + let e = Env::default(); + e.mock_all_auths(); + let address = e.register(MockContract, ()); + let owner = Address::generate(&e); + let spender = Address::generate(&e); + let recipient = Address::generate(&e); + + e.as_contract(&address, || { + mint(&e, &owner, 100); + approve(&e, &owner, &spender, 30, 1000); + transfer_from(&e, &spender, &owner, &recipient, 50); + }); +} + +#[test] +fn update_transfers_between_accounts() { + let e = Env::default(); + let address = e.register(MockContract, ()); + let from = Address::generate(&e); + let to = Address::generate(&e); + + e.as_contract(&address, || { + mint(&e, &from, 100); + update(&e, Some(&from), Some(&to), 50); + assert_eq!(balance(&e, &from), 50); + assert_eq!(balance(&e, &to), 50); + }); +} + +#[test] +fn update_mints_tokens() { + let e = Env::default(); + let address = e.register(MockContract, ()); + let to = Address::generate(&e); + + e.as_contract(&address, || { + update(&e, None, Some(&to), 100); + assert_eq!(balance(&e, &to), 100); + assert_eq!(total_supply(&e), 100); + }); +} + +#[test] +fn update_burns_tokens() { + let e = Env::default(); + let address = e.register(MockContract, ()); + let from = Address::generate(&e); + + e.as_contract(&address, || { + mint(&e, &from, 100); + update(&e, Some(&from), None, 50); + assert_eq!(balance(&e, &from), 50); + assert_eq!(total_supply(&e), 50); + }); +} + +#[test] +#[should_panic(expected = "value must be > 0")] +fn update_with_invalid_value_panics() { + let e = Env::default(); + let address = e.register(MockContract, ()); + let from = Address::generate(&e); + let to = Address::generate(&e); + + e.as_contract(&address, || { + update(&e, Some(&from), Some(&to), 0); + }); +} + +#[test] +#[should_panic(expected = "Error(Contract, #1)")] +fn update_with_insufficient_balance_panics() { + let e = Env::default(); + let address = e.register(MockContract, ()); + let from = Address::generate(&e); + let to = Address::generate(&e); + + e.as_contract(&address, || { + mint(&e, &from, 50); + update(&e, Some(&from), Some(&to), 100); + }); +} diff --git a/contracts/token/fungible/test_snapshots/test/approve_and_transfer_from.1.json b/contracts/token/fungible/test_snapshots/test/approve_and_transfer_from.1.json new file mode 100644 index 0000000..ac4611b --- /dev/null +++ b/contracts/token/fungible/test_snapshots/test/approve_and_transfer_from.1.json @@ -0,0 +1,446 @@ +{ + "generators": { + "address": 4, + "nonce": 0 + }, + "auth": [ + [], + [ + [ + "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFCT4", + { + "function": { + "contract_fn": { + "contract_address": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD2KM", + "function_name": "", + "args": [] + } + }, + "sub_invocations": [] + } + ], + [ + "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAHK3M", + { + "function": { + "contract_fn": { + "contract_address": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD2KM", + "function_name": "", + "args": [] + } + }, + "sub_invocations": [] + } + ] + ] + ], + "ledger": { + "protocol_version": 22, + "sequence_number": 0, + "timestamp": 0, + "network_id": "0000000000000000000000000000000000000000000000000000000000000000", + "base_reserve": 0, + "min_persistent_entry_ttl": 4096, + "min_temp_entry_ttl": 16, + "max_entry_ttl": 6312000, + "ledger_entries": [ + [ + { + "contract_data": { + "contract": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD2KM", + "key": { + "vec": [ + { + "symbol": "Allowance" + }, + { + "map": [ + { + "key": { + "symbol": "owner" + }, + "val": { + "address": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFCT4" + } + }, + { + "key": { + "symbol": "spender" + }, + "val": { + "address": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAHK3M" + } + } + ] + } + ] + }, + "durability": "temporary" + } + }, + [ + { + "last_modified_ledger_seq": 0, + "data": { + "contract_data": { + "ext": "v0", + "contract": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD2KM", + "key": { + "vec": [ + { + "symbol": "Allowance" + }, + { + "map": [ + { + "key": { + "symbol": "owner" + }, + "val": { + "address": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFCT4" + } + }, + { + "key": { + "symbol": "spender" + }, + "val": { + "address": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAHK3M" + } + } + ] + } + ] + }, + "durability": "temporary", + "val": { + "map": [ + { + "key": { + "symbol": "live_until_ledger" + }, + "val": { + "u32": 1000 + } + }, + { + "key": { + "symbol": "value" + }, + "val": { + "i128": { + "hi": 0, + "lo": 20 + } + } + } + ] + } + } + }, + "ext": "v0" + }, + 1000 + ] + ], + [ + { + "contract_data": { + "contract": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD2KM", + "key": { + "vec": [ + { + "symbol": "Balance" + }, + { + "address": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFCT4" + } + ] + }, + "durability": "persistent" + } + }, + [ + { + "last_modified_ledger_seq": 0, + "data": { + "contract_data": { + "ext": "v0", + "contract": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD2KM", + "key": { + "vec": [ + { + "symbol": "Balance" + }, + { + "address": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFCT4" + } + ] + }, + "durability": "persistent", + "val": { + "i128": { + "hi": 0, + "lo": 70 + } + } + } + }, + "ext": "v0" + }, + 518400 + ] + ], + [ + { + "contract_data": { + "contract": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD2KM", + "key": { + "vec": [ + { + "symbol": "Balance" + }, + { + "address": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAITA4" + } + ] + }, + "durability": "persistent" + } + }, + [ + { + "last_modified_ledger_seq": 0, + "data": { + "contract_data": { + "ext": "v0", + "contract": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD2KM", + "key": { + "vec": [ + { + "symbol": "Balance" + }, + { + "address": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAITA4" + } + ] + }, + "durability": "persistent", + "val": { + "i128": { + "hi": 0, + "lo": 30 + } + } + } + }, + "ext": "v0" + }, + 518400 + ] + ], + [ + { + "contract_data": { + "contract": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD2KM", + "key": "ledger_key_contract_instance", + "durability": "persistent" + } + }, + [ + { + "last_modified_ledger_seq": 0, + "data": { + "contract_data": { + "ext": "v0", + "contract": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD2KM", + "key": "ledger_key_contract_instance", + "durability": "persistent", + "val": { + "contract_instance": { + "executable": { + "wasm": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855" + }, + "storage": [ + { + "key": { + "vec": [ + { + "symbol": "TotalSupply" + } + ] + }, + "val": { + "i128": { + "hi": 0, + "lo": 100 + } + } + } + ] + } + } + } + }, + "ext": "v0" + }, + 120960 + ] + ], + [ + { + "contract_data": { + "contract": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFCT4", + "key": { + "ledger_key_nonce": { + "nonce": 801925984706572462 + } + }, + "durability": "temporary" + } + }, + [ + { + "last_modified_ledger_seq": 0, + "data": { + "contract_data": { + "ext": "v0", + "contract": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFCT4", + "key": { + "ledger_key_nonce": { + "nonce": 801925984706572462 + } + }, + "durability": "temporary", + "val": "void" + } + }, + "ext": "v0" + }, + 6311999 + ] + ], + [ + { + "contract_data": { + "contract": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAHK3M", + "key": { + "ledger_key_nonce": { + "nonce": 5541220902715666415 + } + }, + "durability": "temporary" + } + }, + [ + { + "last_modified_ledger_seq": 0, + "data": { + "contract_data": { + "ext": "v0", + "contract": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAHK3M", + "key": { + "ledger_key_nonce": { + "nonce": 5541220902715666415 + } + }, + "durability": "temporary", + "val": "void" + } + }, + "ext": "v0" + }, + 6311999 + ] + ], + [ + { + "contract_code": { + "hash": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855" + } + }, + [ + { + "last_modified_ledger_seq": 0, + "data": { + "contract_code": { + "ext": "v0", + "hash": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", + "code": "" + } + }, + "ext": "v0" + }, + 120960 + ] + ] + ] + }, + "events": [ + { + "event": { + "ext": "v0", + "contract_id": "0000000000000000000000000000000000000000000000000000000000000001", + "type_": "contract", + "body": { + "v0": { + "topics": [ + { + "symbol": "approve" + }, + { + "address": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFCT4" + }, + { + "address": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAHK3M" + } + ], + "data": { + "vec": [ + { + "i128": { + "hi": 0, + "lo": 50 + } + }, + { + "u32": 1000 + } + ] + } + } + } + }, + "failed_call": false + }, + { + "event": { + "ext": "v0", + "contract_id": "0000000000000000000000000000000000000000000000000000000000000001", + "type_": "contract", + "body": { + "v0": { + "topics": [ + { + "symbol": "transfer" + }, + { + "address": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFCT4" + }, + { + "address": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAITA4" + } + ], + "data": { + "i128": { + "hi": 0, + "lo": 30 + } + } + } + } + }, + "failed_call": false + } + ] +} \ No newline at end of file diff --git a/contracts/token/fungible/test_snapshots/test/approve_handles_expiry.1.json b/contracts/token/fungible/test_snapshots/test/approve_handles_expiry.1.json new file mode 100644 index 0000000..086d0f4 --- /dev/null +++ b/contracts/token/fungible/test_snapshots/test/approve_handles_expiry.1.json @@ -0,0 +1,259 @@ +{ + "generators": { + "address": 3, + "nonce": 0 + }, + "auth": [ + [], + [ + [ + "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFCT4", + { + "function": { + "contract_fn": { + "contract_address": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD2KM", + "function_name": "", + "args": [] + } + }, + "sub_invocations": [] + } + ] + ] + ], + "ledger": { + "protocol_version": 22, + "sequence_number": 3, + "timestamp": 0, + "network_id": "0000000000000000000000000000000000000000000000000000000000000000", + "base_reserve": 0, + "min_persistent_entry_ttl": 4096, + "min_temp_entry_ttl": 16, + "max_entry_ttl": 6312000, + "ledger_entries": [ + [ + { + "contract_data": { + "contract": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD2KM", + "key": { + "vec": [ + { + "symbol": "Allowance" + }, + { + "map": [ + { + "key": { + "symbol": "owner" + }, + "val": { + "address": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFCT4" + } + }, + { + "key": { + "symbol": "spender" + }, + "val": { + "address": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAHK3M" + } + } + ] + } + ] + }, + "durability": "temporary" + } + }, + [ + { + "last_modified_ledger_seq": 0, + "data": { + "contract_data": { + "ext": "v0", + "contract": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD2KM", + "key": { + "vec": [ + { + "symbol": "Allowance" + }, + { + "map": [ + { + "key": { + "symbol": "owner" + }, + "val": { + "address": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFCT4" + } + }, + { + "key": { + "symbol": "spender" + }, + "val": { + "address": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAHK3M" + } + } + ] + } + ] + }, + "durability": "temporary", + "val": { + "map": [ + { + "key": { + "symbol": "live_until_ledger" + }, + "val": { + "u32": 2 + } + }, + { + "key": { + "symbol": "value" + }, + "val": { + "i128": { + "hi": 0, + "lo": 50 + } + } + } + ] + } + } + }, + "ext": "v0" + }, + 15 + ] + ], + [ + { + "contract_data": { + "contract": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD2KM", + "key": "ledger_key_contract_instance", + "durability": "persistent" + } + }, + [ + { + "last_modified_ledger_seq": 0, + "data": { + "contract_data": { + "ext": "v0", + "contract": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD2KM", + "key": "ledger_key_contract_instance", + "durability": "persistent", + "val": { + "contract_instance": { + "executable": { + "wasm": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855" + }, + "storage": null + } + } + } + }, + "ext": "v0" + }, + 4095 + ] + ], + [ + { + "contract_data": { + "contract": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFCT4", + "key": { + "ledger_key_nonce": { + "nonce": 801925984706572462 + } + }, + "durability": "temporary" + } + }, + [ + { + "last_modified_ledger_seq": 0, + "data": { + "contract_data": { + "ext": "v0", + "contract": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFCT4", + "key": { + "ledger_key_nonce": { + "nonce": 801925984706572462 + } + }, + "durability": "temporary", + "val": "void" + } + }, + "ext": "v0" + }, + 6311999 + ] + ], + [ + { + "contract_code": { + "hash": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855" + } + }, + [ + { + "last_modified_ledger_seq": 0, + "data": { + "contract_code": { + "ext": "v0", + "hash": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", + "code": "" + } + }, + "ext": "v0" + }, + 4095 + ] + ] + ] + }, + "events": [ + { + "event": { + "ext": "v0", + "contract_id": "0000000000000000000000000000000000000000000000000000000000000001", + "type_": "contract", + "body": { + "v0": { + "topics": [ + { + "symbol": "approve" + }, + { + "address": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFCT4" + }, + { + "address": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAHK3M" + } + ], + "data": { + "vec": [ + { + "i128": { + "hi": 0, + "lo": 50 + } + }, + { + "u32": 2 + } + ] + } + } + } + }, + "failed_call": false + } + ] +} \ No newline at end of file diff --git a/contracts/token/fungible/test_snapshots/test/approve_with_event.1.json b/contracts/token/fungible/test_snapshots/test/approve_with_event.1.json new file mode 100644 index 0000000..dfe9b1a --- /dev/null +++ b/contracts/token/fungible/test_snapshots/test/approve_with_event.1.json @@ -0,0 +1,259 @@ +{ + "generators": { + "address": 3, + "nonce": 0 + }, + "auth": [ + [], + [ + [ + "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFCT4", + { + "function": { + "contract_fn": { + "contract_address": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD2KM", + "function_name": "", + "args": [] + } + }, + "sub_invocations": [] + } + ] + ] + ], + "ledger": { + "protocol_version": 22, + "sequence_number": 0, + "timestamp": 0, + "network_id": "0000000000000000000000000000000000000000000000000000000000000000", + "base_reserve": 0, + "min_persistent_entry_ttl": 4096, + "min_temp_entry_ttl": 16, + "max_entry_ttl": 6312000, + "ledger_entries": [ + [ + { + "contract_data": { + "contract": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD2KM", + "key": { + "vec": [ + { + "symbol": "Allowance" + }, + { + "map": [ + { + "key": { + "symbol": "owner" + }, + "val": { + "address": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFCT4" + } + }, + { + "key": { + "symbol": "spender" + }, + "val": { + "address": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAHK3M" + } + } + ] + } + ] + }, + "durability": "temporary" + } + }, + [ + { + "last_modified_ledger_seq": 0, + "data": { + "contract_data": { + "ext": "v0", + "contract": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD2KM", + "key": { + "vec": [ + { + "symbol": "Allowance" + }, + { + "map": [ + { + "key": { + "symbol": "owner" + }, + "val": { + "address": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFCT4" + } + }, + { + "key": { + "symbol": "spender" + }, + "val": { + "address": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAHK3M" + } + } + ] + } + ] + }, + "durability": "temporary", + "val": { + "map": [ + { + "key": { + "symbol": "live_until_ledger" + }, + "val": { + "u32": 1000 + } + }, + { + "key": { + "symbol": "value" + }, + "val": { + "i128": { + "hi": 0, + "lo": 50 + } + } + } + ] + } + } + }, + "ext": "v0" + }, + 1000 + ] + ], + [ + { + "contract_data": { + "contract": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD2KM", + "key": "ledger_key_contract_instance", + "durability": "persistent" + } + }, + [ + { + "last_modified_ledger_seq": 0, + "data": { + "contract_data": { + "ext": "v0", + "contract": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD2KM", + "key": "ledger_key_contract_instance", + "durability": "persistent", + "val": { + "contract_instance": { + "executable": { + "wasm": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855" + }, + "storage": null + } + } + } + }, + "ext": "v0" + }, + 4095 + ] + ], + [ + { + "contract_data": { + "contract": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFCT4", + "key": { + "ledger_key_nonce": { + "nonce": 801925984706572462 + } + }, + "durability": "temporary" + } + }, + [ + { + "last_modified_ledger_seq": 0, + "data": { + "contract_data": { + "ext": "v0", + "contract": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFCT4", + "key": { + "ledger_key_nonce": { + "nonce": 801925984706572462 + } + }, + "durability": "temporary", + "val": "void" + } + }, + "ext": "v0" + }, + 6311999 + ] + ], + [ + { + "contract_code": { + "hash": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855" + } + }, + [ + { + "last_modified_ledger_seq": 0, + "data": { + "contract_code": { + "ext": "v0", + "hash": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", + "code": "" + } + }, + "ext": "v0" + }, + 4095 + ] + ] + ] + }, + "events": [ + { + "event": { + "ext": "v0", + "contract_id": "0000000000000000000000000000000000000000000000000000000000000001", + "type_": "contract", + "body": { + "v0": { + "topics": [ + { + "symbol": "approve" + }, + { + "address": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFCT4" + }, + { + "address": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAHK3M" + } + ], + "data": { + "vec": [ + { + "i128": { + "hi": 0, + "lo": 50 + } + }, + { + "u32": 1000 + } + ] + } + } + } + }, + "failed_call": false + } + ] +} \ No newline at end of file diff --git a/contracts/token/fungible/test_snapshots/test/bump_instance_works.1.json b/contracts/token/fungible/test_snapshots/test/bump_instance_works.1.json new file mode 100644 index 0000000..d8aa36c --- /dev/null +++ b/contracts/token/fungible/test_snapshots/test/bump_instance_works.1.json @@ -0,0 +1,76 @@ +{ + "generators": { + "address": 1, + "nonce": 0 + }, + "auth": [ + [], + [] + ], + "ledger": { + "protocol_version": 22, + "sequence_number": 499, + "timestamp": 0, + "network_id": "0000000000000000000000000000000000000000000000000000000000000000", + "base_reserve": 0, + "min_persistent_entry_ttl": 500, + "min_temp_entry_ttl": 16, + "max_entry_ttl": 6312000, + "ledger_entries": [ + [ + { + "contract_data": { + "contract": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD2KM", + "key": "ledger_key_contract_instance", + "durability": "persistent" + } + }, + [ + { + "last_modified_ledger_seq": 0, + "data": { + "contract_data": { + "ext": "v0", + "contract": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD2KM", + "key": "ledger_key_contract_instance", + "durability": "persistent", + "val": { + "contract_instance": { + "executable": { + "wasm": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855" + }, + "storage": null + } + } + } + }, + "ext": "v0" + }, + 121459 + ] + ], + [ + { + "contract_code": { + "hash": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855" + } + }, + [ + { + "last_modified_ledger_seq": 0, + "data": { + "contract_code": { + "ext": "v0", + "hash": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", + "code": "" + } + }, + "ext": "v0" + }, + 121459 + ] + ] + ] + }, + "events": [] +} \ No newline at end of file diff --git a/contracts/token/fungible/test_snapshots/test/burn_works.1.json b/contracts/token/fungible/test_snapshots/test/burn_works.1.json new file mode 100644 index 0000000..b14185c --- /dev/null +++ b/contracts/token/fungible/test_snapshots/test/burn_works.1.json @@ -0,0 +1,140 @@ +{ + "generators": { + "address": 2, + "nonce": 0 + }, + "auth": [ + [], + [] + ], + "ledger": { + "protocol_version": 22, + "sequence_number": 0, + "timestamp": 0, + "network_id": "0000000000000000000000000000000000000000000000000000000000000000", + "base_reserve": 0, + "min_persistent_entry_ttl": 4096, + "min_temp_entry_ttl": 16, + "max_entry_ttl": 6312000, + "ledger_entries": [ + [ + { + "contract_data": { + "contract": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD2KM", + "key": { + "vec": [ + { + "symbol": "Balance" + }, + { + "address": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFCT4" + } + ] + }, + "durability": "persistent" + } + }, + [ + { + "last_modified_ledger_seq": 0, + "data": { + "contract_data": { + "ext": "v0", + "contract": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD2KM", + "key": { + "vec": [ + { + "symbol": "Balance" + }, + { + "address": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFCT4" + } + ] + }, + "durability": "persistent", + "val": { + "i128": { + "hi": 0, + "lo": 50 + } + } + } + }, + "ext": "v0" + }, + 518400 + ] + ], + [ + { + "contract_data": { + "contract": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD2KM", + "key": "ledger_key_contract_instance", + "durability": "persistent" + } + }, + [ + { + "last_modified_ledger_seq": 0, + "data": { + "contract_data": { + "ext": "v0", + "contract": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD2KM", + "key": "ledger_key_contract_instance", + "durability": "persistent", + "val": { + "contract_instance": { + "executable": { + "wasm": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855" + }, + "storage": [ + { + "key": { + "vec": [ + { + "symbol": "TotalSupply" + } + ] + }, + "val": { + "i128": { + "hi": 0, + "lo": 50 + } + } + } + ] + } + } + } + }, + "ext": "v0" + }, + 120960 + ] + ], + [ + { + "contract_code": { + "hash": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855" + } + }, + [ + { + "last_modified_ledger_seq": 0, + "data": { + "contract_code": { + "ext": "v0", + "hash": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", + "code": "" + } + }, + "ext": "v0" + }, + 120960 + ] + ] + ] + }, + "events": [] +} \ No newline at end of file diff --git a/contracts/token/fungible/test_snapshots/test/extend_balance_ttl_thru_transfer.1.json b/contracts/token/fungible/test_snapshots/test/extend_balance_ttl_thru_transfer.1.json new file mode 100644 index 0000000..6bc2f45 --- /dev/null +++ b/contracts/token/fungible/test_snapshots/test/extend_balance_ttl_thru_transfer.1.json @@ -0,0 +1,265 @@ +{ + "generators": { + "address": 3, + "nonce": 0 + }, + "auth": [ + [], + [ + [ + "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFCT4", + { + "function": { + "contract_fn": { + "contract_address": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD2KM", + "function_name": "", + "args": [] + } + }, + "sub_invocations": [] + } + ] + ] + ], + "ledger": { + "protocol_version": 22, + "sequence_number": 4095, + "timestamp": 0, + "network_id": "0000000000000000000000000000000000000000000000000000000000000000", + "base_reserve": 0, + "min_persistent_entry_ttl": 4096, + "min_temp_entry_ttl": 16, + "max_entry_ttl": 6312000, + "ledger_entries": [ + [ + { + "contract_data": { + "contract": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD2KM", + "key": { + "vec": [ + { + "symbol": "Balance" + }, + { + "address": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFCT4" + } + ] + }, + "durability": "persistent" + } + }, + [ + { + "last_modified_ledger_seq": 0, + "data": { + "contract_data": { + "ext": "v0", + "contract": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD2KM", + "key": { + "vec": [ + { + "symbol": "Balance" + }, + { + "address": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFCT4" + } + ] + }, + "durability": "persistent", + "val": { + "i128": { + "hi": 0, + "lo": 50 + } + } + } + }, + "ext": "v0" + }, + 522495 + ] + ], + [ + { + "contract_data": { + "contract": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD2KM", + "key": { + "vec": [ + { + "symbol": "Balance" + }, + { + "address": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAHK3M" + } + ] + }, + "durability": "persistent" + } + }, + [ + { + "last_modified_ledger_seq": 0, + "data": { + "contract_data": { + "ext": "v0", + "contract": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD2KM", + "key": { + "vec": [ + { + "symbol": "Balance" + }, + { + "address": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAHK3M" + } + ] + }, + "durability": "persistent", + "val": { + "i128": { + "hi": 0, + "lo": 50 + } + } + } + }, + "ext": "v0" + }, + 8190 + ] + ], + [ + { + "contract_data": { + "contract": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD2KM", + "key": "ledger_key_contract_instance", + "durability": "persistent" + } + }, + [ + { + "last_modified_ledger_seq": 0, + "data": { + "contract_data": { + "ext": "v0", + "contract": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD2KM", + "key": "ledger_key_contract_instance", + "durability": "persistent", + "val": { + "contract_instance": { + "executable": { + "wasm": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855" + }, + "storage": [ + { + "key": { + "vec": [ + { + "symbol": "TotalSupply" + } + ] + }, + "val": { + "i128": { + "hi": 0, + "lo": 100 + } + } + } + ] + } + } + } + }, + "ext": "v0" + }, + 120960 + ] + ], + [ + { + "contract_data": { + "contract": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFCT4", + "key": { + "ledger_key_nonce": { + "nonce": 801925984706572462 + } + }, + "durability": "temporary" + } + }, + [ + { + "last_modified_ledger_seq": 0, + "data": { + "contract_data": { + "ext": "v0", + "contract": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFCT4", + "key": { + "ledger_key_nonce": { + "nonce": 801925984706572462 + } + }, + "durability": "temporary", + "val": "void" + } + }, + "ext": "v0" + }, + 6316094 + ] + ], + [ + { + "contract_code": { + "hash": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855" + } + }, + [ + { + "last_modified_ledger_seq": 0, + "data": { + "contract_code": { + "ext": "v0", + "hash": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", + "code": "" + } + }, + "ext": "v0" + }, + 120960 + ] + ] + ] + }, + "events": [ + { + "event": { + "ext": "v0", + "contract_id": "0000000000000000000000000000000000000000000000000000000000000001", + "type_": "contract", + "body": { + "v0": { + "topics": [ + { + "symbol": "transfer" + }, + { + "address": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFCT4" + }, + { + "address": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAHK3M" + } + ], + "data": { + "i128": { + "hi": 0, + "lo": 50 + } + } + } + } + }, + "failed_call": false + } + ] +} \ No newline at end of file diff --git a/contracts/token/fungible/test_snapshots/test/initial_state.1.json b/contracts/token/fungible/test_snapshots/test/initial_state.1.json new file mode 100644 index 0000000..ebf9274 --- /dev/null +++ b/contracts/token/fungible/test_snapshots/test/initial_state.1.json @@ -0,0 +1,76 @@ +{ + "generators": { + "address": 2, + "nonce": 0 + }, + "auth": [ + [], + [] + ], + "ledger": { + "protocol_version": 22, + "sequence_number": 0, + "timestamp": 0, + "network_id": "0000000000000000000000000000000000000000000000000000000000000000", + "base_reserve": 0, + "min_persistent_entry_ttl": 4096, + "min_temp_entry_ttl": 16, + "max_entry_ttl": 6312000, + "ledger_entries": [ + [ + { + "contract_data": { + "contract": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD2KM", + "key": "ledger_key_contract_instance", + "durability": "persistent" + } + }, + [ + { + "last_modified_ledger_seq": 0, + "data": { + "contract_data": { + "ext": "v0", + "contract": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD2KM", + "key": "ledger_key_contract_instance", + "durability": "persistent", + "val": { + "contract_instance": { + "executable": { + "wasm": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855" + }, + "storage": null + } + } + } + }, + "ext": "v0" + }, + 120960 + ] + ], + [ + { + "contract_code": { + "hash": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855" + } + }, + [ + { + "last_modified_ledger_seq": 0, + "data": { + "contract_code": { + "ext": "v0", + "hash": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", + "code": "" + } + }, + "ext": "v0" + }, + 120960 + ] + ] + ] + }, + "events": [] +} \ No newline at end of file diff --git a/contracts/token/fungible/test_snapshots/test/mint_works.1.json b/contracts/token/fungible/test_snapshots/test/mint_works.1.json new file mode 100644 index 0000000..7cea01f --- /dev/null +++ b/contracts/token/fungible/test_snapshots/test/mint_works.1.json @@ -0,0 +1,140 @@ +{ + "generators": { + "address": 2, + "nonce": 0 + }, + "auth": [ + [], + [] + ], + "ledger": { + "protocol_version": 22, + "sequence_number": 0, + "timestamp": 0, + "network_id": "0000000000000000000000000000000000000000000000000000000000000000", + "base_reserve": 0, + "min_persistent_entry_ttl": 4096, + "min_temp_entry_ttl": 16, + "max_entry_ttl": 6312000, + "ledger_entries": [ + [ + { + "contract_data": { + "contract": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD2KM", + "key": { + "vec": [ + { + "symbol": "Balance" + }, + { + "address": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFCT4" + } + ] + }, + "durability": "persistent" + } + }, + [ + { + "last_modified_ledger_seq": 0, + "data": { + "contract_data": { + "ext": "v0", + "contract": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD2KM", + "key": { + "vec": [ + { + "symbol": "Balance" + }, + { + "address": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFCT4" + } + ] + }, + "durability": "persistent", + "val": { + "i128": { + "hi": 0, + "lo": 100 + } + } + } + }, + "ext": "v0" + }, + 518400 + ] + ], + [ + { + "contract_data": { + "contract": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD2KM", + "key": "ledger_key_contract_instance", + "durability": "persistent" + } + }, + [ + { + "last_modified_ledger_seq": 0, + "data": { + "contract_data": { + "ext": "v0", + "contract": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD2KM", + "key": "ledger_key_contract_instance", + "durability": "persistent", + "val": { + "contract_instance": { + "executable": { + "wasm": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855" + }, + "storage": [ + { + "key": { + "vec": [ + { + "symbol": "TotalSupply" + } + ] + }, + "val": { + "i128": { + "hi": 0, + "lo": 100 + } + } + } + ] + } + } + } + }, + "ext": "v0" + }, + 120960 + ] + ], + [ + { + "contract_code": { + "hash": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855" + } + }, + [ + { + "last_modified_ledger_seq": 0, + "data": { + "contract_code": { + "ext": "v0", + "hash": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", + "code": "" + } + }, + "ext": "v0" + }, + 120960 + ] + ] + ] + }, + "events": [] +} \ No newline at end of file diff --git a/contracts/token/fungible/test_snapshots/test/set_allowance_with_expired_ledger_fails.1.json b/contracts/token/fungible/test_snapshots/test/set_allowance_with_expired_ledger_fails.1.json new file mode 100644 index 0000000..2c1541f --- /dev/null +++ b/contracts/token/fungible/test_snapshots/test/set_allowance_with_expired_ledger_fails.1.json @@ -0,0 +1,75 @@ +{ + "generators": { + "address": 3, + "nonce": 0 + }, + "auth": [ + [] + ], + "ledger": { + "protocol_version": 22, + "sequence_number": 10, + "timestamp": 0, + "network_id": "0000000000000000000000000000000000000000000000000000000000000000", + "base_reserve": 0, + "min_persistent_entry_ttl": 4096, + "min_temp_entry_ttl": 16, + "max_entry_ttl": 6312000, + "ledger_entries": [ + [ + { + "contract_data": { + "contract": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD2KM", + "key": "ledger_key_contract_instance", + "durability": "persistent" + } + }, + [ + { + "last_modified_ledger_seq": 0, + "data": { + "contract_data": { + "ext": "v0", + "contract": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD2KM", + "key": "ledger_key_contract_instance", + "durability": "persistent", + "val": { + "contract_instance": { + "executable": { + "wasm": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855" + }, + "storage": null + } + } + } + }, + "ext": "v0" + }, + 4095 + ] + ], + [ + { + "contract_code": { + "hash": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855" + } + }, + [ + { + "last_modified_ledger_seq": 0, + "data": { + "contract_code": { + "ext": "v0", + "hash": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", + "code": "" + } + }, + "ext": "v0" + }, + 4095 + ] + ] + ] + }, + "events": [] +} \ No newline at end of file diff --git a/contracts/token/fungible/test_snapshots/test/set_allowance_with_zero_value.1.json b/contracts/token/fungible/test_snapshots/test/set_allowance_with_zero_value.1.json new file mode 100644 index 0000000..f0f4991 --- /dev/null +++ b/contracts/token/fungible/test_snapshots/test/set_allowance_with_zero_value.1.json @@ -0,0 +1,274 @@ +{ + "generators": { + "address": 4, + "nonce": 0 + }, + "auth": [ + [], + [] + ], + "ledger": { + "protocol_version": 22, + "sequence_number": 10, + "timestamp": 0, + "network_id": "0000000000000000000000000000000000000000000000000000000000000000", + "base_reserve": 0, + "min_persistent_entry_ttl": 4096, + "min_temp_entry_ttl": 16, + "max_entry_ttl": 6312000, + "ledger_entries": [ + [ + { + "contract_data": { + "contract": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD2KM", + "key": { + "vec": [ + { + "symbol": "Allowance" + }, + { + "map": [ + { + "key": { + "symbol": "owner" + }, + "val": { + "address": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFCT4" + } + }, + { + "key": { + "symbol": "spender" + }, + "val": { + "address": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAITA4" + } + } + ] + } + ] + }, + "durability": "temporary" + } + }, + [ + { + "last_modified_ledger_seq": 0, + "data": { + "contract_data": { + "ext": "v0", + "contract": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD2KM", + "key": { + "vec": [ + { + "symbol": "Allowance" + }, + { + "map": [ + { + "key": { + "symbol": "owner" + }, + "val": { + "address": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFCT4" + } + }, + { + "key": { + "symbol": "spender" + }, + "val": { + "address": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAITA4" + } + } + ] + } + ] + }, + "durability": "temporary", + "val": { + "map": [ + { + "key": { + "symbol": "live_until_ledger" + }, + "val": { + "u32": 5 + } + }, + { + "key": { + "symbol": "value" + }, + "val": { + "i128": { + "hi": 0, + "lo": 0 + } + } + } + ] + } + } + }, + "ext": "v0" + }, + 15 + ] + ], + [ + { + "contract_data": { + "contract": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD2KM", + "key": { + "vec": [ + { + "symbol": "Allowance" + }, + { + "map": [ + { + "key": { + "symbol": "owner" + }, + "val": { + "address": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAHK3M" + } + }, + { + "key": { + "symbol": "spender" + }, + "val": { + "address": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAITA4" + } + } + ] + } + ] + }, + "durability": "temporary" + } + }, + [ + { + "last_modified_ledger_seq": 0, + "data": { + "contract_data": { + "ext": "v0", + "contract": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD2KM", + "key": { + "vec": [ + { + "symbol": "Allowance" + }, + { + "map": [ + { + "key": { + "symbol": "owner" + }, + "val": { + "address": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAHK3M" + } + }, + { + "key": { + "symbol": "spender" + }, + "val": { + "address": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAITA4" + } + } + ] + } + ] + }, + "durability": "temporary", + "val": { + "map": [ + { + "key": { + "symbol": "live_until_ledger" + }, + "val": { + "u32": 5 + } + }, + { + "key": { + "symbol": "value" + }, + "val": { + "i128": { + "hi": 0, + "lo": 0 + } + } + } + ] + } + } + }, + "ext": "v0" + }, + 25 + ] + ], + [ + { + "contract_data": { + "contract": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD2KM", + "key": "ledger_key_contract_instance", + "durability": "persistent" + } + }, + [ + { + "last_modified_ledger_seq": 0, + "data": { + "contract_data": { + "ext": "v0", + "contract": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD2KM", + "key": "ledger_key_contract_instance", + "durability": "persistent", + "val": { + "contract_instance": { + "executable": { + "wasm": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855" + }, + "storage": null + } + } + } + }, + "ext": "v0" + }, + 4095 + ] + ], + [ + { + "contract_code": { + "hash": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855" + } + }, + [ + { + "last_modified_ledger_seq": 0, + "data": { + "contract_code": { + "ext": "v0", + "hash": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", + "code": "" + } + }, + "ext": "v0" + }, + 4095 + ] + ] + ] + }, + "events": [] +} \ No newline at end of file diff --git a/contracts/token/fungible/test_snapshots/test/spend_allowance_insufficient_allowance_fails.1.json b/contracts/token/fungible/test_snapshots/test/spend_allowance_insufficient_allowance_fails.1.json new file mode 100644 index 0000000..be3f9ca --- /dev/null +++ b/contracts/token/fungible/test_snapshots/test/spend_allowance_insufficient_allowance_fails.1.json @@ -0,0 +1,244 @@ +{ + "generators": { + "address": 3, + "nonce": 0 + }, + "auth": [ + [] + ], + "ledger": { + "protocol_version": 22, + "sequence_number": 0, + "timestamp": 0, + "network_id": "0000000000000000000000000000000000000000000000000000000000000000", + "base_reserve": 0, + "min_persistent_entry_ttl": 4096, + "min_temp_entry_ttl": 16, + "max_entry_ttl": 6312000, + "ledger_entries": [ + [ + { + "contract_data": { + "contract": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD2KM", + "key": { + "vec": [ + { + "symbol": "Allowance" + }, + { + "map": [ + { + "key": { + "symbol": "owner" + }, + "val": { + "address": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFCT4" + } + }, + { + "key": { + "symbol": "spender" + }, + "val": { + "address": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAHK3M" + } + } + ] + } + ] + }, + "durability": "temporary" + } + }, + [ + { + "last_modified_ledger_seq": 0, + "data": { + "contract_data": { + "ext": "v0", + "contract": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD2KM", + "key": { + "vec": [ + { + "symbol": "Allowance" + }, + { + "map": [ + { + "key": { + "symbol": "owner" + }, + "val": { + "address": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFCT4" + } + }, + { + "key": { + "symbol": "spender" + }, + "val": { + "address": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAHK3M" + } + } + ] + } + ] + }, + "durability": "temporary", + "val": { + "map": [ + { + "key": { + "symbol": "live_until_ledger" + }, + "val": { + "u32": 1000 + } + }, + { + "key": { + "symbol": "value" + }, + "val": { + "i128": { + "hi": 0, + "lo": 10 + } + } + } + ] + } + } + }, + "ext": "v0" + }, + 1000 + ] + ], + [ + { + "contract_data": { + "contract": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD2KM", + "key": "ledger_key_contract_instance", + "durability": "persistent" + } + }, + [ + { + "last_modified_ledger_seq": 0, + "data": { + "contract_data": { + "ext": "v0", + "contract": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD2KM", + "key": "ledger_key_contract_instance", + "durability": "persistent", + "val": { + "contract_instance": { + "executable": { + "wasm": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855" + }, + "storage": null + } + } + } + }, + "ext": "v0" + }, + 4095 + ] + ], + [ + { + "contract_data": { + "contract": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFCT4", + "key": { + "ledger_key_nonce": { + "nonce": 801925984706572462 + } + }, + "durability": "temporary" + } + }, + [ + { + "last_modified_ledger_seq": 0, + "data": { + "contract_data": { + "ext": "v0", + "contract": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFCT4", + "key": { + "ledger_key_nonce": { + "nonce": 801925984706572462 + } + }, + "durability": "temporary", + "val": "void" + } + }, + "ext": "v0" + }, + 6311999 + ] + ], + [ + { + "contract_code": { + "hash": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855" + } + }, + [ + { + "last_modified_ledger_seq": 0, + "data": { + "contract_code": { + "ext": "v0", + "hash": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", + "code": "" + } + }, + "ext": "v0" + }, + 4095 + ] + ] + ] + }, + "events": [ + { + "event": { + "ext": "v0", + "contract_id": "0000000000000000000000000000000000000000000000000000000000000001", + "type_": "contract", + "body": { + "v0": { + "topics": [ + { + "symbol": "approve" + }, + { + "address": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFCT4" + }, + { + "address": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAHK3M" + } + ], + "data": { + "vec": [ + { + "i128": { + "hi": 0, + "lo": 10 + } + }, + { + "u32": 1000 + } + ] + } + } + } + }, + "failed_call": false + } + ] +} \ No newline at end of file diff --git a/contracts/token/fungible/test_snapshots/test/spend_allowance_reduces_value.1.json b/contracts/token/fungible/test_snapshots/test/spend_allowance_reduces_value.1.json new file mode 100644 index 0000000..b330269 --- /dev/null +++ b/contracts/token/fungible/test_snapshots/test/spend_allowance_reduces_value.1.json @@ -0,0 +1,259 @@ +{ + "generators": { + "address": 3, + "nonce": 0 + }, + "auth": [ + [], + [ + [ + "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFCT4", + { + "function": { + "contract_fn": { + "contract_address": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD2KM", + "function_name": "", + "args": [] + } + }, + "sub_invocations": [] + } + ] + ] + ], + "ledger": { + "protocol_version": 22, + "sequence_number": 0, + "timestamp": 0, + "network_id": "0000000000000000000000000000000000000000000000000000000000000000", + "base_reserve": 0, + "min_persistent_entry_ttl": 4096, + "min_temp_entry_ttl": 16, + "max_entry_ttl": 6312000, + "ledger_entries": [ + [ + { + "contract_data": { + "contract": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD2KM", + "key": { + "vec": [ + { + "symbol": "Allowance" + }, + { + "map": [ + { + "key": { + "symbol": "owner" + }, + "val": { + "address": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFCT4" + } + }, + { + "key": { + "symbol": "spender" + }, + "val": { + "address": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAHK3M" + } + } + ] + } + ] + }, + "durability": "temporary" + } + }, + [ + { + "last_modified_ledger_seq": 0, + "data": { + "contract_data": { + "ext": "v0", + "contract": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD2KM", + "key": { + "vec": [ + { + "symbol": "Allowance" + }, + { + "map": [ + { + "key": { + "symbol": "owner" + }, + "val": { + "address": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFCT4" + } + }, + { + "key": { + "symbol": "spender" + }, + "val": { + "address": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAHK3M" + } + } + ] + } + ] + }, + "durability": "temporary", + "val": { + "map": [ + { + "key": { + "symbol": "live_until_ledger" + }, + "val": { + "u32": 1000 + } + }, + { + "key": { + "symbol": "value" + }, + "val": { + "i128": { + "hi": 0, + "lo": 30 + } + } + } + ] + } + } + }, + "ext": "v0" + }, + 1000 + ] + ], + [ + { + "contract_data": { + "contract": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD2KM", + "key": "ledger_key_contract_instance", + "durability": "persistent" + } + }, + [ + { + "last_modified_ledger_seq": 0, + "data": { + "contract_data": { + "ext": "v0", + "contract": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD2KM", + "key": "ledger_key_contract_instance", + "durability": "persistent", + "val": { + "contract_instance": { + "executable": { + "wasm": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855" + }, + "storage": null + } + } + } + }, + "ext": "v0" + }, + 4095 + ] + ], + [ + { + "contract_data": { + "contract": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFCT4", + "key": { + "ledger_key_nonce": { + "nonce": 801925984706572462 + } + }, + "durability": "temporary" + } + }, + [ + { + "last_modified_ledger_seq": 0, + "data": { + "contract_data": { + "ext": "v0", + "contract": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFCT4", + "key": { + "ledger_key_nonce": { + "nonce": 801925984706572462 + } + }, + "durability": "temporary", + "val": "void" + } + }, + "ext": "v0" + }, + 6311999 + ] + ], + [ + { + "contract_code": { + "hash": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855" + } + }, + [ + { + "last_modified_ledger_seq": 0, + "data": { + "contract_code": { + "ext": "v0", + "hash": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", + "code": "" + } + }, + "ext": "v0" + }, + 4095 + ] + ] + ] + }, + "events": [ + { + "event": { + "ext": "v0", + "contract_id": "0000000000000000000000000000000000000000000000000000000000000001", + "type_": "contract", + "body": { + "v0": { + "topics": [ + { + "symbol": "approve" + }, + { + "address": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFCT4" + }, + { + "address": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAHK3M" + } + ], + "data": { + "vec": [ + { + "i128": { + "hi": 0, + "lo": 50 + } + }, + { + "u32": 1000 + } + ] + } + } + } + }, + "failed_call": false + } + ] +} \ No newline at end of file diff --git a/contracts/token/fungible/test_snapshots/test/transfer_from_insufficient_allowance_fails.1.json b/contracts/token/fungible/test_snapshots/test/transfer_from_insufficient_allowance_fails.1.json new file mode 100644 index 0000000..82d57b8 --- /dev/null +++ b/contracts/token/fungible/test_snapshots/test/transfer_from_insufficient_allowance_fails.1.json @@ -0,0 +1,325 @@ +{ + "generators": { + "address": 4, + "nonce": 0 + }, + "auth": [ + [] + ], + "ledger": { + "protocol_version": 22, + "sequence_number": 0, + "timestamp": 0, + "network_id": "0000000000000000000000000000000000000000000000000000000000000000", + "base_reserve": 0, + "min_persistent_entry_ttl": 4096, + "min_temp_entry_ttl": 16, + "max_entry_ttl": 6312000, + "ledger_entries": [ + [ + { + "contract_data": { + "contract": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD2KM", + "key": { + "vec": [ + { + "symbol": "Allowance" + }, + { + "map": [ + { + "key": { + "symbol": "owner" + }, + "val": { + "address": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFCT4" + } + }, + { + "key": { + "symbol": "spender" + }, + "val": { + "address": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAHK3M" + } + } + ] + } + ] + }, + "durability": "temporary" + } + }, + [ + { + "last_modified_ledger_seq": 0, + "data": { + "contract_data": { + "ext": "v0", + "contract": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD2KM", + "key": { + "vec": [ + { + "symbol": "Allowance" + }, + { + "map": [ + { + "key": { + "symbol": "owner" + }, + "val": { + "address": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFCT4" + } + }, + { + "key": { + "symbol": "spender" + }, + "val": { + "address": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAHK3M" + } + } + ] + } + ] + }, + "durability": "temporary", + "val": { + "map": [ + { + "key": { + "symbol": "live_until_ledger" + }, + "val": { + "u32": 1000 + } + }, + { + "key": { + "symbol": "value" + }, + "val": { + "i128": { + "hi": 0, + "lo": 30 + } + } + } + ] + } + } + }, + "ext": "v0" + }, + 1000 + ] + ], + [ + { + "contract_data": { + "contract": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD2KM", + "key": { + "vec": [ + { + "symbol": "Balance" + }, + { + "address": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFCT4" + } + ] + }, + "durability": "persistent" + } + }, + [ + { + "last_modified_ledger_seq": 0, + "data": { + "contract_data": { + "ext": "v0", + "contract": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD2KM", + "key": { + "vec": [ + { + "symbol": "Balance" + }, + { + "address": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFCT4" + } + ] + }, + "durability": "persistent", + "val": { + "i128": { + "hi": 0, + "lo": 100 + } + } + } + }, + "ext": "v0" + }, + 4095 + ] + ], + [ + { + "contract_data": { + "contract": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD2KM", + "key": "ledger_key_contract_instance", + "durability": "persistent" + } + }, + [ + { + "last_modified_ledger_seq": 0, + "data": { + "contract_data": { + "ext": "v0", + "contract": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD2KM", + "key": "ledger_key_contract_instance", + "durability": "persistent", + "val": { + "contract_instance": { + "executable": { + "wasm": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855" + }, + "storage": null + } + } + } + }, + "ext": "v0" + }, + 120960 + ] + ], + [ + { + "contract_data": { + "contract": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFCT4", + "key": { + "ledger_key_nonce": { + "nonce": 801925984706572462 + } + }, + "durability": "temporary" + } + }, + [ + { + "last_modified_ledger_seq": 0, + "data": { + "contract_data": { + "ext": "v0", + "contract": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFCT4", + "key": { + "ledger_key_nonce": { + "nonce": 801925984706572462 + } + }, + "durability": "temporary", + "val": "void" + } + }, + "ext": "v0" + }, + 6311999 + ] + ], + [ + { + "contract_data": { + "contract": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAHK3M", + "key": { + "ledger_key_nonce": { + "nonce": 5541220902715666415 + } + }, + "durability": "temporary" + } + }, + [ + { + "last_modified_ledger_seq": 0, + "data": { + "contract_data": { + "ext": "v0", + "contract": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAHK3M", + "key": { + "ledger_key_nonce": { + "nonce": 5541220902715666415 + } + }, + "durability": "temporary", + "val": "void" + } + }, + "ext": "v0" + }, + 6311999 + ] + ], + [ + { + "contract_code": { + "hash": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855" + } + }, + [ + { + "last_modified_ledger_seq": 0, + "data": { + "contract_code": { + "ext": "v0", + "hash": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", + "code": "" + } + }, + "ext": "v0" + }, + 120960 + ] + ] + ] + }, + "events": [ + { + "event": { + "ext": "v0", + "contract_id": "0000000000000000000000000000000000000000000000000000000000000001", + "type_": "contract", + "body": { + "v0": { + "topics": [ + { + "symbol": "approve" + }, + { + "address": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFCT4" + }, + { + "address": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAHK3M" + } + ], + "data": { + "vec": [ + { + "i128": { + "hi": 0, + "lo": 30 + } + }, + { + "u32": 1000 + } + ] + } + } + } + }, + "failed_call": false + } + ] +} \ No newline at end of file diff --git a/contracts/token/fungible/test_snapshots/test/transfer_insufficient_balance_fails.1.json b/contracts/token/fungible/test_snapshots/test/transfer_insufficient_balance_fails.1.json new file mode 100644 index 0000000..cb2ff0e --- /dev/null +++ b/contracts/token/fungible/test_snapshots/test/transfer_insufficient_balance_fails.1.json @@ -0,0 +1,156 @@ +{ + "generators": { + "address": 3, + "nonce": 0 + }, + "auth": [ + [] + ], + "ledger": { + "protocol_version": 22, + "sequence_number": 0, + "timestamp": 0, + "network_id": "0000000000000000000000000000000000000000000000000000000000000000", + "base_reserve": 0, + "min_persistent_entry_ttl": 4096, + "min_temp_entry_ttl": 16, + "max_entry_ttl": 6312000, + "ledger_entries": [ + [ + { + "contract_data": { + "contract": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD2KM", + "key": { + "vec": [ + { + "symbol": "Balance" + }, + { + "address": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFCT4" + } + ] + }, + "durability": "persistent" + } + }, + [ + { + "last_modified_ledger_seq": 0, + "data": { + "contract_data": { + "ext": "v0", + "contract": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD2KM", + "key": { + "vec": [ + { + "symbol": "Balance" + }, + { + "address": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFCT4" + } + ] + }, + "durability": "persistent", + "val": { + "i128": { + "hi": 0, + "lo": 50 + } + } + } + }, + "ext": "v0" + }, + 518400 + ] + ], + [ + { + "contract_data": { + "contract": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD2KM", + "key": "ledger_key_contract_instance", + "durability": "persistent" + } + }, + [ + { + "last_modified_ledger_seq": 0, + "data": { + "contract_data": { + "ext": "v0", + "contract": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD2KM", + "key": "ledger_key_contract_instance", + "durability": "persistent", + "val": { + "contract_instance": { + "executable": { + "wasm": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855" + }, + "storage": null + } + } + } + }, + "ext": "v0" + }, + 120960 + ] + ], + [ + { + "contract_data": { + "contract": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFCT4", + "key": { + "ledger_key_nonce": { + "nonce": 801925984706572462 + } + }, + "durability": "temporary" + } + }, + [ + { + "last_modified_ledger_seq": 0, + "data": { + "contract_data": { + "ext": "v0", + "contract": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFCT4", + "key": { + "ledger_key_nonce": { + "nonce": 801925984706572462 + } + }, + "durability": "temporary", + "val": "void" + } + }, + "ext": "v0" + }, + 6311999 + ] + ], + [ + { + "contract_code": { + "hash": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855" + } + }, + [ + { + "last_modified_ledger_seq": 0, + "data": { + "contract_code": { + "ext": "v0", + "hash": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", + "code": "" + } + }, + "ext": "v0" + }, + 120960 + ] + ] + ] + }, + "events": [] +} \ No newline at end of file diff --git a/contracts/token/fungible/test_snapshots/test/transfer_works.1.json b/contracts/token/fungible/test_snapshots/test/transfer_works.1.json new file mode 100644 index 0000000..1e4cce6 --- /dev/null +++ b/contracts/token/fungible/test_snapshots/test/transfer_works.1.json @@ -0,0 +1,265 @@ +{ + "generators": { + "address": 3, + "nonce": 0 + }, + "auth": [ + [], + [ + [ + "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFCT4", + { + "function": { + "contract_fn": { + "contract_address": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD2KM", + "function_name": "", + "args": [] + } + }, + "sub_invocations": [] + } + ] + ] + ], + "ledger": { + "protocol_version": 22, + "sequence_number": 0, + "timestamp": 0, + "network_id": "0000000000000000000000000000000000000000000000000000000000000000", + "base_reserve": 0, + "min_persistent_entry_ttl": 4096, + "min_temp_entry_ttl": 16, + "max_entry_ttl": 6312000, + "ledger_entries": [ + [ + { + "contract_data": { + "contract": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD2KM", + "key": { + "vec": [ + { + "symbol": "Balance" + }, + { + "address": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFCT4" + } + ] + }, + "durability": "persistent" + } + }, + [ + { + "last_modified_ledger_seq": 0, + "data": { + "contract_data": { + "ext": "v0", + "contract": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD2KM", + "key": { + "vec": [ + { + "symbol": "Balance" + }, + { + "address": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFCT4" + } + ] + }, + "durability": "persistent", + "val": { + "i128": { + "hi": 0, + "lo": 50 + } + } + } + }, + "ext": "v0" + }, + 518400 + ] + ], + [ + { + "contract_data": { + "contract": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD2KM", + "key": { + "vec": [ + { + "symbol": "Balance" + }, + { + "address": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAHK3M" + } + ] + }, + "durability": "persistent" + } + }, + [ + { + "last_modified_ledger_seq": 0, + "data": { + "contract_data": { + "ext": "v0", + "contract": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD2KM", + "key": { + "vec": [ + { + "symbol": "Balance" + }, + { + "address": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAHK3M" + } + ] + }, + "durability": "persistent", + "val": { + "i128": { + "hi": 0, + "lo": 50 + } + } + } + }, + "ext": "v0" + }, + 518400 + ] + ], + [ + { + "contract_data": { + "contract": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD2KM", + "key": "ledger_key_contract_instance", + "durability": "persistent" + } + }, + [ + { + "last_modified_ledger_seq": 0, + "data": { + "contract_data": { + "ext": "v0", + "contract": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD2KM", + "key": "ledger_key_contract_instance", + "durability": "persistent", + "val": { + "contract_instance": { + "executable": { + "wasm": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855" + }, + "storage": [ + { + "key": { + "vec": [ + { + "symbol": "TotalSupply" + } + ] + }, + "val": { + "i128": { + "hi": 0, + "lo": 100 + } + } + } + ] + } + } + } + }, + "ext": "v0" + }, + 120960 + ] + ], + [ + { + "contract_data": { + "contract": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFCT4", + "key": { + "ledger_key_nonce": { + "nonce": 801925984706572462 + } + }, + "durability": "temporary" + } + }, + [ + { + "last_modified_ledger_seq": 0, + "data": { + "contract_data": { + "ext": "v0", + "contract": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFCT4", + "key": { + "ledger_key_nonce": { + "nonce": 801925984706572462 + } + }, + "durability": "temporary", + "val": "void" + } + }, + "ext": "v0" + }, + 6311999 + ] + ], + [ + { + "contract_code": { + "hash": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855" + } + }, + [ + { + "last_modified_ledger_seq": 0, + "data": { + "contract_code": { + "ext": "v0", + "hash": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", + "code": "" + } + }, + "ext": "v0" + }, + 120960 + ] + ] + ] + }, + "events": [ + { + "event": { + "ext": "v0", + "contract_id": "0000000000000000000000000000000000000000000000000000000000000001", + "type_": "contract", + "body": { + "v0": { + "topics": [ + { + "symbol": "transfer" + }, + { + "address": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFCT4" + }, + { + "address": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAHK3M" + } + ], + "data": { + "i128": { + "hi": 0, + "lo": 50 + } + } + } + } + }, + "failed_call": false + } + ] +} \ No newline at end of file diff --git a/contracts/token/fungible/test_snapshots/test/update_burns_tokens.1.json b/contracts/token/fungible/test_snapshots/test/update_burns_tokens.1.json new file mode 100644 index 0000000..b14185c --- /dev/null +++ b/contracts/token/fungible/test_snapshots/test/update_burns_tokens.1.json @@ -0,0 +1,140 @@ +{ + "generators": { + "address": 2, + "nonce": 0 + }, + "auth": [ + [], + [] + ], + "ledger": { + "protocol_version": 22, + "sequence_number": 0, + "timestamp": 0, + "network_id": "0000000000000000000000000000000000000000000000000000000000000000", + "base_reserve": 0, + "min_persistent_entry_ttl": 4096, + "min_temp_entry_ttl": 16, + "max_entry_ttl": 6312000, + "ledger_entries": [ + [ + { + "contract_data": { + "contract": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD2KM", + "key": { + "vec": [ + { + "symbol": "Balance" + }, + { + "address": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFCT4" + } + ] + }, + "durability": "persistent" + } + }, + [ + { + "last_modified_ledger_seq": 0, + "data": { + "contract_data": { + "ext": "v0", + "contract": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD2KM", + "key": { + "vec": [ + { + "symbol": "Balance" + }, + { + "address": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFCT4" + } + ] + }, + "durability": "persistent", + "val": { + "i128": { + "hi": 0, + "lo": 50 + } + } + } + }, + "ext": "v0" + }, + 518400 + ] + ], + [ + { + "contract_data": { + "contract": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD2KM", + "key": "ledger_key_contract_instance", + "durability": "persistent" + } + }, + [ + { + "last_modified_ledger_seq": 0, + "data": { + "contract_data": { + "ext": "v0", + "contract": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD2KM", + "key": "ledger_key_contract_instance", + "durability": "persistent", + "val": { + "contract_instance": { + "executable": { + "wasm": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855" + }, + "storage": [ + { + "key": { + "vec": [ + { + "symbol": "TotalSupply" + } + ] + }, + "val": { + "i128": { + "hi": 0, + "lo": 50 + } + } + } + ] + } + } + } + }, + "ext": "v0" + }, + 120960 + ] + ], + [ + { + "contract_code": { + "hash": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855" + } + }, + [ + { + "last_modified_ledger_seq": 0, + "data": { + "contract_code": { + "ext": "v0", + "hash": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", + "code": "" + } + }, + "ext": "v0" + }, + 120960 + ] + ] + ] + }, + "events": [] +} \ No newline at end of file diff --git a/contracts/token/fungible/test_snapshots/test/update_mints_tokens.1.json b/contracts/token/fungible/test_snapshots/test/update_mints_tokens.1.json new file mode 100644 index 0000000..7cea01f --- /dev/null +++ b/contracts/token/fungible/test_snapshots/test/update_mints_tokens.1.json @@ -0,0 +1,140 @@ +{ + "generators": { + "address": 2, + "nonce": 0 + }, + "auth": [ + [], + [] + ], + "ledger": { + "protocol_version": 22, + "sequence_number": 0, + "timestamp": 0, + "network_id": "0000000000000000000000000000000000000000000000000000000000000000", + "base_reserve": 0, + "min_persistent_entry_ttl": 4096, + "min_temp_entry_ttl": 16, + "max_entry_ttl": 6312000, + "ledger_entries": [ + [ + { + "contract_data": { + "contract": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD2KM", + "key": { + "vec": [ + { + "symbol": "Balance" + }, + { + "address": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFCT4" + } + ] + }, + "durability": "persistent" + } + }, + [ + { + "last_modified_ledger_seq": 0, + "data": { + "contract_data": { + "ext": "v0", + "contract": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD2KM", + "key": { + "vec": [ + { + "symbol": "Balance" + }, + { + "address": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFCT4" + } + ] + }, + "durability": "persistent", + "val": { + "i128": { + "hi": 0, + "lo": 100 + } + } + } + }, + "ext": "v0" + }, + 518400 + ] + ], + [ + { + "contract_data": { + "contract": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD2KM", + "key": "ledger_key_contract_instance", + "durability": "persistent" + } + }, + [ + { + "last_modified_ledger_seq": 0, + "data": { + "contract_data": { + "ext": "v0", + "contract": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD2KM", + "key": "ledger_key_contract_instance", + "durability": "persistent", + "val": { + "contract_instance": { + "executable": { + "wasm": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855" + }, + "storage": [ + { + "key": { + "vec": [ + { + "symbol": "TotalSupply" + } + ] + }, + "val": { + "i128": { + "hi": 0, + "lo": 100 + } + } + } + ] + } + } + } + }, + "ext": "v0" + }, + 120960 + ] + ], + [ + { + "contract_code": { + "hash": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855" + } + }, + [ + { + "last_modified_ledger_seq": 0, + "data": { + "contract_code": { + "ext": "v0", + "hash": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", + "code": "" + } + }, + "ext": "v0" + }, + 120960 + ] + ] + ] + }, + "events": [] +} \ No newline at end of file diff --git a/contracts/token/fungible/test_snapshots/test/update_transfers_between_accounts.1.json b/contracts/token/fungible/test_snapshots/test/update_transfers_between_accounts.1.json new file mode 100644 index 0000000..9096897 --- /dev/null +++ b/contracts/token/fungible/test_snapshots/test/update_transfers_between_accounts.1.json @@ -0,0 +1,188 @@ +{ + "generators": { + "address": 3, + "nonce": 0 + }, + "auth": [ + [], + [] + ], + "ledger": { + "protocol_version": 22, + "sequence_number": 0, + "timestamp": 0, + "network_id": "0000000000000000000000000000000000000000000000000000000000000000", + "base_reserve": 0, + "min_persistent_entry_ttl": 4096, + "min_temp_entry_ttl": 16, + "max_entry_ttl": 6312000, + "ledger_entries": [ + [ + { + "contract_data": { + "contract": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD2KM", + "key": { + "vec": [ + { + "symbol": "Balance" + }, + { + "address": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFCT4" + } + ] + }, + "durability": "persistent" + } + }, + [ + { + "last_modified_ledger_seq": 0, + "data": { + "contract_data": { + "ext": "v0", + "contract": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD2KM", + "key": { + "vec": [ + { + "symbol": "Balance" + }, + { + "address": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFCT4" + } + ] + }, + "durability": "persistent", + "val": { + "i128": { + "hi": 0, + "lo": 50 + } + } + } + }, + "ext": "v0" + }, + 518400 + ] + ], + [ + { + "contract_data": { + "contract": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD2KM", + "key": { + "vec": [ + { + "symbol": "Balance" + }, + { + "address": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAHK3M" + } + ] + }, + "durability": "persistent" + } + }, + [ + { + "last_modified_ledger_seq": 0, + "data": { + "contract_data": { + "ext": "v0", + "contract": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD2KM", + "key": { + "vec": [ + { + "symbol": "Balance" + }, + { + "address": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAHK3M" + } + ] + }, + "durability": "persistent", + "val": { + "i128": { + "hi": 0, + "lo": 50 + } + } + } + }, + "ext": "v0" + }, + 518400 + ] + ], + [ + { + "contract_data": { + "contract": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD2KM", + "key": "ledger_key_contract_instance", + "durability": "persistent" + } + }, + [ + { + "last_modified_ledger_seq": 0, + "data": { + "contract_data": { + "ext": "v0", + "contract": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD2KM", + "key": "ledger_key_contract_instance", + "durability": "persistent", + "val": { + "contract_instance": { + "executable": { + "wasm": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855" + }, + "storage": [ + { + "key": { + "vec": [ + { + "symbol": "TotalSupply" + } + ] + }, + "val": { + "i128": { + "hi": 0, + "lo": 100 + } + } + } + ] + } + } + } + }, + "ext": "v0" + }, + 120960 + ] + ], + [ + { + "contract_code": { + "hash": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855" + } + }, + [ + { + "last_modified_ledger_seq": 0, + "data": { + "contract_code": { + "ext": "v0", + "hash": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", + "code": "" + } + }, + "ext": "v0" + }, + 120960 + ] + ] + ] + }, + "events": [] +} \ No newline at end of file diff --git a/contracts/token/fungible/test_snapshots/test/update_with_insufficient_balance_panics.1.json b/contracts/token/fungible/test_snapshots/test/update_with_insufficient_balance_panics.1.json new file mode 100644 index 0000000..80dc3da --- /dev/null +++ b/contracts/token/fungible/test_snapshots/test/update_with_insufficient_balance_panics.1.json @@ -0,0 +1,123 @@ +{ + "generators": { + "address": 3, + "nonce": 0 + }, + "auth": [ + [] + ], + "ledger": { + "protocol_version": 22, + "sequence_number": 0, + "timestamp": 0, + "network_id": "0000000000000000000000000000000000000000000000000000000000000000", + "base_reserve": 0, + "min_persistent_entry_ttl": 4096, + "min_temp_entry_ttl": 16, + "max_entry_ttl": 6312000, + "ledger_entries": [ + [ + { + "contract_data": { + "contract": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD2KM", + "key": { + "vec": [ + { + "symbol": "Balance" + }, + { + "address": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFCT4" + } + ] + }, + "durability": "persistent" + } + }, + [ + { + "last_modified_ledger_seq": 0, + "data": { + "contract_data": { + "ext": "v0", + "contract": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD2KM", + "key": { + "vec": [ + { + "symbol": "Balance" + }, + { + "address": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFCT4" + } + ] + }, + "durability": "persistent", + "val": { + "i128": { + "hi": 0, + "lo": 50 + } + } + } + }, + "ext": "v0" + }, + 518400 + ] + ], + [ + { + "contract_data": { + "contract": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD2KM", + "key": "ledger_key_contract_instance", + "durability": "persistent" + } + }, + [ + { + "last_modified_ledger_seq": 0, + "data": { + "contract_data": { + "ext": "v0", + "contract": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD2KM", + "key": "ledger_key_contract_instance", + "durability": "persistent", + "val": { + "contract_instance": { + "executable": { + "wasm": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855" + }, + "storage": null + } + } + } + }, + "ext": "v0" + }, + 120960 + ] + ], + [ + { + "contract_code": { + "hash": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855" + } + }, + [ + { + "last_modified_ledger_seq": 0, + "data": { + "contract_code": { + "ext": "v0", + "hash": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", + "code": "" + } + }, + "ext": "v0" + }, + 120960 + ] + ] + ] + }, + "events": [] +} \ No newline at end of file diff --git a/contracts/token/fungible/test_snapshots/test/update_with_invalid_value_panics.1.json b/contracts/token/fungible/test_snapshots/test/update_with_invalid_value_panics.1.json new file mode 100644 index 0000000..129890f --- /dev/null +++ b/contracts/token/fungible/test_snapshots/test/update_with_invalid_value_panics.1.json @@ -0,0 +1,75 @@ +{ + "generators": { + "address": 3, + "nonce": 0 + }, + "auth": [ + [] + ], + "ledger": { + "protocol_version": 22, + "sequence_number": 0, + "timestamp": 0, + "network_id": "0000000000000000000000000000000000000000000000000000000000000000", + "base_reserve": 0, + "min_persistent_entry_ttl": 4096, + "min_temp_entry_ttl": 16, + "max_entry_ttl": 6312000, + "ledger_entries": [ + [ + { + "contract_data": { + "contract": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD2KM", + "key": "ledger_key_contract_instance", + "durability": "persistent" + } + }, + [ + { + "last_modified_ledger_seq": 0, + "data": { + "contract_data": { + "ext": "v0", + "contract": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD2KM", + "key": "ledger_key_contract_instance", + "durability": "persistent", + "val": { + "contract_instance": { + "executable": { + "wasm": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855" + }, + "storage": null + } + } + } + }, + "ext": "v0" + }, + 4095 + ] + ], + [ + { + "contract_code": { + "hash": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855" + } + }, + [ + { + "last_modified_ledger_seq": 0, + "data": { + "contract_code": { + "ext": "v0", + "hash": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", + "code": "" + } + }, + "ext": "v0" + }, + 4095 + ] + ] + ] + }, + "events": [] +} \ No newline at end of file