@shapeshiftoss/unchained-client 9.8.3 → 9.9.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.
@@ -1,5 +1,5 @@
1
- import { StandardTx, StandardTxMetadata } from '../types';
2
- export interface TxMetadata extends StandardTxMetadata {
1
+ import { BaseTxMetadata, StandardTx } from '../types';
2
+ export interface TxMetadata extends BaseTxMetadata {
3
3
  parser: 'cosmos';
4
4
  delegator?: string;
5
5
  sourceValidator?: string;
@@ -1,5 +1,9 @@
1
1
  import { Tx } from '../../../generated/ethereum';
2
+ import { BaseTxMetadata } from '../../../types';
2
3
  import { SubParser, TxSpecific } from '../../parser';
4
+ export interface TxMetadata extends BaseTxMetadata {
5
+ parser: 'cowswap';
6
+ }
3
7
  export declare class Parser implements SubParser<Tx> {
4
8
  parse(tx: Tx): Promise<TxSpecific | undefined>;
5
9
  }
@@ -1,6 +1,10 @@
1
1
  import { ethers } from 'ethers';
2
2
  import { Tx } from '../../../generated/ethereum';
3
+ import { BaseTxMetadata } from '../../../types';
3
4
  import { SubParser, TxSpecific } from '../../parser';
5
+ export interface TxMetadata extends BaseTxMetadata {
6
+ parser: 'foxy';
7
+ }
4
8
  export declare class Parser implements SubParser<Tx> {
5
9
  readonly abiInterface: ethers.utils.Interface;
6
10
  readonly supportedFunctions: {
@@ -1,7 +1,11 @@
1
1
  import { ChainId } from '@shapeshiftoss/caip';
2
2
  import { ethers } from 'ethers';
3
3
  import { Tx } from '../../../generated/ethereum';
4
+ import { BaseTxMetadata } from '../../../types';
4
5
  import { SubParser, TxSpecific } from '../../parser';
6
+ export interface TxMetadata extends BaseTxMetadata {
7
+ parser: 'thor';
8
+ }
5
9
  export interface ParserArgs {
6
10
  chainId: ChainId;
7
11
  rpcUrl: string;
@@ -1,7 +1,11 @@
1
1
  import { ChainId } from '@shapeshiftoss/caip';
2
2
  import { ethers } from 'ethers';
3
3
  import { Tx } from '../../../generated/ethereum';
4
+ import { BaseTxMetadata } from '../../../types';
4
5
  import { SubParser, TxSpecific } from '../../parser';
6
+ export interface TxMetadata extends BaseTxMetadata {
7
+ parser: 'uniV2';
8
+ }
5
9
  export interface ParserArgs {
6
10
  chainId: ChainId;
7
11
  provider: ethers.providers.JsonRpcProvider;
@@ -1,7 +1,11 @@
1
1
  import { ChainId } from '@shapeshiftoss/caip';
2
2
  import { ethers } from 'ethers';
3
3
  import { Tx } from '../../../generated/ethereum';
4
+ import { BaseTxMetadata } from '../../../types';
4
5
  import { SubParser, TxSpecific } from '../../parser';
6
+ export interface TxMetadata extends BaseTxMetadata {
7
+ parser: 'weth';
8
+ }
5
9
  export interface ParserArgs {
6
10
  chainId: ChainId;
7
11
  provider: ethers.providers.JsonRpcProvider;
@@ -2,7 +2,13 @@ import { ChainId } from '@shapeshiftoss/caip';
2
2
  import { ChainId as YearnChainId, Yearn } from '@yfi/sdk';
3
3
  import { ethers } from 'ethers';
4
4
  import { Tx } from '../../../generated/ethereum';
5
+ import { BaseTxMetadata } from '../../../types';
5
6
  import { SubParser, TxSpecific } from '../../parser';
7
+ export interface TxMetadata extends BaseTxMetadata {
8
+ parser: 'yearn';
9
+ assetId?: string;
10
+ value?: string;
11
+ }
6
12
  interface ParserArgs {
7
13
  chainId: ChainId;
8
14
  provider: ethers.providers.JsonRpcProvider;
@@ -11,6 +17,7 @@ export declare class Parser implements SubParser<Tx> {
11
17
  provider: ethers.providers.JsonRpcProvider;
12
18
  yearnSdk: Yearn<YearnChainId> | undefined;
13
19
  yearnTokenVaultAddresses: string[] | undefined;
20
+ readonly chainId: ChainId;
14
21
  readonly shapeShiftInterface: ethers.utils.Interface;
15
22
  readonly yearnInterface: ethers.utils.Interface;
16
23
  readonly supportedYearnFunctions: {
@@ -4,6 +4,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.Parser = void 0;
7
+ const caip_1 = require("@shapeshiftoss/caip");
7
8
  const sdk_1 = require("@yfi/sdk");
8
9
  const ethers_1 = require("ethers");
9
10
  const parser_1 = require("../../parser");
@@ -25,6 +26,7 @@ class Parser {
25
26
  depositSigHash: this.shapeShiftInterface.getSighash('deposit(address,address,uint256,uint256)'),
26
27
  };
27
28
  this.provider = args.provider;
29
+ this.chainId = args.chainId;
28
30
  // The only Yearn-supported chain we currently support is mainnet
29
31
  if (args.chainId === 'eip155:1') {
30
32
  // 1 for EthMain (@yfi/sdk/dist/chain.d.ts)
@@ -36,6 +38,12 @@ class Parser {
36
38
  if (!tx.inputData)
37
39
  return;
38
40
  const txSigHash = (0, parser_1.getSigHash)(tx.inputData);
41
+ const supportedSigHashes = [
42
+ ...Object.values(this.supportedShapeShiftFunctions),
43
+ ...Object.values(this.supportedYearnFunctions),
44
+ ];
45
+ if (!supportedSigHashes.some((hash) => hash === txSigHash))
46
+ return;
39
47
  const abiInterface = this.getAbiInterface(txSigHash);
40
48
  if (!abiInterface)
41
49
  return;
@@ -47,31 +55,39 @@ class Parser {
47
55
  // failed to decode input data
48
56
  if (!decoded)
49
57
  return;
58
+ const data = {
59
+ method: decoded.name,
60
+ parser: 'yearn',
61
+ };
50
62
  switch (txSigHash) {
51
63
  case this.supportedYearnFunctions.approveSigHash:
52
- if ((decoded === null || decoded === void 0 ? void 0 : decoded.args._spender) !== constants_1.SHAPE_SHIFT_ROUTER_CONTRACT)
64
+ if (decoded.args._spender !== constants_1.SHAPE_SHIFT_ROUTER_CONTRACT)
53
65
  return;
54
- break;
66
+ return {
67
+ data: {
68
+ ...data,
69
+ assetId: (0, caip_1.toAssetId)({
70
+ chainId: this.chainId,
71
+ assetNamespace: 'erc20',
72
+ assetReference: tx.to,
73
+ }),
74
+ value: decoded.args._value.toString(),
75
+ },
76
+ };
55
77
  case this.supportedShapeShiftFunctions.depositSigHash:
56
78
  if (tx.to !== constants_1.SHAPE_SHIFT_ROUTER_CONTRACT)
57
79
  return;
58
- break;
59
- case this.supportedYearnFunctions.withdrawSigHash:
60
- case this.supportedYearnFunctions.depositSigHash:
61
- case this.supportedYearnFunctions.depositAmountSigHash:
80
+ return { data };
62
81
  case this.supportedYearnFunctions.depositAmountAndRecipientSigHash:
63
82
  if (tx.to && !((_b = this.yearnTokenVaultAddresses) === null || _b === void 0 ? void 0 : _b.includes(tx.to)))
64
83
  return;
65
- break;
84
+ return { data };
85
+ case this.supportedYearnFunctions.withdrawSigHash:
86
+ case this.supportedYearnFunctions.depositSigHash:
87
+ case this.supportedYearnFunctions.depositAmountSigHash:
66
88
  default:
67
- return;
89
+ return { data };
68
90
  }
69
- return {
70
- data: {
71
- method: decoded.name,
72
- parser: 'yearn',
73
- },
74
- };
75
91
  }
76
92
  getAbiInterface(txSigHash) {
77
93
  if (Object.values(this.supportedYearnFunctions).some((abi) => abi === txSigHash))
@@ -1,6 +1,12 @@
1
1
  import { ChainId } from '@shapeshiftoss/caip';
2
2
  import { ethers } from 'ethers';
3
+ import { BaseTxMetadata } from '../../types';
3
4
  import { SubParser, Tx, TxSpecific } from './types';
5
+ export interface TxMetadata extends BaseTxMetadata {
6
+ parser: 'erc20';
7
+ assetId: string;
8
+ value?: string;
9
+ }
4
10
  interface ParserArgs {
5
11
  chainId: ChainId;
6
12
  provider: ethers.providers.JsonRpcProvider;
@@ -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 erc20_1 = __importDefault(require("./abi/erc20"));
10
- const types_1 = require("./types");
11
10
  const utils_1 = require("./utils");
12
11
  class Parser {
13
12
  constructor(args) {
@@ -28,17 +27,21 @@ class Parser {
28
27
  // failed to decode input data
29
28
  if (!decoded)
30
29
  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
- },
30
+ const data = {
31
+ assetId: (0, caip_1.toAssetId)({
32
+ ...(0, caip_1.fromChainId)(this.chainId),
33
+ assetNamespace: 'erc20',
34
+ assetReference: tx.to,
35
+ }),
36
+ method: decoded.name,
37
+ parser: 'erc20',
41
38
  };
39
+ switch (txSigHash) {
40
+ case this.supportedFunctions.approveSigHash:
41
+ return { data: { ...data, value: (decoded === null || decoded === void 0 ? void 0 : decoded.args.amount).toString() } };
42
+ default:
43
+ return { data };
44
+ }
42
45
  }
43
46
  }
44
47
  exports.Parser = Parser;
@@ -1,14 +1,15 @@
1
1
  import type { evm } from '@shapeshiftoss/common-api';
2
- import { BaseTxMetadata, StandardTx, StandardTxMetadata } from '../../types';
2
+ import { StandardTx } from '../../types';
3
+ import * as cowswap from '../ethereum/parser/cowswap';
4
+ import * as foxy from '../ethereum/parser/foxy';
5
+ import * as thor from '../ethereum/parser/thor';
6
+ import * as uniV2 from '../ethereum/parser/uniV2';
7
+ import * as weth from '../ethereum/parser/weth';
8
+ import * as yearn from '../ethereum/parser/yearn';
9
+ import * as erc20 from '../parser/erc20';
10
+ import * as zrx from '../parser/zrx';
3
11
  export declare type Tx = evm.Tx;
4
- export declare enum TxParser {
5
- ERC20 = "erc20"
6
- }
7
- export interface ERC20TxMetadata extends BaseTxMetadata {
8
- parser: TxParser.ERC20;
9
- assetId?: string;
10
- }
11
- export declare type TxMetadata = StandardTxMetadata | ERC20TxMetadata;
12
+ export declare type TxMetadata = cowswap.TxMetadata | erc20.TxMetadata | foxy.TxMetadata | thor.TxMetadata | uniV2.TxMetadata | weth.TxMetadata | yearn.TxMetadata | zrx.TxMetadata;
12
13
  export interface ParsedTx extends StandardTx {
13
14
  data?: TxMetadata;
14
15
  }
@@ -1,7 +1,2 @@
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 = {}));
@@ -1,5 +1,9 @@
1
+ import { BaseTxMetadata } from '../../types';
1
2
  import { type Tx } from '../parser/types';
2
3
  import { type SubParser, type TxSpecific } from '.';
4
+ export interface TxMetadata extends BaseTxMetadata {
5
+ parser: 'zrx';
6
+ }
3
7
  export declare class Parser implements SubParser<Tx> {
4
8
  parse(tx: Tx): Promise<TxSpecific | undefined>;
5
9
  }
package/dist/types.d.ts CHANGED
@@ -44,23 +44,10 @@ export declare enum TransferType {
44
44
  Receive = "Receive",
45
45
  Contract = "Contract"
46
46
  }
47
- export declare enum TxParser {
48
- Cosmos = "cosmos",
49
- Yearn = "yearn",
50
- UniV2 = "uniV2",
51
- ZRX = "zrx",
52
- Thor = "thor",
53
- Foxy = "foxy",
54
- WETH = "weth",
55
- CowSwap = "cowswap"
56
- }
57
47
  export interface BaseTxMetadata {
58
48
  method?: string;
59
49
  parser: string;
60
50
  }
61
- export interface StandardTxMetadata extends BaseTxMetadata {
62
- parser: `${TxParser}`;
63
- }
64
51
  export interface StandardTx {
65
52
  address: string;
66
53
  blockHash?: string;
package/dist/types.js CHANGED
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.TxParser = exports.TransferType = exports.TradeType = exports.TxStatus = exports.Dex = void 0;
3
+ exports.TransferType = exports.TradeType = exports.TxStatus = exports.Dex = void 0;
4
4
  // these are user facing values, and should be rendered as such
5
5
  var Dex;
6
6
  (function (Dex) {
@@ -29,14 +29,3 @@ var TransferType;
29
29
  TransferType["Receive"] = "Receive";
30
30
  TransferType["Contract"] = "Contract";
31
31
  })(TransferType = exports.TransferType || (exports.TransferType = {}));
32
- var TxParser;
33
- (function (TxParser) {
34
- TxParser["Cosmos"] = "cosmos";
35
- TxParser["Yearn"] = "yearn";
36
- TxParser["UniV2"] = "uniV2";
37
- TxParser["ZRX"] = "zrx";
38
- TxParser["Thor"] = "thor";
39
- TxParser["Foxy"] = "foxy";
40
- TxParser["WETH"] = "weth";
41
- TxParser["CowSwap"] = "cowswap";
42
- })(TxParser = exports.TxParser || (exports.TxParser = {}));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@shapeshiftoss/unchained-client",
3
- "version": "9.8.3",
3
+ "version": "9.9.0",
4
4
  "license": "MIT",
5
5
  "main": "dist/index.js",
6
6
  "source": "src/index.ts",