@instadapp/interop-x 0.0.0-dev.76d0265 → 0.0.0-dev.7738003
Sign up to get free protection for your applications and to get access to all the features.
- package/.github/workflows/ci.yml +19 -0
- package/dist/package.json +1 -1
- package/dist/src/abi/index.js +2 -2
- package/dist/src/abi/interopX.json +1436 -0
- package/dist/src/api/index.js +1 -1
- package/dist/src/constants/addresses.js +2 -7
- package/dist/src/db/models/transaction.js +11 -9
- package/dist/src/gnosis/actions/withdraw/index.js +106 -107
- package/dist/src/index.js +1 -1
- package/dist/src/tasks/{InteropXContract/SyncBridgeRequestEvents.js → InteropX/SyncLogSubmitEvents.js} +18 -12
- package/dist/src/tasks/Transactions/SyncTransactionStatusTask.js +4 -2
- package/dist/src/tasks/index.js +4 -13
- package/dist/src/typechain/{InteropXContract.js → InteropX.js} +0 -0
- package/dist/src/typechain/factories/InteropX__factory.js +1928 -0
- package/dist/src/typechain/factories/index.js +3 -3
- package/dist/src/typechain/index.js +3 -3
- package/dist/src/utils/index.js +5 -3
- package/package.json +1 -1
- package/src/abi/index.ts +2 -2
- package/src/abi/interopX.json +1436 -0
- package/src/api/index.ts +1 -1
- package/src/constants/addresses.ts +3 -8
- package/src/db/models/transaction.ts +28 -37
- package/src/gnosis/actions/withdraw/index.ts +131 -131
- package/src/tasks/{InteropXContract/SyncBridgeRequestEvents.ts → InteropX/SyncLogSubmitEvents.ts} +37 -16
- package/src/tasks/Transactions/SyncTransactionStatusTask.ts +4 -2
- package/src/tasks/index.ts +5 -17
- package/src/typechain/InteropX.ts +1216 -0
- package/src/typechain/factories/InteropX__factory.ts +1932 -0
- package/src/typechain/factories/index.ts +1 -1
- package/src/typechain/index.ts +2 -2
- package/src/utils/index.ts +22 -8
- package/dist/src/abi/interopXContract.json +0 -454
- package/dist/src/tasks/InteropXContract/ProcessBridgeRequestEvents.js +0 -159
- package/dist/src/tasks/InteropXContract/SyncBridgeCommittedEvents.js +0 -93
- package/dist/src/tasks/InteropXContract/SyncBridgeRequestSentEvents.js +0 -90
- package/dist/src/typechain/factories/InteropXContract__factory.js +0 -635
- package/src/abi/interopXContract.json +0 -454
- package/src/tasks/InteropXContract/ProcessBridgeRequestEvents.ts +0 -227
- package/src/tasks/InteropXContract/SyncBridgeCommittedEvents.ts +0 -125
- package/src/tasks/InteropXContract/SyncBridgeRequestSentEvents.ts +0 -121
- package/src/typechain/InteropXContract.ts +0 -680
- package/src/typechain/factories/InteropXContract__factory.ts +0 -642
@@ -1,454 +0,0 @@
|
|
1
|
-
[
|
2
|
-
{
|
3
|
-
"anonymous": false,
|
4
|
-
"inputs": [
|
5
|
-
{
|
6
|
-
"indexed": false,
|
7
|
-
"internalType": "string",
|
8
|
-
"name": "actionId",
|
9
|
-
"type": "string"
|
10
|
-
},
|
11
|
-
{
|
12
|
-
"indexed": true,
|
13
|
-
"internalType": "address",
|
14
|
-
"name": "bridger",
|
15
|
-
"type": "address"
|
16
|
-
},
|
17
|
-
{
|
18
|
-
"components": [
|
19
|
-
{
|
20
|
-
"components": [
|
21
|
-
{
|
22
|
-
"internalType": "address",
|
23
|
-
"name": "sourceToken",
|
24
|
-
"type": "address"
|
25
|
-
},
|
26
|
-
{
|
27
|
-
"internalType": "address",
|
28
|
-
"name": "targetToken",
|
29
|
-
"type": "address"
|
30
|
-
},
|
31
|
-
{ "internalType": "uint256", "name": "amount", "type": "uint256" }
|
32
|
-
],
|
33
|
-
"internalType": "struct InteropXContractBeta.TokenInfo[]",
|
34
|
-
"name": "supply",
|
35
|
-
"type": "tuple[]"
|
36
|
-
},
|
37
|
-
{
|
38
|
-
"components": [
|
39
|
-
{
|
40
|
-
"internalType": "address",
|
41
|
-
"name": "sourceToken",
|
42
|
-
"type": "address"
|
43
|
-
},
|
44
|
-
{
|
45
|
-
"internalType": "address",
|
46
|
-
"name": "targetToken",
|
47
|
-
"type": "address"
|
48
|
-
},
|
49
|
-
{ "internalType": "uint256", "name": "amount", "type": "uint256" }
|
50
|
-
],
|
51
|
-
"internalType": "struct InteropXContractBeta.TokenInfo[]",
|
52
|
-
"name": "withdraw",
|
53
|
-
"type": "tuple[]"
|
54
|
-
}
|
55
|
-
],
|
56
|
-
"indexed": false,
|
57
|
-
"internalType": "struct InteropXContractBeta.Position",
|
58
|
-
"name": "position",
|
59
|
-
"type": "tuple"
|
60
|
-
},
|
61
|
-
{
|
62
|
-
"indexed": true,
|
63
|
-
"internalType": "uint32",
|
64
|
-
"name": "sourceChainId",
|
65
|
-
"type": "uint32"
|
66
|
-
},
|
67
|
-
{
|
68
|
-
"indexed": false,
|
69
|
-
"internalType": "uint32",
|
70
|
-
"name": "targetChainId",
|
71
|
-
"type": "uint32"
|
72
|
-
},
|
73
|
-
{
|
74
|
-
"indexed": true,
|
75
|
-
"internalType": "bytes32",
|
76
|
-
"name": "requestTransactionHash",
|
77
|
-
"type": "bytes32"
|
78
|
-
},
|
79
|
-
{
|
80
|
-
"indexed": false,
|
81
|
-
"internalType": "bytes",
|
82
|
-
"name": "metadata",
|
83
|
-
"type": "bytes"
|
84
|
-
}
|
85
|
-
],
|
86
|
-
"name": "LogBridgeCommitted",
|
87
|
-
"type": "event"
|
88
|
-
},
|
89
|
-
{
|
90
|
-
"anonymous": false,
|
91
|
-
"inputs": [
|
92
|
-
{
|
93
|
-
"indexed": false,
|
94
|
-
"internalType": "string",
|
95
|
-
"name": "actionId",
|
96
|
-
"type": "string"
|
97
|
-
},
|
98
|
-
{
|
99
|
-
"indexed": true,
|
100
|
-
"internalType": "address",
|
101
|
-
"name": "bridger",
|
102
|
-
"type": "address"
|
103
|
-
},
|
104
|
-
{
|
105
|
-
"components": [
|
106
|
-
{
|
107
|
-
"components": [
|
108
|
-
{
|
109
|
-
"internalType": "address",
|
110
|
-
"name": "sourceToken",
|
111
|
-
"type": "address"
|
112
|
-
},
|
113
|
-
{
|
114
|
-
"internalType": "address",
|
115
|
-
"name": "targetToken",
|
116
|
-
"type": "address"
|
117
|
-
},
|
118
|
-
{ "internalType": "uint256", "name": "amount", "type": "uint256" }
|
119
|
-
],
|
120
|
-
"internalType": "struct InteropXContractBeta.TokenInfo[]",
|
121
|
-
"name": "supply",
|
122
|
-
"type": "tuple[]"
|
123
|
-
},
|
124
|
-
{
|
125
|
-
"components": [
|
126
|
-
{
|
127
|
-
"internalType": "address",
|
128
|
-
"name": "sourceToken",
|
129
|
-
"type": "address"
|
130
|
-
},
|
131
|
-
{
|
132
|
-
"internalType": "address",
|
133
|
-
"name": "targetToken",
|
134
|
-
"type": "address"
|
135
|
-
},
|
136
|
-
{ "internalType": "uint256", "name": "amount", "type": "uint256" }
|
137
|
-
],
|
138
|
-
"internalType": "struct InteropXContractBeta.TokenInfo[]",
|
139
|
-
"name": "withdraw",
|
140
|
-
"type": "tuple[]"
|
141
|
-
}
|
142
|
-
],
|
143
|
-
"indexed": false,
|
144
|
-
"internalType": "struct InteropXContractBeta.Position",
|
145
|
-
"name": "position",
|
146
|
-
"type": "tuple"
|
147
|
-
},
|
148
|
-
{
|
149
|
-
"indexed": false,
|
150
|
-
"internalType": "uint256",
|
151
|
-
"name": "sourceChainId",
|
152
|
-
"type": "uint256"
|
153
|
-
},
|
154
|
-
{
|
155
|
-
"indexed": true,
|
156
|
-
"internalType": "uint256",
|
157
|
-
"name": "targetChainId",
|
158
|
-
"type": "uint256"
|
159
|
-
},
|
160
|
-
{
|
161
|
-
"indexed": true,
|
162
|
-
"internalType": "bytes32",
|
163
|
-
"name": "requestTransactionHash",
|
164
|
-
"type": "bytes32"
|
165
|
-
},
|
166
|
-
{
|
167
|
-
"indexed": false,
|
168
|
-
"internalType": "bytes32",
|
169
|
-
"name": "targetCommittedTransactionHash",
|
170
|
-
"type": "bytes32"
|
171
|
-
},
|
172
|
-
{
|
173
|
-
"indexed": false,
|
174
|
-
"internalType": "bytes",
|
175
|
-
"name": "metadata",
|
176
|
-
"type": "bytes"
|
177
|
-
}
|
178
|
-
],
|
179
|
-
"name": "LogBridgeCompleted",
|
180
|
-
"type": "event"
|
181
|
-
},
|
182
|
-
{
|
183
|
-
"anonymous": false,
|
184
|
-
"inputs": [
|
185
|
-
{
|
186
|
-
"indexed": false,
|
187
|
-
"internalType": "string",
|
188
|
-
"name": "actionId",
|
189
|
-
"type": "string"
|
190
|
-
},
|
191
|
-
{
|
192
|
-
"indexed": true,
|
193
|
-
"internalType": "address",
|
194
|
-
"name": "bridger",
|
195
|
-
"type": "address"
|
196
|
-
},
|
197
|
-
{
|
198
|
-
"components": [
|
199
|
-
{
|
200
|
-
"components": [
|
201
|
-
{
|
202
|
-
"internalType": "address",
|
203
|
-
"name": "sourceToken",
|
204
|
-
"type": "address"
|
205
|
-
},
|
206
|
-
{
|
207
|
-
"internalType": "address",
|
208
|
-
"name": "targetToken",
|
209
|
-
"type": "address"
|
210
|
-
},
|
211
|
-
{ "internalType": "uint256", "name": "amount", "type": "uint256" }
|
212
|
-
],
|
213
|
-
"internalType": "struct InteropXContractBeta.TokenInfo[]",
|
214
|
-
"name": "supply",
|
215
|
-
"type": "tuple[]"
|
216
|
-
},
|
217
|
-
{
|
218
|
-
"components": [
|
219
|
-
{
|
220
|
-
"internalType": "address",
|
221
|
-
"name": "sourceToken",
|
222
|
-
"type": "address"
|
223
|
-
},
|
224
|
-
{
|
225
|
-
"internalType": "address",
|
226
|
-
"name": "targetToken",
|
227
|
-
"type": "address"
|
228
|
-
},
|
229
|
-
{ "internalType": "uint256", "name": "amount", "type": "uint256" }
|
230
|
-
],
|
231
|
-
"internalType": "struct InteropXContractBeta.TokenInfo[]",
|
232
|
-
"name": "withdraw",
|
233
|
-
"type": "tuple[]"
|
234
|
-
}
|
235
|
-
],
|
236
|
-
"indexed": false,
|
237
|
-
"internalType": "struct InteropXContractBeta.Position",
|
238
|
-
"name": "position",
|
239
|
-
"type": "tuple"
|
240
|
-
},
|
241
|
-
{
|
242
|
-
"indexed": false,
|
243
|
-
"internalType": "uint256",
|
244
|
-
"name": "sourceChainId",
|
245
|
-
"type": "uint256"
|
246
|
-
},
|
247
|
-
{
|
248
|
-
"indexed": true,
|
249
|
-
"internalType": "uint256",
|
250
|
-
"name": "targetChainId",
|
251
|
-
"type": "uint256"
|
252
|
-
},
|
253
|
-
{
|
254
|
-
"indexed": false,
|
255
|
-
"internalType": "bytes",
|
256
|
-
"name": "metadata",
|
257
|
-
"type": "bytes"
|
258
|
-
}
|
259
|
-
],
|
260
|
-
"name": "LogBridgeRequest",
|
261
|
-
"type": "event"
|
262
|
-
},
|
263
|
-
{
|
264
|
-
"anonymous": false,
|
265
|
-
"inputs": [
|
266
|
-
{
|
267
|
-
"indexed": false,
|
268
|
-
"internalType": "string",
|
269
|
-
"name": "actionId",
|
270
|
-
"type": "string"
|
271
|
-
},
|
272
|
-
{
|
273
|
-
"indexed": true,
|
274
|
-
"internalType": "address",
|
275
|
-
"name": "bridger",
|
276
|
-
"type": "address"
|
277
|
-
},
|
278
|
-
{
|
279
|
-
"components": [
|
280
|
-
{
|
281
|
-
"components": [
|
282
|
-
{
|
283
|
-
"internalType": "address",
|
284
|
-
"name": "sourceToken",
|
285
|
-
"type": "address"
|
286
|
-
},
|
287
|
-
{
|
288
|
-
"internalType": "address",
|
289
|
-
"name": "targetToken",
|
290
|
-
"type": "address"
|
291
|
-
},
|
292
|
-
{ "internalType": "uint256", "name": "amount", "type": "uint256" }
|
293
|
-
],
|
294
|
-
"internalType": "struct InteropXContractBeta.TokenInfo[]",
|
295
|
-
"name": "supply",
|
296
|
-
"type": "tuple[]"
|
297
|
-
},
|
298
|
-
{
|
299
|
-
"components": [
|
300
|
-
{
|
301
|
-
"internalType": "address",
|
302
|
-
"name": "sourceToken",
|
303
|
-
"type": "address"
|
304
|
-
},
|
305
|
-
{
|
306
|
-
"internalType": "address",
|
307
|
-
"name": "targetToken",
|
308
|
-
"type": "address"
|
309
|
-
},
|
310
|
-
{ "internalType": "uint256", "name": "amount", "type": "uint256" }
|
311
|
-
],
|
312
|
-
"internalType": "struct InteropXContractBeta.TokenInfo[]",
|
313
|
-
"name": "withdraw",
|
314
|
-
"type": "tuple[]"
|
315
|
-
}
|
316
|
-
],
|
317
|
-
"indexed": false,
|
318
|
-
"internalType": "struct InteropXContractBeta.Position",
|
319
|
-
"name": "position",
|
320
|
-
"type": "tuple"
|
321
|
-
},
|
322
|
-
{
|
323
|
-
"indexed": false,
|
324
|
-
"internalType": "uint32",
|
325
|
-
"name": "sourceChainId",
|
326
|
-
"type": "uint32"
|
327
|
-
},
|
328
|
-
{
|
329
|
-
"indexed": true,
|
330
|
-
"internalType": "uint32",
|
331
|
-
"name": "targetChainId",
|
332
|
-
"type": "uint32"
|
333
|
-
},
|
334
|
-
{
|
335
|
-
"indexed": true,
|
336
|
-
"internalType": "bytes32",
|
337
|
-
"name": "requestTransactionHash",
|
338
|
-
"type": "bytes32"
|
339
|
-
},
|
340
|
-
{
|
341
|
-
"indexed": false,
|
342
|
-
"internalType": "bytes",
|
343
|
-
"name": "metadata",
|
344
|
-
"type": "bytes"
|
345
|
-
}
|
346
|
-
],
|
347
|
-
"name": "LogBridgeRequestSent",
|
348
|
-
"type": "event"
|
349
|
-
},
|
350
|
-
{
|
351
|
-
"inputs": [
|
352
|
-
{ "internalType": "string", "name": "actionId", "type": "string" },
|
353
|
-
{ "internalType": "address", "name": "to_", "type": "address" },
|
354
|
-
{ "internalType": "address", "name": "sourceToken_", "type": "address" },
|
355
|
-
{ "internalType": "address", "name": "targetToken_", "type": "address" },
|
356
|
-
{ "internalType": "uint256", "name": "amount_", "type": "uint256" },
|
357
|
-
{ "internalType": "uint32", "name": "sourceChainId_", "type": "uint32" },
|
358
|
-
{
|
359
|
-
"internalType": "bytes32",
|
360
|
-
"name": "transactionHash_",
|
361
|
-
"type": "bytes32"
|
362
|
-
},
|
363
|
-
{ "internalType": "bytes", "name": "metadata_", "type": "bytes" }
|
364
|
-
],
|
365
|
-
"name": "completeBridge",
|
366
|
-
"outputs": [],
|
367
|
-
"stateMutability": "nonpayable",
|
368
|
-
"type": "function"
|
369
|
-
},
|
370
|
-
{
|
371
|
-
"inputs": [
|
372
|
-
{ "internalType": "address", "name": "user", "type": "address" },
|
373
|
-
{ "internalType": "address[]", "name": "tokens", "type": "address[]" }
|
374
|
-
],
|
375
|
-
"name": "getBridgeAmounts",
|
376
|
-
"outputs": [
|
377
|
-
{
|
378
|
-
"components": [
|
379
|
-
{ "internalType": "uint256", "name": "deposit", "type": "uint256" },
|
380
|
-
{ "internalType": "uint256", "name": "withdraw", "type": "uint256" }
|
381
|
-
],
|
382
|
-
"internalType": "struct InteropXContractBeta.UserData[]",
|
383
|
-
"name": "userData",
|
384
|
-
"type": "tuple[]"
|
385
|
-
}
|
386
|
-
],
|
387
|
-
"stateMutability": "view",
|
388
|
-
"type": "function"
|
389
|
-
},
|
390
|
-
{
|
391
|
-
"inputs": [
|
392
|
-
{ "internalType": "string", "name": "actionId", "type": "string" },
|
393
|
-
{ "internalType": "address", "name": "sourceToken_", "type": "address" },
|
394
|
-
{ "internalType": "address", "name": "targetToken_", "type": "address" },
|
395
|
-
{ "internalType": "uint256", "name": "amount_", "type": "uint256" },
|
396
|
-
{ "internalType": "uint32", "name": "targetChainId_", "type": "uint32" },
|
397
|
-
{ "internalType": "bytes", "name": "metadata_", "type": "bytes" }
|
398
|
-
],
|
399
|
-
"name": "requestWithdraw",
|
400
|
-
"outputs": [],
|
401
|
-
"stateMutability": "nonpayable",
|
402
|
-
"type": "function"
|
403
|
-
},
|
404
|
-
{
|
405
|
-
"inputs": [
|
406
|
-
{ "internalType": "address", "name": "token", "type": "address" },
|
407
|
-
{ "internalType": "bool", "name": "toggle", "type": "bool" }
|
408
|
-
],
|
409
|
-
"name": "toggleWhitelist",
|
410
|
-
"outputs": [],
|
411
|
-
"stateMutability": "nonpayable",
|
412
|
-
"type": "function"
|
413
|
-
},
|
414
|
-
{
|
415
|
-
"inputs": [
|
416
|
-
{ "internalType": "address", "name": "", "type": "address" },
|
417
|
-
{ "internalType": "address", "name": "", "type": "address" }
|
418
|
-
],
|
419
|
-
"name": "userMapping",
|
420
|
-
"outputs": [
|
421
|
-
{ "internalType": "uint256", "name": "deposit", "type": "uint256" },
|
422
|
-
{ "internalType": "uint256", "name": "withdraw", "type": "uint256" }
|
423
|
-
],
|
424
|
-
"stateMutability": "view",
|
425
|
-
"type": "function"
|
426
|
-
},
|
427
|
-
{
|
428
|
-
"inputs": [{ "internalType": "address", "name": "", "type": "address" }],
|
429
|
-
"name": "whitelistedTokens",
|
430
|
-
"outputs": [{ "internalType": "bool", "name": "", "type": "bool" }],
|
431
|
-
"stateMutability": "view",
|
432
|
-
"type": "function"
|
433
|
-
},
|
434
|
-
{
|
435
|
-
"inputs": [
|
436
|
-
{ "internalType": "string", "name": "actionId", "type": "string" },
|
437
|
-
{ "internalType": "address", "name": "user_", "type": "address" },
|
438
|
-
{ "internalType": "address", "name": "sourceToken_", "type": "address" },
|
439
|
-
{ "internalType": "address", "name": "targetToken_", "type": "address" },
|
440
|
-
{ "internalType": "uint256", "name": "amount_", "type": "uint256" },
|
441
|
-
{ "internalType": "uint32", "name": "chainId_", "type": "uint32" },
|
442
|
-
{
|
443
|
-
"internalType": "bytes32",
|
444
|
-
"name": "transactionHash_",
|
445
|
-
"type": "bytes32"
|
446
|
-
},
|
447
|
-
{ "internalType": "bytes", "name": "metadata_", "type": "bytes" }
|
448
|
-
],
|
449
|
-
"name": "withdrawRequested",
|
450
|
-
"outputs": [],
|
451
|
-
"stateMutability": "nonpayable",
|
452
|
-
"type": "function"
|
453
|
-
}
|
454
|
-
]
|
@@ -1,227 +0,0 @@
|
|
1
|
-
import { BaseTask } from "../BaseTask";
|
2
|
-
import Logger from '@/logger';
|
3
|
-
import { ethers, Wallet } from "ethers";
|
4
|
-
import abi from "@/abi";
|
5
|
-
import { Transaction } from "@/db";
|
6
|
-
import { buildSignatureBytes, generateGnosisTransaction, generateInteropTransactionHash, getContract, getRpcProviderUrl, LiquidityError, Signature } from "@/utils";
|
7
|
-
import { addresses } from "@/constants";
|
8
|
-
import { Op } from "sequelize";
|
9
|
-
import { ChainId } from "@/types";
|
10
|
-
import config from "@/config";
|
11
|
-
import { GnosisSafe, InteropXContract } from "@/typechain";
|
12
|
-
import wait from "waait";
|
13
|
-
import { buildGnosisAction } from "@/gnosis";
|
14
|
-
import { peerPool, protocol } from "@/net";
|
15
|
-
import { LogDescription } from "ethers/lib/utils";
|
16
|
-
|
17
|
-
class ProccessBridgeRequestEvents extends BaseTask {
|
18
|
-
contractAddress: string;
|
19
|
-
safeContractAddress: string;
|
20
|
-
provider: ethers.providers.JsonRpcProvider;
|
21
|
-
contract: InteropXContract;
|
22
|
-
safeContract: GnosisSafe;
|
23
|
-
chainId: ChainId;
|
24
|
-
sourceWallet: Wallet;
|
25
|
-
|
26
|
-
leadNodeOnly: boolean = true;
|
27
|
-
|
28
|
-
constructor({ chainId }: { chainId: ChainId }) {
|
29
|
-
super({
|
30
|
-
logger: new Logger("InteropXContract::ProccessBridgeRequestEvents"),
|
31
|
-
})
|
32
|
-
this.chainId = chainId;
|
33
|
-
}
|
34
|
-
|
35
|
-
async pollHandler() {
|
36
|
-
const blockNumber = await this.provider.getBlockNumber()
|
37
|
-
|
38
|
-
const transaction = await Transaction.findOne({
|
39
|
-
where: {
|
40
|
-
status: 'pending',
|
41
|
-
sourceStatus: 'uninitialised',
|
42
|
-
createdAt: {
|
43
|
-
[Op.gte]: new Date(Date.now() - 12 * 60 * 60 * 1000),
|
44
|
-
},
|
45
|
-
sourceDelayUntil: {
|
46
|
-
[Op.or]: {
|
47
|
-
[Op.is]: null,
|
48
|
-
[Op.lt]: new Date(),
|
49
|
-
}
|
50
|
-
},
|
51
|
-
requestBlockNumber: {
|
52
|
-
[Op.lt]: blockNumber - 12,
|
53
|
-
},
|
54
|
-
sourceChainId: this.chainId,
|
55
|
-
}
|
56
|
-
})
|
57
|
-
|
58
|
-
if (!transaction) {
|
59
|
-
return;
|
60
|
-
}
|
61
|
-
|
62
|
-
console.log(`Processing transaction ${transaction.transactionHash}`);
|
63
|
-
|
64
|
-
transaction.targetStatus = 'pending';
|
65
|
-
await transaction.save();
|
66
|
-
|
67
|
-
const ownersThreshold = await this.safeContract.getThreshold();
|
68
|
-
await wait(10000);
|
69
|
-
|
70
|
-
|
71
|
-
let data, logs = [];
|
72
|
-
|
73
|
-
try {
|
74
|
-
({ data, logs } = await buildGnosisAction(transaction, 'source'));
|
75
|
-
|
76
|
-
} catch (error) {
|
77
|
-
|
78
|
-
if(error instanceof LiquidityError){
|
79
|
-
await transaction.save();
|
80
|
-
transaction.sourceDelayUntil = new Date(Date.now() + 60 * 5 * 1000);
|
81
|
-
transaction.sourceStatus = 'uninitialised'
|
82
|
-
|
83
|
-
await transaction.save();
|
84
|
-
|
85
|
-
throw error
|
86
|
-
return;
|
87
|
-
}
|
88
|
-
|
89
|
-
transaction.sourceStatus = 'failed';
|
90
|
-
transaction.sourceErrors = [error.message];
|
91
|
-
transaction.targetStatus = 'failed';
|
92
|
-
|
93
|
-
transaction.status = 'failed'
|
94
|
-
await transaction.save();
|
95
|
-
protocol.sendTransaction(transaction)
|
96
|
-
return;
|
97
|
-
}
|
98
|
-
|
99
|
-
let gnosisTx = await generateGnosisTransaction({
|
100
|
-
baseGas: "0",
|
101
|
-
data,
|
102
|
-
gasPrice: "0",
|
103
|
-
gasToken: "0x0000000000000000000000000000000000000000",
|
104
|
-
nonce: '0',
|
105
|
-
operation: "1",
|
106
|
-
refundReceiver: "0x0000000000000000000000000000000000000000",
|
107
|
-
safeAddress: this.safeContractAddress,
|
108
|
-
safeTxGas: "79668",
|
109
|
-
to: addresses[transaction.sourceChainId].multisend,
|
110
|
-
value: "0",
|
111
|
-
}, this.safeContract);
|
112
|
-
|
113
|
-
const owners = await this.safeContract.getOwners().then(owners => owners.map(owner => owner.toLowerCase()));
|
114
|
-
|
115
|
-
const ownerPeerIds = peerPool.activePeers.filter(peer => owners.includes(peer.publicAddress.toLowerCase())).map(peer => peer.id)
|
116
|
-
|
117
|
-
console.log(`Collecting signatures for execution ${transaction.transactionHash}`)
|
118
|
-
|
119
|
-
console.log(ownerPeerIds);
|
120
|
-
|
121
|
-
const signatures = await protocol.requestSignatures({
|
122
|
-
type: 'source',
|
123
|
-
transactionHash: transaction.transactionHash,
|
124
|
-
safeTxGas: gnosisTx.safeTxGas,
|
125
|
-
safeNonce: gnosisTx.nonce
|
126
|
-
}, ownerPeerIds)
|
127
|
-
|
128
|
-
|
129
|
-
const validSignatures = signatures.filter(s => !!s.data && s.data !== '0x') as Signature[];
|
130
|
-
|
131
|
-
console.log({ signatures, validSignatures, ownersThreshold: ownersThreshold.toString() });
|
132
|
-
|
133
|
-
if (validSignatures.length === 0 || ownersThreshold.gt(validSignatures.length)) {
|
134
|
-
await transaction.save();
|
135
|
-
transaction.sourceDelayUntil = new Date(Date.now() + 30 * 1000);
|
136
|
-
transaction.sourceStatus = 'uninitialised'
|
137
|
-
|
138
|
-
await transaction.save();
|
139
|
-
const errorMessage = signatures.find(s => !!s.error)?.error;
|
140
|
-
throw new Error(`Not enough signatures` + (errorMessage ? `: ${errorMessage}` : ''));
|
141
|
-
}
|
142
|
-
|
143
|
-
console.log(`Executing transaction for execution ${transaction.transactionHash}`)
|
144
|
-
|
145
|
-
const { data: txData } = await this.safeContract.populateTransaction.execTransaction(
|
146
|
-
gnosisTx.to,
|
147
|
-
gnosisTx.value,
|
148
|
-
gnosisTx.data,
|
149
|
-
gnosisTx.operation,
|
150
|
-
gnosisTx.safeTxGas,
|
151
|
-
gnosisTx.baseGas,
|
152
|
-
gnosisTx.gasPrice,
|
153
|
-
gnosisTx.gasToken,
|
154
|
-
gnosisTx.refundReceiver,
|
155
|
-
buildSignatureBytes(validSignatures)
|
156
|
-
);
|
157
|
-
|
158
|
-
const txSent = await this.sourceWallet.sendTransaction({
|
159
|
-
from: this.sourceWallet.address,
|
160
|
-
gasPrice: ethers.BigNumber.from(120 * 10 ** 9),
|
161
|
-
to: this.safeContractAddress,
|
162
|
-
data: txData,
|
163
|
-
})
|
164
|
-
|
165
|
-
console.log(txSent);
|
166
|
-
|
167
|
-
|
168
|
-
const receipt = await txSent.wait();
|
169
|
-
|
170
|
-
const parsedLogs: LogDescription[] = [];
|
171
|
-
|
172
|
-
receipt.logs.forEach((log) => {
|
173
|
-
try {
|
174
|
-
parsedLogs.push(this.safeContract.interface.parseLog(log));
|
175
|
-
} catch (e) { }
|
176
|
-
});
|
177
|
-
|
178
|
-
if (parsedLogs.find(e => e.name === 'ExecutionSuccess')) {
|
179
|
-
console.log('ExecutionSuccess')
|
180
|
-
transaction.sourceStatus = 'success'
|
181
|
-
if (txSent.blockNumber)
|
182
|
-
transaction.sourceBlockNumber = txSent.blockNumber;
|
183
|
-
transaction.sourceTransactionHash = txSent.hash
|
184
|
-
transaction.sourceLogs = logs;
|
185
|
-
transaction.status = 'success'
|
186
|
-
await transaction.save();
|
187
|
-
} else {
|
188
|
-
console.log('ExecutionFailure')
|
189
|
-
transaction.sourceStatus = 'failed'
|
190
|
-
if (txSent.blockNumber)
|
191
|
-
transaction.sourceBlockNumber = txSent.blockNumber;
|
192
|
-
transaction.sourceTransactionHash = txSent.hash
|
193
|
-
transaction.sourceTransactionHash = txSent.hash
|
194
|
-
transaction.status = 'failed'
|
195
|
-
await transaction.save();
|
196
|
-
}
|
197
|
-
|
198
|
-
protocol.sendTransaction(transaction)
|
199
|
-
}
|
200
|
-
|
201
|
-
async start(): Promise<void> {
|
202
|
-
this.contractAddress = addresses[this.chainId].interopXContract;
|
203
|
-
|
204
|
-
this.provider = new ethers.providers.JsonRpcProvider(
|
205
|
-
getRpcProviderUrl(this.chainId)
|
206
|
-
);
|
207
|
-
|
208
|
-
this.sourceWallet = new ethers.Wallet(config.privateKey!, this.provider);
|
209
|
-
|
210
|
-
this.contract = getContract<InteropXContract>(
|
211
|
-
this.contractAddress,
|
212
|
-
abi.interopXContract,
|
213
|
-
this.sourceWallet
|
214
|
-
);
|
215
|
-
|
216
|
-
this.safeContractAddress = addresses[this.chainId].gnosisSafe;
|
217
|
-
this.safeContract = getContract<GnosisSafe>(
|
218
|
-
this.safeContractAddress,
|
219
|
-
abi.gnosisSafe,
|
220
|
-
this.sourceWallet
|
221
|
-
);
|
222
|
-
|
223
|
-
await super.start()
|
224
|
-
}
|
225
|
-
}
|
226
|
-
|
227
|
-
export default ProccessBridgeRequestEvents;
|