@instadapp/interop-x 0.0.0-dev.fd6776c → 0.0.0-dev.ffcf753
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/.github/workflows/ci.yml +19 -0
- package/bin/interop-x +1 -1
- package/dist/package.json +76 -0
- package/dist/src/abi/connectors/index.js +36 -0
- package/dist/src/abi/connectors/v1/aave.js +148 -0
- package/dist/src/abi/connectors/v1/aave_claim.js +4 -0
- package/dist/src/abi/connectors/v1/aave_migrate.js +109 -0
- package/dist/src/abi/connectors/v1/aave_polygon_migrate.js +110 -0
- package/dist/src/abi/connectors/v1/aave_stake.js +4 -0
- package/dist/src/abi/connectors/v1/aave_v1_import.js +54 -0
- package/dist/src/abi/connectors/v1/aave_v2.js +230 -0
- package/dist/src/abi/connectors/v1/aave_v2_import.js +59 -0
- package/dist/src/abi/connectors/v1/authority.js +100 -0
- package/dist/src/abi/connectors/v1/basic.js +136 -0
- package/dist/src/abi/connectors/v1/chi.js +36 -0
- package/dist/src/abi/connectors/v1/comp.js +4 -0
- package/dist/src/abi/connectors/v1/compound.js +4 -0
- package/dist/src/abi/connectors/v1/compoundImport.js +69 -0
- package/dist/src/abi/connectors/v1/compoundImport_v2.js +4 -0
- package/dist/src/abi/connectors/v1/compound_old.js +448 -0
- package/dist/src/abi/connectors/v1/curve.js +140 -0
- package/dist/src/abi/connectors/v1/curve_claim.js +63 -0
- package/dist/src/abi/connectors/v1/curve_gauge.js +158 -0
- package/dist/src/abi/connectors/v1/curve_sbtc.js +140 -0
- package/dist/src/abi/connectors/v1/curve_susd.js +140 -0
- package/dist/src/abi/connectors/v1/curve_three.js +79 -0
- package/dist/src/abi/connectors/v1/curve_y.js +140 -0
- package/dist/src/abi/connectors/v1/dsa_migrate_v1_to_v2.js +4 -0
- package/dist/src/abi/connectors/v1/dydx.js +148 -0
- package/dist/src/abi/connectors/v1/dydx_flash.js +52 -0
- package/dist/src/abi/connectors/v1/fee.js +50 -0
- package/dist/src/abi/connectors/v1/gelato.js +1138 -0
- package/dist/src/abi/connectors/v1/index.js +58 -0
- package/dist/src/abi/connectors/v1/instapool.js +439 -0
- package/dist/src/abi/connectors/v1/instapool_v2.js +126 -0
- package/dist/src/abi/connectors/v1/kyber.js +117 -0
- package/dist/src/abi/connectors/v1/maker.js +480 -0
- package/dist/src/abi/connectors/v1/maker_old.js +300 -0
- package/dist/src/abi/connectors/v1/math.js +43 -0
- package/dist/src/abi/connectors/v1/migrate.js +46 -0
- package/dist/src/abi/connectors/v1/oasis.js +198 -0
- package/dist/src/abi/connectors/v1/oneInch.js +160 -0
- package/dist/src/abi/connectors/v1/polygon_bridge.js +4 -0
- package/dist/src/abi/connectors/v1/refinance.js +4 -0
- package/dist/src/abi/connectors/v1/staking.js +220 -0
- package/dist/src/abi/connectors/v1/swerve.js +179 -0
- package/dist/src/abi/connectors/v1/uniswap.js +297 -0
- package/dist/src/abi/connectors/v2/1INCH-A.js +4 -0
- package/dist/src/abi/connectors/v2/1INCH-B.js +4 -0
- package/dist/src/abi/connectors/v2/AAVE-CLAIM-A.js +4 -0
- package/dist/src/abi/connectors/v2/AAVE-CLAIM-B.js +166 -0
- package/dist/src/abi/connectors/v2/AAVE-STAKE-A.js +4 -0
- package/dist/src/abi/connectors/v2/AAVE-V1-A.js +130 -0
- package/dist/src/abi/connectors/v2/AAVE-V1-IMPORT-A.js +4 -0
- package/dist/src/abi/connectors/v2/AAVE-V2-A.js +230 -0
- package/dist/src/abi/connectors/v2/AAVE-V2-IMPORT-A.js +4 -0
- package/dist/src/abi/connectors/v2/AAVE-V2-IMPORT-B.js +225 -0
- package/dist/src/abi/connectors/v2/AUTHORITY-A.js +100 -0
- package/dist/src/abi/connectors/v2/B-COMPOUND-A.js +4 -0
- package/dist/src/abi/connectors/v2/B-LIQUITY-A.js +4 -0
- package/dist/src/abi/connectors/v2/B-MAKERDAO-A.js +4 -0
- package/dist/src/abi/connectors/v2/BASIC-A.js +136 -0
- package/dist/src/abi/connectors/v2/BASIC-B.js +4 -0
- package/dist/src/abi/connectors/v2/BASIC-C.js +4 -0
- package/dist/src/abi/connectors/v2/COMP-A.js +4 -0
- package/dist/src/abi/connectors/v2/COMPOUND-A.js +4 -0
- package/dist/src/abi/connectors/v2/COMPOUND-IMPORT-A.js +4 -0
- package/dist/src/abi/connectors/v2/COMPOUND-IMPORT-B.js +195 -0
- package/dist/src/abi/connectors/v2/G-UNISWAP-A.js +4 -0
- package/dist/src/abi/connectors/v2/GELATO-AAVE-A.js +4 -0
- package/dist/src/abi/connectors/v2/INST-A.js +4 -0
- package/dist/src/abi/connectors/v2/INST-LM-A.js +4 -0
- package/dist/src/abi/connectors/v2/INST-STAKING-A.js +4 -0
- package/dist/src/abi/connectors/v2/INST-STAKING-B.js +4 -0
- package/dist/src/abi/connectors/v2/INSTAPOOL-A.js +4 -0
- package/dist/src/abi/connectors/v2/LIQUITY-A.js +4 -0
- package/dist/src/abi/connectors/v2/MAKERDAO-A.js +4 -0
- package/dist/src/abi/connectors/v2/MAKERDAO-CLAIM-A.js +136 -0
- package/dist/src/abi/connectors/v2/PARASWAP-A.js +4 -0
- package/dist/src/abi/connectors/v2/POLYGON-BRIDGE-A.js +4 -0
- package/dist/src/abi/connectors/v2/REFINANCE-A.js +4 -0
- package/dist/src/abi/connectors/v2/REFLEXER-A.js +4 -0
- package/dist/src/abi/connectors/v2/STAKE-ERC20-A.js +4 -0
- package/dist/src/abi/connectors/v2/UNISWAP-A.js +297 -0
- package/dist/src/abi/connectors/v2/UNISWAP-V2-A.js +4 -0
- package/dist/src/abi/connectors/v2/UNISWAP-V3-A.js +4 -0
- package/dist/src/abi/connectors/v2/UNISWAP-V3-STAKE-A.js +4 -0
- package/dist/src/abi/connectors/v2/WETH-A.js +4 -0
- package/dist/src/abi/connectors/v2/YEARN-VAULT-A.js +4 -0
- package/dist/src/abi/connectors/v2/index.js +89 -0
- package/dist/{abi → src/abi}/erc20.json +0 -0
- package/dist/{abi → src/abi}/gnosisSafe.json +0 -0
- package/dist/{abi → src/abi}/index.js +4 -4
- package/dist/src/abi/interopX.json +1436 -0
- package/dist/src/alias.js +10 -0
- package/dist/src/api/index.js +36 -0
- package/dist/{config → src/config}/index.js +11 -1
- package/dist/src/constants/addresses.js +17 -0
- package/dist/src/constants/blockConfirmations.js +8 -0
- package/dist/{constants → src/constants}/index.js +1 -0
- package/dist/{constants → src/constants}/tokens.js +62 -39
- package/dist/{db → src/db}/index.js +0 -0
- package/dist/{db → src/db}/models/index.js +0 -0
- package/dist/{db → src/db}/models/transaction.js +37 -13
- package/dist/{db → src/db}/sequelize.js +0 -0
- package/dist/src/gnosis/actions/aaveV2/index.js +11 -0
- package/dist/src/gnosis/actions/aaveV2/source.js +73 -0
- package/dist/src/gnosis/actions/aaveV2/target.js +85 -0
- package/dist/src/gnosis/actions/index.js +9 -0
- package/dist/src/gnosis/index.js +20 -0
- package/dist/src/index.js +119 -0
- package/dist/{logger → src/logger}/index.js +0 -0
- package/dist/{net → src/net}/index.js +0 -0
- package/dist/{net → src/net}/peer/index.js +8 -3
- package/dist/{net → src/net}/pool/index.js +32 -9
- package/dist/{net → src/net}/protocol/dial/BaseDialProtocol.js +0 -0
- package/dist/{net → src/net}/protocol/dial/SignatureDialProtocol.js +21 -12
- package/dist/src/net/protocol/dial/TransactionStatusDialProtocol.js +30 -0
- package/dist/{net → src/net}/protocol/index.js +51 -1
- package/dist/src/tasks/AutoUpdateTask.js +70 -0
- package/dist/{tasks → src/tasks}/BaseTask.js +12 -4
- package/dist/src/tasks/InteropX/ProcessSubmitSubmitEvents.js +179 -0
- package/dist/src/tasks/InteropX/ProcessValidateEvents.js +183 -0
- package/dist/src/tasks/InteropX/SyncLogSubmitEvents.js +87 -0
- package/dist/src/tasks/InteropX/SyncLogValidateEvents.js +105 -0
- package/dist/src/tasks/Transactions/SyncTransactionStatusTask.js +58 -0
- package/dist/src/tasks/index.js +43 -0
- package/dist/{typechain → src/typechain}/Erc20.js +0 -0
- package/dist/{typechain → src/typechain}/GnosisSafe.js +0 -0
- package/dist/{typechain/InteropBridgeToken.js → src/typechain/InteropX.js} +0 -0
- package/dist/{typechain → src/typechain}/common.js +0 -0
- package/dist/{typechain → src/typechain}/factories/Erc20__factory.js +0 -0
- package/dist/{typechain → src/typechain}/factories/GnosisSafe__factory.js +0 -0
- package/dist/src/typechain/factories/InteropX__factory.js +1928 -0
- package/dist/src/typechain/factories/index.js +12 -0
- package/dist/{typechain → src/typechain}/index.js +3 -5
- package/dist/{types.js → src/types.js} +0 -0
- package/dist/src/utils/index.js +223 -0
- package/package.json +26 -16
- package/patches/@ethersproject+properties+5.6.0.patch +13 -0
- package/src/abi/connectors/index.ts +14 -0
- package/src/abi/connectors/v1/aave.ts +147 -0
- package/src/abi/connectors/v1/aave_claim.ts +3 -0
- package/src/abi/connectors/v1/aave_migrate.ts +108 -0
- package/src/abi/connectors/v1/aave_polygon_migrate.ts +109 -0
- package/src/abi/connectors/v1/aave_stake.ts +3 -0
- package/src/abi/connectors/v1/aave_v1_import.ts +53 -0
- package/src/abi/connectors/v1/aave_v2.ts +229 -0
- package/src/abi/connectors/v1/aave_v2_import.ts +58 -0
- package/src/abi/connectors/v1/authority.ts +99 -0
- package/src/abi/connectors/v1/basic.ts +135 -0
- package/src/abi/connectors/v1/chi.ts +35 -0
- package/src/abi/connectors/v1/comp.ts +3 -0
- package/src/abi/connectors/v1/compound.ts +3 -0
- package/src/abi/connectors/v1/compoundImport.ts +68 -0
- package/src/abi/connectors/v1/compoundImport_v2.ts +3 -0
- package/src/abi/connectors/v1/compound_old.ts +447 -0
- package/src/abi/connectors/v1/curve.ts +139 -0
- package/src/abi/connectors/v1/curve_claim.ts +62 -0
- package/src/abi/connectors/v1/curve_gauge.ts +157 -0
- package/src/abi/connectors/v1/curve_sbtc.ts +139 -0
- package/src/abi/connectors/v1/curve_susd.ts +139 -0
- package/src/abi/connectors/v1/curve_three.ts +78 -0
- package/src/abi/connectors/v1/curve_y.ts +139 -0
- package/src/abi/connectors/v1/dsa_migrate_v1_to_v2.ts +3 -0
- package/src/abi/connectors/v1/dydx.ts +147 -0
- package/src/abi/connectors/v1/dydx_flash.ts +51 -0
- package/src/abi/connectors/v1/fee.ts +49 -0
- package/src/abi/connectors/v1/gelato.ts +1137 -0
- package/src/abi/connectors/v1/index.ts +42 -0
- package/src/abi/connectors/v1/instapool.ts +438 -0
- package/src/abi/connectors/v1/instapool_v2.ts +125 -0
- package/src/abi/connectors/v1/kyber.ts +116 -0
- package/src/abi/connectors/v1/maker.ts +479 -0
- package/src/abi/connectors/v1/maker_old.ts +299 -0
- package/src/abi/connectors/v1/math.ts +42 -0
- package/src/abi/connectors/v1/migrate.ts +45 -0
- package/src/abi/connectors/v1/oasis.ts +197 -0
- package/src/abi/connectors/v1/oneInch.ts +159 -0
- package/src/abi/connectors/v1/polygon_bridge.ts +3 -0
- package/src/abi/connectors/v1/refinance.ts +3 -0
- package/src/abi/connectors/v1/staking.ts +219 -0
- package/src/abi/connectors/v1/swerve.ts +178 -0
- package/src/abi/connectors/v1/uniswap.ts +297 -0
- package/src/abi/connectors/v2/1INCH-A.ts +3 -0
- package/src/abi/connectors/v2/1INCH-B.ts +3 -0
- package/src/abi/connectors/v2/AAVE-CLAIM-A.ts +3 -0
- package/src/abi/connectors/v2/AAVE-CLAIM-B.ts +165 -0
- package/src/abi/connectors/v2/AAVE-STAKE-A.ts +3 -0
- package/src/abi/connectors/v2/AAVE-V1-A.ts +130 -0
- package/src/abi/connectors/v2/AAVE-V1-IMPORT-A.ts +3 -0
- package/src/abi/connectors/v2/AAVE-V2-A.ts +229 -0
- package/src/abi/connectors/v2/AAVE-V2-IMPORT-A.ts +3 -0
- package/src/abi/connectors/v2/AAVE-V2-IMPORT-B.ts +224 -0
- package/src/abi/connectors/v2/AUTHORITY-A.ts +99 -0
- package/src/abi/connectors/v2/B-COMPOUND-A.ts +3 -0
- package/src/abi/connectors/v2/B-LIQUITY-A.ts +3 -0
- package/src/abi/connectors/v2/B-MAKERDAO-A.ts +3 -0
- package/src/abi/connectors/v2/BASIC-A.ts +135 -0
- package/src/abi/connectors/v2/BASIC-B.ts +3 -0
- package/src/abi/connectors/v2/BASIC-C.ts +3 -0
- package/src/abi/connectors/v2/COMP-A.ts +3 -0
- package/src/abi/connectors/v2/COMPOUND-A.ts +3 -0
- package/src/abi/connectors/v2/COMPOUND-IMPORT-A.ts +3 -0
- package/src/abi/connectors/v2/COMPOUND-IMPORT-B.ts +194 -0
- package/src/abi/connectors/v2/G-UNISWAP-A.ts +3 -0
- package/src/abi/connectors/v2/GELATO-AAVE-A.ts +3 -0
- package/src/abi/connectors/v2/INST-A.ts +3 -0
- package/src/abi/connectors/v2/INST-LM-A.ts +3 -0
- package/src/abi/connectors/v2/INST-STAKING-A.ts +3 -0
- package/src/abi/connectors/v2/INST-STAKING-B.ts +3 -0
- package/src/abi/connectors/v2/INSTAPOOL-A.ts +3 -0
- package/src/abi/connectors/v2/LIQUITY-A.ts +3 -0
- package/src/abi/connectors/v2/MAKERDAO-A.ts +3 -0
- package/src/abi/connectors/v2/MAKERDAO-CLAIM-A.ts +135 -0
- package/src/abi/connectors/v2/PARASWAP-A.ts +3 -0
- package/src/abi/connectors/v2/POLYGON-BRIDGE-A.ts +3 -0
- package/src/abi/connectors/v2/REFINANCE-A.ts +3 -0
- package/src/abi/connectors/v2/REFLEXER-A.ts +3 -0
- package/src/abi/connectors/v2/STAKE-ERC20-A.ts +3 -0
- package/src/abi/connectors/v2/UNISWAP-A.ts +297 -0
- package/src/abi/connectors/v2/UNISWAP-V2-A.ts +3 -0
- package/src/abi/connectors/v2/UNISWAP-V3-A.ts +3 -0
- package/src/abi/connectors/v2/UNISWAP-V3-STAKE-A.ts +3 -0
- package/src/abi/connectors/v2/WETH-A.ts +3 -0
- package/src/abi/connectors/v2/YEARN-VAULT-A.ts +3 -0
- package/src/abi/connectors/v2/index.ts +87 -0
- package/src/abi/index.ts +7 -7
- package/src/abi/interopX.json +1436 -0
- package/src/alias.ts +6 -0
- package/src/api/index.ts +36 -0
- package/src/config/index.ts +11 -1
- package/src/constants/addresses.ts +5 -16
- package/src/constants/blockConfirmations.ts +5 -0
- package/src/constants/index.ts +1 -0
- package/src/constants/tokens.ts +63 -40
- package/src/db/models/transaction.ts +136 -59
- package/src/gnosis/actions/aaveV2/index.ts +9 -0
- package/src/gnosis/actions/aaveV2/source.ts +118 -0
- package/src/gnosis/actions/aaveV2/target.ts +132 -0
- package/src/gnosis/actions/index.ts +5 -0
- package/src/gnosis/index.ts +19 -0
- package/src/index.ts +101 -24
- package/src/net/peer/index.ts +9 -7
- package/src/net/pool/index.ts +41 -11
- package/src/net/protocol/dial/SignatureDialProtocol.ts +24 -13
- package/src/net/protocol/dial/TransactionStatusDialProtocol.ts +33 -0
- package/src/net/protocol/index.ts +67 -1
- package/src/tasks/AutoUpdateTask.ts +82 -0
- package/src/tasks/BaseTask.ts +14 -4
- package/src/tasks/InteropX/ProcessSubmitSubmitEvents.ts +269 -0
- package/src/tasks/InteropX/ProcessValidateEvents.ts +274 -0
- package/src/tasks/InteropX/SyncLogSubmitEvents.ts +139 -0
- package/src/tasks/InteropX/SyncLogValidateEvents.ts +152 -0
- package/src/tasks/Transactions/SyncTransactionStatusTask.ts +70 -0
- package/src/tasks/index.ts +29 -5
- package/src/typechain/InteropX.ts +1216 -0
- package/src/typechain/factories/InteropX__factory.ts +1932 -0
- package/src/typechain/factories/index.ts +1 -2
- package/src/typechain/index.ts +2 -4
- package/src/utils/index.ts +281 -45
- package/tsconfig.json +7 -2
- package/dist/abi/interopBridgeToken.json +0 -286
- package/dist/abi/interopXGateway.json +0 -184
- package/dist/constants/addresses.js +0 -28
- package/dist/index.js +0 -63
- package/dist/tasks/InteropXGateway/SyncDepositEvents.js +0 -79
- package/dist/tasks/index.js +0 -27
- package/dist/typechain/InteropXGateway.js +0 -2
- package/dist/typechain/factories/InteropBridgeToken__factory.js +0 -459
- package/dist/typechain/factories/InteropXGateway__factory.js +0 -265
- package/dist/typechain/factories/index.js +0 -14
- package/dist/utils/index.js +0 -101
- package/src/abi/interopBridgeToken.json +0 -286
- package/src/abi/interopXGateway.json +0 -184
- package/src/tasks/InteropXGateway/SyncDepositEvents.ts +0 -114
- package/src/typechain/InteropBridgeToken.ts +0 -686
- package/src/typechain/InteropXGateway.ts +0 -407
- package/src/typechain/factories/InteropBridgeToken__factory.ts +0 -466
- package/src/typechain/factories/InteropXGateway__factory.ts +0 -272
@@ -0,0 +1,179 @@
|
|
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 ProcessSubmitSubmitEvents extends BaseTask_1.BaseTask {
|
20
|
+
constructor({ chainId }) {
|
21
|
+
super({
|
22
|
+
logger: new logger_1.default("InteropX::ProcessSubmitSubmitEvents"),
|
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: "pending",
|
35
|
+
sourceChainId: this.chainId,
|
36
|
+
submitBlockNumber: {
|
37
|
+
[sequelize_1.Op.lt]: currentBlockNumber - this.blockConfirmationsCount,
|
38
|
+
},
|
39
|
+
sourceDelayUntil: {
|
40
|
+
[sequelize_1.Op.or]: {
|
41
|
+
[sequelize_1.Op.is]: null,
|
42
|
+
[sequelize_1.Op.lt]: new Date(),
|
43
|
+
},
|
44
|
+
},
|
45
|
+
submitEvent: { $ne: null },
|
46
|
+
createdAt: {
|
47
|
+
[sequelize_1.Op.gt]: (0, moment_1.default)().subtract({ hours: 12 }).toDate(),
|
48
|
+
},
|
49
|
+
},
|
50
|
+
});
|
51
|
+
if (!transaction) {
|
52
|
+
return;
|
53
|
+
}
|
54
|
+
this.logger.debug(`Processing transaction ${transaction.transactionHash}`);
|
55
|
+
transaction.sourceStatus = "proccessing";
|
56
|
+
await transaction.save();
|
57
|
+
const ownersThreshold = await this.sourceGnosisContract.getThreshold();
|
58
|
+
await (0, waait_1.default)(10000);
|
59
|
+
this.logger.debug(`Build gnosis action for ${transaction.transactionHash}`);
|
60
|
+
let data, logs = [];
|
61
|
+
try {
|
62
|
+
({ data, logs } = await (0, gnosis_1.buildGnosisAction)(transaction, "source"));
|
63
|
+
}
|
64
|
+
catch (error) {
|
65
|
+
if (error instanceof utils_1.LiquidityError) {
|
66
|
+
await transaction.save();
|
67
|
+
transaction.sourceDelayUntil = new Date(Date.now() + 60 * 5 * 1000);
|
68
|
+
transaction.sourceStatus = "pending";
|
69
|
+
await transaction.save();
|
70
|
+
throw error;
|
71
|
+
return;
|
72
|
+
}
|
73
|
+
transaction.sourceStatus = "failed";
|
74
|
+
transaction.sourceErrors = [error.message];
|
75
|
+
transaction.targetStatus = "failed";
|
76
|
+
transaction.status = "failed";
|
77
|
+
await transaction.save();
|
78
|
+
net_1.protocol.sendTransaction(transaction);
|
79
|
+
return;
|
80
|
+
}
|
81
|
+
this.logger.debug(`Generating gnosis tx for ${transaction.transactionHash}`);
|
82
|
+
let gnosisTx = await (0, utils_1.generateGnosisTransaction)({
|
83
|
+
baseGas: "0",
|
84
|
+
data,
|
85
|
+
gasPrice: "0",
|
86
|
+
gasToken: "0x0000000000000000000000000000000000000000",
|
87
|
+
nonce: "0",
|
88
|
+
operation: "1",
|
89
|
+
refundReceiver: "0x0000000000000000000000000000000000000000",
|
90
|
+
safeAddress: this.sourceGnosisContract.address,
|
91
|
+
safeTxGas: "79668",
|
92
|
+
to: constants_1.addresses[transaction.sourceChainId].multisend,
|
93
|
+
value: "0",
|
94
|
+
}, this.sourceGnosisContract);
|
95
|
+
const owners = await this.sourceGnosisContract
|
96
|
+
.getOwners()
|
97
|
+
.then((owners) => owners.map((owner) => owner.toLowerCase()));
|
98
|
+
const ownerPeerIds = net_1.peerPool.activePeers
|
99
|
+
.filter((peer) => owners.includes(peer.publicAddress.toLowerCase()))
|
100
|
+
.map((peer) => peer.id);
|
101
|
+
console.log(`Collecting signatures for execution ${transaction.transactionHash}`);
|
102
|
+
console.log(ownerPeerIds);
|
103
|
+
const signatures = await net_1.protocol.requestSignatures({
|
104
|
+
type: "source",
|
105
|
+
transactionHash: transaction.transactionHash,
|
106
|
+
safeTxGas: gnosisTx.safeTxGas,
|
107
|
+
safeNonce: gnosisTx.nonce,
|
108
|
+
chainId: this.chainId,
|
109
|
+
}, ownerPeerIds);
|
110
|
+
const validSignatures = signatures.filter((s) => !!s.data && s.data !== "0x");
|
111
|
+
console.log({
|
112
|
+
signatures,
|
113
|
+
validSignatures,
|
114
|
+
ownersThreshold: ownersThreshold.toString(),
|
115
|
+
});
|
116
|
+
if (validSignatures.length === 0 ||
|
117
|
+
ownersThreshold.gt(validSignatures.length)) {
|
118
|
+
await transaction.save();
|
119
|
+
transaction.sourceDelayUntil = new Date(Date.now() + 30 * 1000);
|
120
|
+
transaction.sourceStatus = "pending";
|
121
|
+
await transaction.save();
|
122
|
+
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}` : ""));
|
124
|
+
}
|
125
|
+
console.log(`Executing transaction for execution ${transaction.transactionHash}`);
|
126
|
+
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));
|
127
|
+
const [gasPrice, gasLimit] = await Promise.all([
|
128
|
+
this.sourceProvider.getGasPrice(),
|
129
|
+
this.sourceProvider.estimateGas({
|
130
|
+
from: this.sourceWallet.address,
|
131
|
+
to: this.sourceGnosisContract.address,
|
132
|
+
data: txData,
|
133
|
+
}),
|
134
|
+
]);
|
135
|
+
const txSent = await this.sourceWallet.sendTransaction({
|
136
|
+
from: this.sourceWallet.address,
|
137
|
+
to: this.sourceGnosisContract.address,
|
138
|
+
gasPrice: gasPrice.mul(120).div(100),
|
139
|
+
gasLimit: 5000000,
|
140
|
+
data: txData,
|
141
|
+
});
|
142
|
+
console.log(txSent);
|
143
|
+
const receipt = await txSent.wait();
|
144
|
+
const parsedLogs = [];
|
145
|
+
receipt.logs.forEach((log) => {
|
146
|
+
try {
|
147
|
+
parsedLogs.push(this.sourceGnosisContract.interface.parseLog(log));
|
148
|
+
}
|
149
|
+
catch (e) { }
|
150
|
+
});
|
151
|
+
if (parsedLogs.find((e) => e.name === "ExecutionSuccess")) {
|
152
|
+
console.log("ExecutionSuccess");
|
153
|
+
transaction.sourceStatus = "success";
|
154
|
+
if (txSent.blockNumber)
|
155
|
+
transaction.sourceBlockNumber = txSent.blockNumber;
|
156
|
+
transaction.sourceTransactionHash = txSent.hash;
|
157
|
+
transaction.sourceLogs = logs;
|
158
|
+
await transaction.save();
|
159
|
+
}
|
160
|
+
else {
|
161
|
+
console.log("ExecutionFailure");
|
162
|
+
transaction.sourceStatus = "failed";
|
163
|
+
if (txSent.blockNumber)
|
164
|
+
transaction.sourceBlockNumber = txSent.blockNumber;
|
165
|
+
transaction.sourceTransactionHash = txSent.hash;
|
166
|
+
transaction.status = "failed";
|
167
|
+
await transaction.save();
|
168
|
+
}
|
169
|
+
net_1.protocol.sendTransaction(transaction);
|
170
|
+
}
|
171
|
+
async start() {
|
172
|
+
this.blockConfirmationsCount = constants_1.blockConfirmations[this.chainId] + 1;
|
173
|
+
this.sourceProvider = new ethers_1.ethers.providers.JsonRpcProvider((0, utils_1.getRpcProviderUrl)(this.chainId));
|
174
|
+
this.sourceWallet = new ethers_1.ethers.Wallet(config_1.default.privateKey, this.sourceProvider);
|
175
|
+
this.sourceGnosisContract = (0, utils_1.getContract)(constants_1.addresses[this.chainId].gnosisSafe, abi_1.default.gnosisSafe, this.sourceWallet);
|
176
|
+
await super.start();
|
177
|
+
}
|
178
|
+
}
|
179
|
+
exports.default = ProcessSubmitSubmitEvents;
|
@@ -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;
|
@@ -0,0 +1,87 @@
|
|
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
|
+
class SyncLogSubmitEvents extends BaseTask_1.BaseTask {
|
15
|
+
constructor({ chainId }) {
|
16
|
+
super({
|
17
|
+
logger: new logger_1.default("InteropX::SyncLogSubmitEvents"),
|
18
|
+
});
|
19
|
+
this.chainId = chainId;
|
20
|
+
}
|
21
|
+
async pollHandler() {
|
22
|
+
const currentBlock = await this.provider.getBlockNumber();
|
23
|
+
const events = await this.contract.queryFilter(this.contract.filters.LogSubmit(), currentBlock - 2000, currentBlock);
|
24
|
+
let processedEvents = 0;
|
25
|
+
for (const event of events) {
|
26
|
+
try {
|
27
|
+
if (!event.args) {
|
28
|
+
continue;
|
29
|
+
}
|
30
|
+
const { position, actionId, actionIdHashHash, sourceSender, sourceDsaId, targetDsaId, sourceChainId, targetChainId, vnonce, metadata, } = event.args;
|
31
|
+
const uniqueIdentifier = {
|
32
|
+
actionId,
|
33
|
+
vnonce: vnonce.toString(),
|
34
|
+
sourceSender: sourceSender.toString(),
|
35
|
+
sourceChainId: sourceChainId.toNumber(),
|
36
|
+
targetChainId: targetChainId.toNumber(),
|
37
|
+
sourceDsaId: sourceDsaId.toString(),
|
38
|
+
targetDsaId: targetDsaId.toString(),
|
39
|
+
};
|
40
|
+
let transactionHash = (0, utils_1.generateInteropTransactionHash)(uniqueIdentifier);
|
41
|
+
const transaction = await db_1.Transaction.findOne({
|
42
|
+
where: { transactionHash },
|
43
|
+
});
|
44
|
+
if (transaction) {
|
45
|
+
continue;
|
46
|
+
}
|
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
|
+
actionId,
|
49
|
+
actionIdHashHash,
|
50
|
+
actionIdHash: actionIdHashHash,
|
51
|
+
vnonce: vnonce.toString(),
|
52
|
+
position: {
|
53
|
+
withdraw: position.withdraw.map((v) => ({
|
54
|
+
sourceToken: v.sourceToken,
|
55
|
+
targetToken: v.targetToken,
|
56
|
+
amount: v.amount.toString(),
|
57
|
+
})),
|
58
|
+
supply: position.supply.map((v) => ({
|
59
|
+
sourceToken: v.sourceToken,
|
60
|
+
targetToken: v.targetToken,
|
61
|
+
amount: v.amount.toString(),
|
62
|
+
})),
|
63
|
+
},
|
64
|
+
sourceChainId: sourceChainId.toNumber(),
|
65
|
+
targetChainId: targetChainId.toNumber(),
|
66
|
+
sourceSender,
|
67
|
+
sourceDsaId: sourceDsaId.toString(),
|
68
|
+
targetDsaId: targetDsaId.toString(),
|
69
|
+
metadata,
|
70
|
+
} }));
|
71
|
+
this.logger.info(`New InteropX tranaction: ${transactionHash} `);
|
72
|
+
}
|
73
|
+
catch (error) {
|
74
|
+
this.logger.error(error);
|
75
|
+
}
|
76
|
+
}
|
77
|
+
if (processedEvents > 0)
|
78
|
+
this.logger.info(`${processedEvents} events processed`);
|
79
|
+
}
|
80
|
+
async start() {
|
81
|
+
this.contractAddress = constants_1.addresses[this.chainId].interopX;
|
82
|
+
this.provider = new ethers_1.ethers.providers.JsonRpcProvider((0, utils_1.getRpcProviderUrl)(this.chainId));
|
83
|
+
this.contract = (0, utils_1.getContract)(this.contractAddress, abi_1.default.interopX, new ethers_1.ethers.Wallet(config_1.default.privateKey, this.provider));
|
84
|
+
await super.start();
|
85
|
+
}
|
86
|
+
}
|
87
|
+
exports.default = SyncLogSubmitEvents;
|
@@ -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;
|
@@ -0,0 +1,58 @@
|
|
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 net_1 = require("@/net");
|
9
|
+
const db_1 = require("@/db");
|
10
|
+
const sequelize_1 = require("sequelize");
|
11
|
+
class SyncTransactionStatusTask extends BaseTask_1.BaseTask {
|
12
|
+
constructor() {
|
13
|
+
super({
|
14
|
+
logger: new logger_1.default("SyncTransactionStatusTask"),
|
15
|
+
});
|
16
|
+
this.pollIntervalMs = 60 * 1000;
|
17
|
+
this.exceptLeadNode = true;
|
18
|
+
}
|
19
|
+
async pollHandler() {
|
20
|
+
// if transaction is pending for more than 1 hour, check lead node for status
|
21
|
+
const leadNode = net_1.peerPool.getLeadPeer();
|
22
|
+
if (!leadNode) {
|
23
|
+
console.log("No lead node found");
|
24
|
+
return;
|
25
|
+
}
|
26
|
+
const transaction = await db_1.Transaction.findOne({
|
27
|
+
where: {
|
28
|
+
status: {
|
29
|
+
[sequelize_1.Op.notIn]: ['success', 'failed'],
|
30
|
+
},
|
31
|
+
createdAt: {
|
32
|
+
[sequelize_1.Op.lt]: new Date(Date.now() - 15 * 60 * 1000),
|
33
|
+
},
|
34
|
+
}
|
35
|
+
});
|
36
|
+
if (!transaction) {
|
37
|
+
return;
|
38
|
+
}
|
39
|
+
this.logger.info(`Requesting transaction status for ${transaction.transactionHash}`);
|
40
|
+
const transactionStatus = await net_1.protocol.requestTransactionStatus(transaction.transactionHash, leadNode.id);
|
41
|
+
if (!transactionStatus) {
|
42
|
+
return;
|
43
|
+
}
|
44
|
+
this.logger.info(`Received transaction status for ${transaction.transactionHash}`);
|
45
|
+
transaction.sourceStatus = transactionStatus.sourceStatus;
|
46
|
+
transaction.sourceTransactionHash = transactionStatus.sourceTransactionHash;
|
47
|
+
transaction.sourceErrors = transactionStatus.sourceErrors;
|
48
|
+
transaction.sourceLogs = transactionStatus.sourceLogs;
|
49
|
+
transaction.targetStatus = transactionStatus.targetStatus;
|
50
|
+
transaction.targetTransactionHash = transactionStatus.targetTransactionHash;
|
51
|
+
transaction.targetErrors = transactionStatus.targetErrors;
|
52
|
+
transaction.targetLogs = transactionStatus.targetLogs;
|
53
|
+
transaction.status = transactionStatus.status;
|
54
|
+
await transaction.save();
|
55
|
+
this.logger.info(`Updated transaction status for ${transaction.transactionHash}`);
|
56
|
+
}
|
57
|
+
}
|
58
|
+
exports.default = SyncTransactionStatusTask;
|
@@ -0,0 +1,43 @@
|
|
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
|
+
exports.Tasks = void 0;
|
7
|
+
const waait_1 = __importDefault(require("waait"));
|
8
|
+
const SyncTransactionStatusTask_1 = __importDefault(require("./Transactions/SyncTransactionStatusTask"));
|
9
|
+
const AutoUpdateTask_1 = __importDefault(require("./AutoUpdateTask"));
|
10
|
+
const SyncLogSubmitEvents_1 = __importDefault(require("./InteropX/SyncLogSubmitEvents"));
|
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
|
+
class Tasks {
|
15
|
+
constructor() {
|
16
|
+
this.tasks = [
|
17
|
+
// new SyncTransactionStatusTask(),
|
18
|
+
new AutoUpdateTask_1.default(),
|
19
|
+
// InteropX
|
20
|
+
new SyncLogSubmitEvents_1.default({ chainId: 137 }),
|
21
|
+
new SyncLogSubmitEvents_1.default({ chainId: 43114 }),
|
22
|
+
new ProcessSubmitSubmitEvents_1.default({ chainId: 137 }),
|
23
|
+
new ProcessSubmitSubmitEvents_1.default({ chainId: 43114 }),
|
24
|
+
new SyncLogValidateEvents_1.default({ chainId: 137 }),
|
25
|
+
new SyncLogValidateEvents_1.default({ chainId: 43114 }),
|
26
|
+
new ProcessValidateEvents_1.default({ chainId: 137 }),
|
27
|
+
new ProcessValidateEvents_1.default({ chainId: 43114 }),
|
28
|
+
new SyncTransactionStatusTask_1.default(),
|
29
|
+
];
|
30
|
+
}
|
31
|
+
async start() {
|
32
|
+
for (const task of this.tasks) {
|
33
|
+
try {
|
34
|
+
task.start();
|
35
|
+
await (0, waait_1.default)(1000);
|
36
|
+
}
|
37
|
+
catch (error) {
|
38
|
+
console.error(`Error starting task: ${task.constructor.name}`);
|
39
|
+
}
|
40
|
+
}
|
41
|
+
}
|
42
|
+
}
|
43
|
+
exports.Tasks = Tasks;
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|