@instadapp/interop-x 0.0.0-dev.a861339 → 0.0.0-dev.a9047d2
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/dist/package.json +22 -12
- package/dist/src/abi/aaveV2Resolver.json +832 -0
- package/dist/src/abi/aaveV3Resolver.json +628 -0
- package/dist/src/abi/balanceResolver.json +211 -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/src/abi/index.js +12 -2
- package/dist/src/abi/instList.json +232 -0
- package/dist/src/abi/interopX.json +1436 -0
- package/dist/src/api/index.js +8 -1
- package/dist/src/constants/addresses.js +12 -7
- package/dist/src/constants/blockConfirmations.js +8 -0
- package/dist/src/constants/capPerChain.js +8 -0
- package/dist/src/constants/index.js +3 -0
- package/dist/src/constants/tokens.js +30 -7
- 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 +26 -18
- package/dist/src/errors/index.js +30 -0
- package/dist/src/gnosis/actions/aaveV2/index.js +11 -0
- package/dist/src/gnosis/actions/aaveV2/source.js +100 -0
- package/dist/src/gnosis/actions/aaveV2/target.js +101 -0
- package/dist/src/gnosis/actions/aaveV3/index.js +11 -0
- package/dist/src/gnosis/actions/aaveV3/source.js +74 -0
- package/dist/src/gnosis/actions/aaveV3/target.js +87 -0
- package/dist/src/gnosis/actions/index.js +4 -2
- package/dist/src/gnosis/index.js +3 -3
- package/dist/src/index.js +2 -1
- package/dist/src/net/protocol/dial/SignatureDialProtocol.js +2 -2
- 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/ProcessSubmitEvents.js +273 -0
- package/dist/src/tasks/InteropX/ProcessValidateEvents.js +203 -0
- package/dist/src/tasks/InteropX/SyncLogExecuteEvents.js +113 -0
- package/dist/src/tasks/{InteropXContract/SyncBridgeRequestEvents.js → InteropX/SyncLogSubmitEvents.js} +28 -18
- package/dist/src/tasks/InteropX/SyncLogValidateEvents.js +106 -0
- package/dist/src/tasks/Transactions/SyncTransactionStatusTask.js +6 -3
- package/dist/src/tasks/index.js +19 -12
- package/dist/src/typechain/{InteropXContract.js → AaveV2Resolver.js} +0 -0
- package/dist/src/typechain/AaveV3Resolver.js +2 -0
- package/dist/src/typechain/BalanceResolver.js +2 -0
- package/dist/src/typechain/InstList.js +2 -0
- package/dist/src/typechain/InteropX.js +2 -0
- package/dist/src/typechain/factories/AaveV2Resolver__factory.js +1191 -0
- package/dist/src/typechain/factories/AaveV3Resolver__factory.js +887 -0
- package/dist/src/typechain/factories/BalanceResolver__factory.js +228 -0
- package/dist/src/typechain/factories/InstList__factory.js +249 -0
- package/dist/src/typechain/factories/InteropX__factory.js +1928 -0
- package/dist/src/typechain/factories/index.js +11 -3
- package/dist/src/typechain/index.js +11 -3
- 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 +87 -0
- package/dist/src/utils/http.js +10 -0
- package/dist/src/utils/index.js +22 -165
- package/dist/src/utils/interop.js +16 -0
- package/dist/src/utils/tokens.js +22 -0
- package/dist/src/utils/validate.js +107 -0
- package/dist/src/utils/web3.js +93 -0
- package/package.json +22 -12
- package/src/abi/aaveV2Resolver.json +832 -0
- package/src/abi/aaveV3Resolver.json +628 -0
- package/src/abi/balanceResolver.json +211 -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 +15 -5
- package/src/abi/instList.json +232 -0
- package/src/abi/interopX.json +1436 -0
- package/src/api/index.ts +9 -1
- package/src/constants/addresses.ts +24 -8
- package/src/constants/blockConfirmations.ts +5 -0
- package/src/constants/capPerChain.ts +5 -0
- package/src/constants/index.ts +3 -0
- package/src/constants/tokens.ts +31 -8
- 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 +147 -98
- package/src/errors/index.ts +26 -0
- package/src/gnosis/actions/aaveV2/index.ts +9 -0
- package/src/gnosis/actions/aaveV2/source.ts +183 -0
- package/src/gnosis/actions/aaveV2/target.ts +168 -0
- package/src/gnosis/actions/aaveV3/index.ts +9 -0
- package/src/gnosis/actions/aaveV3/source.ts +119 -0
- package/src/gnosis/actions/aaveV3/target.ts +142 -0
- package/src/gnosis/actions/index.ts +4 -2
- package/src/gnosis/index.ts +3 -3
- package/src/index.ts +1 -0
- package/src/net/protocol/dial/SignatureDialProtocol.ts +3 -2
- 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/ProcessSubmitEvents.ts +385 -0
- package/src/tasks/InteropX/ProcessValidateEvents.ts +297 -0
- package/src/tasks/InteropX/SyncLogExecuteEvents.ts +161 -0
- package/src/tasks/InteropX/SyncLogSubmitEvents.ts +138 -0
- package/src/tasks/InteropX/SyncLogValidateEvents.ts +151 -0
- package/src/tasks/Transactions/SyncTransactionStatusTask.ts +6 -3
- package/src/tasks/index.ts +20 -12
- package/src/typechain/AaveV2Resolver.ts +1017 -0
- package/src/typechain/AaveV3Resolver.ts +935 -0
- package/src/typechain/BalanceResolver.ts +266 -0
- package/src/typechain/InstList.ts +402 -0
- package/src/typechain/InteropX.ts +1216 -0
- package/src/typechain/factories/AaveV2Resolver__factory.ts +1198 -0
- package/src/typechain/factories/AaveV3Resolver__factory.ts +894 -0
- package/src/typechain/factories/BalanceResolver__factory.ts +235 -0
- package/src/typechain/factories/InstList__factory.ts +253 -0
- package/src/typechain/factories/InteropX__factory.ts +1932 -0
- package/src/typechain/factories/index.ts +5 -1
- package/src/typechain/index.ts +10 -2
- 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 +166 -0
- package/src/utils/http.ts +6 -0
- package/src/utils/index.ts +9 -240
- package/src/utils/interop.ts +28 -0
- package/src/utils/tokens.ts +21 -0
- package/src/utils/validate.ts +171 -0
- package/src/utils/web3.ts +132 -0
- package/dist/src/abi/interopXContract.json +0 -391
- package/dist/src/gnosis/actions/withdraw/index.js +0 -41
- package/dist/src/tasks/InteropXContract/ProcessBridgeRequestEvents.js +0 -147
- package/dist/src/tasks/InteropXContract/SyncBridgeRequestSentEvents.js +0 -80
- package/dist/src/typechain/factories/InteropXContract__factory.js +0 -526
- package/src/abi/interopXContract.json +0 -391
- package/src/gnosis/actions/withdraw/index.ts +0 -56
- package/src/tasks/InteropXContract/ProcessBridgeRequestEvents.ts +0 -211
- package/src/tasks/InteropXContract/SyncBridgeRequestEvents.ts +0 -116
- package/src/tasks/InteropXContract/SyncBridgeRequestSentEvents.ts +0 -112
- package/src/typechain/InteropXContract.ts +0 -524
- package/src/typechain/factories/InteropXContract__factory.ts +0 -533
@@ -0,0 +1,203 @@
|
|
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
|
+
const providers_1 = require("@/providers");
|
21
|
+
class ProcessValidateEvents extends BaseTask_1.BaseTask {
|
22
|
+
constructor({ chainId }) {
|
23
|
+
super({
|
24
|
+
logger: new logger_1.default("InteropX::ProcessValidateEvents"),
|
25
|
+
});
|
26
|
+
this.leadNodeOnly = true;
|
27
|
+
this.blockConfirmationsCount = 12;
|
28
|
+
this.chainId = chainId;
|
29
|
+
}
|
30
|
+
async pollHandler() {
|
31
|
+
var _a;
|
32
|
+
const currentBlockNumber = await this.sourceProvider.getBlockNumber();
|
33
|
+
const transaction = await db_1.Transaction.findOne({
|
34
|
+
where: {
|
35
|
+
status: "pending",
|
36
|
+
sourceStatus: "success",
|
37
|
+
targetStatus: "pending",
|
38
|
+
sourceChainId: this.chainId,
|
39
|
+
sourceBlockNumber: {
|
40
|
+
[sequelize_1.Op.lt]: currentBlockNumber - this.blockConfirmationsCount,
|
41
|
+
},
|
42
|
+
targetDelayUntil: {
|
43
|
+
[sequelize_1.Op.or]: {
|
44
|
+
[sequelize_1.Op.is]: null,
|
45
|
+
[sequelize_1.Op.lt]: new Date(),
|
46
|
+
},
|
47
|
+
},
|
48
|
+
submitEvent: { $ne: null },
|
49
|
+
validateEvent: { $ne: null },
|
50
|
+
createdAt: {
|
51
|
+
[sequelize_1.Op.gt]: (0, moment_1.default)().subtract({ hours: 12 }).toDate(),
|
52
|
+
},
|
53
|
+
},
|
54
|
+
});
|
55
|
+
if (!transaction) {
|
56
|
+
return;
|
57
|
+
}
|
58
|
+
this.logger.debug(`Processing transaction ${transaction.transactionHash}`);
|
59
|
+
transaction.targetStatus = "proccessing";
|
60
|
+
await transaction.save();
|
61
|
+
const { sourceChainId, targetChainId } = transaction.validateEvent;
|
62
|
+
const targetProvider = new providers_1.JsonRpcRetryProvider((0, utils_1.getRpcProviderUrl)(targetChainId));
|
63
|
+
const targetWallet = new ethers_1.ethers.Wallet(config_1.default.privateKey, targetProvider);
|
64
|
+
const targetGnosisContract = (0, utils_1.getContract)(constants_1.addresses[targetChainId].gnosisSafe, abi_1.default.gnosisSafe, targetWallet);
|
65
|
+
const ownersThreshold = await targetGnosisContract.getThreshold();
|
66
|
+
await (0, waait_1.default)(10000);
|
67
|
+
this.logger.debug(`Build gnosis action for ${transaction.transactionHash}`);
|
68
|
+
let data, logs = [];
|
69
|
+
try {
|
70
|
+
({ data, logs } = await (0, gnosis_1.buildGnosisAction)(transaction, "target"));
|
71
|
+
}
|
72
|
+
catch (error) {
|
73
|
+
if (error instanceof errors_1.LiquidityError) {
|
74
|
+
await transaction.save();
|
75
|
+
transaction.targetDelayUntil = new Date(Date.now() + 60 * 5 * 1000);
|
76
|
+
transaction.targetStatus = "pending";
|
77
|
+
await transaction.save();
|
78
|
+
throw error;
|
79
|
+
return;
|
80
|
+
}
|
81
|
+
transaction.targetStatus = "failed";
|
82
|
+
transaction.targetErrors = [error.message];
|
83
|
+
transaction.status = "failed";
|
84
|
+
await transaction.save();
|
85
|
+
net_1.protocol.sendTransaction(transaction);
|
86
|
+
return;
|
87
|
+
}
|
88
|
+
this.logger.debug(`Generating gnosis tx for ${transaction.transactionHash}`);
|
89
|
+
let gnosisTx = await (0, utils_1.generateGnosisTransaction)({
|
90
|
+
baseGas: "0",
|
91
|
+
data,
|
92
|
+
gasPrice: "0",
|
93
|
+
gasToken: "0x0000000000000000000000000000000000000000",
|
94
|
+
nonce: "0",
|
95
|
+
operation: "1",
|
96
|
+
refundReceiver: "0x0000000000000000000000000000000000000000",
|
97
|
+
safeAddress: targetGnosisContract.address,
|
98
|
+
safeTxGas: "79668",
|
99
|
+
to: constants_1.addresses[transaction.targetChainId].multisend,
|
100
|
+
value: "0",
|
101
|
+
}, targetGnosisContract);
|
102
|
+
const ownerPeerIds = await (0, utils_1.getGnosisOwnerPeerIds)({
|
103
|
+
gnosisContract: targetGnosisContract,
|
104
|
+
});
|
105
|
+
console.log(`Collecting signatures for execution ${transaction.transactionHash}`);
|
106
|
+
console.log(ownerPeerIds);
|
107
|
+
const message = (0, utils_1.generateGnosisSignatureMessage)({
|
108
|
+
to: constants_1.addresses[targetChainId].multisend,
|
109
|
+
data,
|
110
|
+
chainId: targetChainId,
|
111
|
+
safeTxGas: gnosisTx.safeTxGas,
|
112
|
+
nonce: gnosisTx.safeNonce,
|
113
|
+
});
|
114
|
+
const signatures = await net_1.protocol.requestSignatures({
|
115
|
+
type: "target",
|
116
|
+
transactionHash: transaction.transactionHash,
|
117
|
+
safeTxGas: gnosisTx.safeTxGas,
|
118
|
+
safeNonce: gnosisTx.nonce,
|
119
|
+
chainId: targetChainId,
|
120
|
+
}, ownerPeerIds);
|
121
|
+
const validSignatures = signatures
|
122
|
+
.filter((s) => !!s.data && s.data !== "0x")
|
123
|
+
.filter((s) => {
|
124
|
+
try {
|
125
|
+
const address = (0, utils_1.getGnosisSignatureAddress)({
|
126
|
+
message,
|
127
|
+
signature: s.data,
|
128
|
+
chainId: targetChainId,
|
129
|
+
});
|
130
|
+
return (address === null || address === void 0 ? void 0 : address.toLowerCase()) === s.signer.toLowerCase();
|
131
|
+
}
|
132
|
+
catch (error) {
|
133
|
+
return false;
|
134
|
+
}
|
135
|
+
});
|
136
|
+
console.log({
|
137
|
+
signatures,
|
138
|
+
validSignatures,
|
139
|
+
ownersThreshold: ownersThreshold.toString(),
|
140
|
+
});
|
141
|
+
if (validSignatures.length === 0 ||
|
142
|
+
ownersThreshold.gt(validSignatures.length)) {
|
143
|
+
await transaction.save();
|
144
|
+
transaction.targetDelayUntil = new Date(Date.now() + 30 * 1000);
|
145
|
+
transaction.targetStatus = "pending";
|
146
|
+
await transaction.save();
|
147
|
+
const errorMessage = (_a = signatures.find((s) => !!s.error)) === null || _a === void 0 ? void 0 : _a.error;
|
148
|
+
throw new Error(`Not enough signatures` + (errorMessage ? `: ${errorMessage}` : ""));
|
149
|
+
}
|
150
|
+
console.log(`Executing transaction for execution ${transaction.transactionHash}`);
|
151
|
+
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));
|
152
|
+
const [gasPrice, gasLimit] = await Promise.all([
|
153
|
+
targetProvider.getGasPrice(),
|
154
|
+
targetProvider.estimateGas({
|
155
|
+
from: targetWallet.address,
|
156
|
+
to: targetGnosisContract.address,
|
157
|
+
data: txData,
|
158
|
+
}),
|
159
|
+
]);
|
160
|
+
const txSent = await targetWallet.sendTransaction({
|
161
|
+
from: targetWallet.address,
|
162
|
+
to: targetGnosisContract.address,
|
163
|
+
gasPrice: gasPrice.mul(120).div(100),
|
164
|
+
gasLimit: 5000000,
|
165
|
+
data: txData,
|
166
|
+
});
|
167
|
+
console.log(txSent);
|
168
|
+
const receipt = await txSent.wait();
|
169
|
+
const parsedLogs = [];
|
170
|
+
receipt.logs.forEach((log) => {
|
171
|
+
try {
|
172
|
+
parsedLogs.push(targetGnosisContract.interface.parseLog(log));
|
173
|
+
}
|
174
|
+
catch (e) { }
|
175
|
+
});
|
176
|
+
if (parsedLogs.find((e) => e.name === "ExecutionSuccess")) {
|
177
|
+
console.log("ExecutionSuccess");
|
178
|
+
transaction.targetStatus = "success";
|
179
|
+
transaction.status = "success";
|
180
|
+
if (txSent.blockNumber)
|
181
|
+
transaction.targetBlockNumber = txSent.blockNumber;
|
182
|
+
transaction.targetTransactionHash = txSent.hash;
|
183
|
+
transaction.targetLogs = logs;
|
184
|
+
await transaction.save();
|
185
|
+
}
|
186
|
+
else {
|
187
|
+
console.log("ExecutionFailure");
|
188
|
+
transaction.targetStatus = "failed";
|
189
|
+
if (txSent.blockNumber)
|
190
|
+
transaction.targetBlockNumber = txSent.blockNumber;
|
191
|
+
transaction.targetTransactionHash = txSent.hash;
|
192
|
+
transaction.status = "failed";
|
193
|
+
await transaction.save();
|
194
|
+
}
|
195
|
+
net_1.protocol.sendTransaction(transaction);
|
196
|
+
}
|
197
|
+
async start() {
|
198
|
+
this.blockConfirmationsCount = constants_1.blockConfirmations[this.chainId] + 1;
|
199
|
+
this.sourceProvider = new providers_1.JsonRpcRetryProvider((0, utils_1.getRpcProviderUrl)(this.chainId));
|
200
|
+
await super.start();
|
201
|
+
}
|
202
|
+
}
|
203
|
+
exports.default = ProcessValidateEvents;
|
@@ -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,55 +11,65 @@ 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
|
-
|
14
|
+
const providers_1 = require("@/providers");
|
15
|
+
class SyncLogSubmitEvents extends BaseTask_1.BaseTask {
|
15
16
|
constructor({ chainId }) {
|
16
17
|
super({
|
17
|
-
logger: new logger_1.default("
|
18
|
+
logger: new logger_1.default("InteropX::SyncLogSubmitEvents"),
|
18
19
|
});
|
19
20
|
this.chainId = chainId;
|
20
21
|
}
|
21
22
|
async pollHandler() {
|
22
23
|
const currentBlock = await this.provider.getBlockNumber();
|
23
|
-
const events = await this.contract.queryFilter(this.contract.filters.
|
24
|
+
const events = await this.contract.queryFilter(this.contract.filters.LogSubmit(), currentBlock - 2000, currentBlock);
|
24
25
|
let processedEvents = 0;
|
25
26
|
for (const event of events) {
|
26
27
|
try {
|
27
28
|
if (!event.args) {
|
28
29
|
continue;
|
29
30
|
}
|
30
|
-
const {
|
31
|
+
const { position, actionId, actionIdHashHash, sourceSender, sourceDsaId, targetDsaId, sourceChainId, targetChainId, vnonce, metadata, } = event.args;
|
31
32
|
const uniqueIdentifier = {
|
32
|
-
|
33
|
-
|
34
|
-
|
33
|
+
actionId,
|
34
|
+
vnonce: vnonce.toString(),
|
35
|
+
sourceSender: sourceSender.toString(),
|
35
36
|
sourceChainId: sourceChainId.toNumber(),
|
36
37
|
targetChainId: targetChainId.toNumber(),
|
38
|
+
sourceDsaId: sourceDsaId.toString(),
|
39
|
+
targetDsaId: targetDsaId.toString(),
|
37
40
|
};
|
38
41
|
let transactionHash = (0, utils_1.generateInteropTransactionHash)(uniqueIdentifier);
|
39
|
-
const transaction = await db_1.Transaction.findOne({
|
42
|
+
const transaction = await db_1.Transaction.findOne({
|
43
|
+
where: { transactionHash },
|
44
|
+
});
|
40
45
|
if (transaction) {
|
41
46
|
continue;
|
42
47
|
}
|
43
|
-
await db_1.Transaction.create(Object.assign(Object.assign({ transactionHash }, uniqueIdentifier), {
|
44
|
-
|
45
|
-
|
48
|
+
await db_1.Transaction.create(Object.assign(Object.assign({ transactionHash }, uniqueIdentifier), { submitChainId: this.chainId, submitTransactionHash: event.transactionHash, submitBlockNumber: event.blockNumber, submitCreatedAt: new Date(), submitEvent: {
|
49
|
+
actionId,
|
50
|
+
actionIdHashHash,
|
51
|
+
actionIdHash: actionIdHashHash,
|
52
|
+
vnonce: vnonce.toString(),
|
46
53
|
position: {
|
47
54
|
withdraw: position.withdraw.map((v) => ({
|
48
55
|
sourceToken: v.sourceToken,
|
49
56
|
targetToken: v.targetToken,
|
50
|
-
amount: v.amount.toString()
|
57
|
+
amount: v.amount.toString(),
|
51
58
|
})),
|
52
59
|
supply: position.supply.map((v) => ({
|
53
60
|
sourceToken: v.sourceToken,
|
54
61
|
targetToken: v.targetToken,
|
55
|
-
amount: v.amount.toString()
|
62
|
+
amount: v.amount.toString(),
|
56
63
|
})),
|
57
64
|
},
|
58
65
|
sourceChainId: sourceChainId.toNumber(),
|
59
66
|
targetChainId: targetChainId.toNumber(),
|
67
|
+
sourceSender,
|
68
|
+
sourceDsaId: sourceDsaId.toString(),
|
69
|
+
targetDsaId: targetDsaId.toString(),
|
60
70
|
metadata,
|
61
71
|
} }));
|
62
|
-
this.logger.info(`New
|
72
|
+
this.logger.info(`New InteropX tranaction: ${transactionHash} `);
|
63
73
|
}
|
64
74
|
catch (error) {
|
65
75
|
this.logger.error(error);
|
@@ -69,10 +79,10 @@ class SyncBridgeRequestEvents extends BaseTask_1.BaseTask {
|
|
69
79
|
this.logger.info(`${processedEvents} events processed`);
|
70
80
|
}
|
71
81
|
async start() {
|
72
|
-
this.contractAddress = constants_1.addresses[this.chainId].
|
73
|
-
this.provider = new
|
74
|
-
this.contract = (0, utils_1.getContract)(this.contractAddress, abi_1.default.
|
82
|
+
this.contractAddress = constants_1.addresses[this.chainId].interopX;
|
83
|
+
this.provider = new providers_1.JsonRpcRetryProvider((0, utils_1.getRpcProviderUrl)(this.chainId));
|
84
|
+
this.contract = (0, utils_1.getContract)(this.contractAddress, abi_1.default.interopX, new ethers_1.ethers.Wallet(config_1.default.privateKey, this.provider));
|
75
85
|
await super.start();
|
76
86
|
}
|
77
87
|
}
|
78
|
-
exports.default =
|
88
|
+
exports.default = SyncLogSubmitEvents;
|
@@ -0,0 +1,106 @@
|
|
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 SyncLogValidateEvents extends BaseTask_1.BaseTask {
|
17
|
+
constructor({ chainId }) {
|
18
|
+
super({
|
19
|
+
logger: new logger_1.default("InteropX::SyncLogValidateEvents"),
|
20
|
+
});
|
21
|
+
this.chainId = chainId;
|
22
|
+
}
|
23
|
+
async pollHandler() {
|
24
|
+
const currentBlock = await this.provider.getBlockNumber();
|
25
|
+
const events = await this.contract.queryFilter(this.contract.filters.LogValidate(), 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, 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
|
+
validateEvent: { [sequelize_1.Op.eq]: null },
|
47
|
+
},
|
48
|
+
});
|
49
|
+
if (!transaction) {
|
50
|
+
continue;
|
51
|
+
}
|
52
|
+
if (transaction.sourceStatus != "success") {
|
53
|
+
transaction.sourceStatus = "success";
|
54
|
+
}
|
55
|
+
if (!transaction.sourceCreatedAt) {
|
56
|
+
transaction.sourceCreatedAt = new Date();
|
57
|
+
}
|
58
|
+
transaction.sourceTransactionHash = event.transactionHash;
|
59
|
+
transaction.sourceBlockNumber = event.blockNumber;
|
60
|
+
transaction.sourceLogs = [];
|
61
|
+
transaction.validateEvent = {
|
62
|
+
actionId,
|
63
|
+
actionIdHashHash: actionIdHash,
|
64
|
+
actionIdHash,
|
65
|
+
vnonce: vnonce.toString(),
|
66
|
+
sourceSpells: sourceSpells.map(({ connector, data }) => ({
|
67
|
+
connector,
|
68
|
+
data,
|
69
|
+
})),
|
70
|
+
position: {
|
71
|
+
withdraw: position.withdraw.map((v) => ({
|
72
|
+
sourceToken: v.sourceToken,
|
73
|
+
targetToken: v.targetToken,
|
74
|
+
amount: v.amount.toString(),
|
75
|
+
})),
|
76
|
+
supply: position.supply.map((v) => ({
|
77
|
+
sourceToken: v.sourceToken,
|
78
|
+
targetToken: v.targetToken,
|
79
|
+
amount: v.amount.toString(),
|
80
|
+
})),
|
81
|
+
},
|
82
|
+
sourceChainId: sourceChainId.toNumber(),
|
83
|
+
targetChainId: targetChainId.toNumber(),
|
84
|
+
sourceSender,
|
85
|
+
sourceDsaId: sourceDsaId.toString(),
|
86
|
+
targetDsaId: targetDsaId.toString(),
|
87
|
+
metadata,
|
88
|
+
};
|
89
|
+
await transaction.save();
|
90
|
+
this.logger.info(`New InteropX tranaction: ${transactionHash} `);
|
91
|
+
}
|
92
|
+
catch (error) {
|
93
|
+
this.logger.error(error);
|
94
|
+
}
|
95
|
+
}
|
96
|
+
if (processedEvents > 0)
|
97
|
+
this.logger.info(`${processedEvents} events processed`);
|
98
|
+
}
|
99
|
+
async start() {
|
100
|
+
this.contractAddress = constants_1.addresses[this.chainId].interopX;
|
101
|
+
this.provider = new providers_1.JsonRpcRetryProvider((0, utils_1.getRpcProviderUrl)(this.chainId));
|
102
|
+
this.contract = (0, utils_1.getContract)(this.contractAddress, abi_1.default.interopX, new ethers_1.ethers.Wallet(config_1.default.privateKey, this.provider));
|
103
|
+
await super.start();
|
104
|
+
}
|
105
|
+
}
|
106
|
+
exports.default = SyncLogValidateEvents;
|
@@ -20,13 +20,16 @@ class SyncTransactionStatusTask extends BaseTask_1.BaseTask {
|
|
20
20
|
// if transaction is pending for more than 1 hour, check lead node for status
|
21
21
|
const leadNode = net_1.peerPool.getLeadPeer();
|
22
22
|
if (!leadNode) {
|
23
|
+
console.log("No lead node found");
|
23
24
|
return;
|
24
25
|
}
|
25
26
|
const transaction = await db_1.Transaction.findOne({
|
26
27
|
where: {
|
27
|
-
status:
|
28
|
-
|
29
|
-
|
28
|
+
status: {
|
29
|
+
[sequelize_1.Op.notIn]: ['success', 'failed'],
|
30
|
+
},
|
31
|
+
createdAt: {
|
32
|
+
[sequelize_1.Op.lt]: new Date(Date.now() - 15 * 60 * 1000),
|
30
33
|
},
|
31
34
|
}
|
32
35
|
});
|
package/dist/src/tasks/index.js
CHANGED
@@ -5,29 +5,36 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
6
6
|
exports.Tasks = void 0;
|
7
7
|
const waait_1 = __importDefault(require("waait"));
|
8
|
+
const SyncTransactionStatusTask_1 = __importDefault(require("./Transactions/SyncTransactionStatusTask"));
|
8
9
|
const AutoUpdateTask_1 = __importDefault(require("./AutoUpdateTask"));
|
9
|
-
const
|
10
|
-
const
|
11
|
-
const
|
10
|
+
const SyncLogSubmitEvents_1 = __importDefault(require("./InteropX/SyncLogSubmitEvents"));
|
11
|
+
const ProcessSubmitEvents_1 = __importDefault(require("./InteropX/ProcessSubmitEvents"));
|
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 = [
|
15
|
-
// new SyncTransactionStatusTask(),
|
16
18
|
new AutoUpdateTask_1.default(),
|
17
|
-
//
|
18
|
-
new
|
19
|
-
new
|
20
|
-
new
|
21
|
-
new
|
22
|
-
new
|
23
|
-
new
|
19
|
+
// InteropX
|
20
|
+
new SyncLogSubmitEvents_1.default({ chainId: 137 }),
|
21
|
+
new SyncLogSubmitEvents_1.default({ chainId: 43114 }),
|
22
|
+
new ProcessSubmitEvents_1.default({ chainId: 137 }),
|
23
|
+
new ProcessSubmitEvents_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 SyncLogExecuteEvents_1.default({ targetChainId: 137 }),
|
29
|
+
new SyncLogExecuteEvents_1.default({ targetChainId: 43114 }),
|
30
|
+
new SyncTransactionStatusTask_1.default(),
|
24
31
|
];
|
25
32
|
}
|
26
33
|
async start() {
|
27
34
|
for (const task of this.tasks) {
|
28
35
|
try {
|
29
36
|
task.start();
|
30
|
-
await (0, waait_1.default)(
|
37
|
+
await (0, waait_1.default)(300);
|
31
38
|
}
|
32
39
|
catch (error) {
|
33
40
|
console.error(`Error starting task: ${task.constructor.name}`);
|
File without changes
|