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§
sourcefn transfer(from: Address, to: Address, amount: &BaseUnits) -> Result<(), Error>
fn transfer(from: Address, to: Address, amount: &BaseUnits) -> Result<(), Error>
Transfer an amount from one account to the other.
sourcefn transfer_silent(
from: Address,
to: Address,
amount: &BaseUnits,
) -> Result<(), Error>
fn transfer_silent( from: Address, to: Address, amount: &BaseUnits, ) -> Result<(), Error>
Transfer an amount from one account to the other without emitting an event.
sourcefn mint(to: Address, amount: &BaseUnits) -> Result<(), Error>
fn mint(to: Address, amount: &BaseUnits) -> Result<(), Error>
Mint new tokens, increasing the total supply.
sourcefn burn(from: Address, amount: &BaseUnits) -> Result<(), Error>
fn burn(from: Address, amount: &BaseUnits) -> Result<(), Error>
Burn existing tokens, decreasing the total supply.
sourcefn set_balance(address: Address, amount: &BaseUnits)
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.
sourcefn get_balance(
address: Address,
denomination: Denomination,
) -> Result<u128, Error>
fn get_balance( address: Address, denomination: Denomination, ) -> Result<u128, Error>
Fetch an account’s balance of the given denomination.
sourcefn get_balances(address: Address) -> Result<AccountBalances, Error>
fn get_balances(address: Address) -> Result<AccountBalances, Error>
Fetch an account’s current balances.
sourcefn get_addresses(denomination: Denomination) -> Result<Vec<Address>, Error>
fn get_addresses(denomination: Denomination) -> Result<Vec<Address>, Error>
Fetch addresses.
sourcefn get_total_supplies() -> Result<BTreeMap<Denomination, u128>, Error>
fn get_total_supplies() -> Result<BTreeMap<Denomination, u128>, Error>
Fetch total supplies.
sourcefn set_total_supply(amount: &BaseUnits)
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.
sourcefn get_denomination_info(
denomination: &Denomination,
) -> Result<DenominationInfo, Error>
fn get_denomination_info( denomination: &Denomination, ) -> Result<DenominationInfo, Error>
Fetch information about a denomination.
sourcefn charge_tx_fee(from: Address, amount: &BaseUnits) -> Result<(), Error>
fn charge_tx_fee(from: Address, amount: &BaseUnits) -> Result<(), Error>
Moves the amount into the per-transaction fee accumulator.
sourcefn set_refund_unused_tx_fee(refund: bool)
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).
sourcefn take_refund_unused_tx_fee() -> bool
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
.