@instadapp/interop-x 0.0.0-dev.ee3d74b → 0.0.0-dev.ef38dfb
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 +3 -1
- package/dist/src/abi/index.js +2 -0
- package/dist/src/abi/instList.json +232 -0
- package/dist/src/api/index.js +7 -0
- package/dist/src/constants/addresses.js +4 -2
- package/dist/src/db/models/transaction.js +15 -7
- package/dist/src/errors/index.js +10 -0
- package/dist/src/gnosis/actions/aaveV2/source.js +15 -4
- package/dist/src/gnosis/actions/aaveV2/target.js +78 -0
- package/dist/src/index.js +1 -1
- package/dist/src/tasks/InteropX/ProcessSubmitSubmitEvents.js +15 -3
- package/dist/src/tasks/InteropX/ProcessValidateEvents.js +184 -0
- package/dist/src/tasks/InteropX/SyncLogExecuteEvents.js +112 -0
- package/dist/src/tasks/InteropX/SyncLogSubmitEvents.js +1 -0
- package/dist/src/tasks/InteropX/SyncLogValidateEvents.js +105 -0
- package/dist/src/tasks/index.js +10 -1
- package/dist/src/typechain/InstList.js +2 -0
- package/dist/src/typechain/factories/InstList__factory.js +249 -0
- package/dist/src/typechain/factories/index.js +3 -1
- package/dist/src/typechain/index.js +3 -1
- package/dist/src/utils/async.js +18 -0
- package/dist/src/utils/dsa.js +24 -0
- package/dist/src/utils/formatting.js +17 -0
- package/dist/src/utils/gnosis.js +62 -0
- package/dist/src/utils/http.js +10 -0
- package/dist/src/utils/index.js +20 -219
- package/dist/src/utils/interop.js +16 -0
- package/dist/src/utils/web3.js +92 -0
- package/package.json +3 -1
- package/src/abi/index.ts +2 -0
- package/src/abi/instList.json +232 -0
- package/src/api/index.ts +8 -0
- package/src/constants/addresses.ts +5 -3
- package/src/db/models/transaction.ts +134 -80
- package/src/errors/index.ts +6 -0
- package/src/gnosis/actions/aaveV2/source.ts +19 -5
- package/src/gnosis/actions/aaveV2/target.ts +130 -2
- package/src/tasks/InteropX/ProcessSubmitSubmitEvents.ts +20 -3
- package/src/tasks/InteropX/ProcessValidateEvents.ts +274 -0
- package/src/tasks/InteropX/SyncLogExecuteEvents.ts +162 -0
- package/src/tasks/InteropX/SyncLogSubmitEvents.ts +1 -0
- package/src/tasks/InteropX/SyncLogValidateEvents.ts +152 -0
- package/src/tasks/index.ts +13 -1
- package/src/typechain/InstList.ts +402 -0
- package/src/typechain/factories/InstList__factory.ts +253 -0
- package/src/typechain/factories/index.ts +1 -0
- package/src/typechain/index.ts +2 -0
- package/src/utils/async.ts +22 -0
- package/src/utils/dsa.ts +30 -0
- package/src/utils/formatting.ts +15 -0
- package/src/utils/gnosis.ts +123 -0
- package/src/utils/http.ts +6 -0
- package/src/utils/index.ts +7 -365
- package/src/utils/interop.ts +28 -0
- package/src/utils/web3.ts +131 -0
@@ -0,0 +1,184 @@
|
|
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 moment_1 = __importDefault(require("moment"));
|
15
|
+
const sequelize_1 = require("sequelize");
|
16
|
+
const gnosis_1 = require("@/gnosis");
|
17
|
+
const net_1 = require("@/net");
|
18
|
+
const waait_1 = __importDefault(require("waait"));
|
19
|
+
const errors_1 = require("@/errors");
|
20
|
+
class ProcessValidateEvents extends BaseTask_1.BaseTask {
|
21
|
+
constructor({ chainId }) {
|
22
|
+
super({
|
23
|
+
logger: new logger_1.default("InteropX::ProcessValidateEvents"),
|
24
|
+
});
|
25
|
+
this.leadNodeOnly = true;
|
26
|
+
this.blockConfirmationsCount = 12;
|
27
|
+
this.chainId = chainId;
|
28
|
+
}
|
29
|
+
async pollHandler() {
|
30
|
+
var _a;
|
31
|
+
const currentBlockNumber = await this.sourceProvider.getBlockNumber();
|
32
|
+
const transaction = await db_1.Transaction.findOne({
|
33
|
+
where: {
|
34
|
+
status: "pending",
|
35
|
+
sourceStatus: "success",
|
36
|
+
targetStatus: "pending",
|
37
|
+
sourceChainId: this.chainId,
|
38
|
+
sourceBlockNumber: {
|
39
|
+
[sequelize_1.Op.lt]: currentBlockNumber - this.blockConfirmationsCount,
|
40
|
+
},
|
41
|
+
targetDelayUntil: {
|
42
|
+
[sequelize_1.Op.or]: {
|
43
|
+
[sequelize_1.Op.is]: null,
|
44
|
+
[sequelize_1.Op.lt]: new Date(),
|
45
|
+
},
|
46
|
+
},
|
47
|
+
submitEvent: { $ne: null },
|
48
|
+
validateEvent: { $ne: null },
|
49
|
+
createdAt: {
|
50
|
+
[sequelize_1.Op.gt]: (0, moment_1.default)().subtract({ hours: 12 }).toDate(),
|
51
|
+
},
|
52
|
+
},
|
53
|
+
});
|
54
|
+
if (!transaction) {
|
55
|
+
return;
|
56
|
+
}
|
57
|
+
this.logger.debug(`Processing transaction ${transaction.transactionHash}`);
|
58
|
+
transaction.targetStatus = "proccessing";
|
59
|
+
await transaction.save();
|
60
|
+
const { sourceChainId, targetChainId } = transaction.validateEvent;
|
61
|
+
const targetProvider = new ethers_1.ethers.providers.JsonRpcProvider((0, utils_1.getRpcProviderUrl)(targetChainId));
|
62
|
+
const targetWallet = new ethers_1.ethers.Wallet(config_1.default.privateKey, targetProvider);
|
63
|
+
const targetGnosisContract = (0, utils_1.getContract)(constants_1.addresses[targetChainId].gnosisSafe, abi_1.default.gnosisSafe, targetWallet);
|
64
|
+
const ownersThreshold = await targetGnosisContract.getThreshold();
|
65
|
+
await (0, waait_1.default)(10000);
|
66
|
+
this.logger.debug(`Build gnosis action for ${transaction.transactionHash}`);
|
67
|
+
let data, logs = [];
|
68
|
+
try {
|
69
|
+
({ data, logs } = await (0, gnosis_1.buildGnosisAction)(transaction, "target"));
|
70
|
+
}
|
71
|
+
catch (error) {
|
72
|
+
if (error instanceof errors_1.LiquidityError) {
|
73
|
+
await transaction.save();
|
74
|
+
transaction.targetDelayUntil = new Date(Date.now() + 60 * 5 * 1000);
|
75
|
+
transaction.targetStatus = "pending";
|
76
|
+
await transaction.save();
|
77
|
+
throw error;
|
78
|
+
return;
|
79
|
+
}
|
80
|
+
transaction.targetStatus = "failed";
|
81
|
+
transaction.targetErrors = [error.message];
|
82
|
+
transaction.status = "failed";
|
83
|
+
await transaction.save();
|
84
|
+
net_1.protocol.sendTransaction(transaction);
|
85
|
+
return;
|
86
|
+
}
|
87
|
+
this.logger.debug(`Generating gnosis tx for ${transaction.transactionHash}`);
|
88
|
+
let gnosisTx = await (0, utils_1.generateGnosisTransaction)({
|
89
|
+
baseGas: "0",
|
90
|
+
data,
|
91
|
+
gasPrice: "0",
|
92
|
+
gasToken: "0x0000000000000000000000000000000000000000",
|
93
|
+
nonce: "0",
|
94
|
+
operation: "1",
|
95
|
+
refundReceiver: "0x0000000000000000000000000000000000000000",
|
96
|
+
safeAddress: targetGnosisContract.address,
|
97
|
+
safeTxGas: "79668",
|
98
|
+
to: constants_1.addresses[transaction.targetChainId].multisend,
|
99
|
+
value: "0",
|
100
|
+
}, targetGnosisContract);
|
101
|
+
const owners = await targetGnosisContract
|
102
|
+
.getOwners()
|
103
|
+
.then((owners) => owners.map((owner) => owner.toLowerCase()));
|
104
|
+
const ownerPeerIds = net_1.peerPool.activePeers
|
105
|
+
.filter((peer) => owners.includes(peer.publicAddress.toLowerCase()))
|
106
|
+
.map((peer) => peer.id);
|
107
|
+
console.log(`Collecting signatures for execution ${transaction.transactionHash}`);
|
108
|
+
console.log(ownerPeerIds);
|
109
|
+
const signatures = await net_1.protocol.requestSignatures({
|
110
|
+
type: "target",
|
111
|
+
transactionHash: transaction.transactionHash,
|
112
|
+
safeTxGas: gnosisTx.safeTxGas,
|
113
|
+
safeNonce: gnosisTx.nonce,
|
114
|
+
chainId: targetChainId,
|
115
|
+
}, ownerPeerIds);
|
116
|
+
const validSignatures = signatures.filter((s) => !!s.data && s.data !== "0x");
|
117
|
+
console.log({
|
118
|
+
signatures,
|
119
|
+
validSignatures,
|
120
|
+
ownersThreshold: ownersThreshold.toString(),
|
121
|
+
});
|
122
|
+
if (validSignatures.length === 0 ||
|
123
|
+
ownersThreshold.gt(validSignatures.length)) {
|
124
|
+
await transaction.save();
|
125
|
+
transaction.targetDelayUntil = new Date(Date.now() + 30 * 1000);
|
126
|
+
transaction.targetStatus = "pending";
|
127
|
+
await transaction.save();
|
128
|
+
const errorMessage = (_a = signatures.find((s) => !!s.error)) === null || _a === void 0 ? void 0 : _a.error;
|
129
|
+
throw new Error(`Not enough signatures` + (errorMessage ? `: ${errorMessage}` : ""));
|
130
|
+
}
|
131
|
+
console.log(`Executing transaction for execution ${transaction.transactionHash}`);
|
132
|
+
const { data: txData } = await targetGnosisContract.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));
|
133
|
+
const [gasPrice, gasLimit] = await Promise.all([
|
134
|
+
targetProvider.getGasPrice(),
|
135
|
+
targetProvider.estimateGas({
|
136
|
+
from: targetWallet.address,
|
137
|
+
to: targetGnosisContract.address,
|
138
|
+
data: txData,
|
139
|
+
}),
|
140
|
+
]);
|
141
|
+
const txSent = await targetWallet.sendTransaction({
|
142
|
+
from: targetWallet.address,
|
143
|
+
to: targetGnosisContract.address,
|
144
|
+
gasPrice: gasPrice.mul(120).div(100),
|
145
|
+
gasLimit: 5000000,
|
146
|
+
data: txData,
|
147
|
+
});
|
148
|
+
console.log(txSent);
|
149
|
+
const receipt = await txSent.wait();
|
150
|
+
const parsedLogs = [];
|
151
|
+
receipt.logs.forEach((log) => {
|
152
|
+
try {
|
153
|
+
parsedLogs.push(targetGnosisContract.interface.parseLog(log));
|
154
|
+
}
|
155
|
+
catch (e) { }
|
156
|
+
});
|
157
|
+
if (parsedLogs.find((e) => e.name === "ExecutionSuccess")) {
|
158
|
+
console.log("ExecutionSuccess");
|
159
|
+
transaction.targetStatus = "success";
|
160
|
+
transaction.status = "success";
|
161
|
+
if (txSent.blockNumber)
|
162
|
+
transaction.targetBlockNumber = txSent.blockNumber;
|
163
|
+
transaction.targetTransactionHash = txSent.hash;
|
164
|
+
transaction.targetLogs = logs;
|
165
|
+
await transaction.save();
|
166
|
+
}
|
167
|
+
else {
|
168
|
+
console.log("ExecutionFailure");
|
169
|
+
transaction.targetStatus = "failed";
|
170
|
+
if (txSent.blockNumber)
|
171
|
+
transaction.targetBlockNumber = txSent.blockNumber;
|
172
|
+
transaction.targetTransactionHash = txSent.hash;
|
173
|
+
transaction.status = "failed";
|
174
|
+
await transaction.save();
|
175
|
+
}
|
176
|
+
net_1.protocol.sendTransaction(transaction);
|
177
|
+
}
|
178
|
+
async start() {
|
179
|
+
this.blockConfirmationsCount = constants_1.blockConfirmations[this.chainId] + 1;
|
180
|
+
this.sourceProvider = new ethers_1.ethers.providers.JsonRpcProvider((0, utils_1.getRpcProviderUrl)(this.chainId));
|
181
|
+
await super.start();
|
182
|
+
}
|
183
|
+
}
|
184
|
+
exports.default = ProcessValidateEvents;
|
@@ -0,0 +1,112 @@
|
|
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
|
+
class SyncLogExecuteEvents extends BaseTask_1.BaseTask {
|
16
|
+
constructor({ targetChainId }) {
|
17
|
+
super({
|
18
|
+
logger: new logger_1.default("InteropX::SyncLogExecuteEvents"),
|
19
|
+
});
|
20
|
+
this.targetChainId = targetChainId;
|
21
|
+
}
|
22
|
+
async pollHandler() {
|
23
|
+
const currentBlock = await this.provider.getBlockNumber();
|
24
|
+
const events = await this.contract.queryFilter(this.contract.filters.LogExecute(), currentBlock - 2000, currentBlock);
|
25
|
+
let processedEvents = 0;
|
26
|
+
for (const event of events) {
|
27
|
+
try {
|
28
|
+
if (!event.args) {
|
29
|
+
continue;
|
30
|
+
}
|
31
|
+
const { sourceSpells, targetSpells, position, actionId, actionIdHash, sourceSender, sourceDsaId, targetDsaId, sourceChainId, targetChainId, vnonce, metadata, } = event.args;
|
32
|
+
const uniqueIdentifier = {
|
33
|
+
actionId,
|
34
|
+
vnonce: vnonce.toString(),
|
35
|
+
sourceSender: sourceSender.toString(),
|
36
|
+
sourceChainId: sourceChainId.toNumber(),
|
37
|
+
targetChainId: targetChainId.toNumber(),
|
38
|
+
sourceDsaId: sourceDsaId.toString(),
|
39
|
+
targetDsaId: targetDsaId.toString(),
|
40
|
+
};
|
41
|
+
let transactionHash = (0, utils_1.generateInteropTransactionHash)(uniqueIdentifier);
|
42
|
+
const transaction = await db_1.Transaction.findOne({
|
43
|
+
where: {
|
44
|
+
transactionHash,
|
45
|
+
executeEvent: { [sequelize_1.Op.eq]: null },
|
46
|
+
},
|
47
|
+
});
|
48
|
+
if (!transaction) {
|
49
|
+
continue;
|
50
|
+
}
|
51
|
+
if (transaction.targetStatus != "success") {
|
52
|
+
transaction.targetStatus = "success";
|
53
|
+
}
|
54
|
+
if (transaction.status != "success") {
|
55
|
+
transaction.status = "success";
|
56
|
+
}
|
57
|
+
if (!transaction.targetCreatedAt) {
|
58
|
+
transaction.targetCreatedAt = new Date();
|
59
|
+
}
|
60
|
+
transaction.targetTransactionHash = event.transactionHash;
|
61
|
+
transaction.targetBlockNumber = event.blockNumber;
|
62
|
+
transaction.targetLogs = [];
|
63
|
+
transaction.executeEvent = {
|
64
|
+
actionId,
|
65
|
+
actionIdHashHash: actionIdHash,
|
66
|
+
actionIdHash,
|
67
|
+
vnonce: vnonce.toString(),
|
68
|
+
sourceSpells: sourceSpells.map(({ connector, data }) => ({
|
69
|
+
connector,
|
70
|
+
data,
|
71
|
+
})),
|
72
|
+
targetSpells: targetSpells.map(({ connector, data }) => ({
|
73
|
+
connector,
|
74
|
+
data,
|
75
|
+
})),
|
76
|
+
position: {
|
77
|
+
withdraw: position.withdraw.map((v) => ({
|
78
|
+
sourceToken: v.sourceToken,
|
79
|
+
targetToken: v.targetToken,
|
80
|
+
amount: v.amount.toString(),
|
81
|
+
})),
|
82
|
+
supply: position.supply.map((v) => ({
|
83
|
+
sourceToken: v.sourceToken,
|
84
|
+
targetToken: v.targetToken,
|
85
|
+
amount: v.amount.toString(),
|
86
|
+
})),
|
87
|
+
},
|
88
|
+
sourceChainId: sourceChainId.toNumber(),
|
89
|
+
targetChainId: targetChainId.toNumber(),
|
90
|
+
sourceSender,
|
91
|
+
sourceDsaId: sourceDsaId.toString(),
|
92
|
+
targetDsaId: targetDsaId.toString(),
|
93
|
+
metadata,
|
94
|
+
};
|
95
|
+
await transaction.save();
|
96
|
+
this.logger.info(`New InteropX tranaction: ${transactionHash} `);
|
97
|
+
}
|
98
|
+
catch (error) {
|
99
|
+
this.logger.error(error);
|
100
|
+
}
|
101
|
+
}
|
102
|
+
if (processedEvents > 0)
|
103
|
+
this.logger.info(`${processedEvents} events processed`);
|
104
|
+
}
|
105
|
+
async start() {
|
106
|
+
this.contractAddress = constants_1.addresses[this.targetChainId].interopX;
|
107
|
+
this.provider = new ethers_1.ethers.providers.JsonRpcProvider((0, utils_1.getRpcProviderUrl)(this.targetChainId));
|
108
|
+
this.contract = (0, utils_1.getContract)(this.contractAddress, abi_1.default.interopX, new ethers_1.ethers.Wallet(config_1.default.privateKey, this.provider));
|
109
|
+
await super.start();
|
110
|
+
}
|
111
|
+
}
|
112
|
+
exports.default = SyncLogExecuteEvents;
|
@@ -47,6 +47,7 @@ class SyncLogSubmitEvents extends BaseTask_1.BaseTask {
|
|
47
47
|
await db_1.Transaction.create(Object.assign(Object.assign({ transactionHash }, uniqueIdentifier), { submitChainId: this.chainId, submitTransactionHash: event.transactionHash, submitBlockNumber: event.blockNumber, submitCreatedAt: new Date(), submitEvent: {
|
48
48
|
actionId,
|
49
49
|
actionIdHashHash,
|
50
|
+
actionIdHash: actionIdHashHash,
|
50
51
|
vnonce: vnonce.toString(),
|
51
52
|
position: {
|
52
53
|
withdraw: position.withdraw.map((v) => ({
|
@@ -0,0 +1,105 @@
|
|
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
|
+
class SyncLogValidateEvents extends BaseTask_1.BaseTask {
|
16
|
+
constructor({ chainId }) {
|
17
|
+
super({
|
18
|
+
logger: new logger_1.default("InteropX::SyncLogValidateEvents"),
|
19
|
+
});
|
20
|
+
this.chainId = chainId;
|
21
|
+
}
|
22
|
+
async pollHandler() {
|
23
|
+
const currentBlock = await this.provider.getBlockNumber();
|
24
|
+
const events = await this.contract.queryFilter(this.contract.filters.LogValidate(), currentBlock - 2000, currentBlock);
|
25
|
+
let processedEvents = 0;
|
26
|
+
for (const event of events) {
|
27
|
+
try {
|
28
|
+
if (!event.args) {
|
29
|
+
continue;
|
30
|
+
}
|
31
|
+
const { sourceSpells, position, actionId, actionIdHash, sourceSender, sourceDsaId, targetDsaId, sourceChainId, targetChainId, vnonce, metadata, } = event.args;
|
32
|
+
const uniqueIdentifier = {
|
33
|
+
actionId,
|
34
|
+
vnonce: vnonce.toString(),
|
35
|
+
sourceSender: sourceSender.toString(),
|
36
|
+
sourceChainId: sourceChainId.toNumber(),
|
37
|
+
targetChainId: targetChainId.toNumber(),
|
38
|
+
sourceDsaId: sourceDsaId.toString(),
|
39
|
+
targetDsaId: targetDsaId.toString(),
|
40
|
+
};
|
41
|
+
let transactionHash = (0, utils_1.generateInteropTransactionHash)(uniqueIdentifier);
|
42
|
+
const transaction = await db_1.Transaction.findOne({
|
43
|
+
where: {
|
44
|
+
transactionHash,
|
45
|
+
validateEvent: { [sequelize_1.Op.eq]: null },
|
46
|
+
},
|
47
|
+
});
|
48
|
+
if (!transaction) {
|
49
|
+
continue;
|
50
|
+
}
|
51
|
+
if (transaction.sourceStatus != "success") {
|
52
|
+
transaction.sourceStatus = "success";
|
53
|
+
}
|
54
|
+
if (!transaction.sourceCreatedAt) {
|
55
|
+
transaction.sourceCreatedAt = new Date();
|
56
|
+
}
|
57
|
+
transaction.sourceTransactionHash = event.transactionHash;
|
58
|
+
transaction.sourceBlockNumber = event.blockNumber;
|
59
|
+
transaction.sourceLogs = [];
|
60
|
+
transaction.validateEvent = {
|
61
|
+
actionId,
|
62
|
+
actionIdHashHash: actionIdHash,
|
63
|
+
actionIdHash,
|
64
|
+
vnonce: vnonce.toString(),
|
65
|
+
sourceSpells: sourceSpells.map(({ connector, data }) => ({
|
66
|
+
connector,
|
67
|
+
data,
|
68
|
+
})),
|
69
|
+
position: {
|
70
|
+
withdraw: position.withdraw.map((v) => ({
|
71
|
+
sourceToken: v.sourceToken,
|
72
|
+
targetToken: v.targetToken,
|
73
|
+
amount: v.amount.toString(),
|
74
|
+
})),
|
75
|
+
supply: position.supply.map((v) => ({
|
76
|
+
sourceToken: v.sourceToken,
|
77
|
+
targetToken: v.targetToken,
|
78
|
+
amount: v.amount.toString(),
|
79
|
+
})),
|
80
|
+
},
|
81
|
+
sourceChainId: sourceChainId.toNumber(),
|
82
|
+
targetChainId: targetChainId.toNumber(),
|
83
|
+
sourceSender,
|
84
|
+
sourceDsaId: sourceDsaId.toString(),
|
85
|
+
targetDsaId: targetDsaId.toString(),
|
86
|
+
metadata,
|
87
|
+
};
|
88
|
+
await transaction.save();
|
89
|
+
this.logger.info(`New InteropX tranaction: ${transactionHash} `);
|
90
|
+
}
|
91
|
+
catch (error) {
|
92
|
+
this.logger.error(error);
|
93
|
+
}
|
94
|
+
}
|
95
|
+
if (processedEvents > 0)
|
96
|
+
this.logger.info(`${processedEvents} events processed`);
|
97
|
+
}
|
98
|
+
async start() {
|
99
|
+
this.contractAddress = constants_1.addresses[this.chainId].interopX;
|
100
|
+
this.provider = new ethers_1.ethers.providers.JsonRpcProvider((0, utils_1.getRpcProviderUrl)(this.chainId));
|
101
|
+
this.contract = (0, utils_1.getContract)(this.contractAddress, abi_1.default.interopX, new ethers_1.ethers.Wallet(config_1.default.privateKey, this.provider));
|
102
|
+
await super.start();
|
103
|
+
}
|
104
|
+
}
|
105
|
+
exports.default = SyncLogValidateEvents;
|
package/dist/src/tasks/index.js
CHANGED
@@ -9,6 +9,9 @@ const SyncTransactionStatusTask_1 = __importDefault(require("./Transactions/Sync
|
|
9
9
|
const AutoUpdateTask_1 = __importDefault(require("./AutoUpdateTask"));
|
10
10
|
const SyncLogSubmitEvents_1 = __importDefault(require("./InteropX/SyncLogSubmitEvents"));
|
11
11
|
const ProcessSubmitSubmitEvents_1 = __importDefault(require("./InteropX/ProcessSubmitSubmitEvents"));
|
12
|
+
const SyncLogValidateEvents_1 = __importDefault(require("./InteropX/SyncLogValidateEvents"));
|
13
|
+
const ProcessValidateEvents_1 = __importDefault(require("./InteropX/ProcessValidateEvents"));
|
14
|
+
const SyncLogExecuteEvents_1 = __importDefault(require("./InteropX/SyncLogExecuteEvents"));
|
12
15
|
class Tasks {
|
13
16
|
constructor() {
|
14
17
|
this.tasks = [
|
@@ -19,6 +22,12 @@ class Tasks {
|
|
19
22
|
new SyncLogSubmitEvents_1.default({ chainId: 43114 }),
|
20
23
|
new ProcessSubmitSubmitEvents_1.default({ chainId: 137 }),
|
21
24
|
new ProcessSubmitSubmitEvents_1.default({ chainId: 43114 }),
|
25
|
+
new SyncLogValidateEvents_1.default({ chainId: 137 }),
|
26
|
+
new SyncLogValidateEvents_1.default({ chainId: 43114 }),
|
27
|
+
new ProcessValidateEvents_1.default({ chainId: 137 }),
|
28
|
+
new ProcessValidateEvents_1.default({ chainId: 43114 }),
|
29
|
+
new SyncLogExecuteEvents_1.default({ targetChainId: 137 }),
|
30
|
+
new SyncLogExecuteEvents_1.default({ targetChainId: 43114 }),
|
22
31
|
new SyncTransactionStatusTask_1.default(),
|
23
32
|
];
|
24
33
|
}
|
@@ -26,7 +35,7 @@ class Tasks {
|
|
26
35
|
for (const task of this.tasks) {
|
27
36
|
try {
|
28
37
|
task.start();
|
29
|
-
await (0, waait_1.default)(
|
38
|
+
await (0, waait_1.default)(300);
|
30
39
|
}
|
31
40
|
catch (error) {
|
32
41
|
console.error(`Error starting task: ${task.constructor.name}`);
|