@shapeshiftoss/unchained-client 9.0.0-alpha.2 → 9.0.2
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/ethereum/parser/erc20.d.ts +19 -0
- package/dist/ethereum/parser/erc20.js +44 -0
- package/dist/ethereum/parser/index.d.ts +1 -0
- package/dist/ethereum/parser/index.js +3 -1
- package/dist/ethereum/parser/weth.d.ts +0 -1
- package/dist/ethereum/parser/weth.js +0 -1
- package/dist/ethereum/types.d.ts +10 -2
- package/dist/ethereum/types.js +5 -0
- package/dist/generated/bitcoin/api.d.ts +1 -1
- package/dist/generated/bitcoin/api.js +1 -1
- package/dist/generated/bitcoin/base.d.ts +1 -1
- package/dist/generated/bitcoin/base.js +1 -1
- package/dist/generated/bitcoin/common.d.ts +1 -1
- package/dist/generated/bitcoin/common.js +1 -1
- package/dist/generated/bitcoin/configuration.d.ts +1 -1
- package/dist/generated/bitcoin/configuration.js +1 -1
- package/dist/generated/bitcoin/index.d.ts +1 -1
- package/dist/generated/bitcoin/index.js +1 -1
- package/dist/generated/ethereum/api.d.ts +1 -1
- package/dist/generated/ethereum/api.js +1 -1
- package/dist/generated/ethereum/base.d.ts +1 -1
- package/dist/generated/ethereum/base.js +1 -1
- package/dist/generated/ethereum/common.d.ts +1 -1
- package/dist/generated/ethereum/common.js +1 -1
- package/dist/generated/ethereum/configuration.d.ts +1 -1
- package/dist/generated/ethereum/configuration.js +1 -1
- package/dist/generated/ethereum/index.d.ts +1 -1
- package/dist/generated/ethereum/index.js +1 -1
- package/dist/types.d.ts +4 -1
- package/package.json +7 -8
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { ChainId } from '@shapeshiftoss/caip';
|
|
2
|
+
import { ethers } from 'ethers';
|
|
3
|
+
import { EthereumTx } from '../../generated/ethereum';
|
|
4
|
+
import { SubParser, TxSpecific } from '../types';
|
|
5
|
+
interface ParserArgs {
|
|
6
|
+
chainId: ChainId;
|
|
7
|
+
provider: ethers.providers.JsonRpcProvider;
|
|
8
|
+
}
|
|
9
|
+
export declare class Parser implements SubParser {
|
|
10
|
+
provider: ethers.providers.JsonRpcProvider;
|
|
11
|
+
readonly chainId: ChainId;
|
|
12
|
+
readonly abiInterface: ethers.utils.Interface;
|
|
13
|
+
readonly supportedFunctions: {
|
|
14
|
+
approveSigHash: string;
|
|
15
|
+
};
|
|
16
|
+
constructor(args: ParserArgs);
|
|
17
|
+
parse(tx: EthereumTx): Promise<TxSpecific | undefined>;
|
|
18
|
+
}
|
|
19
|
+
export {};
|
|
@@ -0,0 +1,44 @@
|
|
|
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.Parser = void 0;
|
|
7
|
+
const caip_1 = require("@shapeshiftoss/caip");
|
|
8
|
+
const ethers_1 = require("ethers");
|
|
9
|
+
const types_1 = require("../types");
|
|
10
|
+
const erc20_1 = __importDefault(require("./abi/erc20"));
|
|
11
|
+
const utils_1 = require("./utils");
|
|
12
|
+
class Parser {
|
|
13
|
+
constructor(args) {
|
|
14
|
+
this.abiInterface = new ethers_1.ethers.utils.Interface(erc20_1.default);
|
|
15
|
+
this.supportedFunctions = {
|
|
16
|
+
approveSigHash: this.abiInterface.getSighash('approve')
|
|
17
|
+
};
|
|
18
|
+
this.provider = args.provider;
|
|
19
|
+
this.chainId = args.chainId;
|
|
20
|
+
}
|
|
21
|
+
async parse(tx) {
|
|
22
|
+
if (!tx.inputData)
|
|
23
|
+
return;
|
|
24
|
+
const txSigHash = (0, utils_1.getSigHash)(tx.inputData);
|
|
25
|
+
if (!Object.values(this.supportedFunctions).some((hash) => hash === txSigHash))
|
|
26
|
+
return;
|
|
27
|
+
const decoded = this.abiInterface.parseTransaction({ data: tx.inputData });
|
|
28
|
+
// failed to decode input data
|
|
29
|
+
if (!decoded)
|
|
30
|
+
return;
|
|
31
|
+
return {
|
|
32
|
+
data: {
|
|
33
|
+
assetId: (0, caip_1.toAssetId)({
|
|
34
|
+
...(0, caip_1.fromChainId)(this.chainId),
|
|
35
|
+
assetNamespace: 'erc20',
|
|
36
|
+
assetReference: tx.to
|
|
37
|
+
}),
|
|
38
|
+
method: decoded.name,
|
|
39
|
+
parser: types_1.TxParser.ERC20
|
|
40
|
+
}
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
exports.Parser = Parser;
|
|
@@ -14,6 +14,7 @@ export declare class TransactionParser {
|
|
|
14
14
|
private readonly yearn;
|
|
15
15
|
private readonly foxy;
|
|
16
16
|
private readonly weth;
|
|
17
|
+
private readonly erc20;
|
|
17
18
|
private readonly parsers;
|
|
18
19
|
constructor(args: TransactionParserArgs);
|
|
19
20
|
parse(tx: EthereumTx, address: string): Promise<ParsedTx>;
|
|
@@ -29,6 +29,7 @@ const bignumber_js_1 = require("bignumber.js");
|
|
|
29
29
|
const ethers_1 = require("ethers");
|
|
30
30
|
const types_1 = require("../../types");
|
|
31
31
|
const utils_1 = require("../../utils");
|
|
32
|
+
const erc20 = __importStar(require("./erc20"));
|
|
32
33
|
const foxy = __importStar(require("./foxy"));
|
|
33
34
|
const thor = __importStar(require("./thor"));
|
|
34
35
|
const uniV2 = __importStar(require("./uniV2"));
|
|
@@ -50,8 +51,9 @@ class TransactionParser {
|
|
|
50
51
|
this.yearn = new yearn.Parser({ provider, chainId: this.chainId });
|
|
51
52
|
this.foxy = new foxy.Parser();
|
|
52
53
|
this.weth = new weth.Parser({ chainId: this.chainId, provider });
|
|
54
|
+
this.erc20 = new erc20.Parser({ chainId: this.chainId, provider });
|
|
53
55
|
// order here matters currently as weth and yearn have the same sigHash for deposit() and the weth parser is stricter resulting in faster processing times
|
|
54
|
-
this.parsers = [this.zrx, this.thor, this.uniV2, this.weth, this.foxy, this.yearn];
|
|
56
|
+
this.parsers = [this.zrx, this.thor, this.uniV2, this.weth, this.foxy, this.yearn, this.erc20];
|
|
55
57
|
}
|
|
56
58
|
async parse(tx, address) {
|
|
57
59
|
var _a;
|
|
@@ -8,7 +8,6 @@ export interface ParserArgs {
|
|
|
8
8
|
}
|
|
9
9
|
export declare class Parser implements SubParser {
|
|
10
10
|
provider: ethers.providers.JsonRpcProvider;
|
|
11
|
-
readonly name = "weth";
|
|
12
11
|
readonly chainId: ChainId;
|
|
13
12
|
readonly wethContract: string;
|
|
14
13
|
readonly abiInterface: ethers.utils.Interface;
|
|
@@ -12,7 +12,6 @@ const constants_1 = require("./constants");
|
|
|
12
12
|
const utils_1 = require("./utils");
|
|
13
13
|
class Parser {
|
|
14
14
|
constructor(args) {
|
|
15
|
-
this.name = 'weth';
|
|
16
15
|
this.abiInterface = new ethers_1.ethers.utils.Interface(weth_1.default);
|
|
17
16
|
this.supportedFunctions = {
|
|
18
17
|
depositSigHash: this.abiInterface.getSighash('deposit'),
|
package/dist/ethereum/types.d.ts
CHANGED
|
@@ -1,7 +1,15 @@
|
|
|
1
1
|
import { EthereumTx } from '../generated/ethereum';
|
|
2
|
-
import { StandardTx, StandardTxMetadata } from '../types';
|
|
2
|
+
import { BaseTxMetadata, StandardTx, StandardTxMetadata } from '../types';
|
|
3
|
+
export declare enum TxParser {
|
|
4
|
+
ERC20 = "erc20"
|
|
5
|
+
}
|
|
6
|
+
export interface ERC20TxMetadata extends BaseTxMetadata {
|
|
7
|
+
parser: TxParser.ERC20;
|
|
8
|
+
assetId?: string;
|
|
9
|
+
}
|
|
10
|
+
export declare type TxMetadata = StandardTxMetadata | ERC20TxMetadata;
|
|
3
11
|
export interface ParsedTx extends StandardTx {
|
|
4
|
-
data?:
|
|
12
|
+
data?: TxMetadata;
|
|
5
13
|
}
|
|
6
14
|
export declare type TxSpecific = Partial<Pick<ParsedTx, 'trade' | 'transfers' | 'data'>>;
|
|
7
15
|
export interface SubParser {
|
package/dist/ethereum/types.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* @shapeshiftoss/bitcoin-api
|
|
3
3
|
* No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
|
|
4
4
|
*
|
|
5
|
-
* The version of the OpenAPI document:
|
|
5
|
+
* The version of the OpenAPI document: 7.0.0
|
|
6
6
|
*
|
|
7
7
|
*
|
|
8
8
|
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
* @shapeshiftoss/bitcoin-api
|
|
6
6
|
* No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
|
|
7
7
|
*
|
|
8
|
-
* The version of the OpenAPI document:
|
|
8
|
+
* The version of the OpenAPI document: 7.0.0
|
|
9
9
|
*
|
|
10
10
|
*
|
|
11
11
|
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* @shapeshiftoss/bitcoin-api
|
|
3
3
|
* No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
|
|
4
4
|
*
|
|
5
|
-
* The version of the OpenAPI document:
|
|
5
|
+
* The version of the OpenAPI document: 7.0.0
|
|
6
6
|
*
|
|
7
7
|
*
|
|
8
8
|
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
* @shapeshiftoss/bitcoin-api
|
|
6
6
|
* No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
|
|
7
7
|
*
|
|
8
|
-
* The version of the OpenAPI document:
|
|
8
|
+
* The version of the OpenAPI document: 7.0.0
|
|
9
9
|
*
|
|
10
10
|
*
|
|
11
11
|
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* @shapeshiftoss/bitcoin-api
|
|
3
3
|
* No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
|
|
4
4
|
*
|
|
5
|
-
* The version of the OpenAPI document:
|
|
5
|
+
* The version of the OpenAPI document: 7.0.0
|
|
6
6
|
*
|
|
7
7
|
*
|
|
8
8
|
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
* @shapeshiftoss/bitcoin-api
|
|
6
6
|
* No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
|
|
7
7
|
*
|
|
8
|
-
* The version of the OpenAPI document:
|
|
8
|
+
* The version of the OpenAPI document: 7.0.0
|
|
9
9
|
*
|
|
10
10
|
*
|
|
11
11
|
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* @shapeshiftoss/bitcoin-api
|
|
3
3
|
* No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
|
|
4
4
|
*
|
|
5
|
-
* The version of the OpenAPI document:
|
|
5
|
+
* The version of the OpenAPI document: 7.0.0
|
|
6
6
|
*
|
|
7
7
|
*
|
|
8
8
|
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
* @shapeshiftoss/bitcoin-api
|
|
6
6
|
* No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
|
|
7
7
|
*
|
|
8
|
-
* The version of the OpenAPI document:
|
|
8
|
+
* The version of the OpenAPI document: 7.0.0
|
|
9
9
|
*
|
|
10
10
|
*
|
|
11
11
|
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* @shapeshiftoss/bitcoin-api
|
|
3
3
|
* No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
|
|
4
4
|
*
|
|
5
|
-
* The version of the OpenAPI document:
|
|
5
|
+
* The version of the OpenAPI document: 7.0.0
|
|
6
6
|
*
|
|
7
7
|
*
|
|
8
8
|
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
* @shapeshiftoss/bitcoin-api
|
|
6
6
|
* No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
|
|
7
7
|
*
|
|
8
|
-
* The version of the OpenAPI document:
|
|
8
|
+
* The version of the OpenAPI document: 7.0.0
|
|
9
9
|
*
|
|
10
10
|
*
|
|
11
11
|
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* @shapeshiftoss/ethereum-api
|
|
3
3
|
* No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
|
|
4
4
|
*
|
|
5
|
-
* The version of the OpenAPI document:
|
|
5
|
+
* The version of the OpenAPI document: 7.0.0
|
|
6
6
|
*
|
|
7
7
|
*
|
|
8
8
|
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
* @shapeshiftoss/ethereum-api
|
|
6
6
|
* No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
|
|
7
7
|
*
|
|
8
|
-
* The version of the OpenAPI document:
|
|
8
|
+
* The version of the OpenAPI document: 7.0.0
|
|
9
9
|
*
|
|
10
10
|
*
|
|
11
11
|
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* @shapeshiftoss/ethereum-api
|
|
3
3
|
* No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
|
|
4
4
|
*
|
|
5
|
-
* The version of the OpenAPI document:
|
|
5
|
+
* The version of the OpenAPI document: 7.0.0
|
|
6
6
|
*
|
|
7
7
|
*
|
|
8
8
|
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
* @shapeshiftoss/ethereum-api
|
|
6
6
|
* No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
|
|
7
7
|
*
|
|
8
|
-
* The version of the OpenAPI document:
|
|
8
|
+
* The version of the OpenAPI document: 7.0.0
|
|
9
9
|
*
|
|
10
10
|
*
|
|
11
11
|
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* @shapeshiftoss/ethereum-api
|
|
3
3
|
* No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
|
|
4
4
|
*
|
|
5
|
-
* The version of the OpenAPI document:
|
|
5
|
+
* The version of the OpenAPI document: 7.0.0
|
|
6
6
|
*
|
|
7
7
|
*
|
|
8
8
|
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
* @shapeshiftoss/ethereum-api
|
|
6
6
|
* No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
|
|
7
7
|
*
|
|
8
|
-
* The version of the OpenAPI document:
|
|
8
|
+
* The version of the OpenAPI document: 7.0.0
|
|
9
9
|
*
|
|
10
10
|
*
|
|
11
11
|
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* @shapeshiftoss/ethereum-api
|
|
3
3
|
* No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
|
|
4
4
|
*
|
|
5
|
-
* The version of the OpenAPI document:
|
|
5
|
+
* The version of the OpenAPI document: 7.0.0
|
|
6
6
|
*
|
|
7
7
|
*
|
|
8
8
|
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
* @shapeshiftoss/ethereum-api
|
|
6
6
|
* No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
|
|
7
7
|
*
|
|
8
|
-
* The version of the OpenAPI document:
|
|
8
|
+
* The version of the OpenAPI document: 7.0.0
|
|
9
9
|
*
|
|
10
10
|
*
|
|
11
11
|
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* @shapeshiftoss/ethereum-api
|
|
3
3
|
* No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
|
|
4
4
|
*
|
|
5
|
-
* The version of the OpenAPI document:
|
|
5
|
+
* The version of the OpenAPI document: 7.0.0
|
|
6
6
|
*
|
|
7
7
|
*
|
|
8
8
|
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
* @shapeshiftoss/ethereum-api
|
|
6
6
|
* No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
|
|
7
7
|
*
|
|
8
|
-
* The version of the OpenAPI document:
|
|
8
|
+
* The version of the OpenAPI document: 7.0.0
|
|
9
9
|
*
|
|
10
10
|
*
|
|
11
11
|
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
package/dist/types.d.ts
CHANGED
|
@@ -51,8 +51,11 @@ export declare enum TxParser {
|
|
|
51
51
|
Foxy = "foxy",
|
|
52
52
|
WETH = "weth"
|
|
53
53
|
}
|
|
54
|
-
export interface
|
|
54
|
+
export interface BaseTxMetadata {
|
|
55
55
|
method?: string;
|
|
56
|
+
parser: string;
|
|
57
|
+
}
|
|
58
|
+
export interface StandardTxMetadata extends BaseTxMetadata {
|
|
56
59
|
parser: TxParser;
|
|
57
60
|
}
|
|
58
61
|
export interface StandardTx {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@shapeshiftoss/unchained-client",
|
|
3
|
-
"version": "9.0.
|
|
3
|
+
"version": "9.0.2",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"source": "src/index.ts",
|
|
@@ -22,24 +22,23 @@
|
|
|
22
22
|
"type-check": "tsc --project ./tsconfig.build.json --noEmit"
|
|
23
23
|
},
|
|
24
24
|
"dependencies": {
|
|
25
|
-
"@shapeshiftoss/blockbook": "^6.11.0",
|
|
26
25
|
"@yfi/sdk": "^1.0.30",
|
|
27
|
-
"bignumber.js": "^9.0.
|
|
26
|
+
"bignumber.js": "^9.0.2",
|
|
28
27
|
"ethers": "^5.5.3",
|
|
29
28
|
"isomorphic-ws": "^4.0.1",
|
|
30
29
|
"ws": "^8.3.0"
|
|
31
30
|
},
|
|
32
31
|
"peerDependencies": {
|
|
33
|
-
"@shapeshiftoss/caip": "^
|
|
32
|
+
"@shapeshiftoss/caip": "^6.2.0",
|
|
34
33
|
"@shapeshiftoss/logger": "^1.1.2",
|
|
35
|
-
"@shapeshiftoss/types": "
|
|
34
|
+
"@shapeshiftoss/types": "^6.2.0"
|
|
36
35
|
},
|
|
37
36
|
"devDependencies": {
|
|
38
37
|
"@openapitools/openapi-generator-cli": "^2.5.1",
|
|
39
|
-
"@shapeshiftoss/caip": "^
|
|
40
|
-
"@shapeshiftoss/common-api": "^
|
|
38
|
+
"@shapeshiftoss/caip": "^6.2.0",
|
|
39
|
+
"@shapeshiftoss/common-api": "^7.0.0",
|
|
41
40
|
"@shapeshiftoss/logger": "^1.1.2",
|
|
42
|
-
"@shapeshiftoss/types": "
|
|
41
|
+
"@shapeshiftoss/types": "^6.2.0",
|
|
43
42
|
"@types/ws": "^8.2.1"
|
|
44
43
|
}
|
|
45
44
|
}
|