@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.
- package/.turbo/turbo-build.log +10 -10
- package/.turbo/turbo-lint.log +1 -1
- package/.turbo/turbo-test.log +25 -0
- package/CHANGELOG.md +12 -0
- package/README.md +137 -71
- package/dist/index.cjs +11 -3
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +207 -34
- package/dist/index.d.ts +207 -34
- package/dist/index.js +4 -3
- package/dist/index.js.map +1 -1
- package/jest.config.js +9 -0
- package/package.json +15 -9
- package/src/bridges/cctp/__mocks__/asset.mock.ts +15 -0
- package/src/bridges/cctp/__mocks__/bridge-transfer.mock.ts +48 -0
- package/src/bridges/cctp/__mocks__/chain.mocks.ts +31 -0
- package/src/bridges/cctp/__mocks__/config.mock.ts +42 -0
- package/src/bridges/cctp/abis/erc20.ts +117 -0
- package/src/bridges/cctp/abis/message-transmitter.ts +318 -0
- package/src/bridges/cctp/abis/token-router.ts +843 -0
- package/src/bridges/cctp/factory.test.ts +73 -0
- package/src/bridges/cctp/factory.ts +32 -0
- package/src/bridges/cctp/handlers/get-assets.test.ts +47 -0
- package/src/bridges/cctp/handlers/get-assets.ts +27 -0
- package/src/bridges/cctp/handlers/get-fees.test.ts +61 -0
- package/src/bridges/cctp/handlers/get-fees.ts +26 -0
- package/src/bridges/cctp/handlers/track-transfer.test.ts +775 -0
- package/src/bridges/cctp/handlers/track-transfer.ts +365 -0
- package/src/bridges/cctp/handlers/transfer-asset.test.ts +429 -0
- package/src/bridges/cctp/handlers/transfer-asset.ts +179 -0
- package/src/bridges/cctp/index.ts +1 -0
- package/src/bridges/cctp/types/chain.ts +4 -0
- package/src/bridges/cctp/types/config.ts +19 -0
- package/src/bridges/cctp/utils/config.test.ts +49 -0
- package/src/bridges/cctp/utils/config.ts +36 -0
- package/src/bridges/cctp/utils/transfer-data.test.ts +83 -0
- package/src/bridges/cctp/utils/transfer-data.ts +48 -0
- package/src/errors/bridge-error.ts +11 -0
- package/src/errors/bridge-initialization-error.ts +9 -0
- package/src/errors/bridge-unavailable-error.ts +9 -0
- package/src/errors/index.ts +4 -20
- package/src/errors/invalid-params-error.ts +9 -0
- package/src/index.ts +3 -1
- package/src/types/asset.ts +26 -0
- package/src/types/bridge.ts +63 -0
- package/src/types/chain.ts +10 -0
- package/src/types/config.ts +10 -0
- package/src/types/environment.ts +4 -0
- package/src/types/error.ts +19 -0
- package/src/types/index.ts +9 -0
- package/src/types/provider.ts +12 -0
- package/src/types/signer.ts +18 -0
- package/src/types/transfer.ts +35 -0
- package/src/unified-bridge-service.test.ts +208 -0
- package/src/unified-bridge-service.ts +90 -0
- package/src/utils/bridge-types.test.ts +103 -0
- package/src/utils/bridge-types.ts +32 -0
- package/src/utils/caip2.test.ts +44 -0
- package/src/utils/caip2.ts +41 -0
- package/src/utils/client.test.ts +97 -0
- package/src/utils/client.ts +44 -0
- package/src/utils/ensure-config.test.ts +43 -0
- package/src/utils/ensure-config.ts +12 -0
- package/src/utils/index.ts +2 -0
- package/src/utils/network-fee.test.ts +24 -0
- package/src/utils/network-fee.ts +6 -0
- package/src/utils/retry-promise.test.ts +115 -0
- package/src/utils/retry-promise.ts +72 -0
- package/src/utils/wait.test.ts +33 -0
- package/src/utils/wait.ts +4 -0
- package/tsconfig.jest.json +7 -0
- package/tsconfig.json +2 -1
- package/src/bridge-service.ts +0 -18
- package/src/handlers/get-bridge-router.ts +0 -25
- package/src/handlers/submit-and-watch-bridge-transaction.ts +0 -1
- package/src/handlers/submit-bridge-transaction-step.ts +0 -22
|
@@ -0,0 +1,775 @@
|
|
|
1
|
+
import { decodeEventLog } from 'viem';
|
|
2
|
+
import { BridgeType, type BridgeService, ErrorCode, ErrorReason } from '../../../types';
|
|
3
|
+
import { getClientForChain } from '../../../utils/client';
|
|
4
|
+
import { getNetworkFeeEVM } from '../../../utils/network-fee';
|
|
5
|
+
import { retryPromise } from '../../../utils/retry-promise';
|
|
6
|
+
import { getBridgeTrackinParams } from '../__mocks__/bridge-transfer.mock';
|
|
7
|
+
import { CCTP_CONFIG, SOURCE_ROUTER_ADDRESS, TARGET_TRANSMITTER_ADDRESS } from '../__mocks__/config.mock';
|
|
8
|
+
import { getTrackingDelayByChainId } from '../utils/config';
|
|
9
|
+
import * as tracking from './track-transfer';
|
|
10
|
+
import {
|
|
11
|
+
MAX_BLOCKS,
|
|
12
|
+
TRACKING_LIMIT_MS,
|
|
13
|
+
INITIAL_DELAY,
|
|
14
|
+
trackSourceTx,
|
|
15
|
+
trackTargetTx,
|
|
16
|
+
trackTransfer,
|
|
17
|
+
} from './track-transfer';
|
|
18
|
+
import { SOURCE_CHAIN, TARGET_CHAIN } from '../__mocks__/chain.mocks';
|
|
19
|
+
import { TOKEN_ROUTER_ABI } from '../abis/token-router';
|
|
20
|
+
import { InvalidParamsError } from '../../../errors';
|
|
21
|
+
|
|
22
|
+
jest.mock('../../../utils/retry-promise');
|
|
23
|
+
jest.mock('../../../utils/client');
|
|
24
|
+
jest.mock('../../../utils/network-fee');
|
|
25
|
+
jest.mock('../utils/config');
|
|
26
|
+
jest.mock('viem');
|
|
27
|
+
|
|
28
|
+
describe('CCTP trackTransfer', () => {
|
|
29
|
+
const now = 10;
|
|
30
|
+
const networkFee = 1000n;
|
|
31
|
+
const delay = 5000;
|
|
32
|
+
|
|
33
|
+
// used for updateListener callback param testing
|
|
34
|
+
// https://github.com/jestjs/jest/issues/434
|
|
35
|
+
const updateListenerWithoutReference = jest.fn();
|
|
36
|
+
const updateListener = jest.fn();
|
|
37
|
+
const doneMock = jest.fn();
|
|
38
|
+
|
|
39
|
+
const txMock = { hash: 'hash' };
|
|
40
|
+
const bridgeMock = {
|
|
41
|
+
type: BridgeType.CCTP,
|
|
42
|
+
config: CCTP_CONFIG,
|
|
43
|
+
ensureHasConfig: jest.fn(),
|
|
44
|
+
} as unknown as BridgeService;
|
|
45
|
+
const sourceClientMock = {
|
|
46
|
+
getTransactionReceipt: jest.fn(),
|
|
47
|
+
getTransaction: jest.fn(),
|
|
48
|
+
getTransactionConfirmations: jest.fn(),
|
|
49
|
+
};
|
|
50
|
+
const targetClientMock = {
|
|
51
|
+
getTransactionReceipt: jest.fn(),
|
|
52
|
+
getTransaction: jest.fn(),
|
|
53
|
+
getTransactionConfirmations: jest.fn(),
|
|
54
|
+
getBlockNumber: jest.fn(),
|
|
55
|
+
getLogs: jest.fn(),
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
beforeEach(() => {
|
|
59
|
+
jest.resetAllMocks();
|
|
60
|
+
jest.useFakeTimers().setSystemTime(new Date(now));
|
|
61
|
+
|
|
62
|
+
(retryPromise as jest.Mock).mockImplementation(
|
|
63
|
+
({ promise }: { promise: (done: () => unknown) => Promise<unknown> }) => ({
|
|
64
|
+
result: promise(doneMock),
|
|
65
|
+
}),
|
|
66
|
+
);
|
|
67
|
+
|
|
68
|
+
updateListener.mockImplementation((args) => updateListenerWithoutReference({ ...args }));
|
|
69
|
+
doneMock.mockImplementation((arg) => arg);
|
|
70
|
+
sourceClientMock.getTransaction.mockResolvedValue(txMock);
|
|
71
|
+
targetClientMock.getTransaction.mockResolvedValue(txMock);
|
|
72
|
+
(getNetworkFeeEVM as jest.Mock).mockReturnValue(networkFee);
|
|
73
|
+
(getTrackingDelayByChainId as jest.Mock).mockReturnValue(delay);
|
|
74
|
+
});
|
|
75
|
+
|
|
76
|
+
afterEach(() => {
|
|
77
|
+
jest.useRealTimers();
|
|
78
|
+
});
|
|
79
|
+
|
|
80
|
+
describe('combined tracking', () => {
|
|
81
|
+
afterEach(() => {
|
|
82
|
+
jest.restoreAllMocks();
|
|
83
|
+
});
|
|
84
|
+
|
|
85
|
+
it('calls ensureHasConfig', async () => {
|
|
86
|
+
const params = getBridgeTrackinParams({ updateListener });
|
|
87
|
+
const error = new Error('error');
|
|
88
|
+
(bridgeMock.ensureHasConfig as jest.Mock).mockRejectedValueOnce(error);
|
|
89
|
+
|
|
90
|
+
const { result } = trackTransfer(bridgeMock, params);
|
|
91
|
+
|
|
92
|
+
await expect(result).rejects.toThrow(error);
|
|
93
|
+
});
|
|
94
|
+
|
|
95
|
+
it('tracks the transactions correctly', async () => {
|
|
96
|
+
const initialParams = getBridgeTrackinParams({ updateListener });
|
|
97
|
+
const transferAfterSource = { ...initialParams.bridgeTransfer, metadata: { nonce: 1 } };
|
|
98
|
+
const transferAfterTarget = { ...transferAfterSource, completedAt: 999 };
|
|
99
|
+
|
|
100
|
+
const sourceCancel = jest.fn();
|
|
101
|
+
const targetCancel = jest.fn();
|
|
102
|
+
|
|
103
|
+
const sourceTrackerSpy = jest.spyOn(tracking, 'trackSourceTx').mockResolvedValueOnce({
|
|
104
|
+
result: new Promise((res) => res(transferAfterSource)),
|
|
105
|
+
cancel: sourceCancel,
|
|
106
|
+
});
|
|
107
|
+
|
|
108
|
+
const targetTrackerSpy = jest.spyOn(tracking, 'trackTargetTx').mockResolvedValueOnce({
|
|
109
|
+
result: new Promise((res) => res(transferAfterTarget)),
|
|
110
|
+
cancel: targetCancel,
|
|
111
|
+
});
|
|
112
|
+
|
|
113
|
+
const { result, cancel } = trackTransfer(bridgeMock, initialParams);
|
|
114
|
+
expect(await result).toStrictEqual(transferAfterTarget);
|
|
115
|
+
expect(sourceTrackerSpy).toHaveBeenCalledWith(bridgeMock.config, initialParams);
|
|
116
|
+
expect(targetTrackerSpy).toHaveBeenCalledWith(bridgeMock.config, {
|
|
117
|
+
...initialParams,
|
|
118
|
+
bridgeTransfer: transferAfterSource,
|
|
119
|
+
});
|
|
120
|
+
|
|
121
|
+
cancel();
|
|
122
|
+
expect(sourceCancel).not.toHaveBeenCalled();
|
|
123
|
+
expect(targetCancel).toHaveBeenCalled();
|
|
124
|
+
});
|
|
125
|
+
});
|
|
126
|
+
|
|
127
|
+
describe('source tx tracking', () => {
|
|
128
|
+
beforeEach(() => {
|
|
129
|
+
(getClientForChain as jest.Mock)
|
|
130
|
+
.mockReturnValueOnce(sourceClientMock)
|
|
131
|
+
.mockReturnValueOnce(targetClientMock)
|
|
132
|
+
.mockReturnValueOnce(targetClientMock);
|
|
133
|
+
});
|
|
134
|
+
|
|
135
|
+
it('resolves if bridging has already completed', async () => {
|
|
136
|
+
const params = getBridgeTrackinParams({
|
|
137
|
+
bridgeTransfer: {
|
|
138
|
+
completedAt: 1,
|
|
139
|
+
},
|
|
140
|
+
updateListener,
|
|
141
|
+
});
|
|
142
|
+
|
|
143
|
+
const { result } = await trackSourceTx(bridgeMock.config!, params);
|
|
144
|
+
expect(await result).toStrictEqual(params.bridgeTransfer);
|
|
145
|
+
expect(doneMock).toHaveBeenCalledWith(params.bridgeTransfer);
|
|
146
|
+
expect(updateListenerWithoutReference).not.toHaveBeenCalled();
|
|
147
|
+
|
|
148
|
+
expect(getTrackingDelayByChainId).toHaveBeenCalledWith(SOURCE_CHAIN.chainId);
|
|
149
|
+
expect(retryPromise).toHaveBeenCalledWith({
|
|
150
|
+
promise: expect.any(Function),
|
|
151
|
+
delay,
|
|
152
|
+
startAfter: INITIAL_DELAY,
|
|
153
|
+
});
|
|
154
|
+
});
|
|
155
|
+
|
|
156
|
+
it('resolves if message nonce is already known', async () => {
|
|
157
|
+
const params = getBridgeTrackinParams({
|
|
158
|
+
bridgeTransfer: {
|
|
159
|
+
metadata: { nonce: 1 },
|
|
160
|
+
},
|
|
161
|
+
updateListener,
|
|
162
|
+
});
|
|
163
|
+
|
|
164
|
+
const { result } = await trackSourceTx(bridgeMock.config!, params);
|
|
165
|
+
expect(await result).toStrictEqual(params.bridgeTransfer);
|
|
166
|
+
expect(doneMock).toHaveBeenCalledWith(params.bridgeTransfer);
|
|
167
|
+
expect(updateListenerWithoutReference).not.toHaveBeenCalled();
|
|
168
|
+
|
|
169
|
+
expect(getTrackingDelayByChainId).toHaveBeenCalledWith(SOURCE_CHAIN.chainId);
|
|
170
|
+
expect(retryPromise).toHaveBeenCalledWith({
|
|
171
|
+
promise: expect.any(Function),
|
|
172
|
+
delay,
|
|
173
|
+
startAfter: INITIAL_DELAY,
|
|
174
|
+
});
|
|
175
|
+
});
|
|
176
|
+
|
|
177
|
+
it('resolves if transaction has timed out', async () => {
|
|
178
|
+
const params = getBridgeTrackinParams({
|
|
179
|
+
updateListener,
|
|
180
|
+
});
|
|
181
|
+
const time = params.bridgeTransfer.sourceStartedAt + TRACKING_LIMIT_MS;
|
|
182
|
+
|
|
183
|
+
jest.useFakeTimers().setSystemTime(time);
|
|
184
|
+
|
|
185
|
+
const { result } = await trackSourceTx(bridgeMock.config!, params);
|
|
186
|
+
const expectedResult = { ...params.bridgeTransfer, completedAt: time, errorCode: ErrorCode.TIMEOUT };
|
|
187
|
+
|
|
188
|
+
expect(await result).toStrictEqual(expectedResult);
|
|
189
|
+
expect(doneMock).toHaveBeenCalledWith(expectedResult);
|
|
190
|
+
expect(updateListenerWithoutReference).toHaveBeenCalledTimes(1);
|
|
191
|
+
expect(updateListenerWithoutReference).toHaveBeenCalledWith(expectedResult);
|
|
192
|
+
|
|
193
|
+
expect(getTrackingDelayByChainId).toHaveBeenCalledWith(SOURCE_CHAIN.chainId);
|
|
194
|
+
expect(retryPromise).toHaveBeenCalledWith({
|
|
195
|
+
promise: expect.any(Function),
|
|
196
|
+
delay,
|
|
197
|
+
startAfter: INITIAL_DELAY,
|
|
198
|
+
});
|
|
199
|
+
});
|
|
200
|
+
|
|
201
|
+
it('resolves if transaction was reverted', async () => {
|
|
202
|
+
const receiptMock = {
|
|
203
|
+
status: 'reverted',
|
|
204
|
+
};
|
|
205
|
+
const params = getBridgeTrackinParams({
|
|
206
|
+
updateListener,
|
|
207
|
+
});
|
|
208
|
+
|
|
209
|
+
sourceClientMock.getTransactionReceipt.mockResolvedValueOnce(receiptMock);
|
|
210
|
+
|
|
211
|
+
const { result } = await trackSourceTx(bridgeMock.config!, params);
|
|
212
|
+
const expectedResult = {
|
|
213
|
+
...params.bridgeTransfer,
|
|
214
|
+
sourceNetworkFee: networkFee,
|
|
215
|
+
completedAt: now,
|
|
216
|
+
errorCode: ErrorCode.TRANSACTION_REVERTED,
|
|
217
|
+
};
|
|
218
|
+
|
|
219
|
+
expect(await result).toStrictEqual(expectedResult);
|
|
220
|
+
expect(doneMock).toHaveBeenCalledWith(expectedResult);
|
|
221
|
+
expect(updateListenerWithoutReference).toHaveBeenCalledTimes(2);
|
|
222
|
+
expect(updateListenerWithoutReference).toHaveBeenNthCalledWith(1, {
|
|
223
|
+
...params.bridgeTransfer,
|
|
224
|
+
sourceNetworkFee: networkFee,
|
|
225
|
+
});
|
|
226
|
+
expect(updateListenerWithoutReference).toHaveBeenNthCalledWith(2, expectedResult);
|
|
227
|
+
|
|
228
|
+
expect(sourceClientMock.getTransactionReceipt).toHaveBeenCalledWith({
|
|
229
|
+
hash: params.bridgeTransfer.sourceTxHash,
|
|
230
|
+
});
|
|
231
|
+
expect(sourceClientMock.getTransaction).toHaveBeenCalledWith({
|
|
232
|
+
hash: params.bridgeTransfer.sourceTxHash,
|
|
233
|
+
});
|
|
234
|
+
expect(getNetworkFeeEVM).toHaveBeenCalledWith(txMock, receiptMock);
|
|
235
|
+
|
|
236
|
+
expect(getTrackingDelayByChainId).toHaveBeenCalledWith(SOURCE_CHAIN.chainId);
|
|
237
|
+
expect(retryPromise).toHaveBeenCalledWith({
|
|
238
|
+
promise: expect.any(Function),
|
|
239
|
+
delay,
|
|
240
|
+
startAfter: INITIAL_DELAY,
|
|
241
|
+
});
|
|
242
|
+
});
|
|
243
|
+
|
|
244
|
+
it('does not resolve if more confirmations are needed', async () => {
|
|
245
|
+
const confirmations = 3;
|
|
246
|
+
const targetBlockNumber = 50n;
|
|
247
|
+
const receiptMock = {
|
|
248
|
+
status: 'succeeded',
|
|
249
|
+
};
|
|
250
|
+
|
|
251
|
+
const params = getBridgeTrackinParams({
|
|
252
|
+
updateListener,
|
|
253
|
+
bridgeTransfer: {
|
|
254
|
+
requiredSourceConfirmationCount: 5,
|
|
255
|
+
},
|
|
256
|
+
});
|
|
257
|
+
|
|
258
|
+
sourceClientMock.getTransactionReceipt.mockResolvedValueOnce(receiptMock);
|
|
259
|
+
sourceClientMock.getTransactionConfirmations.mockResolvedValueOnce(confirmations);
|
|
260
|
+
targetClientMock.getBlockNumber.mockResolvedValueOnce(targetBlockNumber);
|
|
261
|
+
|
|
262
|
+
const { result } = await trackSourceTx(bridgeMock.config!, params);
|
|
263
|
+
const expectedResult = {
|
|
264
|
+
...params.bridgeTransfer,
|
|
265
|
+
sourceNetworkFee: networkFee,
|
|
266
|
+
sourceConfirmationCount: confirmations,
|
|
267
|
+
startBlockNumber: targetBlockNumber,
|
|
268
|
+
};
|
|
269
|
+
|
|
270
|
+
expect(await result).toBeUndefined();
|
|
271
|
+
expect(doneMock).not.toHaveBeenCalled();
|
|
272
|
+
expect(updateListenerWithoutReference).toHaveBeenCalledTimes(2);
|
|
273
|
+
expect(updateListenerWithoutReference).toHaveBeenNthCalledWith(1, {
|
|
274
|
+
...params.bridgeTransfer,
|
|
275
|
+
sourceNetworkFee: networkFee,
|
|
276
|
+
});
|
|
277
|
+
expect(updateListenerWithoutReference).toHaveBeenNthCalledWith(2, expectedResult);
|
|
278
|
+
|
|
279
|
+
expect(sourceClientMock.getTransactionReceipt).toHaveBeenCalledWith({
|
|
280
|
+
hash: params.bridgeTransfer.sourceTxHash,
|
|
281
|
+
});
|
|
282
|
+
expect(sourceClientMock.getTransaction).toHaveBeenCalledWith({
|
|
283
|
+
hash: params.bridgeTransfer.sourceTxHash,
|
|
284
|
+
});
|
|
285
|
+
expect(getNetworkFeeEVM).toHaveBeenCalledWith(txMock, receiptMock);
|
|
286
|
+
expect(sourceClientMock.getTransactionConfirmations).toHaveBeenCalledWith({
|
|
287
|
+
hash: params.bridgeTransfer.sourceTxHash,
|
|
288
|
+
});
|
|
289
|
+
|
|
290
|
+
expect(getTrackingDelayByChainId).toHaveBeenCalledWith(SOURCE_CHAIN.chainId);
|
|
291
|
+
expect(retryPromise).toHaveBeenCalledWith({
|
|
292
|
+
promise: expect.any(Function),
|
|
293
|
+
delay,
|
|
294
|
+
startAfter: INITIAL_DELAY,
|
|
295
|
+
});
|
|
296
|
+
});
|
|
297
|
+
|
|
298
|
+
it('resolves if transaction has enough confirmations', async () => {
|
|
299
|
+
const nonce = 999;
|
|
300
|
+
const confirmations = 5;
|
|
301
|
+
const targetBlockNumber = 50n;
|
|
302
|
+
const receiptMock = {
|
|
303
|
+
status: 'succeeded',
|
|
304
|
+
logs: [{ address: SOURCE_ROUTER_ADDRESS }],
|
|
305
|
+
};
|
|
306
|
+
|
|
307
|
+
const params = getBridgeTrackinParams({
|
|
308
|
+
updateListener,
|
|
309
|
+
bridgeTransfer: {
|
|
310
|
+
requiredSourceConfirmationCount: confirmations,
|
|
311
|
+
},
|
|
312
|
+
});
|
|
313
|
+
|
|
314
|
+
(decodeEventLog as jest.Mock)
|
|
315
|
+
.mockReturnValueOnce({ eventName: 'TransferTokens' })
|
|
316
|
+
.mockReturnValueOnce({ args: { nonce } });
|
|
317
|
+
sourceClientMock.getTransactionReceipt.mockResolvedValueOnce(receiptMock);
|
|
318
|
+
sourceClientMock.getTransactionConfirmations.mockResolvedValueOnce(confirmations);
|
|
319
|
+
targetClientMock.getBlockNumber.mockResolvedValueOnce(targetBlockNumber);
|
|
320
|
+
|
|
321
|
+
const { result } = await trackSourceTx(bridgeMock.config!, params);
|
|
322
|
+
|
|
323
|
+
const expectedResult = {
|
|
324
|
+
...params.bridgeTransfer,
|
|
325
|
+
sourceNetworkFee: networkFee,
|
|
326
|
+
sourceConfirmationCount: confirmations,
|
|
327
|
+
targetStartedAt: now,
|
|
328
|
+
startBlockNumber: targetBlockNumber,
|
|
329
|
+
metadata: {
|
|
330
|
+
nonce,
|
|
331
|
+
},
|
|
332
|
+
};
|
|
333
|
+
|
|
334
|
+
expect(await result).toStrictEqual(expectedResult);
|
|
335
|
+
expect(doneMock).toHaveBeenCalledWith(expectedResult);
|
|
336
|
+
expect(updateListenerWithoutReference).toHaveBeenCalledTimes(4);
|
|
337
|
+
expect(updateListenerWithoutReference).toHaveBeenNthCalledWith(1, {
|
|
338
|
+
...params.bridgeTransfer,
|
|
339
|
+
sourceNetworkFee: networkFee,
|
|
340
|
+
});
|
|
341
|
+
expect(updateListenerWithoutReference).toHaveBeenNthCalledWith(2, {
|
|
342
|
+
...params.bridgeTransfer,
|
|
343
|
+
sourceNetworkFee: networkFee,
|
|
344
|
+
sourceConfirmationCount: confirmations,
|
|
345
|
+
});
|
|
346
|
+
expect(updateListenerWithoutReference).toHaveBeenNthCalledWith(3, {
|
|
347
|
+
...params.bridgeTransfer,
|
|
348
|
+
sourceNetworkFee: networkFee,
|
|
349
|
+
sourceConfirmationCount: confirmations,
|
|
350
|
+
startBlockNumber: targetBlockNumber,
|
|
351
|
+
});
|
|
352
|
+
expect(updateListenerWithoutReference).toHaveBeenNthCalledWith(4, expectedResult);
|
|
353
|
+
|
|
354
|
+
expect(sourceClientMock.getTransactionReceipt).toHaveBeenCalledWith({
|
|
355
|
+
hash: params.bridgeTransfer.sourceTxHash,
|
|
356
|
+
});
|
|
357
|
+
expect(sourceClientMock.getTransaction).toHaveBeenCalledWith({
|
|
358
|
+
hash: params.bridgeTransfer.sourceTxHash,
|
|
359
|
+
});
|
|
360
|
+
expect(getNetworkFeeEVM).toHaveBeenCalledWith(txMock, receiptMock);
|
|
361
|
+
expect(sourceClientMock.getTransactionConfirmations).toHaveBeenCalledWith({
|
|
362
|
+
hash: params.bridgeTransfer.sourceTxHash,
|
|
363
|
+
});
|
|
364
|
+
expect(decodeEventLog).toHaveBeenCalledTimes(2);
|
|
365
|
+
expect(decodeEventLog).toHaveBeenNthCalledWith(1, {
|
|
366
|
+
abi: TOKEN_ROUTER_ABI,
|
|
367
|
+
address: SOURCE_ROUTER_ADDRESS,
|
|
368
|
+
});
|
|
369
|
+
expect(decodeEventLog).toHaveBeenNthCalledWith(2, {
|
|
370
|
+
abi: TOKEN_ROUTER_ABI,
|
|
371
|
+
eventName: 'TransferTokens',
|
|
372
|
+
address: SOURCE_ROUTER_ADDRESS,
|
|
373
|
+
});
|
|
374
|
+
|
|
375
|
+
expect(getTrackingDelayByChainId).toHaveBeenCalledWith(SOURCE_CHAIN.chainId);
|
|
376
|
+
expect(retryPromise).toHaveBeenCalledWith({
|
|
377
|
+
promise: expect.any(Function),
|
|
378
|
+
delay,
|
|
379
|
+
startAfter: INITIAL_DELAY,
|
|
380
|
+
});
|
|
381
|
+
});
|
|
382
|
+
});
|
|
383
|
+
|
|
384
|
+
describe('target tx tracking', () => {
|
|
385
|
+
const nonce = 999;
|
|
386
|
+
const startBlockNumber = 12n;
|
|
387
|
+
const txHash = '0x124124';
|
|
388
|
+
const msgReceivedEvent = {
|
|
389
|
+
name: 'MessageReceived',
|
|
390
|
+
type: 'event',
|
|
391
|
+
inputs: [
|
|
392
|
+
{ indexed: true, internalType: 'address', name: 'caller', type: 'address' },
|
|
393
|
+
{ indexed: false, internalType: 'uint32', name: 'sourceDomain', type: 'uint32' },
|
|
394
|
+
{ indexed: true, internalType: 'uint64', name: 'nonce', type: 'uint64' },
|
|
395
|
+
{ indexed: false, internalType: 'bytes32', name: 'sender', type: 'bytes32' },
|
|
396
|
+
{ indexed: false, internalType: 'bytes', name: 'messageBody', type: 'bytes' },
|
|
397
|
+
],
|
|
398
|
+
};
|
|
399
|
+
|
|
400
|
+
beforeEach(() => {
|
|
401
|
+
(getClientForChain as jest.Mock).mockReturnValueOnce(targetClientMock);
|
|
402
|
+
});
|
|
403
|
+
|
|
404
|
+
it('throws if message nonce is missing', async () => {
|
|
405
|
+
const params = getBridgeTrackinParams({
|
|
406
|
+
updateListener,
|
|
407
|
+
});
|
|
408
|
+
|
|
409
|
+
await expect(trackTargetTx(bridgeMock.config!, params)).rejects.toThrow(
|
|
410
|
+
new InvalidParamsError(ErrorReason.INVALID_PARAMS, 'nonce is missing'),
|
|
411
|
+
);
|
|
412
|
+
});
|
|
413
|
+
|
|
414
|
+
it('throws if start block number is missing', async () => {
|
|
415
|
+
const params = getBridgeTrackinParams({
|
|
416
|
+
updateListener,
|
|
417
|
+
bridgeTransfer: {
|
|
418
|
+
metadata: {
|
|
419
|
+
nonce,
|
|
420
|
+
},
|
|
421
|
+
},
|
|
422
|
+
});
|
|
423
|
+
|
|
424
|
+
await expect(trackTargetTx(bridgeMock.config!, params)).rejects.toThrow(
|
|
425
|
+
new InvalidParamsError(ErrorReason.INVALID_PARAMS, `startBlockNumber is missing`),
|
|
426
|
+
);
|
|
427
|
+
});
|
|
428
|
+
|
|
429
|
+
it('resolves if bridging has already completed', async () => {
|
|
430
|
+
const params = getBridgeTrackinParams({
|
|
431
|
+
bridgeTransfer: {
|
|
432
|
+
completedAt: 1,
|
|
433
|
+
startBlockNumber,
|
|
434
|
+
metadata: {
|
|
435
|
+
nonce,
|
|
436
|
+
},
|
|
437
|
+
},
|
|
438
|
+
updateListener,
|
|
439
|
+
});
|
|
440
|
+
|
|
441
|
+
const { result } = await trackTargetTx(bridgeMock.config!, params);
|
|
442
|
+
expect(await result).toStrictEqual(params.bridgeTransfer);
|
|
443
|
+
expect(doneMock).toHaveBeenCalledWith(params.bridgeTransfer);
|
|
444
|
+
expect(updateListenerWithoutReference).not.toHaveBeenCalled();
|
|
445
|
+
|
|
446
|
+
expect(getTrackingDelayByChainId).toHaveBeenCalledWith(TARGET_CHAIN.chainId);
|
|
447
|
+
expect(retryPromise).toHaveBeenCalledWith({
|
|
448
|
+
promise: expect.any(Function),
|
|
449
|
+
delay,
|
|
450
|
+
startAfter: INITIAL_DELAY,
|
|
451
|
+
});
|
|
452
|
+
});
|
|
453
|
+
|
|
454
|
+
it('resolves if transaction has timed out', async () => {
|
|
455
|
+
const params = getBridgeTrackinParams({
|
|
456
|
+
bridgeTransfer: {
|
|
457
|
+
startBlockNumber,
|
|
458
|
+
metadata: {
|
|
459
|
+
nonce,
|
|
460
|
+
},
|
|
461
|
+
},
|
|
462
|
+
updateListener,
|
|
463
|
+
});
|
|
464
|
+
|
|
465
|
+
const time = params.bridgeTransfer.sourceStartedAt + TRACKING_LIMIT_MS;
|
|
466
|
+
|
|
467
|
+
jest.useFakeTimers().setSystemTime(time);
|
|
468
|
+
|
|
469
|
+
const expectedResult = {
|
|
470
|
+
...params.bridgeTransfer,
|
|
471
|
+
completedAt: time,
|
|
472
|
+
errorCode: ErrorCode.TIMEOUT,
|
|
473
|
+
};
|
|
474
|
+
|
|
475
|
+
const { result } = await trackTargetTx(bridgeMock.config!, params);
|
|
476
|
+
expect(await result).toStrictEqual(expectedResult);
|
|
477
|
+
expect(doneMock).toHaveBeenCalledWith(expectedResult);
|
|
478
|
+
expect(updateListenerWithoutReference).toHaveBeenCalledTimes(1);
|
|
479
|
+
expect(updateListenerWithoutReference).toHaveBeenCalledWith(expectedResult);
|
|
480
|
+
|
|
481
|
+
expect(getTrackingDelayByChainId).toHaveBeenCalledWith(TARGET_CHAIN.chainId);
|
|
482
|
+
expect(retryPromise).toHaveBeenCalledWith({
|
|
483
|
+
promise: expect.any(Function),
|
|
484
|
+
delay,
|
|
485
|
+
startAfter: INITIAL_DELAY,
|
|
486
|
+
});
|
|
487
|
+
});
|
|
488
|
+
|
|
489
|
+
it('resolves if startBlockNumber became invalid', async () => {
|
|
490
|
+
(retryPromise as jest.Mock).mockImplementationOnce(
|
|
491
|
+
({ promise }: { promise: (done: () => unknown) => Promise<unknown> }) => ({
|
|
492
|
+
result: promise(doneMock).then(() => promise(doneMock)),
|
|
493
|
+
}),
|
|
494
|
+
);
|
|
495
|
+
|
|
496
|
+
const targetBlockNumber = 0n;
|
|
497
|
+
|
|
498
|
+
const params = getBridgeTrackinParams({
|
|
499
|
+
bridgeTransfer: {
|
|
500
|
+
requiredTargetConfirmationCount: 5,
|
|
501
|
+
startBlockNumber,
|
|
502
|
+
metadata: {
|
|
503
|
+
nonce,
|
|
504
|
+
},
|
|
505
|
+
},
|
|
506
|
+
updateListener,
|
|
507
|
+
});
|
|
508
|
+
|
|
509
|
+
const expectedResult = {
|
|
510
|
+
...params.bridgeTransfer,
|
|
511
|
+
completedAt: now,
|
|
512
|
+
startBlockNumber: targetBlockNumber,
|
|
513
|
+
errorCode: ErrorCode.INVALID_PARAMS,
|
|
514
|
+
};
|
|
515
|
+
|
|
516
|
+
targetClientMock.getBlockNumber.mockResolvedValueOnce(targetBlockNumber);
|
|
517
|
+
targetClientMock.getLogs.mockResolvedValueOnce([]);
|
|
518
|
+
|
|
519
|
+
const { result } = await trackTargetTx(bridgeMock.config!, params);
|
|
520
|
+
expect(await result).toStrictEqual(expectedResult);
|
|
521
|
+
expect(doneMock).toHaveBeenCalledWith(expectedResult);
|
|
522
|
+
|
|
523
|
+
expect(updateListenerWithoutReference).toHaveBeenCalledTimes(2);
|
|
524
|
+
expect(updateListenerWithoutReference).toHaveBeenNthCalledWith(1, {
|
|
525
|
+
...params.bridgeTransfer,
|
|
526
|
+
startBlockNumber: targetBlockNumber,
|
|
527
|
+
});
|
|
528
|
+
expect(updateListenerWithoutReference).toHaveBeenNthCalledWith(2, expectedResult);
|
|
529
|
+
|
|
530
|
+
expect(targetClientMock.getTransactionReceipt).not.toHaveBeenCalled();
|
|
531
|
+
expect(retryPromise).toHaveBeenCalledWith({
|
|
532
|
+
promise: expect.any(Function),
|
|
533
|
+
delay,
|
|
534
|
+
startAfter: INITIAL_DELAY,
|
|
535
|
+
});
|
|
536
|
+
});
|
|
537
|
+
|
|
538
|
+
it('resolves if transaction was reverted', async () => {
|
|
539
|
+
const targetBlockNumber = 50n;
|
|
540
|
+
const receiptMock = {
|
|
541
|
+
status: 'reverted',
|
|
542
|
+
};
|
|
543
|
+
const params = getBridgeTrackinParams({
|
|
544
|
+
bridgeTransfer: {
|
|
545
|
+
startBlockNumber,
|
|
546
|
+
metadata: {
|
|
547
|
+
nonce,
|
|
548
|
+
},
|
|
549
|
+
},
|
|
550
|
+
updateListener,
|
|
551
|
+
});
|
|
552
|
+
|
|
553
|
+
targetClientMock.getLogs.mockResolvedValueOnce([{ transactionHash: txHash }]);
|
|
554
|
+
targetClientMock.getTransactionReceipt.mockResolvedValueOnce(receiptMock);
|
|
555
|
+
targetClientMock.getBlockNumber.mockResolvedValueOnce(targetBlockNumber);
|
|
556
|
+
|
|
557
|
+
const expectedResult = {
|
|
558
|
+
...params.bridgeTransfer,
|
|
559
|
+
targetTxHash: txHash,
|
|
560
|
+
targetNetworkFee: networkFee,
|
|
561
|
+
completedAt: now,
|
|
562
|
+
errorCode: ErrorCode.TRANSACTION_REVERTED,
|
|
563
|
+
};
|
|
564
|
+
|
|
565
|
+
const { result } = await trackTargetTx(bridgeMock.config!, params);
|
|
566
|
+
expect(await result).toStrictEqual(expectedResult);
|
|
567
|
+
expect(doneMock).toHaveBeenCalledWith(expectedResult);
|
|
568
|
+
expect(updateListenerWithoutReference).toHaveBeenCalledTimes(3);
|
|
569
|
+
expect(updateListenerWithoutReference).toHaveBeenNthCalledWith(1, {
|
|
570
|
+
...params.bridgeTransfer,
|
|
571
|
+
targetTxHash: txHash,
|
|
572
|
+
});
|
|
573
|
+
expect(updateListenerWithoutReference).toHaveBeenNthCalledWith(2, {
|
|
574
|
+
...params.bridgeTransfer,
|
|
575
|
+
targetTxHash: txHash,
|
|
576
|
+
targetNetworkFee: networkFee,
|
|
577
|
+
});
|
|
578
|
+
expect(updateListenerWithoutReference).toHaveBeenNthCalledWith(3, expectedResult);
|
|
579
|
+
|
|
580
|
+
expect(targetClientMock.getLogs).toHaveBeenCalledWith({
|
|
581
|
+
address: TARGET_TRANSMITTER_ADDRESS,
|
|
582
|
+
event: msgReceivedEvent,
|
|
583
|
+
args: { nonce },
|
|
584
|
+
fromBlock: 'earliest',
|
|
585
|
+
toBlock: 'latest',
|
|
586
|
+
});
|
|
587
|
+
expect(targetClientMock.getTransactionReceipt).toHaveBeenCalledWith({ hash: txHash });
|
|
588
|
+
expect(targetClientMock.getTransaction).toHaveBeenCalledWith({ hash: txHash });
|
|
589
|
+
expect(getNetworkFeeEVM).toHaveBeenCalledWith(txMock, receiptMock);
|
|
590
|
+
|
|
591
|
+
expect(getTrackingDelayByChainId).toHaveBeenCalledWith(TARGET_CHAIN.chainId);
|
|
592
|
+
expect(retryPromise).toHaveBeenCalledWith({
|
|
593
|
+
promise: expect.any(Function),
|
|
594
|
+
delay,
|
|
595
|
+
startAfter: INITIAL_DELAY,
|
|
596
|
+
});
|
|
597
|
+
});
|
|
598
|
+
|
|
599
|
+
it('does not resolve if transaction hash is unknown', async () => {
|
|
600
|
+
const targetBlockNumber = 50;
|
|
601
|
+
|
|
602
|
+
const params = getBridgeTrackinParams({
|
|
603
|
+
bridgeTransfer: {
|
|
604
|
+
requiredTargetConfirmationCount: 5,
|
|
605
|
+
startBlockNumber,
|
|
606
|
+
metadata: {
|
|
607
|
+
nonce,
|
|
608
|
+
},
|
|
609
|
+
},
|
|
610
|
+
updateListener,
|
|
611
|
+
});
|
|
612
|
+
|
|
613
|
+
targetClientMock.getBlockNumber.mockResolvedValueOnce(targetBlockNumber);
|
|
614
|
+
targetClientMock.getLogs.mockResolvedValueOnce([]);
|
|
615
|
+
|
|
616
|
+
const { result } = await trackTargetTx(bridgeMock.config!, params);
|
|
617
|
+
expect(await result).toBeUndefined();
|
|
618
|
+
expect(doneMock).not.toHaveBeenCalled();
|
|
619
|
+
|
|
620
|
+
expect(updateListenerWithoutReference).toHaveBeenCalledTimes(1);
|
|
621
|
+
expect(updateListenerWithoutReference).toHaveBeenCalledWith({
|
|
622
|
+
...params.bridgeTransfer,
|
|
623
|
+
startBlockNumber: targetBlockNumber,
|
|
624
|
+
});
|
|
625
|
+
|
|
626
|
+
expect(targetClientMock.getLogs).toHaveBeenCalledWith({
|
|
627
|
+
address: TARGET_TRANSMITTER_ADDRESS,
|
|
628
|
+
event: msgReceivedEvent,
|
|
629
|
+
args: { nonce },
|
|
630
|
+
fromBlock: 'earliest',
|
|
631
|
+
toBlock: 'latest',
|
|
632
|
+
});
|
|
633
|
+
|
|
634
|
+
expect(targetClientMock.getTransactionReceipt).not.toHaveBeenCalled();
|
|
635
|
+
expect(retryPromise).toHaveBeenCalledWith({
|
|
636
|
+
promise: expect.any(Function),
|
|
637
|
+
delay,
|
|
638
|
+
startAfter: INITIAL_DELAY,
|
|
639
|
+
});
|
|
640
|
+
});
|
|
641
|
+
|
|
642
|
+
it('does not resolve if more confirmations are needed', async () => {
|
|
643
|
+
const targetBlockNumber = 50;
|
|
644
|
+
const receiptMock = {
|
|
645
|
+
status: 'succeeded',
|
|
646
|
+
};
|
|
647
|
+
const confirmations = 3;
|
|
648
|
+
const params = getBridgeTrackinParams({
|
|
649
|
+
bridgeTransfer: {
|
|
650
|
+
requiredTargetConfirmationCount: 5,
|
|
651
|
+
startBlockNumber,
|
|
652
|
+
metadata: {
|
|
653
|
+
nonce,
|
|
654
|
+
},
|
|
655
|
+
},
|
|
656
|
+
updateListener,
|
|
657
|
+
});
|
|
658
|
+
|
|
659
|
+
targetClientMock.getLogs.mockResolvedValueOnce([{ transactionHash: txHash }]);
|
|
660
|
+
targetClientMock.getTransactionReceipt.mockResolvedValueOnce(receiptMock);
|
|
661
|
+
targetClientMock.getTransactionConfirmations.mockResolvedValueOnce(confirmations);
|
|
662
|
+
targetClientMock.getBlockNumber.mockResolvedValueOnce(targetBlockNumber);
|
|
663
|
+
|
|
664
|
+
const { result } = await trackTargetTx(bridgeMock.config!, params);
|
|
665
|
+
expect(await result).toBeUndefined();
|
|
666
|
+
expect(doneMock).not.toHaveBeenCalled();
|
|
667
|
+
expect(updateListenerWithoutReference).toHaveBeenCalledTimes(3);
|
|
668
|
+
expect(updateListenerWithoutReference).toHaveBeenNthCalledWith(1, {
|
|
669
|
+
...params.bridgeTransfer,
|
|
670
|
+
targetTxHash: txHash,
|
|
671
|
+
});
|
|
672
|
+
expect(updateListenerWithoutReference).toHaveBeenNthCalledWith(2, {
|
|
673
|
+
...params.bridgeTransfer,
|
|
674
|
+
targetTxHash: txHash,
|
|
675
|
+
targetNetworkFee: networkFee,
|
|
676
|
+
});
|
|
677
|
+
expect(updateListenerWithoutReference).toHaveBeenNthCalledWith(3, {
|
|
678
|
+
...params.bridgeTransfer,
|
|
679
|
+
targetTxHash: txHash,
|
|
680
|
+
targetNetworkFee: networkFee,
|
|
681
|
+
targetConfirmationCount: confirmations,
|
|
682
|
+
});
|
|
683
|
+
|
|
684
|
+
expect(targetClientMock.getLogs).toHaveBeenCalledWith({
|
|
685
|
+
address: TARGET_TRANSMITTER_ADDRESS,
|
|
686
|
+
event: msgReceivedEvent,
|
|
687
|
+
args: { nonce },
|
|
688
|
+
fromBlock: 'earliest',
|
|
689
|
+
toBlock: 'latest',
|
|
690
|
+
});
|
|
691
|
+
expect(targetClientMock.getTransactionReceipt).toHaveBeenCalledWith({ hash: txHash });
|
|
692
|
+
expect(targetClientMock.getTransaction).toHaveBeenCalledWith({ hash: txHash });
|
|
693
|
+
expect(getNetworkFeeEVM).toHaveBeenCalledWith(txMock, receiptMock);
|
|
694
|
+
expect(targetClientMock.getTransactionConfirmations).toHaveBeenCalledWith({ hash: txHash });
|
|
695
|
+
|
|
696
|
+
expect(getTrackingDelayByChainId).toHaveBeenCalledWith(TARGET_CHAIN.chainId);
|
|
697
|
+
expect(retryPromise).toHaveBeenCalledWith({
|
|
698
|
+
promise: expect.any(Function),
|
|
699
|
+
delay,
|
|
700
|
+
startAfter: INITIAL_DELAY,
|
|
701
|
+
});
|
|
702
|
+
});
|
|
703
|
+
|
|
704
|
+
it('resolves if transaction has enough confirmations', async () => {
|
|
705
|
+
const targetBlockNumber = MAX_BLOCKS * 6n;
|
|
706
|
+
const receiptMock = {
|
|
707
|
+
status: 'succeeded',
|
|
708
|
+
};
|
|
709
|
+
const confirmations = 3;
|
|
710
|
+
const params = getBridgeTrackinParams({
|
|
711
|
+
bridgeTransfer: {
|
|
712
|
+
requiredTargetConfirmationCount: confirmations,
|
|
713
|
+
startBlockNumber: MAX_BLOCKS * 2n,
|
|
714
|
+
metadata: {
|
|
715
|
+
nonce,
|
|
716
|
+
},
|
|
717
|
+
},
|
|
718
|
+
updateListener,
|
|
719
|
+
});
|
|
720
|
+
|
|
721
|
+
const expectedResult = {
|
|
722
|
+
...params.bridgeTransfer,
|
|
723
|
+
targetTxHash: txHash,
|
|
724
|
+
targetNetworkFee: networkFee,
|
|
725
|
+
targetConfirmationCount: confirmations,
|
|
726
|
+
completedAt: now,
|
|
727
|
+
};
|
|
728
|
+
|
|
729
|
+
targetClientMock.getLogs.mockResolvedValueOnce([{ transactionHash: txHash }]);
|
|
730
|
+
targetClientMock.getTransactionReceipt.mockResolvedValueOnce(receiptMock);
|
|
731
|
+
targetClientMock.getTransactionConfirmations.mockResolvedValueOnce(confirmations);
|
|
732
|
+
targetClientMock.getBlockNumber.mockResolvedValueOnce(targetBlockNumber);
|
|
733
|
+
|
|
734
|
+
const { result } = await trackTargetTx(bridgeMock.config!, params);
|
|
735
|
+
expect(await result).toStrictEqual(expectedResult);
|
|
736
|
+
expect(doneMock).toHaveBeenCalledWith(expectedResult);
|
|
737
|
+
expect(updateListenerWithoutReference).toHaveBeenCalledTimes(4);
|
|
738
|
+
expect(updateListenerWithoutReference).toHaveBeenNthCalledWith(1, {
|
|
739
|
+
...params.bridgeTransfer,
|
|
740
|
+
targetTxHash: txHash,
|
|
741
|
+
});
|
|
742
|
+
expect(updateListenerWithoutReference).toHaveBeenNthCalledWith(2, {
|
|
743
|
+
...params.bridgeTransfer,
|
|
744
|
+
targetTxHash: txHash,
|
|
745
|
+
targetNetworkFee: networkFee,
|
|
746
|
+
});
|
|
747
|
+
expect(updateListenerWithoutReference).toHaveBeenNthCalledWith(3, {
|
|
748
|
+
...params.bridgeTransfer,
|
|
749
|
+
targetTxHash: txHash,
|
|
750
|
+
targetNetworkFee: networkFee,
|
|
751
|
+
targetConfirmationCount: confirmations,
|
|
752
|
+
});
|
|
753
|
+
expect(updateListenerWithoutReference).toHaveBeenNthCalledWith(4, expectedResult);
|
|
754
|
+
|
|
755
|
+
expect(targetClientMock.getLogs).toHaveBeenCalledWith({
|
|
756
|
+
address: TARGET_TRANSMITTER_ADDRESS,
|
|
757
|
+
event: msgReceivedEvent,
|
|
758
|
+
args: { nonce },
|
|
759
|
+
fromBlock: params.bridgeTransfer.startBlockNumber! - MAX_BLOCKS,
|
|
760
|
+
toBlock: params.bridgeTransfer.startBlockNumber! + MAX_BLOCKS,
|
|
761
|
+
});
|
|
762
|
+
expect(targetClientMock.getTransactionReceipt).toHaveBeenCalledWith({ hash: txHash });
|
|
763
|
+
expect(targetClientMock.getTransaction).toHaveBeenCalledWith({ hash: txHash });
|
|
764
|
+
expect(getNetworkFeeEVM).toHaveBeenCalledWith(txMock, receiptMock);
|
|
765
|
+
expect(targetClientMock.getTransactionConfirmations).toHaveBeenCalledWith({ hash: txHash });
|
|
766
|
+
|
|
767
|
+
expect(getTrackingDelayByChainId).toHaveBeenCalledWith(TARGET_CHAIN.chainId);
|
|
768
|
+
expect(retryPromise).toHaveBeenCalledWith({
|
|
769
|
+
promise: expect.any(Function),
|
|
770
|
+
delay,
|
|
771
|
+
startAfter: INITIAL_DELAY,
|
|
772
|
+
});
|
|
773
|
+
});
|
|
774
|
+
});
|
|
775
|
+
});
|