@instadapp/interop-x 0.0.0-dev.9387bd9 → 0.0.0-dev.9b1fcb8

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 (91) hide show
  1. package/.env.example +2 -1
  2. package/bin/interop-x +1 -1
  3. package/dist/package.json +72 -0
  4. package/dist/src/abi/erc20.json +350 -0
  5. package/dist/src/abi/gnosisSafe.json +747 -0
  6. package/dist/src/abi/index.js +15 -0
  7. package/dist/src/abi/interopBridgeToken.json +286 -0
  8. package/dist/src/abi/interopXGateway.json +184 -0
  9. package/dist/src/api/index.js +33 -0
  10. package/dist/{config → src/config}/index.js +5 -1
  11. package/dist/src/constants/addresses.js +20 -0
  12. package/dist/{constants → src/constants}/index.js +2 -0
  13. package/dist/src/constants/itokens.js +13 -0
  14. package/dist/src/constants/tokens.js +107 -0
  15. package/dist/{db → src/db}/index.js +0 -0
  16. package/dist/{db → src/db}/models/index.js +1 -1
  17. package/dist/src/db/models/transaction.js +54 -0
  18. package/dist/{db → src/db}/sequelize.js +2 -1
  19. package/dist/{index.js → src/index.js} +29 -3
  20. package/dist/{logger → src/logger}/index.js +0 -0
  21. package/dist/{net → src/net}/index.js +0 -0
  22. package/dist/{net → src/net}/peer/index.js +11 -7
  23. package/dist/{net → src/net}/pool/index.js +18 -11
  24. package/dist/{net → src/net}/protocol/dial/BaseDialProtocol.js +1 -1
  25. package/dist/{net → src/net}/protocol/dial/SignatureDialProtocol.js +22 -14
  26. package/dist/{net → src/net}/protocol/index.js +3 -3
  27. package/dist/{tasks → src/tasks}/BaseTask.js +3 -3
  28. package/dist/src/tasks/InteropBridge/SyncWithdrawEvents.js +68 -0
  29. package/dist/src/tasks/InteropXGateway/ProcessDepositEvents.js +147 -0
  30. package/dist/src/tasks/InteropXGateway/SyncDepositEvents.js +75 -0
  31. package/dist/src/tasks/index.js +36 -0
  32. package/dist/src/typechain/Erc20.js +2 -0
  33. package/dist/src/typechain/GnosisSafe.js +2 -0
  34. package/dist/src/typechain/InteropBridgeToken.js +2 -0
  35. package/dist/src/typechain/InteropXGateway.js +2 -0
  36. package/dist/src/typechain/common.js +2 -0
  37. package/dist/src/typechain/factories/Erc20__factory.js +367 -0
  38. package/dist/src/typechain/factories/GnosisSafe__factory.js +1174 -0
  39. package/dist/src/typechain/factories/InteropBridgeToken__factory.js +459 -0
  40. package/dist/src/typechain/factories/InteropXGateway__factory.js +265 -0
  41. package/dist/src/typechain/factories/index.js +14 -0
  42. package/dist/src/typechain/index.js +35 -0
  43. package/dist/{types.js → src/types.js} +0 -0
  44. package/dist/src/utils/index.js +178 -0
  45. package/package.json +19 -6
  46. package/patches/@ethersproject+properties+5.6.0.patch +13 -0
  47. package/src/abi/erc20.json +350 -0
  48. package/src/abi/gnosisSafe.json +747 -0
  49. package/src/abi/index.ts +11 -0
  50. package/src/abi/interopBridgeToken.json +286 -0
  51. package/src/abi/interopXGateway.json +184 -0
  52. package/src/api/index.ts +33 -0
  53. package/src/config/index.ts +7 -1
  54. package/src/constants/addresses.ts +9 -2
  55. package/src/constants/index.ts +2 -0
  56. package/src/constants/itokens.ts +10 -0
  57. package/src/constants/tokens.ts +104 -0
  58. package/src/db/index.ts +1 -1
  59. package/src/db/models/index.ts +1 -1
  60. package/src/db/models/transaction.ts +96 -0
  61. package/src/db/sequelize.ts +2 -1
  62. package/src/index.ts +35 -3
  63. package/src/net/peer/index.ts +10 -9
  64. package/src/net/pool/index.ts +22 -12
  65. package/src/net/protocol/dial/BaseDialProtocol.ts +1 -1
  66. package/src/net/protocol/dial/SignatureDialProtocol.ts +26 -17
  67. package/src/net/protocol/index.ts +3 -3
  68. package/src/tasks/BaseTask.ts +3 -4
  69. package/src/tasks/InteropBridge/SyncWithdrawEvents.ts +119 -0
  70. package/src/tasks/InteropXGateway/ProcessDepositEvents.ts +241 -0
  71. package/src/tasks/InteropXGateway/SyncDepositEvents.ts +126 -0
  72. package/src/tasks/index.ts +15 -1
  73. package/src/typechain/Erc20.ts +491 -0
  74. package/src/typechain/GnosisSafe.ts +1728 -0
  75. package/src/typechain/InteropBridgeToken.ts +686 -0
  76. package/src/typechain/InteropXGateway.ts +407 -0
  77. package/src/typechain/common.ts +44 -0
  78. package/src/typechain/factories/Erc20__factory.ts +368 -0
  79. package/src/typechain/factories/GnosisSafe__factory.ts +1178 -0
  80. package/src/typechain/factories/InteropBridgeToken__factory.ts +466 -0
  81. package/src/typechain/factories/InteropXGateway__factory.ts +272 -0
  82. package/src/typechain/factories/index.ts +7 -0
  83. package/src/typechain/index.ts +12 -0
  84. package/src/types.ts +2 -2
  85. package/src/utils/index.ts +124 -2
  86. package/tsconfig.json +3 -0
  87. package/dist/constants/addresses.js +0 -13
  88. package/dist/db/models/execution.js +0 -38
  89. package/dist/tasks/index.js +0 -19
  90. package/dist/utils/index.js +0 -89
  91. package/src/db/models/execution.ts +0 -57
@@ -0,0 +1,96 @@
1
+ import { sequelize } from '@/db/sequelize'
2
+ import { CreationOptional, InferAttributes, InferCreationAttributes, Model, DataTypes } from 'sequelize';
3
+
4
+ export class Transaction extends Model<InferAttributes<Transaction>, InferCreationAttributes<Transaction>> {
5
+ declare id: CreationOptional<number>;
6
+
7
+ declare transactionHash: string;
8
+ declare action: string;
9
+ declare from: string;
10
+ declare to: string;
11
+
12
+ declare submitTransactionHash: string;
13
+ declare submitBlockNumber: number;
14
+
15
+ declare sourceChainId: number;
16
+ declare sourceTransactionHash: CreationOptional<string>;
17
+ declare sourceBlockNumber: CreationOptional<number>;
18
+ declare sourceStatus: string;
19
+ declare sourceErrors: CreationOptional<string[]>;
20
+ declare sourceCreatedAt: CreationOptional<Date>;
21
+ declare sourceDelayUntil: CreationOptional<Date>;
22
+
23
+ declare targetChainId: number;
24
+ declare targetTransactionHash: CreationOptional<string>;
25
+ declare targetBlockNumber: CreationOptional<number>;
26
+ declare targetStatus: string;
27
+ declare targetErrors: CreationOptional<string[]>;
28
+ declare targetCreatedAt: CreationOptional<Date>;
29
+ declare targetDelayUntil: CreationOptional<Date>;
30
+
31
+ declare submitEvent: any;
32
+ declare sourceEvent: CreationOptional<any>;
33
+ declare targetEvent: CreationOptional<any>;
34
+
35
+ declare metadata: CreationOptional<any>;
36
+
37
+ declare status: string;
38
+
39
+ declare createdAt: CreationOptional<Date>;
40
+ declare updatedAt: CreationOptional<Date>;
41
+ }
42
+
43
+ Transaction.init({
44
+ id: {
45
+ type: DataTypes.INTEGER,
46
+ autoIncrement: true,
47
+ primaryKey: true
48
+ },
49
+
50
+ submitTransactionHash: DataTypes.NUMBER,
51
+ submitBlockNumber: DataTypes.NUMBER,
52
+
53
+ transactionHash: DataTypes.STRING,
54
+ action: DataTypes.STRING,
55
+
56
+ from: DataTypes.STRING,
57
+ to: DataTypes.STRING,
58
+
59
+ sourceChainId: DataTypes.NUMBER,
60
+ sourceTransactionHash: DataTypes.STRING,
61
+ sourceBlockNumber: DataTypes.NUMBER,
62
+ sourceStatus: DataTypes.STRING,
63
+ sourceErrors: {
64
+ type: DataTypes.JSON,
65
+ // defaultValue: [],
66
+ },
67
+ sourceCreatedAt: {
68
+ type: DataTypes.DATE,
69
+ defaultValue: Date.now()
70
+ },
71
+ sourceDelayUntil: DataTypes.STRING,
72
+
73
+ targetChainId: DataTypes.NUMBER,
74
+ targetTransactionHash: DataTypes.STRING,
75
+ targetBlockNumber: DataTypes.NUMBER,
76
+ targetStatus: DataTypes.STRING,
77
+ targetErrors: {
78
+ type: DataTypes.JSON,
79
+ // defaultValue: [],
80
+ },
81
+ targetCreatedAt: DataTypes.DATE,
82
+ targetDelayUntil: DataTypes.DATE,
83
+
84
+ submitEvent: DataTypes.JSON,
85
+ sourceEvent: DataTypes.JSON,
86
+ targetEvent: DataTypes.JSON,
87
+
88
+ metadata: DataTypes.JSON,
89
+
90
+ status: {
91
+ type: DataTypes.STRING,
92
+ defaultValue: 'pending'
93
+ },
94
+ createdAt: DataTypes.DATE,
95
+ updatedAt: DataTypes.DATE,
96
+ }, { sequelize, tableName: 'transactions' });
@@ -1,9 +1,10 @@
1
1
  //@ts-ignore
2
+ import config from "@/config";
2
3
  import expandHomeDir from "expand-home-dir";
3
4
 
4
5
  import { Sequelize } from 'sequelize';
5
6
 
6
- const basePath = expandHomeDir('~/.interop-x/data');
7
+ const basePath = expandHomeDir(`~/.interop-x/data/${config.publicAddress}/${config.staging ? 'staging' : ''}`);
7
8
 
8
9
  export const sequelize = new Sequelize({
9
10
  dialect: 'sqlite',
package/src/index.ts CHANGED
@@ -1,10 +1,38 @@
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
+ })
17
+
18
+ moduleAlias();
1
19
  import assert from "assert";
2
20
  import dotenv from "dotenv";
3
- import Logger from "./logger";
4
21
  import { ethers } from "ethers";
22
+ import packageJson from '../package.json'
5
23
  dotenv.config();
24
+
25
+ import Logger from "@/logger";
6
26
  const logger = new Logger('Process')
7
27
 
28
+
29
+ if (process.argv.at(-1) === 'help') {
30
+ console.log('Usage:')
31
+ console.log(' PRIVATE_KEY=abcd1234 interop-x')
32
+ console.log(' PRIVATE_KEY=abcd1234 STAGING=true interop-x')
33
+ process.exit(0)
34
+ }
35
+
8
36
  assert(process.env.PRIVATE_KEY, "PRIVATE_KEY is not defined");
9
37
 
10
38
  try {
@@ -14,9 +42,11 @@ try {
14
42
  process.exit(1)
15
43
  }
16
44
 
17
- import { Tasks } from "./tasks";
18
- import { startPeer } from "./net";
45
+ logger.debug(`Starting Interop X Node (v${packageJson.version} - rev.@GIT_SHORT_HASH@)`)
19
46
 
47
+ import { Tasks } from "@/tasks";
48
+ import { startPeer } from "@/net";
49
+ import { startApiServer } from '@/api';
20
50
 
21
51
  async function main() {
22
52
 
@@ -25,6 +55,8 @@ async function main() {
25
55
  const tasks = new Tasks()
26
56
 
27
57
  tasks.start();
58
+
59
+ startApiServer()
28
60
  }
29
61
 
30
62
  main()
@@ -5,7 +5,7 @@ import WS from "libp2p-websockets";
5
5
  //@ts-ignore
6
6
  import Mplex from "libp2p-mplex";
7
7
  import { NOISE } from "libp2p-noise";
8
- import Logger from "../../logger";
8
+ import Logger from "@/logger";
9
9
  import Bootstrap from "libp2p-bootstrap";
10
10
  import wait from "waait";
11
11
  import Gossipsub from "@achingbrain/libp2p-gossipsub";
@@ -15,8 +15,8 @@ import MulticastDNS from "libp2p-mdns";
15
15
  import KadDHT from "libp2p-kad-dht";
16
16
  //@ts-ignore
17
17
  import PubsubPeerDiscovery from "libp2p-pubsub-peer-discovery";
18
- import { protocol } from "../protocol";
19
- import config from "../../config";
18
+ import { protocol } from "@/net";
19
+ import config from "@/config";
20
20
 
21
21
  const logger = new Logger("Peer");
22
22
 
@@ -88,12 +88,13 @@ export const startPeer = async ({ }: IPeerOptions) => {
88
88
  libp2p: node
89
89
  })
90
90
 
91
- node.on("peer:discovery", (peer) =>
92
- logger.log(`Discovered peer ${peer}`)
93
- ); // peer disc.
94
- node.connectionManager.on("peer:connect", (connection) =>
95
- logger.log(`Connected to ${connection.remotePeer.toB58String()}`)
96
- );
91
+ node.on("peer:discovery", (peer) => {
92
+ // logger.log(`Discovered peer ${peer}`)
93
+ }); // peer disc.
94
+
95
+ node.connectionManager.on("peer:connect", (connection) => {
96
+ // logger.log(`Connected to ${connection.remotePeer.toB58String()}`)
97
+ });
97
98
 
98
99
  logger.log("Peer discovery started");
99
100
 
@@ -1,5 +1,9 @@
1
- import { Event } from "../../types";
2
- import config from "../../config";
1
+ import { Event } from "@/types";
2
+ import config from "@/config";
3
+ import Logger from "@/logger";
4
+
5
+
6
+ const logger = new Logger('PeerPool')
3
7
 
4
8
  export interface IPeerInfo {
5
9
  id: string;
@@ -75,10 +79,15 @@ export class PeerPool {
75
79
  * @emits {@link Event.POOL_PEER_ADDED}
76
80
  */
77
81
  add(peer?: IPeerInfo) {
78
- if (peer && peer.id && !this.pool.get(peer.id)) {
82
+ if (peer && peer.id) {
83
+ const newPeer = !this.pool.get(peer.id);
79
84
  this.pool.set(peer.id, peer)
80
85
  peer.pooled = true
81
- config.events.emit(Event.POOL_PEER_ADDED, peer)
86
+
87
+ if(newPeer) {
88
+ config.events.emit(Event.POOL_PEER_ADDED, peer)
89
+ logger.info(`Peer ${peer.id} with address ${peer.publicAddress} added to pool`)
90
+ }
82
91
  }
83
92
  }
84
93
 
@@ -92,6 +101,7 @@ export class PeerPool {
92
101
  if (this.pool.delete(peer.id)) {
93
102
  peer.pooled = false
94
103
  config.events.emit(Event.POOL_PEER_REMOVED, peer)
104
+ logger.info(`Peer ${peer.id} with address ${peer.publicAddress} removed from pool`)
95
105
  }
96
106
  }
97
107
  }
@@ -114,14 +124,14 @@ export class PeerPool {
114
124
 
115
125
 
116
126
  cleanup() {
117
- let compDate = Date.now() - this.PEERS_CLEANUP_TIME_LIMIT * 60
118
-
119
- this.peers.forEach((peerInfo) => {
120
- if (peerInfo.updated.getTime() < compDate) {
121
- console.log(`Peer ${peerInfo.id} idle for ${this.PEERS_CLEANUP_TIME_LIMIT} minutes`)
122
- this.remove(peerInfo)
123
- }
124
- })
127
+ // let compDate = Date.now() - this.PEERS_CLEANUP_TIME_LIMIT * 60
128
+
129
+ // this.peers.forEach((peerInfo) => {
130
+ // if (peerInfo.updated.getTime() < compDate) {
131
+ // console.log(`Peer ${peerInfo.id} idle for ${this.PEERS_CLEANUP_TIME_LIMIT} minutes`)
132
+ // this.remove(peerInfo)
133
+ // }
134
+ // })
125
135
  }
126
136
  }
127
137
 
@@ -1,7 +1,7 @@
1
1
  import pipe from 'it-pipe';
2
2
  import Libp2p from 'libp2p';
3
3
  import PeerId from 'peer-id';
4
- import { asyncCallWithTimeout } from '../../../utils';
4
+ import { asyncCallWithTimeout } from '@/utils';
5
5
  import wait from 'waait';
6
6
 
7
7
  export class BaseDialProtocol<TRequest extends any, TResponse extends any> {
@@ -1,14 +1,14 @@
1
- import { signGnosisSafeTx } from "../../../utils";
2
1
  import { BaseDialProtocol } from "./BaseDialProtocol";
3
2
  import wait from "waait";
4
- import { ChainId } from "../../../types";
5
- import config from "../../../config";
6
- import { addresses } from "../../../constants";
7
- import { Execution } from "db";
3
+ import config from "@/config";
4
+ import { Transaction } from "@/db";
5
+ import { buildDataForTransaction, signGnosisSafeTx } from "@/utils";
6
+ import { addresses } from "@/constants";
7
+ import { ChainId } from "@/types";
8
8
 
9
9
  export interface ISignatureRequest {
10
- type: string,
11
- vnonce: string
10
+ type: 'source' | 'target' ,
11
+ transactionHash: string
12
12
  safeTxGas: string
13
13
  safeNonce: string
14
14
  }
@@ -21,25 +21,25 @@ export class SignatureDialProtocol extends BaseDialProtocol<ISignatureRequest, I
21
21
  protected timeout = 30000;
22
22
 
23
23
  constructor(libp2p) {
24
- super(libp2p, '/signatures')
24
+ super(libp2p, '/interop-x/signatures')
25
25
  }
26
26
 
27
27
  async response(data: ISignatureRequest): Promise<ISignatureResponse> {
28
28
  const signer = config.wallet;
29
29
 
30
- let event: Execution | null;
30
+ let transaction: Transaction | null;
31
31
  let maxTimeout = 20000;
32
32
 
33
33
  do {
34
- event = await Execution.findOne({ where: { vnonce: data.vnonce.toString() } })
34
+ transaction = await Transaction.findOne({ where: { transactionHash: data.transactionHash } })
35
35
 
36
- if (!event) {
36
+ if (!transaction) {
37
37
  await wait(1000);
38
38
  maxTimeout -= 1000;
39
39
  }
40
- } while (!event && maxTimeout > 0)
40
+ } while (!transaction && maxTimeout > 0)
41
41
 
42
- if (!event) {
42
+ if (!transaction) {
43
43
  return {
44
44
  signer: signer.address,
45
45
  data: null,
@@ -47,16 +47,25 @@ export class SignatureDialProtocol extends BaseDialProtocol<ISignatureRequest, I
47
47
  };
48
48
  }
49
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
+ });
57
+
50
58
  const signedData = await signGnosisSafeTx({
51
- to: addresses[event.chainId as ChainId].multisend,
52
- data: 'TODO',
53
- chainId: event.chainId as ChainId,
59
+ to: addresses[transaction.targetChainId].multisend,
60
+ data: await buildDataForTransaction(transaction, data.type),
61
+ chainId: transaction.targetChainId as ChainId,
54
62
  safeTxGas: data.safeTxGas,
63
+ nonce: data.safeNonce,
55
64
  }, { signer });
56
65
 
57
66
  return {
58
67
  signer: signer.address,
59
- data: signedData,
68
+ data: signedData
60
69
  }
61
70
  }
62
71
  }
@@ -3,8 +3,8 @@ import Libp2p from 'libp2p';
3
3
  import { bufferToInt, rlp } from 'ethereumjs-util'
4
4
  import { SignatureDialProtocol, ISignatureRequest, ISignatureResponse } from "./dial/SignatureDialProtocol";
5
5
  import { IPeerInfo, peerPool } from "..";
6
- import config from "config";
7
- import { Event } from "types";
6
+ import config from "@/config";
7
+ import { Event } from "@/types";
8
8
 
9
9
  export interface ProtocolOptions {
10
10
  /* Handshake timeout in ms (default: 8000) */
@@ -58,7 +58,7 @@ class Protocol extends EventEmitter {
58
58
 
59
59
  start({ libp2p, topic = null, }) {
60
60
  this.libp2p = libp2p
61
- this.topic = topic || 'protocol'
61
+ this.topic = topic || 'itnerop-x-protocol'
62
62
 
63
63
  if (this.libp2p.isStarted()) this.init()
64
64
 
@@ -1,8 +1,7 @@
1
- import config from "config";
2
- import { ethers } from "ethers";
1
+ import config from "@/config";
3
2
  import EventEmitter from "events";
4
3
  import wait from "waait";
5
- import Logger from "../logger";
4
+ import Logger from "@/logger";
6
5
 
7
6
  export interface IBaseTask {
8
7
  pollCheck(): Promise<void>
@@ -38,7 +37,7 @@ export class BaseTask extends EventEmitter implements IBaseTask {
38
37
  await this.pollHandler()
39
38
  }
40
39
  } catch (err) {
41
- this.logger.error(`poll check error: ${err.message}\ntrace: ${err.stack}`)
40
+ this.logger.error(`poll check error:\n${err.message}\ntrace: ${err.stack}`)
42
41
  }
43
42
 
44
43
  await this.postPollHandler()
@@ -0,0 +1,119 @@
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 { ChainId } from "@/types";
8
+ import config from "@/config";
9
+ import { InteropBridgeToken } from "@/typechain";
10
+
11
+ class SyncWithdrawEvents extends BaseTask {
12
+ contractAddress: string;
13
+ provider: ethers.providers.JsonRpcProvider;
14
+ contract: InteropBridgeToken;
15
+ chainId: ChainId;
16
+ itokenAddress: string;
17
+
18
+ constructor({ chainId, itokenAddress }: { chainId: ChainId, itokenAddress: string }) {
19
+ super({
20
+ logger: new Logger("InteropBridgeToken::SyncWithdrawEvents"),
21
+ })
22
+ this.chainId = chainId;
23
+ this.itokenAddress = itokenAddress;
24
+ }
25
+
26
+ async pollHandler() {
27
+ const currentBlock = await this.provider.getBlockNumber();
28
+
29
+ const events = await this.contract.queryFilter(
30
+ this.contract.filters.Burn(),
31
+ currentBlock - 2000,
32
+ currentBlock,
33
+ );
34
+
35
+ let processedEvents = 0;
36
+
37
+ for (const event of events) {
38
+
39
+ try {
40
+ if (!event.args) {
41
+ continue;
42
+ }
43
+
44
+ const { to, amount, chainId } = event.args;
45
+
46
+ const uniqueIdentifier = {
47
+ action: 'withdraw',
48
+ submitTransactionHash: event.transactionHash,
49
+ sourceChainId:this.chainId,
50
+ targetChainId: chainId.toNumber(),
51
+ }
52
+
53
+ if (await Transaction.findOne({ where: uniqueIdentifier })) {
54
+ continue;
55
+ }
56
+
57
+ const tx = await event.getTransaction()
58
+
59
+ await Transaction.create({
60
+ ...uniqueIdentifier,
61
+ transactionHash: generateInteropTransactionHash(uniqueIdentifier),
62
+ from: tx.from,
63
+ to,
64
+
65
+
66
+ submitTransactionHash: event.transactionHash,
67
+ submitBlockNumber: event.blockNumber,
68
+
69
+ // submit & source are the same
70
+ sourceTransactionHash: event.transactionHash,
71
+ sourceBlockNumber: event.blockNumber,
72
+ sourceStatus: "success",
73
+
74
+ targetStatus: "uninitialised",
75
+
76
+ submitEvent: {
77
+ to,
78
+ amount: amount.toString(),
79
+ chainId: chainId.toString()
80
+ },
81
+
82
+ sourceEvent: {
83
+ to,
84
+ amount: amount.toString(),
85
+ chainId: chainId.toString(),
86
+ },
87
+ status: "pending",
88
+ })
89
+
90
+ this.logger.info(
91
+ `Withdraw queued: ${event.transactionHash} ${event.blockNumber}`
92
+ );
93
+ } catch (error) {
94
+ this.logger.error(error);
95
+ }
96
+ }
97
+
98
+ if (processedEvents > 0)
99
+ this.logger.info(`${processedEvents} events processed`);
100
+ }
101
+
102
+ async start(): Promise<void> {
103
+ this.logger.info(`Starting execution watcher on interop chain`);
104
+
105
+ this.provider = new ethers.providers.JsonRpcProvider(
106
+ getRpcProviderUrl(this.chainId)
107
+ );
108
+
109
+ this.contract = getContract<InteropBridgeToken>(
110
+ this.itokenAddress,
111
+ abi.interopBridgeToken,
112
+ new ethers.Wallet(config.privateKey!, this.provider)
113
+ );
114
+
115
+ await super.start()
116
+ }
117
+ }
118
+
119
+ export default SyncWithdrawEvents;