@instadapp/interop-x 0.0.0-dev.73e5298 → 0.0.0-dev.7738003

Sign up to get free protection for your applications and to get access to all the features.
Files changed (43) hide show
  1. package/.github/workflows/ci.yml +19 -0
  2. package/dist/package.json +1 -1
  3. package/dist/src/abi/index.js +2 -2
  4. package/dist/src/abi/interopX.json +1436 -0
  5. package/dist/src/api/index.js +1 -1
  6. package/dist/src/constants/addresses.js +2 -7
  7. package/dist/src/db/models/transaction.js +11 -9
  8. package/dist/src/gnosis/actions/withdraw/index.js +106 -107
  9. package/dist/src/index.js +1 -1
  10. package/dist/src/tasks/{InteropXContract/SyncBridgeRequestEvents.js → InteropX/SyncLogSubmitEvents.js} +18 -12
  11. package/dist/src/tasks/Transactions/SyncTransactionStatusTask.js +3 -3
  12. package/dist/src/tasks/index.js +4 -13
  13. package/dist/src/typechain/{InteropXContract.js → InteropX.js} +0 -0
  14. package/dist/src/typechain/factories/InteropX__factory.js +1928 -0
  15. package/dist/src/typechain/factories/index.js +3 -3
  16. package/dist/src/typechain/index.js +3 -3
  17. package/dist/src/utils/index.js +5 -3
  18. package/package.json +1 -1
  19. package/src/abi/index.ts +2 -2
  20. package/src/abi/interopX.json +1436 -0
  21. package/src/api/index.ts +1 -1
  22. package/src/constants/addresses.ts +3 -8
  23. package/src/db/models/transaction.ts +28 -37
  24. package/src/gnosis/actions/withdraw/index.ts +131 -131
  25. package/src/tasks/{InteropXContract/SyncBridgeRequestEvents.ts → InteropX/SyncLogSubmitEvents.ts} +37 -16
  26. package/src/tasks/Transactions/SyncTransactionStatusTask.ts +3 -3
  27. package/src/tasks/index.ts +5 -17
  28. package/src/typechain/InteropX.ts +1216 -0
  29. package/src/typechain/factories/InteropX__factory.ts +1932 -0
  30. package/src/typechain/factories/index.ts +1 -1
  31. package/src/typechain/index.ts +2 -2
  32. package/src/utils/index.ts +22 -8
  33. package/dist/src/abi/interopXContract.json +0 -454
  34. package/dist/src/tasks/InteropXContract/ProcessBridgeRequestEvents.js +0 -158
  35. package/dist/src/tasks/InteropXContract/SyncBridgeCommittedEvents.js +0 -93
  36. package/dist/src/tasks/InteropXContract/SyncBridgeRequestSentEvents.js +0 -90
  37. package/dist/src/typechain/factories/InteropXContract__factory.js +0 -635
  38. package/src/abi/interopXContract.json +0 -454
  39. package/src/tasks/InteropXContract/ProcessBridgeRequestEvents.ts +0 -226
  40. package/src/tasks/InteropXContract/SyncBridgeCommittedEvents.ts +0 -125
  41. package/src/tasks/InteropXContract/SyncBridgeRequestSentEvents.ts +0 -121
  42. package/src/typechain/InteropXContract.ts +0 -680
  43. package/src/typechain/factories/InteropXContract__factory.ts +0 -642
@@ -1,125 +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 { generateInteropTransactionHash, getContract, getRpcProviderUrl } from "@/utils";
7
- import { addresses } from "@/constants";
8
- import { ChainId } from "@/types";
9
- import config from "@/config";
10
- import { InteropXContract } from "@/typechain";
11
- import { Op } from "sequelize";
12
-
13
- class SyncBridgeCommittedEvents extends BaseTask {
14
- contractAddress: string;
15
- provider: ethers.providers.JsonRpcProvider;
16
- contract: InteropXContract;
17
- chainId: ChainId;
18
-
19
- constructor({ chainId }: { chainId: ChainId }) {
20
- super({
21
- logger: new Logger("InteropXContract::SyncBridgeCommittedEvents"),
22
- })
23
- this.chainId = chainId;
24
- }
25
-
26
- async pollHandler() {
27
- const currentBlock = await this.provider.getBlockNumber();
28
-
29
- const events = await this.contract.queryFilter(
30
- this.contract.filters.LogBridgeCommitted(),
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 { actionId, bridger, position, sourceChainId, targetChainId, requestTransactionHash, metadata } = event.args;
45
-
46
- const uniqueIdentifier = {
47
- actionId,
48
- bridger,
49
- requestTransactionHash,
50
- sourceChainId: sourceChainId,
51
- targetChainId: targetChainId,
52
- }
53
-
54
- let transactionHash = generateInteropTransactionHash(uniqueIdentifier);
55
-
56
- const transaction = await Transaction.findOne({
57
- where: {
58
- transactionHash,
59
- sourceStatus: 'success',
60
- committedEvent: {
61
- [Op.eq]: null,
62
- }
63
- }
64
- });
65
-
66
- if (!transaction) {
67
- continue;
68
- }
69
- transaction.targetStatus = 'success'
70
- transaction.targetBlockNumber = event.blockNumber;
71
- transaction.targetTransactionHash = event.transactionHash
72
- transaction.committedEvent = {
73
- actionId,
74
- bridger,
75
- position: {
76
- withdraw: position.withdraw.map((v) => ({
77
- sourceToken: v.sourceToken,
78
- targetToken: v.targetToken,
79
- amount: v.amount.toString()
80
- })),
81
- supply: position.supply.map((v) => ({
82
- sourceToken: v.sourceToken,
83
- targetToken: v.targetToken,
84
- amount: v.amount.toString()
85
- })),
86
- },
87
- sourceChainId: sourceChainId,
88
- targetChainId: targetChainId,
89
- metadata,
90
- requestTransactionHash,
91
- }
92
-
93
- transaction.status = 'success';
94
- await transaction.save()
95
-
96
- this.logger.info(
97
- `New bridge committed received: ${transactionHash} `
98
- );
99
- } catch (error) {
100
- this.logger.error(error);
101
- }
102
- }
103
-
104
- if (processedEvents > 0)
105
- this.logger.info(`${processedEvents} events processed`);
106
- }
107
-
108
- async start(): Promise<void> {
109
- this.contractAddress = addresses[this.chainId].interopXContract;
110
-
111
- this.provider = new ethers.providers.JsonRpcProvider(
112
- getRpcProviderUrl(this.chainId)
113
- );
114
-
115
- this.contract = getContract<InteropXContract>(
116
- this.contractAddress,
117
- abi.interopXContract,
118
- new ethers.Wallet(config.privateKey!, this.provider)
119
- );
120
-
121
- await super.start()
122
- }
123
- }
124
-
125
- export default SyncBridgeCommittedEvents;
@@ -1,121 +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 { generateInteropTransactionHash, getContract, getRpcProviderUrl } from "@/utils";
7
- import { addresses } from "@/constants";
8
- import { ChainId } from "@/types";
9
- import config from "@/config";
10
- import { InteropXContract } from "@/typechain";
11
- import { Op } from "sequelize";
12
-
13
- class SyncBridgeRequestSentEvents extends BaseTask {
14
- contractAddress: string;
15
- provider: ethers.providers.JsonRpcProvider;
16
- contract: InteropXContract;
17
- chainId: ChainId;
18
-
19
- constructor({ chainId }: { chainId: ChainId }) {
20
- super({
21
- logger: new Logger("InteropXContract::SyncBridgeRequestSentEvents"),
22
- })
23
- this.chainId = chainId;
24
- }
25
-
26
- async pollHandler() {
27
- const currentBlock = await this.provider.getBlockNumber();
28
-
29
- const events = await this.contract.queryFilter(
30
- this.contract.filters.LogBridgeRequestSent(),
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 { actionId, bridger, position, sourceChainId, targetChainId, requestTransactionHash, metadata } = event.args;
45
-
46
- const uniqueIdentifier = {
47
- actionId,
48
- bridger,
49
- requestTransactionHash,
50
- sourceChainId: sourceChainId,
51
- targetChainId: targetChainId,
52
- }
53
-
54
- let transactionHash = generateInteropTransactionHash(uniqueIdentifier);
55
-
56
- const transaction = await Transaction.findOne({
57
- where: {
58
- transactionHash, requestSentEvent: {
59
- [Op.eq]: null,
60
- }
61
- }
62
- });
63
-
64
- if (!transaction) {
65
- continue;
66
- }
67
- transaction.sourceStatus = 'success'
68
- transaction.sourceBlockNumber = event.blockNumber;
69
- transaction.sourceTransactionHash = event.transactionHash
70
- transaction.requestSentEvent = {
71
- actionId,
72
- bridger,
73
- position: {
74
- withdraw: position.withdraw.map((v) => ({
75
- sourceToken: v.sourceToken,
76
- targetToken: v.targetToken,
77
- amount: v.amount.toString()
78
- })),
79
- supply: position.supply.map((v) => ({
80
- sourceToken: v.sourceToken,
81
- targetToken: v.targetToken,
82
- amount: v.amount.toString()
83
- })),
84
- },
85
- sourceChainId: sourceChainId,
86
- targetChainId: targetChainId,
87
- metadata,
88
- requestTransactionHash,
89
- }
90
- await transaction.save()
91
-
92
- this.logger.info(
93
- `New bridge request sent received: ${transactionHash} `
94
- );
95
- } catch (error) {
96
- this.logger.error(error);
97
- }
98
- }
99
-
100
- if (processedEvents > 0)
101
- this.logger.info(`${processedEvents} events processed`);
102
- }
103
-
104
- async start(): Promise<void> {
105
- this.contractAddress = addresses[this.chainId].interopXContract;
106
-
107
- this.provider = new ethers.providers.JsonRpcProvider(
108
- getRpcProviderUrl(this.chainId)
109
- );
110
-
111
- this.contract = getContract<InteropXContract>(
112
- this.contractAddress,
113
- abi.interopXContract,
114
- new ethers.Wallet(config.privateKey!, this.provider)
115
- );
116
-
117
- await super.start()
118
- }
119
- }
120
-
121
- export default SyncBridgeRequestSentEvents;