Trait oasis_runtime_sdk::modules::accounts::API

source ·
pub trait API {
Show 20 methods // Required methods fn transfer( from: Address, to: Address, amount: &BaseUnits, ) -> Result<(), Error>; fn transfer_silent( from: Address, to: Address, amount: &BaseUnits, ) -> Result<(), Error>; fn mint(to: Address, amount: &BaseUnits) -> Result<(), Error>; fn burn(from: Address, amount: &BaseUnits) -> Result<(), Error>; fn set_nonce(address: Address, nonce: u64); fn get_nonce(address: Address) -> Result<u64, Error>; fn inc_nonce(address: Address); fn set_balance(address: Address, amount: &BaseUnits); fn get_balance( address: Address, denomination: Denomination, ) -> Result<u128, Error>; fn get_balances(address: Address) -> Result<AccountBalances, Error>; fn get_addresses(denomination: Denomination) -> Result<Vec<Address>, Error>; fn get_total_supplies() -> Result<BTreeMap<Denomination, u128>, Error>; fn set_total_supply(amount: &BaseUnits); fn get_denomination_info( denomination: &Denomination, ) -> Result<DenominationInfo, Error>; fn charge_tx_fee(from: Address, amount: &BaseUnits) -> Result<(), Error>; fn set_refund_unused_tx_fee(refund: bool); fn take_refund_unused_tx_fee() -> bool; fn check_signer_nonces<C: Context>( ctx: &C, tx_auth_info: &AuthInfo, ) -> Result<Address, Error>; fn update_signer_nonces<C: Context>( ctx: &C, tx_auth_info: &AuthInfo, ) -> Result<(), Error>; // Provided method fn ensure_balance(address: Address, amount: &BaseUnits) -> Result<(), Error> { ... }
}
Expand description

Interface that can be called from other modules.

Required Methods§

source

fn transfer(from: Address, to: Address, amount: &BaseUnits) -> Result<(), Error>

Transfer an amount from one account to the other.

source

fn transfer_silent( from: Address, to: Address, amount: &BaseUnits, ) -> Result<(), Error>

Transfer an amount from one account to the other without emitting an event.

source

fn mint(to: Address, amount: &BaseUnits) -> Result<(), Error>

Mint new tokens, increasing the total supply.

source

fn burn(from: Address, amount: &BaseUnits) -> Result<(), Error>

Burn existing tokens, decreasing the total supply.

source

fn set_nonce(address: Address, nonce: u64)

Sets an account’s nonce.

source

fn get_nonce(address: Address) -> Result<u64, Error>

Fetch an account’s current nonce.

source

fn inc_nonce(address: Address)

Increments an account’s nonce.

source

fn set_balance(address: Address, amount: &BaseUnits)

Sets an account’s balance of the given denomination.

§Warning

This method is dangerous as it can result in invariant violations.

source

fn get_balance( address: Address, denomination: Denomination, ) -> Result<u128, Error>

Fetch an account’s balance of the given denomination.

source

fn get_balances(address: Address) -> Result<AccountBalances, Error>

Fetch an account’s current balances.

source

fn get_addresses(denomination: Denomination) -> Result<Vec<Address>, Error>

Fetch addresses.

source

fn get_total_supplies() -> Result<BTreeMap<Denomination, u128>, Error>

Fetch total supplies.

source

fn set_total_supply(amount: &BaseUnits)

Sets the total supply for the given denomination.

§Warning

This method is dangerous as it can result in invariant violations.

source

fn get_denomination_info( denomination: &Denomination, ) -> Result<DenominationInfo, Error>

Fetch information about a denomination.

source

fn charge_tx_fee(from: Address, amount: &BaseUnits) -> Result<(), Error>

Moves the amount into the per-transaction fee accumulator.

source

fn set_refund_unused_tx_fee(refund: bool)

Indicates that the unused portion of the transaction fee should be refunded after the transaction completes (even in case it fails).

source

fn take_refund_unused_tx_fee() -> bool

Take the flag indicating that the unused portion of the transaction fee should be refunded after the transaction completes is set.

After calling this method the flag is reset to false.

source

fn check_signer_nonces<C: Context>( ctx: &C, tx_auth_info: &AuthInfo, ) -> Result<Address, Error>

Check transaction signer account nonces. Return payer address.

source

fn update_signer_nonces<C: Context>( ctx: &C, tx_auth_info: &AuthInfo, ) -> Result<(), Error>

Update transaction signer account nonces.

Provided Methods§

source

fn ensure_balance(address: Address, amount: &BaseUnits) -> Result<(), Error>

Ensures that the given account has at least the specified balance.

Object Safety§

This trait is not object safe.

Implementors§