# Rust SDK Code Structure ## Mod Sections --- ### grpc - Function: communicate with forge by grpc, functions as follows: - 1.create connection with forge server. impl in `connection.rs`. - 2.get something from forge, such as forge info, account state, tx detail, and so on. api in `lib.rs`. `Get API list` as follows: - 1.` get_chain_info(chain_name: Option)` - 2.` get_chain_id(chain_name: Option)` - 3.` get_net_info(chain_name: Option)` - 4.` get_node_info(chain_name: Option)` - 5.` get_validators_info(chain_name: Option)` - 6.` get_config(is_parsed: Option, chain_name: Option)` - 7.` get_tx(txs: &[String], chain_name: Option)` - 8.` get_block(height: u64, chain_name: Option)` - 9.` multisig(multisig: &chain_client::RequestMultisig, chain_name: option)` - 10.` search(key: &str, value: &str, chain_name: Option)` - 11.` get_account_state(wallet_addresses: &[String], chain_name: option)` - 12.` get_asset_state(asset_addresses: &[String], chain_name: Option)` - 13.` get_forge_state(wallet_addresses: &[String],height: u64, chain_name: Option)` - 3.send tx to forge. support declare, poke, transfer, asset, delegate, migrate account, and so on. Api list in `lib.rs`, impl detail in `mod transaction`. Send diff transactions example in `mod example`. `SendTx API list` as follows: - 1.` declare(request: &Request, dec: &build_itx::Declare)` - 2.` poke(request: &Request)` - 3.` transfer(request: &Request, transfer: &build_itx::Transfer)` - 4.` create_asset(request: &Request, itx: &build_itx::CreateAsset)` - 5.` update_asset(request: &Request, itx: &build_itx::UpdateAsset)` - 6.` consume_asset(request: &Request, itx: &build_itx::ConsumeAsset, asset_address: &str, signers: &[Wallet])` - 7.` acquire_asset(request: &Request, itx: &build_itx::AcquireAsset)` - 8.` exchange(request: &Request, itx: &build_itx::Exchange, signers: &[Wallet])` - 9.` delegate(request: &Request, itx: &build_itx::DelegateTx)` - 10.` account_migrate(request: &Request, itx: &build_itx::AccountMigrate)` - 11.` create_wallet(request: &wallet_client::CreateWallet, forge_name: Option)` - 12.` deposit_token(request: &Request, itx: &build_itx::DepositToken)` --- ### wallet - Function: help user create wallet, functions as follows: - ` create_default_wallet() -> Result` - ` from_wallet_type(w_type: &WalletType) -> Result` - ` from_address(addr: &str) -> Result` - ` from_pk(pk: &[u8], w_type: &WalletType) -> Result` - ` from_sk(sk: &[u8], w_type: &WalletType) -> Result` - ` from_json(j: Value) -> Result` - ` to_json(&self) -> Result` - ` verify(&self, message: &[u8], signature: &[u8]) -> Result` - ` hash(&self, message: &[u8]) -> Result>` - ` sign(&self, message: &[u8]) -> Result>` - ` format_wallet(&mut self) -> Result<()>` - ` is_valid(wallet: &Wallet) -> bool` --- ### did - Function: get did address from sk, pk, pk hash. it is a base mod for `wallet` ### hasher - Function: hash algorithms impl, current support hash algorithms as follows: - `sha2` - `sha3` - `blake2b` - `keccak` --- ### crypter - Function: crypto algorithms impl, current support crypto algorithms as follows: - `aes256` --- ### signer - Function: sign algorithms impl, current support sign algorithms as follows: - `ed25519` - `secp256k` --- ### execution - Function: console client, user can get sth or send tx to forge through console, such as: - `./execution get --chain_info` will print chain(default socket `grpc/src/config.rs/FORGE_ADDRESS`) info - `./execution get --node_info` will print node info - `./execution get --tx 3385A9673BBD992DBF2E80CDCAD86891BA3B11005D8095437E6B7FBD5457E2A7` will print the info - `./execution get --account_state z1d6tCknGjMNiAZxYET16edYRySHEeBHBnD` will print the account info - `./execution get --account_state z1d6tCknGjMNiAZxYET16edYRySHEeBHBnD` will print the account info - `./execution send -p z1d6tCknGjMNiAZxYET16edYRySHEeBHBnD 1.0` will send 1.0 ABT to `z1d6tCknGjMNiAZxYET16edYRySHEeBHBnD` by default wallet(save in settings) - others... --- ### util - Function: tools mod, help to create settings.json to save something. such as grpc will use it to save test wallets. ---