@shapeshiftoss/unchained-client 8.3.3 → 9.0.0-alpha.0
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/dist/bitcoin/parser/index.d.ts +2 -3
- package/dist/bitcoin/parser/index.js +4 -4
- package/dist/ethereum/parser/foxy.d.ts +2 -2
- package/dist/ethereum/parser/foxy.js +3 -5
- package/dist/ethereum/parser/index.d.ts +3 -4
- package/dist/ethereum/parser/index.js +17 -31
- package/dist/ethereum/parser/thor.d.ts +2 -3
- package/dist/ethereum/parser/thor.js +3 -15
- package/dist/ethereum/parser/uniV2.d.ts +4 -4
- package/dist/ethereum/parser/uniV2.js +9 -14
- package/dist/ethereum/parser/utils.d.ts +2 -4
- package/dist/ethereum/parser/utils.js +2 -22
- package/dist/ethereum/parser/weth.d.ts +2 -2
- package/dist/ethereum/parser/weth.js +5 -8
- package/dist/ethereum/parser/yearn.d.ts +2 -2
- package/dist/ethereum/parser/yearn.js +7 -9
- package/dist/ethereum/parser/zrx.d.ts +2 -2
- package/dist/ethereum/types.d.ts +2 -18
- package/dist/generated/bitcoin/api.d.ts +211 -188
- package/dist/generated/bitcoin/api.js +62 -5
- package/dist/generated/bitcoin/base.js +1 -1
- package/dist/generated/ethereum/api.d.ts +77 -4
- package/dist/generated/ethereum/api.js +57 -0
- package/dist/generated/ethereum/base.js +1 -1
- package/dist/websocket.d.ts +2 -1
- package/dist/websocket.js +36 -23
- package/package.json +5 -5
- package/dist/ethereum/parser/abi/multiSig.d.ts +0 -3
- package/dist/ethereum/parser/abi/multiSig.js +0 -368
|
@@ -1,13 +1,12 @@
|
|
|
1
|
-
import { Tx as BlockbookTx } from '@shapeshiftoss/blockbook';
|
|
2
1
|
import { AssetId, ChainId } from '@shapeshiftoss/caip';
|
|
2
|
+
import { BitcoinTx } from '../../generated/bitcoin';
|
|
3
3
|
import { Tx as ParsedTx } from '../../types';
|
|
4
4
|
export interface TransactionParserArgs {
|
|
5
5
|
chainId: ChainId;
|
|
6
|
-
rpcUrl: string;
|
|
7
6
|
}
|
|
8
7
|
export declare class TransactionParser {
|
|
9
8
|
chainId: ChainId;
|
|
10
9
|
assetId: AssetId;
|
|
11
10
|
constructor(args: TransactionParserArgs);
|
|
12
|
-
parse(tx:
|
|
11
|
+
parse(tx: BitcoinTx, address: string): Promise<ParsedTx>;
|
|
13
12
|
}
|
|
@@ -19,7 +19,7 @@ class TransactionParser {
|
|
|
19
19
|
address,
|
|
20
20
|
blockHash: tx.blockHash,
|
|
21
21
|
blockHeight: tx.blockHeight,
|
|
22
|
-
blockTime: tx.
|
|
22
|
+
blockTime: tx.timestamp,
|
|
23
23
|
chainId: this.chainId,
|
|
24
24
|
confirmations: tx.confirmations,
|
|
25
25
|
status: tx.confirmations > 0 ? types_1.Status.Confirmed : types_1.Status.Pending,
|
|
@@ -28,14 +28,14 @@ class TransactionParser {
|
|
|
28
28
|
};
|
|
29
29
|
tx.vin.forEach((vin) => {
|
|
30
30
|
var _a, _b, _c, _d, _e, _f, _g;
|
|
31
|
-
if (
|
|
31
|
+
if ((_a = vin.addresses) === null || _a === void 0 ? void 0 : _a.includes(address)) {
|
|
32
32
|
// send amount
|
|
33
33
|
const sendValue = new bignumber_js_1.BigNumber((_b = vin.value) !== null && _b !== void 0 ? _b : 0);
|
|
34
34
|
if (sendValue.gt(0)) {
|
|
35
35
|
parsedTx.transfers = (0, utils_1.aggregateTransfer)(parsedTx.transfers, types_1.TransferType.Send, this.assetId, (_d = (_c = vin.addresses) === null || _c === void 0 ? void 0 : _c[0]) !== null && _d !== void 0 ? _d : '', (_f = (_e = tx.vout[0].addresses) === null || _e === void 0 ? void 0 : _e[0]) !== null && _f !== void 0 ? _f : '', sendValue.toString(10));
|
|
36
36
|
}
|
|
37
37
|
// network fee
|
|
38
|
-
const fees = new bignumber_js_1.BigNumber((_g = tx.
|
|
38
|
+
const fees = new bignumber_js_1.BigNumber((_g = tx.fee) !== null && _g !== void 0 ? _g : 0);
|
|
39
39
|
if (fees.gt(0)) {
|
|
40
40
|
parsedTx.fee = { assetId: this.assetId, value: fees.toString(10) };
|
|
41
41
|
}
|
|
@@ -43,7 +43,7 @@ class TransactionParser {
|
|
|
43
43
|
});
|
|
44
44
|
tx.vout.forEach((vout) => {
|
|
45
45
|
var _a, _b, _c, _d, _e, _f;
|
|
46
|
-
if (
|
|
46
|
+
if ((_a = vout.addresses) === null || _a === void 0 ? void 0 : _a.includes(address)) {
|
|
47
47
|
// receive amount
|
|
48
48
|
const receiveValue = new bignumber_js_1.BigNumber((_b = vout.value) !== null && _b !== void 0 ? _b : 0);
|
|
49
49
|
if (receiveValue.gt(0)) {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { Tx as BlockbookTx } from '@shapeshiftoss/blockbook';
|
|
2
1
|
import { ethers } from 'ethers';
|
|
2
|
+
import { EthereumTx } from '../../generated/ethereum';
|
|
3
3
|
import { SubParser, TxSpecific } from '../types';
|
|
4
4
|
export declare class Parser implements SubParser {
|
|
5
5
|
readonly abiInterface: ethers.utils.Interface;
|
|
@@ -9,5 +9,5 @@ export declare class Parser implements SubParser {
|
|
|
9
9
|
instantUnstakeSigHash: string;
|
|
10
10
|
claimWithdrawSigHash: string;
|
|
11
11
|
};
|
|
12
|
-
parse(tx:
|
|
12
|
+
parse(tx: EthereumTx): Promise<TxSpecific | undefined>;
|
|
13
13
|
}
|
|
@@ -20,16 +20,14 @@ class Parser {
|
|
|
20
20
|
};
|
|
21
21
|
}
|
|
22
22
|
async parse(tx) {
|
|
23
|
-
var _a;
|
|
24
|
-
const txData = (_a = tx.ethereumSpecific) === null || _a === void 0 ? void 0 : _a.data;
|
|
25
23
|
if (!(0, utils_1.txInteractsWithContract)(tx, constants_1.FOXY_STAKING_CONTRACT))
|
|
26
24
|
return;
|
|
27
|
-
if (!
|
|
25
|
+
if (!tx.inputData)
|
|
28
26
|
return;
|
|
29
|
-
const txSigHash = (0, utils_1.getSigHash)(
|
|
27
|
+
const txSigHash = (0, utils_1.getSigHash)(tx.inputData);
|
|
30
28
|
if (!Object.values(this.supportedFunctions).some((hash) => hash === txSigHash))
|
|
31
29
|
return;
|
|
32
|
-
const decoded = this.abiInterface.parseTransaction({ data:
|
|
30
|
+
const decoded = this.abiInterface.parseTransaction({ data: tx.inputData });
|
|
33
31
|
// failed to decode input data
|
|
34
32
|
if (!decoded)
|
|
35
33
|
return;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { Tx as BlockbookTx } from '@shapeshiftoss/blockbook';
|
|
2
1
|
import { AssetId, ChainId } from '@shapeshiftoss/caip';
|
|
3
|
-
import {
|
|
2
|
+
import { EthereumTx } from '../../generated/ethereum';
|
|
3
|
+
import { ParsedTx } from '../types';
|
|
4
4
|
export interface TransactionParserArgs {
|
|
5
5
|
chainId: ChainId;
|
|
6
6
|
rpcUrl: string;
|
|
@@ -16,8 +16,7 @@ export declare class TransactionParser {
|
|
|
16
16
|
private readonly weth;
|
|
17
17
|
private readonly parsers;
|
|
18
18
|
constructor(args: TransactionParserArgs);
|
|
19
|
-
|
|
20
|
-
parse(tx: BlockbookTx, address: string, internalTxs?: Array<InternalTx>): Promise<ParsedTx>;
|
|
19
|
+
parse(tx: EthereumTx, address: string): Promise<ParsedTx>;
|
|
21
20
|
private static getStatus;
|
|
22
21
|
private getParsedTxWithTransfers;
|
|
23
22
|
}
|
|
@@ -32,7 +32,6 @@ const utils_1 = require("../../utils");
|
|
|
32
32
|
const foxy = __importStar(require("./foxy"));
|
|
33
33
|
const thor = __importStar(require("./thor"));
|
|
34
34
|
const uniV2 = __importStar(require("./uniV2"));
|
|
35
|
-
const utils_2 = require("./utils");
|
|
36
35
|
const weth = __importStar(require("./weth"));
|
|
37
36
|
const yearn = __importStar(require("./yearn"));
|
|
38
37
|
const zrx = __importStar(require("./zrx"));
|
|
@@ -53,26 +52,16 @@ class TransactionParser {
|
|
|
53
52
|
this.weth = new weth.Parser({ chainId: this.chainId, provider });
|
|
54
53
|
this.parsers = [this.zrx, this.thor, this.uniV2, this.yearn, this.foxy, this.weth];
|
|
55
54
|
}
|
|
56
|
-
|
|
57
|
-
getInternalAddress(inputData) {
|
|
58
|
-
switch ((0, utils_2.getSigHash)(inputData)) {
|
|
59
|
-
case this.thor.supportedFunctions.transferOutSigHash:
|
|
60
|
-
return this.thor.getInternalAddress(inputData);
|
|
61
|
-
case utils_2.SENDMULTISIG_SIG_HASH:
|
|
62
|
-
return (0, utils_2.getInternalMultisigAddress)(inputData);
|
|
63
|
-
default:
|
|
64
|
-
return;
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
async parse(tx, address, internalTxs) {
|
|
55
|
+
async parse(tx, address) {
|
|
68
56
|
var _a;
|
|
57
|
+
address = ethers_1.ethers.utils.getAddress(address);
|
|
69
58
|
// We expect only one Parser to return a result. If multiple do, we take the first and early exit.
|
|
70
59
|
const contractParserResult = await (0, utils_1.findAsyncSequential)(this.parsers, async (parser) => await parser.parse(tx));
|
|
71
60
|
const parsedTx = {
|
|
72
61
|
address,
|
|
73
62
|
blockHash: tx.blockHash,
|
|
74
63
|
blockHeight: tx.blockHeight,
|
|
75
|
-
blockTime: tx.
|
|
64
|
+
blockTime: tx.timestamp,
|
|
76
65
|
chainId: this.chainId,
|
|
77
66
|
confirmations: tx.confirmations,
|
|
78
67
|
status: TransactionParser.getStatus(tx),
|
|
@@ -81,11 +70,10 @@ class TransactionParser {
|
|
|
81
70
|
txid: tx.txid,
|
|
82
71
|
data: contractParserResult === null || contractParserResult === void 0 ? void 0 : contractParserResult.data
|
|
83
72
|
};
|
|
84
|
-
return this.getParsedTxWithTransfers(tx, parsedTx, address
|
|
73
|
+
return this.getParsedTxWithTransfers(tx, parsedTx, address);
|
|
85
74
|
}
|
|
86
75
|
static getStatus(tx) {
|
|
87
|
-
|
|
88
|
-
const status = (_a = tx.ethereumSpecific) === null || _a === void 0 ? void 0 : _a.status;
|
|
76
|
+
const status = tx.status;
|
|
89
77
|
if (status === -1 && tx.confirmations <= 0)
|
|
90
78
|
return types_1.Status.Pending;
|
|
91
79
|
if (status === 1 && tx.confirmations > 0)
|
|
@@ -94,37 +82,35 @@ class TransactionParser {
|
|
|
94
82
|
return types_1.Status.Failed;
|
|
95
83
|
return types_1.Status.Unknown;
|
|
96
84
|
}
|
|
97
|
-
getParsedTxWithTransfers(tx, parsedTx, address
|
|
98
|
-
var _a, _b
|
|
99
|
-
|
|
100
|
-
const receiveAddress = (_d = (_c = tx.vout[0].addresses) === null || _c === void 0 ? void 0 : _c[0]) !== null && _d !== void 0 ? _d : '';
|
|
101
|
-
if (address === sendAddress) {
|
|
85
|
+
getParsedTxWithTransfers(tx, parsedTx, address) {
|
|
86
|
+
var _a, _b;
|
|
87
|
+
if (address === tx.from) {
|
|
102
88
|
// send amount
|
|
103
89
|
const sendValue = new bignumber_js_1.BigNumber(tx.value);
|
|
104
90
|
if (sendValue.gt(0)) {
|
|
105
|
-
parsedTx.transfers = (0, utils_1.aggregateTransfer)(parsedTx.transfers, types_1.TransferType.Send, this.assetId,
|
|
91
|
+
parsedTx.transfers = (0, utils_1.aggregateTransfer)(parsedTx.transfers, types_1.TransferType.Send, this.assetId, tx.from, tx.to, sendValue.toString(10));
|
|
106
92
|
}
|
|
107
93
|
// network fee
|
|
108
|
-
const fees = new bignumber_js_1.BigNumber(
|
|
94
|
+
const fees = new bignumber_js_1.BigNumber(tx.fee);
|
|
109
95
|
if (fees.gt(0)) {
|
|
110
96
|
parsedTx.fee = { assetId: this.assetId, value: fees.toString(10) };
|
|
111
97
|
}
|
|
112
98
|
}
|
|
113
|
-
if (address ===
|
|
99
|
+
if (address === tx.to) {
|
|
114
100
|
// receive amount
|
|
115
101
|
const receiveValue = new bignumber_js_1.BigNumber(tx.value);
|
|
116
102
|
if (receiveValue.gt(0)) {
|
|
117
|
-
parsedTx.transfers = (0, utils_1.aggregateTransfer)(parsedTx.transfers, types_1.TransferType.Receive, this.assetId,
|
|
103
|
+
parsedTx.transfers = (0, utils_1.aggregateTransfer)(parsedTx.transfers, types_1.TransferType.Receive, this.assetId, tx.from, tx.to, receiveValue.toString(10));
|
|
118
104
|
}
|
|
119
105
|
}
|
|
120
|
-
(
|
|
106
|
+
(_a = tx.tokenTransfers) === null || _a === void 0 ? void 0 : _a.forEach((transfer) => {
|
|
121
107
|
// FTX Token (FTT) name and symbol was set backwards on the ERC20 contract
|
|
122
|
-
if (transfer.
|
|
108
|
+
if (transfer.contract === '0x50D1c9771902476076eCFc8B2A83Ad6b9355a4c9') {
|
|
123
109
|
transfer.name = transfer.symbol;
|
|
124
110
|
transfer.symbol = transfer.name;
|
|
125
111
|
}
|
|
126
112
|
const token = {
|
|
127
|
-
contract: transfer.
|
|
113
|
+
contract: transfer.contract,
|
|
128
114
|
decimals: transfer.decimals,
|
|
129
115
|
name: transfer.name,
|
|
130
116
|
symbol: transfer.symbol
|
|
@@ -133,7 +119,7 @@ class TransactionParser {
|
|
|
133
119
|
(0, caip_1.toAssetId)({
|
|
134
120
|
...(0, caip_1.fromChainId)(this.chainId),
|
|
135
121
|
assetNamespace: 'erc20',
|
|
136
|
-
assetReference: transfer.
|
|
122
|
+
assetReference: transfer.contract
|
|
137
123
|
}),
|
|
138
124
|
transfer.from,
|
|
139
125
|
transfer.to,
|
|
@@ -149,7 +135,7 @@ class TransactionParser {
|
|
|
149
135
|
parsedTx.transfers = (0, utils_1.aggregateTransfer)(parsedTx.transfers, types_1.TransferType.Receive, ...transferArgs);
|
|
150
136
|
}
|
|
151
137
|
});
|
|
152
|
-
internalTxs === null ||
|
|
138
|
+
(_b = tx.internalTxs) === null || _b === void 0 ? void 0 : _b.forEach((internalTx) => {
|
|
153
139
|
const transferArgs = [
|
|
154
140
|
(0, caip_1.toAssetId)({
|
|
155
141
|
...(0, caip_1.fromChainId)(this.chainId),
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { Tx as BlockbookTx } from '@shapeshiftoss/blockbook';
|
|
2
1
|
import { ChainId } from '@shapeshiftoss/caip';
|
|
3
2
|
import { ethers } from 'ethers';
|
|
3
|
+
import { EthereumTx } from '../../generated/ethereum';
|
|
4
4
|
import { SubParser, TxSpecific } from '../types';
|
|
5
5
|
export interface ParserArgs {
|
|
6
6
|
chainId: ChainId;
|
|
@@ -14,6 +14,5 @@ export declare class Parser implements SubParser {
|
|
|
14
14
|
transferOutSigHash: string;
|
|
15
15
|
};
|
|
16
16
|
constructor(args: ParserArgs);
|
|
17
|
-
|
|
18
|
-
parse(tx: BlockbookTx): Promise<TxSpecific | undefined>;
|
|
17
|
+
parse(tx: EthereumTx): Promise<TxSpecific | undefined>;
|
|
19
18
|
}
|
|
@@ -30,27 +30,15 @@ class Parser {
|
|
|
30
30
|
throw new Error('chainId is not supported. (supported chainIds: eip155:1, eip155:3)');
|
|
31
31
|
}
|
|
32
32
|
}
|
|
33
|
-
// detect address associated with transferOut internal transaction
|
|
34
|
-
getInternalAddress(inputData) {
|
|
35
|
-
if ((0, utils_1.getSigHash)(inputData) !== this.supportedFunctions.transferOutSigHash)
|
|
36
|
-
return;
|
|
37
|
-
const result = this.abiInterface.decodeFunctionData(this.supportedFunctions.transferOutSigHash, inputData);
|
|
38
|
-
const [type] = result.memo.split(':');
|
|
39
|
-
if (type !== 'OUT' || type !== 'REFUND')
|
|
40
|
-
return;
|
|
41
|
-
return result.to;
|
|
42
|
-
}
|
|
43
33
|
async parse(tx) {
|
|
44
|
-
var _a;
|
|
45
|
-
const txData = (_a = tx.ethereumSpecific) === null || _a === void 0 ? void 0 : _a.data;
|
|
46
34
|
if (!(0, utils_1.txInteractsWithContract)(tx, this.routerContract))
|
|
47
35
|
return;
|
|
48
|
-
if (!
|
|
36
|
+
if (!tx.inputData)
|
|
49
37
|
return;
|
|
50
|
-
const txSigHash = (0, utils_1.getSigHash)(
|
|
38
|
+
const txSigHash = (0, utils_1.getSigHash)(tx.inputData);
|
|
51
39
|
if (!Object.values(this.supportedFunctions).some((hash) => hash === txSigHash))
|
|
52
40
|
return;
|
|
53
|
-
const decoded = this.abiInterface.parseTransaction({ data:
|
|
41
|
+
const decoded = this.abiInterface.parseTransaction({ data: tx.inputData });
|
|
54
42
|
// failed to decode input data
|
|
55
43
|
if (!decoded)
|
|
56
44
|
return;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { Tx as BlockbookTx } from '@shapeshiftoss/blockbook';
|
|
2
1
|
import { ChainId } from '@shapeshiftoss/caip';
|
|
3
2
|
import { ethers } from 'ethers';
|
|
3
|
+
import { EthereumTx } from '../../generated/ethereum';
|
|
4
4
|
import { SubParser, TxSpecific } from '../types';
|
|
5
5
|
export interface ParserArgs {
|
|
6
6
|
chainId: ChainId;
|
|
@@ -21,8 +21,8 @@ export declare class Parser implements SubParser {
|
|
|
21
21
|
exitSigHash: string;
|
|
22
22
|
};
|
|
23
23
|
constructor(args: ParserArgs);
|
|
24
|
-
parseUniV2(tx:
|
|
25
|
-
parseStakingRewards(tx:
|
|
26
|
-
parse(tx:
|
|
24
|
+
parseUniV2(tx: EthereumTx): Promise<TxSpecific | undefined>;
|
|
25
|
+
parseStakingRewards(tx: EthereumTx): Promise<TxSpecific | undefined>;
|
|
26
|
+
parse(tx: EthereumTx): Promise<TxSpecific | undefined>;
|
|
27
27
|
private static pairFor;
|
|
28
28
|
}
|
|
@@ -38,24 +38,21 @@ class Parser {
|
|
|
38
38
|
}
|
|
39
39
|
}
|
|
40
40
|
async parseUniV2(tx) {
|
|
41
|
-
|
|
42
|
-
const txData = (_a = tx.ethereumSpecific) === null || _a === void 0 ? void 0 : _a.data;
|
|
43
|
-
if (!txData)
|
|
41
|
+
if (!tx.inputData)
|
|
44
42
|
return;
|
|
45
43
|
if (tx.confirmations)
|
|
46
44
|
return;
|
|
47
|
-
const txSigHash = (0, utils_1.getSigHash)(
|
|
45
|
+
const txSigHash = (0, utils_1.getSigHash)(tx.inputData);
|
|
48
46
|
if (!Object.values(this.supportedFunctions).some((hash) => hash === txSigHash))
|
|
49
47
|
return;
|
|
50
|
-
const decoded = this.abiInterface.parseTransaction({ data:
|
|
48
|
+
const decoded = this.abiInterface.parseTransaction({ data: tx.inputData });
|
|
51
49
|
// failed to decode input data
|
|
52
50
|
if (!decoded)
|
|
53
51
|
return;
|
|
54
|
-
const sendAddress = (_c = (_b = tx.vin[0].addresses) === null || _b === void 0 ? void 0 : _b[0]) !== null && _c !== void 0 ? _c : '';
|
|
55
52
|
const tokenAddress = ethers_1.ethers.utils.getAddress(decoded.args.token.toLowerCase());
|
|
56
53
|
const lpTokenAddress = Parser.pairFor(tokenAddress, this.wethContract);
|
|
57
54
|
const transfers = await (async () => {
|
|
58
|
-
switch ((0, utils_1.getSigHash)(
|
|
55
|
+
switch ((0, utils_1.getSigHash)(tx.inputData)) {
|
|
59
56
|
case this.supportedFunctions.addLiquidityEthSigHash: {
|
|
60
57
|
const contract = new ethers_1.ethers.Contract(tokenAddress, erc20_1.default, this.provider);
|
|
61
58
|
const decimals = await contract.decimals();
|
|
@@ -70,7 +67,7 @@ class Parser {
|
|
|
70
67
|
return [
|
|
71
68
|
{
|
|
72
69
|
type: types_1.TransferType.Send,
|
|
73
|
-
from:
|
|
70
|
+
from: tx.from,
|
|
74
71
|
to: lpTokenAddress,
|
|
75
72
|
assetId,
|
|
76
73
|
totalValue: value,
|
|
@@ -93,7 +90,7 @@ class Parser {
|
|
|
93
90
|
return [
|
|
94
91
|
{
|
|
95
92
|
type: types_1.TransferType.Send,
|
|
96
|
-
from:
|
|
93
|
+
from: tx.from,
|
|
97
94
|
to: lpTokenAddress,
|
|
98
95
|
assetId,
|
|
99
96
|
totalValue: value,
|
|
@@ -118,14 +115,12 @@ class Parser {
|
|
|
118
115
|
};
|
|
119
116
|
}
|
|
120
117
|
async parseStakingRewards(tx) {
|
|
121
|
-
|
|
122
|
-
const txData = (_a = tx.ethereumSpecific) === null || _a === void 0 ? void 0 : _a.data;
|
|
123
|
-
if (!txData)
|
|
118
|
+
if (!tx.inputData)
|
|
124
119
|
return;
|
|
125
|
-
const txSigHash = (0, utils_1.getSigHash)(
|
|
120
|
+
const txSigHash = (0, utils_1.getSigHash)(tx.inputData);
|
|
126
121
|
if (!Object.values(this.supportedStakingRewardsFunctions).some((hash) => hash === txSigHash))
|
|
127
122
|
return;
|
|
128
|
-
const decoded = this.stakingRewardsInterface.parseTransaction({ data:
|
|
123
|
+
const decoded = this.stakingRewardsInterface.parseTransaction({ data: tx.inputData });
|
|
129
124
|
// failed to decode input data
|
|
130
125
|
if (!decoded)
|
|
131
126
|
return;
|
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { EthereumTx } from '../../generated/ethereum';
|
|
2
2
|
export declare const getSigHash: (inputData: string | undefined) => string | undefined;
|
|
3
|
-
export declare const txInteractsWithContract: (tx:
|
|
4
|
-
export declare const SENDMULTISIG_SIG_HASH: string;
|
|
5
|
-
export declare const getInternalMultisigAddress: (inputData: string) => string | undefined;
|
|
3
|
+
export declare const txInteractsWithContract: (tx: EthereumTx, contract: string) => boolean;
|
|
@@ -1,11 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.
|
|
7
|
-
const ethers_1 = require("ethers");
|
|
8
|
-
const multiSig_1 = __importDefault(require("./abi/multiSig"));
|
|
3
|
+
exports.txInteractsWithContract = exports.getSigHash = void 0;
|
|
9
4
|
const getSigHash = (inputData) => {
|
|
10
5
|
if (!inputData)
|
|
11
6
|
return;
|
|
@@ -14,21 +9,6 @@ const getSigHash = (inputData) => {
|
|
|
14
9
|
};
|
|
15
10
|
exports.getSigHash = getSigHash;
|
|
16
11
|
const txInteractsWithContract = (tx, contract) => {
|
|
17
|
-
|
|
18
|
-
const receiveAddress = (_b = (_a = tx.vout[0].addresses) === null || _a === void 0 ? void 0 : _a[0]) !== null && _b !== void 0 ? _b : '';
|
|
19
|
-
return receiveAddress === contract;
|
|
12
|
+
return tx.to === contract;
|
|
20
13
|
};
|
|
21
14
|
exports.txInteractsWithContract = txInteractsWithContract;
|
|
22
|
-
exports.SENDMULTISIG_SIG_HASH = (() => {
|
|
23
|
-
const abiInterface = new ethers_1.ethers.utils.Interface(multiSig_1.default);
|
|
24
|
-
return abiInterface.getSighash('sendMultiSig');
|
|
25
|
-
})();
|
|
26
|
-
// detect address associated with sendMultiSig internal transaction
|
|
27
|
-
const getInternalMultisigAddress = (inputData) => {
|
|
28
|
-
const abiInterface = new ethers_1.ethers.utils.Interface(multiSig_1.default);
|
|
29
|
-
if ((0, exports.getSigHash)(inputData) !== exports.SENDMULTISIG_SIG_HASH)
|
|
30
|
-
return;
|
|
31
|
-
const result = abiInterface.decodeFunctionData(exports.SENDMULTISIG_SIG_HASH, inputData);
|
|
32
|
-
return result.toAddress;
|
|
33
|
-
};
|
|
34
|
-
exports.getInternalMultisigAddress = getInternalMultisigAddress;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { Tx as BlockbookTx } from '@shapeshiftoss/blockbook';
|
|
2
1
|
import { ChainId } from '@shapeshiftoss/caip';
|
|
3
2
|
import { ethers } from 'ethers';
|
|
3
|
+
import { EthereumTx } from '../../generated/ethereum';
|
|
4
4
|
import { SubParser, TxSpecific } from '../types';
|
|
5
5
|
export interface ParserArgs {
|
|
6
6
|
chainId: ChainId;
|
|
@@ -16,5 +16,5 @@ export declare class Parser implements SubParser {
|
|
|
16
16
|
withdrawalSigHash: string;
|
|
17
17
|
};
|
|
18
18
|
constructor(args: ParserArgs);
|
|
19
|
-
parse(tx:
|
|
19
|
+
parse(tx: EthereumTx): Promise<TxSpecific | undefined>;
|
|
20
20
|
}
|
|
@@ -32,20 +32,17 @@ class Parser {
|
|
|
32
32
|
}
|
|
33
33
|
}
|
|
34
34
|
async parse(tx) {
|
|
35
|
-
var _a, _b, _c;
|
|
36
|
-
const txData = (_a = tx.ethereumSpecific) === null || _a === void 0 ? void 0 : _a.data;
|
|
37
35
|
if (!(0, utils_1.txInteractsWithContract)(tx, this.wethContract))
|
|
38
36
|
return;
|
|
39
|
-
if (!
|
|
37
|
+
if (!tx.inputData)
|
|
40
38
|
return;
|
|
41
|
-
const txSigHash = (0, utils_1.getSigHash)(
|
|
39
|
+
const txSigHash = (0, utils_1.getSigHash)(tx.inputData);
|
|
42
40
|
if (!Object.values(this.supportedFunctions).some((hash) => hash === txSigHash))
|
|
43
41
|
return;
|
|
44
|
-
const decoded = this.abiInterface.parseTransaction({ data:
|
|
42
|
+
const decoded = this.abiInterface.parseTransaction({ data: tx.inputData });
|
|
45
43
|
// failed to decode input data
|
|
46
44
|
if (!decoded)
|
|
47
45
|
return;
|
|
48
|
-
const sendAddress = (_c = (_b = tx.vin[0].addresses) === null || _b === void 0 ? void 0 : _b[0]) !== null && _c !== void 0 ? _c : '';
|
|
49
46
|
const contract = new ethers_1.ethers.Contract(this.wethContract, erc20_1.default, this.provider);
|
|
50
47
|
const assetId = (0, caip_1.toAssetId)({
|
|
51
48
|
...(0, caip_1.fromChainId)(this.chainId),
|
|
@@ -65,7 +62,7 @@ class Parser {
|
|
|
65
62
|
{
|
|
66
63
|
type: types_1.TransferType.Receive,
|
|
67
64
|
from: this.wethContract,
|
|
68
|
-
to:
|
|
65
|
+
to: tx.from,
|
|
69
66
|
assetId,
|
|
70
67
|
totalValue: tx.value,
|
|
71
68
|
components: [{ value: tx.value }],
|
|
@@ -77,7 +74,7 @@ class Parser {
|
|
|
77
74
|
return [
|
|
78
75
|
{
|
|
79
76
|
type: types_1.TransferType.Send,
|
|
80
|
-
from:
|
|
77
|
+
from: tx.from,
|
|
81
78
|
to: this.wethContract,
|
|
82
79
|
assetId,
|
|
83
80
|
totalValue: decoded.args.wad.toString(),
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { Tx as BlockbookTx } from '@shapeshiftoss/blockbook';
|
|
2
1
|
import { ChainId } from '@shapeshiftoss/caip';
|
|
3
2
|
import { ChainId as YearnChainId, Yearn } from '@yfi/sdk';
|
|
4
3
|
import { ethers } from 'ethers';
|
|
4
|
+
import { EthereumTx } from '../../generated/ethereum';
|
|
5
5
|
import { SubParser, TxSpecific } from '../types';
|
|
6
6
|
interface ParserArgs {
|
|
7
7
|
chainId: ChainId;
|
|
@@ -24,7 +24,7 @@ export declare class Parser implements SubParser {
|
|
|
24
24
|
depositSigHash: string;
|
|
25
25
|
};
|
|
26
26
|
constructor(args: ParserArgs);
|
|
27
|
-
parse(tx:
|
|
27
|
+
parse(tx: EthereumTx): Promise<TxSpecific | undefined>;
|
|
28
28
|
getAbiInterface(txSigHash: string | undefined): ethers.utils.Interface | undefined;
|
|
29
29
|
}
|
|
30
30
|
export {};
|
|
@@ -33,37 +33,35 @@ class Parser {
|
|
|
33
33
|
}
|
|
34
34
|
}
|
|
35
35
|
async parse(tx) {
|
|
36
|
-
var _a, _b
|
|
37
|
-
|
|
38
|
-
if (!txData)
|
|
36
|
+
var _a, _b;
|
|
37
|
+
if (!tx.inputData)
|
|
39
38
|
return;
|
|
40
|
-
const txSigHash = (0, utils_1.getSigHash)(
|
|
39
|
+
const txSigHash = (0, utils_1.getSigHash)(tx.inputData);
|
|
41
40
|
const abiInterface = this.getAbiInterface(txSigHash);
|
|
42
41
|
if (!abiInterface)
|
|
43
42
|
return;
|
|
44
43
|
if (!this.yearnTokenVaultAddresses) {
|
|
45
|
-
const vaults = await ((
|
|
44
|
+
const vaults = await ((_a = this.yearnSdk) === null || _a === void 0 ? void 0 : _a.vaults.get());
|
|
46
45
|
this.yearnTokenVaultAddresses = vaults === null || vaults === void 0 ? void 0 : vaults.map((vault) => vault.address);
|
|
47
46
|
}
|
|
48
|
-
const decoded = abiInterface.parseTransaction({ data:
|
|
47
|
+
const decoded = abiInterface.parseTransaction({ data: tx.inputData });
|
|
49
48
|
// failed to decode input data
|
|
50
49
|
if (!decoded)
|
|
51
50
|
return;
|
|
52
|
-
const receiveAddress = (_d = (_c = tx.vout) === null || _c === void 0 ? void 0 : _c[0].addresses) === null || _d === void 0 ? void 0 : _d[0];
|
|
53
51
|
switch (txSigHash) {
|
|
54
52
|
case this.supportedYearnFunctions.approveSigHash:
|
|
55
53
|
if ((decoded === null || decoded === void 0 ? void 0 : decoded.args._spender) !== constants_1.SHAPE_SHIFT_ROUTER_CONTRACT)
|
|
56
54
|
return;
|
|
57
55
|
break;
|
|
58
56
|
case this.supportedShapeShiftFunctions.depositSigHash:
|
|
59
|
-
if (
|
|
57
|
+
if (tx.to !== constants_1.SHAPE_SHIFT_ROUTER_CONTRACT)
|
|
60
58
|
return;
|
|
61
59
|
break;
|
|
62
60
|
case this.supportedYearnFunctions.withdrawSigHash:
|
|
63
61
|
case this.supportedYearnFunctions.depositSigHash:
|
|
64
62
|
case this.supportedYearnFunctions.depositAmountSigHash:
|
|
65
63
|
case this.supportedYearnFunctions.depositAmountAndRecipientSigHash:
|
|
66
|
-
if (
|
|
64
|
+
if (tx.to && !((_b = this.yearnTokenVaultAddresses) === null || _b === void 0 ? void 0 : _b.includes(tx.to)))
|
|
67
65
|
return;
|
|
68
66
|
break;
|
|
69
67
|
default:
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { EthereumTx } from '../../generated/ethereum';
|
|
2
2
|
import { SubParser, TxSpecific } from '../types';
|
|
3
3
|
export declare class Parser implements SubParser {
|
|
4
|
-
parse(tx:
|
|
4
|
+
parse(tx: EthereumTx): Promise<TxSpecific | undefined>;
|
|
5
5
|
}
|
package/dist/ethereum/types.d.ts
CHANGED
|
@@ -1,25 +1,9 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { EthereumTx } from '../generated/ethereum';
|
|
2
2
|
import { StandardTx, StandardTxMetadata } from '../types';
|
|
3
|
-
export interface InternalTx {
|
|
4
|
-
blockNumber: string;
|
|
5
|
-
timeStamp: string;
|
|
6
|
-
hash: string;
|
|
7
|
-
from: string;
|
|
8
|
-
to: string;
|
|
9
|
-
value: string;
|
|
10
|
-
contractAddress: string;
|
|
11
|
-
input: string;
|
|
12
|
-
type: string;
|
|
13
|
-
gas: string;
|
|
14
|
-
gasUsed: string;
|
|
15
|
-
traceId: string;
|
|
16
|
-
isError: string;
|
|
17
|
-
errCode: string;
|
|
18
|
-
}
|
|
19
3
|
export interface ParsedTx extends StandardTx {
|
|
20
4
|
data?: StandardTxMetadata;
|
|
21
5
|
}
|
|
22
6
|
export declare type TxSpecific = Partial<Pick<ParsedTx, 'trade' | 'transfers' | 'data'>>;
|
|
23
7
|
export interface SubParser {
|
|
24
|
-
parse(tx:
|
|
8
|
+
parse(tx: EthereumTx): Promise<TxSpecific | undefined>;
|
|
25
9
|
}
|