@avalabs/vm-module-types 0.0.13 → 0.0.16
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/.turbo/turbo-build.log +107 -21
- package/.turbo/turbo-lint.log +1 -1
- package/CHANGELOG.md +18 -0
- package/dist/balance.cjs +6 -0
- package/dist/balance.d.cts +103 -0
- package/dist/balance.d.ts +103 -0
- package/dist/balance.js +3 -0
- package/dist/chunk-4PGCXP4C.cjs +10 -0
- package/dist/chunk-4PGCXP4C.cjs.map +1 -0
- package/dist/chunk-74SNNWSF.cjs +9 -0
- package/dist/chunk-74SNNWSF.cjs.map +1 -0
- package/dist/chunk-7FBUAZNW.cjs +8 -0
- package/dist/chunk-7FBUAZNW.cjs.map +1 -0
- package/dist/chunk-7U2R34EQ.js +3 -0
- package/dist/chunk-7U2R34EQ.js.map +1 -0
- package/dist/chunk-A4YEBDMG.js +7 -0
- package/dist/chunk-A4YEBDMG.js.map +1 -0
- package/dist/chunk-AILYKQEY.cjs +4 -0
- package/dist/chunk-AILYKQEY.cjs.map +1 -0
- package/dist/chunk-BFBDZPL3.cjs +9 -0
- package/dist/chunk-BFBDZPL3.cjs.map +1 -0
- package/dist/chunk-BHB5UV3J.js +3 -0
- package/dist/chunk-BHB5UV3J.js.map +1 -0
- package/dist/chunk-CUVJNZP5.js +3 -0
- package/dist/chunk-CUVJNZP5.js.map +1 -0
- package/dist/chunk-H6ZZE5M7.js +5 -0
- package/dist/chunk-H6ZZE5M7.js.map +1 -0
- package/dist/chunk-JUV577XH.cjs +4 -0
- package/dist/chunk-JUV577XH.cjs.map +1 -0
- package/dist/chunk-KVTVJNN4.cjs +7 -0
- package/dist/chunk-KVTVJNN4.cjs.map +1 -0
- package/dist/chunk-OGQBQHLH.cjs +4 -0
- package/dist/chunk-OGQBQHLH.cjs.map +1 -0
- package/dist/chunk-TSO5BGJ4.js +5 -0
- package/dist/chunk-TSO5BGJ4.js.map +1 -0
- package/dist/chunk-WOO6UGSQ.js +7 -0
- package/dist/chunk-WOO6UGSQ.js.map +1 -0
- package/dist/chunk-XMGYJ4KK.js +5 -0
- package/dist/chunk-XMGYJ4KK.js.map +1 -0
- package/dist/chunk-XQGU7MZ4.cjs +7 -0
- package/dist/chunk-XQGU7MZ4.cjs.map +1 -0
- package/dist/chunk-YJHKZHST.js +5 -0
- package/dist/chunk-YJHKZHST.js.map +1 -0
- package/dist/coingecko.cjs +16 -0
- package/dist/coingecko.cjs.map +1 -0
- package/dist/coingecko.d.cts +23 -0
- package/dist/coingecko.d.ts +23 -0
- package/dist/coingecko.js +3 -0
- package/dist/coingecko.js.map +1 -0
- package/dist/common.cjs +12 -0
- package/dist/common.cjs.map +1 -0
- package/dist/common.d.cts +32 -0
- package/dist/common.d.ts +32 -0
- package/dist/common.js +3 -0
- package/dist/common.js.map +1 -0
- package/dist/index.cjs +31 -15
- package/dist/index.d.cts +11 -1
- package/dist/index.d.ts +11 -1
- package/dist/index.js +9 -1
- package/dist/manifest.cjs +12 -0
- package/dist/manifest.cjs.map +1 -0
- package/dist/manifest.d.cts +261 -0
- package/dist/manifest.d.ts +261 -0
- package/dist/manifest.js +3 -0
- package/dist/manifest.js.map +1 -0
- package/dist/module.cjs +6 -0
- package/dist/module.cjs.map +1 -0
- package/dist/module.d.cts +24 -0
- package/dist/module.d.ts +24 -0
- package/dist/module.js +3 -0
- package/dist/module.js.map +1 -0
- package/dist/network-fee.cjs +6 -0
- package/dist/network-fee.cjs.map +1 -0
- package/dist/network-fee.d.cts +18 -0
- package/dist/network-fee.d.ts +18 -0
- package/dist/network-fee.js +3 -0
- package/dist/network-fee.js.map +1 -0
- package/dist/rpc.cjs +16 -0
- package/dist/rpc.cjs.map +1 -0
- package/dist/rpc.d.cts +125 -0
- package/dist/rpc.d.ts +125 -0
- package/dist/rpc.js +3 -0
- package/dist/rpc.js.map +1 -0
- package/dist/token.cjs +12 -0
- package/dist/token.cjs.map +1 -0
- package/dist/token.d.cts +25 -0
- package/dist/token.d.ts +25 -0
- package/dist/token.js +3 -0
- package/dist/token.js.map +1 -0
- package/dist/transaction-history.cjs +20 -0
- package/dist/transaction-history.cjs.map +1 -0
- package/dist/transaction-history.d.cts +106 -0
- package/dist/transaction-history.d.ts +106 -0
- package/dist/transaction-history.js +3 -0
- package/dist/transaction-history.js.map +1 -0
- package/package.json +7 -2
- package/src/balance.ts +118 -0
- package/src/coingecko.ts +15 -0
- package/src/common.ts +34 -0
- package/src/index.ts +9 -1
- package/src/manifest.ts +40 -0
- package/src/module.ts +17 -0
- package/src/network-fee.ts +7 -0
- package/src/rpc.ts +144 -0
- package/src/token.ts +25 -0
- package/src/transaction-history.ts +113 -0
- package/dist/chunk-4RO2H63T.js +0 -7
- package/dist/chunk-4RO2H63T.js.map +0 -1
- package/dist/chunk-L7UO6W6T.cjs +0 -16
- package/dist/chunk-L7UO6W6T.cjs.map +0 -1
- package/dist/types.cjs +0 -40
- package/dist/types.d.cts +0 -516
- package/dist/types.d.ts +0 -516
- package/dist/types.js +0 -3
- package/src/types.ts +0 -328
- /package/dist/{types.cjs.map → balance.cjs.map} +0 -0
- /package/dist/{types.js.map → balance.js.map} +0 -0
package/src/types.ts
DELETED
|
@@ -1,328 +0,0 @@
|
|
|
1
|
-
import { object, string, boolean, z } from 'zod';
|
|
2
|
-
import type { TransactionRequest } from 'ethers';
|
|
3
|
-
import type { JsonRpcError, EthereumProviderError, OptionalDataWithOptionalCause } from '@metamask/rpc-errors';
|
|
4
|
-
|
|
5
|
-
export 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
|
-
|
|
21
|
-
export enum PChainTransactionType {
|
|
22
|
-
ADD_VALIDATOR_TX = 'AddValidatorTx',
|
|
23
|
-
ADD_SUBNET_VALIDATOR_TX = 'AddSubnetValidatorTx',
|
|
24
|
-
ADD_DELEGATOR_TX = 'AddDelegatorTx',
|
|
25
|
-
CREATE_CHAIN_TX = 'CreateChainTx',
|
|
26
|
-
CREATE_SUBNET_TX = 'CreateSubnetTx',
|
|
27
|
-
IMPORT_TX = 'ImportTx',
|
|
28
|
-
EXPORT_TX = 'ExportTx',
|
|
29
|
-
ADVANCE_TIME_TX = 'AdvanceTimeTx',
|
|
30
|
-
REWARD_VALIDATOR_TX = 'RewardValidatorTx',
|
|
31
|
-
REMOVE_SUBNET_VALIDATOR_TX = 'RemoveSubnetValidatorTx',
|
|
32
|
-
TRANSFORM_SUBNET_TX = 'TransformSubnetTx',
|
|
33
|
-
ADD_PERMISSIONLESS_VALIDATOR_TX = 'AddPermissionlessValidatorTx',
|
|
34
|
-
ADD_PERMISSIONLESS_DELEGATOR_TX = 'AddPermissionlessDelegatorTx',
|
|
35
|
-
BASE_TX = 'BaseTx',
|
|
36
|
-
TRANSFER_SUBNET_OWNERSHIP_TX = 'TransferSubnetOwnershipTx',
|
|
37
|
-
UNKNOWN = 'UNKNOWN',
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
export enum XChainTransactionType {
|
|
41
|
-
BASE_TX = 'BaseTx',
|
|
42
|
-
CREATE_ASSET_TX = 'CreateAssetTx',
|
|
43
|
-
OPERATION_TX = 'OperationTx',
|
|
44
|
-
IMPORT_TX = 'ImportTx',
|
|
45
|
-
EXPORT_TX = 'ExportTx',
|
|
46
|
-
UNKNOWN = 'UNKNOWN',
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
export enum TokenType {
|
|
50
|
-
NATIVE = 'NATIVE',
|
|
51
|
-
ERC20 = 'ERC20',
|
|
52
|
-
ERC721 = 'ERC721',
|
|
53
|
-
ERC1155 = 'ERC1155',
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
export type NetworkFees = {
|
|
57
|
-
low: { maxFeePerGas: bigint; maxPriorityFeePerGas?: bigint };
|
|
58
|
-
medium: { maxFeePerGas: bigint; maxPriorityFeePerGas?: bigint };
|
|
59
|
-
high: { maxFeePerGas: bigint; maxPriorityFeePerGas?: bigint };
|
|
60
|
-
baseFee: bigint;
|
|
61
|
-
isFixedFee: boolean;
|
|
62
|
-
};
|
|
63
|
-
|
|
64
|
-
export enum RpcMethod {
|
|
65
|
-
/* EVM */
|
|
66
|
-
ETH_SEND_TRANSACTION = 'eth_sendTransaction',
|
|
67
|
-
SIGN_TYPED_DATA_V3 = 'eth_signTypedData_v3',
|
|
68
|
-
SIGN_TYPED_DATA_V4 = 'eth_signTypedData_v4',
|
|
69
|
-
SIGN_TYPED_DATA_V1 = 'eth_signTypedData_v1',
|
|
70
|
-
SIGN_TYPED_DATA = 'eth_signTypedData',
|
|
71
|
-
PERSONAL_SIGN = 'personal_sign',
|
|
72
|
-
ETH_SIGN = 'eth_sign',
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
export type DappInfo = {
|
|
76
|
-
name: string;
|
|
77
|
-
url: string;
|
|
78
|
-
icon: string;
|
|
79
|
-
};
|
|
80
|
-
|
|
81
|
-
export type RpcRequest = {
|
|
82
|
-
requestId: string;
|
|
83
|
-
sessionId: string;
|
|
84
|
-
method: RpcMethod;
|
|
85
|
-
chainId: Caip2ChainId;
|
|
86
|
-
params: unknown;
|
|
87
|
-
dappInfo: DappInfo;
|
|
88
|
-
context?: Record<string, unknown>; // for storing additional context information that's only relevant to the consumer
|
|
89
|
-
};
|
|
90
|
-
|
|
91
|
-
export type RpcError =
|
|
92
|
-
| JsonRpcError<OptionalDataWithOptionalCause>
|
|
93
|
-
| EthereumProviderError<OptionalDataWithOptionalCause>;
|
|
94
|
-
|
|
95
|
-
export type RpcResponse<R = unknown, E extends RpcError = JsonRpcError<OptionalDataWithOptionalCause>> =
|
|
96
|
-
| {
|
|
97
|
-
result: R;
|
|
98
|
-
}
|
|
99
|
-
| {
|
|
100
|
-
error: E;
|
|
101
|
-
};
|
|
102
|
-
|
|
103
|
-
export type Network = {
|
|
104
|
-
chainId: number;
|
|
105
|
-
chainName: string;
|
|
106
|
-
rpcUrl: string;
|
|
107
|
-
networkToken: NetworkToken;
|
|
108
|
-
utilityAddresses?: {
|
|
109
|
-
multicall: string;
|
|
110
|
-
};
|
|
111
|
-
logoUrl?: string;
|
|
112
|
-
isTestnet?: boolean;
|
|
113
|
-
explorerUrl?: string;
|
|
114
|
-
};
|
|
115
|
-
|
|
116
|
-
export interface Module {
|
|
117
|
-
getManifest: () => Manifest | undefined;
|
|
118
|
-
getBalances: () => Promise<string>;
|
|
119
|
-
getTransactionHistory: (params: GetTransactionHistory) => Promise<TransactionHistoryResponse>;
|
|
120
|
-
getNetworkFee: (network: Network) => Promise<NetworkFees>;
|
|
121
|
-
getAddress: () => Promise<string>;
|
|
122
|
-
getTokens: (network: Network) => Promise<NetworkContractToken[]>;
|
|
123
|
-
onRpcRequest: (request: RpcRequest, network: Network) => Promise<RpcResponse>;
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
export type GetTransactionHistory = {
|
|
127
|
-
network: Network;
|
|
128
|
-
address: string;
|
|
129
|
-
nextPageToken?: string;
|
|
130
|
-
offset?: number;
|
|
131
|
-
};
|
|
132
|
-
|
|
133
|
-
export type TransactionHistoryResponse = {
|
|
134
|
-
transactions: Transaction[];
|
|
135
|
-
nextPageToken?: string;
|
|
136
|
-
};
|
|
137
|
-
|
|
138
|
-
export type Transaction = {
|
|
139
|
-
isContractCall: boolean;
|
|
140
|
-
isIncoming: boolean;
|
|
141
|
-
isOutgoing: boolean;
|
|
142
|
-
isSender: boolean;
|
|
143
|
-
timestamp: number;
|
|
144
|
-
hash: string;
|
|
145
|
-
from: string;
|
|
146
|
-
to: string;
|
|
147
|
-
tokens: TxToken[];
|
|
148
|
-
gasPrice?: string;
|
|
149
|
-
gasUsed: string;
|
|
150
|
-
txType?: TransactionType | PChainTransactionType | XChainTransactionType;
|
|
151
|
-
chainId: string; // chainId from ActiveNetwork used to fetch tx
|
|
152
|
-
method?: string;
|
|
153
|
-
explorerLink: string;
|
|
154
|
-
};
|
|
155
|
-
|
|
156
|
-
export interface TxToken {
|
|
157
|
-
decimal?: string;
|
|
158
|
-
name: string;
|
|
159
|
-
symbol: string;
|
|
160
|
-
amount: string;
|
|
161
|
-
imageUri?: string;
|
|
162
|
-
from?: RichAddress;
|
|
163
|
-
to?: RichAddress;
|
|
164
|
-
collectableTokenId?: string;
|
|
165
|
-
type: TokenType;
|
|
166
|
-
}
|
|
167
|
-
|
|
168
|
-
type RichAddress = {
|
|
169
|
-
/**
|
|
170
|
-
* The contract name.
|
|
171
|
-
*/
|
|
172
|
-
name?: string;
|
|
173
|
-
/**
|
|
174
|
-
* The contract symbol.
|
|
175
|
-
*/
|
|
176
|
-
symbol?: string;
|
|
177
|
-
/**
|
|
178
|
-
* The number of decimals the token uses. For example `6`, means to divide the token amount by `1000000` to get its user representation.
|
|
179
|
-
*/
|
|
180
|
-
decimals?: number;
|
|
181
|
-
/**
|
|
182
|
-
* The logo uri for the address.
|
|
183
|
-
*/
|
|
184
|
-
logoUri?: string;
|
|
185
|
-
/**
|
|
186
|
-
* A wallet or contract address in mixed-case checksum encoding.
|
|
187
|
-
*/
|
|
188
|
-
address: string;
|
|
189
|
-
};
|
|
190
|
-
|
|
191
|
-
export interface NetworkToken {
|
|
192
|
-
name: string;
|
|
193
|
-
symbol: string;
|
|
194
|
-
description: string;
|
|
195
|
-
decimals: number;
|
|
196
|
-
logoUri: string;
|
|
197
|
-
}
|
|
198
|
-
|
|
199
|
-
export interface NetworkContractToken {
|
|
200
|
-
address: string;
|
|
201
|
-
chainId?: number;
|
|
202
|
-
color?: string;
|
|
203
|
-
contractType: string;
|
|
204
|
-
decimals: number;
|
|
205
|
-
logoUri?: string;
|
|
206
|
-
name: string;
|
|
207
|
-
symbol: string;
|
|
208
|
-
}
|
|
209
|
-
|
|
210
|
-
const sourceSchema = object({
|
|
211
|
-
checksum: string(),
|
|
212
|
-
location: object({
|
|
213
|
-
npm: object({
|
|
214
|
-
filePath: string(),
|
|
215
|
-
packageName: string(),
|
|
216
|
-
registry: string(),
|
|
217
|
-
}),
|
|
218
|
-
}),
|
|
219
|
-
});
|
|
220
|
-
|
|
221
|
-
const manifestSchema = object({
|
|
222
|
-
name: string(),
|
|
223
|
-
version: string(),
|
|
224
|
-
description: string(),
|
|
225
|
-
sources: object({
|
|
226
|
-
module: sourceSchema,
|
|
227
|
-
provider: sourceSchema.optional(),
|
|
228
|
-
}),
|
|
229
|
-
network: object({
|
|
230
|
-
chainIds: string().array(),
|
|
231
|
-
namespaces: string().array(),
|
|
232
|
-
}),
|
|
233
|
-
cointype: string(),
|
|
234
|
-
permissions: object({
|
|
235
|
-
rpc: object({
|
|
236
|
-
dapps: boolean(),
|
|
237
|
-
methods: string().array(),
|
|
238
|
-
}),
|
|
239
|
-
}),
|
|
240
|
-
manifestVersion: string(),
|
|
241
|
-
});
|
|
242
|
-
|
|
243
|
-
export type Manifest = z.infer<typeof manifestSchema>;
|
|
244
|
-
|
|
245
|
-
export const parseManifest = (params: unknown): z.SafeParseReturnType<unknown, Manifest> => {
|
|
246
|
-
return manifestSchema.safeParse(params);
|
|
247
|
-
};
|
|
248
|
-
|
|
249
|
-
export type Caip2ChainId = string;
|
|
250
|
-
|
|
251
|
-
export type Hex = `0x${string}`;
|
|
252
|
-
|
|
253
|
-
export enum Environment {
|
|
254
|
-
PRODUCTION = 'production',
|
|
255
|
-
DEV = 'dev',
|
|
256
|
-
}
|
|
257
|
-
|
|
258
|
-
export type DisplayData = {
|
|
259
|
-
title: string;
|
|
260
|
-
network: {
|
|
261
|
-
chainId: number;
|
|
262
|
-
name: string;
|
|
263
|
-
logoUrl?: string;
|
|
264
|
-
};
|
|
265
|
-
messageDetails?: string;
|
|
266
|
-
transactionDetails?: {
|
|
267
|
-
website: string;
|
|
268
|
-
from: string;
|
|
269
|
-
to: string;
|
|
270
|
-
data?: string;
|
|
271
|
-
};
|
|
272
|
-
networkFeeSelector?: boolean;
|
|
273
|
-
};
|
|
274
|
-
|
|
275
|
-
/**
|
|
276
|
-
* Enum for different types of signing data.
|
|
277
|
-
*/
|
|
278
|
-
export enum SigningDataType {
|
|
279
|
-
// EVM signing data types
|
|
280
|
-
EVM_TRANSACTION = 'evm_transaction',
|
|
281
|
-
EVM_MESSAGE_ETH_SIGN = 'evm_message_eth_sign',
|
|
282
|
-
EVM_MESSAGE_PERSONAL_SIGN = 'evm_message_personal_sign',
|
|
283
|
-
EVM_MESSAGE_ETH_SIGN_TYPED_DATA = 'evm_message_eth_sign_typed_data',
|
|
284
|
-
EVM_MESSAGE_ETH_SIGN_TYPED_DATA_V1 = 'evm_message_eth_sign_typed_data_v1',
|
|
285
|
-
EVM_MESSAGE_ETH_SIGN_TYPED_DATA_V3 = 'evm_message_eth_sign_typed_data_v3',
|
|
286
|
-
EVM_MESSAGE_ETH_SIGN_TYPED_DATA_V4 = 'evm_message_eth_sign_typed_data_v4',
|
|
287
|
-
|
|
288
|
-
// Avalanche signing data types
|
|
289
|
-
AVALANCHE_TRANSACTION = 'avalanche_transaction',
|
|
290
|
-
AVALANCHE_MESSAGE = 'avalanche_message',
|
|
291
|
-
|
|
292
|
-
// Bitcoin signing data types
|
|
293
|
-
BTC_TRANSACTION = 'btc_transaction',
|
|
294
|
-
}
|
|
295
|
-
|
|
296
|
-
export type SigningData =
|
|
297
|
-
| {
|
|
298
|
-
type: SigningDataType.EVM_TRANSACTION;
|
|
299
|
-
account: string;
|
|
300
|
-
chainId: number;
|
|
301
|
-
data: TransactionRequest;
|
|
302
|
-
}
|
|
303
|
-
| {
|
|
304
|
-
type: SigningDataType.EVM_MESSAGE_ETH_SIGN;
|
|
305
|
-
account: string;
|
|
306
|
-
chainId: number;
|
|
307
|
-
data: string;
|
|
308
|
-
};
|
|
309
|
-
|
|
310
|
-
export type ApprovalParams = {
|
|
311
|
-
request: RpcRequest;
|
|
312
|
-
displayData: DisplayData;
|
|
313
|
-
signingData: SigningData;
|
|
314
|
-
};
|
|
315
|
-
|
|
316
|
-
export type ApprovalResponse =
|
|
317
|
-
| {
|
|
318
|
-
result: Hex;
|
|
319
|
-
}
|
|
320
|
-
| {
|
|
321
|
-
error: RpcError;
|
|
322
|
-
};
|
|
323
|
-
|
|
324
|
-
export interface ApprovalController {
|
|
325
|
-
requestApproval: (params: ApprovalParams) => Promise<ApprovalResponse>;
|
|
326
|
-
onTransactionConfirmed: (txHash: Hex) => void;
|
|
327
|
-
onTransactionReverted: (txHash: Hex) => void;
|
|
328
|
-
}
|
|
File without changes
|
|
File without changes
|