@waves/node-api-js 1.3.10-beta.2 → 1.3.10

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 (165) hide show
  1. package/README.md +2 -2
  2. package/cjs/api-node/activation/index.d.ts +21 -21
  3. package/cjs/api-node/activation/index.js +19 -19
  4. package/cjs/api-node/addresses/index.d.ts +81 -81
  5. package/cjs/api-node/addresses/index.js +173 -173
  6. package/cjs/api-node/alias/index.d.ts +6 -6
  7. package/cjs/api-node/alias/index.js +21 -21
  8. package/cjs/api-node/assets/index.d.ts +79 -79
  9. package/cjs/api-node/assets/index.js +171 -171
  10. package/cjs/api-node/blocks/index.d.ts +143 -143
  11. package/cjs/api-node/blocks/index.js +209 -209
  12. package/cjs/api-node/debug/index.d.ts +189 -189
  13. package/cjs/api-node/debug/index.js +244 -244
  14. package/cjs/api-node/eth/index.d.ts +3 -3
  15. package/cjs/api-node/eth/index.js +14 -14
  16. package/cjs/api-node/leasing/index.d.ts +22 -22
  17. package/cjs/api-node/leasing/index.js +41 -41
  18. package/cjs/api-node/node/index.d.ts +11 -11
  19. package/cjs/api-node/node/index.js +19 -19
  20. package/cjs/api-node/peers/index.d.ts +46 -46
  21. package/cjs/api-node/peers/index.js +59 -59
  22. package/cjs/api-node/rewards/index.d.ts +21 -21
  23. package/cjs/api-node/rewards/index.js +20 -20
  24. package/cjs/api-node/transactions/index.d.ts +73 -73
  25. package/cjs/api-node/transactions/index.js +192 -192
  26. package/cjs/api-node/utils/index.d.ts +110 -110
  27. package/cjs/api-node/utils/index.js +210 -210
  28. package/cjs/api-node/wallet/index.d.ts +5 -5
  29. package/cjs/api-node/wallet/index.js +6 -6
  30. package/cjs/constants.d.ts +40 -40
  31. package/cjs/constants.js +42 -42
  32. package/cjs/create.d.ts +1238 -1238
  33. package/cjs/create.js +115 -115
  34. package/cjs/index.d.ts +9 -9
  35. package/cjs/index.js +17 -17
  36. package/cjs/interface.d.ts +44 -44
  37. package/cjs/interface.js +9 -9
  38. package/cjs/tools/adresses/availableSponsoredBalances.d.ts +7 -7
  39. package/cjs/tools/adresses/availableSponsoredBalances.js +29 -29
  40. package/cjs/tools/adresses/ethAddress2waves.d.ts +1 -1
  41. package/cjs/tools/adresses/ethAddress2waves.js +46 -46
  42. package/cjs/tools/adresses/getAssetIdListByTx.d.ts +2 -2
  43. package/cjs/tools/adresses/getAssetIdListByTx.js +47 -47
  44. package/cjs/tools/adresses/getAssetsByTransaction.d.ts +3 -3
  45. package/cjs/tools/adresses/getAssetsByTransaction.js +13 -13
  46. package/cjs/tools/adresses/getTransactionsWithAssets.d.ts +6 -6
  47. package/cjs/tools/adresses/getTransactionsWithAssets.js +12 -12
  48. package/cjs/tools/adresses/watch.d.ts +24 -24
  49. package/cjs/tools/adresses/watch.js +167 -167
  50. package/cjs/tools/adresses/wavesAddress2eth.d.ts +1 -1
  51. package/cjs/tools/adresses/wavesAddress2eth.js +9 -9
  52. package/cjs/tools/assets/wavesAsset2eth.d.ts +1 -1
  53. package/cjs/tools/assets/wavesAsset2eth.js +9 -9
  54. package/cjs/tools/blocks/detectInterval.d.ts +1 -1
  55. package/cjs/tools/blocks/detectInterval.js +11 -11
  56. package/cjs/tools/blocks/getNetworkByte.d.ts +1 -1
  57. package/cjs/tools/blocks/getNetworkByte.js +53 -53
  58. package/cjs/tools/blocks/getNetworkCode.d.ts +1 -1
  59. package/cjs/tools/blocks/getNetworkCode.js +10 -10
  60. package/cjs/tools/blocks/waitHeight.d.ts +3 -3
  61. package/cjs/tools/blocks/waitHeight.js +64 -64
  62. package/cjs/tools/parse.d.ts +1 -1
  63. package/cjs/tools/parse.js +7 -7
  64. package/cjs/tools/query.d.ts +4 -4
  65. package/cjs/tools/query.js +40 -40
  66. package/cjs/tools/request.d.ts +64 -64
  67. package/cjs/tools/request.js +41 -41
  68. package/cjs/tools/resolve.d.ts +1 -1
  69. package/cjs/tools/resolve.js +6 -6
  70. package/cjs/tools/stringify.d.ts +1 -1
  71. package/cjs/tools/stringify.js +20 -20
  72. package/cjs/tools/transactions/broadcast.d.ts +14 -14
  73. package/cjs/tools/transactions/broadcast.js +59 -59
  74. package/cjs/tools/transactions/ethTxId2waves.d.ts +1 -1
  75. package/cjs/tools/transactions/ethTxId2waves.js +10 -10
  76. package/cjs/tools/transactions/wait.d.ts +10 -10
  77. package/cjs/tools/transactions/wait.js +41 -41
  78. package/cjs/tools/utils.d.ts +32 -32
  79. package/cjs/tools/utils.js +117 -117
  80. package/dist/node-api.js +2371 -2371
  81. package/es/api-node/activation/index.d.ts +21 -21
  82. package/es/api-node/activation/index.js +12 -12
  83. package/es/api-node/addresses/index.d.ts +81 -81
  84. package/es/api-node/addresses/index.js +110 -110
  85. package/es/api-node/alias/index.d.ts +6 -6
  86. package/es/api-node/alias/index.js +13 -13
  87. package/es/api-node/assets/index.d.ts +79 -79
  88. package/es/api-node/assets/index.js +102 -102
  89. package/es/api-node/blocks/index.d.ts +143 -143
  90. package/es/api-node/blocks/index.js +178 -178
  91. package/es/api-node/debug/index.d.ts +189 -189
  92. package/es/api-node/debug/index.js +200 -200
  93. package/es/api-node/eth/index.d.ts +3 -3
  94. package/es/api-node/eth/index.js +7 -7
  95. package/es/api-node/leasing/index.d.ts +22 -22
  96. package/es/api-node/leasing/index.js +21 -21
  97. package/es/api-node/node/index.d.ts +11 -11
  98. package/es/api-node/node/index.js +9 -9
  99. package/es/api-node/peers/index.d.ts +46 -46
  100. package/es/api-node/peers/index.js +45 -45
  101. package/es/api-node/rewards/index.d.ts +21 -21
  102. package/es/api-node/rewards/index.js +12 -12
  103. package/es/api-node/transactions/index.d.ts +73 -73
  104. package/es/api-node/transactions/index.js +136 -136
  105. package/es/api-node/utils/index.d.ts +110 -110
  106. package/es/api-node/utils/index.js +192 -192
  107. package/es/api-node/wallet/index.d.ts +5 -5
  108. package/es/api-node/wallet/index.js +6 -6
  109. package/es/constants.d.ts +40 -40
  110. package/es/constants.js +39 -39
  111. package/es/create.d.ts +1238 -1238
  112. package/es/create.js +89 -89
  113. package/es/index.d.ts +9 -9
  114. package/es/index.js +8 -8
  115. package/es/interface.d.ts +44 -44
  116. package/es/interface.js +2 -2
  117. package/es/tools/adresses/availableSponsoredBalances.d.ts +7 -7
  118. package/es/tools/adresses/availableSponsoredBalances.js +26 -26
  119. package/es/tools/adresses/ethAddress2waves.d.ts +1 -1
  120. package/es/tools/adresses/ethAddress2waves.js +30 -30
  121. package/es/tools/adresses/getAssetIdListByTx.d.ts +2 -2
  122. package/es/tools/adresses/getAssetIdListByTx.js +23 -23
  123. package/es/tools/adresses/getAssetsByTransaction.d.ts +3 -3
  124. package/es/tools/adresses/getAssetsByTransaction.js +7 -7
  125. package/es/tools/adresses/getTransactionsWithAssets.d.ts +6 -6
  126. package/es/tools/adresses/getTransactionsWithAssets.js +6 -6
  127. package/es/tools/adresses/watch.d.ts +24 -24
  128. package/es/tools/adresses/watch.js +133 -133
  129. package/es/tools/adresses/wavesAddress2eth.d.ts +1 -1
  130. package/es/tools/adresses/wavesAddress2eth.js +6 -6
  131. package/es/tools/assets/wavesAsset2eth.d.ts +1 -1
  132. package/es/tools/assets/wavesAsset2eth.js +6 -6
  133. package/es/tools/blocks/detectInterval.d.ts +1 -1
  134. package/es/tools/blocks/detectInterval.js +8 -8
  135. package/es/tools/blocks/getNetworkByte.d.ts +1 -1
  136. package/es/tools/blocks/getNetworkByte.js +50 -50
  137. package/es/tools/blocks/getNetworkCode.d.ts +1 -1
  138. package/es/tools/blocks/getNetworkCode.js +4 -4
  139. package/es/tools/blocks/waitHeight.d.ts +3 -3
  140. package/es/tools/blocks/waitHeight.js +35 -35
  141. package/es/tools/parse.d.ts +1 -1
  142. package/es/tools/parse.js +4 -4
  143. package/es/tools/query.d.ts +4 -4
  144. package/es/tools/query.js +11 -11
  145. package/es/tools/request.d.ts +64 -64
  146. package/es/tools/request.js +21 -21
  147. package/es/tools/resolve.d.ts +1 -1
  148. package/es/tools/resolve.js +3 -3
  149. package/es/tools/stringify.d.ts +1 -1
  150. package/es/tools/stringify.js +17 -17
  151. package/es/tools/transactions/broadcast.d.ts +14 -14
  152. package/es/tools/transactions/broadcast.js +42 -42
  153. package/es/tools/transactions/ethTxId2waves.d.ts +1 -1
  154. package/es/tools/transactions/ethTxId2waves.js +7 -7
  155. package/es/tools/transactions/wait.d.ts +10 -10
  156. package/es/tools/transactions/wait.js +38 -38
  157. package/es/tools/utils.d.ts +32 -32
  158. package/es/tools/utils.js +72 -72
  159. package/package.json +66 -66
  160. package/cjs/api-node/consensus/index.d.ts +0 -39
  161. package/cjs/api-node/consensus/index.js +0 -37
  162. package/cjs/api-node/consensus/index.js.map +0 -1
  163. package/es/api-node/consensus/index.d.ts +0 -39
  164. package/es/api-node/consensus/index.js +0 -27
  165. package/es/api-node/consensus/index.js.map +0 -1
@@ -1,48 +1,48 @@
1
- "use strict";
2
- var __read = (this && this.__read) || function (o, n) {
3
- var m = typeof Symbol === "function" && o[Symbol.iterator];
4
- if (!m) return o;
5
- var i = m.call(o), r, ar = [], e;
6
- try {
7
- while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
8
- }
9
- catch (error) { e = { error: error }; }
10
- finally {
11
- try {
12
- if (r && !r.done && (m = i["return"])) m.call(i);
13
- }
14
- finally { if (e) throw e.error; }
15
- }
16
- return ar;
17
- };
18
- var __spread = (this && this.__spread) || function () {
19
- for (var ar = [], i = 0; i < arguments.length; i++) ar = ar.concat(__read(arguments[i]));
20
- return ar;
21
- };
22
- var _a;
23
- Object.defineProperty(exports, "__esModule", { value: true });
24
- var utils_1 = require("../utils");
25
- var constants_1 = require("../../constants");
26
- var getAssetIdList = utils_1.switchTransactionByType((_a = {},
27
- _a[constants_1.NAME_MAP.transfer] = function (tx) { return [tx.assetId, tx.feeAssetId]; },
28
- _a[constants_1.NAME_MAP.burn] = function (tx) { return [tx.assetId]; },
29
- _a[constants_1.NAME_MAP.reissue] = function (tx) { return [tx.assetId]; },
30
- _a[constants_1.NAME_MAP.exchange] = function (tx) { return Array.from(new Set([
31
- tx.order1.assetPair.amountAsset,
32
- tx.order1.assetPair.priceAsset,
33
- tx.order1.version === 3 ? tx.order1.matcherFeeAssetId : null,
34
- tx.order2.version === 3 ? tx.order2.matcherFeeAssetId : null
35
- ])); },
36
- _a[constants_1.NAME_MAP.massTransfer] = function (tx) { return [tx.assetId]; },
37
- _a[constants_1.NAME_MAP.setAssetScript] = function (tx) { return [tx.assetId]; },
38
- _a[constants_1.NAME_MAP.sponsorship] = function (tx) { return [tx.assetId]; },
39
- _a[constants_1.NAME_MAP.invoke] = function (tx) { return __spread((tx.payment || []).map(utils_1.prop('assetId')), [tx.feeAssetId]); },
40
- _a[constants_1.NAME_MAP.updateAsset] = function (tx) { return [tx.assetId]; },
41
- _a));
42
- function default_1(tx) {
43
- // @ts-ignore
44
- var idList = utils_1.toArray(tx).reduce(function (acc, tx) { return acc.concat(getAssetIdList(tx) || []); }, []).filter(function (x) { return x != null; });
45
- return idList;
46
- }
47
- exports.default = default_1;
1
+ "use strict";
2
+ var __read = (this && this.__read) || function (o, n) {
3
+ var m = typeof Symbol === "function" && o[Symbol.iterator];
4
+ if (!m) return o;
5
+ var i = m.call(o), r, ar = [], e;
6
+ try {
7
+ while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
8
+ }
9
+ catch (error) { e = { error: error }; }
10
+ finally {
11
+ try {
12
+ if (r && !r.done && (m = i["return"])) m.call(i);
13
+ }
14
+ finally { if (e) throw e.error; }
15
+ }
16
+ return ar;
17
+ };
18
+ var __spread = (this && this.__spread) || function () {
19
+ for (var ar = [], i = 0; i < arguments.length; i++) ar = ar.concat(__read(arguments[i]));
20
+ return ar;
21
+ };
22
+ var _a;
23
+ Object.defineProperty(exports, "__esModule", { value: true });
24
+ var utils_1 = require("../utils");
25
+ var constants_1 = require("../../constants");
26
+ var getAssetIdList = utils_1.switchTransactionByType((_a = {},
27
+ _a[constants_1.NAME_MAP.transfer] = function (tx) { return [tx.assetId, tx.feeAssetId]; },
28
+ _a[constants_1.NAME_MAP.burn] = function (tx) { return [tx.assetId]; },
29
+ _a[constants_1.NAME_MAP.reissue] = function (tx) { return [tx.assetId]; },
30
+ _a[constants_1.NAME_MAP.exchange] = function (tx) { return Array.from(new Set([
31
+ tx.order1.assetPair.amountAsset,
32
+ tx.order1.assetPair.priceAsset,
33
+ tx.order1.version === 3 ? tx.order1.matcherFeeAssetId : null,
34
+ tx.order2.version === 3 ? tx.order2.matcherFeeAssetId : null
35
+ ])); },
36
+ _a[constants_1.NAME_MAP.massTransfer] = function (tx) { return [tx.assetId]; },
37
+ _a[constants_1.NAME_MAP.setAssetScript] = function (tx) { return [tx.assetId]; },
38
+ _a[constants_1.NAME_MAP.sponsorship] = function (tx) { return [tx.assetId]; },
39
+ _a[constants_1.NAME_MAP.invoke] = function (tx) { return __spread((tx.payment || []).map(utils_1.prop('assetId')), [tx.feeAssetId]); },
40
+ _a[constants_1.NAME_MAP.updateAsset] = function (tx) { return [tx.assetId]; },
41
+ _a));
42
+ function default_1(tx) {
43
+ // @ts-ignore
44
+ var idList = utils_1.toArray(tx).reduce(function (acc, tx) { return acc.concat(getAssetIdList(tx) || []); }, []).filter(function (x) { return x != null; });
45
+ return idList;
46
+ }
47
+ exports.default = default_1;
48
48
  //# sourceMappingURL=getAssetIdListByTx.js.map
@@ -1,3 +1,3 @@
1
- import { TAssetDetails } from '../../api-node/assets';
2
- import { Transaction, TransactionFromNode } from '@waves/ts-types';
3
- export default function (base: string, tx: Array<Transaction> | Transaction | TransactionFromNode | TransactionFromNode[]): Promise<Record<string, TAssetDetails>>;
1
+ import { TAssetDetails } from '../../api-node/assets';
2
+ import { Transaction, TransactionFromNode } from '@waves/ts-types';
3
+ export default function (base: string, tx: Array<Transaction> | Transaction | TransactionFromNode | TransactionFromNode[]): Promise<Record<string, TAssetDetails>>;
@@ -1,14 +1,14 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- var assets_1 = require("../../api-node/assets");
7
- var getAssetIdListByTx_1 = __importDefault(require("./getAssetIdListByTx"));
8
- var utils_1 = require("../utils");
9
- function default_1(base, tx) {
10
- return assets_1.fetchDetails(base, getAssetIdListByTx_1.default(tx))
11
- .then(function (list) { return utils_1.indexBy(utils_1.prop('assetId'), list); });
12
- }
13
- exports.default = default_1;
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ var assets_1 = require("../../api-node/assets");
7
+ var getAssetIdListByTx_1 = __importDefault(require("./getAssetIdListByTx"));
8
+ var utils_1 = require("../utils");
9
+ function default_1(base, tx) {
10
+ return assets_1.fetchDetails(base, getAssetIdListByTx_1.default(tx))
11
+ .then(function (list) { return utils_1.indexBy(utils_1.prop('assetId'), list); });
12
+ }
13
+ exports.default = default_1;
14
14
  //# sourceMappingURL=getAssetsByTransaction.js.map
@@ -1,6 +1,6 @@
1
- import { TAssetDetails } from '../../api-node/assets';
2
- import { TransactionFromNode } from '@waves/ts-types';
3
- export default function (base: string, address: string, limit: number, after?: string): Promise<{
4
- transactions: Array<TransactionFromNode>;
5
- assets: Record<string, TAssetDetails>;
6
- }>;
1
+ import { TAssetDetails } from '../../api-node/assets';
2
+ import { TransactionFromNode } from '@waves/ts-types';
3
+ export default function (base: string, address: string, limit: number, after?: string): Promise<{
4
+ transactions: Array<TransactionFromNode>;
5
+ assets: Record<string, TAssetDetails>;
6
+ }>;
@@ -1,13 +1,13 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- var transactions_1 = require("../../api-node/transactions");
7
- var getAssetsByTransaction_1 = __importDefault(require("./getAssetsByTransaction"));
8
- function default_1(base, address, limit, after) {
9
- return transactions_1.fetchTransactions(base, address, limit, after)
10
- .then(function (transactions) { return getAssetsByTransaction_1.default(base, transactions).then(function (assets) { return ({ transactions: transactions, assets: assets }); }); });
11
- }
12
- exports.default = default_1;
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ var transactions_1 = require("../../api-node/transactions");
7
+ var getAssetsByTransaction_1 = __importDefault(require("./getAssetsByTransaction"));
8
+ function default_1(base, address, limit, after) {
9
+ return transactions_1.fetchTransactions(base, address, limit, after)
10
+ .then(function (transactions) { return getAssetsByTransaction_1.default(base, transactions).then(function (assets) { return ({ transactions: transactions, assets: assets }); }); });
11
+ }
12
+ exports.default = default_1;
13
13
  //# sourceMappingURL=getTransactionsWithAssets.js.map
@@ -1,24 +1,24 @@
1
- import { Transaction, WithApiMixin } from '@waves/ts-types';
2
- import { TLong } from '../../interface';
3
- import { EventEmitter } from 'typed-ts-events';
4
- export declare class Watch {
5
- readonly address: string;
6
- private readonly _base;
7
- private readonly _interval;
8
- private readonly _emitter;
9
- private _lastBlock;
10
- private _timer;
11
- constructor(base: string, address: string, tx: (Transaction<TLong> & WithApiMixin) | null, interval?: number);
12
- on<K extends keyof IEvents>(event: K, handler: EventEmitter.IHandler<IEvents[K], any>): void;
13
- once<K extends keyof IEvents>(event: K, handler: EventEmitter.IHandler<IEvents[K], any>): void;
14
- off(event?: keyof IEvents, handler?: EventEmitter.IHandler<IEvents[keyof IEvents], any>): void;
15
- private _run;
16
- private getTransactionsInHeight;
17
- private _addTimeout;
18
- private static _groupByHeight;
19
- private static _getTransactionsToDispatch;
20
- }
21
- export interface IEvents {
22
- 'change-state': Array<Transaction<TLong> & WithApiMixin>;
23
- }
24
- export default function (base: string, address: string, interval?: number): Promise<Watch>;
1
+ import { Transaction, WithApiMixin } from '@waves/ts-types';
2
+ import { TLong } from '../../interface';
3
+ import { EventEmitter } from 'typed-ts-events';
4
+ export declare class Watch {
5
+ readonly address: string;
6
+ private readonly _base;
7
+ private readonly _interval;
8
+ private readonly _emitter;
9
+ private _lastBlock;
10
+ private _timer;
11
+ constructor(base: string, address: string, tx: (Transaction<TLong> & WithApiMixin) | null, interval?: number);
12
+ on<K extends keyof IEvents>(event: K, handler: EventEmitter.IHandler<IEvents[K], any>): void;
13
+ once<K extends keyof IEvents>(event: K, handler: EventEmitter.IHandler<IEvents[K], any>): void;
14
+ off(event?: keyof IEvents, handler?: EventEmitter.IHandler<IEvents[keyof IEvents], any>): void;
15
+ private _run;
16
+ private getTransactionsInHeight;
17
+ private _addTimeout;
18
+ private static _groupByHeight;
19
+ private static _getTransactionsToDispatch;
20
+ }
21
+ export interface IEvents {
22
+ 'change-state': Array<Transaction<TLong> & WithApiMixin>;
23
+ }
24
+ export default function (base: string, address: string, interval?: number): Promise<Watch>;
@@ -1,168 +1,168 @@
1
- "use strict";
2
- var __read = (this && this.__read) || function (o, n) {
3
- var m = typeof Symbol === "function" && o[Symbol.iterator];
4
- if (!m) return o;
5
- var i = m.call(o), r, ar = [], e;
6
- try {
7
- while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
8
- }
9
- catch (error) { e = { error: error }; }
10
- finally {
11
- try {
12
- if (r && !r.done && (m = i["return"])) m.call(i);
13
- }
14
- finally { if (e) throw e.error; }
15
- }
16
- return ar;
17
- };
18
- var __spread = (this && this.__spread) || function () {
19
- for (var ar = [], i = 0; i < arguments.length; i++) ar = ar.concat(__read(arguments[i]));
20
- return ar;
21
- };
22
- Object.defineProperty(exports, "__esModule", { value: true });
23
- exports.Watch = void 0;
24
- var transactions_1 = require("../../api-node/transactions");
25
- var utils_1 = require("../utils");
26
- var typed_ts_events_1 = require("typed-ts-events");
27
- var Watch = /** @class */ (function () {
28
- function Watch(base, address, tx, interval) {
29
- this._emitter = new typed_ts_events_1.EventEmitter();
30
- this._timer = null;
31
- this.address = address;
32
- this._interval = interval || 1000;
33
- this._base = base;
34
- this._lastBlock = {
35
- lastId: (tx === null || tx === void 0 ? void 0 : tx.id) || '',
36
- height: (tx === null || tx === void 0 ? void 0 : tx.height) || 0,
37
- transactions: tx ? [tx] : []
38
- };
39
- this._addTimeout();
40
- }
41
- Watch.prototype.on = function (event, handler) {
42
- this._emitter.on(event, handler);
43
- };
44
- Watch.prototype.once = function (event, handler) {
45
- this._emitter.once(event, handler);
46
- };
47
- Watch.prototype.off = function (event, handler) {
48
- this._emitter.off(event, handler);
49
- };
50
- Watch.prototype._run = function () {
51
- var _this = this;
52
- if (this._timer) {
53
- clearTimeout(this._timer);
54
- }
55
- var onError = function () { return _this._addTimeout(); };
56
- transactions_1.fetchTransactions(this._base, this.address, 1)
57
- .then(function (_a) {
58
- var _b = __read(_a, 1), tx = _b[0];
59
- if (!tx) {
60
- _this._addTimeout();
61
- return null;
62
- }
63
- _this.getTransactionsInHeight(tx, 310)
64
- .then(function (list) {
65
- var _a;
66
- var hash = Watch._groupByHeight(list);
67
- var heightList = utils_1.keys(hash)
68
- .map(Number)
69
- .sort(function (a, b) { return b - a; });
70
- var _b = __read(heightList, 2), last = _b[0], prev = _b[1];
71
- if (!_this._lastBlock.height) {
72
- _this._lastBlock = {
73
- height: last,
74
- lastId: hash[prev] && hash[prev].length ? hash[prev][0].id : '',
75
- transactions: hash[last]
76
- };
77
- _this._emitter.trigger('change-state', list);
78
- }
79
- else {
80
- var wasDispatchHash = utils_1.indexBy(utils_1.prop('id'), _this._lastBlock.transactions);
81
- var toDispatch = Watch._getTransactionsToDispatch(__spread(hash[last], (hash[prev] || [])), wasDispatchHash, _this._lastBlock.lastId);
82
- if (_this._lastBlock.height !== last) {
83
- _this._lastBlock = {
84
- height: last,
85
- lastId: hash[prev] && hash[prev].length ? hash[prev][0].id : '',
86
- transactions: hash[last]
87
- };
88
- }
89
- else {
90
- (_a = _this._lastBlock.transactions).push.apply(_a, __spread(toDispatch));
91
- }
92
- if (toDispatch.length) {
93
- _this._emitter.trigger('change-state', toDispatch);
94
- }
95
- }
96
- _this._addTimeout();
97
- }, onError);
98
- })
99
- .catch(onError);
100
- };
101
- Watch.prototype.getTransactionsInHeight = function (from, limit) {
102
- var _this = this;
103
- var height = from.height;
104
- var loop = function (downloaded) {
105
- if (downloaded.length >= limit) {
106
- return Promise.resolve(downloaded);
107
- }
108
- return transactions_1.fetchTransactions(_this._base, _this.address, downloaded.length + 100).then(function (list) {
109
- if (downloaded.length === list.length) {
110
- return downloaded;
111
- }
112
- var hash = Watch._groupByHeight(list);
113
- var heightList = utils_1.keys(hash)
114
- .map(Number)
115
- .sort(function (a, b) { return b - a; });
116
- var _a = __read(heightList, 2), last = _a[0], prev = _a[1];
117
- if (last === height) {
118
- return prev ? __spread(hash[last], [hash[prev][0]]) : loop(list);
119
- }
120
- else {
121
- return loop(list);
122
- }
123
- });
124
- };
125
- return loop([from]);
126
- };
127
- Watch.prototype._addTimeout = function () {
128
- var _this = this;
129
- this._timer = setTimeout(function () {
130
- _this._run();
131
- }, this._interval);
132
- };
133
- Watch._groupByHeight = function (list) {
134
- return list.reduce(function (hash, tx) {
135
- if (!hash[tx.height]) {
136
- hash[tx.height] = [tx];
137
- }
138
- else {
139
- hash[tx.height].push(tx);
140
- }
141
- return hash;
142
- }, Object.create(null));
143
- };
144
- Watch._getTransactionsToDispatch = function (list, dispatched, lastId) {
145
- var result = [];
146
- for (var i = 0; i < list.length; i++) {
147
- var tx = list[i];
148
- if (tx.id === lastId) {
149
- break;
150
- }
151
- if (!dispatched[tx.id]) {
152
- result.push(tx);
153
- }
154
- }
155
- return result;
156
- };
157
- return Watch;
158
- }());
159
- exports.Watch = Watch;
160
- function default_1(base, address, interval) {
161
- return transactions_1.fetchTransactions(base, address, 1)
162
- .then(function (_a) {
163
- var _b = __read(_a, 1), tx = _b[0];
164
- return new Watch(base, address, tx, interval);
165
- });
166
- }
167
- exports.default = default_1;
1
+ "use strict";
2
+ var __read = (this && this.__read) || function (o, n) {
3
+ var m = typeof Symbol === "function" && o[Symbol.iterator];
4
+ if (!m) return o;
5
+ var i = m.call(o), r, ar = [], e;
6
+ try {
7
+ while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
8
+ }
9
+ catch (error) { e = { error: error }; }
10
+ finally {
11
+ try {
12
+ if (r && !r.done && (m = i["return"])) m.call(i);
13
+ }
14
+ finally { if (e) throw e.error; }
15
+ }
16
+ return ar;
17
+ };
18
+ var __spread = (this && this.__spread) || function () {
19
+ for (var ar = [], i = 0; i < arguments.length; i++) ar = ar.concat(__read(arguments[i]));
20
+ return ar;
21
+ };
22
+ Object.defineProperty(exports, "__esModule", { value: true });
23
+ exports.Watch = void 0;
24
+ var transactions_1 = require("../../api-node/transactions");
25
+ var utils_1 = require("../utils");
26
+ var typed_ts_events_1 = require("typed-ts-events");
27
+ var Watch = /** @class */ (function () {
28
+ function Watch(base, address, tx, interval) {
29
+ this._emitter = new typed_ts_events_1.EventEmitter();
30
+ this._timer = null;
31
+ this.address = address;
32
+ this._interval = interval || 1000;
33
+ this._base = base;
34
+ this._lastBlock = {
35
+ lastId: (tx === null || tx === void 0 ? void 0 : tx.id) || '',
36
+ height: (tx === null || tx === void 0 ? void 0 : tx.height) || 0,
37
+ transactions: tx ? [tx] : []
38
+ };
39
+ this._addTimeout();
40
+ }
41
+ Watch.prototype.on = function (event, handler) {
42
+ this._emitter.on(event, handler);
43
+ };
44
+ Watch.prototype.once = function (event, handler) {
45
+ this._emitter.once(event, handler);
46
+ };
47
+ Watch.prototype.off = function (event, handler) {
48
+ this._emitter.off(event, handler);
49
+ };
50
+ Watch.prototype._run = function () {
51
+ var _this = this;
52
+ if (this._timer) {
53
+ clearTimeout(this._timer);
54
+ }
55
+ var onError = function () { return _this._addTimeout(); };
56
+ transactions_1.fetchTransactions(this._base, this.address, 1)
57
+ .then(function (_a) {
58
+ var _b = __read(_a, 1), tx = _b[0];
59
+ if (!tx) {
60
+ _this._addTimeout();
61
+ return null;
62
+ }
63
+ _this.getTransactionsInHeight(tx, 310)
64
+ .then(function (list) {
65
+ var _a;
66
+ var hash = Watch._groupByHeight(list);
67
+ var heightList = utils_1.keys(hash)
68
+ .map(Number)
69
+ .sort(function (a, b) { return b - a; });
70
+ var _b = __read(heightList, 2), last = _b[0], prev = _b[1];
71
+ if (!_this._lastBlock.height) {
72
+ _this._lastBlock = {
73
+ height: last,
74
+ lastId: hash[prev] && hash[prev].length ? hash[prev][0].id : '',
75
+ transactions: hash[last]
76
+ };
77
+ _this._emitter.trigger('change-state', list);
78
+ }
79
+ else {
80
+ var wasDispatchHash = utils_1.indexBy(utils_1.prop('id'), _this._lastBlock.transactions);
81
+ var toDispatch = Watch._getTransactionsToDispatch(__spread(hash[last], (hash[prev] || [])), wasDispatchHash, _this._lastBlock.lastId);
82
+ if (_this._lastBlock.height !== last) {
83
+ _this._lastBlock = {
84
+ height: last,
85
+ lastId: hash[prev] && hash[prev].length ? hash[prev][0].id : '',
86
+ transactions: hash[last]
87
+ };
88
+ }
89
+ else {
90
+ (_a = _this._lastBlock.transactions).push.apply(_a, __spread(toDispatch));
91
+ }
92
+ if (toDispatch.length) {
93
+ _this._emitter.trigger('change-state', toDispatch);
94
+ }
95
+ }
96
+ _this._addTimeout();
97
+ }, onError);
98
+ })
99
+ .catch(onError);
100
+ };
101
+ Watch.prototype.getTransactionsInHeight = function (from, limit) {
102
+ var _this = this;
103
+ var height = from.height;
104
+ var loop = function (downloaded) {
105
+ if (downloaded.length >= limit) {
106
+ return Promise.resolve(downloaded);
107
+ }
108
+ return transactions_1.fetchTransactions(_this._base, _this.address, downloaded.length + 100).then(function (list) {
109
+ if (downloaded.length === list.length) {
110
+ return downloaded;
111
+ }
112
+ var hash = Watch._groupByHeight(list);
113
+ var heightList = utils_1.keys(hash)
114
+ .map(Number)
115
+ .sort(function (a, b) { return b - a; });
116
+ var _a = __read(heightList, 2), last = _a[0], prev = _a[1];
117
+ if (last === height) {
118
+ return prev ? __spread(hash[last], [hash[prev][0]]) : loop(list);
119
+ }
120
+ else {
121
+ return loop(list);
122
+ }
123
+ });
124
+ };
125
+ return loop([from]);
126
+ };
127
+ Watch.prototype._addTimeout = function () {
128
+ var _this = this;
129
+ this._timer = setTimeout(function () {
130
+ _this._run();
131
+ }, this._interval);
132
+ };
133
+ Watch._groupByHeight = function (list) {
134
+ return list.reduce(function (hash, tx) {
135
+ if (!hash[tx.height]) {
136
+ hash[tx.height] = [tx];
137
+ }
138
+ else {
139
+ hash[tx.height].push(tx);
140
+ }
141
+ return hash;
142
+ }, Object.create(null));
143
+ };
144
+ Watch._getTransactionsToDispatch = function (list, dispatched, lastId) {
145
+ var result = [];
146
+ for (var i = 0; i < list.length; i++) {
147
+ var tx = list[i];
148
+ if (tx.id === lastId) {
149
+ break;
150
+ }
151
+ if (!dispatched[tx.id]) {
152
+ result.push(tx);
153
+ }
154
+ }
155
+ return result;
156
+ };
157
+ return Watch;
158
+ }());
159
+ exports.Watch = Watch;
160
+ function default_1(base, address, interval) {
161
+ return transactions_1.fetchTransactions(base, address, 1)
162
+ .then(function (_a) {
163
+ var _b = __read(_a, 1), tx = _b[0];
164
+ return new Watch(base, address, tx, interval);
165
+ });
166
+ }
167
+ exports.default = default_1;
168
168
  //# sourceMappingURL=watch.js.map
@@ -1 +1 @@
1
- export default function wavesAddress2eth(wavesAddress: string): string;
1
+ export default function wavesAddress2eth(wavesAddress: string): string;
@@ -1,10 +1,10 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- var ts_lib_crypto_1 = require("@waves/ts-lib-crypto");
4
- function wavesAddress2eth(wavesAddress) {
5
- var rawBytes = ts_lib_crypto_1.base58Decode(wavesAddress);
6
- var bytes = rawBytes.slice(2, rawBytes.byteLength - 4);
7
- return "0x" + ts_lib_crypto_1.base16Encode(bytes);
8
- }
9
- exports.default = wavesAddress2eth;
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ var ts_lib_crypto_1 = require("@waves/ts-lib-crypto");
4
+ function wavesAddress2eth(wavesAddress) {
5
+ var rawBytes = ts_lib_crypto_1.base58Decode(wavesAddress);
6
+ var bytes = rawBytes.slice(2, rawBytes.byteLength - 4);
7
+ return "0x" + ts_lib_crypto_1.base16Encode(bytes);
8
+ }
9
+ exports.default = wavesAddress2eth;
10
10
  //# sourceMappingURL=wavesAddress2eth.js.map
@@ -1 +1 @@
1
- export default function wavesAsset2Eth(wavesAsset: string): string;
1
+ export default function wavesAsset2Eth(wavesAsset: string): string;
@@ -1,10 +1,10 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- var ts_lib_crypto_1 = require("@waves/ts-lib-crypto");
4
- function wavesAsset2Eth(wavesAsset) {
5
- var rawBytes = ts_lib_crypto_1.base58Decode(wavesAsset);
6
- var bytes = rawBytes.slice(0, 20);
7
- return "0x" + ts_lib_crypto_1.base16Encode(bytes);
8
- }
9
- exports.default = wavesAsset2Eth;
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ var ts_lib_crypto_1 = require("@waves/ts-lib-crypto");
4
+ function wavesAsset2Eth(wavesAsset) {
5
+ var rawBytes = ts_lib_crypto_1.base58Decode(wavesAsset);
6
+ var bytes = rawBytes.slice(0, 20);
7
+ return "0x" + ts_lib_crypto_1.base16Encode(bytes);
8
+ }
9
+ exports.default = wavesAsset2Eth;
10
10
  //# sourceMappingURL=wavesAsset2eth.js.map
@@ -1 +1 @@
1
- export default function (base: string): Promise<number>;
1
+ export default function (base: string): Promise<number>;
@@ -1,12 +1,12 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- var blocks_1 = require("../../api-node/blocks");
4
- function default_1(base) {
5
- return blocks_1.fetchHeadersLast(base).then(function (header) {
6
- var firstHeight = Math.max(2, header.height - 1000);
7
- return blocks_1.fetchHeadersAt(base, firstHeight)
8
- .then(function (oldHeader) { return Math.floor((header.timestamp - oldHeader.timestamp) / (header.height - firstHeight)); });
9
- });
10
- }
11
- exports.default = default_1;
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ var blocks_1 = require("../../api-node/blocks");
4
+ function default_1(base) {
5
+ return blocks_1.fetchHeadersLast(base).then(function (header) {
6
+ var firstHeight = Math.max(2, header.height - 1000);
7
+ return blocks_1.fetchHeadersAt(base, firstHeight)
8
+ .then(function (oldHeader) { return Math.floor((header.timestamp - oldHeader.timestamp) / (header.height - firstHeight)); });
9
+ });
10
+ }
11
+ exports.default = default_1;
12
12
  //# sourceMappingURL=detectInterval.js.map
@@ -1 +1 @@
1
- export default function (base: string): Promise<number>;
1
+ export default function (base: string): Promise<number>;