@shapeshiftoss/unchained-client 6.11.0 → 6.11.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.
Files changed (187) hide show
  1. package/README.md +3 -1
  2. package/dist/bitcoin/index.d.ts +0 -1
  3. package/dist/bitcoin/index.js +5 -2
  4. package/dist/bitcoin/parser/index.d.ts +0 -1
  5. package/dist/bitcoin/parser/index.js +43 -55
  6. package/dist/bitcoin/parser/utils.d.ts +0 -1
  7. package/dist/bitcoin/parser/utils.js +0 -1
  8. package/dist/bitcoin/types.d.ts +0 -1
  9. package/dist/bitcoin/types.js +0 -1
  10. package/dist/cosmos/index.d.ts +0 -1
  11. package/dist/cosmos/index.js +5 -2
  12. package/dist/cosmos/parser/index.d.ts +1 -2
  13. package/dist/cosmos/parser/index.js +56 -64
  14. package/dist/cosmos/parser/utils.d.ts +2 -3
  15. package/dist/cosmos/parser/utils.js +21 -22
  16. package/dist/cosmos/types.d.ts +0 -1
  17. package/dist/cosmos/types.js +0 -1
  18. package/dist/ethereum/index.d.ts +0 -1
  19. package/dist/ethereum/index.js +5 -2
  20. package/dist/ethereum/parser/abi/erc20.d.ts +0 -1
  21. package/dist/ethereum/parser/abi/erc20.js +69 -70
  22. package/dist/ethereum/parser/abi/foxyStaking.d.ts +0 -1
  23. package/dist/ethereum/parser/abi/foxyStaking.js +161 -162
  24. package/dist/ethereum/parser/abi/multiSig.d.ts +0 -1
  25. package/dist/ethereum/parser/abi/multiSig.js +79 -80
  26. package/dist/ethereum/parser/abi/shapeShiftRouter.d.ts +0 -1
  27. package/dist/ethereum/parser/abi/shapeShiftRouter.js +119 -120
  28. package/dist/ethereum/parser/abi/thor.d.ts +0 -1
  29. package/dist/ethereum/parser/abi/thor.js +28 -29
  30. package/dist/ethereum/parser/abi/uniV2.d.ts +0 -1
  31. package/dist/ethereum/parser/abi/uniV2.js +55 -56
  32. package/dist/ethereum/parser/abi/weth.d.ts +0 -1
  33. package/dist/ethereum/parser/abi/weth.js +66 -67
  34. package/dist/ethereum/parser/abi/yearnVault.d.ts +0 -1
  35. package/dist/ethereum/parser/abi/yearnVault.js +95 -96
  36. package/dist/ethereum/parser/constants.d.ts +0 -1
  37. package/dist/ethereum/parser/constants.js +0 -1
  38. package/dist/ethereum/parser/foxy.d.ts +1 -2
  39. package/dist/ethereum/parser/foxy.js +22 -34
  40. package/dist/ethereum/parser/index.d.ts +0 -1
  41. package/dist/ethereum/parser/index.js +46 -54
  42. package/dist/ethereum/parser/thor.d.ts +1 -2
  43. package/dist/ethereum/parser/thor.js +29 -41
  44. package/dist/ethereum/parser/uniV2.d.ts +0 -1
  45. package/dist/ethereum/parser/uniV2.js +87 -99
  46. package/dist/ethereum/parser/utils.d.ts +0 -1
  47. package/dist/ethereum/parser/utils.js +2 -3
  48. package/dist/ethereum/parser/weth.d.ts +0 -1
  49. package/dist/ethereum/parser/weth.js +72 -84
  50. package/dist/ethereum/parser/yearn.d.ts +1 -2
  51. package/dist/ethereum/parser/yearn.js +46 -58
  52. package/dist/ethereum/parser/zrx.d.ts +1 -2
  53. package/dist/ethereum/parser/zrx.js +18 -30
  54. package/dist/ethereum/types.d.ts +0 -1
  55. package/dist/ethereum/types.js +0 -1
  56. package/dist/generated/bitcoin/api.d.ts +116 -120
  57. package/dist/generated/bitcoin/api.js +81 -110
  58. package/dist/generated/bitcoin/base.d.ts +2 -3
  59. package/dist/generated/bitcoin/base.js +1 -2
  60. package/dist/generated/bitcoin/common.d.ts +2 -3
  61. package/dist/generated/bitcoin/common.js +22 -38
  62. package/dist/generated/bitcoin/configuration.d.ts +0 -1
  63. package/dist/generated/bitcoin/configuration.js +0 -1
  64. package/dist/generated/bitcoin/index.d.ts +0 -1
  65. package/dist/generated/bitcoin/index.js +5 -2
  66. package/dist/generated/cosmos/api.d.ts +143 -144
  67. package/dist/generated/cosmos/api.js +89 -115
  68. package/dist/generated/cosmos/base.d.ts +2 -3
  69. package/dist/generated/cosmos/base.js +0 -1
  70. package/dist/generated/cosmos/common.d.ts +2 -3
  71. package/dist/generated/cosmos/common.js +22 -38
  72. package/dist/generated/cosmos/configuration.d.ts +0 -1
  73. package/dist/generated/cosmos/configuration.js +0 -1
  74. package/dist/generated/cosmos/index.d.ts +0 -1
  75. package/dist/generated/cosmos/index.js +5 -2
  76. package/dist/generated/ethereum/api.d.ts +73 -77
  77. package/dist/generated/ethereum/api.js +73 -100
  78. package/dist/generated/ethereum/base.d.ts +2 -3
  79. package/dist/generated/ethereum/base.js +1 -2
  80. package/dist/generated/ethereum/common.d.ts +2 -3
  81. package/dist/generated/ethereum/common.js +22 -38
  82. package/dist/generated/ethereum/configuration.d.ts +0 -1
  83. package/dist/generated/ethereum/configuration.js +0 -1
  84. package/dist/generated/ethereum/index.d.ts +0 -1
  85. package/dist/generated/ethereum/index.js +5 -2
  86. package/dist/index.d.ts +0 -1
  87. package/dist/index.js +5 -2
  88. package/dist/types.d.ts +0 -1
  89. package/dist/types.js +0 -1
  90. package/dist/utils.d.ts +1 -2
  91. package/dist/utils.js +18 -21
  92. package/dist/websocket.d.ts +1 -2
  93. package/dist/websocket.js +78 -84
  94. package/package.json +19 -11
  95. package/dist/bitcoin/index.d.ts.map +0 -1
  96. package/dist/bitcoin/index.js.map +0 -1
  97. package/dist/bitcoin/parser/index.d.ts.map +0 -1
  98. package/dist/bitcoin/parser/index.js.map +0 -1
  99. package/dist/bitcoin/parser/utils.d.ts.map +0 -1
  100. package/dist/bitcoin/parser/utils.js.map +0 -1
  101. package/dist/bitcoin/types.d.ts.map +0 -1
  102. package/dist/bitcoin/types.js.map +0 -1
  103. package/dist/cosmos/index.d.ts.map +0 -1
  104. package/dist/cosmos/index.js.map +0 -1
  105. package/dist/cosmos/parser/index.d.ts.map +0 -1
  106. package/dist/cosmos/parser/index.js.map +0 -1
  107. package/dist/cosmos/parser/utils.d.ts.map +0 -1
  108. package/dist/cosmos/parser/utils.js.map +0 -1
  109. package/dist/cosmos/types.d.ts.map +0 -1
  110. package/dist/cosmos/types.js.map +0 -1
  111. package/dist/ethereum/index.d.ts.map +0 -1
  112. package/dist/ethereum/index.js.map +0 -1
  113. package/dist/ethereum/parser/abi/erc20.d.ts.map +0 -1
  114. package/dist/ethereum/parser/abi/erc20.js.map +0 -1
  115. package/dist/ethereum/parser/abi/foxyStaking.d.ts.map +0 -1
  116. package/dist/ethereum/parser/abi/foxyStaking.js.map +0 -1
  117. package/dist/ethereum/parser/abi/multiSig.d.ts.map +0 -1
  118. package/dist/ethereum/parser/abi/multiSig.js.map +0 -1
  119. package/dist/ethereum/parser/abi/shapeShiftRouter.d.ts.map +0 -1
  120. package/dist/ethereum/parser/abi/shapeShiftRouter.js.map +0 -1
  121. package/dist/ethereum/parser/abi/thor.d.ts.map +0 -1
  122. package/dist/ethereum/parser/abi/thor.js.map +0 -1
  123. package/dist/ethereum/parser/abi/uniV2.d.ts.map +0 -1
  124. package/dist/ethereum/parser/abi/uniV2.js.map +0 -1
  125. package/dist/ethereum/parser/abi/weth.d.ts.map +0 -1
  126. package/dist/ethereum/parser/abi/weth.js.map +0 -1
  127. package/dist/ethereum/parser/abi/yearnVault.d.ts.map +0 -1
  128. package/dist/ethereum/parser/abi/yearnVault.js.map +0 -1
  129. package/dist/ethereum/parser/constants.d.ts.map +0 -1
  130. package/dist/ethereum/parser/constants.js.map +0 -1
  131. package/dist/ethereum/parser/foxy.d.ts.map +0 -1
  132. package/dist/ethereum/parser/foxy.js.map +0 -1
  133. package/dist/ethereum/parser/index.d.ts.map +0 -1
  134. package/dist/ethereum/parser/index.js.map +0 -1
  135. package/dist/ethereum/parser/thor.d.ts.map +0 -1
  136. package/dist/ethereum/parser/thor.js.map +0 -1
  137. package/dist/ethereum/parser/uniV2.d.ts.map +0 -1
  138. package/dist/ethereum/parser/uniV2.js.map +0 -1
  139. package/dist/ethereum/parser/utils.d.ts.map +0 -1
  140. package/dist/ethereum/parser/utils.js.map +0 -1
  141. package/dist/ethereum/parser/weth.d.ts.map +0 -1
  142. package/dist/ethereum/parser/weth.js.map +0 -1
  143. package/dist/ethereum/parser/yearn.d.ts.map +0 -1
  144. package/dist/ethereum/parser/yearn.js.map +0 -1
  145. package/dist/ethereum/parser/zrx.d.ts.map +0 -1
  146. package/dist/ethereum/parser/zrx.js.map +0 -1
  147. package/dist/ethereum/types.d.ts.map +0 -1
  148. package/dist/ethereum/types.js.map +0 -1
  149. package/dist/generated/bitcoin/api.d.ts.map +0 -1
  150. package/dist/generated/bitcoin/api.js.map +0 -1
  151. package/dist/generated/bitcoin/base.d.ts.map +0 -1
  152. package/dist/generated/bitcoin/base.js.map +0 -1
  153. package/dist/generated/bitcoin/common.d.ts.map +0 -1
  154. package/dist/generated/bitcoin/common.js.map +0 -1
  155. package/dist/generated/bitcoin/configuration.d.ts.map +0 -1
  156. package/dist/generated/bitcoin/configuration.js.map +0 -1
  157. package/dist/generated/bitcoin/index.d.ts.map +0 -1
  158. package/dist/generated/bitcoin/index.js.map +0 -1
  159. package/dist/generated/cosmos/api.d.ts.map +0 -1
  160. package/dist/generated/cosmos/api.js.map +0 -1
  161. package/dist/generated/cosmos/base.d.ts.map +0 -1
  162. package/dist/generated/cosmos/base.js.map +0 -1
  163. package/dist/generated/cosmos/common.d.ts.map +0 -1
  164. package/dist/generated/cosmos/common.js.map +0 -1
  165. package/dist/generated/cosmos/configuration.d.ts.map +0 -1
  166. package/dist/generated/cosmos/configuration.js.map +0 -1
  167. package/dist/generated/cosmos/index.d.ts.map +0 -1
  168. package/dist/generated/cosmos/index.js.map +0 -1
  169. package/dist/generated/ethereum/api.d.ts.map +0 -1
  170. package/dist/generated/ethereum/api.js.map +0 -1
  171. package/dist/generated/ethereum/base.d.ts.map +0 -1
  172. package/dist/generated/ethereum/base.js.map +0 -1
  173. package/dist/generated/ethereum/common.d.ts.map +0 -1
  174. package/dist/generated/ethereum/common.js.map +0 -1
  175. package/dist/generated/ethereum/configuration.d.ts.map +0 -1
  176. package/dist/generated/ethereum/configuration.js.map +0 -1
  177. package/dist/generated/ethereum/index.d.ts.map +0 -1
  178. package/dist/generated/ethereum/index.js.map +0 -1
  179. package/dist/index.d.ts.map +0 -1
  180. package/dist/index.js.map +0 -1
  181. package/dist/tsconfig.tsbuildinfo +0 -4986
  182. package/dist/types.d.ts.map +0 -1
  183. package/dist/types.js.map +0 -1
  184. package/dist/utils.d.ts.map +0 -1
  185. package/dist/utils.js.map +0 -1
  186. package/dist/websocket.d.ts.map +0 -1
  187. package/dist/websocket.js.map +0 -1
@@ -1,13 +1,4 @@
1
1
  "use strict";
2
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
- return new (P || (P = Promise))(function (resolve, reject) {
5
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
- step((generator = generator.apply(thisArg, _arguments || [])).next());
9
- });
10
- };
11
2
  var __importDefault = (this && this.__importDefault) || function (mod) {
12
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
13
4
  };
@@ -17,111 +8,109 @@ const caip_1 = require("@shapeshiftoss/caip");
17
8
  const types_1 = require("@shapeshiftoss/types");
18
9
  const ethers_1 = require("ethers");
19
10
  const types_2 = require("../../types");
20
- const uniV2_1 = __importDefault(require("./abi/uniV2"));
21
11
  const erc20_1 = __importDefault(require("./abi/erc20"));
22
- const utils_1 = require("./utils");
12
+ const uniV2_1 = __importDefault(require("./abi/uniV2"));
23
13
  const constants_1 = require("./constants");
14
+ const utils_1 = require("./utils");
24
15
  class Parser {
25
16
  constructor(args) {
26
17
  this.abiInterface = new ethers_1.ethers.utils.Interface(uniV2_1.default);
27
18
  this.supportedFunctions = {
28
19
  addLiquidityEthSigHash: this.abiInterface.getSighash('addLiquidityETH'),
29
- removeLiquidityEthSigHash: this.abiInterface.getSighash('removeLiquidityETH'),
20
+ removeLiquidityEthSigHash: this.abiInterface.getSighash('removeLiquidityETH')
30
21
  };
31
22
  this.network = args.network;
32
23
  this.provider = args.provider;
33
24
  this.wethContract = {
34
25
  mainnet: constants_1.WETH_CONTRACT_MAINNET,
35
- ropsten: constants_1.WETH_CONTRACT_ROPSTEN,
26
+ ropsten: constants_1.WETH_CONTRACT_ROPSTEN
36
27
  }[this.network];
37
28
  }
38
- parse(tx) {
29
+ async parse(tx) {
39
30
  var _a, _b, _c;
40
- return __awaiter(this, void 0, void 0, function* () {
41
- const txData = (_a = tx.ethereumSpecific) === null || _a === void 0 ? void 0 : _a.data;
42
- if (!utils_1.txInteractsWithContract(tx, constants_1.UNI_V2_ROUTER_CONTRACT))
43
- return;
44
- if (!txData)
45
- return;
46
- if (tx.confirmations)
47
- return;
48
- const txSigHash = utils_1.getSigHash(txData);
49
- if (!Object.values(this.supportedFunctions).some((hash) => hash === txSigHash))
50
- return;
51
- const decoded = this.abiInterface.parseTransaction({ data: txData });
52
- // failed to decode input data
53
- if (!decoded)
54
- return;
55
- const sendAddress = (_c = (_b = tx.vin[0].addresses) === null || _b === void 0 ? void 0 : _b[0]) !== null && _c !== void 0 ? _c : '';
56
- const tokenAddress = ethers_1.ethers.utils.getAddress(decoded.args.token.toLowerCase());
57
- const lpTokenAddress = Parser.pairFor(tokenAddress, this.wethContract);
58
- const transfers = yield (() => __awaiter(this, void 0, void 0, function* () {
59
- switch (utils_1.getSigHash(txData)) {
60
- case this.supportedFunctions.addLiquidityEthSigHash: {
61
- const contract = new ethers_1.ethers.Contract(tokenAddress, erc20_1.default, this.provider);
62
- const decimals = yield contract.decimals();
63
- const name = yield contract.name();
64
- const symbol = yield contract.symbol();
65
- const value = decoded.args.amountTokenDesired.toString();
66
- const assetId = caip_1.caip19.toCAIP19({
67
- chain: types_1.ChainTypes.Ethereum,
68
- network: utils_1.toNetworkType(this.network),
69
- assetNamespace: caip_1.AssetNamespace.ERC20,
70
- assetReference: tokenAddress,
71
- });
72
- return [
73
- {
74
- type: types_2.TransferType.Send,
75
- from: sendAddress,
76
- to: lpTokenAddress,
77
- caip19: assetId,
78
- assetId: assetId,
79
- totalValue: value,
80
- components: [{ value }],
81
- token: { contract: tokenAddress, decimals, name, symbol },
82
- },
83
- ];
84
- }
85
- case this.supportedFunctions.removeLiquidityEthSigHash: {
86
- const contract = new ethers_1.ethers.Contract(lpTokenAddress, erc20_1.default, this.provider);
87
- const decimals = yield contract.decimals();
88
- const name = yield contract.name();
89
- const symbol = yield contract.symbol();
90
- const value = decoded.args.liquidity.toString();
91
- const assetId = caip_1.caip19.toCAIP19({
92
- chain: types_1.ChainTypes.Ethereum,
93
- network: utils_1.toNetworkType(this.network),
94
- assetNamespace: caip_1.AssetNamespace.ERC20,
95
- assetReference: lpTokenAddress,
96
- });
97
- return [
98
- {
99
- type: types_2.TransferType.Send,
100
- from: sendAddress,
101
- to: lpTokenAddress,
102
- caip19: assetId,
103
- assetId: assetId,
104
- totalValue: value,
105
- components: [{ value }],
106
- token: { contract: lpTokenAddress, decimals, name, symbol },
107
- },
108
- ];
109
- }
110
- default:
111
- return;
31
+ const txData = (_a = tx.ethereumSpecific) === null || _a === void 0 ? void 0 : _a.data;
32
+ if (!(0, utils_1.txInteractsWithContract)(tx, constants_1.UNI_V2_ROUTER_CONTRACT))
33
+ return;
34
+ if (!txData)
35
+ return;
36
+ if (tx.confirmations)
37
+ return;
38
+ const txSigHash = (0, utils_1.getSigHash)(txData);
39
+ if (!Object.values(this.supportedFunctions).some((hash) => hash === txSigHash))
40
+ return;
41
+ const decoded = this.abiInterface.parseTransaction({ data: txData });
42
+ // failed to decode input data
43
+ if (!decoded)
44
+ return;
45
+ const sendAddress = (_c = (_b = tx.vin[0].addresses) === null || _b === void 0 ? void 0 : _b[0]) !== null && _c !== void 0 ? _c : '';
46
+ const tokenAddress = ethers_1.ethers.utils.getAddress(decoded.args.token.toLowerCase());
47
+ const lpTokenAddress = Parser.pairFor(tokenAddress, this.wethContract);
48
+ const transfers = await (async () => {
49
+ switch ((0, utils_1.getSigHash)(txData)) {
50
+ case this.supportedFunctions.addLiquidityEthSigHash: {
51
+ const contract = new ethers_1.ethers.Contract(tokenAddress, erc20_1.default, this.provider);
52
+ const decimals = await contract.decimals();
53
+ const name = await contract.name();
54
+ const symbol = await contract.symbol();
55
+ const value = decoded.args.amountTokenDesired.toString();
56
+ const assetId = caip_1.caip19.toCAIP19({
57
+ chain: types_1.ChainTypes.Ethereum,
58
+ network: (0, utils_1.toNetworkType)(this.network),
59
+ assetNamespace: caip_1.AssetNamespace.ERC20,
60
+ assetReference: tokenAddress
61
+ });
62
+ return [
63
+ {
64
+ type: types_2.TransferType.Send,
65
+ from: sendAddress,
66
+ to: lpTokenAddress,
67
+ caip19: assetId,
68
+ assetId,
69
+ totalValue: value,
70
+ components: [{ value }],
71
+ token: { contract: tokenAddress, decimals, name, symbol }
72
+ }
73
+ ];
74
+ }
75
+ case this.supportedFunctions.removeLiquidityEthSigHash: {
76
+ const contract = new ethers_1.ethers.Contract(lpTokenAddress, erc20_1.default, this.provider);
77
+ const decimals = await contract.decimals();
78
+ const name = await contract.name();
79
+ const symbol = await contract.symbol();
80
+ const value = decoded.args.liquidity.toString();
81
+ const assetId = caip_1.caip19.toCAIP19({
82
+ chain: types_1.ChainTypes.Ethereum,
83
+ network: (0, utils_1.toNetworkType)(this.network),
84
+ assetNamespace: caip_1.AssetNamespace.ERC20,
85
+ assetReference: lpTokenAddress
86
+ });
87
+ return [
88
+ {
89
+ type: types_2.TransferType.Send,
90
+ from: sendAddress,
91
+ to: lpTokenAddress,
92
+ caip19: assetId,
93
+ assetId,
94
+ totalValue: value,
95
+ components: [{ value }],
96
+ token: { contract: lpTokenAddress, decimals, name, symbol }
97
+ }
98
+ ];
112
99
  }
113
- }))();
114
- // no supported function detected
115
- if (!transfers)
116
- return;
117
- return {
118
- transfers,
119
- data: {
120
- parser: types_2.TxParser.UniV2,
121
- method: decoded.name,
122
- },
123
- };
124
- });
100
+ default:
101
+ return;
102
+ }
103
+ })();
104
+ // no supported function detected
105
+ if (!transfers)
106
+ return;
107
+ return {
108
+ transfers,
109
+ data: {
110
+ parser: types_2.TxParser.UniV2,
111
+ method: decoded.name
112
+ }
113
+ };
125
114
  }
126
115
  static pairFor(tokenA, tokenB) {
127
116
  const [token0, token1] = tokenA < tokenB ? [tokenA, tokenB] : [tokenB, tokenA];
@@ -132,4 +121,3 @@ class Parser {
132
121
  }
133
122
  }
134
123
  exports.Parser = Parser;
135
- //# sourceMappingURL=uniV2.js.map
@@ -6,4 +6,3 @@ export declare const getSigHash: (inputData: string | undefined) => string | und
6
6
  export declare const txInteractsWithContract: (tx: BlockbookTx, contract: string) => boolean;
7
7
  export declare const SENDMULTISIG_SIG_HASH: string;
8
8
  export declare const getInternalMultisigAddress: (inputData: string) => string | undefined;
9
- //# sourceMappingURL=utils.d.ts.map
@@ -4,8 +4,8 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.getInternalMultisigAddress = exports.SENDMULTISIG_SIG_HASH = exports.txInteractsWithContract = exports.getSigHash = exports.toNetworkType = void 0;
7
- const ethers_1 = require("ethers");
8
7
  const types_1 = require("@shapeshiftoss/types");
8
+ const ethers_1 = require("ethers");
9
9
  const multiSig_1 = __importDefault(require("./abi/multiSig"));
10
10
  const toNetworkType = (network) => {
11
11
  switch (network) {
@@ -38,10 +38,9 @@ exports.SENDMULTISIG_SIG_HASH = (() => {
38
38
  // detect address associated with sendMultiSig internal transaction
39
39
  const getInternalMultisigAddress = (inputData) => {
40
40
  const abiInterface = new ethers_1.ethers.utils.Interface(multiSig_1.default);
41
- if (exports.getSigHash(inputData) !== exports.SENDMULTISIG_SIG_HASH)
41
+ if ((0, exports.getSigHash)(inputData) !== exports.SENDMULTISIG_SIG_HASH)
42
42
  return;
43
43
  const result = abiInterface.decodeFunctionData(exports.SENDMULTISIG_SIG_HASH, inputData);
44
44
  return result.toAddress;
45
45
  };
46
46
  exports.getInternalMultisigAddress = getInternalMultisigAddress;
47
- //# sourceMappingURL=utils.js.map
@@ -17,4 +17,3 @@ export declare class Parser implements SubParser {
17
17
  constructor(args: ParserArgs);
18
18
  parse(tx: BlockbookTx): Promise<TxSpecific | undefined>;
19
19
  }
20
- //# sourceMappingURL=weth.d.ts.map
@@ -1,13 +1,4 @@
1
1
  "use strict";
2
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
- return new (P || (P = Promise))(function (resolve, reject) {
5
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
- step((generator = generator.apply(thisArg, _arguments || [])).next());
9
- });
10
- };
11
2
  var __importDefault = (this && this.__importDefault) || function (mod) {
12
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
13
4
  };
@@ -19,96 +10,93 @@ const ethers_1 = require("ethers");
19
10
  const types_2 = require("../../types");
20
11
  const erc20_1 = __importDefault(require("./abi/erc20"));
21
12
  const weth_1 = __importDefault(require("./abi/weth"));
22
- const utils_1 = require("./utils");
23
13
  const constants_1 = require("./constants");
14
+ const utils_1 = require("./utils");
24
15
  class Parser {
25
16
  constructor(args) {
26
17
  this.abiInterface = new ethers_1.ethers.utils.Interface(weth_1.default);
27
18
  this.supportedFunctions = {
28
19
  depositSigHash: this.abiInterface.getSighash('deposit'),
29
- withdrawalSigHash: this.abiInterface.getSighash('withdraw'),
20
+ withdrawalSigHash: this.abiInterface.getSighash('withdraw')
30
21
  };
31
22
  this.network = args.network;
32
23
  this.provider = args.provider;
33
24
  this.wethContract = {
34
25
  mainnet: constants_1.WETH_CONTRACT_MAINNET,
35
- ropsten: constants_1.WETH_CONTRACT_ROPSTEN,
26
+ ropsten: constants_1.WETH_CONTRACT_ROPSTEN
36
27
  }[this.network];
37
28
  }
38
- parse(tx) {
29
+ async parse(tx) {
39
30
  var _a, _b, _c;
40
- return __awaiter(this, void 0, void 0, function* () {
41
- const txData = (_a = tx.ethereumSpecific) === null || _a === void 0 ? void 0 : _a.data;
42
- if (!utils_1.txInteractsWithContract(tx, this.wethContract))
43
- return;
44
- if (!txData)
45
- return;
46
- const txSigHash = utils_1.getSigHash(txData);
47
- if (!Object.values(this.supportedFunctions).some((hash) => hash === txSigHash))
48
- return;
49
- const decoded = this.abiInterface.parseTransaction({ data: txData });
50
- // failed to decode input data
51
- if (!decoded)
52
- return;
53
- const sendAddress = (_c = (_b = tx.vin[0].addresses) === null || _b === void 0 ? void 0 : _b[0]) !== null && _c !== void 0 ? _c : '';
54
- const contract = new ethers_1.ethers.Contract(this.wethContract, erc20_1.default, this.provider);
55
- const assetId = caip_1.caip19.toCAIP19({
56
- chain: types_1.ChainTypes.Ethereum,
57
- network: utils_1.toNetworkType(this.network),
58
- assetNamespace: caip_1.AssetNamespace.ERC20,
59
- assetReference: this.wethContract,
60
- });
61
- const token = {
62
- contract: this.wethContract,
63
- decimals: yield contract.decimals(),
64
- name: yield contract.name(),
65
- symbol: yield contract.symbol(),
66
- };
67
- const transfers = (() => {
68
- switch (txSigHash) {
69
- case this.supportedFunctions.depositSigHash: {
70
- return [
71
- {
72
- type: types_2.TransferType.Receive,
73
- from: this.wethContract,
74
- to: sendAddress,
75
- caip19: assetId,
76
- assetId: assetId,
77
- totalValue: tx.value,
78
- components: [{ value: tx.value }],
79
- token: token,
80
- },
81
- ];
82
- }
83
- case this.supportedFunctions.withdrawalSigHash:
84
- return [
85
- {
86
- type: types_2.TransferType.Send,
87
- from: sendAddress,
88
- to: this.wethContract,
89
- caip19: assetId,
90
- assetId: assetId,
91
- totalValue: decoded.args.wad.toString(),
92
- components: [{ value: decoded.args.wad.toString() }],
93
- token: token,
94
- },
95
- ];
96
- default:
97
- return;
98
- }
99
- })();
100
- // no supported function detected
101
- if (!transfers)
102
- return;
103
- return {
104
- transfers,
105
- data: {
106
- parser: types_2.TxParser.WETH,
107
- method: decoded.name,
108
- },
109
- };
31
+ const txData = (_a = tx.ethereumSpecific) === null || _a === void 0 ? void 0 : _a.data;
32
+ if (!(0, utils_1.txInteractsWithContract)(tx, this.wethContract))
33
+ return;
34
+ if (!txData)
35
+ return;
36
+ const txSigHash = (0, utils_1.getSigHash)(txData);
37
+ if (!Object.values(this.supportedFunctions).some((hash) => hash === txSigHash))
38
+ return;
39
+ const decoded = this.abiInterface.parseTransaction({ data: txData });
40
+ // failed to decode input data
41
+ if (!decoded)
42
+ return;
43
+ const sendAddress = (_c = (_b = tx.vin[0].addresses) === null || _b === void 0 ? void 0 : _b[0]) !== null && _c !== void 0 ? _c : '';
44
+ const contract = new ethers_1.ethers.Contract(this.wethContract, erc20_1.default, this.provider);
45
+ const assetId = caip_1.caip19.toCAIP19({
46
+ chain: types_1.ChainTypes.Ethereum,
47
+ network: (0, utils_1.toNetworkType)(this.network),
48
+ assetNamespace: caip_1.AssetNamespace.ERC20,
49
+ assetReference: this.wethContract
110
50
  });
51
+ const token = {
52
+ contract: this.wethContract,
53
+ decimals: await contract.decimals(),
54
+ name: await contract.name(),
55
+ symbol: await contract.symbol()
56
+ };
57
+ const transfers = (() => {
58
+ switch (txSigHash) {
59
+ case this.supportedFunctions.depositSigHash: {
60
+ return [
61
+ {
62
+ type: types_2.TransferType.Receive,
63
+ from: this.wethContract,
64
+ to: sendAddress,
65
+ caip19: assetId,
66
+ assetId,
67
+ totalValue: tx.value,
68
+ components: [{ value: tx.value }],
69
+ token
70
+ }
71
+ ];
72
+ }
73
+ case this.supportedFunctions.withdrawalSigHash:
74
+ return [
75
+ {
76
+ type: types_2.TransferType.Send,
77
+ from: sendAddress,
78
+ to: this.wethContract,
79
+ caip19: assetId,
80
+ assetId,
81
+ totalValue: decoded.args.wad.toString(),
82
+ components: [{ value: decoded.args.wad.toString() }],
83
+ token
84
+ }
85
+ ];
86
+ default:
87
+ return;
88
+ }
89
+ })();
90
+ // no supported function detected
91
+ if (!transfers)
92
+ return;
93
+ return {
94
+ transfers,
95
+ data: {
96
+ parser: types_2.TxParser.WETH,
97
+ method: decoded.name
98
+ }
99
+ };
111
100
  }
112
101
  }
113
102
  exports.Parser = Parser;
114
- //# sourceMappingURL=weth.js.map
@@ -1,5 +1,5 @@
1
- import { ChainId, Yearn } from '@yfi/sdk';
2
1
  import { Tx as BlockbookTx } from '@shapeshiftoss/blockbook';
2
+ import { ChainId, Yearn } from '@yfi/sdk';
3
3
  import { ethers } from 'ethers';
4
4
  import { Network, SubParser, TxSpecific } from '../types';
5
5
  interface ParserArgs {
@@ -27,4 +27,3 @@ export declare class Parser implements SubParser {
27
27
  getAbiInterface(txSigHash: string | undefined): ethers.utils.Interface | undefined;
28
28
  }
29
29
  export {};
30
- //# sourceMappingURL=yearn.d.ts.map
@@ -1,13 +1,4 @@
1
1
  "use strict";
2
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
- return new (P || (P = Promise))(function (resolve, reject) {
5
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
- step((generator = generator.apply(thisArg, _arguments || [])).next());
9
- });
10
- };
11
2
  var __importDefault = (this && this.__importDefault) || function (mod) {
12
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
13
4
  };
@@ -15,11 +6,11 @@ Object.defineProperty(exports, "__esModule", { value: true });
15
6
  exports.Parser = void 0;
16
7
  const sdk_1 = require("@yfi/sdk");
17
8
  const ethers_1 = require("ethers");
18
- const constants_1 = require("./constants");
19
- const utils_1 = require("./utils");
9
+ const types_1 = require("../../types");
20
10
  const shapeShiftRouter_1 = __importDefault(require("./abi/shapeShiftRouter"));
21
11
  const yearnVault_1 = __importDefault(require("./abi/yearnVault"));
22
- const types_1 = require("../../types");
12
+ const constants_1 = require("./constants");
13
+ const utils_1 = require("./utils");
23
14
  class Parser {
24
15
  constructor(args) {
25
16
  this.shapeShiftInterface = new ethers_1.ethers.utils.Interface(shapeShiftRouter_1.default);
@@ -29,63 +20,61 @@ class Parser {
29
20
  depositSigHash: this.yearnInterface.getSighash('deposit()'),
30
21
  depositAmountSigHash: this.yearnInterface.getSighash('deposit(uint256)'),
31
22
  depositAmountAndRecipientSigHash: this.yearnInterface.getSighash('deposit(uint256,address)'),
32
- withdrawSigHash: this.yearnInterface.getSighash('withdraw(uint256,address)'),
23
+ withdrawSigHash: this.yearnInterface.getSighash('withdraw(uint256,address)')
33
24
  };
34
25
  this.supportedShapeShiftFunctions = {
35
- depositSigHash: this.shapeShiftInterface.getSighash('deposit(address,address,uint256,uint256)'),
26
+ depositSigHash: this.shapeShiftInterface.getSighash('deposit(address,address,uint256,uint256)')
36
27
  };
37
28
  this.provider = args.provider;
38
29
  // The only Yearn-supported chain we currently support is mainnet
39
30
  if (args.network === 'mainnet') {
40
31
  // 1 for EthMain (@yfi/sdk/dist/chain.d.ts)
41
- this.yearnSdk = new sdk_1.Yearn(1, { provider: this.provider, disableAllowlist: true });
32
+ this.yearnSdk = new sdk_1.Yearn(1, { provider: this.provider });
42
33
  }
43
34
  }
44
- parse(tx) {
35
+ async parse(tx) {
45
36
  var _a, _b, _c, _d, _e;
46
- return __awaiter(this, void 0, void 0, function* () {
47
- const txData = (_a = tx.ethereumSpecific) === null || _a === void 0 ? void 0 : _a.data;
48
- if (!txData)
49
- return;
50
- const txSigHash = utils_1.getSigHash(txData);
51
- const abiInterface = this.getAbiInterface(txSigHash);
52
- if (!abiInterface)
53
- return;
54
- if (!this.yearnTokenVaultAddresses) {
55
- const vaults = yield ((_b = this.yearnSdk) === null || _b === void 0 ? void 0 : _b.vaults.get());
56
- this.yearnTokenVaultAddresses = vaults === null || vaults === void 0 ? void 0 : vaults.map((vault) => vault.address);
57
- }
58
- const decoded = abiInterface.parseTransaction({ data: txData });
59
- // failed to decode input data
60
- if (!decoded)
61
- return;
62
- const receiveAddress = (_d = (_c = tx.vout) === null || _c === void 0 ? void 0 : _c[0].addresses) === null || _d === void 0 ? void 0 : _d[0];
63
- switch (txSigHash) {
64
- case this.supportedYearnFunctions.approveSigHash:
65
- if ((decoded === null || decoded === void 0 ? void 0 : decoded.args._spender) !== constants_1.SHAPE_SHIFT_ROUTER_CONTRACT)
66
- return;
67
- break;
68
- case this.supportedShapeShiftFunctions.depositSigHash:
69
- if (receiveAddress !== constants_1.SHAPE_SHIFT_ROUTER_CONTRACT)
70
- return;
71
- break;
72
- case this.supportedYearnFunctions.withdrawSigHash:
73
- case this.supportedYearnFunctions.depositSigHash:
74
- case this.supportedYearnFunctions.depositAmountSigHash:
75
- case this.supportedYearnFunctions.depositAmountAndRecipientSigHash:
76
- if (receiveAddress && !((_e = this.yearnTokenVaultAddresses) === null || _e === void 0 ? void 0 : _e.includes(receiveAddress)))
77
- return;
78
- break;
79
- default:
37
+ const txData = (_a = tx.ethereumSpecific) === null || _a === void 0 ? void 0 : _a.data;
38
+ if (!txData)
39
+ return;
40
+ const txSigHash = (0, utils_1.getSigHash)(txData);
41
+ const abiInterface = this.getAbiInterface(txSigHash);
42
+ if (!abiInterface)
43
+ return;
44
+ if (!this.yearnTokenVaultAddresses) {
45
+ const vaults = await ((_b = this.yearnSdk) === null || _b === void 0 ? void 0 : _b.vaults.get());
46
+ this.yearnTokenVaultAddresses = vaults === null || vaults === void 0 ? void 0 : vaults.map((vault) => vault.address);
47
+ }
48
+ const decoded = abiInterface.parseTransaction({ data: txData });
49
+ // failed to decode input data
50
+ if (!decoded)
51
+ 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
+ switch (txSigHash) {
54
+ case this.supportedYearnFunctions.approveSigHash:
55
+ if ((decoded === null || decoded === void 0 ? void 0 : decoded.args._spender) !== constants_1.SHAPE_SHIFT_ROUTER_CONTRACT)
56
+ return;
57
+ break;
58
+ case this.supportedShapeShiftFunctions.depositSigHash:
59
+ if (receiveAddress !== constants_1.SHAPE_SHIFT_ROUTER_CONTRACT)
80
60
  return;
61
+ break;
62
+ case this.supportedYearnFunctions.withdrawSigHash:
63
+ case this.supportedYearnFunctions.depositSigHash:
64
+ case this.supportedYearnFunctions.depositAmountSigHash:
65
+ case this.supportedYearnFunctions.depositAmountAndRecipientSigHash:
66
+ if (receiveAddress && !((_e = this.yearnTokenVaultAddresses) === null || _e === void 0 ? void 0 : _e.includes(receiveAddress)))
67
+ return;
68
+ break;
69
+ default:
70
+ return;
71
+ }
72
+ return {
73
+ data: {
74
+ method: decoded.name,
75
+ parser: types_1.TxParser.Yearn
81
76
  }
82
- return {
83
- data: {
84
- method: decoded.name,
85
- parser: types_1.TxParser.Yearn,
86
- },
87
- };
88
- });
77
+ };
89
78
  }
90
79
  getAbiInterface(txSigHash) {
91
80
  if (Object.values(this.supportedYearnFunctions).some((abi) => abi === txSigHash))
@@ -96,4 +85,3 @@ class Parser {
96
85
  }
97
86
  }
98
87
  exports.Parser = Parser;
99
- //# sourceMappingURL=yearn.js.map
@@ -1,6 +1,5 @@
1
1
  import { Tx as BlockbookTx } from '@shapeshiftoss/blockbook';
2
- import { TxSpecific, SubParser } from '../types';
2
+ import { SubParser, TxSpecific } from '../types';
3
3
  export declare class Parser implements SubParser {
4
4
  parse(tx: BlockbookTx): Promise<TxSpecific | undefined>;
5
5
  }
6
- //# sourceMappingURL=zrx.d.ts.map