@instadapp/interop-x 0.0.0-dev.e69b5e8 → 0.0.0-dev.e916c22
Sign up to get free protection for your applications and to get access to all the features.
- package/.github/workflows/ci.yml +19 -0
- package/dist/package.json +17 -13
- 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 +6 -4
- package/dist/src/abi/instList.json +232 -0
- package/dist/src/abi/interopX.json +1436 -0
- package/dist/src/alias.js +10 -0
- package/dist/src/api/index.js +3 -0
- package/dist/src/config/index.js +10 -1
- package/dist/src/constants/addresses.js +6 -7
- package/dist/src/constants/blockConfirmations.js +8 -0
- package/dist/src/constants/index.js +1 -1
- package/dist/src/constants/tokens.js +62 -39
- package/dist/src/db/models/transaction.js +41 -15
- 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 +86 -0
- package/dist/src/gnosis/actions/index.js +9 -0
- package/dist/src/gnosis/index.js +20 -0
- package/dist/src/index.js +34 -22
- package/dist/src/net/protocol/dial/SignatureDialProtocol.js +9 -10
- package/dist/src/net/protocol/dial/{SignatureDialProtocol.1.js → TransactionStatusDialProtocol.js} +2 -0
- package/dist/src/net/protocol/index.js +17 -7
- package/dist/src/tasks/AutoUpdateTask.js +10 -7
- package/dist/src/tasks/BaseTask.js +4 -0
- package/dist/src/tasks/InteropX/ProcessSubmitSubmitEvents.js +179 -0
- package/dist/src/tasks/InteropX/ProcessValidateEvents.js +183 -0
- package/dist/src/tasks/InteropX/SyncLogExecuteEvents.js +112 -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 +8 -3
- package/dist/src/tasks/index.js +21 -19
- package/dist/src/typechain/{InteropBridgeToken.js → InstList.js} +0 -0
- package/dist/src/typechain/{InteropXGateway.js → InteropX.js} +0 -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 +5 -5
- package/dist/src/typechain/index.js +5 -5
- package/dist/src/utils/index.js +97 -112
- package/package.json +17 -13
- 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 +9 -7
- package/src/abi/instList.json +232 -0
- package/src/abi/interopX.json +1436 -0
- package/src/alias.ts +6 -0
- package/src/api/index.ts +3 -0
- package/src/config/index.ts +9 -1
- package/src/constants/addresses.ts +7 -8
- package/src/constants/blockConfirmations.ts +5 -0
- package/src/constants/index.ts +1 -1
- package/src/constants/tokens.ts +63 -40
- package/src/db/models/transaction.ts +159 -65
- 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 +141 -0
- package/src/gnosis/actions/index.ts +5 -0
- package/src/gnosis/index.ts +19 -0
- package/src/index.ts +47 -26
- package/src/net/protocol/dial/SignatureDialProtocol.ts +12 -13
- package/src/net/protocol/dial/{SignatureDialProtocol.1.ts → TransactionStatusDialProtocol.ts} +3 -1
- package/src/net/protocol/index.ts +17 -7
- package/src/tasks/AutoUpdateTask.ts +14 -13
- package/src/tasks/BaseTask.ts +5 -0
- package/src/tasks/InteropX/ProcessSubmitSubmitEvents.ts +269 -0
- package/src/tasks/InteropX/ProcessValidateEvents.ts +274 -0
- package/src/tasks/InteropX/SyncLogExecuteEvents.ts +162 -0
- package/src/tasks/InteropX/SyncLogSubmitEvents.ts +139 -0
- package/src/tasks/InteropX/SyncLogValidateEvents.ts +152 -0
- package/src/tasks/Transactions/SyncTransactionStatusTask.ts +8 -3
- package/src/tasks/index.ts +26 -20
- package/src/typechain/InstList.ts +402 -0
- package/src/typechain/InteropX.ts +1216 -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 +2 -2
- package/src/typechain/index.ts +4 -4
- package/src/utils/index.ts +229 -183
- package/tsconfig.json +7 -2
- package/dist/src/abi/interopBridgeToken.json +0 -286
- package/dist/src/abi/interopXGateway.json +0 -184
- package/dist/src/constants/itokens.js +0 -13
- package/dist/src/tasks/InteropBridge/ProcessWithdrawEvents.js +0 -146
- package/dist/src/tasks/InteropBridge/SyncWithdrawEvents.js +0 -69
- package/dist/src/tasks/InteropXGateway/ProcessDepositEvents.js +0 -149
- package/dist/src/tasks/InteropXGateway/SyncDepositEvents.js +0 -74
- package/dist/src/typechain/factories/InteropBridgeToken__factory.js +0 -459
- package/dist/src/typechain/factories/InteropXGateway__factory.js +0 -265
- package/src/abi/interopBridgeToken.json +0 -286
- package/src/abi/interopXGateway.json +0 -184
- package/src/constants/itokens.ts +0 -10
- package/src/tasks/InteropBridge/ProcessWithdrawEvents.ts +0 -231
- package/src/tasks/InteropBridge/SyncWithdrawEvents.ts +0 -119
- package/src/tasks/InteropXGateway/ProcessDepositEvents.ts +0 -243
- package/src/tasks/InteropXGateway/SyncDepositEvents.ts +0 -124
- 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,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;
|
@@ -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
|
});
|
@@ -42,9 +45,11 @@ class SyncTransactionStatusTask extends BaseTask_1.BaseTask {
|
|
42
45
|
transaction.sourceStatus = transactionStatus.sourceStatus;
|
43
46
|
transaction.sourceTransactionHash = transactionStatus.sourceTransactionHash;
|
44
47
|
transaction.sourceErrors = transactionStatus.sourceErrors;
|
48
|
+
transaction.sourceLogs = transactionStatus.sourceLogs;
|
45
49
|
transaction.targetStatus = transactionStatus.targetStatus;
|
46
50
|
transaction.targetTransactionHash = transactionStatus.targetTransactionHash;
|
47
51
|
transaction.targetErrors = transactionStatus.targetErrors;
|
52
|
+
transaction.targetLogs = transactionStatus.targetLogs;
|
48
53
|
transaction.status = transactionStatus.status;
|
49
54
|
await transaction.save();
|
50
55
|
this.logger.info(`Updated transaction status for ${transaction.transactionHash}`);
|
package/dist/src/tasks/index.js
CHANGED
@@ -4,36 +4,38 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
4
4
|
};
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
6
6
|
exports.Tasks = void 0;
|
7
|
-
const
|
8
|
-
const SyncDepositEvents_1 = __importDefault(require("./InteropXGateway/SyncDepositEvents"));
|
9
|
-
const SyncWithdrawEvents_1 = __importDefault(require("./InteropBridge/SyncWithdrawEvents"));
|
10
|
-
const ProcessWithdrawEvents_1 = __importDefault(require("./InteropBridge/ProcessWithdrawEvents"));
|
11
|
-
const AutoUpdateTask_1 = __importDefault(require("./AutoUpdateTask"));
|
7
|
+
const waait_1 = __importDefault(require("waait"));
|
12
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
|
+
const SyncLogExecuteEvents_1 = __importDefault(require("./InteropX/SyncLogExecuteEvents"));
|
13
15
|
class Tasks {
|
14
16
|
constructor() {
|
15
17
|
this.tasks = [
|
16
|
-
new
|
18
|
+
// new SyncTransactionStatusTask(),
|
17
19
|
new AutoUpdateTask_1.default(),
|
18
|
-
|
19
|
-
|
20
|
-
}),
|
21
|
-
new
|
22
|
-
|
23
|
-
}),
|
24
|
-
new
|
25
|
-
|
26
|
-
|
27
|
-
}),
|
28
|
-
new
|
29
|
-
|
30
|
-
})
|
20
|
+
// InteropX
|
21
|
+
new SyncLogSubmitEvents_1.default({ chainId: 137 }),
|
22
|
+
new SyncLogSubmitEvents_1.default({ chainId: 43114 }),
|
23
|
+
new ProcessSubmitSubmitEvents_1.default({ chainId: 137 }),
|
24
|
+
new ProcessSubmitSubmitEvents_1.default({ chainId: 43114 }),
|
25
|
+
new SyncLogValidateEvents_1.default({ chainId: 137 }),
|
26
|
+
new SyncLogValidateEvents_1.default({ chainId: 43114 }),
|
27
|
+
new ProcessValidateEvents_1.default({ chainId: 137 }),
|
28
|
+
new ProcessValidateEvents_1.default({ chainId: 43114 }),
|
29
|
+
new SyncLogExecuteEvents_1.default({ targetChainId: 137 }),
|
30
|
+
new SyncLogExecuteEvents_1.default({ targetChainId: 43114 }),
|
31
|
+
new SyncTransactionStatusTask_1.default(),
|
31
32
|
];
|
32
33
|
}
|
33
34
|
async start() {
|
34
35
|
for (const task of this.tasks) {
|
35
36
|
try {
|
36
37
|
task.start();
|
38
|
+
await (0, waait_1.default)(300);
|
37
39
|
}
|
38
40
|
catch (error) {
|
39
41
|
console.error(`Error starting task: ${task.constructor.name}`);
|
File without changes
|
File without changes
|
@@ -0,0 +1,249 @@
|
|
1
|
+
"use strict";
|
2
|
+
/* Autogenerated file. Do not edit manually. */
|
3
|
+
/* tslint:disable */
|
4
|
+
/* eslint-disable */
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
6
|
+
exports.InstList__factory = void 0;
|
7
|
+
const ethers_1 = require("ethers");
|
8
|
+
const _abi = [
|
9
|
+
{
|
10
|
+
inputs: [
|
11
|
+
{
|
12
|
+
internalType: "address",
|
13
|
+
name: "_instaIndex",
|
14
|
+
type: "address",
|
15
|
+
},
|
16
|
+
],
|
17
|
+
stateMutability: "nonpayable",
|
18
|
+
type: "constructor",
|
19
|
+
},
|
20
|
+
{
|
21
|
+
inputs: [
|
22
|
+
{
|
23
|
+
internalType: "uint64",
|
24
|
+
name: "",
|
25
|
+
type: "uint64",
|
26
|
+
},
|
27
|
+
],
|
28
|
+
name: "accountAddr",
|
29
|
+
outputs: [
|
30
|
+
{
|
31
|
+
internalType: "address",
|
32
|
+
name: "",
|
33
|
+
type: "address",
|
34
|
+
},
|
35
|
+
],
|
36
|
+
stateMutability: "view",
|
37
|
+
type: "function",
|
38
|
+
},
|
39
|
+
{
|
40
|
+
inputs: [
|
41
|
+
{
|
42
|
+
internalType: "address",
|
43
|
+
name: "",
|
44
|
+
type: "address",
|
45
|
+
},
|
46
|
+
],
|
47
|
+
name: "accountID",
|
48
|
+
outputs: [
|
49
|
+
{
|
50
|
+
internalType: "uint64",
|
51
|
+
name: "",
|
52
|
+
type: "uint64",
|
53
|
+
},
|
54
|
+
],
|
55
|
+
stateMutability: "view",
|
56
|
+
type: "function",
|
57
|
+
},
|
58
|
+
{
|
59
|
+
inputs: [
|
60
|
+
{
|
61
|
+
internalType: "uint64",
|
62
|
+
name: "",
|
63
|
+
type: "uint64",
|
64
|
+
},
|
65
|
+
],
|
66
|
+
name: "accountLink",
|
67
|
+
outputs: [
|
68
|
+
{
|
69
|
+
internalType: "address",
|
70
|
+
name: "first",
|
71
|
+
type: "address",
|
72
|
+
},
|
73
|
+
{
|
74
|
+
internalType: "address",
|
75
|
+
name: "last",
|
76
|
+
type: "address",
|
77
|
+
},
|
78
|
+
{
|
79
|
+
internalType: "uint64",
|
80
|
+
name: "count",
|
81
|
+
type: "uint64",
|
82
|
+
},
|
83
|
+
],
|
84
|
+
stateMutability: "view",
|
85
|
+
type: "function",
|
86
|
+
},
|
87
|
+
{
|
88
|
+
inputs: [
|
89
|
+
{
|
90
|
+
internalType: "uint64",
|
91
|
+
name: "",
|
92
|
+
type: "uint64",
|
93
|
+
},
|
94
|
+
{
|
95
|
+
internalType: "address",
|
96
|
+
name: "",
|
97
|
+
type: "address",
|
98
|
+
},
|
99
|
+
],
|
100
|
+
name: "accountList",
|
101
|
+
outputs: [
|
102
|
+
{
|
103
|
+
internalType: "address",
|
104
|
+
name: "prev",
|
105
|
+
type: "address",
|
106
|
+
},
|
107
|
+
{
|
108
|
+
internalType: "address",
|
109
|
+
name: "next",
|
110
|
+
type: "address",
|
111
|
+
},
|
112
|
+
],
|
113
|
+
stateMutability: "view",
|
114
|
+
type: "function",
|
115
|
+
},
|
116
|
+
{
|
117
|
+
inputs: [],
|
118
|
+
name: "accounts",
|
119
|
+
outputs: [
|
120
|
+
{
|
121
|
+
internalType: "uint64",
|
122
|
+
name: "",
|
123
|
+
type: "uint64",
|
124
|
+
},
|
125
|
+
],
|
126
|
+
stateMutability: "view",
|
127
|
+
type: "function",
|
128
|
+
},
|
129
|
+
{
|
130
|
+
inputs: [
|
131
|
+
{
|
132
|
+
internalType: "address",
|
133
|
+
name: "_owner",
|
134
|
+
type: "address",
|
135
|
+
},
|
136
|
+
],
|
137
|
+
name: "addAuth",
|
138
|
+
outputs: [],
|
139
|
+
stateMutability: "nonpayable",
|
140
|
+
type: "function",
|
141
|
+
},
|
142
|
+
{
|
143
|
+
inputs: [
|
144
|
+
{
|
145
|
+
internalType: "address",
|
146
|
+
name: "_account",
|
147
|
+
type: "address",
|
148
|
+
},
|
149
|
+
],
|
150
|
+
name: "init",
|
151
|
+
outputs: [],
|
152
|
+
stateMutability: "nonpayable",
|
153
|
+
type: "function",
|
154
|
+
},
|
155
|
+
{
|
156
|
+
inputs: [],
|
157
|
+
name: "instaIndex",
|
158
|
+
outputs: [
|
159
|
+
{
|
160
|
+
internalType: "address",
|
161
|
+
name: "",
|
162
|
+
type: "address",
|
163
|
+
},
|
164
|
+
],
|
165
|
+
stateMutability: "view",
|
166
|
+
type: "function",
|
167
|
+
},
|
168
|
+
{
|
169
|
+
inputs: [
|
170
|
+
{
|
171
|
+
internalType: "address",
|
172
|
+
name: "_owner",
|
173
|
+
type: "address",
|
174
|
+
},
|
175
|
+
],
|
176
|
+
name: "removeAuth",
|
177
|
+
outputs: [],
|
178
|
+
stateMutability: "nonpayable",
|
179
|
+
type: "function",
|
180
|
+
},
|
181
|
+
{
|
182
|
+
inputs: [
|
183
|
+
{
|
184
|
+
internalType: "address",
|
185
|
+
name: "",
|
186
|
+
type: "address",
|
187
|
+
},
|
188
|
+
],
|
189
|
+
name: "userLink",
|
190
|
+
outputs: [
|
191
|
+
{
|
192
|
+
internalType: "uint64",
|
193
|
+
name: "first",
|
194
|
+
type: "uint64",
|
195
|
+
},
|
196
|
+
{
|
197
|
+
internalType: "uint64",
|
198
|
+
name: "last",
|
199
|
+
type: "uint64",
|
200
|
+
},
|
201
|
+
{
|
202
|
+
internalType: "uint64",
|
203
|
+
name: "count",
|
204
|
+
type: "uint64",
|
205
|
+
},
|
206
|
+
],
|
207
|
+
stateMutability: "view",
|
208
|
+
type: "function",
|
209
|
+
},
|
210
|
+
{
|
211
|
+
inputs: [
|
212
|
+
{
|
213
|
+
internalType: "address",
|
214
|
+
name: "",
|
215
|
+
type: "address",
|
216
|
+
},
|
217
|
+
{
|
218
|
+
internalType: "uint64",
|
219
|
+
name: "",
|
220
|
+
type: "uint64",
|
221
|
+
},
|
222
|
+
],
|
223
|
+
name: "userList",
|
224
|
+
outputs: [
|
225
|
+
{
|
226
|
+
internalType: "uint64",
|
227
|
+
name: "prev",
|
228
|
+
type: "uint64",
|
229
|
+
},
|
230
|
+
{
|
231
|
+
internalType: "uint64",
|
232
|
+
name: "next",
|
233
|
+
type: "uint64",
|
234
|
+
},
|
235
|
+
],
|
236
|
+
stateMutability: "view",
|
237
|
+
type: "function",
|
238
|
+
},
|
239
|
+
];
|
240
|
+
class InstList__factory {
|
241
|
+
static createInterface() {
|
242
|
+
return new ethers_1.utils.Interface(_abi);
|
243
|
+
}
|
244
|
+
static connect(address, signerOrProvider) {
|
245
|
+
return new ethers_1.Contract(address, _abi, signerOrProvider);
|
246
|
+
}
|
247
|
+
}
|
248
|
+
exports.InstList__factory = InstList__factory;
|
249
|
+
InstList__factory.abi = _abi;
|