@instadapp/interop-x 0.0.0-dev.2c0a756 → 0.0.0-dev.30b0db0

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 (48) hide show
  1. package/dist/package.json +2 -2
  2. package/dist/src/abi/interopBridgeToken.json +9 -21
  3. package/dist/src/abi/interopXGateway.json +11 -11
  4. package/dist/src/api/index.js +1 -1
  5. package/dist/src/config/index.js +1 -10
  6. package/dist/src/constants/addresses.js +1 -1
  7. package/dist/src/constants/itokens.js +1 -1
  8. package/dist/src/index.js +5 -28
  9. package/dist/src/net/peer/index.js +1 -2
  10. package/dist/src/net/pool/index.js +2 -3
  11. package/dist/src/net/protocol/dial/{TransactionStatusDialProtocol.js → SignatureDialProtocol.1.js} +0 -0
  12. package/dist/src/net/protocol/index.js +6 -6
  13. package/dist/src/tasks/AutoUpdateTask.js +11 -33
  14. package/dist/src/tasks/BaseTask.js +0 -4
  15. package/dist/src/tasks/InteropBridge/{SyncBurnEvents.js → SyncWithdrawEvents.js} +8 -10
  16. package/dist/src/tasks/InteropXGateway/ProcessDepositEvents.js +1 -14
  17. package/dist/src/tasks/InteropXGateway/SyncDepositEvents.js +2 -2
  18. package/dist/src/tasks/index.js +5 -17
  19. package/dist/src/typechain/factories/InteropBridgeToken__factory.js +11 -23
  20. package/dist/src/typechain/factories/InteropXGateway__factory.js +14 -14
  21. package/dist/src/utils/index.js +7 -7
  22. package/package.json +2 -2
  23. package/src/abi/interopBridgeToken.json +9 -21
  24. package/src/abi/interopXGateway.json +11 -11
  25. package/src/api/index.ts +1 -1
  26. package/src/config/index.ts +1 -9
  27. package/src/constants/addresses.ts +1 -1
  28. package/src/constants/itokens.ts +1 -1
  29. package/src/index.ts +9 -41
  30. package/src/net/peer/index.ts +1 -2
  31. package/src/net/pool/index.ts +2 -3
  32. package/src/net/protocol/dial/{TransactionStatusDialProtocol.ts → SignatureDialProtocol.1.ts} +0 -0
  33. package/src/net/protocol/index.ts +5 -5
  34. package/src/tasks/AutoUpdateTask.ts +14 -36
  35. package/src/tasks/BaseTask.ts +0 -5
  36. package/src/tasks/InteropBridge/{SyncBurnEvents.ts → SyncWithdrawEvents.ts} +8 -10
  37. package/src/tasks/InteropXGateway/ProcessDepositEvents.ts +4 -18
  38. package/src/tasks/InteropXGateway/SyncDepositEvents.ts +2 -2
  39. package/src/tasks/index.ts +4 -24
  40. package/src/typechain/InteropBridgeToken.ts +17 -23
  41. package/src/typechain/InteropXGateway.ts +13 -13
  42. package/src/typechain/factories/InteropBridgeToken__factory.ts +11 -23
  43. package/src/typechain/factories/InteropXGateway__factory.ts +14 -14
  44. package/src/utils/index.ts +7 -7
  45. package/dist/src/tasks/InteropBridge/SyncMintEvents.js +0 -66
  46. package/dist/src/tasks/InteropXGateway/SyncWithdrawtEvents.js +0 -71
  47. package/src/tasks/InteropBridge/SyncMintEvents.ts +0 -98
  48. package/src/tasks/InteropXGateway/SyncWithdrawtEvents.ts +0 -103
@@ -1,71 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- const BaseTask_1 = require("../BaseTask");
7
- const logger_1 = __importDefault(require("@/logger"));
8
- const ethers_1 = require("ethers");
9
- const abi_1 = __importDefault(require("@/abi"));
10
- const db_1 = require("@/db");
11
- const utils_1 = require("@/utils");
12
- const constants_1 = require("@/constants");
13
- const config_1 = __importDefault(require("@/config"));
14
- class SyncWithdrawEvents extends BaseTask_1.BaseTask {
15
- constructor({ chainId }) {
16
- super({
17
- logger: new logger_1.default("InteropXGateway::SyncWithdrawEvents"),
18
- });
19
- this.chainId = chainId;
20
- }
21
- async pollHandler() {
22
- const currentBlock = await this.provider.getBlockNumber();
23
- const events = await this.contract.queryFilter(this.contract.filters.LogGatewayWithdraw(), currentBlock - 300, currentBlock);
24
- let processedEvents = 0;
25
- for (const event of events) {
26
- try {
27
- if (!event.args) {
28
- continue;
29
- }
30
- const { user, token, amount, sourceChainId, targetChainId, transactionHash } = event.args;
31
- const uniqueIdentifier = {
32
- action: 'withdraw',
33
- submitTransactionHash: transactionHash,
34
- sourceChainId: sourceChainId,
35
- targetChainId: targetChainId,
36
- };
37
- const transaction = await db_1.Transaction.findOne({ where: uniqueIdentifier });
38
- if (!transaction) {
39
- return;
40
- }
41
- const tx = await event.getTransaction();
42
- transaction.targetStatus = 'success';
43
- transaction.targetErrors = [];
44
- transaction.targetTransactionHash = tx.hash;
45
- transaction.targetEvent = {
46
- user,
47
- token,
48
- amount: amount.toString(),
49
- sourceChainId,
50
- targetChainId,
51
- transactionHash,
52
- };
53
- transaction.status = 'success';
54
- await transaction.save();
55
- this.logger.info(`Witdraw confirmation received: ${transaction.transactionHash} `);
56
- }
57
- catch (error) {
58
- this.logger.error(error);
59
- }
60
- }
61
- if (processedEvents > 0)
62
- this.logger.info(`${processedEvents} events processed`);
63
- }
64
- async start() {
65
- this.contractAddress = constants_1.addresses[this.chainId].interopXGateway;
66
- this.provider = new ethers_1.ethers.providers.JsonRpcProvider((0, utils_1.getRpcProviderUrl)(this.chainId));
67
- this.contract = (0, utils_1.getContract)(this.contractAddress, abi_1.default.interopXGateway, new ethers_1.ethers.Wallet(config_1.default.privateKey, this.provider));
68
- await super.start();
69
- }
70
- }
71
- exports.default = SyncWithdrawEvents;
@@ -1,98 +0,0 @@
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 { getContract, getRpcProviderUrl } from "@/utils";
7
- import { ChainId } from "@/types";
8
- import config from "@/config";
9
- import { InteropBridgeToken } from "@/typechain";
10
-
11
- class SyncMintEvents 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::SyncMintEvents"),
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.Mint(),
31
- currentBlock - 300,
32
- currentBlock,
33
- );
34
-
35
-
36
- for (const event of events) {
37
-
38
- try {
39
- if (!event.args) {
40
- continue;
41
- }
42
-
43
- const { sourceChainId, targetChainId, amount, to, submitTransactionHash } = event.args;
44
-
45
- const uniqueIdentifier = {
46
- action: 'deposit',
47
- submitTransactionHash: submitTransactionHash,
48
- sourceChainId: sourceChainId,
49
- targetChainId: targetChainId,
50
- }
51
-
52
- const transaction = await Transaction.findOne({ where: uniqueIdentifier });
53
-
54
- if(! transaction){
55
- return;
56
- }
57
-
58
- const tx = await event.getTransaction()
59
-
60
- transaction.targetStatus = 'success'
61
- transaction.targetErrors = []
62
- transaction.targetTransactionHash = tx.hash
63
- transaction.targetEvent = {
64
- sourceChainId,
65
- targetChainId,
66
- amount: amount.toString(),
67
- to,
68
- submitTransactionHash
69
- }
70
- transaction.status = 'success'
71
-
72
- await transaction.save()
73
-
74
- this.logger.info(
75
- `Mint confirmation received: ${transaction.transactionHash} `
76
- );
77
- } catch (error) {
78
- this.logger.error(error);
79
- }
80
- }
81
- }
82
-
83
- async start(): Promise<void> {
84
- this.provider = new ethers.providers.JsonRpcProvider(
85
- getRpcProviderUrl(this.chainId)
86
- );
87
-
88
- this.contract = getContract<InteropBridgeToken>(
89
- this.itokenAddress,
90
- abi.interopBridgeToken,
91
- new ethers.Wallet(config.privateKey!, this.provider)
92
- );
93
-
94
- await super.start()
95
- }
96
- }
97
-
98
- export default SyncMintEvents;
@@ -1,103 +0,0 @@
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 { getContract, getRpcProviderUrl } from "@/utils";
7
- import { addresses } from "@/constants";
8
- import { ChainId } from "@/types";
9
- import config from "@/config";
10
- import { InteropXGateway } from "@/typechain";
11
-
12
- class SyncWithdrawEvents extends BaseTask {
13
- contractAddress: string;
14
- provider: ethers.providers.JsonRpcProvider;
15
- contract: InteropXGateway;
16
- chainId: ChainId;
17
-
18
- constructor({ chainId }: { chainId: ChainId }) {
19
- super({
20
- logger: new Logger("InteropXGateway::SyncWithdrawEvents"),
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.LogGatewayWithdraw(),
30
- currentBlock - 300,
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 { user, token, amount, sourceChainId, targetChainId, transactionHash } = event.args;
44
-
45
- const uniqueIdentifier = {
46
- action: 'withdraw',
47
- submitTransactionHash: transactionHash,
48
- sourceChainId: sourceChainId,
49
- targetChainId: targetChainId,
50
- }
51
- const transaction = await Transaction.findOne({ where: uniqueIdentifier });
52
-
53
- if (!transaction) {
54
- return;
55
- }
56
-
57
- const tx = await event.getTransaction()
58
-
59
- transaction.targetStatus = 'success'
60
- transaction.targetErrors = []
61
- transaction.targetTransactionHash = tx.hash
62
- transaction.targetEvent = {
63
- user,
64
- token,
65
- amount: amount.toString(),
66
- sourceChainId,
67
- targetChainId,
68
- transactionHash,
69
- }
70
- transaction.status = 'success'
71
-
72
- await transaction.save()
73
-
74
- this.logger.info(
75
- `Witdraw confirmation received: ${transaction.transactionHash} `
76
- );
77
- } catch (error) {
78
- this.logger.error(error);
79
- }
80
- }
81
-
82
- if (processedEvents > 0)
83
- this.logger.info(`${processedEvents} events processed`);
84
- }
85
-
86
- async start(): Promise<void> {
87
- this.contractAddress = addresses[this.chainId].interopXGateway;
88
-
89
- this.provider = new ethers.providers.JsonRpcProvider(
90
- getRpcProviderUrl(this.chainId)
91
- );
92
-
93
- this.contract = getContract<InteropXGateway>(
94
- this.contractAddress,
95
- abi.interopXGateway,
96
- new ethers.Wallet(config.privateKey!, this.provider)
97
- );
98
-
99
- await super.start()
100
- }
101
- }
102
-
103
- export default SyncWithdrawEvents;