@instadapp/interop-x 0.0.0-dev.20e87fa → 0.0.0-dev.2187d72
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.
- package/dist/package.json +8 -1
- package/dist/src/abi/aaveV2Resolver.json +832 -0
- package/dist/src/abi/balanceResolver.json +211 -0
- package/dist/src/abi/index.js +4 -0
- package/dist/src/api/index.js +7 -0
- package/dist/src/constants/addresses.js +5 -1
- package/dist/src/constants/capPerChain.js +8 -0
- package/dist/src/constants/index.js +2 -0
- package/dist/src/constants/tokens.js +44 -44
- package/dist/src/constants/wrappedNativeToken.js +8 -0
- package/dist/src/crons/index.js +3 -0
- package/dist/src/crons/prices.js +16 -0
- package/dist/src/db/models/transaction.js +4 -0
- package/dist/src/errors/index.js +30 -0
- package/dist/src/gnosis/actions/aaveV2/source.js +2 -1
- package/dist/src/gnosis/actions/aaveV2/target.js +3 -2
- package/dist/src/index.js +2 -1
- package/dist/src/providers/index.js +17 -0
- package/dist/src/providers/retry-provider.js +45 -0
- package/dist/src/services/Prices.js +74 -0
- package/dist/src/services/index.js +8 -0
- package/dist/src/tasks/InteropX/{ProcessSubmitSubmitEvents.js → ProcessSubmitEvents.js} +95 -8
- package/dist/src/tasks/InteropX/ProcessValidateEvents.js +27 -4
- package/dist/src/tasks/InteropX/SyncLogExecuteEvents.js +113 -0
- package/dist/src/tasks/InteropX/SyncLogSubmitEvents.js +2 -1
- package/dist/src/tasks/InteropX/SyncLogValidateEvents.js +5 -4
- package/dist/src/tasks/index.js +7 -5
- package/dist/src/typechain/AaveV2Resolver.js +2 -0
- package/dist/src/typechain/BalanceResolver.js +2 -0
- package/dist/src/typechain/factories/AaveV2Resolver__factory.js +1191 -0
- package/dist/src/typechain/factories/BalanceResolver__factory.js +228 -0
- package/dist/src/typechain/factories/index.js +5 -1
- package/dist/src/typechain/index.js +5 -1
- package/dist/src/utils/async.js +18 -0
- package/dist/src/utils/dsa.js +24 -0
- package/dist/src/utils/formatting.js +67 -0
- package/dist/src/utils/gnosis.js +77 -0
- package/dist/src/utils/http.js +10 -0
- package/dist/src/utils/index.js +22 -220
- package/dist/src/utils/interop.js +16 -0
- package/dist/src/utils/tokens.js +22 -0
- package/dist/src/utils/validate.js +111 -0
- package/dist/src/utils/web3.js +93 -0
- package/package.json +8 -1
- package/src/abi/aaveV2Resolver.json +832 -0
- package/src/abi/balanceResolver.json +211 -0
- package/src/abi/index.ts +4 -0
- package/src/api/index.ts +8 -0
- package/src/constants/addresses.ts +16 -2
- package/src/constants/capPerChain.ts +5 -0
- package/src/constants/index.ts +2 -0
- package/src/constants/tokens.ts +44 -44
- package/src/constants/wrappedNativeToken.ts +5 -0
- package/src/crons/index.ts +1 -0
- package/src/crons/prices.ts +12 -0
- package/src/db/models/transaction.ts +21 -0
- package/src/errors/index.ts +26 -0
- package/src/gnosis/actions/aaveV2/source.ts +2 -1
- package/src/gnosis/actions/aaveV2/target.ts +4 -2
- package/src/index.ts +1 -0
- package/src/providers/index.ts +1 -0
- package/src/providers/retry-provider.ts +51 -0
- package/src/services/Prices.ts +89 -0
- package/src/services/index.ts +1 -0
- package/src/tasks/InteropX/{ProcessSubmitSubmitEvents.ts → ProcessSubmitEvents.ts} +120 -14
- package/src/tasks/InteropX/ProcessValidateEvents.ts +38 -12
- package/src/tasks/InteropX/SyncLogExecuteEvents.ts +161 -0
- package/src/tasks/InteropX/SyncLogSubmitEvents.ts +5 -6
- package/src/tasks/InteropX/SyncLogValidateEvents.ts +8 -9
- package/src/tasks/index.ts +8 -5
- package/src/typechain/AaveV2Resolver.ts +1017 -0
- package/src/typechain/BalanceResolver.ts +266 -0
- package/src/typechain/factories/AaveV2Resolver__factory.ts +1198 -0
- package/src/typechain/factories/BalanceResolver__factory.ts +235 -0
- package/src/typechain/factories/index.ts +2 -0
- package/src/typechain/index.ts +4 -0
- package/src/utils/async.ts +22 -0
- package/src/utils/dsa.ts +30 -0
- package/src/utils/formatting.ts +68 -0
- package/src/utils/gnosis.ts +155 -0
- package/src/utils/http.ts +6 -0
- package/src/utils/index.ts +9 -365
- package/src/utils/interop.ts +28 -0
- package/src/utils/tokens.ts +21 -0
- package/src/utils/validate.ts +174 -0
- package/src/utils/web3.ts +132 -0
@@ -16,10 +16,14 @@ const sequelize_1 = require("sequelize");
|
|
16
16
|
const gnosis_1 = require("@/gnosis");
|
17
17
|
const net_1 = require("@/net");
|
18
18
|
const waait_1 = __importDefault(require("waait"));
|
19
|
-
|
19
|
+
const errors_1 = require("@/errors");
|
20
|
+
const bignumber_js_1 = require("bignumber.js");
|
21
|
+
const dedent_1 = __importDefault(require("dedent"));
|
22
|
+
const providers_1 = require("@/providers");
|
23
|
+
class ProcessSubmitEvents extends BaseTask_1.BaseTask {
|
20
24
|
constructor({ chainId }) {
|
21
25
|
super({
|
22
|
-
logger: new logger_1.default("InteropX::
|
26
|
+
logger: new logger_1.default("InteropX::ProcessSubmitEvents"),
|
23
27
|
});
|
24
28
|
this.leadNodeOnly = true;
|
25
29
|
this.blockConfirmationsCount = 12;
|
@@ -54,6 +58,68 @@ class ProcessSubmitSubmitEvents extends BaseTask_1.BaseTask {
|
|
54
58
|
this.logger.debug(`Processing transaction ${transaction.transactionHash}`);
|
55
59
|
transaction.sourceStatus = "proccessing";
|
56
60
|
await transaction.save();
|
61
|
+
const { submitEvent: { position, sourceChainId, targetChainId } } = transaction;
|
62
|
+
try {
|
63
|
+
(0, utils_1.validateChains)({ sourceChainId, targetChainId });
|
64
|
+
}
|
65
|
+
catch (error) {
|
66
|
+
transaction.sourceErrors = [error.message];
|
67
|
+
transaction.sourceStatus = "failed";
|
68
|
+
transaction.targetStatus = "failed";
|
69
|
+
transaction.status = "failed";
|
70
|
+
await transaction.save();
|
71
|
+
return;
|
72
|
+
}
|
73
|
+
const walletBalance = (await this.sourceWallet.getBalance()).toString();
|
74
|
+
const currentGasPrice = (await this.sourceWallet.getGasPrice()).toString();
|
75
|
+
const minBalanceRequired = new bignumber_js_1.BigNumber(currentGasPrice)
|
76
|
+
.multipliedBy(4000000)
|
77
|
+
.multipliedBy(2); // 2x balance
|
78
|
+
if (new bignumber_js_1.BigNumber(walletBalance).isLessThan(minBalanceRequired)) {
|
79
|
+
console.log((0, dedent_1.default) `Not enough balance in wallet ${(0, utils_1.getExplorerUrl)(sourceChainId, '/address/' + this.sourceWallet.address)} on ${(0, utils_1.chainIdToName)(sourceChainId)}
|
80
|
+
Balance: ${ethers_1.ethers.utils.parseEther(walletBalance)} ${(0, utils_1.getChainIdNativeSymbol)(sourceChainId)}
|
81
|
+
Required Balance: ${ethers_1.ethers.utils.parseEther(minBalanceRequired.toString())}
|
82
|
+
Require more: ${ethers_1.ethers.utils.parseEther(minBalanceRequired.minus(walletBalance).toString())}`);
|
83
|
+
transaction.sourceDelayUntil = (0, moment_1.default)().add({ minutes: 5 }).toDate();
|
84
|
+
transaction.sourceStatus = "pending";
|
85
|
+
await transaction.save();
|
86
|
+
return;
|
87
|
+
}
|
88
|
+
try {
|
89
|
+
await (0, utils_1.validateLiquidityCap)(position, sourceChainId, targetChainId);
|
90
|
+
}
|
91
|
+
catch (error) {
|
92
|
+
transaction.sourceErrors = [error.message];
|
93
|
+
transaction.sourceStatus = "failed";
|
94
|
+
transaction.targetStatus = "failed";
|
95
|
+
transaction.status = "failed";
|
96
|
+
await transaction.save();
|
97
|
+
return;
|
98
|
+
}
|
99
|
+
try {
|
100
|
+
await (0, utils_1.validateSourceLiquidity)({
|
101
|
+
position,
|
102
|
+
sourceChainId,
|
103
|
+
sourceProvider: this.sourceProvider,
|
104
|
+
});
|
105
|
+
}
|
106
|
+
catch (error) {
|
107
|
+
if (error instanceof errors_1.UnsupportedChaindIdError) {
|
108
|
+
console.log(`Dropping transaction ${transaction.transactionHash}`);
|
109
|
+
transaction.sourceErrors = [error.message];
|
110
|
+
transaction.sourceStatus = "failed";
|
111
|
+
transaction.targetStatus = "failed";
|
112
|
+
transaction.status = "failed";
|
113
|
+
await transaction.save();
|
114
|
+
}
|
115
|
+
else {
|
116
|
+
transaction.sourceStatus = "pending";
|
117
|
+
transaction.sourceDelayUntil = (0, moment_1.default)().add({ minutes: 5 }).toDate();
|
118
|
+
await transaction.save();
|
119
|
+
console.log("[validateSourceLiquidity][Warning]", error.message);
|
120
|
+
return;
|
121
|
+
}
|
122
|
+
}
|
57
123
|
const ownersThreshold = await this.sourceGnosisContract.getThreshold();
|
58
124
|
await (0, waait_1.default)(10000);
|
59
125
|
this.logger.debug(`Build gnosis action for ${transaction.transactionHash}`);
|
@@ -62,7 +128,7 @@ class ProcessSubmitSubmitEvents extends BaseTask_1.BaseTask {
|
|
62
128
|
({ data, logs } = await (0, gnosis_1.buildGnosisAction)(transaction, "source"));
|
63
129
|
}
|
64
130
|
catch (error) {
|
65
|
-
if (error instanceof
|
131
|
+
if (error instanceof errors_1.LiquidityError) {
|
66
132
|
await transaction.save();
|
67
133
|
transaction.sourceDelayUntil = new Date(Date.now() + 60 * 5 * 1000);
|
68
134
|
transaction.sourceStatus = "pending";
|
@@ -98,7 +164,7 @@ class ProcessSubmitSubmitEvents extends BaseTask_1.BaseTask {
|
|
98
164
|
const ownerPeerIds = net_1.peerPool.activePeers
|
99
165
|
.filter((peer) => owners.includes(peer.publicAddress.toLowerCase()))
|
100
166
|
.map((peer) => peer.id);
|
101
|
-
console.log(`Collecting signatures for execution ${transaction.transactionHash}`);
|
167
|
+
console.log(`Collecting signatures for execution ${transaction.transactionHash} `);
|
102
168
|
console.log(ownerPeerIds);
|
103
169
|
const signatures = await net_1.protocol.requestSignatures({
|
104
170
|
type: "source",
|
@@ -107,7 +173,28 @@ class ProcessSubmitSubmitEvents extends BaseTask_1.BaseTask {
|
|
107
173
|
safeNonce: gnosisTx.nonce,
|
108
174
|
chainId: this.chainId,
|
109
175
|
}, ownerPeerIds);
|
110
|
-
const
|
176
|
+
const message = (0, utils_1.generateGnosisSignatureMessage)({
|
177
|
+
to: constants_1.addresses[data.chainId].multisend,
|
178
|
+
data,
|
179
|
+
chainId: this.chainId,
|
180
|
+
safeTxGas: gnosisTx.safeTxGas,
|
181
|
+
nonce: gnosisTx.safeNonce,
|
182
|
+
});
|
183
|
+
const validSignatures = signatures
|
184
|
+
.filter((s) => !!s.data && s.data !== "0x")
|
185
|
+
.filter((s) => {
|
186
|
+
try {
|
187
|
+
const address = (0, utils_1.getGnosisSignatureAddress)({
|
188
|
+
message,
|
189
|
+
signature: s.data,
|
190
|
+
chainId: this.chainId,
|
191
|
+
});
|
192
|
+
return (address === null || address === void 0 ? void 0 : address.toLowerCase()) === s.signer.toLowerCase();
|
193
|
+
}
|
194
|
+
catch (error) {
|
195
|
+
return false;
|
196
|
+
}
|
197
|
+
});
|
111
198
|
console.log({
|
112
199
|
signatures,
|
113
200
|
validSignatures,
|
@@ -120,7 +207,7 @@ class ProcessSubmitSubmitEvents extends BaseTask_1.BaseTask {
|
|
120
207
|
transaction.sourceStatus = "pending";
|
121
208
|
await transaction.save();
|
122
209
|
const errorMessage = (_a = signatures.find((s) => !!s.error)) === null || _a === void 0 ? void 0 : _a.error;
|
123
|
-
throw new Error(`Not enough signatures` + (errorMessage ? `: ${errorMessage}` : ""));
|
210
|
+
throw new Error(`Not enough signatures` + (errorMessage ? `: ${errorMessage} ` : ""));
|
124
211
|
}
|
125
212
|
console.log(`Executing transaction for execution ${transaction.transactionHash}`);
|
126
213
|
const { data: txData } = await this.sourceGnosisContract.populateTransaction.execTransaction(gnosisTx.to, gnosisTx.value, gnosisTx.data, gnosisTx.operation, gnosisTx.safeTxGas, gnosisTx.baseGas, gnosisTx.gasPrice, gnosisTx.gasToken, gnosisTx.refundReceiver, (0, utils_1.buildSignatureBytes)(validSignatures));
|
@@ -170,10 +257,10 @@ class ProcessSubmitSubmitEvents extends BaseTask_1.BaseTask {
|
|
170
257
|
}
|
171
258
|
async start() {
|
172
259
|
this.blockConfirmationsCount = constants_1.blockConfirmations[this.chainId] + 1;
|
173
|
-
this.sourceProvider = new
|
260
|
+
this.sourceProvider = new providers_1.JsonRpcRetryProvider((0, utils_1.getRpcProviderUrl)(this.chainId));
|
174
261
|
this.sourceWallet = new ethers_1.ethers.Wallet(config_1.default.privateKey, this.sourceProvider);
|
175
262
|
this.sourceGnosisContract = (0, utils_1.getContract)(constants_1.addresses[this.chainId].gnosisSafe, abi_1.default.gnosisSafe, this.sourceWallet);
|
176
263
|
await super.start();
|
177
264
|
}
|
178
265
|
}
|
179
|
-
exports.default =
|
266
|
+
exports.default = ProcessSubmitEvents;
|
@@ -16,6 +16,8 @@ const sequelize_1 = require("sequelize");
|
|
16
16
|
const gnosis_1 = require("@/gnosis");
|
17
17
|
const net_1 = require("@/net");
|
18
18
|
const waait_1 = __importDefault(require("waait"));
|
19
|
+
const errors_1 = require("@/errors");
|
20
|
+
const providers_1 = require("@/providers");
|
19
21
|
class ProcessValidateEvents extends BaseTask_1.BaseTask {
|
20
22
|
constructor({ chainId }) {
|
21
23
|
super({
|
@@ -57,7 +59,7 @@ class ProcessValidateEvents extends BaseTask_1.BaseTask {
|
|
57
59
|
transaction.targetStatus = "proccessing";
|
58
60
|
await transaction.save();
|
59
61
|
const { sourceChainId, targetChainId } = transaction.validateEvent;
|
60
|
-
const targetProvider = new
|
62
|
+
const targetProvider = new providers_1.JsonRpcRetryProvider((0, utils_1.getRpcProviderUrl)(targetChainId));
|
61
63
|
const targetWallet = new ethers_1.ethers.Wallet(config_1.default.privateKey, targetProvider);
|
62
64
|
const targetGnosisContract = (0, utils_1.getContract)(constants_1.addresses[targetChainId].gnosisSafe, abi_1.default.gnosisSafe, targetWallet);
|
63
65
|
const ownersThreshold = await targetGnosisContract.getThreshold();
|
@@ -68,7 +70,7 @@ class ProcessValidateEvents extends BaseTask_1.BaseTask {
|
|
68
70
|
({ data, logs } = await (0, gnosis_1.buildGnosisAction)(transaction, "target"));
|
69
71
|
}
|
70
72
|
catch (error) {
|
71
|
-
if (error instanceof
|
73
|
+
if (error instanceof errors_1.LiquidityError) {
|
72
74
|
await transaction.save();
|
73
75
|
transaction.targetDelayUntil = new Date(Date.now() + 60 * 5 * 1000);
|
74
76
|
transaction.targetStatus = "pending";
|
@@ -112,7 +114,28 @@ class ProcessValidateEvents extends BaseTask_1.BaseTask {
|
|
112
114
|
safeNonce: gnosisTx.nonce,
|
113
115
|
chainId: targetChainId,
|
114
116
|
}, ownerPeerIds);
|
115
|
-
const
|
117
|
+
const message = (0, utils_1.generateGnosisSignatureMessage)({
|
118
|
+
to: constants_1.addresses[data.chainId].multisend,
|
119
|
+
data,
|
120
|
+
chainId: this.chainId,
|
121
|
+
safeTxGas: gnosisTx.safeTxGas,
|
122
|
+
nonce: gnosisTx.safeNonce,
|
123
|
+
});
|
124
|
+
const validSignatures = signatures
|
125
|
+
.filter((s) => !!s.data && s.data !== "0x")
|
126
|
+
.filter((s) => {
|
127
|
+
try {
|
128
|
+
const address = (0, utils_1.getGnosisSignatureAddress)({
|
129
|
+
message,
|
130
|
+
signature: s.data,
|
131
|
+
chainId: this.chainId,
|
132
|
+
});
|
133
|
+
return (address === null || address === void 0 ? void 0 : address.toLowerCase()) === s.signer.toLowerCase();
|
134
|
+
}
|
135
|
+
catch (error) {
|
136
|
+
return false;
|
137
|
+
}
|
138
|
+
});
|
116
139
|
console.log({
|
117
140
|
signatures,
|
118
141
|
validSignatures,
|
@@ -176,7 +199,7 @@ class ProcessValidateEvents extends BaseTask_1.BaseTask {
|
|
176
199
|
}
|
177
200
|
async start() {
|
178
201
|
this.blockConfirmationsCount = constants_1.blockConfirmations[this.chainId] + 1;
|
179
|
-
this.sourceProvider = new
|
202
|
+
this.sourceProvider = new providers_1.JsonRpcRetryProvider((0, utils_1.getRpcProviderUrl)(this.chainId));
|
180
203
|
await super.start();
|
181
204
|
}
|
182
205
|
}
|
@@ -0,0 +1,113 @@
|
|
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
|
+
const sequelize_1 = require("sequelize");
|
15
|
+
const providers_1 = require("@/providers");
|
16
|
+
class SyncLogExecuteEvents extends BaseTask_1.BaseTask {
|
17
|
+
constructor({ targetChainId }) {
|
18
|
+
super({
|
19
|
+
logger: new logger_1.default("InteropX::SyncLogExecuteEvents"),
|
20
|
+
});
|
21
|
+
this.targetChainId = targetChainId;
|
22
|
+
}
|
23
|
+
async pollHandler() {
|
24
|
+
const currentBlock = await this.provider.getBlockNumber();
|
25
|
+
const events = await this.contract.queryFilter(this.contract.filters.LogExecute(), currentBlock - 2000, currentBlock);
|
26
|
+
let processedEvents = 0;
|
27
|
+
for (const event of events) {
|
28
|
+
try {
|
29
|
+
if (!event.args) {
|
30
|
+
continue;
|
31
|
+
}
|
32
|
+
const { sourceSpells, targetSpells, position, actionId, actionIdHash, sourceSender, sourceDsaId, targetDsaId, sourceChainId, targetChainId, vnonce, metadata, } = event.args;
|
33
|
+
const uniqueIdentifier = {
|
34
|
+
actionId,
|
35
|
+
vnonce: vnonce.toString(),
|
36
|
+
sourceSender: sourceSender.toString(),
|
37
|
+
sourceChainId: sourceChainId.toNumber(),
|
38
|
+
targetChainId: targetChainId.toNumber(),
|
39
|
+
sourceDsaId: sourceDsaId.toString(),
|
40
|
+
targetDsaId: targetDsaId.toString(),
|
41
|
+
};
|
42
|
+
let transactionHash = (0, utils_1.generateInteropTransactionHash)(uniqueIdentifier);
|
43
|
+
const transaction = await db_1.Transaction.findOne({
|
44
|
+
where: {
|
45
|
+
transactionHash,
|
46
|
+
executeEvent: { [sequelize_1.Op.eq]: null },
|
47
|
+
},
|
48
|
+
});
|
49
|
+
if (!transaction) {
|
50
|
+
continue;
|
51
|
+
}
|
52
|
+
if (transaction.targetStatus != "success") {
|
53
|
+
transaction.targetStatus = "success";
|
54
|
+
}
|
55
|
+
if (transaction.status != "success") {
|
56
|
+
transaction.status = "success";
|
57
|
+
}
|
58
|
+
if (!transaction.targetCreatedAt) {
|
59
|
+
transaction.targetCreatedAt = new Date();
|
60
|
+
}
|
61
|
+
transaction.targetTransactionHash = event.transactionHash;
|
62
|
+
transaction.targetBlockNumber = event.blockNumber;
|
63
|
+
transaction.targetLogs = [];
|
64
|
+
transaction.executeEvent = {
|
65
|
+
actionId,
|
66
|
+
actionIdHashHash: actionIdHash,
|
67
|
+
actionIdHash,
|
68
|
+
vnonce: vnonce.toString(),
|
69
|
+
sourceSpells: sourceSpells.map(({ connector, data }) => ({
|
70
|
+
connector,
|
71
|
+
data,
|
72
|
+
})),
|
73
|
+
targetSpells: targetSpells.map(({ connector, data }) => ({
|
74
|
+
connector,
|
75
|
+
data,
|
76
|
+
})),
|
77
|
+
position: {
|
78
|
+
withdraw: position.withdraw.map((v) => ({
|
79
|
+
sourceToken: v.sourceToken,
|
80
|
+
targetToken: v.targetToken,
|
81
|
+
amount: v.amount.toString(),
|
82
|
+
})),
|
83
|
+
supply: position.supply.map((v) => ({
|
84
|
+
sourceToken: v.sourceToken,
|
85
|
+
targetToken: v.targetToken,
|
86
|
+
amount: v.amount.toString(),
|
87
|
+
})),
|
88
|
+
},
|
89
|
+
sourceChainId: sourceChainId.toNumber(),
|
90
|
+
targetChainId: targetChainId.toNumber(),
|
91
|
+
sourceSender,
|
92
|
+
sourceDsaId: sourceDsaId.toString(),
|
93
|
+
targetDsaId: targetDsaId.toString(),
|
94
|
+
metadata,
|
95
|
+
};
|
96
|
+
await transaction.save();
|
97
|
+
this.logger.info(`New InteropX tranaction: ${transactionHash} `);
|
98
|
+
}
|
99
|
+
catch (error) {
|
100
|
+
this.logger.error(error);
|
101
|
+
}
|
102
|
+
}
|
103
|
+
if (processedEvents > 0)
|
104
|
+
this.logger.info(`${processedEvents} events processed`);
|
105
|
+
}
|
106
|
+
async start() {
|
107
|
+
this.contractAddress = constants_1.addresses[this.targetChainId].interopX;
|
108
|
+
this.provider = new providers_1.JsonRpcRetryProvider((0, utils_1.getRpcProviderUrl)(this.targetChainId));
|
109
|
+
this.contract = (0, utils_1.getContract)(this.contractAddress, abi_1.default.interopX, new ethers_1.ethers.Wallet(config_1.default.privateKey, this.provider));
|
110
|
+
await super.start();
|
111
|
+
}
|
112
|
+
}
|
113
|
+
exports.default = SyncLogExecuteEvents;
|
@@ -11,6 +11,7 @@ const db_1 = require("@/db");
|
|
11
11
|
const utils_1 = require("@/utils");
|
12
12
|
const constants_1 = require("@/constants");
|
13
13
|
const config_1 = __importDefault(require("@/config"));
|
14
|
+
const providers_1 = require("@/providers");
|
14
15
|
class SyncLogSubmitEvents extends BaseTask_1.BaseTask {
|
15
16
|
constructor({ chainId }) {
|
16
17
|
super({
|
@@ -79,7 +80,7 @@ class SyncLogSubmitEvents extends BaseTask_1.BaseTask {
|
|
79
80
|
}
|
80
81
|
async start() {
|
81
82
|
this.contractAddress = constants_1.addresses[this.chainId].interopX;
|
82
|
-
this.provider = new
|
83
|
+
this.provider = new providers_1.JsonRpcRetryProvider((0, utils_1.getRpcProviderUrl)(this.chainId));
|
83
84
|
this.contract = (0, utils_1.getContract)(this.contractAddress, abi_1.default.interopX, new ethers_1.ethers.Wallet(config_1.default.privateKey, this.provider));
|
84
85
|
await super.start();
|
85
86
|
}
|
@@ -12,6 +12,7 @@ const utils_1 = require("@/utils");
|
|
12
12
|
const constants_1 = require("@/constants");
|
13
13
|
const config_1 = __importDefault(require("@/config"));
|
14
14
|
const sequelize_1 = require("sequelize");
|
15
|
+
const providers_1 = require("@/providers");
|
15
16
|
class SyncLogValidateEvents extends BaseTask_1.BaseTask {
|
16
17
|
constructor({ chainId }) {
|
17
18
|
super({
|
@@ -57,7 +58,7 @@ class SyncLogValidateEvents extends BaseTask_1.BaseTask {
|
|
57
58
|
transaction.sourceTransactionHash = event.transactionHash;
|
58
59
|
transaction.sourceBlockNumber = event.blockNumber;
|
59
60
|
transaction.sourceLogs = [];
|
60
|
-
|
61
|
+
transaction.validateEvent = {
|
61
62
|
actionId,
|
62
63
|
actionIdHashHash: actionIdHash,
|
63
64
|
actionIdHash,
|
@@ -84,8 +85,8 @@ class SyncLogValidateEvents extends BaseTask_1.BaseTask {
|
|
84
85
|
sourceDsaId: sourceDsaId.toString(),
|
85
86
|
targetDsaId: targetDsaId.toString(),
|
86
87
|
metadata,
|
87
|
-
}
|
88
|
-
|
88
|
+
};
|
89
|
+
await transaction.save();
|
89
90
|
this.logger.info(`New InteropX tranaction: ${transactionHash} `);
|
90
91
|
}
|
91
92
|
catch (error) {
|
@@ -97,7 +98,7 @@ class SyncLogValidateEvents extends BaseTask_1.BaseTask {
|
|
97
98
|
}
|
98
99
|
async start() {
|
99
100
|
this.contractAddress = constants_1.addresses[this.chainId].interopX;
|
100
|
-
this.provider = new
|
101
|
+
this.provider = new providers_1.JsonRpcRetryProvider((0, utils_1.getRpcProviderUrl)(this.chainId));
|
101
102
|
this.contract = (0, utils_1.getContract)(this.contractAddress, abi_1.default.interopX, new ethers_1.ethers.Wallet(config_1.default.privateKey, this.provider));
|
102
103
|
await super.start();
|
103
104
|
}
|
package/dist/src/tasks/index.js
CHANGED
@@ -8,23 +8,25 @@ const waait_1 = __importDefault(require("waait"));
|
|
8
8
|
const SyncTransactionStatusTask_1 = __importDefault(require("./Transactions/SyncTransactionStatusTask"));
|
9
9
|
const AutoUpdateTask_1 = __importDefault(require("./AutoUpdateTask"));
|
10
10
|
const SyncLogSubmitEvents_1 = __importDefault(require("./InteropX/SyncLogSubmitEvents"));
|
11
|
-
const
|
11
|
+
const ProcessSubmitEvents_1 = __importDefault(require("./InteropX/ProcessSubmitEvents"));
|
12
12
|
const SyncLogValidateEvents_1 = __importDefault(require("./InteropX/SyncLogValidateEvents"));
|
13
13
|
const ProcessValidateEvents_1 = __importDefault(require("./InteropX/ProcessValidateEvents"));
|
14
|
+
const SyncLogExecuteEvents_1 = __importDefault(require("./InteropX/SyncLogExecuteEvents"));
|
14
15
|
class Tasks {
|
15
16
|
constructor() {
|
16
17
|
this.tasks = [
|
17
|
-
// new SyncTransactionStatusTask(),
|
18
18
|
new AutoUpdateTask_1.default(),
|
19
19
|
// InteropX
|
20
20
|
new SyncLogSubmitEvents_1.default({ chainId: 137 }),
|
21
21
|
new SyncLogSubmitEvents_1.default({ chainId: 43114 }),
|
22
|
-
new
|
23
|
-
new
|
22
|
+
new ProcessSubmitEvents_1.default({ chainId: 137 }),
|
23
|
+
new ProcessSubmitEvents_1.default({ chainId: 43114 }),
|
24
24
|
new SyncLogValidateEvents_1.default({ chainId: 137 }),
|
25
25
|
new SyncLogValidateEvents_1.default({ chainId: 43114 }),
|
26
26
|
new ProcessValidateEvents_1.default({ chainId: 137 }),
|
27
27
|
new ProcessValidateEvents_1.default({ chainId: 43114 }),
|
28
|
+
new SyncLogExecuteEvents_1.default({ targetChainId: 137 }),
|
29
|
+
new SyncLogExecuteEvents_1.default({ targetChainId: 43114 }),
|
28
30
|
new SyncTransactionStatusTask_1.default(),
|
29
31
|
];
|
30
32
|
}
|
@@ -32,7 +34,7 @@ class Tasks {
|
|
32
34
|
for (const task of this.tasks) {
|
33
35
|
try {
|
34
36
|
task.start();
|
35
|
-
await (0, waait_1.default)(
|
37
|
+
await (0, waait_1.default)(300);
|
36
38
|
}
|
37
39
|
catch (error) {
|
38
40
|
console.error(`Error starting task: ${task.constructor.name}`);
|