@instadapp/interop-x 0.0.0-dev.c4e0c91 → 0.0.0-dev.c696e38

Sign up to get free protection for your applications and to get access to all the features.
package/dist/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@instadapp/interop-x",
3
- "version": "0.0.0-dev.c4e0c91",
3
+ "version": "0.0.0-dev.c696e38",
4
4
  "license": "MIT",
5
5
  "main": "dist/index.js",
6
6
  "engines": {
@@ -11,7 +11,7 @@ exports.addresses = {
11
11
  43114: {
12
12
  gnosisSafe: '0x31d7a5194Fe60AC209Cf1Ce2d539C9A60662Ed6b',
13
13
  multisend: '0x998739BFdAAdde7C933B942a68053933098f9EDa',
14
- interopX: '0xd61f55C6d9deD35B9d13243b816c4BcC1d78592b',
14
+ interopX: '0xA82A87096709E3D8648c9d9a22f31133bC4B6d32',
15
15
  dsaAddress: '0xFcB7d826E32081c4799de2f83b47b49df600dc8c',
16
16
  }
17
17
  };
@@ -17,7 +17,7 @@ async function default_1(transaction) {
17
17
  const targetWallet = new ethers_1.ethers.Wallet(config_1.default.privateKey, targetChainProvider);
18
18
  const dsaAddress = constants_1.addresses[targetChainId].dsaAddress;
19
19
  const sourceUserAddress = Number(sourceDsaId) == 0 ? sourceSender : dsaAddress;
20
- const interopAddress = constants_1.addresses[sourceChainId].interopX;
20
+ const interopAddress = constants_1.addresses[targetChainId].interopX;
21
21
  const contract = (0, utils_1.getContract)(interopAddress, abi_1.default.interopX, targetWallet);
22
22
  const targetSpells = [];
23
23
  const commonSpells = [];
@@ -27,10 +27,19 @@ async function default_1(transaction) {
27
27
  method: "deposit",
28
28
  args: [supplyToken.targetToken, supplyToken.amount, "0", "0"],
29
29
  };
30
- commonSpells.push({
30
+ targetSpells.push({
31
31
  connector: spellData.connector,
32
32
  data: (0, utils_1.encodeConnectorMethod)(spellData),
33
33
  });
34
+ let spellDataBasicWithdraw = {
35
+ connector: "BASIC-A",
36
+ method: "withdraw",
37
+ args: [supplyToken.targetToken, supplyToken.amount, sourceUserAddress, "0", "0"],
38
+ };
39
+ commonSpells.push({
40
+ connector: spellDataBasicWithdraw.connector,
41
+ data: (0, utils_1.encodeConnectorMethod)(spellDataBasicWithdraw),
42
+ });
34
43
  }
35
44
  for (const withdrawToken of position.withdraw) {
36
45
  let spellData = {
package/dist/src/index.js CHANGED
@@ -13,7 +13,7 @@ const package_json_1 = __importDefault(require("../package.json"));
13
13
  dotenv_1.default.config();
14
14
  const logger_1 = __importDefault(require("@/logger"));
15
15
  const logger = new logger_1.default('Process');
16
- const GIT_SHORT_HASH = 'c4e0c91';
16
+ const GIT_SHORT_HASH = 'c696e38';
17
17
  const printUsage = () => {
18
18
  console.log();
19
19
  console.log(`Interop X Node (v${package_json_1.default.version} - rev.${GIT_SHORT_HASH})`);
@@ -0,0 +1,183 @@
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
+ class ProcessValidateEvents extends BaseTask_1.BaseTask {
20
+ constructor({ chainId }) {
21
+ super({
22
+ logger: new logger_1.default("InteropX::ProcessValidateEvents"),
23
+ });
24
+ this.leadNodeOnly = true;
25
+ this.blockConfirmationsCount = 12;
26
+ this.chainId = chainId;
27
+ }
28
+ async pollHandler() {
29
+ var _a;
30
+ const currentBlockNumber = await this.sourceProvider.getBlockNumber();
31
+ const transaction = await db_1.Transaction.findOne({
32
+ where: {
33
+ status: "pending",
34
+ sourceStatus: "success",
35
+ targetStatus: "pending",
36
+ sourceChainId: this.chainId,
37
+ sourceBlockNumber: {
38
+ [sequelize_1.Op.lt]: currentBlockNumber - this.blockConfirmationsCount,
39
+ },
40
+ targetDelayUntil: {
41
+ [sequelize_1.Op.or]: {
42
+ [sequelize_1.Op.is]: null,
43
+ [sequelize_1.Op.lt]: new Date(),
44
+ },
45
+ },
46
+ submitEvent: { $ne: null },
47
+ validateEvent: { $ne: null },
48
+ createdAt: {
49
+ [sequelize_1.Op.gt]: (0, moment_1.default)().subtract({ hours: 12 }).toDate(),
50
+ },
51
+ },
52
+ });
53
+ if (!transaction) {
54
+ return;
55
+ }
56
+ this.logger.debug(`Processing transaction ${transaction.transactionHash}`);
57
+ transaction.targetStatus = "proccessing";
58
+ await transaction.save();
59
+ const { sourceChainId, targetChainId } = transaction.validateEvent;
60
+ const targetProvider = new ethers_1.ethers.providers.JsonRpcProvider((0, utils_1.getRpcProviderUrl)(targetChainId));
61
+ const targetWallet = new ethers_1.ethers.Wallet(config_1.default.privateKey, targetProvider);
62
+ const targetGnosisContract = (0, utils_1.getContract)(constants_1.addresses[targetChainId].gnosisSafe, abi_1.default.gnosisSafe, targetWallet);
63
+ const ownersThreshold = await targetGnosisContract.getThreshold();
64
+ await (0, waait_1.default)(10000);
65
+ this.logger.debug(`Build gnosis action for ${transaction.transactionHash}`);
66
+ let data, logs = [];
67
+ try {
68
+ ({ data, logs } = await (0, gnosis_1.buildGnosisAction)(transaction, "target"));
69
+ }
70
+ catch (error) {
71
+ if (error instanceof utils_1.LiquidityError) {
72
+ await transaction.save();
73
+ transaction.targetDelayUntil = new Date(Date.now() + 60 * 5 * 1000);
74
+ transaction.targetStatus = "pending";
75
+ await transaction.save();
76
+ throw error;
77
+ return;
78
+ }
79
+ transaction.targetStatus = "failed";
80
+ transaction.targetErrors = [error.message];
81
+ transaction.status = "failed";
82
+ await transaction.save();
83
+ net_1.protocol.sendTransaction(transaction);
84
+ return;
85
+ }
86
+ this.logger.debug(`Generating gnosis tx for ${transaction.transactionHash}`);
87
+ let gnosisTx = await (0, utils_1.generateGnosisTransaction)({
88
+ baseGas: "0",
89
+ data,
90
+ gasPrice: "0",
91
+ gasToken: "0x0000000000000000000000000000000000000000",
92
+ nonce: "0",
93
+ operation: "1",
94
+ refundReceiver: "0x0000000000000000000000000000000000000000",
95
+ safeAddress: targetGnosisContract.address,
96
+ safeTxGas: "79668",
97
+ to: constants_1.addresses[transaction.targetChainId].multisend,
98
+ value: "0",
99
+ }, targetGnosisContract);
100
+ const owners = await targetGnosisContract
101
+ .getOwners()
102
+ .then((owners) => owners.map((owner) => owner.toLowerCase()));
103
+ const ownerPeerIds = net_1.peerPool.activePeers
104
+ .filter((peer) => owners.includes(peer.publicAddress.toLowerCase()))
105
+ .map((peer) => peer.id);
106
+ console.log(`Collecting signatures for execution ${transaction.transactionHash}`);
107
+ console.log(ownerPeerIds);
108
+ const signatures = await net_1.protocol.requestSignatures({
109
+ type: "target",
110
+ transactionHash: transaction.transactionHash,
111
+ safeTxGas: gnosisTx.safeTxGas,
112
+ safeNonce: gnosisTx.nonce,
113
+ chainId: targetChainId,
114
+ }, ownerPeerIds);
115
+ const validSignatures = signatures.filter((s) => !!s.data && s.data !== "0x");
116
+ console.log({
117
+ signatures,
118
+ validSignatures,
119
+ ownersThreshold: ownersThreshold.toString(),
120
+ });
121
+ if (validSignatures.length === 0 ||
122
+ ownersThreshold.gt(validSignatures.length)) {
123
+ await transaction.save();
124
+ transaction.targetDelayUntil = new Date(Date.now() + 30 * 1000);
125
+ transaction.targetStatus = "pending";
126
+ await transaction.save();
127
+ const errorMessage = (_a = signatures.find((s) => !!s.error)) === null || _a === void 0 ? void 0 : _a.error;
128
+ throw new Error(`Not enough signatures` + (errorMessage ? `: ${errorMessage}` : ""));
129
+ }
130
+ console.log(`Executing transaction for execution ${transaction.transactionHash}`);
131
+ 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));
132
+ const [gasPrice, gasLimit] = await Promise.all([
133
+ targetProvider.getGasPrice(),
134
+ targetProvider.estimateGas({
135
+ from: targetWallet.address,
136
+ to: targetGnosisContract.address,
137
+ data: txData,
138
+ }),
139
+ ]);
140
+ const txSent = await targetWallet.sendTransaction({
141
+ from: targetWallet.address,
142
+ to: targetGnosisContract.address,
143
+ gasPrice: gasPrice.mul(120).div(100),
144
+ gasLimit: 5000000,
145
+ data: txData,
146
+ });
147
+ console.log(txSent);
148
+ const receipt = await txSent.wait();
149
+ const parsedLogs = [];
150
+ receipt.logs.forEach((log) => {
151
+ try {
152
+ parsedLogs.push(targetGnosisContract.interface.parseLog(log));
153
+ }
154
+ catch (e) { }
155
+ });
156
+ if (parsedLogs.find((e) => e.name === "ExecutionSuccess")) {
157
+ console.log("ExecutionSuccess");
158
+ transaction.targetStatus = "success";
159
+ transaction.status = "success";
160
+ if (txSent.blockNumber)
161
+ transaction.targetBlockNumber = txSent.blockNumber;
162
+ transaction.targetTransactionHash = txSent.hash;
163
+ transaction.targetLogs = logs;
164
+ await transaction.save();
165
+ }
166
+ else {
167
+ console.log("ExecutionFailure");
168
+ transaction.targetStatus = "failed";
169
+ if (txSent.blockNumber)
170
+ transaction.targetBlockNumber = txSent.blockNumber;
171
+ transaction.targetTransactionHash = txSent.hash;
172
+ transaction.status = "failed";
173
+ await transaction.save();
174
+ }
175
+ net_1.protocol.sendTransaction(transaction);
176
+ }
177
+ async start() {
178
+ this.blockConfirmationsCount = constants_1.blockConfirmations[this.chainId] + 1;
179
+ this.sourceProvider = new ethers_1.ethers.providers.JsonRpcProvider((0, utils_1.getRpcProviderUrl)(this.chainId));
180
+ await super.start();
181
+ }
182
+ }
183
+ exports.default = ProcessValidateEvents;
@@ -48,8 +48,8 @@ class SyncLogValidateEvents extends BaseTask_1.BaseTask {
48
48
  if (!transaction) {
49
49
  continue;
50
50
  }
51
- if (transaction.sourceStatus != "confirmed") {
52
- transaction.sourceStatus = "confirmed";
51
+ if (transaction.sourceStatus != "success") {
52
+ transaction.sourceStatus = "success";
53
53
  }
54
54
  if (!transaction.sourceCreatedAt) {
55
55
  transaction.sourceCreatedAt = new Date();
@@ -10,6 +10,7 @@ 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
12
  const SyncLogValidateEvents_1 = __importDefault(require("./InteropX/SyncLogValidateEvents"));
13
+ const ProcessValidateEvents_1 = __importDefault(require("./InteropX/ProcessValidateEvents"));
13
14
  class Tasks {
14
15
  constructor() {
15
16
  this.tasks = [
@@ -22,6 +23,8 @@ class Tasks {
22
23
  new ProcessSubmitSubmitEvents_1.default({ chainId: 43114 }),
23
24
  new SyncLogValidateEvents_1.default({ chainId: 137 }),
24
25
  new SyncLogValidateEvents_1.default({ chainId: 43114 }),
26
+ new ProcessValidateEvents_1.default({ chainId: 137 }),
27
+ new ProcessValidateEvents_1.default({ chainId: 43114 }),
25
28
  new SyncTransactionStatusTask_1.default(),
26
29
  ];
27
30
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@instadapp/interop-x",
3
- "version": "0.0.0-dev.c4e0c91",
3
+ "version": "0.0.0-dev.c696e38",
4
4
  "license": "MIT",
5
5
  "main": "dist/index.js",
6
6
  "engines": {
@@ -8,7 +8,7 @@ export const addresses = {
8
8
  43114: {
9
9
  gnosisSafe: '0x31d7a5194Fe60AC209Cf1Ce2d539C9A60662Ed6b',
10
10
  multisend: '0x998739BFdAAdde7C933B942a68053933098f9EDa',
11
- interopX: '0xd61f55C6d9deD35B9d13243b816c4BcC1d78592b',
11
+ interopX: '0xA82A87096709E3D8648c9d9a22f31133bC4B6d32',
12
12
  dsaAddress: '0xFcB7d826E32081c4799de2f83b47b49df600dc8c',
13
13
  }
14
14
  } as Record<number, { gnosisSafe: string, multisend: string, interopX: string, dsaAddress: string }>
@@ -35,7 +35,7 @@ export default async function (transaction: Transaction) {
35
35
  );
36
36
  const dsaAddress = addresses[targetChainId].dsaAddress;
37
37
  const sourceUserAddress = Number(sourceDsaId) == 0 ? sourceSender : dsaAddress;
38
- const interopAddress = addresses[sourceChainId].interopX;
38
+ const interopAddress = addresses[targetChainId].interopX;
39
39
  const contract = getContract<InteropX>(
40
40
  interopAddress,
41
41
  abi.interopX,
@@ -52,10 +52,21 @@ export default async function (transaction: Transaction) {
52
52
  args: [supplyToken.targetToken, supplyToken.amount, "0", "0"],
53
53
  };
54
54
 
55
- commonSpells.push({
55
+ targetSpells.push({
56
56
  connector: spellData.connector,
57
57
  data: encodeConnectorMethod(spellData),
58
58
  });
59
+
60
+ let spellDataBasicWithdraw = {
61
+ connector: "BASIC-A",
62
+ method: "withdraw",
63
+ args: [supplyToken.targetToken, supplyToken.amount, sourceUserAddress, "0", "0"],
64
+ };
65
+
66
+ commonSpells.push({
67
+ connector: spellDataBasicWithdraw.connector,
68
+ data: encodeConnectorMethod(spellDataBasicWithdraw),
69
+ });
59
70
  }
60
71
 
61
72
  for (const withdrawToken of position.withdraw) {
@@ -0,0 +1,274 @@
1
+ import { BaseTask } from "../BaseTask";
2
+ import Logger from "@/logger";
3
+ import { ethers, Wallet } from "ethers";
4
+ import abi from "@/abi";
5
+ import { Transaction } from "@/db";
6
+ import {
7
+ buildSignatureBytes,
8
+ generateGnosisTransaction,
9
+ generateInteropTransactionHash,
10
+ getContract,
11
+ getRpcProviderUrl,
12
+ LiquidityError,
13
+ Signature,
14
+ } from "@/utils";
15
+ import { addresses, blockConfirmations } from "@/constants";
16
+ import { ChainId } from "@/types";
17
+ import config from "@/config";
18
+ import { GnosisSafe, InteropX } from "@/typechain";
19
+ import moment from "moment";
20
+ import { Op } from "sequelize";
21
+ import { buildGnosisAction } from "@/gnosis";
22
+ import { peerPool, protocol } from "@/net";
23
+ import { LogDescription } from "ethers/lib/utils";
24
+ import wait from "waait";
25
+
26
+ class ProcessValidateEvents extends BaseTask {
27
+ sourceProvider: ethers.providers.JsonRpcProvider;
28
+ chainId: ChainId;
29
+ leadNodeOnly: boolean = true;
30
+ blockConfirmationsCount: number = 12;
31
+
32
+ constructor({ chainId }: { chainId: ChainId }) {
33
+ super({
34
+ logger: new Logger("InteropX::ProcessValidateEvents"),
35
+ });
36
+ this.chainId = chainId;
37
+ }
38
+
39
+ async pollHandler() {
40
+ const currentBlockNumber = await this.sourceProvider.getBlockNumber();
41
+
42
+ const transaction = await Transaction.findOne({
43
+ where: {
44
+ status: "pending",
45
+ sourceStatus: "success",
46
+ targetStatus: "pending",
47
+ sourceChainId: this.chainId,
48
+ sourceBlockNumber: {
49
+ [Op.lt]: currentBlockNumber - this.blockConfirmationsCount,
50
+ },
51
+ targetDelayUntil: {
52
+ [Op.or]: {
53
+ [Op.is]: null,
54
+ [Op.lt]: new Date(),
55
+ },
56
+ },
57
+
58
+ submitEvent: { $ne: null },
59
+ validateEvent: { $ne: null },
60
+
61
+ createdAt: {
62
+ [Op.gt]: moment().subtract({ hours: 12 }).toDate(),
63
+ },
64
+ },
65
+ });
66
+
67
+ if (!transaction) {
68
+ return;
69
+ }
70
+
71
+ this.logger.debug(`Processing transaction ${transaction.transactionHash}`);
72
+
73
+ transaction.targetStatus = "proccessing";
74
+ await transaction.save();
75
+
76
+ const { sourceChainId, targetChainId } = transaction.validateEvent
77
+
78
+ const targetProvider = new ethers.providers.JsonRpcProvider(
79
+ getRpcProviderUrl(targetChainId as ChainId)
80
+ );
81
+
82
+ const targetWallet = new ethers.Wallet(
83
+ config.privateKey!,
84
+ targetProvider
85
+ );
86
+
87
+ const targetGnosisContract = getContract<GnosisSafe>(
88
+ addresses[targetChainId].gnosisSafe,
89
+ abi.gnosisSafe,
90
+ targetWallet
91
+ );
92
+
93
+ const ownersThreshold = await targetGnosisContract.getThreshold();
94
+ await wait(10000);
95
+
96
+ this.logger.debug(`Build gnosis action for ${transaction.transactionHash}`);
97
+
98
+ let data,
99
+ logs = [];
100
+
101
+ try {
102
+ ({ data, logs } = await buildGnosisAction(transaction, "target"));
103
+ } catch (error) {
104
+ if (error instanceof LiquidityError) {
105
+ await transaction.save();
106
+ transaction.targetDelayUntil = new Date(Date.now() + 60 * 5 * 1000);
107
+ transaction.targetStatus = "pending";
108
+
109
+ await transaction.save();
110
+
111
+ throw error;
112
+ return;
113
+ }
114
+
115
+ transaction.targetStatus = "failed";
116
+ transaction.targetErrors = [error.message];
117
+ transaction.status = "failed";
118
+ await transaction.save();
119
+ protocol.sendTransaction(transaction);
120
+ return;
121
+ }
122
+
123
+ this.logger.debug(
124
+ `Generating gnosis tx for ${transaction.transactionHash}`
125
+ );
126
+
127
+ let gnosisTx = await generateGnosisTransaction(
128
+ {
129
+ baseGas: "0",
130
+ data,
131
+ gasPrice: "0",
132
+ gasToken: "0x0000000000000000000000000000000000000000",
133
+ nonce: "0",
134
+ operation: "1",
135
+ refundReceiver: "0x0000000000000000000000000000000000000000",
136
+ safeAddress: targetGnosisContract.address,
137
+ safeTxGas: "79668",
138
+ to: addresses[transaction.targetChainId].multisend,
139
+ value: "0",
140
+ },
141
+ targetGnosisContract
142
+ );
143
+
144
+ const owners = await targetGnosisContract
145
+ .getOwners()
146
+ .then((owners) => owners.map((owner) => owner.toLowerCase()));
147
+
148
+ const ownerPeerIds = peerPool.activePeers
149
+ .filter((peer) => owners.includes(peer.publicAddress.toLowerCase()))
150
+ .map((peer) => peer.id);
151
+
152
+ console.log(
153
+ `Collecting signatures for execution ${transaction.transactionHash}`
154
+ );
155
+
156
+ console.log(ownerPeerIds);
157
+
158
+ const signatures = await protocol.requestSignatures(
159
+ {
160
+ type: "target",
161
+ transactionHash: transaction.transactionHash,
162
+ safeTxGas: gnosisTx.safeTxGas,
163
+ safeNonce: gnosisTx.nonce,
164
+ chainId: targetChainId,
165
+ },
166
+ ownerPeerIds
167
+ );
168
+
169
+ const validSignatures = signatures.filter(
170
+ (s) => !!s.data && s.data !== "0x"
171
+ ) as Signature[];
172
+
173
+ console.log({
174
+ signatures,
175
+ validSignatures,
176
+ ownersThreshold: ownersThreshold.toString(),
177
+ });
178
+
179
+ if (
180
+ validSignatures.length === 0 ||
181
+ ownersThreshold.gt(validSignatures.length)
182
+ ) {
183
+ await transaction.save();
184
+ transaction.targetDelayUntil = new Date(Date.now() + 30 * 1000);
185
+ transaction.targetStatus = "pending";
186
+
187
+ await transaction.save();
188
+ const errorMessage = signatures.find((s) => !!s.error)?.error;
189
+ throw new Error(
190
+ `Not enough signatures` + (errorMessage ? `: ${errorMessage}` : "")
191
+ );
192
+ }
193
+
194
+ console.log(
195
+ `Executing transaction for execution ${transaction.transactionHash}`
196
+ );
197
+
198
+ const { data: txData } =
199
+ await targetGnosisContract.populateTransaction.execTransaction(
200
+ gnosisTx.to,
201
+ gnosisTx.value,
202
+ gnosisTx.data,
203
+ gnosisTx.operation,
204
+ gnosisTx.safeTxGas,
205
+ gnosisTx.baseGas,
206
+ gnosisTx.gasPrice,
207
+ gnosisTx.gasToken,
208
+ gnosisTx.refundReceiver,
209
+ buildSignatureBytes(validSignatures)
210
+ );
211
+
212
+ const [gasPrice, gasLimit] = await Promise.all([
213
+ targetProvider.getGasPrice(),
214
+ targetProvider.estimateGas({
215
+ from: targetWallet.address,
216
+ to: targetGnosisContract.address,
217
+ data: txData,
218
+ }),
219
+ ]);
220
+
221
+ const txSent = await targetWallet.sendTransaction({
222
+ from: targetWallet.address,
223
+ to: targetGnosisContract.address,
224
+ gasPrice: gasPrice.mul(120).div(100),
225
+ gasLimit: 5_000_000,//gasLimit.mul(120).div(100),
226
+ data: txData,
227
+ });
228
+
229
+ console.log(txSent);
230
+
231
+ const receipt = await txSent.wait();
232
+
233
+ const parsedLogs: LogDescription[] = [];
234
+
235
+ receipt.logs.forEach((log) => {
236
+ try {
237
+ parsedLogs.push(targetGnosisContract.interface.parseLog(log));
238
+ } catch (e) { }
239
+ });
240
+
241
+ if (parsedLogs.find((e) => e.name === "ExecutionSuccess")) {
242
+ console.log("ExecutionSuccess");
243
+ transaction.targetStatus = "success";
244
+ transaction.status = "success";
245
+ if (txSent.blockNumber)
246
+ transaction.targetBlockNumber = txSent.blockNumber;
247
+ transaction.targetTransactionHash = txSent.hash;
248
+ transaction.targetLogs = logs;
249
+ await transaction.save();
250
+ } else {
251
+ console.log("ExecutionFailure");
252
+ transaction.targetStatus = "failed";
253
+ if (txSent.blockNumber)
254
+ transaction.targetBlockNumber = txSent.blockNumber;
255
+ transaction.targetTransactionHash = txSent.hash;
256
+ transaction.status = "failed";
257
+ await transaction.save();
258
+ }
259
+
260
+ protocol.sendTransaction(transaction);
261
+ }
262
+
263
+ async start(): Promise<void> {
264
+ this.blockConfirmationsCount = blockConfirmations[this.chainId] + 1;
265
+
266
+ this.sourceProvider = new ethers.providers.JsonRpcProvider(
267
+ getRpcProviderUrl(this.chainId)
268
+ );
269
+
270
+ await super.start();
271
+ }
272
+ }
273
+
274
+ export default ProcessValidateEvents;
@@ -81,8 +81,8 @@ class SyncLogValidateEvents extends BaseTask {
81
81
  continue;
82
82
  }
83
83
 
84
- if (transaction.sourceStatus != "confirmed") {
85
- transaction.sourceStatus = "confirmed";
84
+ if (transaction.sourceStatus != "success") {
85
+ transaction.sourceStatus = "success";
86
86
  }
87
87
 
88
88
  if (!transaction.sourceCreatedAt) {
@@ -8,6 +8,7 @@ import AutoUpdateTask from "./AutoUpdateTask";
8
8
  import SyncLogSubmitEvents from "./InteropX/SyncLogSubmitEvents";
9
9
  import ProcessSubmitSubmitEvents from "./InteropX/ProcessSubmitSubmitEvents";
10
10
  import SyncLogValidateEvents from "./InteropX/SyncLogValidateEvents";
11
+ import ProcessValidateEvents from "./InteropX/ProcessValidateEvents";
11
12
 
12
13
  export class Tasks {
13
14
 
@@ -25,6 +26,9 @@ export class Tasks {
25
26
  new SyncLogValidateEvents({ chainId: 137 }),
26
27
  new SyncLogValidateEvents({ chainId: 43114 }),
27
28
 
29
+ new ProcessValidateEvents({ chainId: 137 }),
30
+ new ProcessValidateEvents({ chainId: 43114 }),
31
+
28
32
  new SyncTransactionStatusTask(),
29
33
  ];
30
34