@shapeshiftoss/unchained-client 6.10.0 → 6.12.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.
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 -54
  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 +4 -5
  13. package/dist/cosmos/parser/index.js +55 -50
  14. package/dist/cosmos/parser/utils.d.ts +3 -4
  15. package/dist/cosmos/parser/utils.js +28 -25
  16. package/dist/cosmos/types.d.ts +4 -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 +8 -9
  39. package/dist/ethereum/parser/foxy.js +27 -59
  40. package/dist/ethereum/parser/index.d.ts +0 -1
  41. package/dist/ethereum/parser/index.js +52 -59
  42. package/dist/ethereum/parser/thor.d.ts +6 -5
  43. package/dist/ethereum/parser/thor.js +33 -49
  44. package/dist/ethereum/parser/uniV2.d.ts +5 -5
  45. package/dist/ethereum/parser/uniV2.js +75 -82
  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 +6 -5
  49. package/dist/ethereum/parser/weth.js +76 -99
  50. package/dist/ethereum/parser/yearn.d.ts +11 -12
  51. package/dist/ethereum/parser/yearn.js +51 -62
  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 +117 -121
  57. package/dist/generated/bitcoin/api.js +82 -111
  58. package/dist/generated/bitcoin/base.d.ts +3 -4
  59. package/dist/generated/bitcoin/base.js +2 -3
  60. package/dist/generated/bitcoin/common.d.ts +3 -4
  61. package/dist/generated/bitcoin/common.js +23 -39
  62. package/dist/generated/bitcoin/configuration.d.ts +1 -2
  63. package/dist/generated/bitcoin/configuration.js +1 -2
  64. package/dist/generated/bitcoin/index.d.ts +1 -2
  65. package/dist/generated/bitcoin/index.js +6 -3
  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 +74 -78
  77. package/dist/generated/ethereum/api.js +74 -101
  78. package/dist/generated/ethereum/base.d.ts +3 -4
  79. package/dist/generated/ethereum/base.js +2 -3
  80. package/dist/generated/ethereum/common.d.ts +3 -4
  81. package/dist/generated/ethereum/common.js +23 -39
  82. package/dist/generated/ethereum/configuration.d.ts +1 -2
  83. package/dist/generated/ethereum/configuration.js +1 -2
  84. package/dist/generated/ethereum/index.d.ts +1 -2
  85. package/dist/generated/ethereum/index.js +6 -3
  86. package/dist/index.d.ts +0 -1
  87. package/dist/index.js +5 -2
  88. package/dist/types.d.ts +12 -2
  89. package/dist/types.js +0 -1
  90. package/dist/utils.d.ts +2 -3
  91. package/dist/utils.js +23 -23
  92. package/dist/websocket.d.ts +1 -2
  93. package/dist/websocket.js +78 -80
  94. package/package.json +21 -13
  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 -4970
  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
@@ -6,4 +6,3 @@ export declare const THOR_ROUTER_CONTRACT_ROPSTEN = "0xefA28233838f46a80AaaC8c30
6
6
  export declare const FOXY_STAKING_CONTRACT = "0xee77aa3Fd23BbeBaf94386dD44b548e9a785ea4b";
7
7
  export declare const WETH_CONTRACT_MAINNET = "0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2";
8
8
  export declare const WETH_CONTRACT_ROPSTEN = "0xc778417E063141139Fce010982780140Aa0cD5Ab";
9
- //# sourceMappingURL=constants.d.ts.map
@@ -9,4 +9,3 @@ exports.THOR_ROUTER_CONTRACT_ROPSTEN = '0xefA28233838f46a80AaaC8c309077a9ba70D12
9
9
  exports.FOXY_STAKING_CONTRACT = '0xee77aa3Fd23BbeBaf94386dD44b548e9a785ea4b';
10
10
  exports.WETH_CONTRACT_MAINNET = '0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2';
11
11
  exports.WETH_CONTRACT_ROPSTEN = '0xc778417E063141139Fce010982780140Aa0cD5Ab';
12
- //# sourceMappingURL=constants.js.map
@@ -1,14 +1,13 @@
1
1
  import { Tx as BlockbookTx } from '@shapeshiftoss/blockbook';
2
2
  import { ethers } from 'ethers';
3
- import { TxSpecific, SubParser } from '../types';
3
+ import { SubParser, TxSpecific } from '../types';
4
4
  export declare class Parser implements SubParser {
5
- abiInterface: ethers.utils.Interface;
6
- readonly stakeSigHash: string;
7
- readonly unstakeSigHash: string;
8
- readonly instantUnstakeSigHash: string;
9
- readonly claimWithdrawSigHash: string;
5
+ readonly abiInterface: ethers.utils.Interface;
6
+ readonly supportedFunctions: {
7
+ stakeSigHash: string;
8
+ unstakeSigHash: string;
9
+ instantUnstakeSigHash: string;
10
+ claimWithdrawSigHash: string;
11
+ };
10
12
  parse(tx: BlockbookTx): Promise<TxSpecific | undefined>;
11
- supportedFoxyFunctions(): string[];
12
- abiInterfaceSupportsSigHash(txSigHash: string | undefined): ethers.utils.Interface | undefined;
13
13
  }
14
- //# sourceMappingURL=foxy.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,62 +6,39 @@ Object.defineProperty(exports, "__esModule", { value: true });
15
6
  exports.Parser = void 0;
16
7
  const ethers_1 = require("ethers");
17
8
  const types_1 = require("../../types");
18
- const utils_1 = require("./utils");
19
- const constants_1 = require("./constants");
20
9
  const foxyStaking_1 = __importDefault(require("./abi/foxyStaking"));
10
+ const constants_1 = require("./constants");
11
+ const utils_1 = require("./utils");
21
12
  class Parser {
22
13
  constructor() {
23
14
  this.abiInterface = new ethers_1.ethers.utils.Interface(foxyStaking_1.default);
24
- // Hard coded staking sigHash because there is two different stake methods
25
- // in the foxy staking contract. This gives us the ability to parse the correct one.
26
- this.stakeSigHash = '0x7acb7757';
27
- this.unstakeSigHash = this.abiInterface.getSighash('unstake');
28
- this.instantUnstakeSigHash = this.abiInterface.getSighash('instantUnstake');
29
- this.claimWithdrawSigHash = this.abiInterface.getSighash('claimWithdraw');
15
+ this.supportedFunctions = {
16
+ stakeSigHash: this.abiInterface.getSighash('stake(uint256,address)'),
17
+ unstakeSigHash: this.abiInterface.getSighash('unstake'),
18
+ instantUnstakeSigHash: this.abiInterface.getSighash('instantUnstake'),
19
+ claimWithdrawSigHash: this.abiInterface.getSighash('claimWithdraw')
20
+ };
30
21
  }
31
- parse(tx) {
22
+ async parse(tx) {
32
23
  var _a;
33
- return __awaiter(this, void 0, void 0, function* () {
34
- if (!utils_1.txInteractsWithContract(tx, constants_1.FOXY_STAKING_CONTRACT))
35
- return;
36
- const txData = (_a = tx.ethereumSpecific) === null || _a === void 0 ? void 0 : _a.data;
37
- if (!txData)
38
- return;
39
- const txSigHash = utils_1.getSigHash(txData);
40
- const abiInterface = this.abiInterfaceSupportsSigHash(txSigHash);
41
- if (!abiInterface)
42
- return;
43
- const decoded = abiInterface.parseTransaction({ data: txData });
44
- const result = (() => {
45
- switch (utils_1.getSigHash(txData)) {
46
- case this.stakeSigHash:
47
- case this.unstakeSigHash:
48
- case this.instantUnstakeSigHash:
49
- case this.claimWithdrawSigHash:
50
- return decoded.args;
51
- default:
52
- return undefined;
53
- }
54
- })();
55
- // We didn't recognise the sigHash - exit
56
- if (!result)
57
- return;
58
- return {
59
- data: {
60
- method: decoded.name,
61
- parser: types_1.TxParser.Foxy,
62
- },
63
- };
64
- });
65
- }
66
- supportedFoxyFunctions() {
67
- return [this.stakeSigHash, this.unstakeSigHash, this.instantUnstakeSigHash, this.claimWithdrawSigHash];
68
- }
69
- abiInterfaceSupportsSigHash(txSigHash) {
70
- if (this.supportedFoxyFunctions().some((abi) => abi === txSigHash))
71
- return this.abiInterface;
72
- return undefined;
24
+ const txData = (_a = tx.ethereumSpecific) === null || _a === void 0 ? void 0 : _a.data;
25
+ if (!(0, utils_1.txInteractsWithContract)(tx, constants_1.FOXY_STAKING_CONTRACT))
26
+ return;
27
+ if (!txData)
28
+ return;
29
+ const txSigHash = (0, utils_1.getSigHash)(txData);
30
+ if (!Object.values(this.supportedFunctions).some((hash) => hash === txSigHash))
31
+ return;
32
+ const decoded = this.abiInterface.parseTransaction({ data: txData });
33
+ // failed to decode input data
34
+ if (!decoded)
35
+ return;
36
+ return {
37
+ data: {
38
+ method: decoded.name,
39
+ parser: types_1.TxParser.Foxy
40
+ }
41
+ };
73
42
  }
74
43
  }
75
44
  exports.Parser = Parser;
76
- //# sourceMappingURL=foxy.js.map
@@ -19,4 +19,3 @@ export declare class TransactionParser {
19
19
  private static getStatus;
20
20
  private getParsedTxWithTransfers;
21
21
  }
22
- //# sourceMappingURL=index.d.ts.map
@@ -1,7 +1,11 @@
1
1
  "use strict";
2
2
  var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
3
  if (k2 === undefined) k2 = k;
4
- Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
5
9
  }) : (function(o, m, k, k2) {
6
10
  if (k2 === undefined) k2 = k;
7
11
  o[k2] = m[k];
@@ -18,30 +22,21 @@ var __importStar = (this && this.__importStar) || function (mod) {
18
22
  __setModuleDefault(result, mod);
19
23
  return result;
20
24
  };
21
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
22
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
23
- return new (P || (P = Promise))(function (resolve, reject) {
24
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
25
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
26
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
27
- step((generator = generator.apply(thisArg, _arguments || [])).next());
28
- });
29
- };
30
25
  Object.defineProperty(exports, "__esModule", { value: true });
31
26
  exports.TransactionParser = void 0;
32
- const bignumber_js_1 = require("bignumber.js");
33
- const ethers_1 = require("ethers");
34
27
  const caip_1 = require("@shapeshiftoss/caip");
35
28
  const types_1 = require("@shapeshiftoss/types");
29
+ const bignumber_js_1 = require("bignumber.js");
30
+ const ethers_1 = require("ethers");
36
31
  const types_2 = require("../../types");
37
32
  const utils_1 = require("../../utils");
38
- const utils_2 = require("./utils");
33
+ const foxy = __importStar(require("./foxy"));
39
34
  const thor = __importStar(require("./thor"));
40
35
  const uniV2 = __importStar(require("./uniV2"));
41
- const zrx = __importStar(require("./zrx"));
42
- const yearn = __importStar(require("./yearn"));
43
- const foxy = __importStar(require("./foxy"));
36
+ const utils_2 = require("./utils");
44
37
  const weth = __importStar(require("./weth"));
38
+ const yearn = __importStar(require("./yearn"));
39
+ const zrx = __importStar(require("./zrx"));
45
40
  class TransactionParser {
46
41
  constructor(args) {
47
42
  var _a;
@@ -57,35 +52,34 @@ class TransactionParser {
57
52
  }
58
53
  // return any addresses that can be detected
59
54
  getInternalAddress(inputData) {
60
- switch (utils_2.getSigHash(inputData)) {
61
- case this.thor.transferOutSigHash:
55
+ switch ((0, utils_2.getSigHash)(inputData)) {
56
+ case this.thor.supportedFunctions.transferOutSigHash:
62
57
  return this.thor.getInternalAddress(inputData);
63
58
  case utils_2.SENDMULTISIG_SIG_HASH:
64
- return utils_2.getInternalMultisigAddress(inputData);
59
+ return (0, utils_2.getInternalMultisigAddress)(inputData);
65
60
  default:
66
61
  return;
67
62
  }
68
63
  }
69
- parse(tx, address, internalTxs) {
64
+ async parse(tx, address, internalTxs) {
70
65
  var _a;
71
- return __awaiter(this, void 0, void 0, function* () {
72
- // We expect only one Parser to return a result. If multiple do, we take the first and early exit.
73
- const contractParserResult = yield utils_1.findAsyncSequential(this.parsers, (parser) => __awaiter(this, void 0, void 0, function* () { return yield parser.parse(tx); }));
74
- const parsedTx = {
75
- address,
76
- blockHash: tx.blockHash,
77
- blockHeight: tx.blockHeight,
78
- blockTime: tx.blockTime,
79
- caip2: caip_1.caip2.toCAIP2({ chain: types_1.ChainTypes.Ethereum, network: utils_2.toNetworkType(this.network) }),
80
- confirmations: tx.confirmations,
81
- status: TransactionParser.getStatus(tx),
82
- trade: contractParserResult === null || contractParserResult === void 0 ? void 0 : contractParserResult.trade,
83
- transfers: (_a = contractParserResult === null || contractParserResult === void 0 ? void 0 : contractParserResult.transfers) !== null && _a !== void 0 ? _a : [],
84
- txid: tx.txid,
85
- data: contractParserResult === null || contractParserResult === void 0 ? void 0 : contractParserResult.data,
86
- };
87
- return this.getParsedTxWithTransfers(tx, parsedTx, address, internalTxs);
88
- });
66
+ // We expect only one Parser to return a result. If multiple do, we take the first and early exit.
67
+ const contractParserResult = await (0, utils_1.findAsyncSequential)(this.parsers, async (parser) => await parser.parse(tx));
68
+ const parsedTx = {
69
+ address,
70
+ blockHash: tx.blockHash,
71
+ blockHeight: tx.blockHeight,
72
+ blockTime: tx.blockTime,
73
+ caip2: (0, caip_1.toCAIP2)({ chain: types_1.ChainTypes.Ethereum, network: (0, utils_2.toNetworkType)(this.network) }),
74
+ chainId: (0, caip_1.toCAIP2)({ chain: types_1.ChainTypes.Ethereum, network: (0, utils_2.toNetworkType)(this.network) }),
75
+ confirmations: tx.confirmations,
76
+ status: TransactionParser.getStatus(tx),
77
+ trade: contractParserResult === null || contractParserResult === void 0 ? void 0 : contractParserResult.trade,
78
+ transfers: (_a = contractParserResult === null || contractParserResult === void 0 ? void 0 : contractParserResult.transfers) !== null && _a !== void 0 ? _a : [],
79
+ txid: tx.txid,
80
+ data: contractParserResult === null || contractParserResult === void 0 ? void 0 : contractParserResult.data
81
+ };
82
+ return this.getParsedTxWithTransfers(tx, parsedTx, address, internalTxs);
89
83
  }
90
84
  static getStatus(tx) {
91
85
  var _a;
@@ -100,11 +94,11 @@ class TransactionParser {
100
94
  }
101
95
  getParsedTxWithTransfers(tx, parsedTx, address, internalTxs) {
102
96
  var _a, _b, _c, _d, _e, _f;
103
- const caip19Ethereum = caip_1.caip19.toCAIP19({
97
+ const caip19Ethereum = (0, caip_1.toCAIP19)({
104
98
  chain: types_1.ChainTypes.Ethereum,
105
- network: utils_2.toNetworkType(this.network),
99
+ network: (0, utils_2.toNetworkType)(this.network),
106
100
  assetNamespace: caip_1.AssetNamespace.Slip44,
107
- assetReference: caip_1.AssetReference.Ethereum,
101
+ assetReference: caip_1.AssetReference.Ethereum
108
102
  });
109
103
  const sendAddress = (_b = (_a = tx.vin[0].addresses) === null || _a === void 0 ? void 0 : _a[0]) !== null && _b !== void 0 ? _b : '';
110
104
  const receiveAddress = (_d = (_c = tx.vout[0].addresses) === null || _c === void 0 ? void 0 : _c[0]) !== null && _d !== void 0 ? _d : '';
@@ -112,24 +106,24 @@ class TransactionParser {
112
106
  // send amount
113
107
  const sendValue = new bignumber_js_1.BigNumber(tx.value);
114
108
  if (sendValue.gt(0)) {
115
- parsedTx.transfers = utils_1.aggregateTransfer(parsedTx.transfers, types_2.TransferType.Send, caip19Ethereum, sendAddress, receiveAddress, sendValue.toString(10));
109
+ parsedTx.transfers = (0, utils_1.aggregateTransfer)(parsedTx.transfers, types_2.TransferType.Send, caip19Ethereum, sendAddress, receiveAddress, sendValue.toString(10));
116
110
  }
117
111
  // network fee
118
112
  const fees = new bignumber_js_1.BigNumber((_e = tx.fees) !== null && _e !== void 0 ? _e : 0);
119
113
  if (fees.gt(0)) {
120
- parsedTx.fee = { caip19: caip19Ethereum, value: fees.toString(10) };
114
+ parsedTx.fee = { caip19: caip19Ethereum, assetId: caip19Ethereum, value: fees.toString(10) };
121
115
  }
122
116
  }
123
117
  if (address === receiveAddress) {
124
118
  // receive amount
125
119
  const receiveValue = new bignumber_js_1.BigNumber(tx.value);
126
120
  if (receiveValue.gt(0)) {
127
- parsedTx.transfers = utils_1.aggregateTransfer(parsedTx.transfers, types_2.TransferType.Receive, caip19Ethereum, sendAddress, receiveAddress, receiveValue.toString(10));
121
+ parsedTx.transfers = (0, utils_1.aggregateTransfer)(parsedTx.transfers, types_2.TransferType.Receive, caip19Ethereum, sendAddress, receiveAddress, receiveValue.toString(10));
128
122
  }
129
123
  }
130
124
  (_f = tx.tokenTransfers) === null || _f === void 0 ? void 0 : _f.forEach((transfer) => {
131
125
  // FTX Token (FTT) name and symbol was set backwards on the ERC20 contract
132
- if (transfer.token == '0x50D1c9771902476076eCFc8B2A83Ad6b9355a4c9') {
126
+ if (transfer.token === '0x50D1c9771902476076eCFc8B2A83Ad6b9355a4c9') {
133
127
  transfer.name = transfer.symbol;
134
128
  transfer.symbol = transfer.name;
135
129
  }
@@ -137,52 +131,51 @@ class TransactionParser {
137
131
  contract: transfer.token,
138
132
  decimals: transfer.decimals,
139
133
  name: transfer.name,
140
- symbol: transfer.symbol,
134
+ symbol: transfer.symbol
141
135
  };
142
136
  const transferArgs = [
143
- caip_1.caip19.toCAIP19({
137
+ (0, caip_1.toCAIP19)({
144
138
  chain: types_1.ChainTypes.Ethereum,
145
- network: utils_2.toNetworkType(this.network),
139
+ network: (0, utils_2.toNetworkType)(this.network),
146
140
  assetNamespace: caip_1.AssetNamespace.ERC20,
147
- assetReference: transfer.token,
141
+ assetReference: transfer.token
148
142
  }),
149
143
  transfer.from,
150
144
  transfer.to,
151
145
  transfer.value,
152
- token,
146
+ token
153
147
  ];
154
148
  // token send amount
155
149
  if (address === transfer.from) {
156
- parsedTx.transfers = utils_1.aggregateTransfer(parsedTx.transfers, types_2.TransferType.Send, ...transferArgs);
150
+ parsedTx.transfers = (0, utils_1.aggregateTransfer)(parsedTx.transfers, types_2.TransferType.Send, ...transferArgs);
157
151
  }
158
152
  // token receive amount
159
153
  if (address === transfer.to) {
160
- parsedTx.transfers = utils_1.aggregateTransfer(parsedTx.transfers, types_2.TransferType.Receive, ...transferArgs);
154
+ parsedTx.transfers = (0, utils_1.aggregateTransfer)(parsedTx.transfers, types_2.TransferType.Receive, ...transferArgs);
161
155
  }
162
156
  });
163
157
  internalTxs === null || internalTxs === void 0 ? void 0 : internalTxs.forEach((internalTx) => {
164
158
  const transferArgs = [
165
- caip_1.caip19.toCAIP19({
159
+ (0, caip_1.toCAIP19)({
166
160
  chain: types_1.ChainTypes.Ethereum,
167
- network: utils_2.toNetworkType(this.network),
161
+ network: (0, utils_2.toNetworkType)(this.network),
168
162
  assetNamespace: caip_1.AssetNamespace.Slip44,
169
- assetReference: caip_1.AssetReference.Ethereum,
163
+ assetReference: caip_1.AssetReference.Ethereum
170
164
  }),
171
165
  internalTx.from,
172
166
  internalTx.to,
173
- internalTx.value,
167
+ internalTx.value
174
168
  ];
175
169
  // internal eth send
176
170
  if (address === internalTx.from) {
177
- parsedTx.transfers = utils_1.aggregateTransfer(parsedTx.transfers, types_2.TransferType.Send, ...transferArgs);
171
+ parsedTx.transfers = (0, utils_1.aggregateTransfer)(parsedTx.transfers, types_2.TransferType.Send, ...transferArgs);
178
172
  }
179
173
  // internal eth receive
180
174
  if (address === internalTx.to) {
181
- parsedTx.transfers = utils_1.aggregateTransfer(parsedTx.transfers, types_2.TransferType.Receive, ...transferArgs);
175
+ parsedTx.transfers = (0, utils_1.aggregateTransfer)(parsedTx.transfers, types_2.TransferType.Receive, ...transferArgs);
182
176
  }
183
177
  });
184
178
  return parsedTx;
185
179
  }
186
180
  }
187
181
  exports.TransactionParser = TransactionParser;
188
- //# sourceMappingURL=index.js.map
@@ -1,17 +1,18 @@
1
- import { ethers } from 'ethers';
2
1
  import { Tx as BlockbookTx } from '@shapeshiftoss/blockbook';
2
+ import { ethers } from 'ethers';
3
3
  import { Network, SubParser, TxSpecific } from '../types';
4
4
  export interface ParserArgs {
5
5
  network: Network;
6
6
  rpcUrl: string;
7
7
  }
8
8
  export declare class Parser implements SubParser {
9
- abiInterface: ethers.utils.Interface;
10
- readonly depositSigHash: string;
11
- readonly transferOutSigHash: string;
12
9
  readonly routerContract: string;
10
+ readonly abiInterface: ethers.utils.Interface;
11
+ readonly supportedFunctions: {
12
+ depositSigHash: string;
13
+ transferOutSigHash: string;
14
+ };
13
15
  constructor(args: ParserArgs);
14
16
  getInternalAddress(inputData: string): string | undefined;
15
17
  parse(tx: BlockbookTx): Promise<TxSpecific | undefined>;
16
18
  }
17
- //# sourceMappingURL=thor.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
  };
@@ -16,66 +7,59 @@ exports.Parser = void 0;
16
7
  const ethers_1 = require("ethers");
17
8
  const types_1 = require("../../types");
18
9
  const thor_1 = __importDefault(require("./abi/thor"));
19
- const utils_1 = require("./utils");
20
10
  const constants_1 = require("./constants");
11
+ const utils_1 = require("./utils");
21
12
  const SWAP_TYPES = ['SWAP', '=', 's'];
22
13
  class Parser {
23
14
  constructor(args) {
24
15
  this.abiInterface = new ethers_1.ethers.utils.Interface(thor_1.default);
25
- this.depositSigHash = this.abiInterface.getSighash('deposit');
26
- this.transferOutSigHash = this.abiInterface.getSighash('transferOut');
16
+ this.supportedFunctions = {
17
+ depositSigHash: this.abiInterface.getSighash('deposit'),
18
+ transferOutSigHash: this.abiInterface.getSighash('transferOut')
19
+ };
27
20
  // TODO: Router contract can change, use /inbound_addresses endpoint to determine current router contract
28
21
  this.routerContract = {
29
22
  mainnet: constants_1.THOR_ROUTER_CONTRACT_MAINNET,
30
- ropsten: constants_1.THOR_ROUTER_CONTRACT_ROPSTEN,
23
+ ropsten: constants_1.THOR_ROUTER_CONTRACT_ROPSTEN
31
24
  }[args.network];
32
25
  }
33
26
  // detect address associated with transferOut internal transaction
34
27
  getInternalAddress(inputData) {
35
- if (utils_1.getSigHash(inputData) !== this.transferOutSigHash)
28
+ if ((0, utils_1.getSigHash)(inputData) !== this.supportedFunctions.transferOutSigHash)
36
29
  return;
37
- const result = this.abiInterface.decodeFunctionData(this.transferOutSigHash, inputData);
30
+ const result = this.abiInterface.decodeFunctionData(this.supportedFunctions.transferOutSigHash, inputData);
38
31
  const [type] = result.memo.split(':');
39
32
  if (type !== 'OUT' || type !== 'REFUND')
40
33
  return;
41
34
  return result.to;
42
35
  }
43
- parse(tx) {
36
+ async parse(tx) {
44
37
  var _a;
45
- return __awaiter(this, void 0, void 0, function* () {
46
- const txData = (_a = tx.ethereumSpecific) === null || _a === void 0 ? void 0 : _a.data;
47
- if (!utils_1.txInteractsWithContract(tx, this.routerContract))
48
- return;
49
- if (!txData)
50
- return;
51
- const decoded = this.abiInterface.parseTransaction({ data: txData });
52
- const result = (() => {
53
- switch (utils_1.getSigHash(txData)) {
54
- case this.depositSigHash:
55
- case this.transferOutSigHash:
56
- return decoded.args;
57
- default:
58
- return undefined;
59
- }
60
- })();
61
- // We didn't recognise the sigHash - exit
62
- if (!result)
63
- return;
64
- const data = {
65
- method: decoded.name,
66
- parser: types_1.TxParser.Thor,
67
- };
68
- const [type] = result.memo.split(':');
69
- if (SWAP_TYPES.includes(type) || type === 'OUT') {
70
- return { trade: { dexName: types_1.Dex.Thor, type: types_1.TradeType.Trade, memo: result.memo }, data };
71
- }
72
- if (type === 'REFUND') {
73
- return { trade: { dexName: types_1.Dex.Thor, type: types_1.TradeType.Refund, memo: result.memo }, data };
74
- }
75
- // We encountered a case we thought we'd support, but don't - exit
38
+ const txData = (_a = tx.ethereumSpecific) === null || _a === void 0 ? void 0 : _a.data;
39
+ if (!(0, utils_1.txInteractsWithContract)(tx, this.routerContract))
40
+ return;
41
+ if (!txData)
42
+ return;
43
+ const txSigHash = (0, utils_1.getSigHash)(txData);
44
+ if (!Object.values(this.supportedFunctions).some((hash) => hash === txSigHash))
45
+ return;
46
+ const decoded = this.abiInterface.parseTransaction({ data: txData });
47
+ // failed to decode input data
48
+ if (!decoded)
76
49
  return;
77
- });
50
+ const data = {
51
+ method: decoded.name,
52
+ parser: types_1.TxParser.Thor
53
+ };
54
+ const [type] = decoded.args.memo.split(':');
55
+ if (SWAP_TYPES.includes(type) || type === 'OUT') {
56
+ return { trade: { dexName: types_1.Dex.Thor, type: types_1.TradeType.Trade, memo: decoded.args.memo }, data };
57
+ }
58
+ if (type === 'REFUND') {
59
+ return { trade: { dexName: types_1.Dex.Thor, type: types_1.TradeType.Refund, memo: decoded.args.memo }, data };
60
+ }
61
+ // memo type not supported
62
+ return;
78
63
  }
79
64
  }
80
65
  exports.Parser = Parser;
81
- //# sourceMappingURL=thor.js.map
@@ -6,15 +6,15 @@ export interface ParserArgs {
6
6
  provider: ethers.providers.JsonRpcProvider;
7
7
  }
8
8
  export declare class Parser implements SubParser {
9
- abiInterface: ethers.utils.Interface;
10
9
  network: Network;
11
10
  provider: ethers.providers.JsonRpcProvider;
12
- readonly addLiquidityEthSigHash: string;
13
- readonly removeLiquidityEthSigHash: string;
14
11
  readonly wethContract: string;
12
+ readonly abiInterface: ethers.utils.Interface;
13
+ readonly supportedFunctions: {
14
+ addLiquidityEthSigHash: string;
15
+ removeLiquidityEthSigHash: string;
16
+ };
15
17
  constructor(args: ParserArgs);
16
18
  parse(tx: BlockbookTx): Promise<TxSpecific | undefined>;
17
19
  private static pairFor;
18
- private getTransfers;
19
20
  }
20
- //# sourceMappingURL=uniV2.d.ts.map