@shapeshiftoss/unchained-client 6.12.0 → 8.0.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 +4 -3
- package/dist/bitcoin/parser/index.js +12 -17
- package/dist/cosmos/parser/index.js +5 -8
- package/dist/cosmos/parser/utils.js +0 -3
- package/dist/cosmos/types.d.ts +0 -4
- package/dist/ethereum/parser/index.d.ts +5 -3
- package/dist/ethereum/parser/index.js +31 -36
- package/dist/ethereum/parser/thor.d.ts +3 -2
- package/dist/ethereum/parser/thor.js +12 -5
- package/dist/ethereum/parser/uniV2.d.ts +4 -3
- package/dist/ethereum/parser/uniV2.js +21 -20
- package/dist/ethereum/parser/utils.d.ts +0 -3
- package/dist/ethereum/parser/utils.js +1 -13
- package/dist/ethereum/parser/weth.d.ts +4 -3
- package/dist/ethereum/parser/weth.js +18 -16
- package/dist/ethereum/parser/yearn.d.ts +5 -4
- package/dist/ethereum/parser/yearn.js +1 -1
- package/dist/ethereum/types.d.ts +0 -1
- package/dist/types.d.ts +0 -12
- package/dist/utils.js +0 -1
- package/package.json +6 -6
- package/dist/bitcoin/parser/utils.d.ts +0 -3
- package/dist/bitcoin/parser/utils.js +0 -15
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
import { Tx as BlockbookTx } from '@shapeshiftoss/blockbook';
|
|
2
|
+
import { AssetId, ChainId } from '@shapeshiftoss/caip';
|
|
2
3
|
import { Tx as ParsedTx } from '../../types';
|
|
3
|
-
import { Network } from '../types';
|
|
4
4
|
export interface TransactionParserArgs {
|
|
5
|
-
|
|
5
|
+
chainId: ChainId;
|
|
6
6
|
rpcUrl: string;
|
|
7
7
|
}
|
|
8
8
|
export declare class TransactionParser {
|
|
9
|
-
|
|
9
|
+
chainId: ChainId;
|
|
10
|
+
assetId: AssetId;
|
|
10
11
|
constructor(args: TransactionParserArgs);
|
|
11
12
|
parse(tx: BlockbookTx, address: string): Promise<ParsedTx>;
|
|
12
13
|
}
|
|
@@ -2,32 +2,27 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.TransactionParser = void 0;
|
|
4
4
|
const caip_1 = require("@shapeshiftoss/caip");
|
|
5
|
-
const types_1 = require("@shapeshiftoss/types");
|
|
6
5
|
const bignumber_js_1 = require("bignumber.js");
|
|
7
|
-
const
|
|
6
|
+
const types_1 = require("../../types");
|
|
8
7
|
const utils_1 = require("../../utils");
|
|
9
|
-
const utils_2 = require("./utils");
|
|
10
8
|
class TransactionParser {
|
|
11
9
|
constructor(args) {
|
|
12
|
-
|
|
13
|
-
this.
|
|
10
|
+
this.chainId = args.chainId;
|
|
11
|
+
this.assetId = (0, caip_1.toAssetId)({
|
|
12
|
+
...(0, caip_1.fromChainId)(this.chainId),
|
|
13
|
+
assetNamespace: 'slip44',
|
|
14
|
+
assetReference: caip_1.ASSET_REFERENCE.Bitcoin
|
|
15
|
+
});
|
|
14
16
|
}
|
|
15
17
|
async parse(tx, address) {
|
|
16
|
-
const caip19Bitcoin = (0, caip_1.toCAIP19)({
|
|
17
|
-
chain: types_1.ChainTypes.Bitcoin,
|
|
18
|
-
network: (0, utils_2.toNetworkType)(this.network),
|
|
19
|
-
assetNamespace: caip_1.AssetNamespace.Slip44,
|
|
20
|
-
assetReference: caip_1.AssetReference.Bitcoin
|
|
21
|
-
});
|
|
22
18
|
const parsedTx = {
|
|
23
19
|
address,
|
|
24
20
|
blockHash: tx.blockHash,
|
|
25
21
|
blockHeight: tx.blockHeight,
|
|
26
22
|
blockTime: tx.blockTime,
|
|
27
|
-
|
|
28
|
-
chainId: (0, caip_1.toCAIP2)({ chain: types_1.ChainTypes.Bitcoin, network: (0, utils_2.toNetworkType)(this.network) }),
|
|
23
|
+
chainId: this.chainId,
|
|
29
24
|
confirmations: tx.confirmations,
|
|
30
|
-
status: tx.confirmations > 0 ?
|
|
25
|
+
status: tx.confirmations > 0 ? types_1.Status.Confirmed : types_1.Status.Pending,
|
|
31
26
|
transfers: [],
|
|
32
27
|
txid: tx.txid
|
|
33
28
|
};
|
|
@@ -37,12 +32,12 @@ class TransactionParser {
|
|
|
37
32
|
// send amount
|
|
38
33
|
const sendValue = new bignumber_js_1.BigNumber((_b = vin.value) !== null && _b !== void 0 ? _b : 0);
|
|
39
34
|
if (sendValue.gt(0)) {
|
|
40
|
-
parsedTx.transfers = (0, utils_1.aggregateTransfer)(parsedTx.transfers,
|
|
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));
|
|
41
36
|
}
|
|
42
37
|
// network fee
|
|
43
38
|
const fees = new bignumber_js_1.BigNumber((_g = tx.fees) !== null && _g !== void 0 ? _g : 0);
|
|
44
39
|
if (fees.gt(0)) {
|
|
45
|
-
parsedTx.fee = {
|
|
40
|
+
parsedTx.fee = { assetId: this.assetId, value: fees.toString(10) };
|
|
46
41
|
}
|
|
47
42
|
}
|
|
48
43
|
});
|
|
@@ -52,7 +47,7 @@ class TransactionParser {
|
|
|
52
47
|
// receive amount
|
|
53
48
|
const receiveValue = new bignumber_js_1.BigNumber((_b = vout.value) !== null && _b !== void 0 ? _b : 0);
|
|
54
49
|
if (receiveValue.gt(0)) {
|
|
55
|
-
parsedTx.transfers = (0, utils_1.aggregateTransfer)(parsedTx.transfers,
|
|
50
|
+
parsedTx.transfers = (0, utils_1.aggregateTransfer)(parsedTx.transfers, types_1.TransferType.Receive, this.assetId, (_d = (_c = tx.vin[0].addresses) === null || _c === void 0 ? void 0 : _c[0]) !== null && _d !== void 0 ? _d : '', (_f = (_e = vout.addresses) === null || _e === void 0 ? void 0 : _e[0]) !== null && _f !== void 0 ? _f : '', receiveValue.toString(10));
|
|
56
51
|
}
|
|
57
52
|
}
|
|
58
53
|
});
|
|
@@ -8,10 +8,10 @@ const utils_1 = require("./utils");
|
|
|
8
8
|
class TransactionParser {
|
|
9
9
|
constructor(args) {
|
|
10
10
|
this.chainId = args.chainId;
|
|
11
|
-
this.assetId = (0, caip_1.
|
|
12
|
-
...(0, caip_1.
|
|
13
|
-
assetNamespace:
|
|
14
|
-
assetReference: caip_1.
|
|
11
|
+
this.assetId = (0, caip_1.toAssetId)({
|
|
12
|
+
...(0, caip_1.fromChainId)(this.chainId),
|
|
13
|
+
assetNamespace: 'slip44',
|
|
14
|
+
assetReference: caip_1.ASSET_REFERENCE.Cosmos
|
|
15
15
|
});
|
|
16
16
|
}
|
|
17
17
|
async parse(tx, address) {
|
|
@@ -21,7 +21,6 @@ class TransactionParser {
|
|
|
21
21
|
blockHash: tx.blockHash,
|
|
22
22
|
blockHeight: (_a = tx.blockHeight) !== null && _a !== void 0 ? _a : -1,
|
|
23
23
|
blockTime: (_b = tx.timestamp) !== null && _b !== void 0 ? _b : Math.floor(Date.now() / 1000),
|
|
24
|
-
caip2: this.chainId,
|
|
25
24
|
chainId: this.chainId,
|
|
26
25
|
confirmations: tx.confirmations,
|
|
27
26
|
status: tx.confirmations > 0 ? types_1.Status.Confirmed : types_1.Status.Pending,
|
|
@@ -36,7 +35,6 @@ class TransactionParser {
|
|
|
36
35
|
parsedTx.transfers = [
|
|
37
36
|
{
|
|
38
37
|
type: types_1.TransferType.Send,
|
|
39
|
-
caip19: this.assetId,
|
|
40
38
|
assetId: this.assetId,
|
|
41
39
|
from,
|
|
42
40
|
to,
|
|
@@ -49,7 +47,6 @@ class TransactionParser {
|
|
|
49
47
|
parsedTx.transfers = [
|
|
50
48
|
{
|
|
51
49
|
type: types_1.TransferType.Receive,
|
|
52
|
-
caip19: this.assetId,
|
|
53
50
|
assetId: this.assetId,
|
|
54
51
|
from,
|
|
55
52
|
to,
|
|
@@ -63,7 +60,7 @@ class TransactionParser {
|
|
|
63
60
|
// network fee
|
|
64
61
|
const fees = new bignumber_js_1.BigNumber(tx.fee.amount);
|
|
65
62
|
if (fees.gt(0)) {
|
|
66
|
-
parsedTx.fee = {
|
|
63
|
+
parsedTx.fee = { assetId: this.assetId, value: fees.toString(10) };
|
|
67
64
|
}
|
|
68
65
|
}
|
|
69
66
|
return parsedTx;
|
|
@@ -32,7 +32,6 @@ const metaData = (msg, assetId) => {
|
|
|
32
32
|
delegator: msg.origin,
|
|
33
33
|
destinationValidator: msg.to,
|
|
34
34
|
value: (_b = msg === null || msg === void 0 ? void 0 : msg.value) === null || _b === void 0 ? void 0 : _b.amount,
|
|
35
|
-
caip19: assetId,
|
|
36
35
|
assetId
|
|
37
36
|
};
|
|
38
37
|
case 'withdraw_delegator_reward':
|
|
@@ -41,7 +40,6 @@ const metaData = (msg, assetId) => {
|
|
|
41
40
|
method: msg.type,
|
|
42
41
|
destinationValidator: msg.to,
|
|
43
42
|
value: (_c = msg === null || msg === void 0 ? void 0 : msg.value) === null || _c === void 0 ? void 0 : _c.amount,
|
|
44
|
-
caip19: assetId,
|
|
45
43
|
assetId
|
|
46
44
|
};
|
|
47
45
|
case 'ibc_send':
|
|
@@ -51,7 +49,6 @@ const metaData = (msg, assetId) => {
|
|
|
51
49
|
method: msg.type,
|
|
52
50
|
ibcDestination: msg.to,
|
|
53
51
|
ibcSource: msg.from,
|
|
54
|
-
caip19: assetId,
|
|
55
52
|
assetId,
|
|
56
53
|
value: (_d = msg === null || msg === void 0 ? void 0 : msg.value) === null || _d === void 0 ? void 0 : _d.amount
|
|
57
54
|
};
|
package/dist/cosmos/types.d.ts
CHANGED
|
@@ -4,10 +4,6 @@ export interface TxMetadata extends Omit<StandardTxMetadata, 'parser'> {
|
|
|
4
4
|
delegator?: string;
|
|
5
5
|
sourceValidator?: string;
|
|
6
6
|
destinationValidator?: string;
|
|
7
|
-
/**
|
|
8
|
-
* @deprecated use 'assetId' instead
|
|
9
|
-
*/
|
|
10
|
-
caip19?: string;
|
|
11
7
|
assetId?: string;
|
|
12
8
|
value?: string;
|
|
13
9
|
ibcDestination?: string;
|
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
import { Tx as BlockbookTx } from '@shapeshiftoss/blockbook';
|
|
2
|
-
import {
|
|
2
|
+
import { AssetId, ChainId } from '@shapeshiftoss/caip';
|
|
3
|
+
import { InternalTx, ParsedTx } from '../types';
|
|
3
4
|
export interface TransactionParserArgs {
|
|
4
|
-
|
|
5
|
+
chainId: ChainId;
|
|
5
6
|
rpcUrl: string;
|
|
6
7
|
}
|
|
7
8
|
export declare class TransactionParser {
|
|
8
|
-
|
|
9
|
+
chainId: ChainId;
|
|
10
|
+
assetId: AssetId;
|
|
9
11
|
private readonly thor;
|
|
10
12
|
private readonly uniV2;
|
|
11
13
|
private readonly zrx;
|
|
@@ -25,10 +25,10 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
25
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
26
|
exports.TransactionParser = void 0;
|
|
27
27
|
const caip_1 = require("@shapeshiftoss/caip");
|
|
28
|
-
const
|
|
28
|
+
const src_1 = require("@shapeshiftoss/caip/src");
|
|
29
29
|
const bignumber_js_1 = require("bignumber.js");
|
|
30
30
|
const ethers_1 = require("ethers");
|
|
31
|
-
const
|
|
31
|
+
const types_1 = require("../../types");
|
|
32
32
|
const utils_1 = require("../../utils");
|
|
33
33
|
const foxy = __importStar(require("./foxy"));
|
|
34
34
|
const thor = __importStar(require("./thor"));
|
|
@@ -39,15 +39,19 @@ const yearn = __importStar(require("./yearn"));
|
|
|
39
39
|
const zrx = __importStar(require("./zrx"));
|
|
40
40
|
class TransactionParser {
|
|
41
41
|
constructor(args) {
|
|
42
|
-
|
|
42
|
+
this.chainId = args.chainId;
|
|
43
|
+
this.assetId = (0, caip_1.toAssetId)({
|
|
44
|
+
...(0, caip_1.fromChainId)(this.chainId),
|
|
45
|
+
assetNamespace: 'slip44',
|
|
46
|
+
assetReference: src_1.ASSET_REFERENCE.Ethereum
|
|
47
|
+
});
|
|
43
48
|
const provider = new ethers_1.ethers.providers.JsonRpcProvider(args.rpcUrl);
|
|
44
|
-
this.
|
|
45
|
-
this.
|
|
46
|
-
this.uniV2 = new uniV2.Parser({ network: this.network, provider });
|
|
49
|
+
this.thor = new thor.Parser({ chainId: this.chainId, rpcUrl: args.rpcUrl });
|
|
50
|
+
this.uniV2 = new uniV2.Parser({ chainId: this.chainId, provider });
|
|
47
51
|
this.zrx = new zrx.Parser();
|
|
48
|
-
this.yearn = new yearn.Parser({ provider,
|
|
52
|
+
this.yearn = new yearn.Parser({ provider, chainId: this.chainId });
|
|
49
53
|
this.foxy = new foxy.Parser();
|
|
50
|
-
this.weth = new weth.Parser({
|
|
54
|
+
this.weth = new weth.Parser({ chainId: this.chainId, provider });
|
|
51
55
|
this.parsers = [this.zrx, this.thor, this.uniV2, this.yearn, this.foxy, this.weth];
|
|
52
56
|
}
|
|
53
57
|
// return any addresses that can be detected
|
|
@@ -70,8 +74,7 @@ class TransactionParser {
|
|
|
70
74
|
blockHash: tx.blockHash,
|
|
71
75
|
blockHeight: tx.blockHeight,
|
|
72
76
|
blockTime: tx.blockTime,
|
|
73
|
-
|
|
74
|
-
chainId: (0, caip_1.toCAIP2)({ chain: types_1.ChainTypes.Ethereum, network: (0, utils_2.toNetworkType)(this.network) }),
|
|
77
|
+
chainId: this.chainId,
|
|
75
78
|
confirmations: tx.confirmations,
|
|
76
79
|
status: TransactionParser.getStatus(tx),
|
|
77
80
|
trade: contractParserResult === null || contractParserResult === void 0 ? void 0 : contractParserResult.trade,
|
|
@@ -85,40 +88,34 @@ class TransactionParser {
|
|
|
85
88
|
var _a;
|
|
86
89
|
const status = (_a = tx.ethereumSpecific) === null || _a === void 0 ? void 0 : _a.status;
|
|
87
90
|
if (status === -1 && tx.confirmations <= 0)
|
|
88
|
-
return
|
|
91
|
+
return types_1.Status.Pending;
|
|
89
92
|
if (status === 1 && tx.confirmations > 0)
|
|
90
|
-
return
|
|
93
|
+
return types_1.Status.Confirmed;
|
|
91
94
|
if (status === 0)
|
|
92
|
-
return
|
|
93
|
-
return
|
|
95
|
+
return types_1.Status.Failed;
|
|
96
|
+
return types_1.Status.Unknown;
|
|
94
97
|
}
|
|
95
98
|
getParsedTxWithTransfers(tx, parsedTx, address, internalTxs) {
|
|
96
99
|
var _a, _b, _c, _d, _e, _f;
|
|
97
|
-
const caip19Ethereum = (0, caip_1.toCAIP19)({
|
|
98
|
-
chain: types_1.ChainTypes.Ethereum,
|
|
99
|
-
network: (0, utils_2.toNetworkType)(this.network),
|
|
100
|
-
assetNamespace: caip_1.AssetNamespace.Slip44,
|
|
101
|
-
assetReference: caip_1.AssetReference.Ethereum
|
|
102
|
-
});
|
|
103
100
|
const sendAddress = (_b = (_a = tx.vin[0].addresses) === null || _a === void 0 ? void 0 : _a[0]) !== null && _b !== void 0 ? _b : '';
|
|
104
101
|
const receiveAddress = (_d = (_c = tx.vout[0].addresses) === null || _c === void 0 ? void 0 : _c[0]) !== null && _d !== void 0 ? _d : '';
|
|
105
102
|
if (address === sendAddress) {
|
|
106
103
|
// send amount
|
|
107
104
|
const sendValue = new bignumber_js_1.BigNumber(tx.value);
|
|
108
105
|
if (sendValue.gt(0)) {
|
|
109
|
-
parsedTx.transfers = (0, utils_1.aggregateTransfer)(parsedTx.transfers,
|
|
106
|
+
parsedTx.transfers = (0, utils_1.aggregateTransfer)(parsedTx.transfers, types_1.TransferType.Send, this.assetId, sendAddress, receiveAddress, sendValue.toString(10));
|
|
110
107
|
}
|
|
111
108
|
// network fee
|
|
112
109
|
const fees = new bignumber_js_1.BigNumber((_e = tx.fees) !== null && _e !== void 0 ? _e : 0);
|
|
113
110
|
if (fees.gt(0)) {
|
|
114
|
-
parsedTx.fee = {
|
|
111
|
+
parsedTx.fee = { assetId: this.assetId, value: fees.toString(10) };
|
|
115
112
|
}
|
|
116
113
|
}
|
|
117
114
|
if (address === receiveAddress) {
|
|
118
115
|
// receive amount
|
|
119
116
|
const receiveValue = new bignumber_js_1.BigNumber(tx.value);
|
|
120
117
|
if (receiveValue.gt(0)) {
|
|
121
|
-
parsedTx.transfers = (0, utils_1.aggregateTransfer)(parsedTx.transfers,
|
|
118
|
+
parsedTx.transfers = (0, utils_1.aggregateTransfer)(parsedTx.transfers, types_1.TransferType.Receive, this.assetId, sendAddress, receiveAddress, receiveValue.toString(10));
|
|
122
119
|
}
|
|
123
120
|
}
|
|
124
121
|
(_f = tx.tokenTransfers) === null || _f === void 0 ? void 0 : _f.forEach((transfer) => {
|
|
@@ -134,10 +131,9 @@ class TransactionParser {
|
|
|
134
131
|
symbol: transfer.symbol
|
|
135
132
|
};
|
|
136
133
|
const transferArgs = [
|
|
137
|
-
(0, caip_1.
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
assetNamespace: caip_1.AssetNamespace.ERC20,
|
|
134
|
+
(0, caip_1.toAssetId)({
|
|
135
|
+
...(0, caip_1.fromChainId)(this.chainId),
|
|
136
|
+
assetNamespace: 'erc20',
|
|
141
137
|
assetReference: transfer.token
|
|
142
138
|
}),
|
|
143
139
|
transfer.from,
|
|
@@ -147,20 +143,19 @@ class TransactionParser {
|
|
|
147
143
|
];
|
|
148
144
|
// token send amount
|
|
149
145
|
if (address === transfer.from) {
|
|
150
|
-
parsedTx.transfers = (0, utils_1.aggregateTransfer)(parsedTx.transfers,
|
|
146
|
+
parsedTx.transfers = (0, utils_1.aggregateTransfer)(parsedTx.transfers, types_1.TransferType.Send, ...transferArgs);
|
|
151
147
|
}
|
|
152
148
|
// token receive amount
|
|
153
149
|
if (address === transfer.to) {
|
|
154
|
-
parsedTx.transfers = (0, utils_1.aggregateTransfer)(parsedTx.transfers,
|
|
150
|
+
parsedTx.transfers = (0, utils_1.aggregateTransfer)(parsedTx.transfers, types_1.TransferType.Receive, ...transferArgs);
|
|
155
151
|
}
|
|
156
152
|
});
|
|
157
153
|
internalTxs === null || internalTxs === void 0 ? void 0 : internalTxs.forEach((internalTx) => {
|
|
158
154
|
const transferArgs = [
|
|
159
|
-
(0, caip_1.
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
assetReference: caip_1.AssetReference.Ethereum
|
|
155
|
+
(0, caip_1.toAssetId)({
|
|
156
|
+
...(0, caip_1.fromChainId)(this.chainId),
|
|
157
|
+
assetNamespace: 'slip44',
|
|
158
|
+
assetReference: src_1.ASSET_REFERENCE.Ethereum
|
|
164
159
|
}),
|
|
165
160
|
internalTx.from,
|
|
166
161
|
internalTx.to,
|
|
@@ -168,11 +163,11 @@ class TransactionParser {
|
|
|
168
163
|
];
|
|
169
164
|
// internal eth send
|
|
170
165
|
if (address === internalTx.from) {
|
|
171
|
-
parsedTx.transfers = (0, utils_1.aggregateTransfer)(parsedTx.transfers,
|
|
166
|
+
parsedTx.transfers = (0, utils_1.aggregateTransfer)(parsedTx.transfers, types_1.TransferType.Send, ...transferArgs);
|
|
172
167
|
}
|
|
173
168
|
// internal eth receive
|
|
174
169
|
if (address === internalTx.to) {
|
|
175
|
-
parsedTx.transfers = (0, utils_1.aggregateTransfer)(parsedTx.transfers,
|
|
170
|
+
parsedTx.transfers = (0, utils_1.aggregateTransfer)(parsedTx.transfers, types_1.TransferType.Receive, ...transferArgs);
|
|
176
171
|
}
|
|
177
172
|
});
|
|
178
173
|
return parsedTx;
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { Tx as BlockbookTx } from '@shapeshiftoss/blockbook';
|
|
2
|
+
import { ChainId } from '@shapeshiftoss/caip';
|
|
2
3
|
import { ethers } from 'ethers';
|
|
3
|
-
import {
|
|
4
|
+
import { SubParser, TxSpecific } from '../types';
|
|
4
5
|
export interface ParserArgs {
|
|
5
|
-
|
|
6
|
+
chainId: ChainId;
|
|
6
7
|
rpcUrl: string;
|
|
7
8
|
}
|
|
8
9
|
export declare class Parser implements SubParser {
|
|
@@ -17,11 +17,18 @@ class Parser {
|
|
|
17
17
|
depositSigHash: this.abiInterface.getSighash('deposit'),
|
|
18
18
|
transferOutSigHash: this.abiInterface.getSighash('transferOut')
|
|
19
19
|
};
|
|
20
|
-
// TODO: Router contract can change, use /inbound_addresses endpoint to determine current router contract
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
20
|
+
// TODO: Router contract can change, use /inbound_addresses endpoint to determine current router contract.
|
|
21
|
+
// We will also need to know all past router contract addresses if we intend on using receive address as the means for detection
|
|
22
|
+
switch (args.chainId) {
|
|
23
|
+
case 'eip155:1':
|
|
24
|
+
this.routerContract = constants_1.THOR_ROUTER_CONTRACT_MAINNET;
|
|
25
|
+
break;
|
|
26
|
+
case 'eip155:3':
|
|
27
|
+
this.routerContract = constants_1.THOR_ROUTER_CONTRACT_ROPSTEN;
|
|
28
|
+
break;
|
|
29
|
+
default:
|
|
30
|
+
throw new Error('chainId is not supported. (supported chainIds: eip155:1, eip155:3)');
|
|
31
|
+
}
|
|
25
32
|
}
|
|
26
33
|
// detect address associated with transferOut internal transaction
|
|
27
34
|
getInternalAddress(inputData) {
|
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
import { Tx as BlockbookTx } from '@shapeshiftoss/blockbook';
|
|
2
|
+
import { ChainId } from '@shapeshiftoss/caip';
|
|
2
3
|
import { ethers } from 'ethers';
|
|
3
|
-
import {
|
|
4
|
+
import { SubParser, TxSpecific } from '../types';
|
|
4
5
|
export interface ParserArgs {
|
|
5
|
-
|
|
6
|
+
chainId: ChainId;
|
|
6
7
|
provider: ethers.providers.JsonRpcProvider;
|
|
7
8
|
}
|
|
8
9
|
export declare class Parser implements SubParser {
|
|
9
|
-
network: Network;
|
|
10
10
|
provider: ethers.providers.JsonRpcProvider;
|
|
11
|
+
readonly chainId: ChainId;
|
|
11
12
|
readonly wethContract: string;
|
|
12
13
|
readonly abiInterface: ethers.utils.Interface;
|
|
13
14
|
readonly supportedFunctions: {
|
|
@@ -5,9 +5,8 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.Parser = void 0;
|
|
7
7
|
const caip_1 = require("@shapeshiftoss/caip");
|
|
8
|
-
const types_1 = require("@shapeshiftoss/types");
|
|
9
8
|
const ethers_1 = require("ethers");
|
|
10
|
-
const
|
|
9
|
+
const types_1 = require("../../types");
|
|
11
10
|
const erc20_1 = __importDefault(require("./abi/erc20"));
|
|
12
11
|
const uniV2_1 = __importDefault(require("./abi/uniV2"));
|
|
13
12
|
const constants_1 = require("./constants");
|
|
@@ -19,12 +18,18 @@ class Parser {
|
|
|
19
18
|
addLiquidityEthSigHash: this.abiInterface.getSighash('addLiquidityETH'),
|
|
20
19
|
removeLiquidityEthSigHash: this.abiInterface.getSighash('removeLiquidityETH')
|
|
21
20
|
};
|
|
22
|
-
this.
|
|
21
|
+
this.chainId = args.chainId;
|
|
23
22
|
this.provider = args.provider;
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
23
|
+
switch (args.chainId) {
|
|
24
|
+
case 'eip155:1':
|
|
25
|
+
this.wethContract = constants_1.WETH_CONTRACT_MAINNET;
|
|
26
|
+
break;
|
|
27
|
+
case 'eip155:3':
|
|
28
|
+
this.wethContract = constants_1.WETH_CONTRACT_ROPSTEN;
|
|
29
|
+
break;
|
|
30
|
+
default:
|
|
31
|
+
throw new Error('chainId is not supported. (supported chainIds: eip155:1, eip155:3)');
|
|
32
|
+
}
|
|
28
33
|
}
|
|
29
34
|
async parse(tx) {
|
|
30
35
|
var _a, _b, _c;
|
|
@@ -53,18 +58,16 @@ class Parser {
|
|
|
53
58
|
const name = await contract.name();
|
|
54
59
|
const symbol = await contract.symbol();
|
|
55
60
|
const value = decoded.args.amountTokenDesired.toString();
|
|
56
|
-
const assetId = (0, caip_1.
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
assetNamespace: caip_1.AssetNamespace.ERC20,
|
|
61
|
+
const assetId = (0, caip_1.toAssetId)({
|
|
62
|
+
...(0, caip_1.fromChainId)(this.chainId),
|
|
63
|
+
assetNamespace: 'erc20',
|
|
60
64
|
assetReference: tokenAddress
|
|
61
65
|
});
|
|
62
66
|
return [
|
|
63
67
|
{
|
|
64
|
-
type:
|
|
68
|
+
type: types_1.TransferType.Send,
|
|
65
69
|
from: sendAddress,
|
|
66
70
|
to: lpTokenAddress,
|
|
67
|
-
caip19: assetId,
|
|
68
71
|
assetId,
|
|
69
72
|
totalValue: value,
|
|
70
73
|
components: [{ value }],
|
|
@@ -78,18 +81,16 @@ class Parser {
|
|
|
78
81
|
const name = await contract.name();
|
|
79
82
|
const symbol = await contract.symbol();
|
|
80
83
|
const value = decoded.args.liquidity.toString();
|
|
81
|
-
const assetId = (0, caip_1.
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
assetNamespace: caip_1.AssetNamespace.ERC20,
|
|
84
|
+
const assetId = (0, caip_1.toAssetId)({
|
|
85
|
+
...(0, caip_1.fromChainId)(this.chainId),
|
|
86
|
+
assetNamespace: 'erc20',
|
|
85
87
|
assetReference: lpTokenAddress
|
|
86
88
|
});
|
|
87
89
|
return [
|
|
88
90
|
{
|
|
89
|
-
type:
|
|
91
|
+
type: types_1.TransferType.Send,
|
|
90
92
|
from: sendAddress,
|
|
91
93
|
to: lpTokenAddress,
|
|
92
|
-
caip19: assetId,
|
|
93
94
|
assetId,
|
|
94
95
|
totalValue: value,
|
|
95
96
|
components: [{ value }],
|
|
@@ -107,7 +108,7 @@ class Parser {
|
|
|
107
108
|
return {
|
|
108
109
|
transfers,
|
|
109
110
|
data: {
|
|
110
|
-
parser:
|
|
111
|
+
parser: types_1.TxParser.UniV2,
|
|
111
112
|
method: decoded.name
|
|
112
113
|
}
|
|
113
114
|
};
|
|
@@ -1,7 +1,4 @@
|
|
|
1
1
|
import { Tx as BlockbookTx } from '@shapeshiftoss/blockbook';
|
|
2
|
-
import { NetworkTypes } from '@shapeshiftoss/types';
|
|
3
|
-
import { Network } from '../types';
|
|
4
|
-
export declare const toNetworkType: (network: Network) => NetworkTypes;
|
|
5
2
|
export declare const getSigHash: (inputData: string | undefined) => string | undefined;
|
|
6
3
|
export declare const txInteractsWithContract: (tx: BlockbookTx, contract: string) => boolean;
|
|
7
4
|
export declare const SENDMULTISIG_SIG_HASH: string;
|
|
@@ -3,21 +3,9 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.getInternalMultisigAddress = exports.SENDMULTISIG_SIG_HASH = exports.txInteractsWithContract = exports.getSigHash =
|
|
7
|
-
const types_1 = require("@shapeshiftoss/types");
|
|
6
|
+
exports.getInternalMultisigAddress = exports.SENDMULTISIG_SIG_HASH = exports.txInteractsWithContract = exports.getSigHash = void 0;
|
|
8
7
|
const ethers_1 = require("ethers");
|
|
9
8
|
const multiSig_1 = __importDefault(require("./abi/multiSig"));
|
|
10
|
-
const toNetworkType = (network) => {
|
|
11
|
-
switch (network) {
|
|
12
|
-
case 'mainnet':
|
|
13
|
-
return types_1.NetworkTypes.MAINNET;
|
|
14
|
-
case 'ropsten':
|
|
15
|
-
return types_1.NetworkTypes.ETH_ROPSTEN;
|
|
16
|
-
default:
|
|
17
|
-
throw new Error('unsupported network');
|
|
18
|
-
}
|
|
19
|
-
};
|
|
20
|
-
exports.toNetworkType = toNetworkType;
|
|
21
9
|
const getSigHash = (inputData) => {
|
|
22
10
|
if (!inputData)
|
|
23
11
|
return;
|
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
import { Tx as BlockbookTx } from '@shapeshiftoss/blockbook';
|
|
2
|
+
import { ChainId } from '@shapeshiftoss/caip';
|
|
2
3
|
import { ethers } from 'ethers';
|
|
3
|
-
import {
|
|
4
|
+
import { SubParser, TxSpecific } from '../types';
|
|
4
5
|
export interface ParserArgs {
|
|
5
|
-
|
|
6
|
+
chainId: ChainId;
|
|
6
7
|
provider: ethers.providers.JsonRpcProvider;
|
|
7
8
|
}
|
|
8
9
|
export declare class Parser implements SubParser {
|
|
9
10
|
provider: ethers.providers.JsonRpcProvider;
|
|
10
|
-
readonly
|
|
11
|
+
readonly chainId: ChainId;
|
|
11
12
|
readonly wethContract: string;
|
|
12
13
|
readonly abiInterface: ethers.utils.Interface;
|
|
13
14
|
readonly supportedFunctions: {
|
|
@@ -5,9 +5,8 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.Parser = void 0;
|
|
7
7
|
const caip_1 = require("@shapeshiftoss/caip");
|
|
8
|
-
const types_1 = require("@shapeshiftoss/types");
|
|
9
8
|
const ethers_1 = require("ethers");
|
|
10
|
-
const
|
|
9
|
+
const types_1 = require("../../types");
|
|
11
10
|
const erc20_1 = __importDefault(require("./abi/erc20"));
|
|
12
11
|
const weth_1 = __importDefault(require("./abi/weth"));
|
|
13
12
|
const constants_1 = require("./constants");
|
|
@@ -19,12 +18,18 @@ class Parser {
|
|
|
19
18
|
depositSigHash: this.abiInterface.getSighash('deposit'),
|
|
20
19
|
withdrawalSigHash: this.abiInterface.getSighash('withdraw')
|
|
21
20
|
};
|
|
22
|
-
this.
|
|
21
|
+
this.chainId = args.chainId;
|
|
23
22
|
this.provider = args.provider;
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
23
|
+
switch (args.chainId) {
|
|
24
|
+
case 'eip155:1':
|
|
25
|
+
this.wethContract = constants_1.WETH_CONTRACT_MAINNET;
|
|
26
|
+
break;
|
|
27
|
+
case 'eip155:3':
|
|
28
|
+
this.wethContract = constants_1.WETH_CONTRACT_ROPSTEN;
|
|
29
|
+
break;
|
|
30
|
+
default:
|
|
31
|
+
throw new Error('chainId is not supported. (supported chainIds: eip155:1, eip155:3)');
|
|
32
|
+
}
|
|
28
33
|
}
|
|
29
34
|
async parse(tx) {
|
|
30
35
|
var _a, _b, _c;
|
|
@@ -42,10 +47,9 @@ class Parser {
|
|
|
42
47
|
return;
|
|
43
48
|
const sendAddress = (_c = (_b = tx.vin[0].addresses) === null || _b === void 0 ? void 0 : _b[0]) !== null && _c !== void 0 ? _c : '';
|
|
44
49
|
const contract = new ethers_1.ethers.Contract(this.wethContract, erc20_1.default, this.provider);
|
|
45
|
-
const assetId = (0, caip_1.
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
assetNamespace: caip_1.AssetNamespace.ERC20,
|
|
50
|
+
const assetId = (0, caip_1.toAssetId)({
|
|
51
|
+
...(0, caip_1.fromChainId)(this.chainId),
|
|
52
|
+
assetNamespace: 'erc20',
|
|
49
53
|
assetReference: this.wethContract
|
|
50
54
|
});
|
|
51
55
|
const token = {
|
|
@@ -59,10 +63,9 @@ class Parser {
|
|
|
59
63
|
case this.supportedFunctions.depositSigHash: {
|
|
60
64
|
return [
|
|
61
65
|
{
|
|
62
|
-
type:
|
|
66
|
+
type: types_1.TransferType.Receive,
|
|
63
67
|
from: this.wethContract,
|
|
64
68
|
to: sendAddress,
|
|
65
|
-
caip19: assetId,
|
|
66
69
|
assetId,
|
|
67
70
|
totalValue: tx.value,
|
|
68
71
|
components: [{ value: tx.value }],
|
|
@@ -73,10 +76,9 @@ class Parser {
|
|
|
73
76
|
case this.supportedFunctions.withdrawalSigHash:
|
|
74
77
|
return [
|
|
75
78
|
{
|
|
76
|
-
type:
|
|
79
|
+
type: types_1.TransferType.Send,
|
|
77
80
|
from: sendAddress,
|
|
78
81
|
to: this.wethContract,
|
|
79
|
-
caip19: assetId,
|
|
80
82
|
assetId,
|
|
81
83
|
totalValue: decoded.args.wad.toString(),
|
|
82
84
|
components: [{ value: decoded.args.wad.toString() }],
|
|
@@ -93,7 +95,7 @@ class Parser {
|
|
|
93
95
|
return {
|
|
94
96
|
transfers,
|
|
95
97
|
data: {
|
|
96
|
-
parser:
|
|
98
|
+
parser: types_1.TxParser.WETH,
|
|
97
99
|
method: decoded.name
|
|
98
100
|
}
|
|
99
101
|
};
|
|
@@ -1,14 +1,15 @@
|
|
|
1
1
|
import { Tx as BlockbookTx } from '@shapeshiftoss/blockbook';
|
|
2
|
-
import { ChainId
|
|
2
|
+
import { ChainId } from '@shapeshiftoss/caip';
|
|
3
|
+
import { ChainId as YearnChainId, Yearn } from '@yfi/sdk';
|
|
3
4
|
import { ethers } from 'ethers';
|
|
4
|
-
import {
|
|
5
|
+
import { SubParser, TxSpecific } from '../types';
|
|
5
6
|
interface ParserArgs {
|
|
6
|
-
|
|
7
|
+
chainId: ChainId;
|
|
7
8
|
provider: ethers.providers.JsonRpcProvider;
|
|
8
9
|
}
|
|
9
10
|
export declare class Parser implements SubParser {
|
|
10
11
|
provider: ethers.providers.JsonRpcProvider;
|
|
11
|
-
yearnSdk: Yearn<
|
|
12
|
+
yearnSdk: Yearn<YearnChainId> | undefined;
|
|
12
13
|
yearnTokenVaultAddresses: string[] | undefined;
|
|
13
14
|
readonly shapeShiftInterface: ethers.utils.Interface;
|
|
14
15
|
readonly yearnInterface: ethers.utils.Interface;
|
|
@@ -27,7 +27,7 @@ class Parser {
|
|
|
27
27
|
};
|
|
28
28
|
this.provider = args.provider;
|
|
29
29
|
// The only Yearn-supported chain we currently support is mainnet
|
|
30
|
-
if (args.
|
|
30
|
+
if (args.chainId === 'eip155:1') {
|
|
31
31
|
// 1 for EthMain (@yfi/sdk/dist/chain.d.ts)
|
|
32
32
|
this.yearnSdk = new sdk_1.Yearn(1, { provider: this.provider });
|
|
33
33
|
}
|
package/dist/ethereum/types.d.ts
CHANGED
|
@@ -20,7 +20,6 @@ export interface ParsedTx extends StandardTx {
|
|
|
20
20
|
data?: StandardTxMetadata;
|
|
21
21
|
}
|
|
22
22
|
export declare type TxSpecific = Partial<Pick<ParsedTx, 'trade' | 'transfers' | 'data'>>;
|
|
23
|
-
export declare type Network = 'mainnet' | 'ropsten';
|
|
24
23
|
export interface SubParser {
|
|
25
24
|
parse(tx: BlockbookTx): Promise<TxSpecific | undefined>;
|
|
26
25
|
}
|
package/dist/types.d.ts
CHANGED
|
@@ -3,10 +3,6 @@ export declare enum Dex {
|
|
|
3
3
|
Zrx = "zrx"
|
|
4
4
|
}
|
|
5
5
|
export interface Fee {
|
|
6
|
-
/**
|
|
7
|
-
* @deprecated use 'assetId' instead
|
|
8
|
-
*/
|
|
9
|
-
caip19: string;
|
|
10
6
|
assetId: string;
|
|
11
7
|
value: string;
|
|
12
8
|
}
|
|
@@ -34,10 +30,6 @@ export declare enum TradeType {
|
|
|
34
30
|
export interface Transfer {
|
|
35
31
|
from: string;
|
|
36
32
|
to: string;
|
|
37
|
-
/**
|
|
38
|
-
* @deprecated use 'assetId' instead
|
|
39
|
-
*/
|
|
40
|
-
caip19: string;
|
|
41
33
|
assetId: string;
|
|
42
34
|
type: TransferType;
|
|
43
35
|
totalValue: string;
|
|
@@ -68,10 +60,6 @@ export interface StandardTx {
|
|
|
68
60
|
blockHash?: string;
|
|
69
61
|
blockHeight: number;
|
|
70
62
|
blockTime: number;
|
|
71
|
-
/**
|
|
72
|
-
* @deprecated use 'chainId' instead
|
|
73
|
-
*/
|
|
74
|
-
caip2: string;
|
|
75
63
|
chainId: string;
|
|
76
64
|
confirmations: number;
|
|
77
65
|
fee?: Fee;
|
package/dist/utils.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@shapeshiftoss/unchained-client",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "8.0.0",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"source": "src/index.ts",
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
"build:public": "yarn clean && yarn generate:public && tsc -p tsconfig.build.json",
|
|
14
14
|
"build:local": "yarn clean && yarn generate:local && tsc -p tsconfig.build.json",
|
|
15
15
|
"dev": "tsc --watch",
|
|
16
|
-
"clean": "rm -rf dist
|
|
16
|
+
"clean": "rm -rf dist src/generated tsconfig.build.tsbuildinfo",
|
|
17
17
|
"generate": "./generator/generate.sh -e dev",
|
|
18
18
|
"generate:public": "./generator/generate.sh -e public",
|
|
19
19
|
"generate:local": "./generator/generate.sh -e local",
|
|
@@ -28,15 +28,15 @@
|
|
|
28
28
|
"ws": "^8.3.0"
|
|
29
29
|
},
|
|
30
30
|
"peerDependencies": {
|
|
31
|
-
"@shapeshiftoss/caip": "^
|
|
31
|
+
"@shapeshiftoss/caip": "^3.0.0",
|
|
32
32
|
"@shapeshiftoss/logger": "^1.1.2",
|
|
33
|
-
"@shapeshiftoss/types": "
|
|
33
|
+
"@shapeshiftoss/types": "^4.0.0"
|
|
34
34
|
},
|
|
35
35
|
"devDependencies": {
|
|
36
|
-
"@shapeshiftoss/caip": "^
|
|
36
|
+
"@shapeshiftoss/caip": "^3.0.0",
|
|
37
37
|
"@shapeshiftoss/common-api": "^6.11.0",
|
|
38
38
|
"@shapeshiftoss/logger": "^1.1.2",
|
|
39
|
-
"@shapeshiftoss/types": "
|
|
39
|
+
"@shapeshiftoss/types": "^4.0.0",
|
|
40
40
|
"@types/ws": "^8.2.1"
|
|
41
41
|
}
|
|
42
42
|
}
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.toNetworkType = void 0;
|
|
4
|
-
const types_1 = require("@shapeshiftoss/types");
|
|
5
|
-
const toNetworkType = (network) => {
|
|
6
|
-
switch (network) {
|
|
7
|
-
case 'mainnet':
|
|
8
|
-
return types_1.NetworkTypes.MAINNET;
|
|
9
|
-
case 'testnet':
|
|
10
|
-
return types_1.NetworkTypes.TESTNET;
|
|
11
|
-
default:
|
|
12
|
-
throw new Error('unsupported network');
|
|
13
|
-
}
|
|
14
|
-
};
|
|
15
|
-
exports.toNetworkType = toNetworkType;
|