@avalabs/vm-module-types 0.0.11 → 0.0.13

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