@instadapp/interop-x 0.0.0-dev.0134f74
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/.env.example +2 -0
- package/.github/workflows/ci.yml +19 -0
- package/.github/workflows/publish-dev.yml +30 -0
- package/README.md +21 -0
- package/bin/interop-x +2 -0
- 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/src/abi/erc20.json +350 -0
- package/dist/src/abi/gnosisSafe.json +747 -0
- package/dist/src/abi/index.js +15 -0
- 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/src/config/index.js +31 -0
- package/dist/src/constants/addresses.js +17 -0
- package/dist/src/constants/blockConfirmations.js +8 -0
- package/dist/src/constants/index.js +19 -0
- package/dist/src/constants/tokens.js +130 -0
- package/dist/src/db/index.js +17 -0
- package/dist/src/db/models/index.js +17 -0
- package/dist/src/db/models/transaction.js +72 -0
- package/dist/src/db/sequelize.js +23 -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 +8 -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/src/logger/index.js +138 -0
- package/dist/src/net/index.js +19 -0
- package/dist/src/net/peer/index.js +109 -0
- package/dist/src/net/pool/index.js +130 -0
- package/dist/src/net/protocol/dial/BaseDialProtocol.js +106 -0
- package/dist/src/net/protocol/dial/SignatureDialProtocol.js +55 -0
- package/dist/src/net/protocol/dial/TransactionStatusDialProtocol.js +30 -0
- package/dist/src/net/protocol/index.js +142 -0
- package/dist/src/tasks/AutoUpdateTask.js +70 -0
- package/dist/src/tasks/BaseTask.js +69 -0
- package/dist/src/tasks/InteropX/ProcessSubmitSubmitEvents.js +180 -0
- package/dist/src/tasks/InteropX/SyncLogSubmitEvents.js +86 -0
- package/dist/src/tasks/Transactions/SyncTransactionStatusTask.js +58 -0
- package/dist/src/tasks/index.js +37 -0
- package/dist/src/typechain/Erc20.js +2 -0
- package/dist/src/typechain/GnosisSafe.js +2 -0
- package/dist/src/typechain/InteropX.js +2 -0
- package/dist/src/typechain/common.js +2 -0
- package/dist/src/typechain/factories/Erc20__factory.js +367 -0
- package/dist/src/typechain/factories/GnosisSafe__factory.js +1174 -0
- package/dist/src/typechain/factories/InteropX__factory.js +1928 -0
- package/dist/src/typechain/factories/index.js +12 -0
- package/dist/src/typechain/index.js +33 -0
- package/dist/src/types.js +21 -0
- package/dist/src/utils/index.js +223 -0
- package/package.json +76 -0
- 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/erc20.json +350 -0
- package/src/abi/gnosisSafe.json +747 -0
- package/src/abi/index.ts +11 -0
- 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 +40 -0
- package/src/constants/addresses.ts +14 -0
- package/src/constants/blockConfirmations.ts +5 -0
- package/src/constants/index.ts +3 -0
- package/src/constants/tokens.ts +127 -0
- package/src/db/index.ts +1 -0
- package/src/db/models/index.ts +1 -0
- package/src/db/models/transaction.ts +136 -0
- package/src/db/sequelize.ts +22 -0
- 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 +13 -0
- package/src/gnosis/actions/index.ts +5 -0
- package/src/gnosis/index.ts +19 -0
- package/src/index.ts +150 -0
- package/src/logger/index.ts +157 -0
- package/src/net/index.ts +3 -0
- package/src/net/peer/index.ts +121 -0
- package/src/net/pool/index.ts +158 -0
- package/src/net/protocol/dial/BaseDialProtocol.ts +104 -0
- package/src/net/protocol/dial/SignatureDialProtocol.ts +70 -0
- package/src/net/protocol/dial/TransactionStatusDialProtocol.ts +33 -0
- package/src/net/protocol/index.ts +204 -0
- package/src/tasks/AutoUpdateTask.ts +82 -0
- package/src/tasks/BaseTask.ts +85 -0
- package/src/tasks/InteropX/ProcessSubmitSubmitEvents.ts +270 -0
- package/src/tasks/InteropX/SyncLogSubmitEvents.ts +138 -0
- package/src/tasks/Transactions/SyncTransactionStatusTask.ts +70 -0
- package/src/tasks/index.ts +37 -0
- package/src/typechain/Erc20.ts +491 -0
- package/src/typechain/GnosisSafe.ts +1728 -0
- package/src/typechain/InteropX.ts +1216 -0
- package/src/typechain/common.ts +44 -0
- package/src/typechain/factories/Erc20__factory.ts +368 -0
- package/src/typechain/factories/GnosisSafe__factory.ts +1178 -0
- package/src/typechain/factories/InteropX__factory.ts +1932 -0
- package/src/typechain/factories/index.ts +6 -0
- package/src/typechain/index.ts +10 -0
- package/src/types.ts +39 -0
- package/src/utils/index.ts +365 -0
- package/tsconfig.json +35 -0
@@ -0,0 +1,138 @@
|
|
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.setLogLevel = exports.LogLevels = void 0;
|
7
|
+
const chalk_1 = __importDefault(require("chalk"));
|
8
|
+
const luxon_1 = require("luxon");
|
9
|
+
var LogLevels;
|
10
|
+
(function (LogLevels) {
|
11
|
+
LogLevels[LogLevels["Critical"] = 0] = "Critical";
|
12
|
+
LogLevels[LogLevels["Error"] = 1] = "Error";
|
13
|
+
LogLevels[LogLevels["Warn"] = 2] = "Warn";
|
14
|
+
LogLevels[LogLevels["Info"] = 3] = "Info";
|
15
|
+
LogLevels[LogLevels["Log"] = 4] = "Log";
|
16
|
+
LogLevels[LogLevels["Debug"] = 5] = "Debug";
|
17
|
+
})(LogLevels = exports.LogLevels || (exports.LogLevels = {}));
|
18
|
+
const logLevelColors = {
|
19
|
+
[LogLevels.Critical]: 'red',
|
20
|
+
[LogLevels.Error]: 'red',
|
21
|
+
[LogLevels.Warn]: 'yellow',
|
22
|
+
[LogLevels.Info]: 'blue',
|
23
|
+
[LogLevels.Log]: 'white',
|
24
|
+
[LogLevels.Debug]: 'white'
|
25
|
+
};
|
26
|
+
let logLevel = LogLevels.Debug;
|
27
|
+
const setLogLevel = (_logLevel) => {
|
28
|
+
if (typeof _logLevel === 'string') {
|
29
|
+
const mapping = {
|
30
|
+
error: LogLevels.Error,
|
31
|
+
warn: LogLevels.Warn,
|
32
|
+
info: LogLevels.Info,
|
33
|
+
debug: LogLevels.Debug
|
34
|
+
};
|
35
|
+
_logLevel = mapping[_logLevel];
|
36
|
+
}
|
37
|
+
logLevel = _logLevel;
|
38
|
+
};
|
39
|
+
exports.setLogLevel = setLogLevel;
|
40
|
+
class Logger {
|
41
|
+
constructor(tag = '', opts = {
|
42
|
+
color: 'white'
|
43
|
+
}) {
|
44
|
+
var _a;
|
45
|
+
this.tag = '';
|
46
|
+
this.prefix = '';
|
47
|
+
this.options = {};
|
48
|
+
this.enabled = true;
|
49
|
+
this.critical = (...input) => {
|
50
|
+
if (!this.enabled)
|
51
|
+
return;
|
52
|
+
console.error(...this.headers(LogLevels.Critical), ...input);
|
53
|
+
};
|
54
|
+
this.debug = (...input) => {
|
55
|
+
if (!this.enabled)
|
56
|
+
return;
|
57
|
+
if (logLevel !== LogLevels.Debug) {
|
58
|
+
return;
|
59
|
+
}
|
60
|
+
console.debug(...this.headers(LogLevels.Debug), ...input);
|
61
|
+
};
|
62
|
+
this.error = (...input) => {
|
63
|
+
if (!this.enabled)
|
64
|
+
return;
|
65
|
+
console.error(...this.headers(LogLevels.Error), ...input);
|
66
|
+
};
|
67
|
+
this.info = (...input) => {
|
68
|
+
if (!this.enabled)
|
69
|
+
return;
|
70
|
+
if (!(logLevel === LogLevels.Debug || logLevel === LogLevels.Info)) {
|
71
|
+
return;
|
72
|
+
}
|
73
|
+
console.info(...this.headers(LogLevels.Info), ...input);
|
74
|
+
};
|
75
|
+
this.log = (...input) => {
|
76
|
+
if (!this.enabled)
|
77
|
+
return;
|
78
|
+
if (logLevel < LogLevels.Info) {
|
79
|
+
return;
|
80
|
+
}
|
81
|
+
console.log(...this.headers(LogLevels.Log), ...input);
|
82
|
+
};
|
83
|
+
this.warn = (...input) => {
|
84
|
+
if (!this.enabled)
|
85
|
+
return;
|
86
|
+
if (logLevel < LogLevels.Warn) {
|
87
|
+
return;
|
88
|
+
}
|
89
|
+
console.warn(...this.headers(LogLevels.Warn), ...input);
|
90
|
+
};
|
91
|
+
if (tag instanceof Object) {
|
92
|
+
opts = tag;
|
93
|
+
tag = (_a = opts.tag) !== null && _a !== void 0 ? _a : '';
|
94
|
+
}
|
95
|
+
if (opts.prefix) {
|
96
|
+
this.prefix = `<${opts.prefix}>`;
|
97
|
+
}
|
98
|
+
if (tag) {
|
99
|
+
if (opts.color) {
|
100
|
+
//@ts-ignore
|
101
|
+
this.tag = chalk_1.default[opts.color](`[${tag}]`);
|
102
|
+
}
|
103
|
+
else {
|
104
|
+
this.tag = `[${tag}]`;
|
105
|
+
}
|
106
|
+
}
|
107
|
+
if (process.env.DISABLE_LOGGER) {
|
108
|
+
this.enabled = false;
|
109
|
+
}
|
110
|
+
this.options = opts;
|
111
|
+
}
|
112
|
+
setEnabled(enabled) {
|
113
|
+
this.enabled = enabled;
|
114
|
+
}
|
115
|
+
create(additionalDataLabel) {
|
116
|
+
let label;
|
117
|
+
if (additionalDataLabel.id) {
|
118
|
+
label = `id: ${additionalDataLabel.id}`;
|
119
|
+
}
|
120
|
+
else {
|
121
|
+
label = `root: ${additionalDataLabel.root}`;
|
122
|
+
}
|
123
|
+
return new Logger(this.options.tag, Object.assign({}, this.options, {
|
124
|
+
prefix: `${this.options.prefix ? `${this.options.prefix} ` : ''}${label}`
|
125
|
+
}));
|
126
|
+
}
|
127
|
+
get timestamp() {
|
128
|
+
return luxon_1.DateTime.now().toISO();
|
129
|
+
}
|
130
|
+
headers(logLevelEnum) {
|
131
|
+
const keys = Object.keys(LogLevels);
|
132
|
+
const logLevelName = keys[logLevelEnum + keys.length / 2].toUpperCase();
|
133
|
+
//@ts-ignore
|
134
|
+
const coloredLogLevel = chalk_1.default[logLevelColors[logLevelEnum]](logLevelName.padEnd(5, ' '));
|
135
|
+
return [this.timestamp, coloredLogLevel, this.tag, this.prefix];
|
136
|
+
}
|
137
|
+
}
|
138
|
+
exports.default = Logger;
|
@@ -0,0 +1,19 @@
|
|
1
|
+
"use strict";
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
3
|
+
if (k2 === undefined) k2 = k;
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
7
|
+
}
|
8
|
+
Object.defineProperty(o, k2, desc);
|
9
|
+
}) : (function(o, m, k, k2) {
|
10
|
+
if (k2 === undefined) k2 = k;
|
11
|
+
o[k2] = m[k];
|
12
|
+
}));
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
15
|
+
};
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
17
|
+
__exportStar(require("./peer"), exports);
|
18
|
+
__exportStar(require("./pool"), exports);
|
19
|
+
__exportStar(require("./protocol"), exports);
|
@@ -0,0 +1,109 @@
|
|
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.stopPeer = exports.startPeer = void 0;
|
7
|
+
const libp2p_1 = __importDefault(require("libp2p"));
|
8
|
+
const libp2p_tcp_1 = __importDefault(require("libp2p-tcp"));
|
9
|
+
//@ts-ignore
|
10
|
+
const libp2p_websockets_1 = __importDefault(require("libp2p-websockets"));
|
11
|
+
//@ts-ignore
|
12
|
+
const libp2p_mplex_1 = __importDefault(require("libp2p-mplex"));
|
13
|
+
const libp2p_noise_1 = require("libp2p-noise");
|
14
|
+
const logger_1 = __importDefault(require("@/logger"));
|
15
|
+
const libp2p_bootstrap_1 = __importDefault(require("libp2p-bootstrap"));
|
16
|
+
const waait_1 = __importDefault(require("waait"));
|
17
|
+
const libp2p_gossipsub_1 = __importDefault(require("@achingbrain/libp2p-gossipsub"));
|
18
|
+
//@ts-ignore
|
19
|
+
const libp2p_mdns_1 = __importDefault(require("libp2p-mdns"));
|
20
|
+
//@ts-ignore
|
21
|
+
const libp2p_kad_dht_1 = __importDefault(require("libp2p-kad-dht"));
|
22
|
+
//@ts-ignore
|
23
|
+
const libp2p_pubsub_peer_discovery_1 = __importDefault(require("libp2p-pubsub-peer-discovery"));
|
24
|
+
const net_1 = require("@/net");
|
25
|
+
const config_1 = __importDefault(require("@/config"));
|
26
|
+
const chalk_1 = __importDefault(require("chalk"));
|
27
|
+
const logger = new logger_1.default("Peer");
|
28
|
+
let node;
|
29
|
+
// Known peers addresses
|
30
|
+
const bootstrapMultiaddrs = [
|
31
|
+
'/ip4/164.92.249.133/tcp/15001/ws/p2p/QmVGmkqRn8FEw4PQz83L8Mun24ALxXB2fEyS5aEfT2gGqz',
|
32
|
+
'/ip4/164.92.249.133/tcp/15000/p2p/QmVGmkqRn8FEw4PQz83L8Mun24ALxXB2fEyS5aEfT2gGqz',
|
33
|
+
];
|
34
|
+
const startPeer = async ({}) => {
|
35
|
+
node = await libp2p_1.default.create({
|
36
|
+
addresses: {
|
37
|
+
listen: ["/ip4/0.0.0.0/tcp/0", "/ip4/0.0.0.0/tcp/0/ws"],
|
38
|
+
},
|
39
|
+
modules: {
|
40
|
+
transport: [libp2p_tcp_1.default, libp2p_websockets_1.default],
|
41
|
+
streamMuxer: [libp2p_mplex_1.default],
|
42
|
+
connEncryption: [libp2p_noise_1.NOISE],
|
43
|
+
peerDiscovery: [libp2p_mdns_1.default, libp2p_bootstrap_1.default, libp2p_pubsub_peer_discovery_1.default],
|
44
|
+
pubsub: libp2p_gossipsub_1.default,
|
45
|
+
dht: libp2p_kad_dht_1.default,
|
46
|
+
},
|
47
|
+
config: {
|
48
|
+
dht: {
|
49
|
+
enabled: true,
|
50
|
+
},
|
51
|
+
peerDiscovery: {
|
52
|
+
autoDial: true,
|
53
|
+
// The `tag` property will be searched when creating the instance of your Peer Discovery service.
|
54
|
+
// The associated object, will be passed to the service when it is instantiated.
|
55
|
+
[libp2p_bootstrap_1.default.tag]: {
|
56
|
+
enabled: true,
|
57
|
+
interval: 60e3,
|
58
|
+
list: bootstrapMultiaddrs, // provide array of multiaddrs
|
59
|
+
},
|
60
|
+
[libp2p_mdns_1.default.tag]: {
|
61
|
+
interval: 20e3,
|
62
|
+
enabled: true,
|
63
|
+
},
|
64
|
+
[libp2p_pubsub_peer_discovery_1.default.tag]: {
|
65
|
+
interval: 1000,
|
66
|
+
enabled: true,
|
67
|
+
},
|
68
|
+
},
|
69
|
+
relay: {
|
70
|
+
enabled: true,
|
71
|
+
autoRelay: {
|
72
|
+
enabled: true,
|
73
|
+
maxListeners: 10,
|
74
|
+
},
|
75
|
+
},
|
76
|
+
},
|
77
|
+
peerStore: {
|
78
|
+
persistence: true,
|
79
|
+
},
|
80
|
+
});
|
81
|
+
logger.info("Peer ID:", chalk_1.default.bold(node.peerId.toB58String()));
|
82
|
+
await node.start();
|
83
|
+
net_1.protocol.start({
|
84
|
+
libp2p: node
|
85
|
+
});
|
86
|
+
node.on("peer:discovery", (peer) => {
|
87
|
+
// logger.log(`Discovered peer ${peer}`)
|
88
|
+
}); // peer disc.
|
89
|
+
node.connectionManager.on("peer:connect", (connection) => {
|
90
|
+
// logger.log(`Connected to ${connection.remotePeer.toB58String()}`)
|
91
|
+
});
|
92
|
+
logger.log("Peer discovery started");
|
93
|
+
await (0, waait_1.default)(1000);
|
94
|
+
setInterval(() => net_1.protocol.sendPeerInfo({
|
95
|
+
publicAddress: config_1.default.wallet.address,
|
96
|
+
}), 5000);
|
97
|
+
};
|
98
|
+
exports.startPeer = startPeer;
|
99
|
+
const stopPeer = async () => {
|
100
|
+
if (node) {
|
101
|
+
// stop libp2p
|
102
|
+
await node.stop();
|
103
|
+
logger.log("libp2p has stopped");
|
104
|
+
}
|
105
|
+
process.exit(0);
|
106
|
+
};
|
107
|
+
exports.stopPeer = stopPeer;
|
108
|
+
process.on("SIGTERM", exports.stopPeer);
|
109
|
+
process.on("SIGINT", exports.stopPeer);
|
@@ -0,0 +1,130 @@
|
|
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.peerPool = exports.PeerPool = void 0;
|
7
|
+
const types_1 = require("@/types");
|
8
|
+
const config_1 = __importDefault(require("@/config"));
|
9
|
+
const logger_1 = __importDefault(require("@/logger"));
|
10
|
+
const utils_1 = require("ethers/lib/utils");
|
11
|
+
const utils_2 = require("@/utils");
|
12
|
+
const chalk_1 = __importDefault(require("chalk"));
|
13
|
+
const logger = new logger_1.default('PeerPool');
|
14
|
+
class PeerPool {
|
15
|
+
constructor() {
|
16
|
+
this.PEERS_CLEANUP_TIME_LIMIT = 1;
|
17
|
+
this.pool = new Map();
|
18
|
+
config_1.default.events.on(types_1.Event.PEER_CONNECTED, (peer) => {
|
19
|
+
this.connected(peer);
|
20
|
+
});
|
21
|
+
config_1.default.events.on(types_1.Event.PEER_DISCONNECTED, (peer) => {
|
22
|
+
this.disconnected(peer);
|
23
|
+
});
|
24
|
+
}
|
25
|
+
/**
|
26
|
+
* Connected peers
|
27
|
+
*/
|
28
|
+
get peers() {
|
29
|
+
const connectedPeers = Array.from(this.pool.values());
|
30
|
+
return connectedPeers;
|
31
|
+
}
|
32
|
+
/**
|
33
|
+
* Number of peers in pool
|
34
|
+
*/
|
35
|
+
get size() {
|
36
|
+
return this.peers.length;
|
37
|
+
}
|
38
|
+
/**
|
39
|
+
* Return true if pool contains the specified peer
|
40
|
+
* @param peer peer object or id
|
41
|
+
*/
|
42
|
+
contains(peer) {
|
43
|
+
if (typeof peer !== 'string') {
|
44
|
+
peer = peer.id;
|
45
|
+
}
|
46
|
+
return !!this.pool.get(peer);
|
47
|
+
}
|
48
|
+
/**
|
49
|
+
* Handler for peer connections
|
50
|
+
* @param peer peer
|
51
|
+
*/
|
52
|
+
connected(peer) {
|
53
|
+
if (this.size >= config_1.default.maxPeers)
|
54
|
+
return;
|
55
|
+
this.add(peer);
|
56
|
+
}
|
57
|
+
/**
|
58
|
+
* Handler for peer disconnections
|
59
|
+
* @param peer peer
|
60
|
+
*/
|
61
|
+
disconnected(peer) {
|
62
|
+
this.remove(peer);
|
63
|
+
}
|
64
|
+
/**
|
65
|
+
* Add peer to pool
|
66
|
+
* @param peer peer
|
67
|
+
* @emits {@link Event.POOL_PEER_ADDED}
|
68
|
+
*/
|
69
|
+
add(peer) {
|
70
|
+
if (peer && peer.id) {
|
71
|
+
const newPeer = !this.pool.get(peer.id);
|
72
|
+
this.pool.set(peer.id, peer);
|
73
|
+
peer.pooled = true;
|
74
|
+
if (newPeer) {
|
75
|
+
config_1.default.events.emit(types_1.Event.POOL_PEER_ADDED, peer);
|
76
|
+
logger.info(`Peer ${chalk_1.default.bold((0, utils_2.shortenHash)(peer.id, 16))} with address ${chalk_1.default.bold((0, utils_2.shortenHash)(peer.publicAddress))} added to pool`);
|
77
|
+
}
|
78
|
+
}
|
79
|
+
}
|
80
|
+
/**
|
81
|
+
* Remove peer from pool
|
82
|
+
* @param peer peer
|
83
|
+
* @emits {@link Event.POOL_PEER_REMOVED}
|
84
|
+
*/
|
85
|
+
remove(peer) {
|
86
|
+
if (peer && peer.id) {
|
87
|
+
if (this.pool.delete(peer.id)) {
|
88
|
+
peer.pooled = false;
|
89
|
+
config_1.default.events.emit(types_1.Event.POOL_PEER_REMOVED, peer);
|
90
|
+
logger.info(`Peer ${chalk_1.default.bold((0, utils_2.shortenHash)(peer.id, 16))} with address ${chalk_1.default.bold((0, utils_2.shortenHash)(peer.publicAddress))} removed from pool`);
|
91
|
+
}
|
92
|
+
}
|
93
|
+
}
|
94
|
+
get activePeers() {
|
95
|
+
this.cleanup();
|
96
|
+
return this.peers.filter((p) => {
|
97
|
+
if (!p.pooled)
|
98
|
+
return false;
|
99
|
+
const now = new Date();
|
100
|
+
return (now.getTime() - p.updated.getTime()) < 1000 * 10; // 10 seconds
|
101
|
+
});
|
102
|
+
}
|
103
|
+
get activePeerIds() {
|
104
|
+
return this.activePeers.map((p) => p.id);
|
105
|
+
}
|
106
|
+
getPeer(id) {
|
107
|
+
return this.pool.get(id);
|
108
|
+
}
|
109
|
+
isLeadNode(id) {
|
110
|
+
const peer = this.pool.get(id);
|
111
|
+
if (!peer) {
|
112
|
+
return false;
|
113
|
+
}
|
114
|
+
return (0, utils_1.getAddress)(peer.publicAddress) === (0, utils_1.getAddress)(config_1.default.leadNodeAddress);
|
115
|
+
}
|
116
|
+
getLeadPeer() {
|
117
|
+
return this.peers.find((p) => this.isLeadNode(p.id));
|
118
|
+
}
|
119
|
+
cleanup() {
|
120
|
+
// let compDate = Date.now() - this.PEERS_CLEANUP_TIME_LIMIT * 60
|
121
|
+
// this.peers.forEach((peerInfo) => {
|
122
|
+
// if (peerInfo.updated.getTime() < compDate) {
|
123
|
+
// console.log(`Peer ${peerInfo.id} idle for ${this.PEERS_CLEANUP_TIME_LIMIT} minutes`)
|
124
|
+
// this.remove(peerInfo)
|
125
|
+
// }
|
126
|
+
// })
|
127
|
+
}
|
128
|
+
}
|
129
|
+
exports.PeerPool = PeerPool;
|
130
|
+
exports.peerPool = new PeerPool();
|
@@ -0,0 +1,106 @@
|
|
1
|
+
"use strict";
|
2
|
+
var __asyncValues = (this && this.__asyncValues) || function (o) {
|
3
|
+
if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
|
4
|
+
var m = o[Symbol.asyncIterator], i;
|
5
|
+
return m ? m.call(o) : (o = typeof __values === "function" ? __values(o) : o[Symbol.iterator](), i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i);
|
6
|
+
function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; }
|
7
|
+
function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); }
|
8
|
+
};
|
9
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
10
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
11
|
+
};
|
12
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
13
|
+
exports.BaseDialProtocol = void 0;
|
14
|
+
const it_pipe_1 = __importDefault(require("it-pipe"));
|
15
|
+
const peer_id_1 = __importDefault(require("peer-id"));
|
16
|
+
const utils_1 = require("@/utils");
|
17
|
+
const waait_1 = __importDefault(require("waait"));
|
18
|
+
class BaseDialProtocol {
|
19
|
+
constructor(libp2p, protocol) {
|
20
|
+
this.timeout = 20000;
|
21
|
+
this.libp2p = libp2p;
|
22
|
+
this.protocol = protocol;
|
23
|
+
this.libp2p.handle(this.protocol, this.handle.bind(this));
|
24
|
+
}
|
25
|
+
encode(data) {
|
26
|
+
return JSON.stringify(data);
|
27
|
+
}
|
28
|
+
encodeResponse(data) {
|
29
|
+
return JSON.stringify(data);
|
30
|
+
}
|
31
|
+
decode(data) {
|
32
|
+
return JSON.parse(data.toString());
|
33
|
+
}
|
34
|
+
decodeResponse(data) {
|
35
|
+
return JSON.parse(data.toString());
|
36
|
+
}
|
37
|
+
async response(data) {
|
38
|
+
return data;
|
39
|
+
}
|
40
|
+
async handle({ connection, stream }) {
|
41
|
+
const instance = this;
|
42
|
+
try {
|
43
|
+
await (0, it_pipe_1.default)(stream, async function (source) {
|
44
|
+
var e_1, _a;
|
45
|
+
try {
|
46
|
+
for (var source_1 = __asyncValues(source), source_1_1; source_1_1 = await source_1.next(), !source_1_1.done;) {
|
47
|
+
const message = source_1_1.value;
|
48
|
+
const response = instance.encodeResponse(await instance.response(instance.decode(message)));
|
49
|
+
await (0, it_pipe_1.default)([response], stream);
|
50
|
+
}
|
51
|
+
}
|
52
|
+
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
53
|
+
finally {
|
54
|
+
try {
|
55
|
+
if (source_1_1 && !source_1_1.done && (_a = source_1.return)) await _a.call(source_1);
|
56
|
+
}
|
57
|
+
finally { if (e_1) throw e_1.error; }
|
58
|
+
}
|
59
|
+
});
|
60
|
+
}
|
61
|
+
catch (err) {
|
62
|
+
console.error(err);
|
63
|
+
}
|
64
|
+
}
|
65
|
+
async send(data, peerId) {
|
66
|
+
return await (0, utils_1.asyncCallWithTimeout)(new Promise(async (resolve, reject) => {
|
67
|
+
try {
|
68
|
+
let connection = this.libp2p.connectionManager.get(peer_id_1.default.createFromB58String(peerId));
|
69
|
+
if (!connection) {
|
70
|
+
await (0, waait_1.default)(5000);
|
71
|
+
connection = this.libp2p.connectionManager.get(peer_id_1.default.createFromB58String(peerId));
|
72
|
+
if (!connection) {
|
73
|
+
await (0, waait_1.default)(3000);
|
74
|
+
connection = this.libp2p.connectionManager.get(peer_id_1.default.createFromB58String(peerId));
|
75
|
+
if (!connection) {
|
76
|
+
throw new Error('No connection available');
|
77
|
+
}
|
78
|
+
}
|
79
|
+
}
|
80
|
+
const { stream } = await connection.newStream([this.protocol]);
|
81
|
+
const instance = this;
|
82
|
+
(0, it_pipe_1.default)([this.encode(data)], stream, async function (source) {
|
83
|
+
var e_2, _a;
|
84
|
+
try {
|
85
|
+
for (var source_2 = __asyncValues(source), source_2_1; source_2_1 = await source_2.next(), !source_2_1.done;) {
|
86
|
+
const message = source_2_1.value;
|
87
|
+
resolve(instance.decodeResponse(message));
|
88
|
+
stream.close();
|
89
|
+
}
|
90
|
+
}
|
91
|
+
catch (e_2_1) { e_2 = { error: e_2_1 }; }
|
92
|
+
finally {
|
93
|
+
try {
|
94
|
+
if (source_2_1 && !source_2_1.done && (_a = source_2.return)) await _a.call(source_2);
|
95
|
+
}
|
96
|
+
finally { if (e_2) throw e_2.error; }
|
97
|
+
}
|
98
|
+
});
|
99
|
+
}
|
100
|
+
catch (error) {
|
101
|
+
reject(error);
|
102
|
+
}
|
103
|
+
}), this.timeout);
|
104
|
+
}
|
105
|
+
}
|
106
|
+
exports.BaseDialProtocol = BaseDialProtocol;
|
@@ -0,0 +1,55 @@
|
|
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.SignatureDialProtocol = void 0;
|
7
|
+
const BaseDialProtocol_1 = require("./BaseDialProtocol");
|
8
|
+
const waait_1 = __importDefault(require("waait"));
|
9
|
+
const config_1 = __importDefault(require("@/config"));
|
10
|
+
const db_1 = require("@/db");
|
11
|
+
const utils_1 = require("@/utils");
|
12
|
+
const constants_1 = require("@/constants");
|
13
|
+
const gnosis_1 = require("@/gnosis");
|
14
|
+
class SignatureDialProtocol extends BaseDialProtocol_1.BaseDialProtocol {
|
15
|
+
constructor(libp2p) {
|
16
|
+
super(libp2p, '/interop-x/signatures');
|
17
|
+
this.timeout = 30000;
|
18
|
+
}
|
19
|
+
async response(data) {
|
20
|
+
console.log({
|
21
|
+
tag: 'SignatureDialProtocol',
|
22
|
+
data
|
23
|
+
});
|
24
|
+
const signer = config_1.default.wallet;
|
25
|
+
let transaction;
|
26
|
+
let maxTimeout = 20000;
|
27
|
+
do {
|
28
|
+
transaction = await db_1.Transaction.findOne({ where: { transactionHash: data.transactionHash } });
|
29
|
+
if (!transaction) {
|
30
|
+
await (0, waait_1.default)(1000);
|
31
|
+
maxTimeout -= 1000;
|
32
|
+
}
|
33
|
+
} while (!transaction && maxTimeout > 0);
|
34
|
+
if (!transaction) {
|
35
|
+
return {
|
36
|
+
signer: signer.address,
|
37
|
+
data: null,
|
38
|
+
error: 'Event not found'
|
39
|
+
};
|
40
|
+
}
|
41
|
+
const { data: gnosisData } = await (0, gnosis_1.buildGnosisAction)(transaction, data.type);
|
42
|
+
const signedData = await (0, utils_1.signGnosisSafeTx)({
|
43
|
+
to: constants_1.addresses[data.chainId].multisend,
|
44
|
+
data: gnosisData,
|
45
|
+
chainId: data.chainId,
|
46
|
+
safeTxGas: data.safeTxGas,
|
47
|
+
nonce: data.safeNonce,
|
48
|
+
}, { signer });
|
49
|
+
return {
|
50
|
+
signer: signer.address,
|
51
|
+
data: signedData
|
52
|
+
};
|
53
|
+
}
|
54
|
+
}
|
55
|
+
exports.SignatureDialProtocol = SignatureDialProtocol;
|
@@ -0,0 +1,30 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
exports.TransactionStatusDialProtocol = void 0;
|
4
|
+
const BaseDialProtocol_1 = require("./BaseDialProtocol");
|
5
|
+
const db_1 = require("@/db");
|
6
|
+
class TransactionStatusDialProtocol extends BaseDialProtocol_1.BaseDialProtocol {
|
7
|
+
constructor(libp2p) {
|
8
|
+
super(libp2p, '/interop-x/transaction-status');
|
9
|
+
this.timeout = 30000;
|
10
|
+
}
|
11
|
+
async response(transactionHash) {
|
12
|
+
const transaction = await db_1.Transaction.findOne({ where: { transactionHash } });
|
13
|
+
if (!transaction) {
|
14
|
+
return null;
|
15
|
+
}
|
16
|
+
return {
|
17
|
+
transactionHash: transaction.transactionHash,
|
18
|
+
sourceStatus: transaction.sourceStatus,
|
19
|
+
sourceTransactionHash: transaction.sourceTransactionHash,
|
20
|
+
sourceErrors: transaction.sourceErrors,
|
21
|
+
sourceLogs: transaction.sourceLogs,
|
22
|
+
targetStatus: transaction.targetStatus,
|
23
|
+
targetTransactionHash: transaction.targetTransactionHash,
|
24
|
+
targetErrors: transaction.targetErrors,
|
25
|
+
targetLogs: transaction.targetLogs,
|
26
|
+
status: transaction.status,
|
27
|
+
};
|
28
|
+
}
|
29
|
+
}
|
30
|
+
exports.TransactionStatusDialProtocol = TransactionStatusDialProtocol;
|