@avalabs/vm-module-types 0.0.10 → 0.0.12

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.
@@ -0,0 +1,489 @@
1
+ import { z } from 'zod';
2
+ import { TransactionRequest } from 'ethers';
3
+ import { JsonRpcError, OptionalDataWithOptionalCause, EthereumProviderError } from '@metamask/rpc-errors';
4
+
5
+ declare enum TransactionType {
6
+ BRIDGE = "Bridge",
7
+ SWAP = "Swap",
8
+ SEND = "Send",
9
+ RECEIVE = "Receive",
10
+ NFT_BUY = "NFTBuy",
11
+ APPROVE = "Approve",
12
+ TRANSFER = "Transfer",
13
+ NFT_SEND = "NFTSend",
14
+ NFT_RECEIVE = "NFTReceive",
15
+ AIRDROP = "Airdrop",
16
+ FILL_ORDER = "FillOrder",
17
+ UNWRAP = "Unwrap",
18
+ UNKNOWN = "UNKNOWN"
19
+ }
20
+ declare enum TokenType {
21
+ NATIVE = "NATIVE",
22
+ ERC20 = "ERC20",
23
+ ERC721 = "ERC721",
24
+ ERC1155 = "ERC1155"
25
+ }
26
+ type NetworkFees = {
27
+ low: {
28
+ maxPriorityFeePerGas: bigint;
29
+ maxFeePerGas: bigint;
30
+ };
31
+ medium: {
32
+ maxPriorityFeePerGas: bigint;
33
+ maxFeePerGas: bigint;
34
+ };
35
+ high: {
36
+ maxPriorityFeePerGas: bigint;
37
+ maxFeePerGas: bigint;
38
+ };
39
+ baseFee: bigint;
40
+ };
41
+ declare enum RpcMethod {
42
+ ETH_SEND_TRANSACTION = "eth_sendTransaction",
43
+ SIGN_TYPED_DATA_V3 = "eth_signTypedData_v3",
44
+ SIGN_TYPED_DATA_V4 = "eth_signTypedData_v4",
45
+ SIGN_TYPED_DATA_V1 = "eth_signTypedData_v1",
46
+ SIGN_TYPED_DATA = "eth_signTypedData",
47
+ PERSONAL_SIGN = "personal_sign",
48
+ ETH_SIGN = "eth_sign"
49
+ }
50
+ type DappInfo = {
51
+ name: string;
52
+ url: string;
53
+ icon: string;
54
+ };
55
+ type RpcRequest = {
56
+ requestId: string;
57
+ sessionId: string;
58
+ method: RpcMethod;
59
+ chainId: Caip2ChainId;
60
+ params: unknown;
61
+ dappInfo: DappInfo;
62
+ context?: Record<string, unknown>;
63
+ };
64
+ type RpcError = JsonRpcError<OptionalDataWithOptionalCause> | EthereumProviderError<OptionalDataWithOptionalCause>;
65
+ type RpcResponse<R = unknown, E extends RpcError = JsonRpcError<OptionalDataWithOptionalCause>> = {
66
+ result: R;
67
+ } | {
68
+ error: E;
69
+ };
70
+ type Network = {
71
+ chainId: number;
72
+ chainName: string;
73
+ rpcUrl: string;
74
+ networkToken: NetworkToken;
75
+ utilityAddresses?: {
76
+ multicall: string;
77
+ };
78
+ logoUrl?: string;
79
+ isTestnet?: boolean;
80
+ explorerUrl?: string;
81
+ };
82
+ interface Module {
83
+ getManifest: () => Manifest | undefined;
84
+ getBalances: () => Promise<string>;
85
+ getTransactionHistory: (params: GetTransactionHistory) => Promise<TransactionHistoryResponse>;
86
+ getNetworkFee: (network: Network) => Promise<NetworkFees>;
87
+ getAddress: () => Promise<string>;
88
+ getTokens: (network: Network) => Promise<NetworkContractToken[]>;
89
+ onRpcRequest: (request: RpcRequest, network: Network) => Promise<RpcResponse>;
90
+ }
91
+ type GetTransactionHistory = {
92
+ network: Network;
93
+ address: string;
94
+ nextPageToken?: string;
95
+ offset?: number;
96
+ };
97
+ type TransactionHistoryResponse = {
98
+ transactions: Transaction[];
99
+ nextPageToken?: string;
100
+ };
101
+ type Transaction = {
102
+ isContractCall: boolean;
103
+ isIncoming: boolean;
104
+ isOutgoing: boolean;
105
+ isSender: boolean;
106
+ timestamp: number;
107
+ hash: string;
108
+ from: string;
109
+ to: string;
110
+ tokens: TxToken[];
111
+ gasPrice?: string;
112
+ gasUsed: string;
113
+ txType?: TransactionType;
114
+ chainId: string;
115
+ method?: string;
116
+ explorerLink: string;
117
+ };
118
+ interface TxToken {
119
+ decimal?: string;
120
+ name: string;
121
+ symbol: string;
122
+ amount: string;
123
+ imageUri?: string;
124
+ from?: RichAddress;
125
+ to?: RichAddress;
126
+ collectableTokenId?: string;
127
+ type: TokenType;
128
+ }
129
+ type RichAddress = {
130
+ /**
131
+ * The contract name.
132
+ */
133
+ name?: string;
134
+ /**
135
+ * The contract symbol.
136
+ */
137
+ symbol?: string;
138
+ /**
139
+ * The number of decimals the token uses. For example `6`, means to divide the token amount by `1000000` to get its user representation.
140
+ */
141
+ decimals?: number;
142
+ /**
143
+ * The logo uri for the address.
144
+ */
145
+ logoUri?: string;
146
+ /**
147
+ * A wallet or contract address in mixed-case checksum encoding.
148
+ */
149
+ address: string;
150
+ };
151
+ interface NetworkToken {
152
+ name: string;
153
+ symbol: string;
154
+ description: string;
155
+ decimals: number;
156
+ logoUri: string;
157
+ }
158
+ interface NetworkContractToken {
159
+ address: string;
160
+ chainId?: number;
161
+ color?: string;
162
+ contractType: string;
163
+ decimals: number;
164
+ logoUri?: string;
165
+ name: string;
166
+ symbol: string;
167
+ }
168
+ declare const manifestSchema: z.ZodObject<{
169
+ name: z.ZodString;
170
+ version: z.ZodString;
171
+ description: z.ZodString;
172
+ sources: z.ZodObject<{
173
+ module: z.ZodObject<{
174
+ checksum: z.ZodString;
175
+ location: z.ZodObject<{
176
+ npm: z.ZodObject<{
177
+ filePath: z.ZodString;
178
+ packageName: z.ZodString;
179
+ registry: z.ZodString;
180
+ }, "strip", z.ZodTypeAny, {
181
+ filePath: string;
182
+ packageName: string;
183
+ registry: string;
184
+ }, {
185
+ filePath: string;
186
+ packageName: string;
187
+ registry: string;
188
+ }>;
189
+ }, "strip", z.ZodTypeAny, {
190
+ npm: {
191
+ filePath: string;
192
+ packageName: string;
193
+ registry: string;
194
+ };
195
+ }, {
196
+ npm: {
197
+ filePath: string;
198
+ packageName: string;
199
+ registry: string;
200
+ };
201
+ }>;
202
+ }, "strip", z.ZodTypeAny, {
203
+ checksum: string;
204
+ location: {
205
+ npm: {
206
+ filePath: string;
207
+ packageName: string;
208
+ registry: string;
209
+ };
210
+ };
211
+ }, {
212
+ checksum: string;
213
+ location: {
214
+ npm: {
215
+ filePath: string;
216
+ packageName: string;
217
+ registry: string;
218
+ };
219
+ };
220
+ }>;
221
+ provider: z.ZodOptional<z.ZodObject<{
222
+ checksum: z.ZodString;
223
+ location: z.ZodObject<{
224
+ npm: z.ZodObject<{
225
+ filePath: z.ZodString;
226
+ packageName: z.ZodString;
227
+ registry: z.ZodString;
228
+ }, "strip", z.ZodTypeAny, {
229
+ filePath: string;
230
+ packageName: string;
231
+ registry: string;
232
+ }, {
233
+ filePath: string;
234
+ packageName: string;
235
+ registry: string;
236
+ }>;
237
+ }, "strip", z.ZodTypeAny, {
238
+ npm: {
239
+ filePath: string;
240
+ packageName: string;
241
+ registry: string;
242
+ };
243
+ }, {
244
+ npm: {
245
+ filePath: string;
246
+ packageName: string;
247
+ registry: string;
248
+ };
249
+ }>;
250
+ }, "strip", z.ZodTypeAny, {
251
+ checksum: string;
252
+ location: {
253
+ npm: {
254
+ filePath: string;
255
+ packageName: string;
256
+ registry: string;
257
+ };
258
+ };
259
+ }, {
260
+ checksum: string;
261
+ location: {
262
+ npm: {
263
+ filePath: string;
264
+ packageName: string;
265
+ registry: string;
266
+ };
267
+ };
268
+ }>>;
269
+ }, "strip", z.ZodTypeAny, {
270
+ module: {
271
+ checksum: string;
272
+ location: {
273
+ npm: {
274
+ filePath: string;
275
+ packageName: string;
276
+ registry: string;
277
+ };
278
+ };
279
+ };
280
+ provider?: {
281
+ checksum: string;
282
+ location: {
283
+ npm: {
284
+ filePath: string;
285
+ packageName: string;
286
+ registry: string;
287
+ };
288
+ };
289
+ } | undefined;
290
+ }, {
291
+ module: {
292
+ checksum: string;
293
+ location: {
294
+ npm: {
295
+ filePath: string;
296
+ packageName: string;
297
+ registry: string;
298
+ };
299
+ };
300
+ };
301
+ provider?: {
302
+ checksum: string;
303
+ location: {
304
+ npm: {
305
+ filePath: string;
306
+ packageName: string;
307
+ registry: string;
308
+ };
309
+ };
310
+ } | undefined;
311
+ }>;
312
+ network: z.ZodObject<{
313
+ chainIds: z.ZodArray<z.ZodString, "many">;
314
+ namespaces: z.ZodArray<z.ZodString, "many">;
315
+ }, "strip", z.ZodTypeAny, {
316
+ chainIds: string[];
317
+ namespaces: string[];
318
+ }, {
319
+ chainIds: string[];
320
+ namespaces: string[];
321
+ }>;
322
+ cointype: z.ZodString;
323
+ permissions: z.ZodObject<{
324
+ rpc: z.ZodObject<{
325
+ dapps: z.ZodBoolean;
326
+ methods: z.ZodArray<z.ZodString, "many">;
327
+ }, "strip", z.ZodTypeAny, {
328
+ dapps: boolean;
329
+ methods: string[];
330
+ }, {
331
+ dapps: boolean;
332
+ methods: string[];
333
+ }>;
334
+ }, "strip", z.ZodTypeAny, {
335
+ rpc: {
336
+ dapps: boolean;
337
+ methods: string[];
338
+ };
339
+ }, {
340
+ rpc: {
341
+ dapps: boolean;
342
+ methods: string[];
343
+ };
344
+ }>;
345
+ manifestVersion: z.ZodString;
346
+ }, "strip", z.ZodTypeAny, {
347
+ name: string;
348
+ version: string;
349
+ description: string;
350
+ sources: {
351
+ module: {
352
+ checksum: string;
353
+ location: {
354
+ npm: {
355
+ filePath: string;
356
+ packageName: string;
357
+ registry: string;
358
+ };
359
+ };
360
+ };
361
+ provider?: {
362
+ checksum: string;
363
+ location: {
364
+ npm: {
365
+ filePath: string;
366
+ packageName: string;
367
+ registry: string;
368
+ };
369
+ };
370
+ } | undefined;
371
+ };
372
+ network: {
373
+ chainIds: string[];
374
+ namespaces: string[];
375
+ };
376
+ cointype: string;
377
+ permissions: {
378
+ rpc: {
379
+ dapps: boolean;
380
+ methods: string[];
381
+ };
382
+ };
383
+ manifestVersion: string;
384
+ }, {
385
+ name: string;
386
+ version: string;
387
+ description: string;
388
+ sources: {
389
+ module: {
390
+ checksum: string;
391
+ location: {
392
+ npm: {
393
+ filePath: string;
394
+ packageName: string;
395
+ registry: string;
396
+ };
397
+ };
398
+ };
399
+ provider?: {
400
+ checksum: string;
401
+ location: {
402
+ npm: {
403
+ filePath: string;
404
+ packageName: string;
405
+ registry: string;
406
+ };
407
+ };
408
+ } | undefined;
409
+ };
410
+ network: {
411
+ chainIds: string[];
412
+ namespaces: string[];
413
+ };
414
+ cointype: string;
415
+ permissions: {
416
+ rpc: {
417
+ dapps: boolean;
418
+ methods: string[];
419
+ };
420
+ };
421
+ manifestVersion: string;
422
+ }>;
423
+ type Manifest = z.infer<typeof manifestSchema>;
424
+ declare const parseManifest: (params: unknown) => z.SafeParseReturnType<unknown, Manifest>;
425
+ type Caip2ChainId = string;
426
+ type Hex = `0x${string}`;
427
+ declare enum Environment {
428
+ PRODUCTION = "production",
429
+ DEV = "dev"
430
+ }
431
+ type DisplayData = {
432
+ title: string;
433
+ network: {
434
+ chainId: number;
435
+ name: string;
436
+ logoUrl?: string;
437
+ };
438
+ messageDetails?: string;
439
+ transactionDetails?: {
440
+ website: string;
441
+ from: string;
442
+ to: string;
443
+ data?: string;
444
+ };
445
+ networkFeeSelector?: boolean;
446
+ };
447
+ /**
448
+ * Enum for different types of signing data.
449
+ */
450
+ declare enum SigningDataType {
451
+ EVM_TRANSACTION = "evm_transaction",
452
+ EVM_MESSAGE_ETH_SIGN = "evm_message_eth_sign",
453
+ EVM_MESSAGE_PERSONAL_SIGN = "evm_message_personal_sign",
454
+ EVM_MESSAGE_ETH_SIGN_TYPED_DATA = "evm_message_eth_sign_typed_data",
455
+ EVM_MESSAGE_ETH_SIGN_TYPED_DATA_V1 = "evm_message_eth_sign_typed_data_v1",
456
+ EVM_MESSAGE_ETH_SIGN_TYPED_DATA_V3 = "evm_message_eth_sign_typed_data_v3",
457
+ EVM_MESSAGE_ETH_SIGN_TYPED_DATA_V4 = "evm_message_eth_sign_typed_data_v4",
458
+ AVALANCHE_TRANSACTION = "avalanche_transaction",
459
+ AVALANCHE_MESSAGE = "avalanche_message",
460
+ BTC_TRANSACTION = "btc_transaction"
461
+ }
462
+ type SigningData = {
463
+ type: SigningDataType.EVM_TRANSACTION;
464
+ account: string;
465
+ chainId: number;
466
+ data: TransactionRequest;
467
+ } | {
468
+ type: SigningDataType.EVM_MESSAGE_ETH_SIGN;
469
+ account: string;
470
+ chainId: number;
471
+ data: string;
472
+ };
473
+ type ApprovalParams = {
474
+ request: RpcRequest;
475
+ displayData: DisplayData;
476
+ signingData: SigningData;
477
+ };
478
+ type ApprovalResponse = {
479
+ result: Hex;
480
+ } | {
481
+ error: RpcError;
482
+ };
483
+ interface ApprovalController {
484
+ requestApproval: (params: ApprovalParams) => Promise<ApprovalResponse>;
485
+ onTransactionConfirmed: (txHash: Hex) => void;
486
+ onTransactionReverted: (txHash: Hex) => void;
487
+ }
488
+
489
+ export { ApprovalController, ApprovalParams, ApprovalResponse, Caip2ChainId, DappInfo, DisplayData, Environment, GetTransactionHistory, Hex, Manifest, Module, Network, NetworkContractToken, NetworkFees, NetworkToken, RpcError, RpcMethod, RpcRequest, RpcResponse, SigningData, SigningDataType, TokenType, Transaction, TransactionHistoryResponse, TransactionType, TxToken, parseManifest };