@instadapp/interop-x 0.0.0-dev.326bdca → 0.0.0-dev.376f394

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 (45) hide show
  1. package/.github/workflows/ci.yml +19 -0
  2. package/dist/package.json +12 -11
  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/constants/tokens.js +62 -39
  8. package/dist/src/db/models/transaction.js +12 -12
  9. package/dist/src/gnosis/actions/withdraw/index.js +106 -33
  10. package/dist/src/gnosis/index.js +4 -4
  11. package/dist/src/index.js +1 -1
  12. package/dist/src/net/protocol/dial/SignatureDialProtocol.js +6 -2
  13. package/dist/src/tasks/{InteropXContract/SyncBridgeRequestEvents.js → InteropX/SyncLogSubmitEvents.js} +21 -15
  14. package/dist/src/tasks/Transactions/SyncTransactionStatusTask.js +5 -2
  15. package/dist/src/tasks/index.js +7 -8
  16. package/dist/src/typechain/{InteropXContract.js → InteropX.js} +0 -0
  17. package/dist/src/typechain/factories/InteropX__factory.js +1928 -0
  18. package/dist/src/typechain/factories/index.js +3 -3
  19. package/dist/src/typechain/index.js +3 -3
  20. package/dist/src/utils/index.js +36 -9
  21. package/package.json +12 -11
  22. package/src/abi/index.ts +2 -2
  23. package/src/abi/interopX.json +1436 -0
  24. package/src/api/index.ts +1 -1
  25. package/src/constants/addresses.ts +3 -8
  26. package/src/constants/tokens.ts +63 -40
  27. package/src/db/models/transaction.ts +31 -29
  28. package/src/gnosis/actions/withdraw/index.ts +141 -42
  29. package/src/gnosis/index.ts +5 -5
  30. package/src/net/protocol/dial/SignatureDialProtocol.ts +6 -2
  31. package/src/tasks/{InteropXContract/SyncBridgeRequestEvents.ts → InteropX/SyncLogSubmitEvents.ts} +40 -20
  32. package/src/tasks/Transactions/SyncTransactionStatusTask.ts +5 -2
  33. package/src/tasks/index.ts +7 -9
  34. package/src/typechain/InteropX.ts +1216 -0
  35. package/src/typechain/factories/InteropX__factory.ts +1932 -0
  36. package/src/typechain/factories/index.ts +1 -1
  37. package/src/typechain/index.ts +2 -2
  38. package/src/utils/index.ts +88 -39
  39. package/dist/src/abi/interopXContract.json +0 -391
  40. package/dist/src/tasks/InteropXContract/ProcessBridgeRequestEvents.js +0 -146
  41. package/dist/src/typechain/factories/InteropXContract__factory.js +0 -526
  42. package/src/abi/interopXContract.json +0 -391
  43. package/src/tasks/InteropXContract/ProcessBridgeRequestEvents.ts +0 -208
  44. package/src/typechain/InteropXContract.ts +0 -524
  45. package/src/typechain/factories/InteropXContract__factory.ts +0 -533
@@ -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);
@@ -55,17 +69,20 @@ class SyncBridgeRequestEvents extends BaseTask {
55
69
  const transaction = await Transaction.findOne({ where: { transactionHash } });
56
70
 
57
71
  if (transaction) {
58
- return;
72
+ continue;
59
73
  }
60
74
 
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;
@@ -20,14 +20,17 @@ class SyncTransactionStatusTask extends BaseTask {
20
20
  const leadNode = peerPool.getLeadPeer();
21
21
 
22
22
  if (!leadNode) {
23
+ console.log("No lead node found");
23
24
  return;
24
25
  }
25
26
 
26
27
  const transaction = await Transaction.findOne({
27
28
  where: {
28
- status: 'pending',
29
+ sourceStatus: {
30
+ [Op.notIn] : ['success', 'failed'],
31
+ },
29
32
  sourceCreatedAt: {
30
- [Op.gte]: new Date(Date.now() - 60 * 60 * 1000),
33
+ [Op.gte]: new Date(Date.now() - 15 * 60 * 1000),
31
34
  },
32
35
  }
33
36
  })
@@ -1,11 +1,11 @@
1
1
  import { BaseTask } from "./BaseTask";
2
+ import wait from "waait";
3
+
2
4
  import SyncTransactionStatusTask from "./Transactions/SyncTransactionStatusTask";
3
5
 
4
6
  import AutoUpdateTask from "./AutoUpdateTask";
5
7
 
6
- import SyncBridgeRequestEvents from "./InteropXContract/SyncBridgeRequestEvents";
7
- import ProccessBridgeRequestEvents from "./InteropXContract/ProcessBridgeRequestEvents";
8
- import wait from "waait";
8
+ import SyncLogSubmitEvents from "./InteropX/SyncLogSubmitEvents";
9
9
 
10
10
  export class Tasks {
11
11
 
@@ -13,13 +13,11 @@ export class Tasks {
13
13
  // new SyncTransactionStatusTask(),
14
14
  new AutoUpdateTask(),
15
15
 
16
- // InteropXContract
17
-
18
- new SyncBridgeRequestEvents({ chainId: 137 }),
19
- new SyncBridgeRequestEvents({ chainId: 43114 }),
16
+ // InteropX
17
+ new SyncLogSubmitEvents({ chainId: 137 }),
18
+ new SyncLogSubmitEvents({ chainId: 43114 }),
20
19
 
21
- new ProccessBridgeRequestEvents({ chainId: 137 }),
22
- new ProccessBridgeRequestEvents({ chainId: 43114 }),
20
+ new SyncTransactionStatusTask(),
23
21
  ];
24
22
 
25
23
  async start() {