@instadapp/interop-x 0.0.0-dev.2c0a756 → 0.0.0-dev.3d62ebf

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 (42) 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/config/index.js +1 -10
  5. package/dist/src/constants/addresses.js +1 -1
  6. package/dist/src/constants/itokens.js +1 -1
  7. package/dist/src/index.js +5 -28
  8. package/dist/src/net/protocol/dial/{TransactionStatusDialProtocol.js → SignatureDialProtocol.1.js} +0 -0
  9. package/dist/src/net/protocol/index.js +6 -6
  10. package/dist/src/tasks/AutoUpdateTask.js +6 -11
  11. package/dist/src/tasks/BaseTask.js +0 -4
  12. package/dist/src/tasks/InteropBridge/{SyncBurnEvents.js → SyncWithdrawEvents.js} +8 -10
  13. package/dist/src/tasks/InteropXGateway/ProcessDepositEvents.js +1 -14
  14. package/dist/src/tasks/InteropXGateway/SyncDepositEvents.js +2 -2
  15. package/dist/src/tasks/index.js +5 -17
  16. package/dist/src/typechain/factories/InteropBridgeToken__factory.js +11 -23
  17. package/dist/src/typechain/factories/InteropXGateway__factory.js +14 -14
  18. package/dist/src/utils/index.js +6 -6
  19. package/package.json +2 -2
  20. package/src/abi/interopBridgeToken.json +9 -21
  21. package/src/abi/interopXGateway.json +11 -11
  22. package/src/config/index.ts +1 -9
  23. package/src/constants/addresses.ts +1 -1
  24. package/src/constants/itokens.ts +1 -1
  25. package/src/index.ts +9 -41
  26. package/src/net/protocol/dial/{TransactionStatusDialProtocol.ts → SignatureDialProtocol.1.ts} +0 -0
  27. package/src/net/protocol/index.ts +5 -5
  28. package/src/tasks/AutoUpdateTask.ts +12 -15
  29. package/src/tasks/BaseTask.ts +0 -5
  30. package/src/tasks/InteropBridge/{SyncBurnEvents.ts → SyncWithdrawEvents.ts} +8 -10
  31. package/src/tasks/InteropXGateway/ProcessDepositEvents.ts +4 -18
  32. package/src/tasks/InteropXGateway/SyncDepositEvents.ts +2 -2
  33. package/src/tasks/index.ts +4 -24
  34. package/src/typechain/InteropBridgeToken.ts +17 -23
  35. package/src/typechain/InteropXGateway.ts +13 -13
  36. package/src/typechain/factories/InteropBridgeToken__factory.ts +11 -23
  37. package/src/typechain/factories/InteropXGateway__factory.ts +14 -14
  38. package/src/utils/index.ts +6 -6
  39. package/dist/src/tasks/InteropBridge/SyncMintEvents.js +0 -66
  40. package/dist/src/tasks/InteropXGateway/SyncWithdrawtEvents.js +0 -71
  41. package/src/tasks/InteropBridge/SyncMintEvents.ts +0 -98
  42. package/src/tasks/InteropXGateway/SyncWithdrawtEvents.ts +0 -103
@@ -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;