Wallet Controller
All chain interaction functions which are vault dependent
Functions
Create an instance
const wallet = new WalletController({
baseUrl: 'http://localhost:8000',
walletType: {
embedded: true, // for external wallet it should be false
suppportAa: boolean,
},
environment, // ENV // default is mainnet
selectedChainName, // string // default is undefined
sessionSignatures,
currentAccount,
customAuthMethod,
accessToken,
sentryDns,
aa,
selectedWallet,
} as TriaArgs);
export type ENV = 'testnet' | 'mainnet-staging' | 'mainnet';
export type AaDetails = {
pimlicoApiKey?: string;
isSponsored?: boolean;
sponsorshipPolicyId?: string;
accountType?: AaAccountType;
sponsorshipPolicyIds?: ChainNameToPolicyId; // {"FUSE": "sp_id_fuse", "POLYGON": "sp_id_poly"}
};
export type AaAccountType = 'Simple' | 'Kernel' | 'Safe' | 'Biconomy';Init
// This inits the signer elements in the wallet instance
// Should be done for all write interactions
await wallet.init()Send Tokens ⛽️
send({
payload,
chain,
gas,
privateKey,
}: {
payload: Send;
chain?: ChainData;
gas?: Gas;
privateKey?: string;
}): Promise<TxnResponse>;export interface TxnResponse {
success: boolean;
data?: {
txnId: string;
viewInExplorer: string;
wait: Function;
};
message?: string;
}export interface Send {
fromTriaName: string;
recipientTriaName: string;
amount: number;
tokenAddress?: string | number | Object;
}// Example
const chainName = "ETHEREUM";
const payload = {
fromTriaName: "dawn@tria",
recipientTriaName: "kate@tria";
amount: 0.1, // ETH
tokenAddress: null;
};
const txn = keyring.send(chainName, payload)internally we fetch the privateKey from the client storage, i.e., from decrypted vault
A check on the FE needs to made for the input & total balance. ( Input <= Total Balance)
you will get totalBalance values from getAllAssets
which will be used to show the assets in choose asset block
tokenAddress -> will be whatever you receive from getAllAssets in number, string, or Object
number -> assetId in Polkadot -> Statemint
Object -> in case of sui
Latest:
Same for new Lit infra gas abstraction integrations
Same for Solana old infra gas abstraction updates
Sign Message
signMessage({
message,
chain,
privateKey,
}: {
message: string;
chain?: ChainData;
privateKey?: string;
}): Promise<StringDataResponse> Approve ⛽️
approve({
payload,
chain,
privateKey,
gas,
}: {
payload: Approve;
chain?: ChainData;
privateKey?: string;
gas?: Gas;
}): Promise<TxnResponse>;export interface Approve {
tokenAddress: string;
amount: number;
spender: string;
}export interface TxnResponse {
success: boolean;
data?: {
txnId: string;
viewInExplorer: string;
wait: Function;
};
message?: string;
}Send NFT ⛽️
Latest:
Same for new Lit infra gas abstraction integrations
Same for Solana old infra gas abstraction updates
Broadcast Transaction
Use this when you have a userOp returned from FeeController response.
This userOp has to also include the gas cut txn on the same chain with some other token
No gas abstraction ❌ in this one, only gas abstraction possible if a batched userOp (with user's main txn + gas cut txn) is passed
Types
⛽️ Lit Infra Gas abstraction updates on same chain - @tria-sdk/[email protected]
If using the interaction functions directly it will batch both txns (main+gas/fee cut txn) in the same userOp and broadcast
If we are using broadcastTxn for the userOp received by FeeController - this userOp only includes the main user txn - on the basis of gas estimated for this txn - we get the gas token amount to cut for the gas cut txn details - we now have to estimate again after the gas token is selected - batch it with the main user txn and get the new userOp (with gas cut txn too) to broadcast.
or, use the main txn interaction functions (send, sendNft, ..) directly to with the gas amount
Ideal case, we preselect a gas token to cut, but we don't know the amount yet unless the first txn fee is estimated, so we have to create the new userOp in the 2nd time only anyways
⛽️ Solana Old Infra gas abstraction updates - @tria-sdk/[email protected]
only in, send
sendNft
rest is in SolanaWallet controller for signAndSendTransaction for any kind of transaction
Last updated