@instadapp/interop-x 0.0.0-dev.73e5298 → 0.0.0-dev.7738003

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 (43) hide show
  1. package/.github/workflows/ci.yml +19 -0
  2. package/dist/package.json +1 -1
  3. package/dist/src/abi/index.js +2 -2
  4. package/dist/src/abi/interopX.json +1436 -0
  5. package/dist/src/api/index.js +1 -1
  6. package/dist/src/constants/addresses.js +2 -7
  7. package/dist/src/db/models/transaction.js +11 -9
  8. package/dist/src/gnosis/actions/withdraw/index.js +106 -107
  9. package/dist/src/index.js +1 -1
  10. package/dist/src/tasks/{InteropXContract/SyncBridgeRequestEvents.js → InteropX/SyncLogSubmitEvents.js} +18 -12
  11. package/dist/src/tasks/Transactions/SyncTransactionStatusTask.js +3 -3
  12. package/dist/src/tasks/index.js +4 -13
  13. package/dist/src/typechain/{InteropXContract.js → InteropX.js} +0 -0
  14. package/dist/src/typechain/factories/InteropX__factory.js +1928 -0
  15. package/dist/src/typechain/factories/index.js +3 -3
  16. package/dist/src/typechain/index.js +3 -3
  17. package/dist/src/utils/index.js +5 -3
  18. package/package.json +1 -1
  19. package/src/abi/index.ts +2 -2
  20. package/src/abi/interopX.json +1436 -0
  21. package/src/api/index.ts +1 -1
  22. package/src/constants/addresses.ts +3 -8
  23. package/src/db/models/transaction.ts +28 -37
  24. package/src/gnosis/actions/withdraw/index.ts +131 -131
  25. package/src/tasks/{InteropXContract/SyncBridgeRequestEvents.ts → InteropX/SyncLogSubmitEvents.ts} +37 -16
  26. package/src/tasks/Transactions/SyncTransactionStatusTask.ts +3 -3
  27. package/src/tasks/index.ts +5 -17
  28. package/src/typechain/InteropX.ts +1216 -0
  29. package/src/typechain/factories/InteropX__factory.ts +1932 -0
  30. package/src/typechain/factories/index.ts +1 -1
  31. package/src/typechain/index.ts +2 -2
  32. package/src/utils/index.ts +22 -8
  33. package/dist/src/abi/interopXContract.json +0 -454
  34. package/dist/src/tasks/InteropXContract/ProcessBridgeRequestEvents.js +0 -158
  35. package/dist/src/tasks/InteropXContract/SyncBridgeCommittedEvents.js +0 -93
  36. package/dist/src/tasks/InteropXContract/SyncBridgeRequestSentEvents.js +0 -90
  37. package/dist/src/typechain/factories/InteropXContract__factory.js +0 -635
  38. package/src/abi/interopXContract.json +0 -454
  39. package/src/tasks/InteropXContract/ProcessBridgeRequestEvents.ts +0 -226
  40. package/src/tasks/InteropXContract/SyncBridgeCommittedEvents.ts +0 -125
  41. package/src/tasks/InteropXContract/SyncBridgeRequestSentEvents.ts +0 -121
  42. package/src/typechain/InteropXContract.ts +0 -680
  43. package/src/typechain/factories/InteropXContract__factory.ts +0 -642
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: '0x65AcB77B5191CED1B1ae85B454D20E2d128fAfEe',
5
+ interopX: '0xDB6083df37C5F224a3dF84A4B5f9fB60b6c8670a',
11
6
  },
12
7
  43114: {
13
8
  gnosisSafe: '0x31d7a5194Fe60AC209Cf1Ce2d539C9A60662Ed6b',
14
9
  multisend: '0x998739BFdAAdde7C933B942a68053933098f9EDa',
15
- interopXContract: '0xd61f55C6d9deD35B9d13243b816c4BcC1d78592b',
10
+ interopX: '0xd61f55C6d9deD35B9d13243b816c4BcC1d78592b',
16
11
  }
17
- } as Record<number, { gnosisSafe: string, multisend: string, interopXContract: string }>
12
+ } as Record<number, { gnosisSafe: string, multisend: string, interopX: string }>
@@ -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
-
19
+ declare vnonce: string;
20
20
  declare actionId: string;
21
- declare bridger: string;
22
- declare requestTransactionHash: 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,33 +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
- actionId: string;
46
- bridger: string;
47
- metadata: string;
48
+ declare submitEvent: {
48
49
  position: IPosition;
49
- sourceChainId: number;
50
- targetChainId: number;
51
- };
52
- declare requestSentEvent: CreationOptional<{
53
50
  actionId: string;
54
- bridger: string;
55
- metadata: string;
56
- position: IPosition;
51
+ actionIdHashHash: string;
52
+ sourceSender: string;
53
+ sourceDsaId: string;
54
+ targetDsaId: string;
57
55
  sourceChainId: number;
58
56
  targetChainId: number;
59
- requestTransactionHash: string;
60
- }>;
61
- declare committedEvent: CreationOptional<{
62
- actionId: string;
63
- bridger: string;
57
+ vnonce: string;
64
58
  metadata: string;
65
- position: IPosition;
66
- sourceChainId: number;
67
- targetChainId: number;
68
- requestTransactionHash: string;
69
- }>;
70
- declare completedEvent: CreationOptional<any>;
59
+ };
71
60
 
72
61
  declare status: CreationOptional<string>;
73
62
 
@@ -82,19 +71,23 @@ Transaction.init({
82
71
  primaryKey: true
83
72
  },
84
73
 
85
- requestTransactionHash: DataTypes.NUMBER,
86
- requestBlockNumber: DataTypes.NUMBER,
87
-
88
74
  transactionHash: DataTypes.STRING,
89
75
  actionId: DataTypes.STRING,
90
- bridger: 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,
91
83
 
92
84
  sourceChainId: DataTypes.NUMBER,
85
+ sourceDsaId: DataTypes.STRING,
93
86
  sourceTransactionHash: DataTypes.STRING,
94
87
  sourceBlockNumber: DataTypes.NUMBER,
95
88
  sourceStatus: {
96
89
  type: DataTypes.STRING,
97
- defaultValue: 'uninitialised'
90
+ defaultValue: 'pending'
98
91
  },
99
92
  sourceErrors: {
100
93
  type: DataTypes.JSON,
@@ -111,11 +104,12 @@ Transaction.init({
111
104
  sourceDelayUntil: DataTypes.STRING,
112
105
 
113
106
  targetChainId: DataTypes.NUMBER,
107
+ targetDsaId: DataTypes.STRING,
114
108
  targetTransactionHash: DataTypes.STRING,
115
109
  targetBlockNumber: DataTypes.NUMBER,
116
110
  targetStatus: {
117
111
  type: DataTypes.STRING,
118
- defaultValue: 'uninitialised'
112
+ defaultValue: 'pending'
119
113
  },
120
114
  targetErrors: {
121
115
  type: DataTypes.JSON,
@@ -128,13 +122,10 @@ Transaction.init({
128
122
  targetCreatedAt: DataTypes.DATE,
129
123
  targetDelayUntil: DataTypes.DATE,
130
124
 
131
- requestEvent: {
125
+ submitEvent: {
132
126
  type: DataTypes.JSON,
133
127
  allowNull: false
134
128
  },
135
- requestSentEvent: DataTypes.JSON,
136
- committedEvent: DataTypes.JSON,
137
- completedEvent: DataTypes.JSON,
138
129
 
139
130
  status: {
140
131
  type: DataTypes.STRING,
@@ -2,154 +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 { Erc20, InteropXContract } from "@/typechain";
5
+ import { Erc20, InteropX } from "@/typechain";
6
6
  import { ChainId } from "@/types";
7
7
  import { getContract, getRpcProviderUrl, LiquidityError } from "@/utils";
8
8
  import { BigNumber, ethers } from "ethers";
9
9
  import { MetaTransaction, OperationType } from "ethers-multisend";
10
10
 
11
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].interopXContract;
16
- const contract = getContract<InteropXContract>(contractAddress, abi.interopXContract, sourceWallet);
17
- const data = await contract.getBridgeAmounts(user, tokens);
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
18
 
19
19
 
20
- return data.map((item, index) => ({
21
- token: tokens[index],
22
- deposit: item.deposit,
23
- withdraw: item.withdraw,
24
- }))
25
- }
20
+ // return data.map((item, index) => ({
21
+ // token: tokens[index],
22
+ // deposit: item.deposit,
23
+ // withdraw: item.withdraw,
24
+ // }))
25
+ // }
26
26
 
27
27
  export default async function (transaction: Transaction, type: 'source' | 'target') {
28
28
  const transactions: MetaTransaction[] = [];
29
29
  const logs: any[] = [];
30
30
 
31
- if (transaction.actionId !== 'withdraw') {
32
- throw new Error(`Invalid action: ${transaction.actionId}`)
33
- }
31
+ // if (transaction.actionId !== 'withdraw') {
32
+ // throw new Error(`Invalid action: ${transaction.actionId}`)
33
+ // }
34
34
 
35
- if (type !== 'source') {
36
- throw new Error(`[WIP] Type not supported: ${type}`)
37
- }
35
+ // if (type !== 'source') {
36
+ // throw new Error(`[WIP] Type not supported: ${type}`)
37
+ // }
38
38
 
39
- if (transaction.sourceStatus === 'pending') {
40
- throw Error('Source transaction already processesing')
41
- }
39
+ // if (transaction.sourceStatus === 'pending') {
40
+ // throw Error('Source transaction already processesing')
41
+ // }
42
42
 
43
- if (transaction.sourceStatus === 'pending') {
44
- throw Error('Source transaction already processed')
45
- }
43
+ // if (transaction.sourceStatus === 'pending') {
44
+ // throw Error('Source transaction already processed')
45
+ // }
46
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].interopXContract;
56
- const contract = getContract<InteropXContract>(contractAddress, abi.interopXContract, 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
- });
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
+ // });
153
153
 
154
154
  return { transactions, logs }
155
155
  }
@@ -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 { actionId, 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
58
  actionId,
47
- bridger,
48
- requestTransactionHash: event.transactionHash,
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,10 +75,14 @@ class SyncBridgeRequestEvents extends BaseTask {
61
75
  await Transaction.create({
62
76
  transactionHash,
63
77
  ...uniqueIdentifier,
64
- requestBlockNumber: event.blockNumber,
65
- requestEvent: {
78
+ submitChainId: this.chainId,
79
+ submitTransactionHash: event.transactionHash,
80
+ submitBlockNumber: event.blockNumber,
81
+ submitCreatedAt: new Date(),
82
+ submitEvent: {
66
83
  actionId,
67
- bridger,
84
+ actionIdHashHash,
85
+ vnonce: vnonce.toString(),
68
86
  position: {
69
87
  withdraw: position.withdraw.map((v) => ({
70
88
  sourceToken: v.sourceToken,
@@ -79,12 +97,15 @@ class SyncBridgeRequestEvents extends BaseTask {
79
97
  },
80
98
  sourceChainId: sourceChainId.toNumber(),
81
99
  targetChainId: targetChainId.toNumber(),
100
+ sourceSender,
101
+ sourceDsaId: sourceDsaId.toString(),
102
+ targetDsaId: targetDsaId.toString(),
82
103
  metadata,
83
104
  }
84
105
  })
85
106
 
86
107
  this.logger.info(
87
- `New bridge request received: ${transactionHash} `
108
+ `New InteropX tranaction: ${transactionHash} `
88
109
  );
89
110
  } catch (error) {
90
111
  this.logger.error(error);
@@ -96,15 +117,15 @@ class SyncBridgeRequestEvents extends BaseTask {
96
117
  }
97
118
 
98
119
  async start(): Promise<void> {
99
- this.contractAddress = addresses[this.chainId].interopXContract;
120
+ this.contractAddress = addresses[this.chainId].interopX;
100
121
 
101
122
  this.provider = new ethers.providers.JsonRpcProvider(
102
123
  getRpcProviderUrl(this.chainId)
103
124
  );
104
125
 
105
- this.contract = getContract<InteropXContract>(
126
+ this.contract = getContract<InteropX>(
106
127
  this.contractAddress,
107
- abi.interopXContract,
128
+ abi.interopX,
108
129
  new ethers.Wallet(config.privateKey!, this.provider)
109
130
  );
110
131
 
@@ -112,4 +133,4 @@ class SyncBridgeRequestEvents extends BaseTask {
112
133
  }
113
134
  }
114
135
 
115
- export default SyncBridgeRequestEvents;
136
+ export default SyncLogSubmitEvents;
@@ -25,11 +25,11 @@ class SyncTransactionStatusTask extends BaseTask {
25
25
 
26
26
  const transaction = await Transaction.findOne({
27
27
  where: {
28
- status: {
29
- [Op.ne] : 'success'
28
+ sourceStatus: {
29
+ [Op.notIn] : ['success', 'failed'],
30
30
  },
31
31
  sourceCreatedAt: {
32
- [Op.gte]: new Date(Date.now() - 60 * 60 * 1000),
32
+ [Op.gte]: new Date(Date.now() - 15 * 60 * 1000),
33
33
  },
34
34
  }
35
35
  })
@@ -5,10 +5,8 @@ import SyncTransactionStatusTask from "./Transactions/SyncTransactionStatusTask"
5
5
 
6
6
  import AutoUpdateTask from "./AutoUpdateTask";
7
7
 
8
- import SyncBridgeRequestEvents from "./InteropXContract/SyncBridgeRequestEvents";
9
- import ProccessBridgeRequestEvents from "./InteropXContract/ProcessBridgeRequestEvents";
10
- import SyncBridgeRequestSentEvents from "./InteropXContract/SyncBridgeRequestSentEvents";
11
- import SyncBridgeCommittedEvents from "./InteropXContract/SyncBridgeCommittedEvents";
8
+ import SyncBridgeRequestEvents from "./InteropX/SyncLogSubmitEvents";
9
+ import SyncLogSubmitEvents from "./InteropX/SyncLogSubmitEvents";
12
10
 
13
11
  export class Tasks {
14
12
 
@@ -16,19 +14,9 @@ export class Tasks {
16
14
  // new SyncTransactionStatusTask(),
17
15
  new AutoUpdateTask(),
18
16
 
19
- // InteropXContract
20
-
21
- new SyncBridgeRequestEvents({ chainId: 137 }),
22
- new SyncBridgeRequestEvents({ chainId: 43114 }),
23
-
24
- new SyncBridgeRequestSentEvents({ chainId: 137 }),
25
- new SyncBridgeRequestSentEvents({ chainId: 43114 }),
26
-
27
- new SyncBridgeCommittedEvents({ chainId: 137 }),
28
- new SyncBridgeCommittedEvents({ chainId: 43114 }),
29
-
30
- new ProccessBridgeRequestEvents({ chainId: 137 }),
31
- new ProccessBridgeRequestEvents({ chainId: 43114 }),
17
+ // InteropX
18
+ new SyncLogSubmitEvents({ chainId: 137 }),
19
+ new SyncLogSubmitEvents({ chainId: 43114 }),
32
20
  ];
33
21
 
34
22
  async start() {