@instadapp/interop-x 0.0.0-dev.a846f65 → 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 (76) hide show
  1. package/dist/package.json +14 -12
  2. package/dist/src/abi/index.js +2 -4
  3. package/dist/src/abi/interopX.json +1436 -0
  4. package/dist/src/alias.js +10 -0
  5. package/dist/src/api/index.js +3 -0
  6. package/dist/src/config/index.js +10 -1
  7. package/dist/src/constants/addresses.js +2 -7
  8. package/dist/src/constants/index.js +0 -1
  9. package/dist/src/constants/tokens.js +62 -39
  10. package/dist/src/db/models/transaction.js +29 -11
  11. package/dist/src/gnosis/actions/index.js +9 -0
  12. package/dist/src/gnosis/actions/withdraw/index.js +114 -0
  13. package/dist/src/gnosis/index.js +20 -0
  14. package/dist/src/index.js +34 -22
  15. package/dist/src/net/protocol/dial/SignatureDialProtocol.js +9 -10
  16. package/dist/src/net/protocol/dial/{SignatureDialProtocol.1.js → TransactionStatusDialProtocol.js} +2 -0
  17. package/dist/src/net/protocol/index.js +17 -7
  18. package/dist/src/tasks/AutoUpdateTask.js +11 -8
  19. package/dist/src/tasks/BaseTask.js +4 -0
  20. package/dist/src/tasks/InteropX/SyncLogSubmitEvents.js +84 -0
  21. package/dist/src/tasks/Transactions/SyncTransactionStatusTask.js +6 -2
  22. package/dist/src/tasks/index.js +7 -19
  23. package/dist/src/typechain/{InteropBridgeToken.js → InteropX.js} +0 -0
  24. package/dist/src/typechain/factories/InteropX__factory.js +1928 -0
  25. package/dist/src/typechain/factories/index.js +3 -5
  26. package/dist/src/typechain/index.js +3 -5
  27. package/dist/src/utils/index.js +46 -89
  28. package/package.json +14 -12
  29. package/src/abi/index.ts +2 -4
  30. package/src/abi/interopX.json +1436 -0
  31. package/src/alias.ts +6 -0
  32. package/src/api/index.ts +3 -0
  33. package/src/config/index.ts +9 -1
  34. package/src/constants/addresses.ts +3 -8
  35. package/src/constants/index.ts +0 -1
  36. package/src/constants/tokens.ts +63 -40
  37. package/src/db/models/transaction.ts +65 -25
  38. package/src/gnosis/actions/index.ts +5 -0
  39. package/src/gnosis/actions/withdraw/index.ts +155 -0
  40. package/src/gnosis/index.ts +19 -0
  41. package/src/index.ts +47 -26
  42. package/src/net/protocol/dial/SignatureDialProtocol.ts +11 -13
  43. package/src/net/protocol/dial/{SignatureDialProtocol.1.ts → TransactionStatusDialProtocol.ts} +3 -1
  44. package/src/net/protocol/index.ts +17 -7
  45. package/src/tasks/AutoUpdateTask.ts +15 -14
  46. package/src/tasks/BaseTask.ts +5 -0
  47. package/src/tasks/InteropX/SyncLogSubmitEvents.ts +136 -0
  48. package/src/tasks/Transactions/SyncTransactionStatusTask.ts +6 -2
  49. package/src/tasks/index.ts +12 -23
  50. package/src/typechain/InteropX.ts +1216 -0
  51. package/src/typechain/factories/InteropX__factory.ts +1932 -0
  52. package/src/typechain/factories/index.ts +1 -2
  53. package/src/typechain/index.ts +2 -4
  54. package/src/utils/index.ts +98 -128
  55. package/tsconfig.json +7 -2
  56. package/dist/src/abi/interopBridgeToken.json +0 -286
  57. package/dist/src/abi/interopXGateway.json +0 -184
  58. package/dist/src/constants/itokens.js +0 -13
  59. package/dist/src/tasks/InteropBridge/ProcessWithdrawEvents.js +0 -146
  60. package/dist/src/tasks/InteropBridge/SyncWithdrawEvents.js +0 -69
  61. package/dist/src/tasks/InteropXGateway/ProcessDepositEvents.js +0 -149
  62. package/dist/src/tasks/InteropXGateway/SyncDepositEvents.js +0 -74
  63. package/dist/src/typechain/InteropXGateway.js +0 -2
  64. package/dist/src/typechain/factories/InteropBridgeToken__factory.js +0 -459
  65. package/dist/src/typechain/factories/InteropXGateway__factory.js +0 -265
  66. package/src/abi/interopBridgeToken.json +0 -286
  67. package/src/abi/interopXGateway.json +0 -184
  68. package/src/constants/itokens.ts +0 -10
  69. package/src/tasks/InteropBridge/ProcessWithdrawEvents.ts +0 -231
  70. package/src/tasks/InteropBridge/SyncWithdrawEvents.ts +0 -119
  71. package/src/tasks/InteropXGateway/ProcessDepositEvents.ts +0 -243
  72. package/src/tasks/InteropXGateway/SyncDepositEvents.ts +0 -124
  73. package/src/typechain/InteropBridgeToken.ts +0 -686
  74. package/src/typechain/InteropXGateway.ts +0 -407
  75. package/src/typechain/factories/InteropBridgeToken__factory.ts +0 -466
  76. package/src/typechain/factories/InteropXGateway__factory.ts +0 -272
package/src/index.ts CHANGED
@@ -1,21 +1,7 @@
1
- import moduleAlias from 'module-alias';
2
-
3
- moduleAlias.addAliases({
4
- "@/": __dirname + "/",
5
- "@/logger": __dirname + "/logger",
6
- "@/tasks": __dirname + "/tasks",
7
- "@/utils": __dirname + "/utils",
8
- "@/api": __dirname + "/api",
9
- "@/net": __dirname + "/net",
10
- "@/db": __dirname + "/db",
11
- "@/config": __dirname + "/config",
12
- "@/types": __dirname + "/types",
13
- "@/abi": __dirname + "/abi",
14
- "@/constants": __dirname + "/constants",
15
- "@/typechain": __dirname + "/typechain"
16
- })
1
+ import './alias'
2
+ import expandHomeDir from "expand-home-dir";
3
+ import fs from 'fs-extra'
17
4
 
18
- moduleAlias();
19
5
  import dotenv from "dotenv";
20
6
  import chalk from 'chalk';
21
7
  import { ethers } from "ethers";
@@ -25,12 +11,30 @@ dotenv.config();
25
11
  import Logger from "@/logger";
26
12
  const logger = new Logger('Process')
27
13
 
14
+ const GIT_SHORT_HASH = '@GIT_SHORT_HASH@';
15
+
28
16
  const printUsage = () => {
17
+ console.log()
18
+ console.log(`Interop X Node (v${packageJson.version} - rev.${GIT_SHORT_HASH})`)
19
+ console.log()
20
+
29
21
  console.log('Usage:')
30
- console.log(' PRIVATE_KEY=abcd1234 interop-x')
31
- console.log(' PRIVATE_KEY=abcd1234 STAGING=true interop-x')
32
- console.log(' PRIVATE_KEY=abcd1234 AUTO_UPDATE=true interop-x')
33
- console.log(' PRIVATE_KEY=abcd1234 API_HOST=0.0.0.0 API_PORT=8080 interop-x')
22
+ console.log(' interop-x help Show this message')
23
+ console.log(' interop-x version Print out the installed version of Interop X')
24
+
25
+ console.log()
26
+
27
+ console.log(' interop-x down Put the node into maintenance mode')
28
+ console.log(' interop-x up Take the node out of maintenance mode')
29
+
30
+ console.log()
31
+
32
+ console.log(' PRIVATE_KEY=abcd1234 interop-x Start the node with the given private key')
33
+ console.log(' PRIVATE_KEY=abcd1234 STAGING=true interop-x Start the node in staging mode')
34
+ console.log(' PRIVATE_KEY=abcd1234 AUTO_UPDATE=true interop-x Start the node in auto update mode')
35
+ console.log(' PRIVATE_KEY=abcd1234 API_HOST=0.0.0.0 API_PORT=8080 interop-x Start the node with custom API host and port')
36
+ console.log()
37
+
34
38
  }
35
39
 
36
40
  if (process.argv.at(-1) === 'help') {
@@ -38,14 +42,27 @@ if (process.argv.at(-1) === 'help') {
38
42
  process.exit(0)
39
43
  }
40
44
 
41
- const GIT_SHORT_HASH = '@GIT_SHORT_HASH@';
45
+ const basePath = expandHomeDir(`~/.interop-x`);
46
+
47
+ if (process.argv.at(-1) === 'down') {
48
+ fs.outputFileSync(basePath + '/maintenance', Date.now().toString())
49
+ console.log(chalk.red('Maintenance mode enabled'))
50
+ process.exit(0)
51
+ }
52
+
53
+ if (process.argv.at(-1) === 'up') {
54
+ fs.removeSync(basePath + '/maintenance')
55
+ console.log(chalk.green('Maintenance mode disabled'))
56
+ process.exit(0)
57
+ }
58
+
42
59
 
43
60
  if (process.argv.at(-1) === 'version') {
44
61
  console.log(`Interop X Node (v${packageJson.version} - rev.${GIT_SHORT_HASH})`)
45
62
  process.exit(0)
46
63
  }
47
64
 
48
- if(! process.env.PRIVATE_KEY) {
65
+ if (!process.env.PRIVATE_KEY) {
49
66
  console.error(chalk.bgRed.white.bold('Please provide a private key\n'))
50
67
  printUsage()
51
68
  process.exit(1)
@@ -72,7 +89,9 @@ async function main() {
72
89
 
73
90
  const tasks = new Tasks()
74
91
 
75
- tasks.start();
92
+ setTimeout(() => {
93
+ tasks.start();
94
+ }, 10000)
76
95
 
77
96
  startApiServer()
78
97
 
@@ -80,10 +99,10 @@ async function main() {
80
99
  if (!peerPool.isLeadNode(payload.peerId)) {
81
100
  const peer = peerPool.getPeer(payload.peerId)
82
101
 
83
- if(! peer) {
102
+ if (!peer) {
84
103
  return;
85
104
  }
86
-
105
+
87
106
  logger.info(`ignored transaction status from ${payload.peerId} ${shortenHash(peer.publicAddress)} `)
88
107
  return;
89
108
  }
@@ -97,10 +116,12 @@ async function main() {
97
116
  transaction.sourceStatus = payload.data.sourceStatus
98
117
  transaction.sourceTransactionHash = payload.data.sourceTransactionHash
99
118
  transaction.sourceErrors = payload.data.sourceErrors
119
+ transaction.sourceLogs = payload.data.sourceLogs
100
120
 
101
121
  transaction.targetStatus = payload.data.targetStatus
102
122
  transaction.targetTransactionHash = payload.data.targetTransactionHash
103
123
  transaction.targetErrors = payload.data.targetErrors
124
+ transaction.targetLogs = payload.data.targetLogs
104
125
 
105
126
  transaction.status = payload.data.status
106
127
 
@@ -2,12 +2,13 @@ import { BaseDialProtocol } from "./BaseDialProtocol";
2
2
  import wait from "waait";
3
3
  import config from "@/config";
4
4
  import { Transaction } from "@/db";
5
- import { buildDataForTransaction, signGnosisSafeTx } from "@/utils";
5
+ import { signGnosisSafeTx } from "@/utils";
6
6
  import { addresses } from "@/constants";
7
7
  import { ChainId } from "@/types";
8
+ import { buildGnosisAction } from "@/gnosis";
8
9
 
9
10
  export interface ISignatureRequest {
10
- type: 'source' | 'target' ,
11
+ type: 'source' | 'target',
11
12
  transactionHash: string
12
13
  safeTxGas: string
13
14
  safeNonce: string
@@ -25,6 +26,10 @@ export class SignatureDialProtocol extends BaseDialProtocol<ISignatureRequest, I
25
26
  }
26
27
 
27
28
  async response(data: ISignatureRequest): Promise<ISignatureResponse> {
29
+ console.log({
30
+ tag: 'SignatureDialProtocol',
31
+ data
32
+ })
28
33
  const signer = config.wallet;
29
34
 
30
35
  let transaction: Transaction | null;
@@ -46,19 +51,12 @@ export class SignatureDialProtocol extends BaseDialProtocol<ISignatureRequest, I
46
51
  error: 'Event not found'
47
52
  };
48
53
  }
49
-
50
- console.log("signing:", {
51
- to: addresses[transaction.targetChainId].multisend,
52
- data: await buildDataForTransaction(transaction, data.type),
53
- chainId: transaction.targetChainId as ChainId,
54
- safeTxGas: data.safeTxGas,
55
- nonce: data.safeNonce,
56
- });
54
+ const { data: gnosisData } = await buildGnosisAction(transaction, data.type);
57
55
 
58
56
  const signedData = await signGnosisSafeTx({
59
- to: addresses[transaction.targetChainId].multisend,
60
- data: await buildDataForTransaction(transaction, data.type),
61
- chainId: transaction.targetChainId as ChainId,
57
+ to: addresses[transaction.sourceChainId].multisend,
58
+ data: gnosisData,
59
+ chainId: transaction.sourceChainId as ChainId,
62
60
  safeTxGas: data.safeTxGas,
63
61
  nonce: data.safeNonce,
64
62
  }, { signer });
@@ -1,7 +1,7 @@
1
1
  import { BaseDialProtocol } from "./BaseDialProtocol";
2
2
  import { Transaction } from "@/db";
3
3
 
4
- export class TransactionStatusDialProtocol extends BaseDialProtocol<string, Pick<Transaction, 'transactionHash' | 'sourceStatus' | 'sourceTransactionHash' | 'sourceErrors' | 'targetStatus' | 'targetTransactionHash' | 'targetErrors' | 'status'> | null> {
4
+ export class TransactionStatusDialProtocol extends BaseDialProtocol<string, Pick<Transaction, 'transactionHash' | 'sourceStatus' | 'sourceTransactionHash' | 'sourceErrors' | 'sourceLogs' | 'targetStatus' | 'targetTransactionHash' | 'targetErrors' | 'targetLogs' | 'status'> | null> {
5
5
  protected timeout = 30000;
6
6
 
7
7
  constructor(libp2p) {
@@ -20,10 +20,12 @@ export class TransactionStatusDialProtocol extends BaseDialProtocol<string, Pick
20
20
  sourceStatus: transaction.sourceStatus,
21
21
  sourceTransactionHash: transaction.sourceTransactionHash,
22
22
  sourceErrors: transaction.sourceErrors,
23
+ sourceLogs: transaction.sourceLogs,
23
24
 
24
25
  targetStatus: transaction.targetStatus,
25
26
  targetTransactionHash: transaction.targetTransactionHash,
26
27
  targetErrors: transaction.targetErrors,
28
+ targetLogs: transaction.targetLogs,
27
29
 
28
30
  status: transaction.status,
29
31
  }
@@ -6,7 +6,7 @@ import { IPeerInfo, peerPool } from "..";
6
6
  import config from "@/config";
7
7
  import { Event } from "@/types";
8
8
  import { Transaction } from "@/db";
9
- import { TransactionStatusDialProtocol } from "./dial/SignatureDialProtocol.1";
9
+ import { TransactionStatusDialProtocol } from "./dial/TransactionStatusDialProtocol";
10
10
 
11
11
  export interface ProtocolOptions {
12
12
  /* Handshake timeout in ms (default: 8000) */
@@ -36,7 +36,7 @@ interface PeerInfoEvent extends BaseMessageEvent {
36
36
  }
37
37
 
38
38
  interface TransactionStatusEvent extends BaseMessageEvent {
39
- data: Pick<Transaction, 'transactionHash' | 'sourceStatus' | 'sourceTransactionHash' | 'sourceErrors' | 'targetStatus' | 'targetTransactionHash' | 'targetErrors' | 'status'>
39
+ data: Pick<Transaction, 'transactionHash' | 'sourceStatus' | 'sourceTransactionHash' | 'sourceErrors' | 'sourceLogs' | 'targetStatus' | 'targetTransactionHash' | 'targetErrors' | 'targetLogs' | 'status'>
40
40
  }
41
41
 
42
42
  declare interface Protocol {
@@ -66,25 +66,35 @@ class Protocol extends EventEmitter {
66
66
  Buffer.from(transaction.transactionHash),
67
67
 
68
68
  Buffer.from(transaction.sourceStatus),
69
- Buffer.from(transaction.sourceTransactionHash),
69
+ Buffer.from(transaction.sourceTransactionHash || ''),
70
70
  transaction.sourceErrors ? transaction.sourceErrors.map((e) => Buffer.from(e)) : [],
71
+ transaction.sourceLogs ? transaction.sourceLogs.map((e) => [Buffer.from(e.type), Buffer.from(e.message)]) : [],
71
72
 
72
73
  Buffer.from(transaction.targetStatus),
73
- Buffer.from(transaction.targetTransactionHash),
74
+ Buffer.from(transaction.targetTransactionHash || ''),
74
75
  transaction.targetErrors ? transaction.targetErrors.map((e) => Buffer.from(e)) : [],
76
+ transaction.targetLogs ? transaction.targetLogs.map((e) => [Buffer.from(e.type), Buffer.from(e.message)]) : [],
75
77
 
76
78
  Buffer.from(transaction.status),
77
79
  ],
78
- decode: ([transactionHash, sourceStatus, sourceTransactionHash, sourceErrors, targetStatus, targetTransactionHash, targetErrors, status]: [Buffer, Buffer, Buffer, Buffer[], Buffer, Buffer, Buffer[], Buffer]) => ({
80
+ decode: ([transactionHash, sourceStatus, sourceTransactionHash, sourceErrors, sourceLogs, targetStatus, targetTransactionHash, targetErrors, targetLogs, status]: [Buffer, Buffer, Buffer, Buffer[],[Buffer,Buffer][], Buffer, Buffer, Buffer[],[Buffer,Buffer][], Buffer]) => ({
79
81
  transactionHash: transactionHash.toString(),
80
82
 
81
83
  sourceStatus: sourceStatus.toString(),
82
- sourceTransactionHash: sourceTransactionHash.toString(),
84
+ sourceTransactionHash: sourceTransactionHash.toString() || null,
83
85
  sourceErrors: sourceErrors.map((e) => e.toString()),
86
+ sourceLogs: sourceLogs.map(e => ({
87
+ type: e[0].toString(),
88
+ message: e[1].toString(),
89
+ })),
84
90
 
85
91
  targetStatus: targetStatus.toString(),
86
- targetTransactionHash: targetTransactionHash.toString(),
92
+ targetTransactionHash: targetTransactionHash.toString() || null,
87
93
  targetErrors: targetErrors.map((e) => e.toString()),
94
+ targetLogs: targetLogs.map(e => ({
95
+ type: e[0].toString(),
96
+ message: e[1].toString(),
97
+ })),
88
98
 
89
99
  status: status.toString(),
90
100
  }),
@@ -1,15 +1,16 @@
1
1
  import { BaseTask } from "./BaseTask";
2
2
  import Logger from '@/logger';
3
- import { http } from "@/utils";
4
- import spawn from 'await-spawn';
3
+ import spawnAsync from 'await-spawn';
4
+ import { spawn } from 'child_process'
5
5
  import config from "@/config";
6
6
  import wait from "waait";
7
7
  import packageJson from "../../package.json";
8
8
 
9
9
  const currentVersion = packageJson.version;
10
+ const tag = config.staging ? 'dev' : 'latest';
10
11
 
11
12
  class AutoUpdateTask extends BaseTask {
12
- pollIntervalMs: number = 60 * 5 * 1000
13
+ pollIntervalMs: number = 60 * 10 * 1000
13
14
 
14
15
  constructor() {
15
16
  super({
@@ -23,22 +24,20 @@ class AutoUpdateTask extends BaseTask {
23
24
 
24
25
  async getInstalledVersion() {
25
26
  try {
26
- const stdout = await spawn('npm', ['-g', 'ls', '--depth=0', '--json'])
27
+ const stdout = await spawnAsync('npm', ['-g', 'ls', '--depth=0', '--json'])
27
28
  return JSON.parse(stdout.toString()).dependencies[packageJson.name].version
28
29
  } catch (error) {
29
30
  this.logger.error(error)
30
-
31
31
  return currentVersion
32
32
  }
33
33
  }
34
34
 
35
35
  async getLatestVersion() {
36
36
  try {
37
- const stdout = await spawn('npm', ['view', packageJson.name, 'version'])
38
- return stdout.toString()
37
+ const stdout = await spawnAsync('npm', ['view', `${packageJson.name}@${tag}`, 'version'])
38
+ return stdout.toString().trim()
39
39
  } catch (error) {
40
40
  this.logger.error(error)
41
-
42
41
  return currentVersion
43
42
  }
44
43
  }
@@ -52,12 +51,9 @@ class AutoUpdateTask extends BaseTask {
52
51
 
53
52
  this.logger.warn(`New version ${version} available.`)
54
53
 
55
-
56
54
  this.logger.info('Updating...')
57
55
 
58
- const spawner = spawn('npm', ['-g', 'install', '@instadapp/interop-x@latest']);
59
- spawner.child.on('data', console.log)
60
- await spawner
56
+ await spawnAsync('npm', ['-g', 'install', `@instadapp/interop-x@${tag}`, '-f']);
61
57
 
62
58
  await wait(5000)
63
59
 
@@ -69,11 +65,16 @@ class AutoUpdateTask extends BaseTask {
69
65
  this.logger.warn(`Installed version ${version}`)
70
66
  this.logger.warn(`Restarting...`)
71
67
 
72
- spawn(process.argv[0], process.argv.slice(1), {
68
+
69
+ // TODO: its restarting in the bg, but it should be in the fg
70
+ const subprocess = spawn(process.argv[0], process.argv.slice(1), {
73
71
  cwd: process.cwd(),
74
- stdio: "inherit"
72
+ stdio: "inherit",
73
+ // shell: process.env.SHELL,
75
74
  });
76
75
 
76
+ subprocess.unref();
77
+
77
78
  process.exit()
78
79
  }
79
80
  }
@@ -46,6 +46,11 @@ export class BaseTask extends EventEmitter implements IBaseTask {
46
46
  }
47
47
 
48
48
  prePollHandler(): boolean {
49
+ if(config.isMaintenanceMode()){
50
+ this.logger.warn('Maintenance mode is enabled. Skipping task.')
51
+ return false
52
+ }
53
+
49
54
  if (this.exceptLeadNode) {
50
55
  return !config.isLeadNode();
51
56
  }
@@ -0,0 +1,136 @@
1
+ import { BaseTask } from "../BaseTask";
2
+ import Logger from '@/logger';
3
+ import { ethers } from "ethers";
4
+ import abi from "@/abi";
5
+ import { Transaction } from "@/db";
6
+ import { generateInteropTransactionHash, getContract, getRpcProviderUrl } from "@/utils";
7
+ import { addresses } from "@/constants";
8
+ import { ChainId } from "@/types";
9
+ import config from "@/config";
10
+ import { InteropX } from "@/typechain";
11
+
12
+ class SyncLogSubmitEvents extends BaseTask {
13
+ contractAddress: string;
14
+ provider: ethers.providers.JsonRpcProvider;
15
+ contract: InteropX;
16
+ chainId: ChainId;
17
+
18
+ constructor({ chainId }: { chainId: ChainId }) {
19
+ super({
20
+ logger: new Logger("InteropX::SyncLogSubmitEvents"),
21
+ })
22
+ this.chainId = chainId;
23
+ }
24
+
25
+ async pollHandler() {
26
+ const currentBlock = await this.provider.getBlockNumber();
27
+
28
+ const events = await this.contract.queryFilter(
29
+ this.contract.filters.LogSubmit(),
30
+ currentBlock - 2000,
31
+ currentBlock,
32
+ );
33
+
34
+ let processedEvents = 0;
35
+
36
+ for (const event of events) {
37
+
38
+ try {
39
+ if (!event.args) {
40
+ continue;
41
+ }
42
+
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;
56
+
57
+ const uniqueIdentifier = {
58
+ actionId,
59
+ vnonce: vnonce.toString(),
60
+ sourceSender: sourceSender.toString(),
61
+ sourceChainId: sourceChainId.toNumber(),
62
+ targetChainId: targetChainId.toNumber(),
63
+ sourceDsaId: sourceDsaId.toString(),
64
+ targetDsaId: targetDsaId.toString(),
65
+ }
66
+
67
+ let transactionHash = generateInteropTransactionHash(uniqueIdentifier);
68
+
69
+ const transaction = await Transaction.findOne({ where: { transactionHash } });
70
+
71
+ if (transaction) {
72
+ continue;
73
+ }
74
+
75
+ await Transaction.create({
76
+ transactionHash,
77
+ ...uniqueIdentifier,
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(),
86
+ position: {
87
+ withdraw: position.withdraw.map((v) => ({
88
+ sourceToken: v.sourceToken,
89
+ targetToken: v.targetToken,
90
+ amount: v.amount.toString()
91
+ })),
92
+ supply: position.supply.map((v) => ({
93
+ sourceToken: v.sourceToken,
94
+ targetToken: v.targetToken,
95
+ amount: v.amount.toString()
96
+ })),
97
+ },
98
+ sourceChainId: sourceChainId.toNumber(),
99
+ targetChainId: targetChainId.toNumber(),
100
+ sourceSender,
101
+ sourceDsaId: sourceDsaId.toString(),
102
+ targetDsaId: targetDsaId.toString(),
103
+ metadata,
104
+ }
105
+ })
106
+
107
+ this.logger.info(
108
+ `New InteropX tranaction: ${transactionHash} `
109
+ );
110
+ } catch (error) {
111
+ this.logger.error(error);
112
+ }
113
+ }
114
+
115
+ if (processedEvents > 0)
116
+ this.logger.info(`${processedEvents} events processed`);
117
+ }
118
+
119
+ async start(): Promise<void> {
120
+ this.contractAddress = addresses[this.chainId].interopX;
121
+
122
+ this.provider = new ethers.providers.JsonRpcProvider(
123
+ getRpcProviderUrl(this.chainId)
124
+ );
125
+
126
+ this.contract = getContract<InteropX>(
127
+ this.contractAddress,
128
+ abi.interopX,
129
+ new ethers.Wallet(config.privateKey!, this.provider)
130
+ );
131
+
132
+ await super.start()
133
+ }
134
+ }
135
+
136
+ export default SyncLogSubmitEvents;
@@ -25,9 +25,11 @@ class SyncTransactionStatusTask extends BaseTask {
25
25
 
26
26
  const transaction = await Transaction.findOne({
27
27
  where: {
28
- status: 'pending',
28
+ sourceStatus: {
29
+ [Op.notIn] : ['success', 'failed'],
30
+ },
29
31
  sourceCreatedAt: {
30
- [Op.gte]: new Date(Date.now() - 60 * 60 * 1000),
32
+ [Op.gte]: new Date(Date.now() - 15 * 60 * 1000),
31
33
  },
32
34
  }
33
35
  })
@@ -49,10 +51,12 @@ class SyncTransactionStatusTask extends BaseTask {
49
51
  transaction.sourceStatus = transactionStatus.sourceStatus
50
52
  transaction.sourceTransactionHash = transactionStatus.sourceTransactionHash
51
53
  transaction.sourceErrors = transactionStatus.sourceErrors
54
+ transaction.sourceLogs = transactionStatus.sourceLogs
52
55
 
53
56
  transaction.targetStatus = transactionStatus.targetStatus
54
57
  transaction.targetTransactionHash = transactionStatus.targetTransactionHash
55
58
  transaction.targetErrors = transactionStatus.targetErrors
59
+ transaction.targetLogs = transactionStatus.targetLogs
56
60
 
57
61
  transaction.status = transactionStatus.status
58
62
 
@@ -1,40 +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";
4
3
 
5
- import InteropBridgeSyncWithdrawEvents from "./InteropBridge/SyncWithdrawEvents";
6
- import InteropBridgeProcessWithdrawEvents from "./InteropBridge/ProcessWithdrawEvents";
7
- import AutoUpdateTask from "./AutoUpdateTask";
8
4
  import SyncTransactionStatusTask from "./Transactions/SyncTransactionStatusTask";
9
5
 
10
- export class Tasks {
11
-
12
- tasks: BaseTask[] = [
13
- new SyncTransactionStatusTask(),
14
- new AutoUpdateTask(),
6
+ import AutoUpdateTask from "./AutoUpdateTask";
15
7
 
16
- new InteropXGatewaySyncDepositEvents({
17
- chainId: 43114
18
- }),
8
+ import SyncBridgeRequestEvents from "./InteropX/SyncLogSubmitEvents";
9
+ import SyncLogSubmitEvents from "./InteropX/SyncLogSubmitEvents";
19
10
 
20
- new InteropXGatewayProcessDepositEvents({
21
- chainId: 43114
22
- }),
11
+ export class Tasks {
23
12
 
24
- new InteropBridgeSyncWithdrawEvents({
25
- chainId: 137,
26
- itokenAddress: '0xEab02fe1F016eE3e4106c1C6aad35FeEe657268E',
27
- }),
13
+ tasks: BaseTask[] = [
14
+ // new SyncTransactionStatusTask(),
15
+ new AutoUpdateTask(),
28
16
 
29
- new InteropBridgeProcessWithdrawEvents({
30
- chainId: 137,
31
- })
17
+ // InteropX
18
+ new SyncLogSubmitEvents({ chainId: 137 }),
19
+ new SyncLogSubmitEvents({ chainId: 43114 }),
32
20
  ];
33
21
 
34
22
  async start() {
35
23
  for (const task of this.tasks) {
36
24
  try {
37
25
  task.start();
26
+ await wait(1000)
38
27
  } catch (error) {
39
28
  console.error(`Error starting task: ${task.constructor.name}`);
40
29
  }