Flex
Flex exchange system
Classes | Macros | Typedefs | Functions
TONTokenWallet.hpp File Reference

TONTokenWallet contract interfaces and data-structs. More...

#include <tvm/schema/message.hpp>
#include <tvm/sequence.hpp>
#include <tvm/small_dict_map.hpp>
#include <tvm/replay_attack_protection/timestamp.hpp>
#include <tvm/smart_switcher.hpp>
#include <tvm/contract_handle.hpp>
#include "FlexLendPayloadArgs.hpp"
#include "Tip3Config.hpp"
#include "Tip3Creds.hpp"
#include "bind_info.hpp"
#include "immutable_ids.hpp"
Include dependency graph for TONTokenWallet.hpp:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  lend_owner_key
 Complex key for lend owners mapping. More...
 
struct  lend_owner
 Lend ownership record (for usage in address->lend_owner_record map). More...
 
struct  lend_owner_array_record
 Lend ownership array record (for usage in getter). More...
 
struct  details_info
 TONTokenWallet details info (for getter). More...
 
interface  ITONTokenWalletNotify
 TON Token wallet notification callback interface. More...
 
interface  ITONTokenWallet
 TON Token wallet contract interface. More...
 
struct  DTONTokenWallet
 TONTokenWallet persistent data struct. More...
 
struct  DTONTokenWalletExternal
 
struct  DTONTokenWalletInternal
 
interface  ETONTokenWallet
 TONTokenWallet events interface. More...
 

Typedefs

using wallet_replay_protection_t = replay_attack_protection::timestamp< TOKEN_WALLET_TIMESTAMP_DELAY >
 
using lend_owners_map = small_dict_map< lend_owner_key, lend_owner >
 Lend owners (contracts) map.
 
using lend_owners_array = dict_array< lend_owner_array_record >
 Lend ownership array.
 
using ITONTokenWalletNotifyPtr = handle< ITONTokenWalletNotify >
 

Functions

DTONTokenWallet prepare_wallet_data (string name, string symbol, uint8 decimals, uint256 root_pubkey, address root_address, uint256 wallet_pubkey, address_opt wallet_owner, uint256 code_hash, uint16 code_depth, int8 workchain_id)
 Prepare TONTokenWallet persistent data struct.
 
__always_inline uint256 calc_wallet_init_hash (string name, string symbol, uint8 decimals, uint256 root_pubkey, address root_address, uint256 wallet_pubkey, address_opt wallet_owner, uint256 code_hash, uint16 code_depth, int8 workchain_id)
 
__always_inline uint256 calc_ext_wallet_init_hash (string name, string symbol, uint8 decimals, uint256 root_pubkey, address root_address, uint256 wallet_pubkey, address_opt wallet_owner, uint256 code_hash, uint16 code_depth, int8 workchain_id)
 
__always_inline uint256 calc_int_wallet_init_hash (Tip3Config tip3cfg, uint256 wallet_pubkey, address_opt wallet_owner, uint256 code_hash, uint16 code_depth, int8 workchain_id)
 
std::pair< StateInit, uint256 > prepare_wallet_state_init_and_addr (DTONTokenWallet wallet_data, cell code)
 
std::pair< StateInit, uint256 > prepare_external_wallet_state_init_and_addr (string name, string symbol, uint8 decimals, uint256 root_pubkey, address root_address, uint256 wallet_pubkey, address_opt wallet_owner, uint256 code_hash, uint16 code_depth, int8 workchain_id, cell code)
 
std::pair< StateInit, uint256 > prepare_internal_wallet_state_init_and_addr (string name, string symbol, uint8 decimals, uint256 root_pubkey, address root_address, uint256 wallet_pubkey, address_opt wallet_owner, uint256 code_hash, uint16 code_depth, int8 workchain_id, cell code)
 

Detailed Description

TONTokenWallet contract interfaces and data-structs.

Compiles into two contract versions: TONTokenWallet.tvc (external wallet) and FlexWallet.tvc (internal wallet). With different macroses. TIP3_ENABLE_EXTERNAL - enable external method calls (by key signature). TIP3_ENABLE_LEND_OWNERSHIP - enable lend ownership functionality. TIP3_ENABLE_BURN - enable burn functionality, to transfer tokens back through Wrapper. TIP3_ENABLE_DESTROY - enable destroy method to self-destruct empty wallet.

Author
Andrew Zhogin

Function Documentation

◆ calc_ext_wallet_init_hash()

__always_inline uint256 tvm::calc_ext_wallet_init_hash ( string  name,
string  symbol,
uint8  decimals,
uint256  root_pubkey,
address  root_address,
uint256  wallet_pubkey,
address_opt  wallet_owner,
uint256  code_hash,
uint16  code_depth,
int8  workchain_id 
)

Calculate wallet original StateInit hash (to get its deploy address). For external wallets.

◆ calc_int_wallet_init_hash()

__always_inline uint256 tvm::calc_int_wallet_init_hash ( Tip3Config  tip3cfg,
uint256  wallet_pubkey,
address_opt  wallet_owner,
uint256  code_hash,
uint16  code_depth,
int8  workchain_id 
)

Calculate wallet original StateInit hash (to get its deploy address). For internal (flex) wallets.

◆ calc_wallet_init_hash()

__always_inline uint256 tvm::calc_wallet_init_hash ( string  name,
string  symbol,
uint8  decimals,
uint256  root_pubkey,
address  root_address,
uint256  wallet_pubkey,
address_opt  wallet_owner,
uint256  code_hash,
uint16  code_depth,
int8  workchain_id 
)

Calculate wallet original StateInit hash (to get its deploy address). This version depends on macroses configuration (external / internal wallet).

◆ prepare_external_wallet_state_init_and_addr()

std::pair<StateInit, uint256> tvm::prepare_external_wallet_state_init_and_addr ( string  name,
string  symbol,
uint8  decimals,
uint256  root_pubkey,
address  root_address,
uint256  wallet_pubkey,
address_opt  wallet_owner,
uint256  code_hash,
uint16  code_depth,
int8  workchain_id,
cell  code 
)
inline

Prepare Token Wallet StateInit structure and expected contract address (hash from StateInit). For external wallets.

◆ prepare_internal_wallet_state_init_and_addr()

std::pair<StateInit, uint256> tvm::prepare_internal_wallet_state_init_and_addr ( string  name,
string  symbol,
uint8  decimals,
uint256  root_pubkey,
address  root_address,
uint256  wallet_pubkey,
address_opt  wallet_owner,
uint256  code_hash,
uint16  code_depth,
int8  workchain_id,
cell  code 
)
inline

Prepare Token Wallet StateInit structure and expected contract address (hash from StateInit). For internal wallets.

◆ prepare_wallet_state_init_and_addr()

std::pair<StateInit, uint256> tvm::prepare_wallet_state_init_and_addr ( DTONTokenWallet  wallet_data,
cell  code 
)
inline

Prepare Token Wallet StateInit structure and expected contract address (hash from StateInit). This version depends on macroses configuration (external / internal wallet).