@instadapp/interop-x 0.0.0-dev.99c56eb → 0.0.0-dev.99c6cb0
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 +11 -11
- package/dist/src/abi/interopXContract.json +73 -10
- package/dist/src/constants/addresses.js +2 -2
- package/dist/src/db/models/transaction.js +1 -1
- package/dist/src/gnosis/actions/withdraw/index.js +4 -4
- package/dist/src/gnosis/index.js +3 -3
- package/dist/src/index.js +1 -1
- package/dist/src/tasks/InteropXContract/SyncBridgeRequestEvents.js +3 -2
- package/dist/src/tasks/InteropXContract/SyncBridgeRequestSentEvents.js +3 -2
- package/dist/src/typechain/factories/InteropXContract__factory.js +124 -15
- package/dist/src/utils/index.js +1 -1
- package/package.json +11 -11
- package/src/abi/interopXContract.json +73 -10
- package/src/constants/addresses.ts +2 -2
- package/src/db/models/transaction.ts +4 -2
- package/src/gnosis/actions/withdraw/index.ts +9 -8
- package/src/gnosis/index.ts +3 -3
- package/src/tasks/InteropXContract/SyncBridgeRequestEvents.ts +3 -2
- package/src/tasks/InteropXContract/SyncBridgeRequestSentEvents.ts +3 -2
- package/src/typechain/InteropXContract.ts +199 -43
- package/src/typechain/factories/InteropXContract__factory.ts +124 -15
- package/src/utils/index.ts +2 -2
@@ -2,6 +2,12 @@
|
|
2
2
|
{
|
3
3
|
"anonymous": false,
|
4
4
|
"inputs": [
|
5
|
+
{
|
6
|
+
"indexed": false,
|
7
|
+
"internalType": "string",
|
8
|
+
"name": "actionId",
|
9
|
+
"type": "string"
|
10
|
+
},
|
5
11
|
{
|
6
12
|
"indexed": true,
|
7
13
|
"internalType": "address",
|
@@ -83,6 +89,12 @@
|
|
83
89
|
{
|
84
90
|
"anonymous": false,
|
85
91
|
"inputs": [
|
92
|
+
{
|
93
|
+
"indexed": false,
|
94
|
+
"internalType": "string",
|
95
|
+
"name": "actionId",
|
96
|
+
"type": "string"
|
97
|
+
},
|
86
98
|
{
|
87
99
|
"indexed": true,
|
88
100
|
"internalType": "address",
|
@@ -170,6 +182,12 @@
|
|
170
182
|
{
|
171
183
|
"anonymous": false,
|
172
184
|
"inputs": [
|
185
|
+
{
|
186
|
+
"indexed": false,
|
187
|
+
"internalType": "string",
|
188
|
+
"name": "actionId",
|
189
|
+
"type": "string"
|
190
|
+
},
|
173
191
|
{
|
174
192
|
"indexed": true,
|
175
193
|
"internalType": "address",
|
@@ -245,6 +263,12 @@
|
|
245
263
|
{
|
246
264
|
"anonymous": false,
|
247
265
|
"inputs": [
|
266
|
+
{
|
267
|
+
"indexed": false,
|
268
|
+
"internalType": "string",
|
269
|
+
"name": "actionId",
|
270
|
+
"type": "string"
|
271
|
+
},
|
248
272
|
{
|
249
273
|
"indexed": true,
|
250
274
|
"internalType": "address",
|
@@ -323,20 +347,14 @@
|
|
323
347
|
"name": "LogBridgeRequestSent",
|
324
348
|
"type": "event"
|
325
349
|
},
|
326
|
-
{
|
327
|
-
"inputs": [],
|
328
|
-
"name": "_vnonce",
|
329
|
-
"outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }],
|
330
|
-
"stateMutability": "view",
|
331
|
-
"type": "function"
|
332
|
-
},
|
333
350
|
{
|
334
351
|
"inputs": [
|
352
|
+
{ "internalType": "string", "name": "actionId", "type": "string" },
|
335
353
|
{ "internalType": "address", "name": "to_", "type": "address" },
|
336
354
|
{ "internalType": "address", "name": "sourceToken_", "type": "address" },
|
337
355
|
{ "internalType": "address", "name": "targetToken_", "type": "address" },
|
338
356
|
{ "internalType": "uint256", "name": "amount_", "type": "uint256" },
|
339
|
-
{ "internalType": "uint32", "name": "
|
357
|
+
{ "internalType": "uint32", "name": "sourceChainId_", "type": "uint32" },
|
340
358
|
{
|
341
359
|
"internalType": "bytes32",
|
342
360
|
"name": "transactionHash_",
|
@@ -351,6 +369,27 @@
|
|
351
369
|
},
|
352
370
|
{
|
353
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" },
|
354
393
|
{ "internalType": "address", "name": "sourceToken_", "type": "address" },
|
355
394
|
{ "internalType": "address", "name": "targetToken_", "type": "address" },
|
356
395
|
{ "internalType": "uint256", "name": "amount_", "type": "uint256" },
|
@@ -362,15 +401,39 @@
|
|
362
401
|
"stateMutability": "nonpayable",
|
363
402
|
"type": "function"
|
364
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
|
+
},
|
365
427
|
{
|
366
428
|
"inputs": [{ "internalType": "address", "name": "", "type": "address" }],
|
367
|
-
"name": "
|
368
|
-
"outputs": [{ "internalType": "
|
429
|
+
"name": "whitelistedTokens",
|
430
|
+
"outputs": [{ "internalType": "bool", "name": "", "type": "bool" }],
|
369
431
|
"stateMutability": "view",
|
370
432
|
"type": "function"
|
371
433
|
},
|
372
434
|
{
|
373
435
|
"inputs": [
|
436
|
+
{ "internalType": "string", "name": "actionId", "type": "string" },
|
374
437
|
{ "internalType": "address", "name": "user_", "type": "address" },
|
375
438
|
{ "internalType": "address", "name": "sourceToken_", "type": "address" },
|
376
439
|
{ "internalType": "address", "name": "targetToken_", "type": "address" },
|
@@ -7,11 +7,11 @@ export const addresses = {
|
|
7
7
|
137: {
|
8
8
|
gnosisSafe: '0x5635d2910e51da33d9DC0422c893CF4F28B69A25',
|
9
9
|
multisend: '0xA238CBeb142c10Ef7Ad8442C6D1f9E89e07e7761',
|
10
|
-
interopXContract: '
|
10
|
+
interopXContract: '0x41bd77583674B3a5c073FBb4922C0C8dA91C43cF',
|
11
11
|
},
|
12
12
|
43114: {
|
13
13
|
gnosisSafe: '0x31d7a5194Fe60AC209Cf1Ce2d539C9A60662Ed6b',
|
14
14
|
multisend: '0x998739BFdAAdde7C933B942a68053933098f9EDa',
|
15
|
-
interopXContract: '
|
15
|
+
interopXContract: '0xCF391A3057eDba541c80307aC5E3Bc1E4a9471b7',
|
16
16
|
}
|
17
17
|
}
|
@@ -17,7 +17,7 @@ export class Transaction extends Model<InferAttributes<Transaction>, InferCreati
|
|
17
17
|
|
18
18
|
declare transactionHash: string;
|
19
19
|
|
20
|
-
declare
|
20
|
+
declare actionId: string;
|
21
21
|
declare bridger: string;
|
22
22
|
declare requestTransactionHash: string;
|
23
23
|
|
@@ -42,6 +42,7 @@ export class Transaction extends Model<InferAttributes<Transaction>, InferCreati
|
|
42
42
|
declare targetDelayUntil: CreationOptional<Date>;
|
43
43
|
|
44
44
|
declare requestEvent: {
|
45
|
+
actionId: string;
|
45
46
|
bridger: string;
|
46
47
|
metadata: string;
|
47
48
|
position: IPosition;
|
@@ -49,6 +50,7 @@ export class Transaction extends Model<InferAttributes<Transaction>, InferCreati
|
|
49
50
|
targetChainId: number;
|
50
51
|
};
|
51
52
|
declare requestSentEvent: CreationOptional<{
|
53
|
+
actionId: string;
|
52
54
|
bridger: string;
|
53
55
|
metadata: string;
|
54
56
|
position: IPosition;
|
@@ -76,7 +78,7 @@ Transaction.init({
|
|
76
78
|
requestBlockNumber: DataTypes.NUMBER,
|
77
79
|
|
78
80
|
transactionHash: DataTypes.STRING,
|
79
|
-
|
81
|
+
actionId: DataTypes.STRING,
|
80
82
|
bridger: DataTypes.STRING,
|
81
83
|
|
82
84
|
sourceChainId: DataTypes.NUMBER,
|
@@ -12,8 +12,8 @@ export default async function (transaction: Transaction, type: 'source' | 'targe
|
|
12
12
|
const transactions: MetaTransaction[] = [];
|
13
13
|
const logs: any[] = [];
|
14
14
|
|
15
|
-
if (transaction.
|
16
|
-
throw new Error(`Invalid action: ${transaction.
|
15
|
+
if (transaction.actionId !== 'withdraw') {
|
16
|
+
throw new Error(`Invalid action: ${transaction.actionId}`)
|
17
17
|
}
|
18
18
|
|
19
19
|
if (type !== 'source') {
|
@@ -32,30 +32,31 @@ export default async function (transaction: Transaction, type: 'source' | 'targe
|
|
32
32
|
throw Error('Something went wrong, source transaction has no request event')
|
33
33
|
}
|
34
34
|
|
35
|
-
const { bridger, position, sourceChainId, targetChainId, metadata
|
35
|
+
const { actionId, bridger, position, sourceChainId, targetChainId, metadata} = transaction.requestEvent;
|
36
36
|
|
37
37
|
const sourceChainProvider = new ethers.providers.JsonRpcProvider(getRpcProviderUrl(targetChainId as ChainId));
|
38
38
|
const sourceWallet = new ethers.Wallet(config.privateKey, sourceChainProvider);
|
39
39
|
const contractAddress = addresses[sourceChainId].interopXContract;
|
40
40
|
const contract = getContract<InteropXContract>(contractAddress, abi.interopXContract, sourceWallet);
|
41
41
|
|
42
|
-
const sourceToken = tokens[sourceChainId].find(
|
42
|
+
const sourceToken = tokens[sourceChainId].find(t => t.address.toLowerCase() === position.withdraw[0].sourceToken.toLowerCase());
|
43
43
|
|
44
|
-
if(!sourceToken) {
|
44
|
+
if (!sourceToken) {
|
45
45
|
throw Error('Source token not found')
|
46
46
|
}
|
47
47
|
|
48
|
-
const targetToken = tokens[targetChainId].find(
|
48
|
+
const targetToken = tokens[targetChainId].find(t => t.address.toLowerCase() === position.withdraw[0].targetToken.toLowerCase());
|
49
49
|
|
50
|
-
if(!targetToken) {
|
50
|
+
if (!targetToken) {
|
51
51
|
throw Error('Target token not found')
|
52
52
|
}
|
53
53
|
|
54
|
-
if(sourceToken.aliases.some(alias => targetToken.aliases.includes(alias))) {
|
54
|
+
if (sourceToken.aliases.some(alias => targetToken.aliases.includes(alias))) {
|
55
55
|
throw Error('Source and target token must be the same')
|
56
56
|
}
|
57
57
|
|
58
58
|
const { data } = await contract.populateTransaction.withdrawRequested(
|
59
|
+
actionId,
|
59
60
|
bridger,
|
60
61
|
position.withdraw[0].sourceToken,
|
61
62
|
position.withdraw[0].targetToken,
|
package/src/gnosis/index.ts
CHANGED
@@ -5,9 +5,9 @@ import actions from "./actions";
|
|
5
5
|
export const buildGnosisAction = async (transaction: Transaction, type: 'source' | 'target') => {
|
6
6
|
// type = type || (transaction.sourceStatus === 'success' ? 'target' : 'source')
|
7
7
|
|
8
|
-
if (actions.hasOwnProperty(transaction.
|
8
|
+
if (actions.hasOwnProperty(transaction.actionId)) {
|
9
9
|
|
10
|
-
const { transactions, logs } = await actions[transaction.
|
10
|
+
const { transactions, logs } = await actions[transaction.actionId](transaction, type);
|
11
11
|
|
12
12
|
return {
|
13
13
|
data: encodeMulti(transactions).data,
|
@@ -15,5 +15,5 @@ export const buildGnosisAction = async (transaction: Transaction, type: 'source'
|
|
15
15
|
};
|
16
16
|
}
|
17
17
|
|
18
|
-
throw new Error(`Unknown action: ${transaction.
|
18
|
+
throw new Error(`Unknown action: ${transaction.actionId}`);
|
19
19
|
}
|
@@ -40,10 +40,10 @@ class SyncBridgeRequestEvents extends BaseTask {
|
|
40
40
|
continue;
|
41
41
|
}
|
42
42
|
|
43
|
-
const { bridger, position, sourceChainId, targetChainId, metadata } = event.args;
|
43
|
+
const { actionId, bridger, position, sourceChainId, targetChainId, metadata } = event.args;
|
44
44
|
|
45
45
|
const uniqueIdentifier = {
|
46
|
-
|
46
|
+
actionId,
|
47
47
|
bridger,
|
48
48
|
requestTransactionHash: event.transactionHash,
|
49
49
|
sourceChainId: sourceChainId.toNumber(),
|
@@ -63,6 +63,7 @@ class SyncBridgeRequestEvents extends BaseTask {
|
|
63
63
|
...uniqueIdentifier,
|
64
64
|
requestBlockNumber: event.blockNumber,
|
65
65
|
requestEvent: {
|
66
|
+
actionId,
|
66
67
|
bridger,
|
67
68
|
position: {
|
68
69
|
withdraw: position.withdraw.map((v) => ({
|
@@ -41,10 +41,10 @@ class SyncBridgeRequestSentEvents extends BaseTask {
|
|
41
41
|
continue;
|
42
42
|
}
|
43
43
|
|
44
|
-
const { bridger, position, sourceChainId, targetChainId, requestTransactionHash, metadata } = event.args;
|
44
|
+
const { actionId, bridger, position, sourceChainId, targetChainId, requestTransactionHash, metadata } = event.args;
|
45
45
|
|
46
46
|
const uniqueIdentifier = {
|
47
|
-
|
47
|
+
actionId,
|
48
48
|
bridger,
|
49
49
|
requestTransactionHash,
|
50
50
|
sourceChainId: sourceChainId,
|
@@ -68,6 +68,7 @@ class SyncBridgeRequestSentEvents extends BaseTask {
|
|
68
68
|
transaction.sourceBlockNumber = event.blockNumber;
|
69
69
|
transaction.sourceTransactionHash = event.transactionHash
|
70
70
|
transaction.requestSentEvent = {
|
71
|
+
actionId,
|
71
72
|
bridger,
|
72
73
|
position: {
|
73
74
|
withdraw: position.withdraw.map((v) => ({
|