@instadapp/interop-x 0.0.0-dev.4887ba6 → 0.0.0-dev.4df5dc2

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 (81) hide show
  1. package/.github/workflows/ci.yml +19 -0
  2. package/dist/package.json +14 -13
  3. package/dist/src/abi/index.js +2 -4
  4. package/dist/src/abi/interopX.json +1436 -0
  5. package/dist/src/alias.js +10 -0
  6. package/dist/src/api/index.js +4 -1
  7. package/dist/src/config/index.js +10 -1
  8. package/dist/src/constants/addresses.js +2 -7
  9. package/dist/src/constants/index.js +0 -1
  10. package/dist/src/constants/tokens.js +62 -39
  11. package/dist/src/db/models/transaction.js +29 -11
  12. package/dist/src/gnosis/actions/index.js +9 -0
  13. package/dist/src/gnosis/actions/withdraw/index.js +114 -0
  14. package/dist/src/gnosis/index.js +20 -0
  15. package/dist/src/index.js +39 -23
  16. package/dist/src/net/peer/index.js +2 -1
  17. package/dist/src/net/pool/index.js +7 -2
  18. package/dist/src/net/protocol/dial/SignatureDialProtocol.js +9 -10
  19. package/dist/src/net/protocol/dial/TransactionStatusDialProtocol.js +30 -0
  20. package/dist/src/net/protocol/index.js +26 -5
  21. package/dist/src/tasks/AutoUpdateTask.js +36 -13
  22. package/dist/src/tasks/BaseTask.js +11 -3
  23. package/dist/src/tasks/InteropX/SyncLogSubmitEvents.js +84 -0
  24. package/dist/src/tasks/Transactions/SyncTransactionStatusTask.js +57 -0
  25. package/dist/src/tasks/index.js +7 -17
  26. package/dist/src/typechain/{InteropBridgeToken.js → InteropX.js} +0 -0
  27. package/dist/src/typechain/factories/InteropX__factory.js +1928 -0
  28. package/dist/src/typechain/factories/index.js +3 -5
  29. package/dist/src/typechain/index.js +3 -5
  30. package/dist/src/utils/index.js +59 -92
  31. package/package.json +14 -13
  32. package/src/abi/index.ts +2 -4
  33. package/src/abi/interopX.json +1436 -0
  34. package/src/alias.ts +6 -0
  35. package/src/api/index.ts +4 -1
  36. package/src/config/index.ts +9 -1
  37. package/src/constants/addresses.ts +3 -8
  38. package/src/constants/index.ts +0 -1
  39. package/src/constants/tokens.ts +63 -40
  40. package/src/db/models/transaction.ts +65 -25
  41. package/src/gnosis/actions/index.ts +5 -0
  42. package/src/gnosis/actions/withdraw/index.ts +155 -0
  43. package/src/gnosis/index.ts +19 -0
  44. package/src/index.ts +52 -25
  45. package/src/net/peer/index.ts +2 -1
  46. package/src/net/pool/index.ts +7 -3
  47. package/src/net/protocol/dial/SignatureDialProtocol.ts +11 -13
  48. package/src/net/protocol/dial/TransactionStatusDialProtocol.ts +33 -0
  49. package/src/net/protocol/index.ts +28 -6
  50. package/src/tasks/AutoUpdateTask.ts +40 -16
  51. package/src/tasks/BaseTask.ts +13 -3
  52. package/src/tasks/InteropX/SyncLogSubmitEvents.ts +136 -0
  53. package/src/tasks/Transactions/SyncTransactionStatusTask.ts +69 -0
  54. package/src/tasks/index.ts +12 -21
  55. package/src/typechain/InteropX.ts +1216 -0
  56. package/src/typechain/factories/InteropX__factory.ts +1932 -0
  57. package/src/typechain/factories/index.ts +1 -2
  58. package/src/typechain/index.ts +2 -4
  59. package/src/utils/index.ts +113 -131
  60. package/tsconfig.json +7 -2
  61. package/dist/src/abi/interopBridgeToken.json +0 -286
  62. package/dist/src/abi/interopXGateway.json +0 -184
  63. package/dist/src/constants/itokens.js +0 -13
  64. package/dist/src/tasks/InteropBridge/ProcessWithdrawEvents.js +0 -147
  65. package/dist/src/tasks/InteropBridge/SyncWithdrawEvents.js +0 -70
  66. package/dist/src/tasks/InteropXGateway/ProcessDepositEvents.js +0 -150
  67. package/dist/src/tasks/InteropXGateway/SyncDepositEvents.js +0 -75
  68. package/dist/src/typechain/InteropXGateway.js +0 -2
  69. package/dist/src/typechain/factories/InteropBridgeToken__factory.js +0 -459
  70. package/dist/src/typechain/factories/InteropXGateway__factory.js +0 -265
  71. package/src/abi/interopBridgeToken.json +0 -286
  72. package/src/abi/interopXGateway.json +0 -184
  73. package/src/constants/itokens.ts +0 -10
  74. package/src/tasks/InteropBridge/ProcessWithdrawEvents.ts +0 -233
  75. package/src/tasks/InteropBridge/SyncWithdrawEvents.ts +0 -121
  76. package/src/tasks/InteropXGateway/ProcessDepositEvents.ts +0 -245
  77. package/src/tasks/InteropXGateway/SyncDepositEvents.ts +0 -126
  78. package/src/typechain/InteropBridgeToken.ts +0 -686
  79. package/src/typechain/InteropXGateway.ts +0 -407
  80. package/src/typechain/factories/InteropBridgeToken__factory.ts +0 -466
  81. package/src/typechain/factories/InteropXGateway__factory.ts +0 -272
@@ -0,0 +1,69 @@
1
+ import { BaseTask } from "../BaseTask";
2
+ import Logger from '@/logger';
3
+ import config from "@/config";
4
+ import { peerPool, protocol } from "@/net";
5
+ import { Transaction } from "@/db";
6
+ import { Op } from "sequelize";
7
+
8
+ class SyncTransactionStatusTask extends BaseTask {
9
+ pollIntervalMs: number = 60 * 1000
10
+ exceptLeadNode: boolean = true;
11
+
12
+ constructor() {
13
+ super({
14
+ logger: new Logger("SyncTransactionStatusTask"),
15
+ })
16
+ }
17
+
18
+ async pollHandler() {
19
+ // if transaction is pending for more than 1 hour, check lead node for status
20
+ const leadNode = peerPool.getLeadPeer();
21
+
22
+ if (!leadNode) {
23
+ return;
24
+ }
25
+
26
+ const transaction = await Transaction.findOne({
27
+ where: {
28
+ sourceStatus: {
29
+ [Op.notIn] : ['success', 'failed'],
30
+ },
31
+ sourceCreatedAt: {
32
+ [Op.gte]: new Date(Date.now() - 15 * 60 * 1000),
33
+ },
34
+ }
35
+ })
36
+
37
+ if (!transaction) {
38
+ return;
39
+ }
40
+
41
+ this.logger.info(`Requesting transaction status for ${transaction.transactionHash}`)
42
+
43
+ const transactionStatus = await protocol.requestTransactionStatus(transaction.transactionHash, leadNode.id);
44
+
45
+ if (!transactionStatus) {
46
+ return;
47
+ }
48
+
49
+ this.logger.info(`Received transaction status for ${transaction.transactionHash}`)
50
+
51
+ transaction.sourceStatus = transactionStatus.sourceStatus
52
+ transaction.sourceTransactionHash = transactionStatus.sourceTransactionHash
53
+ transaction.sourceErrors = transactionStatus.sourceErrors
54
+ transaction.sourceLogs = transactionStatus.sourceLogs
55
+
56
+ transaction.targetStatus = transactionStatus.targetStatus
57
+ transaction.targetTransactionHash = transactionStatus.targetTransactionHash
58
+ transaction.targetErrors = transactionStatus.targetErrors
59
+ transaction.targetLogs = transactionStatus.targetLogs
60
+
61
+ transaction.status = transactionStatus.status
62
+
63
+ await transaction.save()
64
+
65
+ this.logger.info(`Updated transaction status for ${transaction.transactionHash}`)
66
+ }
67
+ }
68
+
69
+ export default SyncTransactionStatusTask;
@@ -1,38 +1,29 @@
1
1
  import { BaseTask } from "./BaseTask";
2
- import InteropXGatewayProcessDepositEvents from "./InteropXGateway/ProcessDepositEvents";
3
- import InteropXGatewaySyncDepositEvents from "./InteropXGateway/SyncDepositEvents";
2
+ import wait from "waait";
3
+
4
+ import SyncTransactionStatusTask from "./Transactions/SyncTransactionStatusTask";
4
5
 
5
- import InteropBridgeSyncWithdrawEvents from "./InteropBridge/SyncWithdrawEvents";
6
- import InteropBridgeProcessWithdrawEvents from "./InteropBridge/ProcessWithdrawEvents";
7
6
  import AutoUpdateTask from "./AutoUpdateTask";
8
7
 
8
+ import SyncBridgeRequestEvents from "./InteropX/SyncLogSubmitEvents";
9
+ import SyncLogSubmitEvents from "./InteropX/SyncLogSubmitEvents";
10
+
9
11
  export class Tasks {
10
-
12
+
11
13
  tasks: BaseTask[] = [
14
+ // new SyncTransactionStatusTask(),
12
15
  new AutoUpdateTask(),
13
16
 
14
- new InteropXGatewaySyncDepositEvents({
15
- chainId: 43114
16
- }),
17
-
18
- new InteropXGatewayProcessDepositEvents({
19
- chainId: 43114
20
- }),
21
-
22
- new InteropBridgeSyncWithdrawEvents({
23
- chainId: 137,
24
- itokenAddress: '0xEab02fe1F016eE3e4106c1C6aad35FeEe657268E',
25
- }),
26
-
27
- new InteropBridgeProcessWithdrawEvents({
28
- chainId: 137,
29
- })
17
+ // InteropX
18
+ new SyncLogSubmitEvents({ chainId: 137 }),
19
+ new SyncLogSubmitEvents({ chainId: 43114 }),
30
20
  ];
31
21
 
32
22
  async start() {
33
23
  for (const task of this.tasks) {
34
24
  try {
35
25
  task.start();
26
+ await wait(1000)
36
27
  } catch (error) {
37
28
  console.error(`Error starting task: ${task.constructor.name}`);
38
29
  }