@instadapp/interop-x 0.0.0-dev.a861339 → 0.0.0-dev.a9cd1d2

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 (44) hide show
  1. package/dist/package.json +12 -11
  2. package/dist/src/abi/index.js +2 -2
  3. package/dist/src/abi/interopX.json +1436 -0
  4. package/dist/src/api/index.js +1 -1
  5. package/dist/src/constants/addresses.js +2 -7
  6. package/dist/src/constants/tokens.js +62 -39
  7. package/dist/src/db/models/transaction.js +10 -10
  8. package/dist/src/gnosis/actions/withdraw/index.js +106 -33
  9. package/dist/src/gnosis/index.js +3 -3
  10. package/dist/src/index.js +1 -1
  11. package/dist/src/tasks/{InteropXContract/SyncBridgeRequestEvents.js → InteropX/SyncLogSubmitEvents.js} +20 -14
  12. package/dist/src/tasks/Transactions/SyncTransactionStatusTask.js +4 -2
  13. package/dist/src/tasks/index.js +4 -10
  14. package/dist/src/typechain/{InteropXContract.js → InteropX.js} +0 -0
  15. package/dist/src/typechain/factories/InteropX__factory.js +1928 -0
  16. package/dist/src/typechain/factories/index.js +3 -3
  17. package/dist/src/typechain/index.js +3 -3
  18. package/dist/src/utils/index.js +36 -9
  19. package/package.json +12 -11
  20. package/src/abi/index.ts +2 -2
  21. package/src/abi/interopX.json +1436 -0
  22. package/src/api/index.ts +1 -1
  23. package/src/constants/addresses.ts +3 -8
  24. package/src/constants/tokens.ts +63 -40
  25. package/src/db/models/transaction.ts +29 -34
  26. package/src/gnosis/actions/withdraw/index.ts +141 -42
  27. package/src/gnosis/index.ts +3 -3
  28. package/src/tasks/{InteropXContract/SyncBridgeRequestEvents.ts → InteropX/SyncLogSubmitEvents.ts} +39 -19
  29. package/src/tasks/Transactions/SyncTransactionStatusTask.ts +4 -2
  30. package/src/tasks/index.ts +5 -13
  31. package/src/typechain/InteropX.ts +1216 -0
  32. package/src/typechain/factories/InteropX__factory.ts +1932 -0
  33. package/src/typechain/factories/index.ts +1 -1
  34. package/src/typechain/index.ts +2 -2
  35. package/src/utils/index.ts +88 -39
  36. package/dist/src/abi/interopXContract.json +0 -391
  37. package/dist/src/tasks/InteropXContract/ProcessBridgeRequestEvents.js +0 -147
  38. package/dist/src/tasks/InteropXContract/SyncBridgeRequestSentEvents.js +0 -80
  39. package/dist/src/typechain/factories/InteropXContract__factory.js +0 -526
  40. package/src/abi/interopXContract.json +0 -391
  41. package/src/tasks/InteropXContract/ProcessBridgeRequestEvents.ts +0 -211
  42. package/src/tasks/InteropXContract/SyncBridgeRequestSentEvents.ts +0 -112
  43. package/src/typechain/InteropXContract.ts +0 -524
  44. package/src/typechain/factories/InteropXContract__factory.ts +0 -533
package/src/api/index.ts CHANGED
@@ -21,7 +21,7 @@ export const startApiServer = async () => {
21
21
  limit: 20,
22
22
  offset: 0,
23
23
  order: [
24
- ['createdAt', 'DESC']
24
+ ['updatedAt', 'DESC']
25
25
  ]
26
26
  })
27
27
  })
@@ -1,17 +1,12 @@
1
1
  export const addresses = {
2
- 1: {
3
- gnosisSafe: '0x811Bff6eF88dAAA0aD6438386B534A81cE3F160F',
4
- multisend: '0xA238CBeb142c10Ef7Ad8442C6D1f9E89e07e7761',
5
- interopXContract: '',
6
- },
7
2
  137: {
8
3
  gnosisSafe: '0x5635d2910e51da33d9DC0422c893CF4F28B69A25',
9
4
  multisend: '0xA238CBeb142c10Ef7Ad8442C6D1f9E89e07e7761',
10
- interopXContract: '0x2189741c8cAc1cf51570932817A7d6390646C80e',
5
+ interopX: '0xDB6083df37C5F224a3dF84A4B5f9fB60b6c8670a',
11
6
  },
12
7
  43114: {
13
8
  gnosisSafe: '0x31d7a5194Fe60AC209Cf1Ce2d539C9A60662Ed6b',
14
9
  multisend: '0x998739BFdAAdde7C933B942a68053933098f9EDa',
15
- interopXContract: '0x1867DF97Ec24bb0bbD4AD464F0Be9C6713422EAE',
10
+ interopX: '0xd61f55C6d9deD35B9d13243b816c4BcC1d78592b',
16
11
  }
17
- }
12
+ } as Record<number, { gnosisSafe: string, multisend: string, interopX: string }>
@@ -1,104 +1,127 @@
1
1
  export const tokens = {
2
- 1: [
3
- {
4
- symbol: "ETH",
5
- name: "Ethereum",
6
- address: "0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE",
7
- decimals: 18,
8
- },
9
- {
10
- symbol: "DAI",
11
- name: "DAI Stable",
12
- address: "0x6B175474E89094C44Da98b954EedeAC495271d0F",
13
- decimals: 18,
14
- },
15
- {
16
- symbol: "USDC",
17
- name: "USD Coin",
18
- address: "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48",
19
- decimals: 6,
20
- },
21
- {
22
- symbol: "USDT",
23
- name: "Tether USD Coin",
24
- address: "0xdAC17F958D2ee523a2206206994597C13D831ec7",
25
- decimals: 6,
26
- },
27
- {
28
- symbol: "WBTC",
29
- name: "Wrapped BTC",
30
- address: "0x2260FAC5E5542a773Aa44fBCfeDf7C193bc2C599",
31
- decimals: 8,
32
- },
33
- ],
2
+ // 1: [
3
+ // {
4
+ // aliases: ['eth'],
5
+ // symbol: "ETH",
6
+ // name: "Ethereum",
7
+ // address: "0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE",
8
+ // decimals: 18,
9
+ // },
10
+ // {
11
+ // aliases: ['weth'],
12
+ // symbol: "WETH",
13
+ // name: "Wrapped Ethereum",
14
+ // address: "0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2",
15
+ // decimals: 18,
16
+ // },
17
+ // {
18
+ // aliases: ['dai'],
19
+ // symbol: "DAI",
20
+ // name: "DAI Stable",
21
+ // address: "0x6B175474E89094C44Da98b954EedeAC495271d0F",
22
+ // decimals: 18,
23
+ // },
24
+ // {
25
+ // aliases: ['usdc'],
26
+ // symbol: "USDC",
27
+ // name: "USD Coin",
28
+ // address: "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48",
29
+ // decimals: 6,
30
+ // },
31
+ // {
32
+ // aliases: ['usdt'],
33
+ // symbol: "USDT",
34
+ // name: "Tether USD Coin",
35
+ // address: "0xdAC17F958D2ee523a2206206994597C13D831ec7",
36
+ // decimals: 6,
37
+ // },
38
+ // {
39
+ // aliases: ['wbtc'],
40
+ // symbol: "WBTC",
41
+ // name: "Wrapped BTC",
42
+ // address: "0x2260FAC5E5542a773Aa44fBCfeDf7C193bc2C599",
43
+ // decimals: 8,
44
+ // },
45
+ // ],
34
46
  137: [
35
47
  {
48
+ aliases: ['eth', 'weth'],
36
49
  symbol: "ETH",
37
50
  name: "Ethereum",
38
51
  address: "0x7ceB23fD6bC0adD59E62ac25578270cFf1b9f619",
39
52
  decimals: 18,
40
53
  },
41
54
  {
55
+ aliases: ['dai'],
42
56
  symbol: "DAI",
43
57
  name: "DAI Stable",
44
58
  address: "0x8f3Cf7ad23Cd3CaDbD9735AFf958023239c6A063",
45
59
  decimals: 18,
46
60
  },
47
61
  {
62
+ aliases: ['usdc'],
48
63
  symbol: "USDC",
49
64
  name: "USD Coin",
50
65
  address: "0x2791Bca1f2de4661ED88A30C99A7a9449Aa84174",
51
66
  decimals: 6,
52
67
  },
53
68
  {
69
+ aliases: ['usdt'],
54
70
  symbol: "USDT",
55
71
  name: "Tether USD Coin",
56
72
  address: "0xc2132D05D31c914a87C6611C10748AEb04B58e8F",
57
73
  decimals: 6,
58
74
  },
59
75
  {
76
+ aliases: ['wbtc'],
60
77
  symbol: "WBTC",
61
78
  name: "Wrapped BTC",
62
79
  address: "0x1BFD67037B42Cf73acF2047067bd4F2C47D9BfD6",
63
80
  decimals: 8,
64
81
  },
65
- {
66
- symbol: "AVAX",
67
- name: "Avalanche Token",
68
- address: "0x2C89bbc92BD86F8075d1DEcc58C7F4E0107f286b",
69
- decimals: 18,
70
- },
71
82
  ],
72
83
  43114: [
73
84
  {
85
+ aliases: ['eth', 'weth'],
74
86
  symbol: "ETH",
75
87
  name: "Ethereum",
76
88
  address: "0x49D5c2BdFfac6CE2BFdB6640F4F80f226bc10bAB",
77
89
  decimals: 18,
78
90
  },
79
91
  {
92
+ aliases: ['dai'],
80
93
  symbol: "DAI",
81
94
  name: "DAI Stable",
82
95
  address: "0xd586E7F844cEa2F87f50152665BCbc2C279D8d70",
83
96
  decimals: 18,
84
97
  },
85
98
  {
99
+ aliases: ['usdc'],
86
100
  symbol: "USDC",
87
101
  name: "USD Coin",
88
102
  address: "0xA7D7079b0FEaD91F3e65f86E8915Cb59c1a4C664",
89
103
  decimals: 6,
90
104
  },
91
105
  {
92
- symbol: "USDT",
106
+ aliases: ['usdt'],
107
+ symbol: "USDt",
93
108
  name: "Tether USD Coin",
109
+ address: "0x9702230A8Ea53601f5cD2dc00fDBc13d4dF4A8c7",
110
+ decimals: 6,
111
+ },
112
+ {
113
+ aliases: ['usdt'],
114
+ symbol: "USDT.e",
115
+ name: "Tether USD",
94
116
  address: "0xc7198437980c041c805A1EDcbA50c1Ce5db95118",
95
117
  decimals: 6,
96
118
  },
97
119
  {
120
+ aliases: ["wbtc"],
98
121
  symbol: "WBTC",
99
122
  name: "Wrapped BTC",
100
123
  address: "0x50b7545627a5162F82A992c33b87aDc75187B218",
101
124
  decimals: 8,
102
125
  },
103
126
  ],
104
- };
127
+ } as Record<number, { aliases: string[], symbol: string, name: string, address: string, decimals: number }[]>;
@@ -1,7 +1,7 @@
1
1
  import { sequelize } from '@/db/sequelize'
2
2
  import { CreationOptional, InferAttributes, InferCreationAttributes, Model, DataTypes } from 'sequelize';
3
3
 
4
- export interface IPositionTokenInfo{
4
+ export interface IPositionTokenInfo {
5
5
  amount: string;
6
6
  sourceToken: string;
7
7
  targetToken: string;
@@ -16,14 +16,17 @@ export class Transaction extends Model<InferAttributes<Transaction>, InferCreati
16
16
  declare id: CreationOptional<number>;
17
17
 
18
18
  declare transactionHash: string;
19
-
20
- declare action: string;
21
- declare bridger: string;
22
- declare requestTransactionHash: string;
19
+ declare vnonce: string;
20
+ declare actionId: string;
21
+ declare sourceSender: string;
23
22
 
24
- declare requestBlockNumber: number;
23
+ declare submitChainId: number;
24
+ declare submitTransactionHash: string;
25
+ declare submitBlockNumber: number;
26
+ declare submitCreatedAt: Date;
25
27
 
26
28
  declare sourceChainId: number;
29
+ declare sourceDsaId: string;
27
30
  declare sourceTransactionHash: CreationOptional<string>;
28
31
  declare sourceBlockNumber: CreationOptional<number>;
29
32
  declare sourceStatus: CreationOptional<string>;
@@ -33,6 +36,7 @@ export class Transaction extends Model<InferAttributes<Transaction>, InferCreati
33
36
  declare sourceDelayUntil: CreationOptional<Date>;
34
37
 
35
38
  declare targetChainId: number;
39
+ declare targetDsaId: string;
36
40
  declare targetTransactionHash: CreationOptional<string>;
37
41
  declare targetBlockNumber: CreationOptional<number>;
38
42
  declare targetStatus: CreationOptional<string>;
@@ -41,26 +45,18 @@ export class Transaction extends Model<InferAttributes<Transaction>, InferCreati
41
45
  declare targetCreatedAt: CreationOptional<Date>;
42
46
  declare targetDelayUntil: CreationOptional<Date>;
43
47
 
44
- declare requestEvent: {
45
- bridger: string;
46
- metadata: string;
48
+ declare submitEvent: {
47
49
  position: IPosition;
50
+ actionId: string;
51
+ actionIdHashHash: string;
52
+ sourceSender: string;
53
+ sourceDsaId: string;
54
+ targetDsaId: string;
48
55
  sourceChainId: number;
49
56
  targetChainId: number;
50
- };
51
- declare requestSentEvent: CreationOptional<{
52
- bridger: string;
57
+ vnonce: string;
53
58
  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;
63
- declare metadata: CreationOptional<any>;
59
+ };
64
60
 
65
61
  declare status: CreationOptional<string>;
66
62
 
@@ -75,14 +71,18 @@ Transaction.init({
75
71
  primaryKey: true
76
72
  },
77
73
 
78
- requestTransactionHash: DataTypes.NUMBER,
79
- requestBlockNumber: DataTypes.NUMBER,
80
-
81
74
  transactionHash: DataTypes.STRING,
82
- action: DataTypes.STRING,
83
- bridger: DataTypes.STRING,
75
+ actionId: DataTypes.STRING,
76
+ vnonce: DataTypes.STRING,
77
+ sourceSender: DataTypes.STRING,
78
+
79
+ submitChainId: DataTypes.NUMBER,
80
+ submitTransactionHash: DataTypes.STRING,
81
+ submitBlockNumber: DataTypes.NUMBER,
82
+ submitCreatedAt: DataTypes.DATE,
84
83
 
85
84
  sourceChainId: DataTypes.NUMBER,
85
+ sourceDsaId: DataTypes.STRING,
86
86
  sourceTransactionHash: DataTypes.STRING,
87
87
  sourceBlockNumber: DataTypes.NUMBER,
88
88
  sourceStatus: {
@@ -104,6 +104,7 @@ Transaction.init({
104
104
  sourceDelayUntil: DataTypes.STRING,
105
105
 
106
106
  targetChainId: DataTypes.NUMBER,
107
+ targetDsaId: DataTypes.STRING,
107
108
  targetTransactionHash: DataTypes.STRING,
108
109
  targetBlockNumber: DataTypes.NUMBER,
109
110
  targetStatus: {
@@ -121,16 +122,10 @@ Transaction.init({
121
122
  targetCreatedAt: DataTypes.DATE,
122
123
  targetDelayUntil: DataTypes.DATE,
123
124
 
124
- requestEvent: {
125
+ submitEvent: {
125
126
  type: DataTypes.JSON,
126
127
  allowNull: false
127
128
  },
128
- requestSentEvent: DataTypes.JSON,
129
- committedEvent: DataTypes.JSON,
130
- completedEvent: DataTypes.JSON,
131
-
132
- position: DataTypes.JSON,
133
- metadata: DataTypes.JSON,
134
129
 
135
130
  status: {
136
131
  type: DataTypes.STRING,
@@ -2,55 +2,154 @@ import abi from "@/abi";
2
2
  import config from "@/config";
3
3
  import { addresses, tokens } from "@/constants";
4
4
  import { Transaction } from "@/db";
5
- import { InteropXContract } from "@/typechain";
5
+ import { Erc20, InteropX } from "@/typechain";
6
6
  import { ChainId } from "@/types";
7
- import { getContract, getRpcProviderUrl } from "@/utils";
8
- import { ethers } from "ethers";
7
+ import { getContract, getRpcProviderUrl, LiquidityError } from "@/utils";
8
+ import { BigNumber, ethers } from "ethers";
9
9
  import { MetaTransaction, OperationType } from "ethers-multisend";
10
10
 
11
+
12
+ // const getBridgeAmounts = async (user: string, tokens: string[], chainId: ChainId) => {
13
+ // const sourceChainProvider = new ethers.providers.JsonRpcProvider(getRpcProviderUrl(chainId));
14
+ // const sourceWallet = new ethers.Wallet(config.privateKey, sourceChainProvider);
15
+ // const contractAddress = addresses[chainId].interopX;
16
+ // const contract = getContract<InteropX>(contractAddress, abi.interopX, sourceWallet);
17
+ // const data = await contract.getBridgeAmounts(user, tokens);
18
+
19
+
20
+ // return data.map((item, index) => ({
21
+ // token: tokens[index],
22
+ // deposit: item.deposit,
23
+ // withdraw: item.withdraw,
24
+ // }))
25
+ // }
26
+
11
27
  export default async function (transaction: Transaction, type: 'source' | 'target') {
12
28
  const transactions: MetaTransaction[] = [];
13
29
  const logs: any[] = [];
14
30
 
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
- });
31
+ // if (transaction.actionId !== 'withdraw') {
32
+ // throw new Error(`Invalid action: ${transaction.actionId}`)
33
+ // }
34
+
35
+ // if (type !== 'source') {
36
+ // throw new Error(`[WIP] Type not supported: ${type}`)
37
+ // }
38
+
39
+ // if (transaction.sourceStatus === 'pending') {
40
+ // throw Error('Source transaction already processesing')
41
+ // }
42
+
43
+ // if (transaction.sourceStatus === 'pending') {
44
+ // throw Error('Source transaction already processed')
45
+ // }
46
+
47
+ // if (!transaction.requestEvent) {
48
+ // throw Error('Something went wrong, source transaction has no request event')
49
+ // }
50
+
51
+ // const { actionId, bridger, position, sourceChainId, targetChainId, metadata } = transaction.requestEvent;
52
+
53
+ // const sourceChainProvider = new ethers.providers.JsonRpcProvider(getRpcProviderUrl(sourceChainId as ChainId));
54
+ // const sourceWallet = new ethers.Wallet(config.privateKey, sourceChainProvider);
55
+ // const contractAddress = addresses[sourceChainId].interopX;
56
+ // const contract = getContract<InteropX>(contractAddress, abi.interopX, sourceWallet);
57
+
58
+ // const sourceToken = tokens[sourceChainId].find(t => t.address.toLowerCase() === position.withdraw[0].sourceToken.toLowerCase());
59
+
60
+ // if (!sourceToken) {
61
+ // throw Error('Source token not found')
62
+ // }
63
+
64
+ // const targetToken = tokens[targetChainId].find(t => t.address.toLowerCase() === position.withdraw[0].targetToken.toLowerCase());
65
+
66
+ // if (!targetToken) {
67
+ // throw Error('Target token not found')
68
+ // }
69
+
70
+ // if (!sourceToken.aliases.some(alias => targetToken.aliases.includes(alias))) {
71
+ // throw Error('Source and target token must be the same')
72
+ // }
73
+
74
+ // const networks: ChainId[] = [137, 43114];
75
+ // const networkUserData = {}
76
+ // for (const network of networks) {
77
+ // networkUserData[network] = await getBridgeAmounts(bridger, tokens[network].map(t => t.address), network)
78
+ // }
79
+
80
+ // for (const tokenSymbol of ["dai", "usdc", "usdt", "eth", "wbtc"]) {
81
+ // let totalDeposit = BigNumber.from(0)
82
+ // let totalWithdraw = BigNumber.from(0)
83
+
84
+ // for (const network of networks) {
85
+ // // on avax might we have 2 usdc/usdt tokens
86
+ // const matchedTokens = tokens[network].filter(t => t.aliases.includes(tokenSymbol));
87
+
88
+ // for (const matchedToken of matchedTokens) {
89
+ // const data = networkUserData[network].find(t => t.token.toLowerCase() === matchedToken.address.toLowerCase());
90
+
91
+ // if (data) {
92
+ // totalDeposit = totalDeposit.add(data.deposit)
93
+ // totalWithdraw = totalWithdraw.add(data.withdraw)
94
+ // }
95
+ // }
96
+
97
+ // // on Mainent add weth too
98
+ // if (tokenSymbol === "eth" && network === 1) {
99
+ // const weth = tokens[1].find(t => t.symbol === 'WETH');
100
+
101
+ // if (weth) {
102
+ // const data = networkUserData[1].find(t => t.token.toLowerCase() === weth.address.toLowerCase());
103
+
104
+ // if (data) {
105
+ // totalDeposit = totalDeposit.add(data.deposit)
106
+ // totalWithdraw = totalWithdraw.add(data.withdraw)
107
+ // }
108
+ // }
109
+ // }
110
+ // }
111
+
112
+ // if (totalWithdraw.gt(totalDeposit)) {
113
+ // throw Error(`if withdraw > deposit, user has debt and we can't process the withdraw and reject it`)
114
+ // }
115
+
116
+ // if (totalWithdraw.lt(totalDeposit)) {
117
+ // throw Error('Something went wrong')
118
+ // }
119
+ // }
120
+
121
+ // let balance = BigNumber.from(0);
122
+
123
+ // if (position.withdraw[0].sourceToken.toLowerCase() === '0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE'.toLowerCase()) {
124
+ // balance = await sourceChainProvider.getBalance(bridger);
125
+
126
+ // } else {
127
+ // const erc20 = getContract<Erc20>(position.withdraw[0].sourceToken, abi.erc20, sourceChainProvider);
128
+ // balance = await erc20.balanceOf(addresses[sourceChainId].gnosisSafe);
129
+ // }
130
+
131
+ // if (balance.lt(position.withdraw[0].amount)) {
132
+ // throw new LiquidityError()
133
+ // }
134
+
135
+
136
+ // const { data } = await contract.populateTransaction.withdrawRequested(
137
+ // actionId,
138
+ // bridger,
139
+ // position.withdraw[0].sourceToken,
140
+ // position.withdraw[0].targetToken,
141
+ // position.withdraw[0].amount,
142
+ // targetChainId,
143
+ // transaction.requestTransactionHash,
144
+ // metadata,
145
+ // );
146
+
147
+ // transactions.push({
148
+ // to: contractAddress,
149
+ // data: data!,
150
+ // value: '0',
151
+ // operation: OperationType.Call,
152
+ // });
54
153
 
55
154
  return { transactions, logs }
56
155
  }
@@ -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.action)) {
8
+ if (actions.hasOwnProperty(transaction.actionId)) {
9
9
 
10
- const { transactions, logs } = await actions[transaction.action](transaction, type);
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.action}`);
18
+ throw new Error(`Unknown action: ${transaction.actionId}`);
19
19
  }
@@ -7,17 +7,17 @@ import { generateInteropTransactionHash, getContract, getRpcProviderUrl } from "
7
7
  import { addresses } from "@/constants";
8
8
  import { ChainId } from "@/types";
9
9
  import config from "@/config";
10
- import { InteropXContract } from "@/typechain";
10
+ import { InteropX } from "@/typechain";
11
11
 
12
- class SyncBridgeRequestEvents extends BaseTask {
12
+ class SyncLogSubmitEvents extends BaseTask {
13
13
  contractAddress: string;
14
14
  provider: ethers.providers.JsonRpcProvider;
15
- contract: InteropXContract;
15
+ contract: InteropX;
16
16
  chainId: ChainId;
17
17
 
18
18
  constructor({ chainId }: { chainId: ChainId }) {
19
19
  super({
20
- logger: new Logger("InteropXContract::SyncBridgeRequestEvents"),
20
+ logger: new Logger("InteropX::SyncLogSubmitEvents"),
21
21
  })
22
22
  this.chainId = chainId;
23
23
  }
@@ -26,7 +26,7 @@ class SyncBridgeRequestEvents extends BaseTask {
26
26
  const currentBlock = await this.provider.getBlockNumber();
27
27
 
28
28
  const events = await this.contract.queryFilter(
29
- this.contract.filters.LogBridgeRequest(),
29
+ this.contract.filters.LogSubmit(),
30
30
  currentBlock - 2000,
31
31
  currentBlock,
32
32
  );
@@ -40,14 +40,28 @@ class SyncBridgeRequestEvents extends BaseTask {
40
40
  continue;
41
41
  }
42
42
 
43
- const { bridger, position, sourceChainId, targetChainId, metadata } = event.args;
43
+ const {
44
+ position,
45
+ actionId,
46
+ actionIdHashHash,
47
+ sourceSender,
48
+ sourceDsaId,
49
+ targetDsaId,
50
+ sourceChainId,
51
+ targetChainId,
52
+ vnonce,
53
+ metadata,
54
+
55
+ } = event.args;
44
56
 
45
57
  const uniqueIdentifier = {
46
- action: 'withdraw', //todo
47
- bridger,
48
- requestTransactionHash: event.transactionHash,
58
+ actionId,
59
+ vnonce: vnonce.toString(),
60
+ sourceSender: sourceSender.toString(),
49
61
  sourceChainId: sourceChainId.toNumber(),
50
62
  targetChainId: targetChainId.toNumber(),
63
+ sourceDsaId: sourceDsaId.toString(),
64
+ targetDsaId: targetDsaId.toString(),
51
65
  }
52
66
 
53
67
  let transactionHash = generateInteropTransactionHash(uniqueIdentifier);
@@ -61,11 +75,14 @@ class SyncBridgeRequestEvents extends BaseTask {
61
75
  await Transaction.create({
62
76
  transactionHash,
63
77
  ...uniqueIdentifier,
64
- position,
65
- metadata,
66
- requestBlockNumber: event.blockNumber,
67
- requestEvent: {
68
- bridger,
78
+ submitChainId: this.chainId,
79
+ submitTransactionHash: event.transactionHash,
80
+ submitBlockNumber: event.blockNumber,
81
+ submitCreatedAt: new Date(),
82
+ submitEvent: {
83
+ actionId,
84
+ actionIdHashHash,
85
+ vnonce: vnonce.toString(),
69
86
  position: {
70
87
  withdraw: position.withdraw.map((v) => ({
71
88
  sourceToken: v.sourceToken,
@@ -80,12 +97,15 @@ class SyncBridgeRequestEvents extends BaseTask {
80
97
  },
81
98
  sourceChainId: sourceChainId.toNumber(),
82
99
  targetChainId: targetChainId.toNumber(),
100
+ sourceSender,
101
+ sourceDsaId: sourceDsaId.toString(),
102
+ targetDsaId: targetDsaId.toString(),
83
103
  metadata,
84
104
  }
85
105
  })
86
106
 
87
107
  this.logger.info(
88
- `New bridge request received: ${transactionHash} `
108
+ `New InteropX tranaction: ${transactionHash} `
89
109
  );
90
110
  } catch (error) {
91
111
  this.logger.error(error);
@@ -97,15 +117,15 @@ class SyncBridgeRequestEvents extends BaseTask {
97
117
  }
98
118
 
99
119
  async start(): Promise<void> {
100
- this.contractAddress = addresses[this.chainId].interopXContract;
120
+ this.contractAddress = addresses[this.chainId].interopX;
101
121
 
102
122
  this.provider = new ethers.providers.JsonRpcProvider(
103
123
  getRpcProviderUrl(this.chainId)
104
124
  );
105
125
 
106
- this.contract = getContract<InteropXContract>(
126
+ this.contract = getContract<InteropX>(
107
127
  this.contractAddress,
108
- abi.interopXContract,
128
+ abi.interopX,
109
129
  new ethers.Wallet(config.privateKey!, this.provider)
110
130
  );
111
131
 
@@ -113,4 +133,4 @@ class SyncBridgeRequestEvents extends BaseTask {
113
133
  }
114
134
  }
115
135
 
116
- export default SyncBridgeRequestEvents;
136
+ export default SyncLogSubmitEvents;