@avalabs/evm-module 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.
Files changed (57) hide show
  1. package/.turbo/turbo-build.log +10 -10
  2. package/.turbo/turbo-lint.log +1 -1
  3. package/.turbo/turbo-test.log +32 -8
  4. package/CHANGELOG.md +27 -0
  5. package/dist/index.cjs +29 -7
  6. package/dist/index.cjs.map +1 -1
  7. package/dist/index.d.cts +10 -6
  8. package/dist/index.d.ts +10 -6
  9. package/dist/index.js +27 -8
  10. package/dist/index.js.map +1 -1
  11. package/manifest.json +1 -1
  12. package/package.json +16 -9
  13. package/src/contracts/openzeppelin/ERC1155.ts +440 -0
  14. package/src/contracts/openzeppelin/ERC20.ts +330 -0
  15. package/src/contracts/openzeppelin/ERC721.ts +420 -0
  16. package/src/contracts/openzeppelin/common.ts +131 -0
  17. package/src/contracts/openzeppelin/factories/ERC1155__factory.ts +388 -0
  18. package/src/contracts/openzeppelin/factories/ERC20__factory.ts +353 -0
  19. package/src/contracts/openzeppelin/factories/ERC721__factory.ts +413 -0
  20. package/src/contracts/openzeppelin/factories/index.ts +6 -0
  21. package/src/contracts/openzeppelin/index.ts +10 -0
  22. package/src/handlers/eth-send-transaction/eth-send-transaction.test.ts +3 -3
  23. package/src/handlers/eth-send-transaction/eth-send-transaction.ts +4 -4
  24. package/src/handlers/eth-sign/eth-sign.test.ts +217 -0
  25. package/src/handlers/eth-sign/eth-sign.ts +137 -0
  26. package/src/handlers/eth-sign/schemas/eth-sign-typed-data.ts +65 -0
  27. package/src/handlers/eth-sign/schemas/eth-sign.ts +9 -0
  28. package/src/handlers/eth-sign/schemas/parse-request-params/fixture.ts +47 -0
  29. package/src/handlers/eth-sign/schemas/parse-request-params/parse-request-params.test.ts +284 -0
  30. package/src/handlers/eth-sign/schemas/parse-request-params/parse-request-params.ts +94 -0
  31. package/src/handlers/eth-sign/schemas/parse-request-params.ts +90 -0
  32. package/src/handlers/eth-sign/schemas/personal-sign.ts +12 -0
  33. package/src/handlers/eth-sign/schemas/shared.ts +5 -0
  34. package/src/handlers/eth-sign/utils/beautify-message/beautify-message.test.ts +29 -0
  35. package/src/handlers/eth-sign/utils/beautify-message/beautify-message.ts +134 -0
  36. package/src/handlers/eth-sign/utils/is-typed-data-valid.ts +26 -0
  37. package/src/handlers/eth-sign/utils/typeguards.ts +10 -0
  38. package/src/handlers/get-balances/evm-balance-service/get-erc20-balances.test.ts +78 -0
  39. package/src/handlers/get-balances/evm-balance-service/get-erc20-balances.ts +85 -0
  40. package/src/handlers/get-balances/evm-balance-service/get-native-token-balances.test.ts +102 -0
  41. package/src/handlers/get-balances/evm-balance-service/get-native-token-balances.ts +54 -0
  42. package/src/handlers/get-balances/get-balances.test.ts +252 -0
  43. package/src/handlers/get-balances/get-balances.ts +109 -0
  44. package/src/handlers/get-balances/glacier-balance-service/get-erc20-balances.test.ts +76 -0
  45. package/src/handlers/get-balances/glacier-balance-service/get-erc20-balances.ts +107 -0
  46. package/src/handlers/get-balances/glacier-balance-service/get-native-token-balances.test.ts +61 -0
  47. package/src/handlers/get-balances/glacier-balance-service/get-native-token-balances.ts +46 -0
  48. package/src/handlers/get-network-fee/get-network-fee.test.ts +0 -1
  49. package/src/handlers/get-network-fee/get-network-fee.ts +0 -1
  50. package/src/handlers/get-transaction-history/converters/evm-transaction-converter/get-transaction-from-glacier.test.ts +72 -59
  51. package/src/handlers/get-transaction-history/converters/evm-transaction-converter/get-transactions-from-glacier.ts +4 -11
  52. package/src/handlers/get-transaction-history/get-transaction-history.test.ts +7 -2
  53. package/src/handlers/get-transaction-history/get-transaction-history.ts +13 -3
  54. package/src/index.ts +1 -0
  55. package/src/module.ts +29 -7
  56. package/src/services/glacier-service/glacier-service.ts +259 -0
  57. package/tsconfig.json +7 -1
@@ -0,0 +1,353 @@
1
+ /* Autogenerated file. Do not edit manually. */
2
+ /* tslint:disable */
3
+ /* eslint-disable */
4
+ import {
5
+ Contract,
6
+ ContractFactory,
7
+ ContractTransactionResponse,
8
+ Interface,
9
+ } from "ethers";
10
+ import type { Signer, ContractDeployTransaction, ContractRunner } from "ethers";
11
+ import type { NonPayableOverrides } from "../common";
12
+ import type { ERC20, ERC20Interface } from "../ERC20";
13
+
14
+ const _abi = [
15
+ {
16
+ inputs: [
17
+ {
18
+ internalType: "string",
19
+ name: "name_",
20
+ type: "string",
21
+ },
22
+ {
23
+ internalType: "string",
24
+ name: "symbol_",
25
+ type: "string",
26
+ },
27
+ ],
28
+ stateMutability: "nonpayable",
29
+ type: "constructor",
30
+ },
31
+ {
32
+ anonymous: false,
33
+ inputs: [
34
+ {
35
+ indexed: true,
36
+ internalType: "address",
37
+ name: "owner",
38
+ type: "address",
39
+ },
40
+ {
41
+ indexed: true,
42
+ internalType: "address",
43
+ name: "spender",
44
+ type: "address",
45
+ },
46
+ {
47
+ indexed: false,
48
+ internalType: "uint256",
49
+ name: "value",
50
+ type: "uint256",
51
+ },
52
+ ],
53
+ name: "Approval",
54
+ type: "event",
55
+ },
56
+ {
57
+ anonymous: false,
58
+ inputs: [
59
+ {
60
+ indexed: true,
61
+ internalType: "address",
62
+ name: "from",
63
+ type: "address",
64
+ },
65
+ {
66
+ indexed: true,
67
+ internalType: "address",
68
+ name: "to",
69
+ type: "address",
70
+ },
71
+ {
72
+ indexed: false,
73
+ internalType: "uint256",
74
+ name: "value",
75
+ type: "uint256",
76
+ },
77
+ ],
78
+ name: "Transfer",
79
+ type: "event",
80
+ },
81
+ {
82
+ inputs: [
83
+ {
84
+ internalType: "address",
85
+ name: "owner",
86
+ type: "address",
87
+ },
88
+ {
89
+ internalType: "address",
90
+ name: "spender",
91
+ type: "address",
92
+ },
93
+ ],
94
+ name: "allowance",
95
+ outputs: [
96
+ {
97
+ internalType: "uint256",
98
+ name: "",
99
+ type: "uint256",
100
+ },
101
+ ],
102
+ stateMutability: "view",
103
+ type: "function",
104
+ },
105
+ {
106
+ inputs: [
107
+ {
108
+ internalType: "address",
109
+ name: "spender",
110
+ type: "address",
111
+ },
112
+ {
113
+ internalType: "uint256",
114
+ name: "amount",
115
+ type: "uint256",
116
+ },
117
+ ],
118
+ name: "approve",
119
+ outputs: [
120
+ {
121
+ internalType: "bool",
122
+ name: "",
123
+ type: "bool",
124
+ },
125
+ ],
126
+ stateMutability: "nonpayable",
127
+ type: "function",
128
+ },
129
+ {
130
+ inputs: [
131
+ {
132
+ internalType: "address",
133
+ name: "account",
134
+ type: "address",
135
+ },
136
+ ],
137
+ name: "balanceOf",
138
+ outputs: [
139
+ {
140
+ internalType: "uint256",
141
+ name: "",
142
+ type: "uint256",
143
+ },
144
+ ],
145
+ stateMutability: "view",
146
+ type: "function",
147
+ },
148
+ {
149
+ inputs: [],
150
+ name: "decimals",
151
+ outputs: [
152
+ {
153
+ internalType: "uint8",
154
+ name: "",
155
+ type: "uint8",
156
+ },
157
+ ],
158
+ stateMutability: "view",
159
+ type: "function",
160
+ },
161
+ {
162
+ inputs: [
163
+ {
164
+ internalType: "address",
165
+ name: "spender",
166
+ type: "address",
167
+ },
168
+ {
169
+ internalType: "uint256",
170
+ name: "subtractedValue",
171
+ type: "uint256",
172
+ },
173
+ ],
174
+ name: "decreaseAllowance",
175
+ outputs: [
176
+ {
177
+ internalType: "bool",
178
+ name: "",
179
+ type: "bool",
180
+ },
181
+ ],
182
+ stateMutability: "nonpayable",
183
+ type: "function",
184
+ },
185
+ {
186
+ inputs: [
187
+ {
188
+ internalType: "address",
189
+ name: "spender",
190
+ type: "address",
191
+ },
192
+ {
193
+ internalType: "uint256",
194
+ name: "addedValue",
195
+ type: "uint256",
196
+ },
197
+ ],
198
+ name: "increaseAllowance",
199
+ outputs: [
200
+ {
201
+ internalType: "bool",
202
+ name: "",
203
+ type: "bool",
204
+ },
205
+ ],
206
+ stateMutability: "nonpayable",
207
+ type: "function",
208
+ },
209
+ {
210
+ inputs: [],
211
+ name: "name",
212
+ outputs: [
213
+ {
214
+ internalType: "string",
215
+ name: "",
216
+ type: "string",
217
+ },
218
+ ],
219
+ stateMutability: "view",
220
+ type: "function",
221
+ },
222
+ {
223
+ inputs: [],
224
+ name: "symbol",
225
+ outputs: [
226
+ {
227
+ internalType: "string",
228
+ name: "",
229
+ type: "string",
230
+ },
231
+ ],
232
+ stateMutability: "view",
233
+ type: "function",
234
+ },
235
+ {
236
+ inputs: [],
237
+ name: "totalSupply",
238
+ outputs: [
239
+ {
240
+ internalType: "uint256",
241
+ name: "",
242
+ type: "uint256",
243
+ },
244
+ ],
245
+ stateMutability: "view",
246
+ type: "function",
247
+ },
248
+ {
249
+ inputs: [
250
+ {
251
+ internalType: "address",
252
+ name: "to",
253
+ type: "address",
254
+ },
255
+ {
256
+ internalType: "uint256",
257
+ name: "amount",
258
+ type: "uint256",
259
+ },
260
+ ],
261
+ name: "transfer",
262
+ outputs: [
263
+ {
264
+ internalType: "bool",
265
+ name: "",
266
+ type: "bool",
267
+ },
268
+ ],
269
+ stateMutability: "nonpayable",
270
+ type: "function",
271
+ },
272
+ {
273
+ inputs: [
274
+ {
275
+ internalType: "address",
276
+ name: "from",
277
+ type: "address",
278
+ },
279
+ {
280
+ internalType: "address",
281
+ name: "to",
282
+ type: "address",
283
+ },
284
+ {
285
+ internalType: "uint256",
286
+ name: "amount",
287
+ type: "uint256",
288
+ },
289
+ ],
290
+ name: "transferFrom",
291
+ outputs: [
292
+ {
293
+ internalType: "bool",
294
+ name: "",
295
+ type: "bool",
296
+ },
297
+ ],
298
+ stateMutability: "nonpayable",
299
+ type: "function",
300
+ },
301
+ ] as const;
302
+
303
+ const _bytecode =
304
+ "0x60806040523480156200001157600080fd5b5060405162000aed38038062000aed8339810160408190526200003491620001db565b81516200004990600390602085019062000068565b5080516200005f90600490602084019062000068565b50505062000281565b828054620000769062000245565b90600052602060002090601f0160209004810192826200009a5760008555620000e5565b82601f10620000b557805160ff1916838001178555620000e5565b82800160010185558215620000e5579182015b82811115620000e5578251825591602001919060010190620000c8565b50620000f3929150620000f7565b5090565b5b80821115620000f35760008155600101620000f8565b634e487b7160e01b600052604160045260246000fd5b600082601f8301126200013657600080fd5b81516001600160401b03808211156200015357620001536200010e565b604051601f8301601f19908116603f011681019082821181831017156200017e576200017e6200010e565b816040528381526020925086838588010111156200019b57600080fd5b600091505b83821015620001bf5785820183015181830184015290820190620001a0565b83821115620001d15760008385830101525b9695505050505050565b60008060408385031215620001ef57600080fd5b82516001600160401b03808211156200020757600080fd5b620002158683870162000124565b935060208501519150808211156200022c57600080fd5b506200023b8582860162000124565b9150509250929050565b600181811c908216806200025a57607f821691505b6020821081036200027b57634e487b7160e01b600052602260045260246000fd5b50919050565b61085c80620002916000396000f3fe608060405234801561001057600080fd5b50600436106100a95760003560e01c80633950935111610071578063395093511461012357806370a082311461013657806395d89b411461015f578063a457c2d714610167578063a9059cbb1461017a578063dd62ed3e1461018d57600080fd5b806306fdde03146100ae578063095ea7b3146100cc57806318160ddd146100ef57806323b872dd14610101578063313ce56714610114575b600080fd5b6100b66101a0565b6040516100c3919061069a565b60405180910390f35b6100df6100da36600461070b565b610232565b60405190151581526020016100c3565b6002545b6040519081526020016100c3565b6100df61010f366004610735565b61024a565b604051601281526020016100c3565b6100df61013136600461070b565b61026e565b6100f3610144366004610771565b6001600160a01b031660009081526020819052604090205490565b6100b6610290565b6100df61017536600461070b565b61029f565b6100df61018836600461070b565b61031f565b6100f361019b366004610793565b61032d565b6060600380546101af906107c6565b80601f01602080910402602001604051908101604052809291908181526020018280546101db906107c6565b80156102285780601f106101fd57610100808354040283529160200191610228565b820191906000526020600020905b81548152906001019060200180831161020b57829003601f168201915b5050505050905090565b600033610240818585610358565b5060019392505050565b60003361025885828561047c565b6102638585856104f6565b506001949350505050565b600033610240818585610281838361032d565b61028b9190610800565b610358565b6060600480546101af906107c6565b600033816102ad828661032d565b9050838110156103125760405162461bcd60e51b815260206004820152602560248201527f45524332303a2064656372656173656420616c6c6f77616e63652062656c6f77604482015264207a65726f60d81b60648201526084015b60405180910390fd5b6102638286868403610358565b6000336102408185856104f6565b6001600160a01b03918216600090815260016020908152604080832093909416825291909152205490565b6001600160a01b0383166103ba5760405162461bcd60e51b8152602060048201526024808201527f45524332303a20617070726f76652066726f6d20746865207a65726f206164646044820152637265737360e01b6064820152608401610309565b6001600160a01b03821661041b5760405162461bcd60e51b815260206004820152602260248201527f45524332303a20617070726f766520746f20746865207a65726f206164647265604482015261737360f01b6064820152608401610309565b6001600160a01b0383811660008181526001602090815260408083209487168084529482529182902085905590518481527f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925910160405180910390a3505050565b6000610488848461032d565b905060001981146104f057818110156104e35760405162461bcd60e51b815260206004820152601d60248201527f45524332303a20696e73756666696369656e7420616c6c6f77616e63650000006044820152606401610309565b6104f08484848403610358565b50505050565b6001600160a01b03831661055a5760405162461bcd60e51b815260206004820152602560248201527f45524332303a207472616e736665722066726f6d20746865207a65726f206164604482015264647265737360d81b6064820152608401610309565b6001600160a01b0382166105bc5760405162461bcd60e51b815260206004820152602360248201527f45524332303a207472616e7366657220746f20746865207a65726f206164647260448201526265737360e81b6064820152608401610309565b6001600160a01b038316600090815260208190526040902054818110156106345760405162461bcd60e51b815260206004820152602660248201527f45524332303a207472616e7366657220616d6f756e7420657863656564732062604482015265616c616e636560d01b6064820152608401610309565b6001600160a01b03848116600081815260208181526040808320878703905593871680835291849020805487019055925185815290927fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef910160405180910390a36104f0565b600060208083528351808285015260005b818110156106c7578581018301518582016040015282016106ab565b818111156106d9576000604083870101525b50601f01601f1916929092016040019392505050565b80356001600160a01b038116811461070657600080fd5b919050565b6000806040838503121561071e57600080fd5b610727836106ef565b946020939093013593505050565b60008060006060848603121561074a57600080fd5b610753846106ef565b9250610761602085016106ef565b9150604084013590509250925092565b60006020828403121561078357600080fd5b61078c826106ef565b9392505050565b600080604083850312156107a657600080fd5b6107af836106ef565b91506107bd602084016106ef565b90509250929050565b600181811c908216806107da57607f821691505b6020821081036107fa57634e487b7160e01b600052602260045260246000fd5b50919050565b6000821982111561082157634e487b7160e01b600052601160045260246000fd5b50019056fea2646970667358221220e7dc257596a973556752e9db5f465b21aad78d068ae819d0395e1f99a95065a964736f6c634300080d0033";
305
+
306
+ type ERC20ConstructorParams =
307
+ | [signer?: Signer]
308
+ | ConstructorParameters<typeof ContractFactory>;
309
+
310
+ const isSuperArgs = (
311
+ xs: ERC20ConstructorParams
312
+ ): xs is ConstructorParameters<typeof ContractFactory> => xs.length > 1;
313
+
314
+ export class ERC20__factory extends ContractFactory {
315
+ constructor(...args: ERC20ConstructorParams) {
316
+ if (isSuperArgs(args)) {
317
+ super(...args);
318
+ } else {
319
+ super(_abi, _bytecode, args[0]);
320
+ }
321
+ }
322
+
323
+ override getDeployTransaction(
324
+ name_: string,
325
+ symbol_: string,
326
+ overrides?: NonPayableOverrides & { from?: string }
327
+ ): Promise<ContractDeployTransaction> {
328
+ return super.getDeployTransaction(name_, symbol_, overrides || {});
329
+ }
330
+ override deploy(
331
+ name_: string,
332
+ symbol_: string,
333
+ overrides?: NonPayableOverrides & { from?: string }
334
+ ) {
335
+ return super.deploy(name_, symbol_, overrides || {}) as Promise<
336
+ ERC20 & {
337
+ deploymentTransaction(): ContractTransactionResponse;
338
+ }
339
+ >;
340
+ }
341
+ override connect(runner: ContractRunner | null): ERC20__factory {
342
+ return super.connect(runner) as ERC20__factory;
343
+ }
344
+
345
+ static readonly bytecode = _bytecode;
346
+ static readonly abi = _abi;
347
+ static createInterface(): ERC20Interface {
348
+ return new Interface(_abi) as ERC20Interface;
349
+ }
350
+ static connect(address: string, runner?: ContractRunner | null): ERC20 {
351
+ return new Contract(address, _abi, runner) as unknown as ERC20;
352
+ }
353
+ }