@shapeshiftoss/unchained-client 9.0.0-alpha.1 → 9.0.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.
@@ -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,7 +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 });
53
- this.parsers = [this.zrx, this.thor, this.uniV2, this.yearn, this.foxy, this.weth];
54
+ this.erc20 = new erc20.Parser({ chainId: this.chainId, provider });
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
56
+ this.parsers = [this.zrx, this.thor, this.uniV2, this.weth, this.foxy, this.yearn, this.erc20];
54
57
  }
55
58
  async parse(tx, address) {
56
59
  var _a;
@@ -7,7 +7,6 @@ exports.Parser = void 0;
7
7
  const caip_1 = require("@shapeshiftoss/caip");
8
8
  const ethers_1 = require("ethers");
9
9
  const types_1 = require("../../types");
10
- const erc20_1 = __importDefault(require("./abi/erc20"));
11
10
  const weth_1 = __importDefault(require("./abi/weth"));
12
11
  const constants_1 = require("./constants");
13
12
  const utils_1 = require("./utils");
@@ -43,7 +42,6 @@ class Parser {
43
42
  // failed to decode input data
44
43
  if (!decoded)
45
44
  return;
46
- const contract = new ethers_1.ethers.Contract(this.wethContract, erc20_1.default, this.provider);
47
45
  const assetId = (0, caip_1.toAssetId)({
48
46
  ...(0, caip_1.fromChainId)(this.chainId),
49
47
  assetNamespace: 'erc20',
@@ -51,9 +49,9 @@ class Parser {
51
49
  });
52
50
  const token = {
53
51
  contract: this.wethContract,
54
- decimals: await contract.decimals(),
55
- name: await contract.name(),
56
- symbol: await contract.symbol()
52
+ decimals: 18,
53
+ name: 'Wrapped Ether',
54
+ symbol: 'WETH'
57
55
  };
58
56
  const transfers = (() => {
59
57
  switch (txSigHash) {
@@ -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?: StandardTxMetadata;
12
+ data?: TxMetadata;
5
13
  }
6
14
  export declare type TxSpecific = Partial<Pick<ParsedTx, 'trade' | 'transfers' | 'data'>>;
7
15
  export interface SubParser {
@@ -1,2 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.TxParser = void 0;
4
+ var TxParser;
5
+ (function (TxParser) {
6
+ TxParser["ERC20"] = "erc20";
7
+ })(TxParser = exports.TxParser || (exports.TxParser = {}));
@@ -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: 6.11.0
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: 6.11.0
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: 6.11.0
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: 6.11.0
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: 6.11.0
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: 6.11.0
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: 6.11.0
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: 6.11.0
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: 6.11.0
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: 6.11.0
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: 6.11.0
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: 6.11.0
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: 6.11.0
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: 6.11.0
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: 6.11.0
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: 6.11.0
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: 6.11.0
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: 6.11.0
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: 6.11.0
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: 6.11.0
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 StandardTxMetadata {
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.0-alpha.1",
3
+ "version": "9.0.1",
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.1",
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": "^5.2.1",
32
+ "@shapeshiftoss/caip": "^6.0.1",
34
33
  "@shapeshiftoss/logger": "^1.1.2",
35
- "@shapeshiftoss/types": "^4.3.1"
34
+ "@shapeshiftoss/types": "^4.4.0"
36
35
  },
37
36
  "devDependencies": {
38
37
  "@openapitools/openapi-generator-cli": "^2.5.1",
39
- "@shapeshiftoss/caip": "^5.2.1",
40
- "@shapeshiftoss/common-api": "^6.11.0",
38
+ "@shapeshiftoss/caip": "^6.0.1",
39
+ "@shapeshiftoss/common-api": "^7.0.0",
41
40
  "@shapeshiftoss/logger": "^1.1.2",
42
- "@shapeshiftoss/types": "^4.3.1",
41
+ "@shapeshiftoss/types": "^4.4.0",
43
42
  "@types/ws": "^8.2.1"
44
43
  }
45
44
  }