@instadapp/interop-x 0.0.0-dev.14afa72 → 0.0.0-dev.1f933be
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/dist/package.json +2 -2
- package/dist/src/abi/index.js +2 -4
- package/dist/src/abi/interopXContract.json +391 -0
- package/dist/src/alias.js +10 -0
- package/dist/src/constants/addresses.js +3 -3
- package/dist/src/constants/index.js +0 -1
- package/dist/src/db/models/transaction.js +19 -9
- package/dist/src/gnosis/actions/index.js +0 -2
- package/dist/src/gnosis/actions/withdraw/index.js +41 -0
- package/dist/src/gnosis/index.js +1 -1
- package/dist/src/index.js +7 -19
- package/dist/src/net/protocol/dial/SignatureDialProtocol.js +4 -0
- package/dist/src/net/protocol/dial/TransactionStatusDialProtocol.js +2 -0
- package/dist/src/net/protocol/index.js +11 -1
- package/dist/src/tasks/{InteropBridge/ProcessWithdrawEvents.js → InteropXContract/ProcessBridgeRequestEvents.js} +32 -47
- package/dist/src/tasks/InteropXContract/SyncBridgeRequestEvents.js +78 -0
- package/dist/src/tasks/Transactions/SyncTransactionStatusTask.js +2 -0
- package/dist/src/tasks/index.js +10 -30
- package/dist/src/typechain/{InteropBridgeToken.js → InteropXContract.js} +0 -0
- package/dist/src/typechain/factories/InteropXContract__factory.js +526 -0
- package/dist/src/typechain/factories/index.js +3 -5
- package/dist/src/typechain/index.js +3 -5
- package/dist/src/utils/index.js +14 -3
- package/package.json +2 -2
- package/src/abi/index.ts +2 -4
- package/src/abi/interopXContract.json +391 -0
- package/src/alias.ts +6 -0
- package/src/constants/addresses.ts +3 -3
- package/src/constants/index.ts +0 -1
- package/src/db/models/transaction.ts +49 -21
- package/src/gnosis/actions/index.ts +0 -2
- package/src/gnosis/actions/withdraw/index.ts +56 -0
- package/src/gnosis/index.ts +2 -2
- package/src/index.ts +6 -18
- package/src/net/protocol/dial/SignatureDialProtocol.ts +4 -0
- package/src/net/protocol/dial/TransactionStatusDialProtocol.ts +3 -1
- package/src/net/protocol/index.ts +13 -3
- package/src/tasks/{InteropBridge/ProcessWithdrawEvents.ts → InteropXContract/ProcessBridgeRequestEvents.ts} +58 -96
- package/src/tasks/InteropXContract/SyncBridgeRequestEvents.ts +116 -0
- package/src/tasks/Transactions/SyncTransactionStatusTask.ts +2 -0
- package/src/tasks/index.ts +12 -39
- package/src/typechain/InteropXContract.ts +524 -0
- package/src/typechain/factories/InteropXContract__factory.ts +533 -0
- package/src/typechain/factories/index.ts +1 -2
- package/src/typechain/index.ts +2 -4
- package/src/utils/index.ts +45 -3
- package/tsconfig.json +7 -2
- package/dist/src/abi/interopBridgeToken.json +0 -298
- package/dist/src/abi/interopXGateway.json +0 -184
- package/dist/src/constants/itokens.js +0 -13
- package/dist/src/gnosis/actions/deposit.js +0 -48
- package/dist/src/gnosis/actions/withdraw.js +0 -50
- package/dist/src/tasks/InteropBridge/SyncBurnEvents.js +0 -71
- package/dist/src/tasks/InteropBridge/SyncMintEvents.js +0 -67
- package/dist/src/tasks/InteropXGateway/ProcessDepositEvents.js +0 -164
- package/dist/src/tasks/InteropXGateway/SyncDepositEvents.js +0 -74
- package/dist/src/tasks/InteropXGateway/SyncWithdrawtEvents.js +0 -72
- package/dist/src/typechain/InteropXGateway.js +0 -2
- package/dist/src/typechain/factories/InteropBridgeToken__factory.js +0 -471
- package/dist/src/typechain/factories/InteropXGateway__factory.js +0 -265
- package/src/abi/interopBridgeToken.json +0 -298
- package/src/abi/interopXGateway.json +0 -184
- package/src/constants/itokens.ts +0 -10
- package/src/gnosis/actions/deposit.ts +0 -63
- package/src/gnosis/actions/withdraw.ts +0 -67
- package/src/tasks/InteropBridge/SyncBurnEvents.ts +0 -119
- package/src/tasks/InteropBridge/SyncMintEvents.ts +0 -99
- package/src/tasks/InteropXGateway/ProcessDepositEvents.ts +0 -260
- package/src/tasks/InteropXGateway/SyncDepositEvents.ts +0 -124
- package/src/tasks/InteropXGateway/SyncWithdrawtEvents.ts +0 -105
- package/src/typechain/InteropBridgeToken.ts +0 -692
- package/src/typechain/InteropXGateway.ts +0 -407
- package/src/typechain/factories/InteropBridgeToken__factory.ts +0 -478
- package/src/typechain/factories/InteropXGateway__factory.ts +0 -272
@@ -0,0 +1,391 @@
|
|
1
|
+
[
|
2
|
+
{
|
3
|
+
"anonymous": false,
|
4
|
+
"inputs": [
|
5
|
+
{
|
6
|
+
"indexed": true,
|
7
|
+
"internalType": "address",
|
8
|
+
"name": "bridger",
|
9
|
+
"type": "address"
|
10
|
+
},
|
11
|
+
{
|
12
|
+
"components": [
|
13
|
+
{
|
14
|
+
"components": [
|
15
|
+
{
|
16
|
+
"internalType": "address",
|
17
|
+
"name": "sourceToken",
|
18
|
+
"type": "address"
|
19
|
+
},
|
20
|
+
{
|
21
|
+
"internalType": "address",
|
22
|
+
"name": "targetToken",
|
23
|
+
"type": "address"
|
24
|
+
},
|
25
|
+
{ "internalType": "uint256", "name": "amount", "type": "uint256" }
|
26
|
+
],
|
27
|
+
"internalType": "struct InteropXContractBeta.TokenInfo[]",
|
28
|
+
"name": "supply",
|
29
|
+
"type": "tuple[]"
|
30
|
+
},
|
31
|
+
{
|
32
|
+
"components": [
|
33
|
+
{
|
34
|
+
"internalType": "address",
|
35
|
+
"name": "sourceToken",
|
36
|
+
"type": "address"
|
37
|
+
},
|
38
|
+
{
|
39
|
+
"internalType": "address",
|
40
|
+
"name": "targetToken",
|
41
|
+
"type": "address"
|
42
|
+
},
|
43
|
+
{ "internalType": "uint256", "name": "amount", "type": "uint256" }
|
44
|
+
],
|
45
|
+
"internalType": "struct InteropXContractBeta.TokenInfo[]",
|
46
|
+
"name": "withdraw",
|
47
|
+
"type": "tuple[]"
|
48
|
+
}
|
49
|
+
],
|
50
|
+
"indexed": false,
|
51
|
+
"internalType": "struct InteropXContractBeta.Position",
|
52
|
+
"name": "position",
|
53
|
+
"type": "tuple"
|
54
|
+
},
|
55
|
+
{
|
56
|
+
"indexed": true,
|
57
|
+
"internalType": "uint32",
|
58
|
+
"name": "sourceChainId",
|
59
|
+
"type": "uint32"
|
60
|
+
},
|
61
|
+
{
|
62
|
+
"indexed": false,
|
63
|
+
"internalType": "uint32",
|
64
|
+
"name": "targetChainId",
|
65
|
+
"type": "uint32"
|
66
|
+
},
|
67
|
+
{
|
68
|
+
"indexed": true,
|
69
|
+
"internalType": "bytes32",
|
70
|
+
"name": "requestTransactionHash",
|
71
|
+
"type": "bytes32"
|
72
|
+
},
|
73
|
+
{
|
74
|
+
"indexed": false,
|
75
|
+
"internalType": "bytes",
|
76
|
+
"name": "metadata",
|
77
|
+
"type": "bytes"
|
78
|
+
}
|
79
|
+
],
|
80
|
+
"name": "LogBridgeCommitted",
|
81
|
+
"type": "event"
|
82
|
+
},
|
83
|
+
{
|
84
|
+
"anonymous": false,
|
85
|
+
"inputs": [
|
86
|
+
{
|
87
|
+
"indexed": true,
|
88
|
+
"internalType": "address",
|
89
|
+
"name": "bridger",
|
90
|
+
"type": "address"
|
91
|
+
},
|
92
|
+
{
|
93
|
+
"components": [
|
94
|
+
{
|
95
|
+
"components": [
|
96
|
+
{
|
97
|
+
"internalType": "address",
|
98
|
+
"name": "sourceToken",
|
99
|
+
"type": "address"
|
100
|
+
},
|
101
|
+
{
|
102
|
+
"internalType": "address",
|
103
|
+
"name": "targetToken",
|
104
|
+
"type": "address"
|
105
|
+
},
|
106
|
+
{ "internalType": "uint256", "name": "amount", "type": "uint256" }
|
107
|
+
],
|
108
|
+
"internalType": "struct InteropXContractBeta.TokenInfo[]",
|
109
|
+
"name": "supply",
|
110
|
+
"type": "tuple[]"
|
111
|
+
},
|
112
|
+
{
|
113
|
+
"components": [
|
114
|
+
{
|
115
|
+
"internalType": "address",
|
116
|
+
"name": "sourceToken",
|
117
|
+
"type": "address"
|
118
|
+
},
|
119
|
+
{
|
120
|
+
"internalType": "address",
|
121
|
+
"name": "targetToken",
|
122
|
+
"type": "address"
|
123
|
+
},
|
124
|
+
{ "internalType": "uint256", "name": "amount", "type": "uint256" }
|
125
|
+
],
|
126
|
+
"internalType": "struct InteropXContractBeta.TokenInfo[]",
|
127
|
+
"name": "withdraw",
|
128
|
+
"type": "tuple[]"
|
129
|
+
}
|
130
|
+
],
|
131
|
+
"indexed": false,
|
132
|
+
"internalType": "struct InteropXContractBeta.Position",
|
133
|
+
"name": "position",
|
134
|
+
"type": "tuple"
|
135
|
+
},
|
136
|
+
{
|
137
|
+
"indexed": false,
|
138
|
+
"internalType": "uint256",
|
139
|
+
"name": "sourceChainId",
|
140
|
+
"type": "uint256"
|
141
|
+
},
|
142
|
+
{
|
143
|
+
"indexed": true,
|
144
|
+
"internalType": "uint256",
|
145
|
+
"name": "targetChainId",
|
146
|
+
"type": "uint256"
|
147
|
+
},
|
148
|
+
{
|
149
|
+
"indexed": true,
|
150
|
+
"internalType": "bytes32",
|
151
|
+
"name": "requestTransactionHash",
|
152
|
+
"type": "bytes32"
|
153
|
+
},
|
154
|
+
{
|
155
|
+
"indexed": false,
|
156
|
+
"internalType": "bytes32",
|
157
|
+
"name": "targetCommittedTransactionHash",
|
158
|
+
"type": "bytes32"
|
159
|
+
},
|
160
|
+
{
|
161
|
+
"indexed": false,
|
162
|
+
"internalType": "bytes",
|
163
|
+
"name": "metadata",
|
164
|
+
"type": "bytes"
|
165
|
+
}
|
166
|
+
],
|
167
|
+
"name": "LogBridgeCompleted",
|
168
|
+
"type": "event"
|
169
|
+
},
|
170
|
+
{
|
171
|
+
"anonymous": false,
|
172
|
+
"inputs": [
|
173
|
+
{
|
174
|
+
"indexed": true,
|
175
|
+
"internalType": "address",
|
176
|
+
"name": "bridger",
|
177
|
+
"type": "address"
|
178
|
+
},
|
179
|
+
{
|
180
|
+
"components": [
|
181
|
+
{
|
182
|
+
"components": [
|
183
|
+
{
|
184
|
+
"internalType": "address",
|
185
|
+
"name": "sourceToken",
|
186
|
+
"type": "address"
|
187
|
+
},
|
188
|
+
{
|
189
|
+
"internalType": "address",
|
190
|
+
"name": "targetToken",
|
191
|
+
"type": "address"
|
192
|
+
},
|
193
|
+
{ "internalType": "uint256", "name": "amount", "type": "uint256" }
|
194
|
+
],
|
195
|
+
"internalType": "struct InteropXContractBeta.TokenInfo[]",
|
196
|
+
"name": "supply",
|
197
|
+
"type": "tuple[]"
|
198
|
+
},
|
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": "withdraw",
|
215
|
+
"type": "tuple[]"
|
216
|
+
}
|
217
|
+
],
|
218
|
+
"indexed": false,
|
219
|
+
"internalType": "struct InteropXContractBeta.Position",
|
220
|
+
"name": "position",
|
221
|
+
"type": "tuple"
|
222
|
+
},
|
223
|
+
{
|
224
|
+
"indexed": false,
|
225
|
+
"internalType": "uint256",
|
226
|
+
"name": "sourceChainId",
|
227
|
+
"type": "uint256"
|
228
|
+
},
|
229
|
+
{
|
230
|
+
"indexed": true,
|
231
|
+
"internalType": "uint256",
|
232
|
+
"name": "targetChainId",
|
233
|
+
"type": "uint256"
|
234
|
+
},
|
235
|
+
{
|
236
|
+
"indexed": false,
|
237
|
+
"internalType": "bytes",
|
238
|
+
"name": "metadata",
|
239
|
+
"type": "bytes"
|
240
|
+
}
|
241
|
+
],
|
242
|
+
"name": "LogBridgeRequest",
|
243
|
+
"type": "event"
|
244
|
+
},
|
245
|
+
{
|
246
|
+
"anonymous": false,
|
247
|
+
"inputs": [
|
248
|
+
{
|
249
|
+
"indexed": true,
|
250
|
+
"internalType": "address",
|
251
|
+
"name": "bridger",
|
252
|
+
"type": "address"
|
253
|
+
},
|
254
|
+
{
|
255
|
+
"components": [
|
256
|
+
{
|
257
|
+
"components": [
|
258
|
+
{
|
259
|
+
"internalType": "address",
|
260
|
+
"name": "sourceToken",
|
261
|
+
"type": "address"
|
262
|
+
},
|
263
|
+
{
|
264
|
+
"internalType": "address",
|
265
|
+
"name": "targetToken",
|
266
|
+
"type": "address"
|
267
|
+
},
|
268
|
+
{ "internalType": "uint256", "name": "amount", "type": "uint256" }
|
269
|
+
],
|
270
|
+
"internalType": "struct InteropXContractBeta.TokenInfo[]",
|
271
|
+
"name": "supply",
|
272
|
+
"type": "tuple[]"
|
273
|
+
},
|
274
|
+
{
|
275
|
+
"components": [
|
276
|
+
{
|
277
|
+
"internalType": "address",
|
278
|
+
"name": "sourceToken",
|
279
|
+
"type": "address"
|
280
|
+
},
|
281
|
+
{
|
282
|
+
"internalType": "address",
|
283
|
+
"name": "targetToken",
|
284
|
+
"type": "address"
|
285
|
+
},
|
286
|
+
{ "internalType": "uint256", "name": "amount", "type": "uint256" }
|
287
|
+
],
|
288
|
+
"internalType": "struct InteropXContractBeta.TokenInfo[]",
|
289
|
+
"name": "withdraw",
|
290
|
+
"type": "tuple[]"
|
291
|
+
}
|
292
|
+
],
|
293
|
+
"indexed": false,
|
294
|
+
"internalType": "struct InteropXContractBeta.Position",
|
295
|
+
"name": "position",
|
296
|
+
"type": "tuple"
|
297
|
+
},
|
298
|
+
{
|
299
|
+
"indexed": false,
|
300
|
+
"internalType": "uint32",
|
301
|
+
"name": "sourceChainId",
|
302
|
+
"type": "uint32"
|
303
|
+
},
|
304
|
+
{
|
305
|
+
"indexed": true,
|
306
|
+
"internalType": "uint32",
|
307
|
+
"name": "targetChainId",
|
308
|
+
"type": "uint32"
|
309
|
+
},
|
310
|
+
{
|
311
|
+
"indexed": true,
|
312
|
+
"internalType": "bytes32",
|
313
|
+
"name": "requestTransactionHash",
|
314
|
+
"type": "bytes32"
|
315
|
+
},
|
316
|
+
{
|
317
|
+
"indexed": false,
|
318
|
+
"internalType": "bytes",
|
319
|
+
"name": "metadata",
|
320
|
+
"type": "bytes"
|
321
|
+
}
|
322
|
+
],
|
323
|
+
"name": "LogBridgeRequestSent",
|
324
|
+
"type": "event"
|
325
|
+
},
|
326
|
+
{
|
327
|
+
"inputs": [],
|
328
|
+
"name": "_vnonce",
|
329
|
+
"outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }],
|
330
|
+
"stateMutability": "view",
|
331
|
+
"type": "function"
|
332
|
+
},
|
333
|
+
{
|
334
|
+
"inputs": [
|
335
|
+
{ "internalType": "address", "name": "to_", "type": "address" },
|
336
|
+
{ "internalType": "address", "name": "sourceToken_", "type": "address" },
|
337
|
+
{ "internalType": "address", "name": "targetToken_", "type": "address" },
|
338
|
+
{ "internalType": "uint256", "name": "amount_", "type": "uint256" },
|
339
|
+
{ "internalType": "uint32", "name": "targetChainId_", "type": "uint32" },
|
340
|
+
{
|
341
|
+
"internalType": "bytes32",
|
342
|
+
"name": "transactionHash_",
|
343
|
+
"type": "bytes32"
|
344
|
+
},
|
345
|
+
{ "internalType": "bytes", "name": "metadata_", "type": "bytes" }
|
346
|
+
],
|
347
|
+
"name": "completeBridge",
|
348
|
+
"outputs": [],
|
349
|
+
"stateMutability": "nonpayable",
|
350
|
+
"type": "function"
|
351
|
+
},
|
352
|
+
{
|
353
|
+
"inputs": [
|
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": "targetChainId_", "type": "uint32" },
|
358
|
+
{ "internalType": "bytes", "name": "metadata_", "type": "bytes" }
|
359
|
+
],
|
360
|
+
"name": "requestWithdraw",
|
361
|
+
"outputs": [],
|
362
|
+
"stateMutability": "nonpayable",
|
363
|
+
"type": "function"
|
364
|
+
},
|
365
|
+
{
|
366
|
+
"inputs": [{ "internalType": "address", "name": "", "type": "address" }],
|
367
|
+
"name": "whitelistedMapping",
|
368
|
+
"outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }],
|
369
|
+
"stateMutability": "view",
|
370
|
+
"type": "function"
|
371
|
+
},
|
372
|
+
{
|
373
|
+
"inputs": [
|
374
|
+
{ "internalType": "address", "name": "user_", "type": "address" },
|
375
|
+
{ "internalType": "address", "name": "sourceToken_", "type": "address" },
|
376
|
+
{ "internalType": "address", "name": "targetToken_", "type": "address" },
|
377
|
+
{ "internalType": "uint256", "name": "amount_", "type": "uint256" },
|
378
|
+
{ "internalType": "uint32", "name": "chainId_", "type": "uint32" },
|
379
|
+
{
|
380
|
+
"internalType": "bytes32",
|
381
|
+
"name": "transactionHash_",
|
382
|
+
"type": "bytes32"
|
383
|
+
},
|
384
|
+
{ "internalType": "bytes", "name": "metadata_", "type": "bytes" }
|
385
|
+
],
|
386
|
+
"name": "withdrawRequested",
|
387
|
+
"outputs": [],
|
388
|
+
"stateMutability": "nonpayable",
|
389
|
+
"type": "function"
|
390
|
+
}
|
391
|
+
]
|
package/src/alias.ts
ADDED
@@ -2,16 +2,16 @@ export const addresses = {
|
|
2
2
|
1: {
|
3
3
|
gnosisSafe: '0x811Bff6eF88dAAA0aD6438386B534A81cE3F160F',
|
4
4
|
multisend: '0xA238CBeb142c10Ef7Ad8442C6D1f9E89e07e7761',
|
5
|
-
|
5
|
+
interopXContract: '',
|
6
6
|
},
|
7
7
|
137: {
|
8
8
|
gnosisSafe: '0x5635d2910e51da33d9DC0422c893CF4F28B69A25',
|
9
9
|
multisend: '0xA238CBeb142c10Ef7Ad8442C6D1f9E89e07e7761',
|
10
|
-
|
10
|
+
interopXContract: '0x2189741c8cAc1cf51570932817A7d6390646C80e',
|
11
11
|
},
|
12
12
|
43114: {
|
13
13
|
gnosisSafe: '0x31d7a5194Fe60AC209Cf1Ce2d539C9A60662Ed6b',
|
14
14
|
multisend: '0x998739BFdAAdde7C933B942a68053933098f9EDa',
|
15
|
-
|
15
|
+
interopXContract: '0x1867DF97Ec24bb0bbD4AD464F0Be9C6713422EAE',
|
16
16
|
}
|
17
17
|
}
|
package/src/constants/index.ts
CHANGED
@@ -1,21 +1,32 @@
|
|
1
1
|
import { sequelize } from '@/db/sequelize'
|
2
2
|
import { CreationOptional, InferAttributes, InferCreationAttributes, Model, DataTypes } from 'sequelize';
|
3
3
|
|
4
|
+
export interface IPositionTokenInfo{
|
5
|
+
amount: string;
|
6
|
+
sourceToken: string;
|
7
|
+
targetToken: string;
|
8
|
+
}
|
9
|
+
|
10
|
+
export interface IPosition {
|
11
|
+
supply: IPositionTokenInfo[];
|
12
|
+
withdraw: IPositionTokenInfo[];
|
13
|
+
}
|
14
|
+
|
4
15
|
export class Transaction extends Model<InferAttributes<Transaction>, InferCreationAttributes<Transaction>> {
|
5
16
|
declare id: CreationOptional<number>;
|
6
17
|
|
7
18
|
declare transactionHash: string;
|
19
|
+
|
8
20
|
declare action: string;
|
9
|
-
declare
|
10
|
-
declare
|
21
|
+
declare bridger: string;
|
22
|
+
declare requestTransactionHash: string;
|
11
23
|
|
12
|
-
declare
|
13
|
-
declare submitBlockNumber: number;
|
24
|
+
declare requestBlockNumber: number;
|
14
25
|
|
15
26
|
declare sourceChainId: number;
|
16
27
|
declare sourceTransactionHash: CreationOptional<string>;
|
17
28
|
declare sourceBlockNumber: CreationOptional<number>;
|
18
|
-
declare sourceStatus: string
|
29
|
+
declare sourceStatus: CreationOptional<string>;
|
19
30
|
declare sourceErrors: CreationOptional<string[]>;
|
20
31
|
declare sourceLogs: CreationOptional<any[]>;
|
21
32
|
declare sourceCreatedAt: CreationOptional<Date>;
|
@@ -24,19 +35,27 @@ export class Transaction extends Model<InferAttributes<Transaction>, InferCreati
|
|
24
35
|
declare targetChainId: number;
|
25
36
|
declare targetTransactionHash: CreationOptional<string>;
|
26
37
|
declare targetBlockNumber: CreationOptional<number>;
|
27
|
-
declare targetStatus: string
|
38
|
+
declare targetStatus: CreationOptional<string>;
|
28
39
|
declare targetErrors: CreationOptional<string[]>;
|
29
40
|
declare targetLogs: CreationOptional<any[]>;
|
30
41
|
declare targetCreatedAt: CreationOptional<Date>;
|
31
42
|
declare targetDelayUntil: CreationOptional<Date>;
|
32
43
|
|
33
|
-
declare
|
34
|
-
|
35
|
-
|
36
|
-
|
44
|
+
declare requestEvent: {
|
45
|
+
bridger: string;
|
46
|
+
metadata: string;
|
47
|
+
position: IPosition;
|
48
|
+
sourceChainId: number;
|
49
|
+
targetChainId: number;
|
50
|
+
};
|
51
|
+
declare requestSendEvent: CreationOptional<any>;
|
52
|
+
declare committedEvent: CreationOptional<any>;
|
53
|
+
declare completedEvent: CreationOptional<any>;
|
54
|
+
|
55
|
+
declare position: any;
|
37
56
|
declare metadata: CreationOptional<any>;
|
38
57
|
|
39
|
-
declare status: string
|
58
|
+
declare status: CreationOptional<string>;
|
40
59
|
|
41
60
|
declare createdAt: CreationOptional<Date>;
|
42
61
|
declare updatedAt: CreationOptional<Date>;
|
@@ -49,19 +68,20 @@ Transaction.init({
|
|
49
68
|
primaryKey: true
|
50
69
|
},
|
51
70
|
|
52
|
-
|
53
|
-
|
71
|
+
requestTransactionHash: DataTypes.NUMBER,
|
72
|
+
requestBlockNumber: DataTypes.NUMBER,
|
54
73
|
|
55
74
|
transactionHash: DataTypes.STRING,
|
56
75
|
action: DataTypes.STRING,
|
57
|
-
|
58
|
-
from: DataTypes.STRING,
|
59
|
-
to: DataTypes.STRING,
|
76
|
+
bridger: DataTypes.STRING,
|
60
77
|
|
61
78
|
sourceChainId: DataTypes.NUMBER,
|
62
79
|
sourceTransactionHash: DataTypes.STRING,
|
63
80
|
sourceBlockNumber: DataTypes.NUMBER,
|
64
|
-
sourceStatus:
|
81
|
+
sourceStatus: {
|
82
|
+
type: DataTypes.STRING,
|
83
|
+
defaultValue: 'uninitialised'
|
84
|
+
},
|
65
85
|
sourceErrors: {
|
66
86
|
type: DataTypes.JSON,
|
67
87
|
// defaultValue: [],
|
@@ -79,7 +99,10 @@ Transaction.init({
|
|
79
99
|
targetChainId: DataTypes.NUMBER,
|
80
100
|
targetTransactionHash: DataTypes.STRING,
|
81
101
|
targetBlockNumber: DataTypes.NUMBER,
|
82
|
-
targetStatus:
|
102
|
+
targetStatus: {
|
103
|
+
type: DataTypes.STRING,
|
104
|
+
defaultValue: 'uninitialised'
|
105
|
+
},
|
83
106
|
targetErrors: {
|
84
107
|
type: DataTypes.JSON,
|
85
108
|
// defaultValue: [],
|
@@ -91,10 +114,15 @@ Transaction.init({
|
|
91
114
|
targetCreatedAt: DataTypes.DATE,
|
92
115
|
targetDelayUntil: DataTypes.DATE,
|
93
116
|
|
94
|
-
|
95
|
-
|
96
|
-
|
117
|
+
requestEvent: {
|
118
|
+
type: DataTypes.JSON,
|
119
|
+
allowNull: false
|
120
|
+
},
|
121
|
+
requestSendEvent: DataTypes.JSON,
|
122
|
+
committedEvent: DataTypes.JSON,
|
123
|
+
completedEvent: DataTypes.JSON,
|
97
124
|
|
125
|
+
position: DataTypes.JSON,
|
98
126
|
metadata: DataTypes.JSON,
|
99
127
|
|
100
128
|
status: {
|
@@ -0,0 +1,56 @@
|
|
1
|
+
import abi from "@/abi";
|
2
|
+
import config from "@/config";
|
3
|
+
import { addresses, tokens } from "@/constants";
|
4
|
+
import { Transaction } from "@/db";
|
5
|
+
import { InteropXContract } from "@/typechain";
|
6
|
+
import { ChainId } from "@/types";
|
7
|
+
import { getContract, getRpcProviderUrl } from "@/utils";
|
8
|
+
import { ethers } from "ethers";
|
9
|
+
import { MetaTransaction, OperationType } from "ethers-multisend";
|
10
|
+
|
11
|
+
export default async function (transaction: Transaction, type: 'source' | 'target') {
|
12
|
+
const transactions: MetaTransaction[] = [];
|
13
|
+
const logs: any[] = [];
|
14
|
+
|
15
|
+
if (transaction.action !== 'withdraw') {
|
16
|
+
throw new Error(`Invalid action: ${transaction.action}`)
|
17
|
+
}
|
18
|
+
|
19
|
+
if (type !== 'source') {
|
20
|
+
throw new Error(`Type not supported: ${type}`)
|
21
|
+
}
|
22
|
+
|
23
|
+
if (transaction.action === 'withdraw' && transaction.sourceStatus === 'pending') {
|
24
|
+
throw Error('Cannot build data for pending withdraw transaction');
|
25
|
+
}
|
26
|
+
|
27
|
+
if (!transaction.requestEvent) {
|
28
|
+
throw Error('Cannot build data for transaction without requestEvent');
|
29
|
+
}
|
30
|
+
|
31
|
+
const { bridger, position, sourceChainId, targetChainId, metadata, } = transaction.requestEvent;
|
32
|
+
|
33
|
+
const sourceChainProvider = new ethers.providers.JsonRpcProvider(getRpcProviderUrl(targetChainId as ChainId));
|
34
|
+
const sourceWallet = new ethers.Wallet(config.privateKey, sourceChainProvider);
|
35
|
+
const contractAddress = addresses[sourceChainId].interopXContract;
|
36
|
+
const contract = getContract<InteropXContract>(contractAddress, abi.interopXContract, sourceWallet);
|
37
|
+
|
38
|
+
const { data } = await contract.populateTransaction.withdrawRequested(
|
39
|
+
bridger,
|
40
|
+
position.withdraw[0].sourceToken,
|
41
|
+
position.withdraw[0].targetToken,
|
42
|
+
position.withdraw[0].amount,
|
43
|
+
targetChainId,
|
44
|
+
transaction.requestTransactionHash,
|
45
|
+
metadata,
|
46
|
+
);
|
47
|
+
|
48
|
+
transactions.push({
|
49
|
+
to: contractAddress,
|
50
|
+
data: data!,
|
51
|
+
value: '0',
|
52
|
+
operation: OperationType.Call,
|
53
|
+
});
|
54
|
+
|
55
|
+
return { transactions, logs }
|
56
|
+
}
|
package/src/gnosis/index.ts
CHANGED
@@ -2,8 +2,8 @@ import { Transaction } from "@/db";
|
|
2
2
|
import { encodeMulti } from "ethers-multisend";
|
3
3
|
import actions from "./actions";
|
4
4
|
|
5
|
-
export const buildGnosisAction = async (transaction: Transaction, type
|
6
|
-
type = type || transaction.sourceStatus === '
|
5
|
+
export const buildGnosisAction = async (transaction: Transaction, type: 'source' | 'target') => {
|
6
|
+
// type = type || (transaction.sourceStatus === 'success' ? 'target' : 'source')
|
7
7
|
|
8
8
|
if (actions.hasOwnProperty(transaction.action)) {
|
9
9
|
|
package/src/index.ts
CHANGED
@@ -1,23 +1,7 @@
|
|
1
|
-
import
|
1
|
+
import './alias'
|
2
2
|
import expandHomeDir from "expand-home-dir";
|
3
3
|
import fs from 'fs-extra'
|
4
|
-
moduleAlias.addAliases({
|
5
|
-
"@/": __dirname + "/",
|
6
|
-
"@/logger": __dirname + "/logger",
|
7
|
-
"@/tasks": __dirname + "/tasks",
|
8
|
-
"@/gnosis": __dirname + "/gnosis",
|
9
|
-
"@/utils": __dirname + "/utils",
|
10
|
-
"@/api": __dirname + "/api",
|
11
|
-
"@/net": __dirname + "/net",
|
12
|
-
"@/db": __dirname + "/db",
|
13
|
-
"@/config": __dirname + "/config",
|
14
|
-
"@/types": __dirname + "/types",
|
15
|
-
"@/abi": __dirname + "/abi",
|
16
|
-
"@/constants": __dirname + "/constants",
|
17
|
-
"@/typechain": __dirname + "/typechain"
|
18
|
-
})
|
19
4
|
|
20
|
-
moduleAlias();
|
21
5
|
import dotenv from "dotenv";
|
22
6
|
import chalk from 'chalk';
|
23
7
|
import { ethers } from "ethers";
|
@@ -105,7 +89,9 @@ async function main() {
|
|
105
89
|
|
106
90
|
const tasks = new Tasks()
|
107
91
|
|
108
|
-
|
92
|
+
setTimeout(() => {
|
93
|
+
tasks.start();
|
94
|
+
}, 10000)
|
109
95
|
|
110
96
|
startApiServer()
|
111
97
|
|
@@ -130,10 +116,12 @@ async function main() {
|
|
130
116
|
transaction.sourceStatus = payload.data.sourceStatus
|
131
117
|
transaction.sourceTransactionHash = payload.data.sourceTransactionHash
|
132
118
|
transaction.sourceErrors = payload.data.sourceErrors
|
119
|
+
transaction.sourceLogs = payload.data.sourceLogs
|
133
120
|
|
134
121
|
transaction.targetStatus = payload.data.targetStatus
|
135
122
|
transaction.targetTransactionHash = payload.data.targetTransactionHash
|
136
123
|
transaction.targetErrors = payload.data.targetErrors
|
124
|
+
transaction.targetLogs = payload.data.targetLogs
|
137
125
|
|
138
126
|
transaction.status = payload.data.status
|
139
127
|
|