@deserialize/multi-vm-wallet 1.2.21 → 1.2.23
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/constant.js +18 -3
- package/dist/constant.js.map +1 -1
- package/dist/evm/transaction.utils.d.ts +362 -0
- package/dist/evm/transaction.utils.js +669 -0
- package/dist/evm/transaction.utils.js.map +1 -0
- package/dist/evm/transactionParsing.d.ts +1 -3633
- package/dist/evm/transactionParsing.js +0 -27
- package/dist/evm/transactionParsing.js.map +1 -1
- package/dist/evm/utils.d.ts +9 -0
- package/dist/evm/utils.js +21 -0
- package/dist/evm/utils.js.map +1 -1
- package/dist/svm/utils.js +6 -4
- package/dist/svm/utils.js.map +1 -1
- package/dist/test.d.ts +4 -0
- package/dist/test.js +17 -18
- package/dist/test.js.map +1 -1
- package/package.json +5 -2
- package/utils/constant.ts +18 -3
- package/utils/evm/transaction.utils.ts +824 -0
- package/utils/evm/transactionParsing.ts +0 -26
- package/utils/evm/utils.ts +19 -0
- package/utils/svm/utils.ts +14 -5
- package/utils/test.ts +18 -16
package/dist/constant.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.TRANSACTION_TYPE = exports.DefaultChains = void 0;
|
|
4
|
+
const chains_1 = require("viem/chains");
|
|
4
5
|
exports.DefaultChains = [{
|
|
5
6
|
chainId: 123456789,
|
|
6
7
|
name: "Solana Mainnet",
|
|
@@ -12,7 +13,7 @@ exports.DefaultChains = [{
|
|
|
12
13
|
decimals: 9,
|
|
13
14
|
},
|
|
14
15
|
testnet: false,
|
|
15
|
-
logoUrl: "https://
|
|
16
|
+
logoUrl: "https://solana.com/src/img/branding/solanaLogoMark.svg",
|
|
16
17
|
vmType: "SVM"
|
|
17
18
|
},
|
|
18
19
|
{
|
|
@@ -26,7 +27,7 @@ exports.DefaultChains = [{
|
|
|
26
27
|
decimals: 18,
|
|
27
28
|
},
|
|
28
29
|
testnet: false,
|
|
29
|
-
logoUrl: "https://cryptologos.cc/logos/ethereum-eth-logo.
|
|
30
|
+
logoUrl: "https://cryptologos.cc/logos/ethereum-eth-logo.svg?v=040",
|
|
30
31
|
vmType: "EVM"
|
|
31
32
|
}, {
|
|
32
33
|
chainId: 56,
|
|
@@ -39,7 +40,7 @@ exports.DefaultChains = [{
|
|
|
39
40
|
decimals: 18,
|
|
40
41
|
},
|
|
41
42
|
testnet: false,
|
|
42
|
-
logoUrl: "https://cryptologos.cc/logos/bnb-bnb-logo.
|
|
43
|
+
logoUrl: "https://cryptologos.cc/logos/bnb-bnb-logo.svg?v=040",
|
|
43
44
|
vmType: "EVM"
|
|
44
45
|
}, {
|
|
45
46
|
chainId: 123456791,
|
|
@@ -68,6 +69,20 @@ exports.DefaultChains = [{
|
|
|
68
69
|
testnet: false,
|
|
69
70
|
logoUrl: "https://chainscan.0g.ai/static/media/zg-logo-new.b22d59dabf457524325ca81c29a4e055.svg",
|
|
70
71
|
vmType: "EVM"
|
|
72
|
+
},
|
|
73
|
+
{
|
|
74
|
+
chainId: chains_1.base.id,
|
|
75
|
+
name: chains_1.base.name,
|
|
76
|
+
rpcUrl: chains_1.base.rpcUrls.default.http[0],
|
|
77
|
+
explorerUrl: chains_1.base.blockExplorers?.default.url || "",
|
|
78
|
+
nativeToken: {
|
|
79
|
+
name: chains_1.base.nativeCurrency.name,
|
|
80
|
+
symbol: chains_1.base.nativeCurrency.symbol,
|
|
81
|
+
decimals: chains_1.base.nativeCurrency.decimals,
|
|
82
|
+
},
|
|
83
|
+
testnet: chains_1.base.testnet,
|
|
84
|
+
logoUrl: "https://avatars.githubusercontent.com/u/108554348?s=200&v=4",
|
|
85
|
+
vmType: "EVM"
|
|
71
86
|
}
|
|
72
87
|
];
|
|
73
88
|
exports.TRANSACTION_TYPE = {
|
package/dist/constant.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constant.js","sourceRoot":"","sources":["../utils/constant.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"constant.js","sourceRoot":"","sources":["../utils/constant.ts"],"names":[],"mappings":"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"}
|
|
@@ -0,0 +1,362 @@
|
|
|
1
|
+
import { type PublicClient, type Address, type Hex } from 'viem';
|
|
2
|
+
/**
|
|
3
|
+
* Enum representing different transaction types
|
|
4
|
+
*/
|
|
5
|
+
export declare enum TransactionType {
|
|
6
|
+
tokenMethodApprove = "approve",
|
|
7
|
+
tokenMethodSetApprovalForAll = "setApprovalForAll",
|
|
8
|
+
tokenMethodTransfer = "transfer",
|
|
9
|
+
tokenMethodTransferFrom = "transferFrom",
|
|
10
|
+
tokenMethodIncreaseAllowance = "increaseAllowance",
|
|
11
|
+
tokenMethodSafeTransferFrom = "safeTransferFrom",
|
|
12
|
+
contractInteraction = "contractInteraction",
|
|
13
|
+
deployContract = "deployContract",
|
|
14
|
+
simpleSend = "simpleSend",
|
|
15
|
+
cancel = "cancel",
|
|
16
|
+
retry = "retry",
|
|
17
|
+
swap = "swap"
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Enum representing asset types
|
|
21
|
+
*/
|
|
22
|
+
export declare enum AssetType {
|
|
23
|
+
native = "NATIVE",
|
|
24
|
+
token = "TOKEN",
|
|
25
|
+
NFT = "NFT",
|
|
26
|
+
unknown = "UNKNOWN"
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Enum representing token standards
|
|
30
|
+
*/
|
|
31
|
+
export declare enum TokenStandard {
|
|
32
|
+
ERC20 = "ERC20",
|
|
33
|
+
ERC721 = "ERC721",
|
|
34
|
+
ERC1155 = "ERC1155",
|
|
35
|
+
none = "none"
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Transaction parameters interface
|
|
39
|
+
*/
|
|
40
|
+
export interface TransactionParams {
|
|
41
|
+
from: Address;
|
|
42
|
+
to?: Address;
|
|
43
|
+
value?: bigint | string;
|
|
44
|
+
data?: Hex;
|
|
45
|
+
gas?: bigint | string;
|
|
46
|
+
gasPrice?: bigint | string;
|
|
47
|
+
maxFeePerGas?: bigint | string;
|
|
48
|
+
maxPriorityFeePerGas?: bigint | string;
|
|
49
|
+
nonce?: number;
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Transaction metadata interface
|
|
53
|
+
*/
|
|
54
|
+
export interface TransactionMeta {
|
|
55
|
+
type?: TransactionType;
|
|
56
|
+
txParams: TransactionParams;
|
|
57
|
+
dappSuggestedGasFees?: {
|
|
58
|
+
gasPrice?: bigint | string;
|
|
59
|
+
maxFeePerGas?: bigint | string;
|
|
60
|
+
maxPriorityFeePerGas?: bigint | string;
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Result of transaction type inference
|
|
65
|
+
*/
|
|
66
|
+
export interface InferTransactionTypeResult {
|
|
67
|
+
type: TransactionType;
|
|
68
|
+
contractCode: Hex | null;
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* Parsed approval transaction data
|
|
72
|
+
*/
|
|
73
|
+
export interface ParsedApprovalData {
|
|
74
|
+
amountOrTokenId?: bigint;
|
|
75
|
+
isApproveAll?: boolean;
|
|
76
|
+
isRevokeAll?: boolean;
|
|
77
|
+
name: string;
|
|
78
|
+
tokenAddress?: Address;
|
|
79
|
+
spender?: Address;
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* Token details interface
|
|
83
|
+
*/
|
|
84
|
+
export interface TokenDetails {
|
|
85
|
+
decimals?: number;
|
|
86
|
+
balance?: bigint;
|
|
87
|
+
symbol?: string;
|
|
88
|
+
standard?: TokenStandard;
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* Determines if a transaction uses EIP-1559 gas fields
|
|
92
|
+
*
|
|
93
|
+
* EIP-1559 transactions use maxFeePerGas and maxPriorityFeePerGas instead of gasPrice
|
|
94
|
+
*
|
|
95
|
+
* @param transactionMeta - Transaction metadata to check
|
|
96
|
+
* @returns True if transaction uses valid EIP-1559 fields
|
|
97
|
+
*
|
|
98
|
+
* @example
|
|
99
|
+
* ```typescript
|
|
100
|
+
* const isEIP1559 = isEIP1559Transaction({
|
|
101
|
+
* txParams: {
|
|
102
|
+
* maxFeePerGas: '0x59682f00',
|
|
103
|
+
* maxPriorityFeePerGas: '0x3b9aca00'
|
|
104
|
+
* }
|
|
105
|
+
* });
|
|
106
|
+
* ```
|
|
107
|
+
*/
|
|
108
|
+
export declare function isEIP1559Transaction(transactionMeta: TransactionMeta): boolean;
|
|
109
|
+
/**
|
|
110
|
+
* Determines if a transaction uses legacy gas fields (gasPrice)
|
|
111
|
+
*
|
|
112
|
+
* Legacy transactions use gasPrice instead of EIP-1559 fields
|
|
113
|
+
*
|
|
114
|
+
* @param transactionMeta - Transaction metadata to check
|
|
115
|
+
* @returns True if transaction uses valid legacy gas fields
|
|
116
|
+
*
|
|
117
|
+
* @example
|
|
118
|
+
* ```typescript
|
|
119
|
+
* const isLegacy = isLegacyTransaction({
|
|
120
|
+
* txParams: {
|
|
121
|
+
* gasPrice: '0x3b9aca00'
|
|
122
|
+
* }
|
|
123
|
+
* });
|
|
124
|
+
* ```
|
|
125
|
+
*/
|
|
126
|
+
export declare function isLegacyTransaction(transactionMeta: TransactionMeta): boolean;
|
|
127
|
+
/**
|
|
128
|
+
* Checks if transaction gas fees match dApp suggested fees
|
|
129
|
+
*
|
|
130
|
+
* Useful for determining if the user has modified the dApp's suggested gas fees
|
|
131
|
+
*
|
|
132
|
+
* @param transactionMeta - Transaction metadata to check
|
|
133
|
+
* @returns True if txParams match dappSuggestedGasFees
|
|
134
|
+
*
|
|
135
|
+
* @example
|
|
136
|
+
* ```typescript
|
|
137
|
+
* const isUnmodified = txParamsAreDappSuggested({
|
|
138
|
+
* txParams: { gasPrice: '0x3b9aca00' },
|
|
139
|
+
* dappSuggestedGasFees: { gasPrice: '0x3b9aca00' }
|
|
140
|
+
* });
|
|
141
|
+
* ```
|
|
142
|
+
*/
|
|
143
|
+
export declare function txParamsAreDappSuggested(transactionMeta: TransactionMeta): boolean;
|
|
144
|
+
/**
|
|
145
|
+
* Attempts to decode transaction data using standard token ABIs
|
|
146
|
+
*
|
|
147
|
+
* Tries to decode the data against ERC20, ERC721, ERC1155, USDC, and Permit2 ABIs
|
|
148
|
+
*
|
|
149
|
+
* @param data - Encoded transaction data
|
|
150
|
+
* @returns Decoded function data or undefined if decoding fails
|
|
151
|
+
*
|
|
152
|
+
* @example
|
|
153
|
+
* ```typescript
|
|
154
|
+
* const parsed = parseStandardTokenTransactionData('0xa9059cbb...');
|
|
155
|
+
* if (parsed) {
|
|
156
|
+
* console.log('Function:', parsed.functionName);
|
|
157
|
+
* console.log('Args:', parsed.args);
|
|
158
|
+
* }
|
|
159
|
+
* ```
|
|
160
|
+
*/
|
|
161
|
+
export declare function parseStandardTokenTransactionData(data: Hex): {
|
|
162
|
+
args: readonly [];
|
|
163
|
+
functionName: "symbol";
|
|
164
|
+
} | {
|
|
165
|
+
args: readonly [];
|
|
166
|
+
functionName: "decimals";
|
|
167
|
+
} | {
|
|
168
|
+
args: readonly [`0x${string}`];
|
|
169
|
+
functionName: "balanceOf";
|
|
170
|
+
} | {
|
|
171
|
+
args: readonly [`0x${string}`, bigint];
|
|
172
|
+
functionName: "transfer";
|
|
173
|
+
} | {
|
|
174
|
+
args: readonly [`0x${string}`, bigint] | readonly [`0x${string}`, `0x${string}`, bigint, number];
|
|
175
|
+
functionName: "approve";
|
|
176
|
+
} | {
|
|
177
|
+
args: readonly [`0x${string}`, boolean];
|
|
178
|
+
functionName: "setApprovalForAll";
|
|
179
|
+
} | {
|
|
180
|
+
args: readonly [`0x${string}`, `0x${string}`, bigint];
|
|
181
|
+
functionName: "transferFrom";
|
|
182
|
+
} | {
|
|
183
|
+
args: readonly [`0x${string}`, bigint];
|
|
184
|
+
functionName: "increaseAllowance";
|
|
185
|
+
} | {
|
|
186
|
+
args: readonly [`0x${string}`, `0x${string}`, bigint] | readonly [`0x${string}`, `0x${string}`, bigint, `0x${string}`] | readonly [`0x${string}`, `0x${string}`, bigint, bigint, `0x${string}`];
|
|
187
|
+
functionName: "safeTransferFrom";
|
|
188
|
+
} | {
|
|
189
|
+
args: readonly [`0x${string}`, bigint];
|
|
190
|
+
functionName: "decreaseAllowance";
|
|
191
|
+
} | {
|
|
192
|
+
args: readonly [`0x${string}`];
|
|
193
|
+
functionName: "supportsInterface";
|
|
194
|
+
} | {
|
|
195
|
+
args: readonly [`0x${string}`, `0x${string}`, readonly bigint[], readonly bigint[], `0x${string}`];
|
|
196
|
+
functionName: "safeBatchTransferFrom";
|
|
197
|
+
} | undefined;
|
|
198
|
+
/**
|
|
199
|
+
* Checks if transaction has meaningful data
|
|
200
|
+
*
|
|
201
|
+
* @param transactionData - Transaction data field
|
|
202
|
+
* @returns True if data exists and is not empty
|
|
203
|
+
*
|
|
204
|
+
* @example
|
|
205
|
+
* ```typescript
|
|
206
|
+
* hasTransactionData('0x') // false
|
|
207
|
+
* hasTransactionData('0xa9059cbb...') // true
|
|
208
|
+
* ```
|
|
209
|
+
*/
|
|
210
|
+
export declare function hasTransactionData(transactionData?: Hex): boolean;
|
|
211
|
+
/**
|
|
212
|
+
* Parses approval transaction data to extract relevant information
|
|
213
|
+
*
|
|
214
|
+
* Supports:
|
|
215
|
+
* - ERC20: approve, increaseAllowance
|
|
216
|
+
* - ERC721/ERC1155: setApprovalForAll
|
|
217
|
+
* - Permit2: approve
|
|
218
|
+
* - USDC: increaseAllowance
|
|
219
|
+
*
|
|
220
|
+
* @param data - Transaction data to parse
|
|
221
|
+
* @returns Parsed approval data or undefined if not an approval transaction
|
|
222
|
+
*
|
|
223
|
+
* @example
|
|
224
|
+
* ```typescript
|
|
225
|
+
* const approval = parseApprovalTransactionData('0x095ea7b3...');
|
|
226
|
+
* if (approval) {
|
|
227
|
+
* console.log('Spender:', approval.spender);
|
|
228
|
+
* console.log('Amount:', approval.amountOrTokenId);
|
|
229
|
+
* console.log('Is approval for all?', approval.isApproveAll);
|
|
230
|
+
* }
|
|
231
|
+
* ```
|
|
232
|
+
*/
|
|
233
|
+
export declare function parseApprovalTransactionData(data: Hex): ParsedApprovalData | undefined;
|
|
234
|
+
/**
|
|
235
|
+
* Reads an address to determine if it's a contract
|
|
236
|
+
*
|
|
237
|
+
* @param client - Viem public client
|
|
238
|
+
* @param address - Address to check
|
|
239
|
+
* @returns Contract code and whether it's a contract address
|
|
240
|
+
*
|
|
241
|
+
* @example
|
|
242
|
+
* ```typescript
|
|
243
|
+
* const { isContractAddress, contractCode } = await readAddressAsContract(
|
|
244
|
+
* client,
|
|
245
|
+
* '0x...'
|
|
246
|
+
* );
|
|
247
|
+
* ```
|
|
248
|
+
*/
|
|
249
|
+
export declare function readAddressAsContract(client: PublicClient, address: Address): Promise<{
|
|
250
|
+
isContractAddress: boolean;
|
|
251
|
+
contractCode: Hex | null;
|
|
252
|
+
}>;
|
|
253
|
+
/**
|
|
254
|
+
* Determines the token standard by checking EIP-165 interface support
|
|
255
|
+
*
|
|
256
|
+
* @param client - Viem public client
|
|
257
|
+
* @param address - Token contract address
|
|
258
|
+
* @returns Token standard (ERC721, ERC1155, ERC20, or none)
|
|
259
|
+
*
|
|
260
|
+
* @example
|
|
261
|
+
* ```typescript
|
|
262
|
+
* const standard = await getTokenStandard(client, '0x...');
|
|
263
|
+
* console.log('Token standard:', standard); // 'ERC721'
|
|
264
|
+
* ```
|
|
265
|
+
*/
|
|
266
|
+
export declare function getTokenStandard(client: PublicClient, address: Address): Promise<TokenStandard>;
|
|
267
|
+
/**
|
|
268
|
+
* Gets token details including standard, decimals, symbol, and balance
|
|
269
|
+
*
|
|
270
|
+
* @param client - Viem public client
|
|
271
|
+
* @param address - Token contract address
|
|
272
|
+
* @param holderAddress - Optional address to check balance for
|
|
273
|
+
* @returns Token details
|
|
274
|
+
*
|
|
275
|
+
* @example
|
|
276
|
+
* ```typescript
|
|
277
|
+
* const details = await getTokenStandardAndDetails(
|
|
278
|
+
* client,
|
|
279
|
+
* '0x...', // token address
|
|
280
|
+
* '0x...' // holder address
|
|
281
|
+
* );
|
|
282
|
+
* console.log(details.symbol, details.decimals, details.balance);
|
|
283
|
+
* ```
|
|
284
|
+
*/
|
|
285
|
+
export declare function getTokenStandardAndDetails(client: PublicClient, address: Address, holderAddress?: Address): Promise<TokenDetails>;
|
|
286
|
+
/**
|
|
287
|
+
* Determines the type of transaction by analyzing its parameters
|
|
288
|
+
*
|
|
289
|
+
* This function analyzes the transaction to determine if it's:
|
|
290
|
+
* - A contract deployment
|
|
291
|
+
* - A token transfer/approval
|
|
292
|
+
* - A contract interaction
|
|
293
|
+
* - A simple ETH transfer
|
|
294
|
+
*
|
|
295
|
+
* @param txParams - Transaction parameters
|
|
296
|
+
* @param client - Viem public client
|
|
297
|
+
* @returns Transaction type and contract code
|
|
298
|
+
*
|
|
299
|
+
* @example
|
|
300
|
+
* ```typescript
|
|
301
|
+
* const result = await determineTransactionType(
|
|
302
|
+
* {
|
|
303
|
+
* from: '0x...',
|
|
304
|
+
* to: '0x...',
|
|
305
|
+
* data: '0xa9059cbb...'
|
|
306
|
+
* },
|
|
307
|
+
* client
|
|
308
|
+
* );
|
|
309
|
+
* console.log('Transaction type:', result.type);
|
|
310
|
+
* ```
|
|
311
|
+
*/
|
|
312
|
+
export declare function determineTransactionType(txParams: TransactionParams, client: PublicClient): Promise<InferTransactionTypeResult>;
|
|
313
|
+
/**
|
|
314
|
+
* Determines the asset type and token standard for a transaction
|
|
315
|
+
*
|
|
316
|
+
* This function analyzes the transaction to determine what type of asset
|
|
317
|
+
* is being transferred and what standard it follows (if applicable)
|
|
318
|
+
*
|
|
319
|
+
* @param txMeta - Transaction metadata
|
|
320
|
+
* @param client - Viem public client
|
|
321
|
+
* @returns Asset type and token standard
|
|
322
|
+
*
|
|
323
|
+
* @example
|
|
324
|
+
* ```typescript
|
|
325
|
+
* const { assetType, tokenStandard } = await determineTransactionAssetType(
|
|
326
|
+
* txMeta,
|
|
327
|
+
* client
|
|
328
|
+
* );
|
|
329
|
+
*
|
|
330
|
+
* if (assetType === AssetType.token) {
|
|
331
|
+
* console.log('ERC20 token transfer');
|
|
332
|
+
* }
|
|
333
|
+
* ```
|
|
334
|
+
*/
|
|
335
|
+
export declare function determineTransactionAssetType(txMeta: TransactionMeta, client: PublicClient): Promise<{
|
|
336
|
+
assetType: AssetType;
|
|
337
|
+
tokenStandard: TokenStandard;
|
|
338
|
+
}>;
|
|
339
|
+
/**
|
|
340
|
+
* Parses typed data message while preserving large number precision
|
|
341
|
+
*
|
|
342
|
+
* JSON.parse can lose precision for numbers > Number.MAX_SAFE_INTEGER
|
|
343
|
+
* This function extracts large values and preserves them as strings
|
|
344
|
+
*
|
|
345
|
+
* @param dataToParse - Data to parse (object or string)
|
|
346
|
+
* @returns Parsed data with preserved precision
|
|
347
|
+
*
|
|
348
|
+
* @example
|
|
349
|
+
* ```typescript
|
|
350
|
+
* const parsed = parseTypedDataMessage(signatureRequest.data);
|
|
351
|
+
* console.log(parsed.message.value); // Preserved as string
|
|
352
|
+
* ```
|
|
353
|
+
*/
|
|
354
|
+
export declare function parseTypedDataMessage(dataToParse: object | string | number | boolean): any;
|
|
355
|
+
/**
|
|
356
|
+
* Case-insensitive string comparison
|
|
357
|
+
*
|
|
358
|
+
* @param str1 - First string
|
|
359
|
+
* @param str2 - Second string
|
|
360
|
+
* @returns True if strings are equal (case-insensitive)
|
|
361
|
+
*/
|
|
362
|
+
export declare function isEqualCaseInsensitive(str1: string, str2: string): boolean;
|