@avalabs/bridge-unified 2.1.1 → 3.0.0

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 (77) hide show
  1. package/LICENSE +9 -0
  2. package/README.md +115 -31
  3. package/dist/index.cjs +36 -10
  4. package/dist/index.cjs.map +1 -1
  5. package/dist/index.d.cts +252 -84
  6. package/dist/index.d.ts +252 -84
  7. package/dist/index.js +9 -4
  8. package/dist/index.js.map +1 -1
  9. package/package.json +14 -4
  10. package/.turbo/turbo-build.log +0 -22
  11. package/.turbo/turbo-lint.log +0 -4
  12. package/.turbo/turbo-test.log +0 -26
  13. package/CHANGELOG.md +0 -37
  14. package/jest.config.js +0 -9
  15. package/src/bridges/cctp/__mocks__/asset.mock.ts +0 -15
  16. package/src/bridges/cctp/__mocks__/bridge-transfer.mock.ts +0 -48
  17. package/src/bridges/cctp/__mocks__/chain.mocks.ts +0 -33
  18. package/src/bridges/cctp/__mocks__/config.mock.ts +0 -45
  19. package/src/bridges/cctp/abis/erc20.ts +0 -117
  20. package/src/bridges/cctp/abis/message-transmitter.ts +0 -318
  21. package/src/bridges/cctp/abis/token-router.ts +0 -843
  22. package/src/bridges/cctp/factory.test.ts +0 -73
  23. package/src/bridges/cctp/factory.ts +0 -36
  24. package/src/bridges/cctp/handlers/estimate-gas.test.ts +0 -110
  25. package/src/bridges/cctp/handlers/estimate-gas.ts +0 -58
  26. package/src/bridges/cctp/handlers/get-assets.test.ts +0 -47
  27. package/src/bridges/cctp/handlers/get-assets.ts +0 -27
  28. package/src/bridges/cctp/handlers/get-fees.test.ts +0 -61
  29. package/src/bridges/cctp/handlers/get-fees.ts +0 -26
  30. package/src/bridges/cctp/handlers/track-transfer.test.ts +0 -779
  31. package/src/bridges/cctp/handlers/track-transfer.ts +0 -365
  32. package/src/bridges/cctp/handlers/transfer-asset.test.ts +0 -429
  33. package/src/bridges/cctp/handlers/transfer-asset.ts +0 -179
  34. package/src/bridges/cctp/index.ts +0 -1
  35. package/src/bridges/cctp/types/chain.ts +0 -9
  36. package/src/bridges/cctp/types/config.ts +0 -20
  37. package/src/bridges/cctp/utils/build-tx.ts +0 -30
  38. package/src/bridges/cctp/utils/config.test.ts +0 -49
  39. package/src/bridges/cctp/utils/config.ts +0 -36
  40. package/src/bridges/cctp/utils/transfer-data.test.ts +0 -83
  41. package/src/bridges/cctp/utils/transfer-data.ts +0 -48
  42. package/src/errors/bridge-error.ts +0 -11
  43. package/src/errors/bridge-initialization-error.ts +0 -9
  44. package/src/errors/bridge-unavailable-error.ts +0 -9
  45. package/src/errors/index.ts +0 -4
  46. package/src/errors/invalid-params-error.ts +0 -9
  47. package/src/index.ts +0 -3
  48. package/src/types/asset.ts +0 -26
  49. package/src/types/bridge.ts +0 -64
  50. package/src/types/chain.ts +0 -10
  51. package/src/types/config.ts +0 -10
  52. package/src/types/environment.ts +0 -4
  53. package/src/types/error.ts +0 -19
  54. package/src/types/index.ts +0 -9
  55. package/src/types/provider.ts +0 -12
  56. package/src/types/signer.ts +0 -18
  57. package/src/types/transfer.ts +0 -35
  58. package/src/unified-bridge-service.test.ts +0 -209
  59. package/src/unified-bridge-service.ts +0 -97
  60. package/src/utils/bridge-types.test.ts +0 -103
  61. package/src/utils/bridge-types.ts +0 -32
  62. package/src/utils/caip2.test.ts +0 -44
  63. package/src/utils/caip2.ts +0 -41
  64. package/src/utils/client.test.ts +0 -97
  65. package/src/utils/client.ts +0 -44
  66. package/src/utils/ensure-config.test.ts +0 -43
  67. package/src/utils/ensure-config.ts +0 -12
  68. package/src/utils/index.ts +0 -2
  69. package/src/utils/network-fee.test.ts +0 -24
  70. package/src/utils/network-fee.ts +0 -6
  71. package/src/utils/retry-promise.test.ts +0 -115
  72. package/src/utils/retry-promise.ts +0 -72
  73. package/src/utils/wait.test.ts +0 -33
  74. package/src/utils/wait.ts +0 -4
  75. package/tsconfig.jest.json +0 -7
  76. package/tsconfig.json +0 -9
  77. package/tsup.config.ts +0 -4
package/package.json CHANGED
@@ -1,14 +1,23 @@
1
1
  {
2
2
  "name": "@avalabs/bridge-unified",
3
- "version": "2.1.1",
3
+ "license": "Limited Ecosystem License",
4
+ "version": "3.0.0",
4
5
  "main": "dist/index.cjs",
5
6
  "module": "dist/index.js",
6
7
  "typings": "dist/index.d.ts",
7
8
  "type": "module",
9
+ "files": [
10
+ "dist"
11
+ ],
8
12
  "dependencies": {
13
+ "@noble/hashes": "1.5.0",
14
+ "@scure/base": "1.1.9",
9
15
  "abitype": "0.9.3",
10
16
  "lodash": "4.17.21",
11
- "viem": "2.11.1"
17
+ "viem": "2.11.1",
18
+ "zod": "3.23.8",
19
+ "@scure/btc-signer": "1.3.2",
20
+ "coinselect": "3.1.13"
12
21
  },
13
22
  "devDependencies": {
14
23
  "@types/jest": "29.5.7",
@@ -16,11 +25,12 @@
16
25
  "jest": "29.7.0",
17
26
  "ts-jest": "29.1.1",
18
27
  "tsup": "7.2.0",
19
- "eslint-config-custom": "0.1.0",
20
- "@internal/tsup-config": "0.0.1"
28
+ "@internal/tsup-config": "0.0.1",
29
+ "eslint-config-custom": "0.1.0"
21
30
  },
22
31
  "scripts": {
23
32
  "build": "tsup",
33
+ "build:watch": "tsup --watch",
24
34
  "lint": "eslint \"src/**/*.ts\"",
25
35
  "test": "jest",
26
36
  "test:watch": "jest --watch"
@@ -1,22 +0,0 @@
1
-
2
- > @avalabs/bridge-unified@2.1.1 build /home/runner/work/consumer-sdks/consumer-sdks/packages/bridge-unified
3
- > tsup
4
-
5
- CLI Building entry: ./src/index.ts
6
- CLI Using tsconfig: tsconfig.json
7
- CLI tsup v7.2.0
8
- CLI Using tsup config: /home/runner/work/consumer-sdks/consumer-sdks/packages/bridge-unified/tsup.config.ts
9
- CLI Target: es2021
10
- CLI Cleaning output folder
11
- CJS Build start
12
- ESM Build start
13
- CJS dist/index.cjs 23.92 KB
14
- CJS dist/index.cjs.map 88.37 KB
15
- CJS ⚡️ Build success in 1972ms
16
- ESM dist/index.js 23.89 KB
17
- ESM dist/index.js.map 88.37 KB
18
- ESM ⚡️ Build success in 1977ms
19
- DTS Build start
20
- DTS ⚡️ Build success in 19494ms
21
- DTS dist/index.d.cts 6.09 KB
22
- DTS dist/index.d.ts 6.09 KB
@@ -1,4 +0,0 @@
1
-
2
- > @avalabs/bridge-unified@2.1.1 lint /home/runner/work/consumer-sdks/consumer-sdks/packages/bridge-unified
3
- > eslint "src/**/*.ts"
4
-
@@ -1,26 +0,0 @@
1
-
2
- > @avalabs/bridge-unified@2.1.1 test /home/runner/work/consumer-sdks/consumer-sdks/packages/bridge-unified
3
- > jest
4
-
5
- PASS src/bridges/cctp/handlers/track-transfer.test.ts (19.737 s)
6
- PASS src/bridges/cctp/handlers/transfer-asset.test.ts (5.48 s)
7
- PASS src/unified-bridge-service.test.ts
8
- PASS src/utils/retry-promise.test.ts
9
- PASS src/bridges/cctp/handlers/estimate-gas.test.ts
10
- PASS src/bridges/cctp/utils/transfer-data.test.ts
11
- PASS src/utils/bridge-types.test.ts
12
- PASS src/utils/client.test.ts
13
- PASS src/bridges/cctp/factory.test.ts
14
- PASS src/bridges/cctp/handlers/get-fees.test.ts
15
- PASS src/bridges/cctp/utils/config.test.ts
16
- PASS src/utils/ensure-config.test.ts
17
- PASS src/utils/caip2.test.ts
18
- PASS src/bridges/cctp/handlers/get-assets.test.ts
19
- PASS src/utils/network-fee.test.ts
20
- PASS src/utils/wait.test.ts
21
-
22
- Test Suites: 16 passed, 16 total
23
- Tests: 87 passed, 87 total
24
- Snapshots: 0 total
25
- Time: 41.328 s
26
- Ran all test suites.
package/CHANGELOG.md DELETED
@@ -1,37 +0,0 @@
1
- # @avalabs/unified-bridge
2
-
3
- ## 2.1.1
4
-
5
- ### Patch Changes
6
-
7
- - a7a0b51: upgrade viem to fix tx not found issue
8
-
9
- ## 2.1.0
10
-
11
- ### Minor Changes
12
-
13
- - 3b691bc: adds estimateGas() handler for bridge-unified sdk
14
-
15
- ## 2.0.1
16
-
17
- ### Patch Changes
18
-
19
- - 672c0e8: fix: lowercase addresses for comparison
20
-
21
- ## 2.0.0
22
-
23
- ### Major Changes
24
-
25
- - 7df7ca0: CCTP integration
26
-
27
- ### Minor Changes
28
-
29
- - 7df7ca0: use caip2 chain ids
30
- - 54757d4: Make sourceProvider optional, add bridged asset denomination info
31
- - b8f102b: update and validate startBlockNumber while tracking
32
-
33
- ## 1.0.1
34
-
35
- ### Patch Changes
36
-
37
- - a397015: Shared tsup config
package/jest.config.js DELETED
@@ -1,9 +0,0 @@
1
- /** @type {import('ts-jest').JestConfigWithTsJest} */
2
- export default {
3
- clearMocks: true,
4
- preset: 'ts-jest',
5
- testEnvironment: 'node',
6
- transform: {
7
- '.ts': ['ts-jest', { tsconfig: './tsconfig.jest.json' }],
8
- },
9
- };
@@ -1,15 +0,0 @@
1
- import { TokenType, type BridgeAsset } from '../../../types/asset';
2
- import { BridgeType } from '../../../types/bridge';
3
- import { TARGET_CHAIN } from './chain.mocks';
4
- import { SOURCE_TOKEN_ADDRESS } from './config.mock';
5
-
6
- export const BRIDGE_ASSET = {
7
- address: SOURCE_TOKEN_ADDRESS,
8
- name: 'USD Coin',
9
- symbol: 'USDC',
10
- decimals: 6,
11
- type: TokenType.ERC20,
12
- destinations: {
13
- [TARGET_CHAIN.chainId]: [BridgeType.CCTP],
14
- },
15
- } as BridgeAsset;
@@ -1,48 +0,0 @@
1
- import { BridgeType, type BridgeTransfer, Environment, type Provider, type TrackingParams } from '../../../types';
2
- import { SOURCE_CHAIN, TARGET_CHAIN } from './chain.mocks';
3
- import { SOURCE_MINIMUM_CONFIRMATIONS, TARGET_MINIMUM_CONFIRMATIONS } from './config.mock';
4
-
5
- const BRIDGE_TRANSFER_MOCK = {
6
- type: BridgeType.CCTP,
7
- environment: Environment.TEST,
8
- fromAddress: '0x787',
9
- toAddress: '0x787',
10
- amount: 1_000_000,
11
- symbol: 'USDC',
12
- bridgeFee: 2_000_000,
13
- sourceChain: SOURCE_CHAIN,
14
- sourceStartedAt: 0,
15
- sourceTxHash: '0x111',
16
- sourceConfirmationCount: 0,
17
- requiredSourceConfirmationCount: SOURCE_MINIMUM_CONFIRMATIONS,
18
- targetChain: TARGET_CHAIN,
19
- targetConfirmationCount: 0,
20
- requiredTargetConfirmationCount: TARGET_MINIMUM_CONFIRMATIONS,
21
- startBlockNumber: 0n,
22
- };
23
-
24
- export const getBridgeTransferMock = (props?: Partial<BridgeTransfer>) => ({
25
- ...BRIDGE_TRANSFER_MOCK,
26
- ...(props ?? {}),
27
- });
28
-
29
- export const getBridgeTrackinParams = ({
30
- bridgeTransfer,
31
- sourceProvider,
32
- targetProvider,
33
- updateListener,
34
- }: {
35
- bridgeTransfer?: Partial<BridgeTransfer>;
36
- sourceProvider?: Provider;
37
- targetProvider?: Provider;
38
- updateListener: (transfer: BridgeTransfer) => void;
39
- }) =>
40
- ({
41
- bridgeTransfer: {
42
- ...BRIDGE_TRANSFER_MOCK,
43
- ...(bridgeTransfer ?? {}),
44
- },
45
- sourceProvider,
46
- targetProvider,
47
- updateListener,
48
- }) as unknown as TrackingParams;
@@ -1,33 +0,0 @@
1
- import { TokenType } from '../../../types/asset';
2
-
3
- export const SOURCE_CHAIN = {
4
- name: 'Source chain',
5
- chainName: 'Source chain',
6
- chainId: 'eip155:1',
7
- rpcUrl: 'https://source-chain/rpc',
8
- utilityAddresses: {
9
- multicall: '0x0000000000000000000000000000000000000007',
10
- },
11
- networkToken: {
12
- decimals: 18,
13
- name: 'Source',
14
- symbol: 'SRC',
15
- type: TokenType.NATIVE,
16
- },
17
- } as const;
18
-
19
- export const TARGET_CHAIN = {
20
- name: 'Target chain',
21
- chainName: 'Target chain',
22
- chainId: 'eip155:2',
23
- rpcUrl: 'https://target-chain/rpc',
24
- utilityAddresses: {
25
- multicall: '0x0000000000000000000000000000000000000008',
26
- },
27
- networkToken: {
28
- decimals: 18,
29
- name: 'Target',
30
- symbol: 'TRGT',
31
- type: TokenType.NATIVE,
32
- },
33
- } as const;
@@ -1,45 +0,0 @@
1
- export const SOURCE_ROUTER_ADDRESS = '0x0000000000abcdef000000000000000000000001';
2
- // We use randomized casing in tests to make sure the implementation normalizes casing
3
- // when searching through logs.
4
- export const SOURCE_ROUTER_ADDRESS_RANDOMIZED_CASING = '0x0000000000aBcDeF000000000000000000000001';
5
- export const SOURCE_TRANSMITTER_ADDRESS = '0x0000000000000000000000000000000000000002';
6
- export const SOURCE_TOKEN_ADDRESS = '0x0000000000000000000000000000000000000003';
7
- export const SOURCE_MINIMUM_CONFIRMATIONS = 5;
8
-
9
- export const TARGET_ROUTER_ADDRESS = '0x0000000000000000000000000000000000000004';
10
- export const TARGET_TRANSMITTER_ADDRESS = '0x0000000000000000000000000000000000000005';
11
- export const TARGET_TOKEN_ADDRESS = '0x0000000000000000000000000000000000000006';
12
- export const TARGET_MINIMUM_CONFIRMATIONS = 10;
13
-
14
- export const CCTP_CONFIG = [
15
- {
16
- chainId: 'eip155:1',
17
- domain: 0,
18
- tokenRouterAddress: SOURCE_ROUTER_ADDRESS,
19
- messageTransmitterAddress: SOURCE_TRANSMITTER_ADDRESS,
20
- tokens: [
21
- {
22
- address: SOURCE_TOKEN_ADDRESS,
23
- name: 'USD Coin',
24
- symbol: 'USDC',
25
- decimals: 6,
26
- },
27
- ],
28
- minimumConfirmations: SOURCE_MINIMUM_CONFIRMATIONS,
29
- },
30
- {
31
- chainId: 'eip155:2',
32
- domain: 1,
33
- tokenRouterAddress: TARGET_ROUTER_ADDRESS,
34
- messageTransmitterAddress: TARGET_TRANSMITTER_ADDRESS,
35
- tokens: [
36
- {
37
- address: TARGET_TOKEN_ADDRESS,
38
- name: 'USD Coin',
39
- symbol: 'USDC',
40
- decimals: 6,
41
- },
42
- ],
43
- minimumConfirmations: TARGET_MINIMUM_CONFIRMATIONS,
44
- },
45
- ] as const;
@@ -1,117 +0,0 @@
1
- export const ERC20_ABI = [
2
- {
3
- constant: true,
4
- inputs: [],
5
- name: 'name',
6
- outputs: [{ name: '', type: 'string' }],
7
- payable: false,
8
- stateMutability: 'view',
9
- type: 'function',
10
- },
11
- {
12
- constant: false,
13
- inputs: [
14
- { name: '_spender', type: 'address' },
15
- { name: '_value', type: 'uint256' },
16
- ],
17
- name: 'approve',
18
- outputs: [{ name: '', type: 'bool' }],
19
- payable: false,
20
- stateMutability: 'nonpayable',
21
- type: 'function',
22
- },
23
- {
24
- constant: true,
25
- inputs: [],
26
- name: 'totalSupply',
27
- outputs: [{ name: '', type: 'uint256' }],
28
- payable: false,
29
- stateMutability: 'view',
30
- type: 'function',
31
- },
32
- {
33
- constant: false,
34
- inputs: [
35
- { name: '_from', type: 'address' },
36
- { name: '_to', type: 'address' },
37
- { name: '_value', type: 'uint256' },
38
- ],
39
- name: 'transferFrom',
40
- outputs: [{ name: '', type: 'bool' }],
41
- payable: false,
42
- stateMutability: 'nonpayable',
43
- type: 'function',
44
- },
45
- {
46
- constant: true,
47
- inputs: [],
48
- name: 'decimals',
49
- outputs: [{ name: '', type: 'uint8' }],
50
- payable: false,
51
- stateMutability: 'view',
52
- type: 'function',
53
- },
54
- {
55
- constant: true,
56
- inputs: [{ name: '_owner', type: 'address' }],
57
- name: 'balanceOf',
58
- outputs: [{ name: 'balance', type: 'uint256' }],
59
- payable: false,
60
- stateMutability: 'view',
61
- type: 'function',
62
- },
63
- {
64
- constant: true,
65
- inputs: [],
66
- name: 'symbol',
67
- outputs: [{ name: '', type: 'string' }],
68
- payable: false,
69
- stateMutability: 'view',
70
- type: 'function',
71
- },
72
- {
73
- constant: false,
74
- inputs: [
75
- { name: '_to', type: 'address' },
76
- { name: '_value', type: 'uint256' },
77
- ],
78
- name: 'transfer',
79
- outputs: [{ name: '', type: 'bool' }],
80
- payable: false,
81
- stateMutability: 'nonpayable',
82
- type: 'function',
83
- },
84
- {
85
- constant: true,
86
- inputs: [
87
- { name: '_owner', type: 'address' },
88
- { name: '_spender', type: 'address' },
89
- ],
90
- name: 'allowance',
91
- outputs: [{ name: '', type: 'uint256' }],
92
- payable: false,
93
- stateMutability: 'view',
94
- type: 'function',
95
- },
96
- { payable: true, stateMutability: 'payable', type: 'fallback' },
97
- {
98
- anonymous: false,
99
- inputs: [
100
- { indexed: true, name: 'owner', type: 'address' },
101
- { indexed: true, name: 'spender', type: 'address' },
102
- { indexed: false, name: 'value', type: 'uint256' },
103
- ],
104
- name: 'Approval',
105
- type: 'event',
106
- },
107
- {
108
- anonymous: false,
109
- inputs: [
110
- { indexed: true, name: 'from', type: 'address' },
111
- { indexed: true, name: 'to', type: 'address' },
112
- { indexed: false, name: 'value', type: 'uint256' },
113
- ],
114
- name: 'Transfer',
115
- type: 'event',
116
- },
117
- ] as const;