- Resource
AutoAcceptCoins
- Struct
AcceptCoinEvent
- Constants
- Function
genesis_init
- Function
balance
- Function
account_coin_store_id
- Function
is_accept_coin
- Function
can_auto_accept_coin
- Function
do_accept_coin
- Function
set_auto_accept_coin
- Function
withdraw
- Function
deposit
- Function
transfer
- Function
exist_account_coin_store
- Function
is_account_coin_store_frozen
- Function
withdraw_extend
- Function
deposit_extend
- Function
transfer_extend
- Function
accept_coin_entry
- Function
enable_auto_accept_coin_entry
- Function
disable_auto_accept_coin_entry
use 0x2::account;
use 0x2::event;
use 0x2::object;
use 0x2::signer;
use 0x2::table;
use 0x3::coin;
use 0x3::coin_store;
A resource that holds the AutoAcceptCoin config for all accounts. The main scenario is that the user can actively turn off the AutoAcceptCoin setting to avoid automatically receiving Coin
struct AutoAcceptCoins has store, key
Event for auto accept coin set
struct AcceptCoinEvent has copy, drop, store
Account hasn't accept CoinType
const ErrorAccountNotAcceptCoin: u64 = 1;
public(friend) fun genesis_init(genesis_account: &signer)
Returns the balance of addr
for provided CoinType
.
Return the account CoinStore object id for addr the account CoinStore is a account named object, the id is determinate for each addr and CoinType
public fun account_coin_store_id<CoinType: key>(addr: address): object::ObjectID
Return whether the account at addr
accept Coin
type coins
public fun is_accept_coin<CoinType: key>(addr: address): bool
Check whether the address can auto accept coin. Default is true if absent
public fun can_auto_accept_coin(addr: address): bool
Add a balance of Coin
type to the sending account.
If user turns off AutoAcceptCoin, call this method to receive the corresponding Coin
public fun do_accept_coin<CoinType: key>(account: &signer)
Configure whether auto-accept coins.
public fun set_auto_accept_coin(account: &signer, enable: bool)
Withdraw specified amount
of coin CoinType
from the signing account.
This public entry function requires the CoinType
to have key
and store
abilities.
public fun withdraw<CoinType: store, key>(account: &signer, amount: u256): coin::Coin<CoinType>
Deposit the coin into the recipient's account and emit an event.
This public entry function requires the CoinType
to have key
and store
abilities.
public fun deposit<CoinType: store, key>(addr: address, coin: coin::Coin<CoinType>)
Transfer amount
of coins CoinType
from from
to to
.
Any account and module can call this function to transfer coins, the CoinType
must have key
and store
abilities.
public fun exist_account_coin_store<CoinType: key>(addr: address): bool
public fun is_account_coin_store_frozen<CoinType: key>(addr: address): bool
Withdraw specified amount
of coin CoinType
from any addr, this function does not check the Coin frozen
attribute
This function is only called by the CoinType
module, for the developer to extend custom withdraw logic
#[private_generics(#[CoinType])]
public fun withdraw_extend<CoinType: key>(addr: address, amount: u256): coin::Coin<CoinType>
Deposit the coin into the recipient's account and emit an event.
This function is only called by the CoinType
module, for the developer to extend custom deposit logic
#[private_generics(#[CoinType])]
public fun deposit_extend<CoinType: key>(addr: address, coin: coin::Coin<CoinType>)
Transfer amount
of coins CoinType
from from
to to
.
This function is only called by the CoinType
module, for the developer to extend custom transfer logic
#[private_generics(#[CoinType])]
public fun transfer_extend<CoinType: key>(from: address, to: address, amount: u256)
Creating a resource that stores balance of CoinType
on user's account.
Required if user wants to start accepting deposits of CoinType
in his account.
public entry fun accept_coin_entry<CoinType: key>(account: &signer)
Enable account's auto-accept-coin feature. The script function is reenterable.
public entry fun enable_auto_accept_coin_entry(account: &signer)
Disable account's auto-accept-coin feature. The script function is reenterable.
public entry fun disable_auto_accept_coin_entry(account: &signer)