-
Notifications
You must be signed in to change notification settings - Fork 302
Expand file tree
/
Copy pathiface.ts
More file actions
127 lines (118 loc) · 3.9 KB
/
iface.ts
File metadata and controls
127 lines (118 loc) · 3.9 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
import {
TransactionExplanation as BaseTransactionExplanation,
TransactionRecipient,
TransactionType as BitGoTransactionType,
} from '@bitgo/sdk-core';
import { EntryFunctionABI, EntryFunctionArgumentTypes, SimpleEntryFunctionArgumentTypes } from '@aptos-labs/ts-sdk';
export interface AptTransactionExplanation extends BaseTransactionExplanation {
sender?: string;
type?: BitGoTransactionType;
}
/**
* The transaction data returned from the toJson() function of a transaction
*/
export interface TxData {
id: string | undefined;
sender: string;
/** @deprecated - use `recipients`. */
recipient?: TransactionRecipient;
recipients: TransactionRecipient[];
sequenceNumber: number;
maxGasAmount: number;
gasUnitPrice: number;
gasUsed: number;
expirationTime: number;
feePayer: string;
assetId: string;
}
/**
* The transaction data returned from the toJson() function of a delegation pool transaction
*/
export interface DelegationPoolTxData extends TxData {
validatorAddress: string | null;
amount: string | null;
}
export interface RecipientsValidationResult {
recipients: {
deserializedAddresses: string[];
deserializedAmounts: Uint8Array[];
};
isValid: boolean;
}
/**
* Parameters for custom Aptos entry function transactions.
*
* Enables calling any Aptos entry function while maintaining compatibility with existing BitGo SDK patterns.
* Entry functions are the standard way to interact with Aptos smart contracts and system functions.
*
* @example Basic APT coin transfer (equivalent to standard transfer):
* ```typescript
* {
* moduleName: "0x1::aptos_account",
* functionName: "transfer_coins",
* typeArguments: ["0x1::aptos_coin::AptosCoin"],
* functionArguments: ["0x123...", 1000000] // [recipient, amount]
* }
* ```
*
* @example Custom smart contract call:
* ```typescript
* {
* moduleName: "0x867ed1f6bf916171b1de3ee92849b8978b7d1b9e0a8cc982a3d19d535dfd9c0c::aptos_names_v1",
* functionName: "register_domain",
* typeArguments: [],
* functionArguments: ["mydomain", 1] // [domain_name, years]
* }
* ```
*
* @remarks
* - The `abi` field is optional but provides type validation when present
* - ABI must match the exact function signature of the target entry function
*/
export interface CustomTransactionParams {
/**
* Fully qualified module name in format "address::module_name"
*
* @example "0x1::aptos_account" (system module)
* @example "0x867ed1f6bf916171b1de3ee92849b8978b7d1b9e0a8cc982a3d19d535dfd9c0c::aptos_names_v1" (custom contract)
*/
moduleName: string;
/**
* Entry function name to call within the specified module
*
* @example "transfer_coins", "register_domain", "create_account"
*/
functionName: string;
/**
* Type arguments for generic functions (optional)
*
* Used for functions that accept generic types like Coin<T>.
*
* @example ["0x1::aptos_coin::AptosCoin"] for coin transfers
* @example [] for functions without generic parameters
*/
typeArguments?: string[];
/**
* Function arguments in the order expected by the entry function (optional)
*
* Arguments are automatically serialized based on their JavaScript types.
* Use appropriate types: strings for addresses, numbers/BigInts for amounts.
*
* @example [recipient_address, amount] for transfers
* @example [domain_name, duration] for domain registration
*/
functionArguments?: Array<EntryFunctionArgumentTypes | SimpleEntryFunctionArgumentTypes>;
/**
* Entry function ABI for type validation and safety (optional)
*
* When provided:
* - Validates argument count matches expected parameters
* - Performs type checking during transaction building
* - Improves error messages for invalid calls
*
* @remarks
* - Providing incorrect ABI will cause transaction building to fail
* - Must match the exact function signature of the target entry function
*/
abi?: EntryFunctionABI;
}