@instadapp/interop-x 0.0.0-dev.d4e8223 → 0.0.0-dev.d71f27e

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 (72) hide show
  1. package/dist/package.json +2 -2
  2. package/dist/src/abi/index.js +2 -4
  3. package/dist/src/abi/interopXContract.json +391 -0
  4. package/dist/src/alias.js +10 -0
  5. package/dist/src/constants/addresses.js +3 -3
  6. package/dist/src/constants/index.js +0 -1
  7. package/dist/src/db/models/transaction.js +27 -9
  8. package/dist/src/gnosis/actions/index.js +9 -0
  9. package/dist/src/gnosis/actions/withdraw/index.js +41 -0
  10. package/dist/src/gnosis/index.js +20 -0
  11. package/dist/src/index.js +7 -18
  12. package/dist/src/net/protocol/dial/SignatureDialProtocol.js +9 -10
  13. package/dist/src/net/protocol/dial/TransactionStatusDialProtocol.js +2 -0
  14. package/dist/src/net/protocol/index.js +11 -1
  15. package/dist/src/tasks/{InteropXGateway/ProcessDepositEvents.js → InteropXContract/ProcessBridgeRequestEvents.js} +43 -53
  16. package/dist/src/tasks/InteropXContract/SyncBridgeRequestEvents.js +78 -0
  17. package/dist/src/tasks/InteropXContract/SyncBridgeRequestSentEvents.js +89 -0
  18. package/dist/src/tasks/Transactions/SyncTransactionStatusTask.js +2 -0
  19. package/dist/src/tasks/index.js +13 -30
  20. package/dist/src/typechain/{InteropBridgeToken.js → InteropXContract.js} +0 -0
  21. package/dist/src/typechain/factories/InteropXContract__factory.js +526 -0
  22. package/dist/src/typechain/factories/index.js +3 -5
  23. package/dist/src/typechain/index.js +3 -5
  24. package/dist/src/utils/index.js +14 -84
  25. package/package.json +2 -2
  26. package/src/abi/index.ts +2 -4
  27. package/src/abi/interopXContract.json +391 -0
  28. package/src/alias.ts +6 -0
  29. package/src/constants/addresses.ts +3 -3
  30. package/src/constants/index.ts +0 -1
  31. package/src/db/models/transaction.ts +66 -21
  32. package/src/gnosis/actions/index.ts +5 -0
  33. package/src/gnosis/actions/withdraw/index.ts +56 -0
  34. package/src/gnosis/index.ts +19 -0
  35. package/src/index.ts +6 -17
  36. package/src/net/protocol/dial/SignatureDialProtocol.ts +11 -13
  37. package/src/net/protocol/dial/TransactionStatusDialProtocol.ts +3 -1
  38. package/src/net/protocol/index.ts +13 -3
  39. package/src/tasks/{InteropXGateway/ProcessDepositEvents.ts → InteropXContract/ProcessBridgeRequestEvents.ts} +62 -103
  40. package/src/tasks/InteropXContract/SyncBridgeRequestEvents.ts +116 -0
  41. package/src/tasks/InteropXContract/SyncBridgeRequestSentEvents.ts +120 -0
  42. package/src/tasks/Transactions/SyncTransactionStatusTask.ts +2 -0
  43. package/src/tasks/index.ts +15 -37
  44. package/src/typechain/InteropXContract.ts +524 -0
  45. package/src/typechain/factories/InteropXContract__factory.ts +533 -0
  46. package/src/typechain/factories/index.ts +1 -2
  47. package/src/typechain/index.ts +2 -4
  48. package/src/utils/index.ts +46 -125
  49. package/tsconfig.json +7 -2
  50. package/dist/src/abi/interopBridgeToken.json +0 -298
  51. package/dist/src/abi/interopXGateway.json +0 -184
  52. package/dist/src/constants/itokens.js +0 -13
  53. package/dist/src/tasks/InteropBridge/ProcessWithdrawEvents.js +0 -146
  54. package/dist/src/tasks/InteropBridge/SyncBurnEvents.js +0 -71
  55. package/dist/src/tasks/InteropBridge/SyncMintEvents.js +0 -67
  56. package/dist/src/tasks/InteropXGateway/SyncDepositEvents.js +0 -74
  57. package/dist/src/tasks/InteropXGateway/SyncWithdrawtEvents.js +0 -72
  58. package/dist/src/typechain/InteropXGateway.js +0 -2
  59. package/dist/src/typechain/factories/InteropBridgeToken__factory.js +0 -471
  60. package/dist/src/typechain/factories/InteropXGateway__factory.js +0 -265
  61. package/src/abi/interopBridgeToken.json +0 -298
  62. package/src/abi/interopXGateway.json +0 -184
  63. package/src/constants/itokens.ts +0 -10
  64. package/src/tasks/InteropBridge/ProcessWithdrawEvents.ts +0 -231
  65. package/src/tasks/InteropBridge/SyncBurnEvents.ts +0 -121
  66. package/src/tasks/InteropBridge/SyncMintEvents.ts +0 -99
  67. package/src/tasks/InteropXGateway/SyncDepositEvents.ts +0 -124
  68. package/src/tasks/InteropXGateway/SyncWithdrawtEvents.ts +0 -105
  69. package/src/typechain/InteropBridgeToken.ts +0 -692
  70. package/src/typechain/InteropXGateway.ts +0 -407
  71. package/src/typechain/factories/InteropBridgeToken__factory.ts +0 -478
  72. package/src/typechain/factories/InteropXGateway__factory.ts +0 -272
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@instadapp/interop-x",
3
- "version": "0.0.0-dev.d4e8223",
3
+ "version": "0.0.0-dev.d71f27e",
4
4
  "license": "MIT",
5
5
  "main": "dist/index.js",
6
6
  "engines": {
@@ -11,7 +11,7 @@
11
11
  "start": "yarn build && node bin/interop-x",
12
12
  "build": "yarn generate-abi-types && export GIT_REF=$(git rev-parse --short HEAD) && rimraf ./dist && tsc -p tsconfig.json && replace-in-file '@GIT_SHORT_HASH@' $GIT_REF ./dist/**/*.js",
13
13
  "dev": "yarn generate-abi-types && NODE_ENV=development nodemon",
14
- "generate-abi-types": "typechain --target=ethers-v5 'src/abi/*.json' --out-dir 'src/typechain'",
14
+ "generate-abi-types": "rimraf src/typechain && typechain --target=ethers-v5 'src/abi/*.json' --out-dir 'src/typechain'",
15
15
  "prepublishOnly": "yarn build",
16
16
  "postinstall": "patch-package"
17
17
  },
package/src/abi/index.ts CHANGED
@@ -1,11 +1,9 @@
1
1
  import gnosisSafe from "./gnosisSafe.json";
2
2
  import erc20 from "./erc20.json";
3
- import interopXGateway from "./interopXGateway.json";
4
- import interopBridgeToken from "./interopBridgeToken.json";
3
+ import interopXContract from "./interopXContract.json";
5
4
 
6
5
  export default {
7
6
  gnosisSafe,
8
7
  erc20,
9
- interopXGateway,
10
- interopBridgeToken,
8
+ interopXContract,
11
9
  }
@@ -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
@@ -0,0 +1,6 @@
1
+ import moduleAlias from 'module-alias';
2
+ moduleAlias.addAliases({
3
+ "@": __dirname,
4
+ })
5
+
6
+ moduleAlias();
@@ -2,16 +2,16 @@ export const addresses = {
2
2
  1: {
3
3
  gnosisSafe: '0x811Bff6eF88dAAA0aD6438386B534A81cE3F160F',
4
4
  multisend: '0xA238CBeb142c10Ef7Ad8442C6D1f9E89e07e7761',
5
- interopXGateway: '',
5
+ interopXContract: '',
6
6
  },
7
7
  137: {
8
8
  gnosisSafe: '0x5635d2910e51da33d9DC0422c893CF4F28B69A25',
9
9
  multisend: '0xA238CBeb142c10Ef7Ad8442C6D1f9E89e07e7761',
10
- interopXGateway: '',
10
+ interopXContract: '0x2189741c8cAc1cf51570932817A7d6390646C80e',
11
11
  },
12
12
  43114: {
13
13
  gnosisSafe: '0x31d7a5194Fe60AC209Cf1Ce2d539C9A60662Ed6b',
14
14
  multisend: '0x998739BFdAAdde7C933B942a68053933098f9EDa',
15
- interopXGateway: '0xF0317C5Bc206F2291dd2f3eE9C4cDB5Bbb25418d',
15
+ interopXContract: '0x1867DF97Ec24bb0bbD4AD464F0Be9C6713422EAE',
16
16
  }
17
17
  }
@@ -1,3 +1,2 @@
1
1
  export * from './addresses';
2
2
  export * from './tokens';
3
- export * from './itokens';
@@ -1,40 +1,68 @@
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 from: string;
10
- declare to: string;
21
+ declare bridger: string;
22
+ declare requestTransactionHash: string;
11
23
 
12
- declare submitTransactionHash: string;
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[]>;
31
+ declare sourceLogs: CreationOptional<any[]>;
20
32
  declare sourceCreatedAt: CreationOptional<Date>;
21
33
  declare sourceDelayUntil: CreationOptional<Date>;
22
34
 
23
35
  declare targetChainId: number;
24
36
  declare targetTransactionHash: CreationOptional<string>;
25
37
  declare targetBlockNumber: CreationOptional<number>;
26
- declare targetStatus: string;
38
+ declare targetStatus: CreationOptional<string>;
27
39
  declare targetErrors: CreationOptional<string[]>;
40
+ declare targetLogs: CreationOptional<any[]>;
28
41
  declare targetCreatedAt: CreationOptional<Date>;
29
42
  declare targetDelayUntil: CreationOptional<Date>;
30
43
 
31
- declare submitEvent: any;
32
- declare sourceEvent: CreationOptional<any>;
33
- declare targetEvent: CreationOptional<any>;
34
-
44
+ declare requestEvent: {
45
+ bridger: string;
46
+ metadata: string;
47
+ position: IPosition;
48
+ sourceChainId: number;
49
+ targetChainId: number;
50
+ };
51
+ declare requestSentEvent: CreationOptional<{
52
+ bridger: string;
53
+ metadata: string;
54
+ position: IPosition;
55
+ sourceChainId: number;
56
+ targetChainId: number;
57
+ requestTransactionHash: string;
58
+ }>;
59
+ declare committedEvent: CreationOptional<any>;
60
+ declare completedEvent: CreationOptional<any>;
61
+
62
+ declare position: any;
35
63
  declare metadata: CreationOptional<any>;
36
64
 
37
- declare status: string;
65
+ declare status: CreationOptional<string>;
38
66
 
39
67
  declare createdAt: CreationOptional<Date>;
40
68
  declare updatedAt: CreationOptional<Date>;
@@ -47,23 +75,28 @@ Transaction.init({
47
75
  primaryKey: true
48
76
  },
49
77
 
50
- submitTransactionHash: DataTypes.NUMBER,
51
- submitBlockNumber: DataTypes.NUMBER,
78
+ requestTransactionHash: DataTypes.NUMBER,
79
+ requestBlockNumber: DataTypes.NUMBER,
52
80
 
53
81
  transactionHash: DataTypes.STRING,
54
82
  action: DataTypes.STRING,
55
-
56
- from: DataTypes.STRING,
57
- to: DataTypes.STRING,
83
+ bridger: DataTypes.STRING,
58
84
 
59
85
  sourceChainId: DataTypes.NUMBER,
60
86
  sourceTransactionHash: DataTypes.STRING,
61
87
  sourceBlockNumber: DataTypes.NUMBER,
62
- sourceStatus: DataTypes.STRING,
88
+ sourceStatus: {
89
+ type: DataTypes.STRING,
90
+ defaultValue: 'uninitialised'
91
+ },
63
92
  sourceErrors: {
64
93
  type: DataTypes.JSON,
65
94
  // defaultValue: [],
66
95
  },
96
+ sourceLogs: {
97
+ type: DataTypes.JSON,
98
+ // defaultValue: [],
99
+ },
67
100
  sourceCreatedAt: {
68
101
  type: DataTypes.DATE,
69
102
  defaultValue: Date.now()
@@ -73,18 +106,30 @@ Transaction.init({
73
106
  targetChainId: DataTypes.NUMBER,
74
107
  targetTransactionHash: DataTypes.STRING,
75
108
  targetBlockNumber: DataTypes.NUMBER,
76
- targetStatus: DataTypes.STRING,
109
+ targetStatus: {
110
+ type: DataTypes.STRING,
111
+ defaultValue: 'uninitialised'
112
+ },
77
113
  targetErrors: {
78
114
  type: DataTypes.JSON,
79
115
  // defaultValue: [],
80
116
  },
117
+ targetLogs: {
118
+ type: DataTypes.JSON,
119
+ // defaultValue: [],
120
+ },
81
121
  targetCreatedAt: DataTypes.DATE,
82
122
  targetDelayUntil: DataTypes.DATE,
83
123
 
84
- submitEvent: DataTypes.JSON,
85
- sourceEvent: DataTypes.JSON,
86
- targetEvent: DataTypes.JSON,
124
+ requestEvent: {
125
+ type: DataTypes.JSON,
126
+ allowNull: false
127
+ },
128
+ requestSentEvent: DataTypes.JSON,
129
+ committedEvent: DataTypes.JSON,
130
+ completedEvent: DataTypes.JSON,
87
131
 
132
+ position: DataTypes.JSON,
88
133
  metadata: DataTypes.JSON,
89
134
 
90
135
  status: {
@@ -0,0 +1,5 @@
1
+ import withdraw from "./withdraw"
2
+
3
+ export default {
4
+ withdraw,
5
+ }
@@ -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
+ }
@@ -0,0 +1,19 @@
1
+ import { Transaction } from "@/db";
2
+ import { encodeMulti } from "ethers-multisend";
3
+ import actions from "./actions";
4
+
5
+ export const buildGnosisAction = async (transaction: Transaction, type: 'source' | 'target') => {
6
+ // type = type || (transaction.sourceStatus === 'success' ? 'target' : 'source')
7
+
8
+ if (actions.hasOwnProperty(transaction.action)) {
9
+
10
+ const { transactions, logs } = await actions[transaction.action](transaction, type);
11
+
12
+ return {
13
+ data: encodeMulti(transactions).data,
14
+ logs
15
+ };
16
+ }
17
+
18
+ throw new Error(`Unknown action: ${transaction.action}`);
19
+ }