@shapeshiftoss/unchained-client 6.11.0 → 6.12.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 +49 -57
  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
package/README.md CHANGED
@@ -5,11 +5,13 @@ Provides a typescript axios client to interact with all supported unchained API'
5
5
  ## Installing
6
6
 
7
7
  Using npm:
8
+
8
9
  ```
9
10
  npm install @shapeshiftoss/unchained-client
10
11
  ```
11
12
 
12
13
  Using yarn:
14
+
13
15
  ```
14
16
  yarn add @shapeshiftoss/unchained-client
15
17
  ```
@@ -51,4 +53,4 @@ await this.providers.ws.subscribeTxs(
51
53
  },
52
54
  (err) => console.warn(err)
53
55
  )
54
- ```
56
+ ```
@@ -1,4 +1,3 @@
1
1
  export * from '../generated/bitcoin';
2
2
  export * from './parser';
3
3
  export * from './types';
4
- //# 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];
@@ -13,4 +17,3 @@ Object.defineProperty(exports, "__esModule", { value: true });
13
17
  __exportStar(require("../generated/bitcoin"), exports);
14
18
  __exportStar(require("./parser"), exports);
15
19
  __exportStar(require("./types"), exports);
16
- //# sourceMappingURL=index.js.map
@@ -10,4 +10,3 @@ export declare class TransactionParser {
10
10
  constructor(args: TransactionParserArgs);
11
11
  parse(tx: BlockbookTx, address: string): Promise<ParsedTx>;
12
12
  }
13
- //# sourceMappingURL=index.d.ts.map
@@ -1,18 +1,9 @@
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
  Object.defineProperty(exports, "__esModule", { value: true });
12
3
  exports.TransactionParser = void 0;
13
- const bignumber_js_1 = require("bignumber.js");
14
4
  const caip_1 = require("@shapeshiftoss/caip");
15
5
  const types_1 = require("@shapeshiftoss/types");
6
+ const bignumber_js_1 = require("bignumber.js");
16
7
  const types_2 = require("../../types");
17
8
  const utils_1 = require("../../utils");
18
9
  const utils_2 = require("./utils");
@@ -21,54 +12,51 @@ class TransactionParser {
21
12
  var _a;
22
13
  this.network = (_a = args.network) !== null && _a !== void 0 ? _a : 'mainnet';
23
14
  }
24
- parse(tx, address) {
25
- return __awaiter(this, void 0, void 0, function* () {
26
- const caip19Bitcoin = caip_1.caip19.toCAIP19({
27
- chain: types_1.ChainTypes.Bitcoin,
28
- network: utils_2.toNetworkType(this.network),
29
- assetNamespace: caip_1.AssetNamespace.Slip44,
30
- assetReference: caip_1.AssetReference.Bitcoin,
31
- });
32
- const parsedTx = {
33
- address,
34
- blockHash: tx.blockHash,
35
- blockHeight: tx.blockHeight,
36
- blockTime: tx.blockTime,
37
- caip2: caip_1.caip2.toCAIP2({ chain: types_1.ChainTypes.Bitcoin, network: utils_2.toNetworkType(this.network) }),
38
- chainId: caip_1.caip2.toCAIP2({ chain: types_1.ChainTypes.Bitcoin, network: utils_2.toNetworkType(this.network) }),
39
- confirmations: tx.confirmations,
40
- status: tx.confirmations > 0 ? types_2.Status.Confirmed : types_2.Status.Pending,
41
- transfers: [],
42
- txid: tx.txid,
43
- };
44
- tx.vin.forEach((vin) => {
45
- var _a, _b, _c, _d, _e, _f, _g;
46
- if (vin.isAddress && ((_a = vin.addresses) === null || _a === void 0 ? void 0 : _a.includes(address))) {
47
- // send amount
48
- const sendValue = new bignumber_js_1.BigNumber((_b = vin.value) !== null && _b !== void 0 ? _b : 0);
49
- if (sendValue.gt(0)) {
50
- parsedTx.transfers = utils_1.aggregateTransfer(parsedTx.transfers, types_2.TransferType.Send, caip19Bitcoin, (_d = (_c = vin.addresses) === null || _c === void 0 ? void 0 : _c[0]) !== null && _d !== void 0 ? _d : '', (_f = (_e = tx.vout[0].addresses) === null || _e === void 0 ? void 0 : _e[0]) !== null && _f !== void 0 ? _f : '', sendValue.toString(10));
51
- }
52
- // network fee
53
- const fees = new bignumber_js_1.BigNumber((_g = tx.fees) !== null && _g !== void 0 ? _g : 0);
54
- if (fees.gt(0)) {
55
- parsedTx.fee = { caip19: caip19Bitcoin, assetId: caip19Bitcoin, value: fees.toString(10) };
56
- }
15
+ async parse(tx, address) {
16
+ const caip19Bitcoin = (0, caip_1.toCAIP19)({
17
+ chain: types_1.ChainTypes.Bitcoin,
18
+ network: (0, utils_2.toNetworkType)(this.network),
19
+ assetNamespace: caip_1.AssetNamespace.Slip44,
20
+ assetReference: caip_1.AssetReference.Bitcoin
21
+ });
22
+ const parsedTx = {
23
+ address,
24
+ blockHash: tx.blockHash,
25
+ blockHeight: tx.blockHeight,
26
+ blockTime: tx.blockTime,
27
+ caip2: (0, caip_1.toCAIP2)({ chain: types_1.ChainTypes.Bitcoin, network: (0, utils_2.toNetworkType)(this.network) }),
28
+ chainId: (0, caip_1.toCAIP2)({ chain: types_1.ChainTypes.Bitcoin, network: (0, utils_2.toNetworkType)(this.network) }),
29
+ confirmations: tx.confirmations,
30
+ status: tx.confirmations > 0 ? types_2.Status.Confirmed : types_2.Status.Pending,
31
+ transfers: [],
32
+ txid: tx.txid
33
+ };
34
+ tx.vin.forEach((vin) => {
35
+ var _a, _b, _c, _d, _e, _f, _g;
36
+ if (vin.isAddress && ((_a = vin.addresses) === null || _a === void 0 ? void 0 : _a.includes(address))) {
37
+ // send amount
38
+ const sendValue = new bignumber_js_1.BigNumber((_b = vin.value) !== null && _b !== void 0 ? _b : 0);
39
+ if (sendValue.gt(0)) {
40
+ parsedTx.transfers = (0, utils_1.aggregateTransfer)(parsedTx.transfers, types_2.TransferType.Send, caip19Bitcoin, (_d = (_c = vin.addresses) === null || _c === void 0 ? void 0 : _c[0]) !== null && _d !== void 0 ? _d : '', (_f = (_e = tx.vout[0].addresses) === null || _e === void 0 ? void 0 : _e[0]) !== null && _f !== void 0 ? _f : '', sendValue.toString(10));
57
41
  }
58
- });
59
- tx.vout.forEach((vout) => {
60
- var _a, _b, _c, _d, _e, _f;
61
- if (vout.isAddress && ((_a = vout.addresses) === null || _a === void 0 ? void 0 : _a.includes(address))) {
62
- // receive amount
63
- const receiveValue = new bignumber_js_1.BigNumber((_b = vout.value) !== null && _b !== void 0 ? _b : 0);
64
- if (receiveValue.gt(0)) {
65
- parsedTx.transfers = utils_1.aggregateTransfer(parsedTx.transfers, types_2.TransferType.Receive, caip19Bitcoin, (_d = (_c = tx.vin[0].addresses) === null || _c === void 0 ? void 0 : _c[0]) !== null && _d !== void 0 ? _d : '', (_f = (_e = vout.addresses) === null || _e === void 0 ? void 0 : _e[0]) !== null && _f !== void 0 ? _f : '', receiveValue.toString(10));
66
- }
42
+ // network fee
43
+ const fees = new bignumber_js_1.BigNumber((_g = tx.fees) !== null && _g !== void 0 ? _g : 0);
44
+ if (fees.gt(0)) {
45
+ parsedTx.fee = { caip19: caip19Bitcoin, assetId: caip19Bitcoin, value: fees.toString(10) };
46
+ }
47
+ }
48
+ });
49
+ tx.vout.forEach((vout) => {
50
+ var _a, _b, _c, _d, _e, _f;
51
+ if (vout.isAddress && ((_a = vout.addresses) === null || _a === void 0 ? void 0 : _a.includes(address))) {
52
+ // receive amount
53
+ const receiveValue = new bignumber_js_1.BigNumber((_b = vout.value) !== null && _b !== void 0 ? _b : 0);
54
+ if (receiveValue.gt(0)) {
55
+ parsedTx.transfers = (0, utils_1.aggregateTransfer)(parsedTx.transfers, types_2.TransferType.Receive, caip19Bitcoin, (_d = (_c = tx.vin[0].addresses) === null || _c === void 0 ? void 0 : _c[0]) !== null && _d !== void 0 ? _d : '', (_f = (_e = vout.addresses) === null || _e === void 0 ? void 0 : _e[0]) !== null && _f !== void 0 ? _f : '', receiveValue.toString(10));
67
56
  }
68
- });
69
- return parsedTx;
57
+ }
70
58
  });
59
+ return parsedTx;
71
60
  }
72
61
  }
73
62
  exports.TransactionParser = TransactionParser;
74
- //# sourceMappingURL=index.js.map
@@ -1,4 +1,3 @@
1
1
  import { NetworkTypes } from '@shapeshiftoss/types';
2
2
  import { Network } from '../types';
3
3
  export declare const toNetworkType: (network: Network) => NetworkTypes;
4
- //# sourceMappingURL=utils.d.ts.map
@@ -13,4 +13,3 @@ const toNetworkType = (network) => {
13
13
  }
14
14
  };
15
15
  exports.toNetworkType = toNetworkType;
16
- //# sourceMappingURL=utils.js.map
@@ -1,2 +1 @@
1
1
  export declare type Network = 'mainnet' | 'testnet';
2
- //# sourceMappingURL=types.d.ts.map
@@ -1,3 +1,2 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- //# sourceMappingURL=types.js.map
@@ -1,4 +1,3 @@
1
1
  export * from '../generated/cosmos';
2
2
  export * from './parser';
3
3
  export * from './types';
4
- //# 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];
@@ -13,4 +17,3 @@ Object.defineProperty(exports, "__esModule", { value: true });
13
17
  __exportStar(require("../generated/cosmos"), exports);
14
18
  __exportStar(require("./parser"), exports);
15
19
  __exportStar(require("./types"), exports);
16
- //# sourceMappingURL=index.js.map
@@ -1,4 +1,4 @@
1
- import { ChainId, AssetId } from '@shapeshiftoss/caip';
1
+ import { AssetId, ChainId } from '@shapeshiftoss/caip';
2
2
  import { Tx as CosmosTx } from '../index';
3
3
  import { ParsedTx } from '../types';
4
4
  export interface TransactionParserArgs {
@@ -10,4 +10,3 @@ export declare class TransactionParser {
10
10
  constructor(args: TransactionParserArgs);
11
11
  parse(tx: CosmosTx, address: string): Promise<ParsedTx>;
12
12
  }
13
- //# sourceMappingURL=index.d.ts.map
@@ -1,80 +1,72 @@
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
  Object.defineProperty(exports, "__esModule", { value: true });
12
3
  exports.TransactionParser = void 0;
13
- const bignumber_js_1 = require("bignumber.js");
14
4
  const caip_1 = require("@shapeshiftoss/caip");
5
+ const bignumber_js_1 = require("bignumber.js");
15
6
  const types_1 = require("../../types");
16
7
  const utils_1 = require("./utils");
17
8
  class TransactionParser {
18
9
  constructor(args) {
19
10
  this.chainId = args.chainId;
20
- this.assetId = caip_1.caip19.toCAIP19(Object.assign(Object.assign({}, caip_1.caip2.fromCAIP2(this.chainId)), { assetNamespace: caip_1.AssetNamespace.Slip44, assetReference: caip_1.AssetReference.Cosmos }));
11
+ this.assetId = (0, caip_1.toCAIP19)({
12
+ ...(0, caip_1.fromCAIP2)(this.chainId),
13
+ assetNamespace: caip_1.AssetNamespace.Slip44,
14
+ assetReference: caip_1.AssetReference.Cosmos
15
+ });
21
16
  }
22
- parse(tx, address) {
17
+ async parse(tx, address) {
23
18
  var _a, _b;
24
- return __awaiter(this, void 0, void 0, function* () {
25
- const parsedTx = {
26
- address,
27
- blockHash: tx.blockHash,
28
- blockHeight: (_a = tx.blockHeight) !== null && _a !== void 0 ? _a : -1,
29
- blockTime: (_b = tx.timestamp) !== null && _b !== void 0 ? _b : Math.floor(Date.now() / 1000),
30
- caip2: this.chainId,
31
- chainId: this.chainId,
32
- confirmations: tx.confirmations,
33
- status: tx.confirmations > 0 ? types_1.Status.Confirmed : types_1.Status.Pending,
34
- transfers: [],
35
- txid: tx.txid,
36
- };
37
- // For simplicity and to limit scope we assume 1 message per transaction
38
- // This works ok enough for transactions we generate but way may want to improve in the future
39
- const { from, to, data, value, origin } = utils_1.valuesFromMsgEvents(tx.messages[0], tx.events, this.assetId);
40
- parsedTx.data = data;
41
- if (from === address && value.gt(0)) {
42
- parsedTx.transfers = [
43
- {
44
- type: types_1.TransferType.Send,
45
- caip19: this.assetId,
46
- assetId: this.assetId,
47
- from,
48
- to,
49
- totalValue: value.toString(10),
50
- components: [{ value: value.toString(10) }],
51
- },
52
- ];
53
- }
54
- if (to === address && value.gt(0)) {
55
- parsedTx.transfers = [
56
- {
57
- type: types_1.TransferType.Receive,
58
- caip19: this.assetId,
59
- assetId: this.assetId,
60
- from,
61
- to,
62
- totalValue: value.toString(10),
63
- components: [{ value: value.toString(10) }],
64
- },
65
- ];
66
- }
67
- // We use origin for fees because some txs have a different from and origin addresses
68
- if (origin === address) {
69
- // network fee
70
- const fees = new bignumber_js_1.BigNumber(tx.fee.amount);
71
- if (fees.gt(0)) {
72
- parsedTx.fee = { caip19: this.assetId, assetId: this.assetId, value: fees.toString(10) };
19
+ const parsedTx = {
20
+ address,
21
+ blockHash: tx.blockHash,
22
+ blockHeight: (_a = tx.blockHeight) !== null && _a !== void 0 ? _a : -1,
23
+ blockTime: (_b = tx.timestamp) !== null && _b !== void 0 ? _b : Math.floor(Date.now() / 1000),
24
+ caip2: this.chainId,
25
+ chainId: this.chainId,
26
+ confirmations: tx.confirmations,
27
+ status: tx.confirmations > 0 ? types_1.Status.Confirmed : types_1.Status.Pending,
28
+ transfers: [],
29
+ txid: tx.txid
30
+ };
31
+ // For simplicity and to limit scope we assume 1 message per transaction
32
+ // This works ok enough for transactions we generate but way may want to improve in the future
33
+ const { from, to, data, value, origin } = (0, utils_1.valuesFromMsgEvents)(tx.messages[0], tx.events, this.assetId);
34
+ parsedTx.data = data;
35
+ if (from === address && value.gt(0)) {
36
+ parsedTx.transfers = [
37
+ {
38
+ type: types_1.TransferType.Send,
39
+ caip19: this.assetId,
40
+ assetId: this.assetId,
41
+ from,
42
+ to,
43
+ totalValue: value.toString(10),
44
+ components: [{ value: value.toString(10) }]
45
+ }
46
+ ];
47
+ }
48
+ if (to === address && value.gt(0)) {
49
+ parsedTx.transfers = [
50
+ {
51
+ type: types_1.TransferType.Receive,
52
+ caip19: this.assetId,
53
+ assetId: this.assetId,
54
+ from,
55
+ to,
56
+ totalValue: value.toString(10),
57
+ components: [{ value: value.toString(10) }]
73
58
  }
59
+ ];
60
+ }
61
+ // We use origin for fees because some txs have a different from and origin addresses
62
+ if (origin === address) {
63
+ // network fee
64
+ const fees = new bignumber_js_1.BigNumber(tx.fee.amount);
65
+ if (fees.gt(0)) {
66
+ parsedTx.fee = { caip19: this.assetId, assetId: this.assetId, value: fees.toString(10) };
74
67
  }
75
- return parsedTx;
76
- });
68
+ }
69
+ return parsedTx;
77
70
  }
78
71
  }
79
72
  exports.TransactionParser = TransactionParser;
80
- //# sourceMappingURL=index.js.map
@@ -1,6 +1,6 @@
1
- import { TxMetadata } from '../types';
2
- import { Event, Message } from '../../generated/cosmos';
3
1
  import BigNumber from 'bignumber.js';
2
+ import { Event, Message } from '../../generated/cosmos';
3
+ import { TxMetadata } from '../types';
4
4
  export declare const valuesFromMsgEvents: (msg: Message, events: {
5
5
  [key: string]: Event[];
6
6
  }, assetId: string) => {
@@ -10,4 +10,3 @@ export declare const valuesFromMsgEvents: (msg: Message, events: {
10
10
  data: TxMetadata | undefined;
11
11
  origin: string;
12
12
  };
13
- //# sourceMappingURL=utils.d.ts.map
@@ -8,19 +8,8 @@ const logger_1 = require("@shapeshiftoss/logger");
8
8
  const bignumber_js_1 = __importDefault(require("bignumber.js"));
9
9
  const logger = new logger_1.Logger({
10
10
  namespace: ['client', 'cosmos', 'utils'],
11
- level: process.env.LOG_LEVEL,
11
+ level: process.env.LOG_LEVEL
12
12
  });
13
- const valuesFromMsgEvents = (msg, events, assetId) => {
14
- var _a, _b, _c, _d;
15
- const virtualMsg = virtualMessageFromEvents(msg, events);
16
- const data = metaData(virtualMsg, assetId);
17
- const from = (_a = virtualMsg === null || virtualMsg === void 0 ? void 0 : virtualMsg.from) !== null && _a !== void 0 ? _a : '';
18
- const to = (_b = virtualMsg === null || virtualMsg === void 0 ? void 0 : virtualMsg.to) !== null && _b !== void 0 ? _b : '';
19
- const origin = (_c = virtualMsg === null || virtualMsg === void 0 ? void 0 : virtualMsg.origin) !== null && _c !== void 0 ? _c : '';
20
- const value = new bignumber_js_1.default(((_d = virtualMsg === null || virtualMsg === void 0 ? void 0 : virtualMsg.value) === null || _d === void 0 ? void 0 : _d.amount) || (data === null || data === void 0 ? void 0 : data.value) || 0);
21
- return { from, to, value, data, origin };
22
- };
23
- exports.valuesFromMsgEvents = valuesFromMsgEvents;
24
13
  const metaData = (msg, assetId) => {
25
14
  var _a, _b, _c, _d;
26
15
  if (!msg)
@@ -33,7 +22,7 @@ const metaData = (msg, assetId) => {
33
22
  method: msg.type,
34
23
  delegator: msg.from,
35
24
  destinationValidator: msg.to,
36
- value: (_a = msg === null || msg === void 0 ? void 0 : msg.value) === null || _a === void 0 ? void 0 : _a.amount,
25
+ value: (_a = msg === null || msg === void 0 ? void 0 : msg.value) === null || _a === void 0 ? void 0 : _a.amount
37
26
  };
38
27
  case 'begin_redelegate':
39
28
  return {
@@ -44,7 +33,7 @@ const metaData = (msg, assetId) => {
44
33
  destinationValidator: msg.to,
45
34
  value: (_b = msg === null || msg === void 0 ? void 0 : msg.value) === null || _b === void 0 ? void 0 : _b.amount,
46
35
  caip19: assetId,
47
- assetId: assetId,
36
+ assetId
48
37
  };
49
38
  case 'withdraw_delegator_reward':
50
39
  return {
@@ -53,7 +42,7 @@ const metaData = (msg, assetId) => {
53
42
  destinationValidator: msg.to,
54
43
  value: (_c = msg === null || msg === void 0 ? void 0 : msg.value) === null || _c === void 0 ? void 0 : _c.amount,
55
44
  caip19: assetId,
56
- assetId: assetId,
45
+ assetId
57
46
  };
58
47
  case 'ibc_send':
59
48
  case 'ibc_receive':
@@ -63,8 +52,8 @@ const metaData = (msg, assetId) => {
63
52
  ibcDestination: msg.to,
64
53
  ibcSource: msg.from,
65
54
  caip19: assetId,
66
- assetId: assetId,
67
- value: (_d = msg === null || msg === void 0 ? void 0 : msg.value) === null || _d === void 0 ? void 0 : _d.amount,
55
+ assetId,
56
+ value: (_d = msg === null || msg === void 0 ? void 0 : msg.value) === null || _d === void 0 ? void 0 : _d.amount
68
57
  };
69
58
  // known message types with no applicable metadata
70
59
  case 'send':
@@ -89,7 +78,7 @@ const virtualMessageFromEvents = (msg, events) => {
89
78
  value: { amount: parsedPacketData.amount, denom: parsedPacketData.amount },
90
79
  from: parsedPacketData.sender,
91
80
  to: parsedPacketData.receiver,
92
- origin: parsedPacketData.sender,
81
+ origin: parsedPacketData.sender
93
82
  };
94
83
  }
95
84
  else if (ibcRecvEventData) {
@@ -99,7 +88,7 @@ const virtualMessageFromEvents = (msg, events) => {
99
88
  value: { amount: parsedPacketData.amount, denom: parsedPacketData.amount },
100
89
  from: parsedPacketData.sender,
101
90
  to: parsedPacketData.receiver,
102
- origin: parsedPacketData.sender,
91
+ origin: parsedPacketData.sender
103
92
  };
104
93
  }
105
94
  else if (rewardEventData) {
@@ -110,13 +99,23 @@ const virtualMessageFromEvents = (msg, events) => {
110
99
  value: { amount: valueParsed !== null && valueParsed !== void 0 ? valueParsed : '', denom: 'uatom' },
111
100
  from: msg.from,
112
101
  to: msg.to,
113
- origin: msg.origin,
102
+ origin: msg.origin
114
103
  };
115
104
  }
116
105
  // no virtual message handled, but also no transaction message
117
106
  if (!msg) {
118
- console.warn(`no transaction message found and unable to create virtual message from events: ${events}`);
107
+ logger.warn(`no transaction message found and unable to create virtual message from events: ${events}`);
119
108
  }
120
109
  return msg;
121
110
  };
122
- //# sourceMappingURL=utils.js.map
111
+ const valuesFromMsgEvents = (msg, events, assetId) => {
112
+ var _a, _b, _c, _d;
113
+ const virtualMsg = virtualMessageFromEvents(msg, events);
114
+ const data = metaData(virtualMsg, assetId);
115
+ const from = (_a = virtualMsg === null || virtualMsg === void 0 ? void 0 : virtualMsg.from) !== null && _a !== void 0 ? _a : '';
116
+ const to = (_b = virtualMsg === null || virtualMsg === void 0 ? void 0 : virtualMsg.to) !== null && _b !== void 0 ? _b : '';
117
+ const origin = (_c = virtualMsg === null || virtualMsg === void 0 ? void 0 : virtualMsg.origin) !== null && _c !== void 0 ? _c : '';
118
+ const value = new bignumber_js_1.default(((_d = virtualMsg === null || virtualMsg === void 0 ? void 0 : virtualMsg.value) === null || _d === void 0 ? void 0 : _d.amount) || (data === null || data === void 0 ? void 0 : data.value) || 0);
119
+ return { from, to, value, data, origin };
120
+ };
121
+ exports.valuesFromMsgEvents = valuesFromMsgEvents;
@@ -16,4 +16,3 @@ export interface TxMetadata extends Omit<StandardTxMetadata, 'parser'> {
16
16
  export interface ParsedTx extends StandardTx {
17
17
  data?: TxMetadata;
18
18
  }
19
- //# sourceMappingURL=types.d.ts.map
@@ -1,3 +1,2 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- //# sourceMappingURL=types.js.map
@@ -1,4 +1,3 @@
1
1
  export * from '../generated/ethereum';
2
2
  export * from './parser';
3
3
  export * from './types';
4
- //# 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];
@@ -13,4 +17,3 @@ Object.defineProperty(exports, "__esModule", { value: true });
13
17
  __exportStar(require("../generated/ethereum"), exports);
14
18
  __exportStar(require("./parser"), exports);
15
19
  __exportStar(require("./types"), exports);
16
- //# sourceMappingURL=index.js.map
@@ -1,4 +1,3 @@
1
1
  import { JsonFragment } from '@ethersproject/abi/lib/fragments';
2
2
  declare const erc20: Array<JsonFragment>;
3
3
  export default erc20;
4
- //# sourceMappingURL=erc20.d.ts.map