@avalabs/evm-module 0.0.15 → 0.0.17

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 (43) hide show
  1. package/.turbo/turbo-build.log +10 -10
  2. package/.turbo/turbo-lint.log +1 -1
  3. package/.turbo/turbo-test.log +35 -15
  4. package/CHANGELOG.md +17 -0
  5. package/dist/index.cjs +31 -9
  6. package/dist/index.cjs.map +1 -1
  7. package/dist/index.d.cts +13 -2
  8. package/dist/index.d.ts +13 -2
  9. package/dist/index.js +28 -10
  10. package/dist/index.js.map +1 -1
  11. package/manifest.json +1 -1
  12. package/package.json +6 -5
  13. package/src/constants.ts +1 -0
  14. package/src/handlers/eth-send-transaction/eth-send-transaction.test.ts +233 -2
  15. package/src/handlers/eth-send-transaction/eth-send-transaction.ts +27 -8
  16. package/src/handlers/eth-sign/eth-sign.test.ts +320 -0
  17. package/src/handlers/eth-sign/eth-sign.ts +158 -0
  18. package/src/handlers/eth-sign/schemas/eth-sign-typed-data.ts +65 -0
  19. package/src/handlers/eth-sign/schemas/eth-sign.ts +9 -0
  20. package/src/handlers/eth-sign/schemas/parse-request-params/fixture.ts +47 -0
  21. package/src/handlers/eth-sign/schemas/parse-request-params/parse-request-params.test.ts +284 -0
  22. package/src/handlers/eth-sign/schemas/parse-request-params/parse-request-params.ts +94 -0
  23. package/src/handlers/eth-sign/schemas/personal-sign.ts +12 -0
  24. package/src/handlers/eth-sign/schemas/shared.ts +5 -0
  25. package/src/handlers/eth-sign/utils/beautify-message/beautify-message.test.ts +29 -0
  26. package/src/handlers/eth-sign/utils/beautify-message/beautify-message.ts +134 -0
  27. package/src/handlers/eth-sign/utils/is-typed-data-valid.ts +26 -0
  28. package/src/handlers/eth-sign/utils/typeguards.ts +10 -0
  29. package/src/handlers/get-balances/evm-balance-service/get-erc20-balances.test.ts +2 -2
  30. package/src/handlers/get-balances/evm-balance-service/get-erc20-balances.ts +4 -6
  31. package/src/handlers/get-balances/get-balances.test.ts +0 -5
  32. package/src/handlers/get-balances/get-balances.ts +14 -3
  33. package/src/handlers/get-balances/glacier-balance-service/get-erc20-balances.test.ts +0 -1
  34. package/src/handlers/get-balances/glacier-balance-service/get-erc20-balances.ts +10 -7
  35. package/src/handlers/get-tokens/get-tokens.test.ts +6 -6
  36. package/src/index.ts +1 -0
  37. package/src/module.ts +14 -0
  38. package/src/types.ts +9 -0
  39. package/src/utils/parse-erc20-transaction-type.ts +35 -0
  40. package/src/utils/process-transaction-simulation.test.ts +105 -0
  41. package/src/utils/process-transaction-simulation.ts +294 -0
  42. package/src/utils/scan-transaction.ts +63 -0
  43. package/tsconfig.json +6 -1
@@ -0,0 +1,63 @@
1
+ import Blockaid from '@blockaid/client';
2
+ import type { TransactionParams } from '../types';
3
+
4
+ const DUMMY_API_KEY = 'DUMMY_API_KEY'; // since we're using our own proxy and api key is handled there, we can use a dummy key here
5
+
6
+ export const scanTransaction = async ({
7
+ proxyApiUrl,
8
+ chainId,
9
+ params,
10
+ domain,
11
+ }: {
12
+ proxyApiUrl: string;
13
+ chainId: number;
14
+ params: TransactionParams;
15
+ domain?: string;
16
+ }): Promise<Blockaid.TransactionScanResponse> => {
17
+ const blockaid = new Blockaid({
18
+ baseURL: proxyApiUrl + '/proxy/blockaid/',
19
+ apiKey: DUMMY_API_KEY,
20
+ });
21
+
22
+ return blockaid.evm.transaction.scan({
23
+ account_address: params.from,
24
+ chain: chainId.toString(),
25
+ options: ['validation', 'simulation'],
26
+ data: {
27
+ from: params.from,
28
+ to: params.to,
29
+ data: params.data,
30
+ value: params.value,
31
+ gas: params.gas,
32
+ gas_price: params.gasPrice,
33
+ },
34
+ metadata: (domain && domain.length > 0 ? { domain } : { non_dapp: true }) as Blockaid.Evm.Metadata,
35
+ });
36
+ };
37
+
38
+ export const scanJsonRpc = async ({
39
+ proxyApiUrl,
40
+ chainId,
41
+ accountAddress,
42
+ data,
43
+ domain,
44
+ }: {
45
+ proxyApiUrl: string;
46
+ chainId: number;
47
+ accountAddress: string;
48
+ data: Blockaid.Evm.JsonRpcScanParams.Data;
49
+ domain?: string;
50
+ }): Promise<Blockaid.TransactionScanResponse> => {
51
+ const blockaid = new Blockaid({
52
+ baseURL: proxyApiUrl + '/proxy/blockaid/',
53
+ apiKey: DUMMY_API_KEY,
54
+ });
55
+
56
+ return blockaid.evm.jsonRpc.scan({
57
+ chain: chainId.toString(),
58
+ options: ['validation', 'simulation'],
59
+ account_address: accountAddress,
60
+ data,
61
+ metadata: (domain && domain.length > 0 ? { domain } : { non_dapp: true }) as Blockaid.Evm.Metadata,
62
+ });
63
+ };
package/tsconfig.json CHANGED
@@ -5,5 +5,10 @@
5
5
  "declaration": false,
6
6
  "incremental": false // Need to turn off because of tsup dts
7
7
  },
8
- "include": ["src"]
8
+ "include": ["src"],
9
+ "references": [
10
+ {
11
+ "path": "../../packages-internal/utils/tsconfig.json"
12
+ }
13
+ ]
9
14
  }