@shapeshiftoss/unchained-client 6.11.0 → 6.11.1
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/README.md +3 -1
- package/dist/bitcoin/index.d.ts +0 -1
- package/dist/bitcoin/index.js +5 -2
- package/dist/bitcoin/parser/index.d.ts +0 -1
- package/dist/bitcoin/parser/index.js +43 -55
- package/dist/bitcoin/parser/utils.d.ts +0 -1
- package/dist/bitcoin/parser/utils.js +0 -1
- package/dist/bitcoin/types.d.ts +0 -1
- package/dist/bitcoin/types.js +0 -1
- package/dist/cosmos/index.d.ts +0 -1
- package/dist/cosmos/index.js +5 -2
- package/dist/cosmos/parser/index.d.ts +1 -2
- package/dist/cosmos/parser/index.js +56 -64
- package/dist/cosmos/parser/utils.d.ts +2 -3
- package/dist/cosmos/parser/utils.js +21 -22
- package/dist/cosmos/types.d.ts +0 -1
- package/dist/cosmos/types.js +0 -1
- package/dist/ethereum/index.d.ts +0 -1
- package/dist/ethereum/index.js +5 -2
- package/dist/ethereum/parser/abi/erc20.d.ts +0 -1
- package/dist/ethereum/parser/abi/erc20.js +69 -70
- package/dist/ethereum/parser/abi/foxyStaking.d.ts +0 -1
- package/dist/ethereum/parser/abi/foxyStaking.js +161 -162
- package/dist/ethereum/parser/abi/multiSig.d.ts +0 -1
- package/dist/ethereum/parser/abi/multiSig.js +79 -80
- package/dist/ethereum/parser/abi/shapeShiftRouter.d.ts +0 -1
- package/dist/ethereum/parser/abi/shapeShiftRouter.js +119 -120
- package/dist/ethereum/parser/abi/thor.d.ts +0 -1
- package/dist/ethereum/parser/abi/thor.js +28 -29
- package/dist/ethereum/parser/abi/uniV2.d.ts +0 -1
- package/dist/ethereum/parser/abi/uniV2.js +55 -56
- package/dist/ethereum/parser/abi/weth.d.ts +0 -1
- package/dist/ethereum/parser/abi/weth.js +66 -67
- package/dist/ethereum/parser/abi/yearnVault.d.ts +0 -1
- package/dist/ethereum/parser/abi/yearnVault.js +95 -96
- package/dist/ethereum/parser/constants.d.ts +0 -1
- package/dist/ethereum/parser/constants.js +0 -1
- package/dist/ethereum/parser/foxy.d.ts +1 -2
- package/dist/ethereum/parser/foxy.js +22 -34
- package/dist/ethereum/parser/index.d.ts +0 -1
- package/dist/ethereum/parser/index.js +46 -54
- package/dist/ethereum/parser/thor.d.ts +1 -2
- package/dist/ethereum/parser/thor.js +29 -41
- package/dist/ethereum/parser/uniV2.d.ts +0 -1
- package/dist/ethereum/parser/uniV2.js +87 -99
- package/dist/ethereum/parser/utils.d.ts +0 -1
- package/dist/ethereum/parser/utils.js +2 -3
- package/dist/ethereum/parser/weth.d.ts +0 -1
- package/dist/ethereum/parser/weth.js +72 -84
- package/dist/ethereum/parser/yearn.d.ts +1 -2
- package/dist/ethereum/parser/yearn.js +46 -58
- package/dist/ethereum/parser/zrx.d.ts +1 -2
- package/dist/ethereum/parser/zrx.js +18 -30
- package/dist/ethereum/types.d.ts +0 -1
- package/dist/ethereum/types.js +0 -1
- package/dist/generated/bitcoin/api.d.ts +116 -120
- package/dist/generated/bitcoin/api.js +81 -110
- package/dist/generated/bitcoin/base.d.ts +2 -3
- package/dist/generated/bitcoin/base.js +1 -2
- package/dist/generated/bitcoin/common.d.ts +2 -3
- package/dist/generated/bitcoin/common.js +22 -38
- package/dist/generated/bitcoin/configuration.d.ts +0 -1
- package/dist/generated/bitcoin/configuration.js +0 -1
- package/dist/generated/bitcoin/index.d.ts +0 -1
- package/dist/generated/bitcoin/index.js +5 -2
- package/dist/generated/cosmos/api.d.ts +143 -144
- package/dist/generated/cosmos/api.js +89 -115
- package/dist/generated/cosmos/base.d.ts +2 -3
- package/dist/generated/cosmos/base.js +0 -1
- package/dist/generated/cosmos/common.d.ts +2 -3
- package/dist/generated/cosmos/common.js +22 -38
- package/dist/generated/cosmos/configuration.d.ts +0 -1
- package/dist/generated/cosmos/configuration.js +0 -1
- package/dist/generated/cosmos/index.d.ts +0 -1
- package/dist/generated/cosmos/index.js +5 -2
- package/dist/generated/ethereum/api.d.ts +73 -77
- package/dist/generated/ethereum/api.js +73 -100
- package/dist/generated/ethereum/base.d.ts +2 -3
- package/dist/generated/ethereum/base.js +1 -2
- package/dist/generated/ethereum/common.d.ts +2 -3
- package/dist/generated/ethereum/common.js +22 -38
- package/dist/generated/ethereum/configuration.d.ts +0 -1
- package/dist/generated/ethereum/configuration.js +0 -1
- package/dist/generated/ethereum/index.d.ts +0 -1
- package/dist/generated/ethereum/index.js +5 -2
- package/dist/index.d.ts +0 -1
- package/dist/index.js +5 -2
- package/dist/types.d.ts +0 -1
- package/dist/types.js +0 -1
- package/dist/utils.d.ts +1 -2
- package/dist/utils.js +18 -21
- package/dist/websocket.d.ts +1 -2
- package/dist/websocket.js +78 -84
- package/package.json +19 -11
- package/dist/bitcoin/index.d.ts.map +0 -1
- package/dist/bitcoin/index.js.map +0 -1
- package/dist/bitcoin/parser/index.d.ts.map +0 -1
- package/dist/bitcoin/parser/index.js.map +0 -1
- package/dist/bitcoin/parser/utils.d.ts.map +0 -1
- package/dist/bitcoin/parser/utils.js.map +0 -1
- package/dist/bitcoin/types.d.ts.map +0 -1
- package/dist/bitcoin/types.js.map +0 -1
- package/dist/cosmos/index.d.ts.map +0 -1
- package/dist/cosmos/index.js.map +0 -1
- package/dist/cosmos/parser/index.d.ts.map +0 -1
- package/dist/cosmos/parser/index.js.map +0 -1
- package/dist/cosmos/parser/utils.d.ts.map +0 -1
- package/dist/cosmos/parser/utils.js.map +0 -1
- package/dist/cosmos/types.d.ts.map +0 -1
- package/dist/cosmos/types.js.map +0 -1
- package/dist/ethereum/index.d.ts.map +0 -1
- package/dist/ethereum/index.js.map +0 -1
- package/dist/ethereum/parser/abi/erc20.d.ts.map +0 -1
- package/dist/ethereum/parser/abi/erc20.js.map +0 -1
- package/dist/ethereum/parser/abi/foxyStaking.d.ts.map +0 -1
- package/dist/ethereum/parser/abi/foxyStaking.js.map +0 -1
- package/dist/ethereum/parser/abi/multiSig.d.ts.map +0 -1
- package/dist/ethereum/parser/abi/multiSig.js.map +0 -1
- package/dist/ethereum/parser/abi/shapeShiftRouter.d.ts.map +0 -1
- package/dist/ethereum/parser/abi/shapeShiftRouter.js.map +0 -1
- package/dist/ethereum/parser/abi/thor.d.ts.map +0 -1
- package/dist/ethereum/parser/abi/thor.js.map +0 -1
- package/dist/ethereum/parser/abi/uniV2.d.ts.map +0 -1
- package/dist/ethereum/parser/abi/uniV2.js.map +0 -1
- package/dist/ethereum/parser/abi/weth.d.ts.map +0 -1
- package/dist/ethereum/parser/abi/weth.js.map +0 -1
- package/dist/ethereum/parser/abi/yearnVault.d.ts.map +0 -1
- package/dist/ethereum/parser/abi/yearnVault.js.map +0 -1
- package/dist/ethereum/parser/constants.d.ts.map +0 -1
- package/dist/ethereum/parser/constants.js.map +0 -1
- package/dist/ethereum/parser/foxy.d.ts.map +0 -1
- package/dist/ethereum/parser/foxy.js.map +0 -1
- package/dist/ethereum/parser/index.d.ts.map +0 -1
- package/dist/ethereum/parser/index.js.map +0 -1
- package/dist/ethereum/parser/thor.d.ts.map +0 -1
- package/dist/ethereum/parser/thor.js.map +0 -1
- package/dist/ethereum/parser/uniV2.d.ts.map +0 -1
- package/dist/ethereum/parser/uniV2.js.map +0 -1
- package/dist/ethereum/parser/utils.d.ts.map +0 -1
- package/dist/ethereum/parser/utils.js.map +0 -1
- package/dist/ethereum/parser/weth.d.ts.map +0 -1
- package/dist/ethereum/parser/weth.js.map +0 -1
- package/dist/ethereum/parser/yearn.d.ts.map +0 -1
- package/dist/ethereum/parser/yearn.js.map +0 -1
- package/dist/ethereum/parser/zrx.d.ts.map +0 -1
- package/dist/ethereum/parser/zrx.js.map +0 -1
- package/dist/ethereum/types.d.ts.map +0 -1
- package/dist/ethereum/types.js.map +0 -1
- package/dist/generated/bitcoin/api.d.ts.map +0 -1
- package/dist/generated/bitcoin/api.js.map +0 -1
- package/dist/generated/bitcoin/base.d.ts.map +0 -1
- package/dist/generated/bitcoin/base.js.map +0 -1
- package/dist/generated/bitcoin/common.d.ts.map +0 -1
- package/dist/generated/bitcoin/common.js.map +0 -1
- package/dist/generated/bitcoin/configuration.d.ts.map +0 -1
- package/dist/generated/bitcoin/configuration.js.map +0 -1
- package/dist/generated/bitcoin/index.d.ts.map +0 -1
- package/dist/generated/bitcoin/index.js.map +0 -1
- package/dist/generated/cosmos/api.d.ts.map +0 -1
- package/dist/generated/cosmos/api.js.map +0 -1
- package/dist/generated/cosmos/base.d.ts.map +0 -1
- package/dist/generated/cosmos/base.js.map +0 -1
- package/dist/generated/cosmos/common.d.ts.map +0 -1
- package/dist/generated/cosmos/common.js.map +0 -1
- package/dist/generated/cosmos/configuration.d.ts.map +0 -1
- package/dist/generated/cosmos/configuration.js.map +0 -1
- package/dist/generated/cosmos/index.d.ts.map +0 -1
- package/dist/generated/cosmos/index.js.map +0 -1
- package/dist/generated/ethereum/api.d.ts.map +0 -1
- package/dist/generated/ethereum/api.js.map +0 -1
- package/dist/generated/ethereum/base.d.ts.map +0 -1
- package/dist/generated/ethereum/base.js.map +0 -1
- package/dist/generated/ethereum/common.d.ts.map +0 -1
- package/dist/generated/ethereum/common.js.map +0 -1
- package/dist/generated/ethereum/configuration.d.ts.map +0 -1
- package/dist/generated/ethereum/configuration.js.map +0 -1
- package/dist/generated/ethereum/index.d.ts.map +0 -1
- package/dist/generated/ethereum/index.js.map +0 -1
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/tsconfig.tsbuildinfo +0 -4986
- package/dist/types.d.ts.map +0 -1
- package/dist/types.js.map +0 -1
- package/dist/utils.d.ts.map +0 -1
- package/dist/utils.js.map +0 -1
- package/dist/websocket.d.ts.map +0 -1
- package/dist/websocket.js.map +0 -1
|
@@ -6,4 +6,3 @@ export declare const THOR_ROUTER_CONTRACT_ROPSTEN = "0xefA28233838f46a80AaaC8c30
|
|
|
6
6
|
export declare const FOXY_STAKING_CONTRACT = "0xee77aa3Fd23BbeBaf94386dD44b548e9a785ea4b";
|
|
7
7
|
export declare const WETH_CONTRACT_MAINNET = "0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2";
|
|
8
8
|
export declare const WETH_CONTRACT_ROPSTEN = "0xc778417E063141139Fce010982780140Aa0cD5Ab";
|
|
9
|
-
//# sourceMappingURL=constants.d.ts.map
|
|
@@ -9,4 +9,3 @@ exports.THOR_ROUTER_CONTRACT_ROPSTEN = '0xefA28233838f46a80AaaC8c309077a9ba70D12
|
|
|
9
9
|
exports.FOXY_STAKING_CONTRACT = '0xee77aa3Fd23BbeBaf94386dD44b548e9a785ea4b';
|
|
10
10
|
exports.WETH_CONTRACT_MAINNET = '0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2';
|
|
11
11
|
exports.WETH_CONTRACT_ROPSTEN = '0xc778417E063141139Fce010982780140Aa0cD5Ab';
|
|
12
|
-
//# sourceMappingURL=constants.js.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Tx as BlockbookTx } from '@shapeshiftoss/blockbook';
|
|
2
2
|
import { ethers } from 'ethers';
|
|
3
|
-
import {
|
|
3
|
+
import { SubParser, TxSpecific } from '../types';
|
|
4
4
|
export declare class Parser implements SubParser {
|
|
5
5
|
readonly abiInterface: ethers.utils.Interface;
|
|
6
6
|
readonly supportedFunctions: {
|
|
@@ -11,4 +11,3 @@ export declare class Parser implements SubParser {
|
|
|
11
11
|
};
|
|
12
12
|
parse(tx: BlockbookTx): Promise<TxSpecific | undefined>;
|
|
13
13
|
}
|
|
14
|
-
//# sourceMappingURL=foxy.d.ts.map
|
|
@@ -1,13 +1,4 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
2
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
4
|
};
|
|
@@ -15,9 +6,9 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
15
6
|
exports.Parser = void 0;
|
|
16
7
|
const ethers_1 = require("ethers");
|
|
17
8
|
const types_1 = require("../../types");
|
|
18
|
-
const utils_1 = require("./utils");
|
|
19
|
-
const constants_1 = require("./constants");
|
|
20
9
|
const foxyStaking_1 = __importDefault(require("./abi/foxyStaking"));
|
|
10
|
+
const constants_1 = require("./constants");
|
|
11
|
+
const utils_1 = require("./utils");
|
|
21
12
|
class Parser {
|
|
22
13
|
constructor() {
|
|
23
14
|
this.abiInterface = new ethers_1.ethers.utils.Interface(foxyStaking_1.default);
|
|
@@ -25,32 +16,29 @@ class Parser {
|
|
|
25
16
|
stakeSigHash: this.abiInterface.getSighash('stake(uint256,address)'),
|
|
26
17
|
unstakeSigHash: this.abiInterface.getSighash('unstake'),
|
|
27
18
|
instantUnstakeSigHash: this.abiInterface.getSighash('instantUnstake'),
|
|
28
|
-
claimWithdrawSigHash: this.abiInterface.getSighash('claimWithdraw')
|
|
19
|
+
claimWithdrawSigHash: this.abiInterface.getSighash('claimWithdraw')
|
|
29
20
|
};
|
|
30
21
|
}
|
|
31
|
-
parse(tx) {
|
|
22
|
+
async parse(tx) {
|
|
32
23
|
var _a;
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
};
|
|
52
|
-
});
|
|
24
|
+
const txData = (_a = tx.ethereumSpecific) === null || _a === void 0 ? void 0 : _a.data;
|
|
25
|
+
if (!(0, utils_1.txInteractsWithContract)(tx, constants_1.FOXY_STAKING_CONTRACT))
|
|
26
|
+
return;
|
|
27
|
+
if (!txData)
|
|
28
|
+
return;
|
|
29
|
+
const txSigHash = (0, utils_1.getSigHash)(txData);
|
|
30
|
+
if (!Object.values(this.supportedFunctions).some((hash) => hash === txSigHash))
|
|
31
|
+
return;
|
|
32
|
+
const decoded = this.abiInterface.parseTransaction({ data: txData });
|
|
33
|
+
// failed to decode input data
|
|
34
|
+
if (!decoded)
|
|
35
|
+
return;
|
|
36
|
+
return {
|
|
37
|
+
data: {
|
|
38
|
+
method: decoded.name,
|
|
39
|
+
parser: types_1.TxParser.Foxy
|
|
40
|
+
}
|
|
41
|
+
};
|
|
53
42
|
}
|
|
54
43
|
}
|
|
55
44
|
exports.Parser = Parser;
|
|
56
|
-
//# sourceMappingURL=foxy.js.map
|
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
3
|
if (k2 === undefined) k2 = k;
|
|
4
|
-
Object.
|
|
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);
|
|
5
9
|
}) : (function(o, m, k, k2) {
|
|
6
10
|
if (k2 === undefined) k2 = k;
|
|
7
11
|
o[k2] = m[k];
|
|
@@ -18,30 +22,21 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
18
22
|
__setModuleDefault(result, mod);
|
|
19
23
|
return result;
|
|
20
24
|
};
|
|
21
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
22
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
23
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
24
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
25
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
26
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
27
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
28
|
-
});
|
|
29
|
-
};
|
|
30
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
31
26
|
exports.TransactionParser = void 0;
|
|
32
|
-
const bignumber_js_1 = require("bignumber.js");
|
|
33
|
-
const ethers_1 = require("ethers");
|
|
34
27
|
const caip_1 = require("@shapeshiftoss/caip");
|
|
35
28
|
const types_1 = require("@shapeshiftoss/types");
|
|
29
|
+
const bignumber_js_1 = require("bignumber.js");
|
|
30
|
+
const ethers_1 = require("ethers");
|
|
36
31
|
const types_2 = require("../../types");
|
|
37
32
|
const utils_1 = require("../../utils");
|
|
38
|
-
const
|
|
33
|
+
const foxy = __importStar(require("./foxy"));
|
|
39
34
|
const thor = __importStar(require("./thor"));
|
|
40
35
|
const uniV2 = __importStar(require("./uniV2"));
|
|
41
|
-
const
|
|
42
|
-
const yearn = __importStar(require("./yearn"));
|
|
43
|
-
const foxy = __importStar(require("./foxy"));
|
|
36
|
+
const utils_2 = require("./utils");
|
|
44
37
|
const weth = __importStar(require("./weth"));
|
|
38
|
+
const yearn = __importStar(require("./yearn"));
|
|
39
|
+
const zrx = __importStar(require("./zrx"));
|
|
45
40
|
class TransactionParser {
|
|
46
41
|
constructor(args) {
|
|
47
42
|
var _a;
|
|
@@ -57,36 +52,34 @@ class TransactionParser {
|
|
|
57
52
|
}
|
|
58
53
|
// return any addresses that can be detected
|
|
59
54
|
getInternalAddress(inputData) {
|
|
60
|
-
switch (utils_2.getSigHash(inputData)) {
|
|
55
|
+
switch ((0, utils_2.getSigHash)(inputData)) {
|
|
61
56
|
case this.thor.supportedFunctions.transferOutSigHash:
|
|
62
57
|
return this.thor.getInternalAddress(inputData);
|
|
63
58
|
case utils_2.SENDMULTISIG_SIG_HASH:
|
|
64
|
-
return utils_2.getInternalMultisigAddress(inputData);
|
|
59
|
+
return (0, utils_2.getInternalMultisigAddress)(inputData);
|
|
65
60
|
default:
|
|
66
61
|
return;
|
|
67
62
|
}
|
|
68
63
|
}
|
|
69
|
-
parse(tx, address, internalTxs) {
|
|
64
|
+
async parse(tx, address, internalTxs) {
|
|
70
65
|
var _a;
|
|
71
|
-
return
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
return this.getParsedTxWithTransfers(tx, parsedTx, address, internalTxs);
|
|
89
|
-
});
|
|
66
|
+
// We expect only one Parser to return a result. If multiple do, we take the first and early exit.
|
|
67
|
+
const contractParserResult = await (0, utils_1.findAsyncSequential)(this.parsers, async (parser) => await parser.parse(tx));
|
|
68
|
+
const parsedTx = {
|
|
69
|
+
address,
|
|
70
|
+
blockHash: tx.blockHash,
|
|
71
|
+
blockHeight: tx.blockHeight,
|
|
72
|
+
blockTime: tx.blockTime,
|
|
73
|
+
caip2: caip_1.caip2.toCAIP2({ chain: types_1.ChainTypes.Ethereum, network: (0, utils_2.toNetworkType)(this.network) }),
|
|
74
|
+
chainId: caip_1.caip2.toCAIP2({ chain: types_1.ChainTypes.Ethereum, network: (0, utils_2.toNetworkType)(this.network) }),
|
|
75
|
+
confirmations: tx.confirmations,
|
|
76
|
+
status: TransactionParser.getStatus(tx),
|
|
77
|
+
trade: contractParserResult === null || contractParserResult === void 0 ? void 0 : contractParserResult.trade,
|
|
78
|
+
transfers: (_a = contractParserResult === null || contractParserResult === void 0 ? void 0 : contractParserResult.transfers) !== null && _a !== void 0 ? _a : [],
|
|
79
|
+
txid: tx.txid,
|
|
80
|
+
data: contractParserResult === null || contractParserResult === void 0 ? void 0 : contractParserResult.data
|
|
81
|
+
};
|
|
82
|
+
return this.getParsedTxWithTransfers(tx, parsedTx, address, internalTxs);
|
|
90
83
|
}
|
|
91
84
|
static getStatus(tx) {
|
|
92
85
|
var _a;
|
|
@@ -103,9 +96,9 @@ class TransactionParser {
|
|
|
103
96
|
var _a, _b, _c, _d, _e, _f;
|
|
104
97
|
const caip19Ethereum = caip_1.caip19.toCAIP19({
|
|
105
98
|
chain: types_1.ChainTypes.Ethereum,
|
|
106
|
-
network: utils_2.toNetworkType(this.network),
|
|
99
|
+
network: (0, utils_2.toNetworkType)(this.network),
|
|
107
100
|
assetNamespace: caip_1.AssetNamespace.Slip44,
|
|
108
|
-
assetReference: caip_1.AssetReference.Ethereum
|
|
101
|
+
assetReference: caip_1.AssetReference.Ethereum
|
|
109
102
|
});
|
|
110
103
|
const sendAddress = (_b = (_a = tx.vin[0].addresses) === null || _a === void 0 ? void 0 : _a[0]) !== null && _b !== void 0 ? _b : '';
|
|
111
104
|
const receiveAddress = (_d = (_c = tx.vout[0].addresses) === null || _c === void 0 ? void 0 : _c[0]) !== null && _d !== void 0 ? _d : '';
|
|
@@ -113,7 +106,7 @@ class TransactionParser {
|
|
|
113
106
|
// send amount
|
|
114
107
|
const sendValue = new bignumber_js_1.BigNumber(tx.value);
|
|
115
108
|
if (sendValue.gt(0)) {
|
|
116
|
-
parsedTx.transfers = utils_1.aggregateTransfer(parsedTx.transfers, types_2.TransferType.Send, caip19Ethereum, sendAddress, receiveAddress, sendValue.toString(10));
|
|
109
|
+
parsedTx.transfers = (0, utils_1.aggregateTransfer)(parsedTx.transfers, types_2.TransferType.Send, caip19Ethereum, sendAddress, receiveAddress, sendValue.toString(10));
|
|
117
110
|
}
|
|
118
111
|
// network fee
|
|
119
112
|
const fees = new bignumber_js_1.BigNumber((_e = tx.fees) !== null && _e !== void 0 ? _e : 0);
|
|
@@ -125,7 +118,7 @@ class TransactionParser {
|
|
|
125
118
|
// receive amount
|
|
126
119
|
const receiveValue = new bignumber_js_1.BigNumber(tx.value);
|
|
127
120
|
if (receiveValue.gt(0)) {
|
|
128
|
-
parsedTx.transfers = utils_1.aggregateTransfer(parsedTx.transfers, types_2.TransferType.Receive, caip19Ethereum, sendAddress, receiveAddress, receiveValue.toString(10));
|
|
121
|
+
parsedTx.transfers = (0, utils_1.aggregateTransfer)(parsedTx.transfers, types_2.TransferType.Receive, caip19Ethereum, sendAddress, receiveAddress, receiveValue.toString(10));
|
|
129
122
|
}
|
|
130
123
|
}
|
|
131
124
|
(_f = tx.tokenTransfers) === null || _f === void 0 ? void 0 : _f.forEach((transfer) => {
|
|
@@ -138,52 +131,51 @@ class TransactionParser {
|
|
|
138
131
|
contract: transfer.token,
|
|
139
132
|
decimals: transfer.decimals,
|
|
140
133
|
name: transfer.name,
|
|
141
|
-
symbol: transfer.symbol
|
|
134
|
+
symbol: transfer.symbol
|
|
142
135
|
};
|
|
143
136
|
const transferArgs = [
|
|
144
137
|
caip_1.caip19.toCAIP19({
|
|
145
138
|
chain: types_1.ChainTypes.Ethereum,
|
|
146
|
-
network: utils_2.toNetworkType(this.network),
|
|
139
|
+
network: (0, utils_2.toNetworkType)(this.network),
|
|
147
140
|
assetNamespace: caip_1.AssetNamespace.ERC20,
|
|
148
|
-
assetReference: transfer.token
|
|
141
|
+
assetReference: transfer.token
|
|
149
142
|
}),
|
|
150
143
|
transfer.from,
|
|
151
144
|
transfer.to,
|
|
152
145
|
transfer.value,
|
|
153
|
-
token
|
|
146
|
+
token
|
|
154
147
|
];
|
|
155
148
|
// token send amount
|
|
156
149
|
if (address === transfer.from) {
|
|
157
|
-
parsedTx.transfers = utils_1.aggregateTransfer(parsedTx.transfers, types_2.TransferType.Send, ...transferArgs);
|
|
150
|
+
parsedTx.transfers = (0, utils_1.aggregateTransfer)(parsedTx.transfers, types_2.TransferType.Send, ...transferArgs);
|
|
158
151
|
}
|
|
159
152
|
// token receive amount
|
|
160
153
|
if (address === transfer.to) {
|
|
161
|
-
parsedTx.transfers = utils_1.aggregateTransfer(parsedTx.transfers, types_2.TransferType.Receive, ...transferArgs);
|
|
154
|
+
parsedTx.transfers = (0, utils_1.aggregateTransfer)(parsedTx.transfers, types_2.TransferType.Receive, ...transferArgs);
|
|
162
155
|
}
|
|
163
156
|
});
|
|
164
157
|
internalTxs === null || internalTxs === void 0 ? void 0 : internalTxs.forEach((internalTx) => {
|
|
165
158
|
const transferArgs = [
|
|
166
159
|
caip_1.caip19.toCAIP19({
|
|
167
160
|
chain: types_1.ChainTypes.Ethereum,
|
|
168
|
-
network: utils_2.toNetworkType(this.network),
|
|
161
|
+
network: (0, utils_2.toNetworkType)(this.network),
|
|
169
162
|
assetNamespace: caip_1.AssetNamespace.Slip44,
|
|
170
|
-
assetReference: caip_1.AssetReference.Ethereum
|
|
163
|
+
assetReference: caip_1.AssetReference.Ethereum
|
|
171
164
|
}),
|
|
172
165
|
internalTx.from,
|
|
173
166
|
internalTx.to,
|
|
174
|
-
internalTx.value
|
|
167
|
+
internalTx.value
|
|
175
168
|
];
|
|
176
169
|
// internal eth send
|
|
177
170
|
if (address === internalTx.from) {
|
|
178
|
-
parsedTx.transfers = utils_1.aggregateTransfer(parsedTx.transfers, types_2.TransferType.Send, ...transferArgs);
|
|
171
|
+
parsedTx.transfers = (0, utils_1.aggregateTransfer)(parsedTx.transfers, types_2.TransferType.Send, ...transferArgs);
|
|
179
172
|
}
|
|
180
173
|
// internal eth receive
|
|
181
174
|
if (address === internalTx.to) {
|
|
182
|
-
parsedTx.transfers = utils_1.aggregateTransfer(parsedTx.transfers, types_2.TransferType.Receive, ...transferArgs);
|
|
175
|
+
parsedTx.transfers = (0, utils_1.aggregateTransfer)(parsedTx.transfers, types_2.TransferType.Receive, ...transferArgs);
|
|
183
176
|
}
|
|
184
177
|
});
|
|
185
178
|
return parsedTx;
|
|
186
179
|
}
|
|
187
180
|
}
|
|
188
181
|
exports.TransactionParser = TransactionParser;
|
|
189
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { ethers } from 'ethers';
|
|
2
1
|
import { Tx as BlockbookTx } from '@shapeshiftoss/blockbook';
|
|
2
|
+
import { ethers } from 'ethers';
|
|
3
3
|
import { Network, SubParser, TxSpecific } from '../types';
|
|
4
4
|
export interface ParserArgs {
|
|
5
5
|
network: Network;
|
|
@@ -16,4 +16,3 @@ export declare class Parser implements SubParser {
|
|
|
16
16
|
getInternalAddress(inputData: string): string | undefined;
|
|
17
17
|
parse(tx: BlockbookTx): Promise<TxSpecific | undefined>;
|
|
18
18
|
}
|
|
19
|
-
//# sourceMappingURL=thor.d.ts.map
|
|
@@ -1,13 +1,4 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
2
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
4
|
};
|
|
@@ -16,25 +7,25 @@ exports.Parser = void 0;
|
|
|
16
7
|
const ethers_1 = require("ethers");
|
|
17
8
|
const types_1 = require("../../types");
|
|
18
9
|
const thor_1 = __importDefault(require("./abi/thor"));
|
|
19
|
-
const utils_1 = require("./utils");
|
|
20
10
|
const constants_1 = require("./constants");
|
|
11
|
+
const utils_1 = require("./utils");
|
|
21
12
|
const SWAP_TYPES = ['SWAP', '=', 's'];
|
|
22
13
|
class Parser {
|
|
23
14
|
constructor(args) {
|
|
24
15
|
this.abiInterface = new ethers_1.ethers.utils.Interface(thor_1.default);
|
|
25
16
|
this.supportedFunctions = {
|
|
26
17
|
depositSigHash: this.abiInterface.getSighash('deposit'),
|
|
27
|
-
transferOutSigHash: this.abiInterface.getSighash('transferOut')
|
|
18
|
+
transferOutSigHash: this.abiInterface.getSighash('transferOut')
|
|
28
19
|
};
|
|
29
20
|
// TODO: Router contract can change, use /inbound_addresses endpoint to determine current router contract
|
|
30
21
|
this.routerContract = {
|
|
31
22
|
mainnet: constants_1.THOR_ROUTER_CONTRACT_MAINNET,
|
|
32
|
-
ropsten: constants_1.THOR_ROUTER_CONTRACT_ROPSTEN
|
|
23
|
+
ropsten: constants_1.THOR_ROUTER_CONTRACT_ROPSTEN
|
|
33
24
|
}[args.network];
|
|
34
25
|
}
|
|
35
26
|
// detect address associated with transferOut internal transaction
|
|
36
27
|
getInternalAddress(inputData) {
|
|
37
|
-
if (utils_1.getSigHash(inputData) !== this.supportedFunctions.transferOutSigHash)
|
|
28
|
+
if ((0, utils_1.getSigHash)(inputData) !== this.supportedFunctions.transferOutSigHash)
|
|
38
29
|
return;
|
|
39
30
|
const result = this.abiInterface.decodeFunctionData(this.supportedFunctions.transferOutSigHash, inputData);
|
|
40
31
|
const [type] = result.memo.split(':');
|
|
@@ -42,36 +33,33 @@ class Parser {
|
|
|
42
33
|
return;
|
|
43
34
|
return result.to;
|
|
44
35
|
}
|
|
45
|
-
parse(tx) {
|
|
36
|
+
async parse(tx) {
|
|
46
37
|
var _a;
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
if (!txData)
|
|
52
|
-
return;
|
|
53
|
-
const txSigHash = utils_1.getSigHash(txData);
|
|
54
|
-
if (!Object.values(this.supportedFunctions).some((hash) => hash === txSigHash))
|
|
55
|
-
return;
|
|
56
|
-
const decoded = this.abiInterface.parseTransaction({ data: txData });
|
|
57
|
-
// failed to decode input data
|
|
58
|
-
if (!decoded)
|
|
59
|
-
return;
|
|
60
|
-
const data = {
|
|
61
|
-
method: decoded.name,
|
|
62
|
-
parser: types_1.TxParser.Thor,
|
|
63
|
-
};
|
|
64
|
-
const [type] = decoded.args.memo.split(':');
|
|
65
|
-
if (SWAP_TYPES.includes(type) || type === 'OUT') {
|
|
66
|
-
return { trade: { dexName: types_1.Dex.Thor, type: types_1.TradeType.Trade, memo: decoded.args.memo }, data };
|
|
67
|
-
}
|
|
68
|
-
if (type === 'REFUND') {
|
|
69
|
-
return { trade: { dexName: types_1.Dex.Thor, type: types_1.TradeType.Refund, memo: decoded.args.memo }, data };
|
|
70
|
-
}
|
|
71
|
-
// memo type not supported
|
|
38
|
+
const txData = (_a = tx.ethereumSpecific) === null || _a === void 0 ? void 0 : _a.data;
|
|
39
|
+
if (!(0, utils_1.txInteractsWithContract)(tx, this.routerContract))
|
|
40
|
+
return;
|
|
41
|
+
if (!txData)
|
|
72
42
|
return;
|
|
73
|
-
|
|
43
|
+
const txSigHash = (0, utils_1.getSigHash)(txData);
|
|
44
|
+
if (!Object.values(this.supportedFunctions).some((hash) => hash === txSigHash))
|
|
45
|
+
return;
|
|
46
|
+
const decoded = this.abiInterface.parseTransaction({ data: txData });
|
|
47
|
+
// failed to decode input data
|
|
48
|
+
if (!decoded)
|
|
49
|
+
return;
|
|
50
|
+
const data = {
|
|
51
|
+
method: decoded.name,
|
|
52
|
+
parser: types_1.TxParser.Thor
|
|
53
|
+
};
|
|
54
|
+
const [type] = decoded.args.memo.split(':');
|
|
55
|
+
if (SWAP_TYPES.includes(type) || type === 'OUT') {
|
|
56
|
+
return { trade: { dexName: types_1.Dex.Thor, type: types_1.TradeType.Trade, memo: decoded.args.memo }, data };
|
|
57
|
+
}
|
|
58
|
+
if (type === 'REFUND') {
|
|
59
|
+
return { trade: { dexName: types_1.Dex.Thor, type: types_1.TradeType.Refund, memo: decoded.args.memo }, data };
|
|
60
|
+
}
|
|
61
|
+
// memo type not supported
|
|
62
|
+
return;
|
|
74
63
|
}
|
|
75
64
|
}
|
|
76
65
|
exports.Parser = Parser;
|
|
77
|
-
//# sourceMappingURL=thor.js.map
|