@avalabs/bridge-unified 1.0.1 → 2.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 (76) hide show
  1. package/.turbo/turbo-build.log +10 -10
  2. package/.turbo/turbo-lint.log +1 -1
  3. package/.turbo/turbo-test.log +25 -0
  4. package/CHANGELOG.md +12 -0
  5. package/README.md +137 -71
  6. package/dist/index.cjs +11 -3
  7. package/dist/index.cjs.map +1 -1
  8. package/dist/index.d.cts +207 -34
  9. package/dist/index.d.ts +207 -34
  10. package/dist/index.js +4 -3
  11. package/dist/index.js.map +1 -1
  12. package/jest.config.js +9 -0
  13. package/package.json +15 -9
  14. package/src/bridges/cctp/__mocks__/asset.mock.ts +15 -0
  15. package/src/bridges/cctp/__mocks__/bridge-transfer.mock.ts +48 -0
  16. package/src/bridges/cctp/__mocks__/chain.mocks.ts +31 -0
  17. package/src/bridges/cctp/__mocks__/config.mock.ts +42 -0
  18. package/src/bridges/cctp/abis/erc20.ts +117 -0
  19. package/src/bridges/cctp/abis/message-transmitter.ts +318 -0
  20. package/src/bridges/cctp/abis/token-router.ts +843 -0
  21. package/src/bridges/cctp/factory.test.ts +73 -0
  22. package/src/bridges/cctp/factory.ts +32 -0
  23. package/src/bridges/cctp/handlers/get-assets.test.ts +47 -0
  24. package/src/bridges/cctp/handlers/get-assets.ts +27 -0
  25. package/src/bridges/cctp/handlers/get-fees.test.ts +61 -0
  26. package/src/bridges/cctp/handlers/get-fees.ts +26 -0
  27. package/src/bridges/cctp/handlers/track-transfer.test.ts +775 -0
  28. package/src/bridges/cctp/handlers/track-transfer.ts +365 -0
  29. package/src/bridges/cctp/handlers/transfer-asset.test.ts +429 -0
  30. package/src/bridges/cctp/handlers/transfer-asset.ts +179 -0
  31. package/src/bridges/cctp/index.ts +1 -0
  32. package/src/bridges/cctp/types/chain.ts +4 -0
  33. package/src/bridges/cctp/types/config.ts +19 -0
  34. package/src/bridges/cctp/utils/config.test.ts +49 -0
  35. package/src/bridges/cctp/utils/config.ts +36 -0
  36. package/src/bridges/cctp/utils/transfer-data.test.ts +83 -0
  37. package/src/bridges/cctp/utils/transfer-data.ts +48 -0
  38. package/src/errors/bridge-error.ts +11 -0
  39. package/src/errors/bridge-initialization-error.ts +9 -0
  40. package/src/errors/bridge-unavailable-error.ts +9 -0
  41. package/src/errors/index.ts +4 -20
  42. package/src/errors/invalid-params-error.ts +9 -0
  43. package/src/index.ts +3 -1
  44. package/src/types/asset.ts +26 -0
  45. package/src/types/bridge.ts +63 -0
  46. package/src/types/chain.ts +10 -0
  47. package/src/types/config.ts +10 -0
  48. package/src/types/environment.ts +4 -0
  49. package/src/types/error.ts +19 -0
  50. package/src/types/index.ts +9 -0
  51. package/src/types/provider.ts +12 -0
  52. package/src/types/signer.ts +18 -0
  53. package/src/types/transfer.ts +35 -0
  54. package/src/unified-bridge-service.test.ts +208 -0
  55. package/src/unified-bridge-service.ts +90 -0
  56. package/src/utils/bridge-types.test.ts +103 -0
  57. package/src/utils/bridge-types.ts +32 -0
  58. package/src/utils/caip2.test.ts +44 -0
  59. package/src/utils/caip2.ts +41 -0
  60. package/src/utils/client.test.ts +97 -0
  61. package/src/utils/client.ts +44 -0
  62. package/src/utils/ensure-config.test.ts +43 -0
  63. package/src/utils/ensure-config.ts +12 -0
  64. package/src/utils/index.ts +2 -0
  65. package/src/utils/network-fee.test.ts +24 -0
  66. package/src/utils/network-fee.ts +6 -0
  67. package/src/utils/retry-promise.test.ts +115 -0
  68. package/src/utils/retry-promise.ts +72 -0
  69. package/src/utils/wait.test.ts +33 -0
  70. package/src/utils/wait.ts +4 -0
  71. package/tsconfig.jest.json +7 -0
  72. package/tsconfig.json +2 -1
  73. package/src/bridge-service.ts +0 -18
  74. package/src/handlers/get-bridge-router.ts +0 -25
  75. package/src/handlers/submit-and-watch-bridge-transaction.ts +0 -1
  76. package/src/handlers/submit-bridge-transaction-step.ts +0 -22
@@ -0,0 +1,318 @@
1
+ export const MESSAGE_TRANSMITTER_ABI = [
2
+ {
3
+ inputs: [
4
+ { internalType: 'uint32', name: '_localDomain', type: 'uint32' },
5
+ { internalType: 'address', name: '_attester', type: 'address' },
6
+ { internalType: 'uint32', name: '_maxMessageBodySize', type: 'uint32' },
7
+ { internalType: 'uint32', name: '_version', type: 'uint32' },
8
+ ],
9
+ stateMutability: 'nonpayable',
10
+ type: 'constructor',
11
+ },
12
+ {
13
+ anonymous: false,
14
+ inputs: [{ indexed: true, internalType: 'address', name: 'attester', type: 'address' }],
15
+ name: 'AttesterDisabled',
16
+ type: 'event',
17
+ },
18
+ {
19
+ anonymous: false,
20
+ inputs: [{ indexed: true, internalType: 'address', name: 'attester', type: 'address' }],
21
+ name: 'AttesterEnabled',
22
+ type: 'event',
23
+ },
24
+ {
25
+ anonymous: false,
26
+ inputs: [
27
+ { indexed: true, internalType: 'address', name: 'previousAttesterManager', type: 'address' },
28
+ { indexed: true, internalType: 'address', name: 'newAttesterManager', type: 'address' },
29
+ ],
30
+ name: 'AttesterManagerUpdated',
31
+ type: 'event',
32
+ },
33
+ {
34
+ anonymous: false,
35
+ inputs: [{ indexed: false, internalType: 'uint256', name: 'newMaxMessageBodySize', type: 'uint256' }],
36
+ name: 'MaxMessageBodySizeUpdated',
37
+ type: 'event',
38
+ },
39
+ {
40
+ anonymous: false,
41
+ inputs: [
42
+ { indexed: true, internalType: 'address', name: 'caller', type: 'address' },
43
+ { indexed: false, internalType: 'uint32', name: 'sourceDomain', type: 'uint32' },
44
+ { indexed: true, internalType: 'uint64', name: 'nonce', type: 'uint64' },
45
+ { indexed: false, internalType: 'bytes32', name: 'sender', type: 'bytes32' },
46
+ { indexed: false, internalType: 'bytes', name: 'messageBody', type: 'bytes' },
47
+ ],
48
+ name: 'MessageReceived',
49
+ type: 'event',
50
+ },
51
+ {
52
+ anonymous: false,
53
+ inputs: [{ indexed: false, internalType: 'bytes', name: 'message', type: 'bytes' }],
54
+ name: 'MessageSent',
55
+ type: 'event',
56
+ },
57
+ {
58
+ anonymous: false,
59
+ inputs: [
60
+ { indexed: true, internalType: 'address', name: 'previousOwner', type: 'address' },
61
+ { indexed: true, internalType: 'address', name: 'newOwner', type: 'address' },
62
+ ],
63
+ name: 'OwnershipTransferStarted',
64
+ type: 'event',
65
+ },
66
+ {
67
+ anonymous: false,
68
+ inputs: [
69
+ { indexed: true, internalType: 'address', name: 'previousOwner', type: 'address' },
70
+ { indexed: true, internalType: 'address', name: 'newOwner', type: 'address' },
71
+ ],
72
+ name: 'OwnershipTransferred',
73
+ type: 'event',
74
+ },
75
+ { anonymous: false, inputs: [], name: 'Pause', type: 'event' },
76
+ {
77
+ anonymous: false,
78
+ inputs: [{ indexed: true, internalType: 'address', name: 'newAddress', type: 'address' }],
79
+ name: 'PauserChanged',
80
+ type: 'event',
81
+ },
82
+ {
83
+ anonymous: false,
84
+ inputs: [{ indexed: true, internalType: 'address', name: 'newRescuer', type: 'address' }],
85
+ name: 'RescuerChanged',
86
+ type: 'event',
87
+ },
88
+ {
89
+ anonymous: false,
90
+ inputs: [
91
+ { indexed: false, internalType: 'uint256', name: 'oldSignatureThreshold', type: 'uint256' },
92
+ { indexed: false, internalType: 'uint256', name: 'newSignatureThreshold', type: 'uint256' },
93
+ ],
94
+ name: 'SignatureThresholdUpdated',
95
+ type: 'event',
96
+ },
97
+ { anonymous: false, inputs: [], name: 'Unpause', type: 'event' },
98
+ { inputs: [], name: 'acceptOwnership', outputs: [], stateMutability: 'nonpayable', type: 'function' },
99
+ {
100
+ inputs: [],
101
+ name: 'attesterManager',
102
+ outputs: [{ internalType: 'address', name: '', type: 'address' }],
103
+ stateMutability: 'view',
104
+ type: 'function',
105
+ },
106
+ {
107
+ inputs: [{ internalType: 'address', name: 'attester', type: 'address' }],
108
+ name: 'disableAttester',
109
+ outputs: [],
110
+ stateMutability: 'nonpayable',
111
+ type: 'function',
112
+ },
113
+ {
114
+ inputs: [{ internalType: 'address', name: 'newAttester', type: 'address' }],
115
+ name: 'enableAttester',
116
+ outputs: [],
117
+ stateMutability: 'nonpayable',
118
+ type: 'function',
119
+ },
120
+ {
121
+ inputs: [{ internalType: 'uint256', name: 'index', type: 'uint256' }],
122
+ name: 'getEnabledAttester',
123
+ outputs: [{ internalType: 'address', name: '', type: 'address' }],
124
+ stateMutability: 'view',
125
+ type: 'function',
126
+ },
127
+ {
128
+ inputs: [],
129
+ name: 'getNumEnabledAttesters',
130
+ outputs: [{ internalType: 'uint256', name: '', type: 'uint256' }],
131
+ stateMutability: 'view',
132
+ type: 'function',
133
+ },
134
+ {
135
+ inputs: [{ internalType: 'address', name: 'attester', type: 'address' }],
136
+ name: 'isEnabledAttester',
137
+ outputs: [{ internalType: 'bool', name: '', type: 'bool' }],
138
+ stateMutability: 'view',
139
+ type: 'function',
140
+ },
141
+ {
142
+ inputs: [],
143
+ name: 'localDomain',
144
+ outputs: [{ internalType: 'uint32', name: '', type: 'uint32' }],
145
+ stateMutability: 'view',
146
+ type: 'function',
147
+ },
148
+ {
149
+ inputs: [],
150
+ name: 'maxMessageBodySize',
151
+ outputs: [{ internalType: 'uint256', name: '', type: 'uint256' }],
152
+ stateMutability: 'view',
153
+ type: 'function',
154
+ },
155
+ {
156
+ inputs: [],
157
+ name: 'nextAvailableNonce',
158
+ outputs: [{ internalType: 'uint64', name: '', type: 'uint64' }],
159
+ stateMutability: 'view',
160
+ type: 'function',
161
+ },
162
+ {
163
+ inputs: [],
164
+ name: 'owner',
165
+ outputs: [{ internalType: 'address', name: '', type: 'address' }],
166
+ stateMutability: 'view',
167
+ type: 'function',
168
+ },
169
+ { inputs: [], name: 'pause', outputs: [], stateMutability: 'nonpayable', type: 'function' },
170
+ {
171
+ inputs: [],
172
+ name: 'paused',
173
+ outputs: [{ internalType: 'bool', name: '', type: 'bool' }],
174
+ stateMutability: 'view',
175
+ type: 'function',
176
+ },
177
+ {
178
+ inputs: [],
179
+ name: 'pauser',
180
+ outputs: [{ internalType: 'address', name: '', type: 'address' }],
181
+ stateMutability: 'view',
182
+ type: 'function',
183
+ },
184
+ {
185
+ inputs: [],
186
+ name: 'pendingOwner',
187
+ outputs: [{ internalType: 'address', name: '', type: 'address' }],
188
+ stateMutability: 'view',
189
+ type: 'function',
190
+ },
191
+ {
192
+ inputs: [
193
+ { internalType: 'bytes', name: 'message', type: 'bytes' },
194
+ { internalType: 'bytes', name: 'attestation', type: 'bytes' },
195
+ ],
196
+ name: 'receiveMessage',
197
+ outputs: [{ internalType: 'bool', name: 'success', type: 'bool' }],
198
+ stateMutability: 'nonpayable',
199
+ type: 'function',
200
+ },
201
+ {
202
+ inputs: [
203
+ { internalType: 'bytes', name: 'originalMessage', type: 'bytes' },
204
+ { internalType: 'bytes', name: 'originalAttestation', type: 'bytes' },
205
+ { internalType: 'bytes', name: 'newMessageBody', type: 'bytes' },
206
+ { internalType: 'bytes32', name: 'newDestinationCaller', type: 'bytes32' },
207
+ ],
208
+ name: 'replaceMessage',
209
+ outputs: [],
210
+ stateMutability: 'nonpayable',
211
+ type: 'function',
212
+ },
213
+ {
214
+ inputs: [
215
+ { internalType: 'contract IERC20', name: 'tokenContract', type: 'address' },
216
+ { internalType: 'address', name: 'to', type: 'address' },
217
+ { internalType: 'uint256', name: 'amount', type: 'uint256' },
218
+ ],
219
+ name: 'rescueERC20',
220
+ outputs: [],
221
+ stateMutability: 'nonpayable',
222
+ type: 'function',
223
+ },
224
+ {
225
+ inputs: [],
226
+ name: 'rescuer',
227
+ outputs: [{ internalType: 'address', name: '', type: 'address' }],
228
+ stateMutability: 'view',
229
+ type: 'function',
230
+ },
231
+ {
232
+ inputs: [
233
+ { internalType: 'uint32', name: 'destinationDomain', type: 'uint32' },
234
+ { internalType: 'bytes32', name: 'recipient', type: 'bytes32' },
235
+ { internalType: 'bytes', name: 'messageBody', type: 'bytes' },
236
+ ],
237
+ name: 'sendMessage',
238
+ outputs: [{ internalType: 'uint64', name: '', type: 'uint64' }],
239
+ stateMutability: 'nonpayable',
240
+ type: 'function',
241
+ },
242
+ {
243
+ inputs: [
244
+ { internalType: 'uint32', name: 'destinationDomain', type: 'uint32' },
245
+ { internalType: 'bytes32', name: 'recipient', type: 'bytes32' },
246
+ { internalType: 'bytes32', name: 'destinationCaller', type: 'bytes32' },
247
+ { internalType: 'bytes', name: 'messageBody', type: 'bytes' },
248
+ ],
249
+ name: 'sendMessageWithCaller',
250
+ outputs: [{ internalType: 'uint64', name: '', type: 'uint64' }],
251
+ stateMutability: 'nonpayable',
252
+ type: 'function',
253
+ },
254
+ {
255
+ inputs: [{ internalType: 'uint256', name: 'newMaxMessageBodySize', type: 'uint256' }],
256
+ name: 'setMaxMessageBodySize',
257
+ outputs: [],
258
+ stateMutability: 'nonpayable',
259
+ type: 'function',
260
+ },
261
+ {
262
+ inputs: [{ internalType: 'uint256', name: 'newSignatureThreshold', type: 'uint256' }],
263
+ name: 'setSignatureThreshold',
264
+ outputs: [],
265
+ stateMutability: 'nonpayable',
266
+ type: 'function',
267
+ },
268
+ {
269
+ inputs: [],
270
+ name: 'signatureThreshold',
271
+ outputs: [{ internalType: 'uint256', name: '', type: 'uint256' }],
272
+ stateMutability: 'view',
273
+ type: 'function',
274
+ },
275
+ {
276
+ inputs: [{ internalType: 'address', name: 'newOwner', type: 'address' }],
277
+ name: 'transferOwnership',
278
+ outputs: [],
279
+ stateMutability: 'nonpayable',
280
+ type: 'function',
281
+ },
282
+ { inputs: [], name: 'unpause', outputs: [], stateMutability: 'nonpayable', type: 'function' },
283
+ {
284
+ inputs: [{ internalType: 'address', name: 'newAttesterManager', type: 'address' }],
285
+ name: 'updateAttesterManager',
286
+ outputs: [],
287
+ stateMutability: 'nonpayable',
288
+ type: 'function',
289
+ },
290
+ {
291
+ inputs: [{ internalType: 'address', name: '_newPauser', type: 'address' }],
292
+ name: 'updatePauser',
293
+ outputs: [],
294
+ stateMutability: 'nonpayable',
295
+ type: 'function',
296
+ },
297
+ {
298
+ inputs: [{ internalType: 'address', name: 'newRescuer', type: 'address' }],
299
+ name: 'updateRescuer',
300
+ outputs: [],
301
+ stateMutability: 'nonpayable',
302
+ type: 'function',
303
+ },
304
+ {
305
+ inputs: [{ internalType: 'bytes32', name: '', type: 'bytes32' }],
306
+ name: 'usedNonces',
307
+ outputs: [{ internalType: 'uint256', name: '', type: 'uint256' }],
308
+ stateMutability: 'view',
309
+ type: 'function',
310
+ },
311
+ {
312
+ inputs: [],
313
+ name: 'version',
314
+ outputs: [{ internalType: 'uint32', name: '', type: 'uint32' }],
315
+ stateMutability: 'view',
316
+ type: 'function',
317
+ },
318
+ ] as const;