@waves/node-api-js 1.3.0 → 1.3.10-beta.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 (178) 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/addresses/index.js.map +1 -1
  7. package/cjs/api-node/alias/index.d.ts +6 -6
  8. package/cjs/api-node/alias/index.js +21 -21
  9. package/cjs/api-node/assets/index.d.ts +79 -79
  10. package/cjs/api-node/assets/index.js +171 -171
  11. package/cjs/api-node/blocks/index.d.ts +143 -131
  12. package/cjs/api-node/blocks/index.js +209 -209
  13. package/cjs/api-node/consensus/index.d.ts +39 -39
  14. package/cjs/api-node/consensus/index.js +36 -36
  15. package/cjs/api-node/debug/index.d.ts +189 -189
  16. package/cjs/api-node/debug/index.js +244 -244
  17. package/cjs/api-node/eth/index.d.ts +3 -3
  18. package/cjs/api-node/eth/index.js +14 -14
  19. package/cjs/api-node/leasing/index.d.ts +22 -22
  20. package/cjs/api-node/leasing/index.js +41 -41
  21. package/cjs/api-node/node/index.d.ts +11 -11
  22. package/cjs/api-node/node/index.js +19 -19
  23. package/cjs/api-node/peers/index.d.ts +46 -46
  24. package/cjs/api-node/peers/index.js +59 -59
  25. package/cjs/api-node/rewards/index.d.ts +21 -21
  26. package/cjs/api-node/rewards/index.js +20 -20
  27. package/cjs/api-node/transactions/index.d.ts +73 -73
  28. package/cjs/api-node/transactions/index.js +192 -192
  29. package/cjs/api-node/utils/index.d.ts +110 -110
  30. package/cjs/api-node/utils/index.js +210 -210
  31. package/cjs/api-node/wallet/index.d.ts +5 -5
  32. package/cjs/api-node/wallet/index.js +6 -6
  33. package/cjs/constants.d.ts +40 -40
  34. package/cjs/constants.js +42 -42
  35. package/cjs/create.d.ts +1238 -1240
  36. package/cjs/create.js +115 -118
  37. package/cjs/create.js.map +1 -1
  38. package/cjs/index.d.ts +9 -9
  39. package/cjs/index.js +17 -17
  40. package/cjs/interface.d.ts +44 -44
  41. package/cjs/interface.js +9 -9
  42. package/cjs/tools/adresses/availableSponsoredBalances.d.ts +7 -7
  43. package/cjs/tools/adresses/availableSponsoredBalances.js +29 -29
  44. package/cjs/tools/adresses/ethAddress2waves.d.ts +1 -1
  45. package/cjs/tools/adresses/ethAddress2waves.js +46 -46
  46. package/cjs/tools/adresses/getAssetIdListByTx.d.ts +2 -2
  47. package/cjs/tools/adresses/getAssetIdListByTx.js +47 -47
  48. package/cjs/tools/adresses/getAssetsByTransaction.d.ts +3 -3
  49. package/cjs/tools/adresses/getAssetsByTransaction.js +13 -13
  50. package/cjs/tools/adresses/getTransactionsWithAssets.d.ts +6 -6
  51. package/cjs/tools/adresses/getTransactionsWithAssets.js +12 -12
  52. package/cjs/tools/adresses/watch.d.ts +24 -24
  53. package/cjs/tools/adresses/watch.js +167 -167
  54. package/cjs/tools/adresses/wavesAddress2eth.d.ts +1 -1
  55. package/cjs/tools/adresses/wavesAddress2eth.js +9 -9
  56. package/cjs/tools/assets/wavesAsset2eth.d.ts +1 -1
  57. package/cjs/tools/assets/wavesAsset2eth.js +9 -9
  58. package/cjs/tools/blocks/detectInterval.d.ts +1 -1
  59. package/cjs/tools/blocks/detectInterval.js +11 -11
  60. package/cjs/tools/blocks/getNetworkByte.d.ts +1 -1
  61. package/cjs/tools/blocks/getNetworkByte.js +53 -53
  62. package/cjs/tools/blocks/getNetworkCode.d.ts +1 -1
  63. package/cjs/tools/blocks/getNetworkCode.js +10 -10
  64. package/cjs/tools/blocks/waitHeight.d.ts +3 -3
  65. package/cjs/tools/blocks/waitHeight.js +64 -64
  66. package/cjs/tools/parse.d.ts +1 -1
  67. package/cjs/tools/parse.js +7 -7
  68. package/cjs/tools/query.d.ts +4 -4
  69. package/cjs/tools/query.js +40 -40
  70. package/cjs/tools/request.d.ts +64 -64
  71. package/cjs/tools/request.js +41 -41
  72. package/cjs/tools/resolve.d.ts +1 -1
  73. package/cjs/tools/resolve.js +6 -6
  74. package/cjs/tools/stringify.d.ts +1 -1
  75. package/cjs/tools/stringify.js +20 -20
  76. package/cjs/tools/transactions/broadcast.d.ts +14 -14
  77. package/cjs/tools/transactions/broadcast.js +59 -59
  78. package/cjs/tools/transactions/ethTxId2waves.d.ts +1 -1
  79. package/cjs/tools/transactions/ethTxId2waves.js +10 -10
  80. package/cjs/tools/transactions/wait.d.ts +10 -10
  81. package/cjs/tools/transactions/wait.js +41 -41
  82. package/cjs/tools/utils.d.ts +32 -32
  83. package/cjs/tools/utils.js +117 -117
  84. package/dist/node-api.js +2368 -2420
  85. package/dist/node-api.min.js +2 -2
  86. package/es/api-node/activation/index.d.ts +21 -21
  87. package/es/api-node/activation/index.js +12 -12
  88. package/es/api-node/addresses/index.d.ts +81 -81
  89. package/es/api-node/addresses/index.js +110 -110
  90. package/es/api-node/addresses/index.js.map +1 -1
  91. package/es/api-node/alias/index.d.ts +6 -6
  92. package/es/api-node/alias/index.js +13 -13
  93. package/es/api-node/assets/index.d.ts +79 -79
  94. package/es/api-node/assets/index.js +102 -102
  95. package/es/api-node/blocks/index.d.ts +143 -131
  96. package/es/api-node/blocks/index.js +178 -178
  97. package/es/api-node/consensus/index.d.ts +39 -39
  98. package/es/api-node/consensus/index.js +26 -26
  99. package/es/api-node/debug/index.d.ts +189 -189
  100. package/es/api-node/debug/index.js +200 -200
  101. package/es/api-node/eth/index.d.ts +3 -3
  102. package/es/api-node/eth/index.js +7 -7
  103. package/es/api-node/leasing/index.d.ts +22 -22
  104. package/es/api-node/leasing/index.js +21 -21
  105. package/es/api-node/node/index.d.ts +11 -11
  106. package/es/api-node/node/index.js +9 -9
  107. package/es/api-node/peers/index.d.ts +46 -46
  108. package/es/api-node/peers/index.js +45 -45
  109. package/es/api-node/rewards/index.d.ts +21 -21
  110. package/es/api-node/rewards/index.js +12 -12
  111. package/es/api-node/transactions/index.d.ts +73 -73
  112. package/es/api-node/transactions/index.js +136 -136
  113. package/es/api-node/utils/index.d.ts +110 -110
  114. package/es/api-node/utils/index.js +192 -192
  115. package/es/api-node/wallet/index.d.ts +5 -5
  116. package/es/api-node/wallet/index.js +6 -6
  117. package/es/constants.d.ts +40 -40
  118. package/es/constants.js +39 -39
  119. package/es/create.d.ts +1238 -1240
  120. package/es/create.js +89 -92
  121. package/es/create.js.map +1 -1
  122. package/es/index.d.ts +9 -9
  123. package/es/index.js +8 -8
  124. package/es/interface.d.ts +44 -44
  125. package/es/interface.js +2 -2
  126. package/es/tools/adresses/availableSponsoredBalances.d.ts +7 -7
  127. package/es/tools/adresses/availableSponsoredBalances.js +26 -26
  128. package/es/tools/adresses/ethAddress2waves.d.ts +1 -1
  129. package/es/tools/adresses/ethAddress2waves.js +30 -30
  130. package/es/tools/adresses/getAssetIdListByTx.d.ts +2 -2
  131. package/es/tools/adresses/getAssetIdListByTx.js +23 -23
  132. package/es/tools/adresses/getAssetsByTransaction.d.ts +3 -3
  133. package/es/tools/adresses/getAssetsByTransaction.js +7 -7
  134. package/es/tools/adresses/getTransactionsWithAssets.d.ts +6 -6
  135. package/es/tools/adresses/getTransactionsWithAssets.js +6 -6
  136. package/es/tools/adresses/watch.d.ts +24 -24
  137. package/es/tools/adresses/watch.js +133 -133
  138. package/es/tools/adresses/wavesAddress2eth.d.ts +1 -1
  139. package/es/tools/adresses/wavesAddress2eth.js +6 -6
  140. package/es/tools/assets/wavesAsset2eth.d.ts +1 -1
  141. package/es/tools/assets/wavesAsset2eth.js +6 -6
  142. package/es/tools/blocks/detectInterval.d.ts +1 -1
  143. package/es/tools/blocks/detectInterval.js +8 -8
  144. package/es/tools/blocks/getNetworkByte.d.ts +1 -1
  145. package/es/tools/blocks/getNetworkByte.js +50 -50
  146. package/es/tools/blocks/getNetworkCode.d.ts +1 -1
  147. package/es/tools/blocks/getNetworkCode.js +4 -4
  148. package/es/tools/blocks/waitHeight.d.ts +3 -3
  149. package/es/tools/blocks/waitHeight.js +35 -35
  150. package/es/tools/parse.d.ts +1 -1
  151. package/es/tools/parse.js +4 -4
  152. package/es/tools/query.d.ts +4 -4
  153. package/es/tools/query.js +11 -11
  154. package/es/tools/request.d.ts +64 -64
  155. package/es/tools/request.js +21 -21
  156. package/es/tools/resolve.d.ts +1 -1
  157. package/es/tools/resolve.js +3 -3
  158. package/es/tools/stringify.d.ts +1 -1
  159. package/es/tools/stringify.js +17 -17
  160. package/es/tools/transactions/broadcast.d.ts +14 -14
  161. package/es/tools/transactions/broadcast.js +42 -42
  162. package/es/tools/transactions/ethTxId2waves.d.ts +1 -1
  163. package/es/tools/transactions/ethTxId2waves.js +7 -7
  164. package/es/tools/transactions/wait.d.ts +10 -10
  165. package/es/tools/transactions/wait.js +38 -38
  166. package/es/tools/utils.d.ts +32 -32
  167. package/es/tools/utils.js +72 -72
  168. package/package.json +66 -66
  169. package/cjs/tools/transactions/transactions.d.ts +0 -0
  170. package/cjs/tools/transactions/transactions.js +0 -2
  171. package/cjs/tools/transactions/transactions.js.map +0 -1
  172. package/dist/0.node-api.js +0 -467
  173. package/dist/node-api.min.js.LICENSE.txt +0 -17
  174. package/dist/node_fs-node_path.node-api.js +0 -23
  175. package/dist/vendors-node_modules_node-fetch_src_utils_multipart-parser_js.node-api.js +0 -599
  176. package/es/tools/transactions/transactions.d.ts +0 -0
  177. package/es/tools/transactions/transactions.js +0 -2
  178. package/es/tools/transactions/transactions.js.map +0 -1
@@ -1,79 +1,79 @@
1
- import { TLong } from '../../interface';
2
- import { AssetDecimals, IssueTransaction, SignedTransaction, WithApiMixin } from '@waves/ts-types';
3
- /**
4
- * GET /assets/details/{assetId}
5
- * Information about an asset
6
- */
7
- export declare function fetchDetails(base: string, assetId: string, options?: RequestInit): Promise<TAssetDetails>;
8
- export declare function fetchDetails(base: string, assetId: Array<string>, options?: RequestInit): Promise<Array<TAssetDetails>>;
9
- /**
10
- * POST /assets/details
11
- * Provides detailed information about the given assets
12
- */
13
- export declare function fetchAssetsDetails(base: string, assetIds: Array<string>, options?: RequestInit): Promise<Array<TAssetDetails | TErrorResponse>>;
14
- export declare function fetchAssetDistribution(base: string, assetId: string, height: number, limit: number, options?: RequestInit): Promise<IAssetDistribution>;
15
- /**
16
- * TODO
17
- * GET /assets/{assetId}/distribution
18
- * Asset balance distribution
19
- */
20
- export declare function fetchAssetsAddressLimit(base: string, address: string, limit: number, options?: RequestInit): Promise<Array<TAssetDetails>>;
21
- /**
22
- * TODO
23
- * GET assets/nft/${address}/limit/${limit}
24
- * Asset balance distribution
25
- */
26
- interface IFetchAssetsNftParams {
27
- address: string;
28
- limit: number;
29
- after?: string;
30
- }
31
- export declare function fetchAssetsNft(base: string, { address, limit, after }: IFetchAssetsNftParams, options?: RequestInit): Promise<Array<TAssetDetails>>;
32
- export declare function fetchAssetsBalance(base: string, address: string, options?: RequestInit): Promise<TAssetsBalance>;
33
- export declare function fetchBalanceAddressAssetId(base: string, address: string, assetId: string, options?: RequestInit): Promise<IBalanceAddressAssetId>;
34
- export declare function convertEthAssetId(base: string, assetId: string): Promise<string>;
35
- export interface IAssetDistribution {
36
- hasNext: boolean;
37
- lastItem: string | null;
38
- items: Record<string, number>;
39
- }
40
- export interface IBalanceAddressAssetId<LONG = TLong> {
41
- address: string;
42
- assetId: string;
43
- balance: LONG;
44
- }
45
- export declare type TAssetsBalance = {
46
- 'address': string;
47
- 'balances': Array<TAssetBalance>;
48
- };
49
- export declare type TAssetBalance<LONG = TLong> = {
50
- 'assetId': string;
51
- 'balance': LONG;
52
- 'reissuable': true;
53
- 'minSponsoredAssetFee': LONG | null;
54
- 'sponsorBalance': LONG | null;
55
- 'quantity': LONG;
56
- 'issueTransaction': SignedTransaction<IssueTransaction & WithApiMixin> & {
57
- feeAssetId: null;
58
- };
59
- };
60
- export declare type TAssetDetails<LONG = TLong> = {
61
- assetId: string;
62
- issueHeight: number;
63
- issueTimestamp: number;
64
- issuer: string;
65
- issuerPublicKey: string;
66
- name: string;
67
- description: string;
68
- decimals: AssetDecimals;
69
- reissuable: boolean;
70
- quantity: LONG;
71
- scripted: boolean;
72
- minSponsoredAssetFee: LONG | null;
73
- originTransactionId: string;
74
- };
75
- export declare type TErrorResponse = {
76
- error: number;
77
- message: string;
78
- };
79
- export {};
1
+ import { TLong } from '../../interface';
2
+ import { AssetDecimals, IssueTransaction, SignedTransaction, WithApiMixin } from '@waves/ts-types';
3
+ /**
4
+ * GET /assets/details/{assetId}
5
+ * Information about an asset
6
+ */
7
+ export declare function fetchDetails(base: string, assetId: string, options?: RequestInit): Promise<TAssetDetails>;
8
+ export declare function fetchDetails(base: string, assetId: Array<string>, options?: RequestInit): Promise<Array<TAssetDetails>>;
9
+ /**
10
+ * POST /assets/details
11
+ * Provides detailed information about the given assets
12
+ */
13
+ export declare function fetchAssetsDetails(base: string, assetIds: Array<string>, options?: RequestInit): Promise<Array<TAssetDetails | TErrorResponse>>;
14
+ export declare function fetchAssetDistribution(base: string, assetId: string, height: number, limit: number, options?: RequestInit): Promise<IAssetDistribution>;
15
+ /**
16
+ * TODO
17
+ * GET /assets/{assetId}/distribution
18
+ * Asset balance distribution
19
+ */
20
+ export declare function fetchAssetsAddressLimit(base: string, address: string, limit: number, options?: RequestInit): Promise<Array<TAssetDetails>>;
21
+ /**
22
+ * TODO
23
+ * GET assets/nft/${address}/limit/${limit}
24
+ * Asset balance distribution
25
+ */
26
+ interface IFetchAssetsNftParams {
27
+ address: string;
28
+ limit: number;
29
+ after?: string;
30
+ }
31
+ export declare function fetchAssetsNft(base: string, { address, limit, after }: IFetchAssetsNftParams, options?: RequestInit): Promise<Array<TAssetDetails>>;
32
+ export declare function fetchAssetsBalance(base: string, address: string, options?: RequestInit): Promise<TAssetsBalance>;
33
+ export declare function fetchBalanceAddressAssetId(base: string, address: string, assetId: string, options?: RequestInit): Promise<IBalanceAddressAssetId>;
34
+ export declare function convertEthAssetId(base: string, assetId: string): Promise<string>;
35
+ export interface IAssetDistribution {
36
+ hasNext: boolean;
37
+ lastItem: string | null;
38
+ items: Record<string, number>;
39
+ }
40
+ export interface IBalanceAddressAssetId<LONG = TLong> {
41
+ address: string;
42
+ assetId: string;
43
+ balance: LONG;
44
+ }
45
+ export declare type TAssetsBalance = {
46
+ 'address': string;
47
+ 'balances': Array<TAssetBalance>;
48
+ };
49
+ export declare type TAssetBalance<LONG = TLong> = {
50
+ 'assetId': string;
51
+ 'balance': LONG;
52
+ 'reissuable': true;
53
+ 'minSponsoredAssetFee': LONG | null;
54
+ 'sponsorBalance': LONG | null;
55
+ 'quantity': LONG;
56
+ 'issueTransaction': SignedTransaction<IssueTransaction & WithApiMixin> & {
57
+ feeAssetId: null;
58
+ };
59
+ };
60
+ export declare type TAssetDetails<LONG = TLong> = {
61
+ assetId: string;
62
+ issueHeight: number;
63
+ issueTimestamp: number;
64
+ issuer: string;
65
+ issuerPublicKey: string;
66
+ name: string;
67
+ description: string;
68
+ decimals: AssetDecimals;
69
+ reissuable: boolean;
70
+ quantity: LONG;
71
+ scripted: boolean;
72
+ minSponsoredAssetFee: LONG | null;
73
+ originTransactionId: string;
74
+ };
75
+ export declare type TErrorResponse = {
76
+ error: number;
77
+ message: string;
78
+ };
79
+ export {};
@@ -1,103 +1,103 @@
1
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
- return new (P || (P = Promise))(function (resolve, reject) {
4
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
- step((generator = generator.apply(thisArg, _arguments || [])).next());
8
- });
9
- };
10
- import { TRANSACTION_TYPE } from '@waves/ts-types';
11
- import request from '../../tools/request';
12
- import { toArray } from '../../tools/utils';
13
- import query from "../../tools/query";
14
- export function fetchDetails(base, assetId, options = Object.create(null)) {
15
- const isOnce = !Array.isArray(assetId);
16
- return Promise.all(toArray(assetId).map(id => request({
17
- base,
18
- url: `/assets/details/${id}`,
19
- options
20
- })))
21
- .then(list => isOnce ? list[0] : list);
22
- }
23
- /**
24
- * POST /assets/details
25
- * Provides detailed information about the given assets
26
- */
27
- export function fetchAssetsDetails(base, assetIds, options = Object.create(null)) {
28
- const body = JSON.stringify({ ids: assetIds });
29
- const _options = Object.assign(Object.assign({}, options), { body, headers: {
30
- 'content-type': 'application/json'
31
- }, method: 'POST' });
32
- return request({ base, url: `/assets/details`, options: _options });
33
- }
34
- export function fetchAssetDistribution(base, assetId, height, limit, options = Object.create(null)) {
35
- return request({ base, url: `/assets/${assetId}/distribution/${height}/limit/${limit}`, options });
36
- }
37
- /**
38
- * TODO
39
- * GET /assets/{assetId}/distribution
40
- * Asset balance distribution
41
- */
42
- export function fetchAssetsAddressLimit(base, address, limit, options = Object.create(null)) {
43
- return request({ base, url: `assets/nft/${address}/limit/${limit}`, options });
44
- }
45
- export function fetchAssetsNft(base, { address, limit, after }, options = Object.create(null)) {
46
- const url = new URL(`assets/nft/${address}/limit/${limit}`, base);
47
- if (after) {
48
- url.searchParams.append('after', after);
49
- }
50
- return request({ base, url: `${url.pathname}${url.search}`, options });
51
- }
52
- export function fetchAssetsBalance(base, address, options = Object.create(null)) {
53
- return __awaiter(this, void 0, void 0, function* () {
54
- const balancesResponse = yield request({ base, url: `/assets/balance/${address}`, options });
55
- const assetsWithoutIssueTransaction = balancesResponse.balances.reduce((acc, balance, index) => {
56
- if (!balance.issueTransaction) {
57
- acc[balance.assetId] = index;
58
- }
59
- return acc;
60
- }, {});
61
- const detailsIds = Object.keys(assetsWithoutIssueTransaction);
62
- if (detailsIds.length) {
63
- const assetsDetailsResponse = yield fetchAssetsDetails(base, detailsIds, options);
64
- assetsDetailsResponse.forEach((assetDetails) => {
65
- if ('error' in assetDetails) {
66
- return;
67
- }
68
- const assetIndex = assetsWithoutIssueTransaction[assetDetails.assetId];
69
- const assetBalance = balancesResponse.balances[assetIndex];
70
- if (!assetBalance) {
71
- return;
72
- }
73
- assetBalance.issueTransaction = {
74
- id: assetDetails.originTransactionId,
75
- name: assetDetails.name,
76
- decimals: assetDetails.decimals,
77
- description: assetDetails.description,
78
- quantity: assetDetails.quantity,
79
- reissuable: assetDetails.reissuable,
80
- sender: assetDetails.issuer,
81
- senderPublicKey: assetDetails.issuerPublicKey,
82
- timestamp: assetDetails.issueTimestamp,
83
- height: assetDetails.issueHeight,
84
- script: assetDetails.scripted ? '-' : null,
85
- proofs: [],
86
- fee: Math.pow(10, 8),
87
- feeAssetId: null,
88
- version: 3,
89
- type: TRANSACTION_TYPE.ISSUE,
90
- chainId: 0
91
- };
92
- });
93
- }
94
- return balancesResponse;
95
- });
96
- }
97
- export function fetchBalanceAddressAssetId(base, address, assetId, options = Object.create(null)) {
98
- return request({ base, url: `/assets/balance/${address}/${assetId}`, options });
99
- }
100
- export function convertEthAssetId(base, assetId) {
101
- return request({ base, url: `/eth/assets${query({ id: assetId })}` }).then(assets => assets[0].assetId);
102
- }
1
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
+ return new (P || (P = Promise))(function (resolve, reject) {
4
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
8
+ });
9
+ };
10
+ import { TRANSACTION_TYPE } from '@waves/ts-types';
11
+ import request from '../../tools/request';
12
+ import { toArray } from '../../tools/utils';
13
+ import query from "../../tools/query";
14
+ export function fetchDetails(base, assetId, options = Object.create(null)) {
15
+ const isOnce = !Array.isArray(assetId);
16
+ return Promise.all(toArray(assetId).map(id => request({
17
+ base,
18
+ url: `/assets/details/${id}`,
19
+ options
20
+ })))
21
+ .then(list => isOnce ? list[0] : list);
22
+ }
23
+ /**
24
+ * POST /assets/details
25
+ * Provides detailed information about the given assets
26
+ */
27
+ export function fetchAssetsDetails(base, assetIds, options = Object.create(null)) {
28
+ const body = JSON.stringify({ ids: assetIds });
29
+ const _options = Object.assign(Object.assign({}, options), { body, headers: {
30
+ 'content-type': 'application/json'
31
+ }, method: 'POST' });
32
+ return request({ base, url: `/assets/details`, options: _options });
33
+ }
34
+ export function fetchAssetDistribution(base, assetId, height, limit, options = Object.create(null)) {
35
+ return request({ base, url: `/assets/${assetId}/distribution/${height}/limit/${limit}`, options });
36
+ }
37
+ /**
38
+ * TODO
39
+ * GET /assets/{assetId}/distribution
40
+ * Asset balance distribution
41
+ */
42
+ export function fetchAssetsAddressLimit(base, address, limit, options = Object.create(null)) {
43
+ return request({ base, url: `assets/nft/${address}/limit/${limit}`, options });
44
+ }
45
+ export function fetchAssetsNft(base, { address, limit, after }, options = Object.create(null)) {
46
+ const url = new URL(`assets/nft/${address}/limit/${limit}`, base);
47
+ if (after) {
48
+ url.searchParams.append('after', after);
49
+ }
50
+ return request({ base, url: `${url.pathname}${url.search}`, options });
51
+ }
52
+ export function fetchAssetsBalance(base, address, options = Object.create(null)) {
53
+ return __awaiter(this, void 0, void 0, function* () {
54
+ const balancesResponse = yield request({ base, url: `/assets/balance/${address}`, options });
55
+ const assetsWithoutIssueTransaction = balancesResponse.balances.reduce((acc, balance, index) => {
56
+ if (!balance.issueTransaction) {
57
+ acc[balance.assetId] = index;
58
+ }
59
+ return acc;
60
+ }, {});
61
+ const detailsIds = Object.keys(assetsWithoutIssueTransaction);
62
+ if (detailsIds.length) {
63
+ const assetsDetailsResponse = yield fetchAssetsDetails(base, detailsIds, options);
64
+ assetsDetailsResponse.forEach((assetDetails) => {
65
+ if ('error' in assetDetails) {
66
+ return;
67
+ }
68
+ const assetIndex = assetsWithoutIssueTransaction[assetDetails.assetId];
69
+ const assetBalance = balancesResponse.balances[assetIndex];
70
+ if (!assetBalance) {
71
+ return;
72
+ }
73
+ assetBalance.issueTransaction = {
74
+ id: assetDetails.originTransactionId,
75
+ name: assetDetails.name,
76
+ decimals: assetDetails.decimals,
77
+ description: assetDetails.description,
78
+ quantity: assetDetails.quantity,
79
+ reissuable: assetDetails.reissuable,
80
+ sender: assetDetails.issuer,
81
+ senderPublicKey: assetDetails.issuerPublicKey,
82
+ timestamp: assetDetails.issueTimestamp,
83
+ height: assetDetails.issueHeight,
84
+ script: assetDetails.scripted ? '-' : null,
85
+ proofs: [],
86
+ fee: Math.pow(10, 8),
87
+ feeAssetId: null,
88
+ version: 3,
89
+ type: TRANSACTION_TYPE.ISSUE,
90
+ chainId: 0
91
+ };
92
+ });
93
+ }
94
+ return balancesResponse;
95
+ });
96
+ }
97
+ export function fetchBalanceAddressAssetId(base, address, assetId, options = Object.create(null)) {
98
+ return request({ base, url: `/assets/balance/${address}/${assetId}`, options });
99
+ }
100
+ export function convertEthAssetId(base, assetId) {
101
+ return request({ base, url: `/eth/assets${query({ id: assetId })}` }).then(assets => assets[0].assetId);
102
+ }
103
103
  //# sourceMappingURL=index.js.map
@@ -1,131 +1,143 @@
1
- import { TLong } from '../../interface';
2
- import { TransactionFromNode, WithApiMixin } from '@waves/ts-types';
3
- /**
4
- * GET /blocks/headers/seq/{from}/{to}
5
- * Get block headers at specified heights
6
- * @param base
7
- * @param from
8
- * @param to
9
- */
10
- export declare function fetchHeadersSeq(base: string, from: number, to: number, options?: RequestInit): Promise<Array<IBlockHeader>>;
11
- /**
12
- * GET /blocks/headers/last
13
- * Last block header
14
- * @param base
15
- */
16
- export declare function fetchHeadersLast(base: string, options?: RequestInit): Promise<IBlockHeader>;
17
- /**
18
- * GET /blocks/height/{id}
19
- * Height of a block by its id
20
- * @param base
21
- * @param id
22
- */
23
- export declare function fetchHeightById(base: string, id: string): Promise<{
24
- height: number;
25
- }>;
26
- /**
27
- * GET /blocks/headers/at/{height}
28
- * Block header at height
29
- * @param base
30
- * @param height
31
- */
32
- export declare function fetchHeadersAt(base: string, height: number, options?: RequestInit): Promise<IBlockHeader>;
33
- /**
34
- * GET /blocks/headers/{id}
35
- * Get block at specified height
36
- * @param base
37
- * @param height
38
- */
39
- export declare function fetchHeadersById(base: string, id: string, options?: RequestInit): Promise<IBlock>;
40
- /**
41
- * GET /blocks/at/{height}
42
- * Get block at specified height
43
- * @param base
44
- * @param height
45
- */
46
- export declare function fetchBlockAt(base: string, height: number, options?: RequestInit): Promise<IBlock>;
47
- /**
48
- * GET /blocks/seq/{from}/{to}
49
- * Block range
50
- * @param base
51
- * @param from
52
- * @param to
53
- */
54
- export declare function fetchSeq(base: string, from: number, to: number, options?: RequestInit): Promise<Array<IBlock>>;
55
- /**
56
- * GET /blocks/{id}
57
- * Get block by its id
58
- * @param base
59
- * @param id
60
- */
61
- export declare function fetchBlockById(base: string, id: string, options?: RequestInit): Promise<IBlock>;
62
- /**
63
- * GET /blocks/first
64
- * Get genesis block
65
- * @param base
66
- */
67
- export declare function fetchFirst(base: string, options?: RequestInit): Promise<IBlock>;
68
- /**
69
- * /blocks/address/{address}/{from}/{to}
70
- * Get list of blocks generated by specified address
71
- * @param base
72
- * @param address
73
- * @param from
74
- * @param to
75
- */
76
- export declare function fetchBlocksByAddress(base: string, address: string, from: number, to: number, options?: RequestInit): Promise<Array<IBlock>>;
77
- /**
78
- * GET /blocks/last
79
- * Last block
80
- * @param base
81
- */
82
- export declare function fetchLast(base: string, options?: RequestInit): Promise<IBlock>;
83
- /**
84
- * GET /blocks/delay/{id}/{blockNum}
85
- * Average delay in milliseconds between last blockNum blocks starting from block with id
86
- * @param base
87
- * @param id
88
- * @param blockNum
89
- */
90
- export declare function fetchDelay(base: string, id: string, blockNum: number): Promise<{
91
- delay: number;
92
- }>;
93
- /**
94
- * GET /blocks/height
95
- * @param base
96
- */
97
- export declare function fetchHeight(base: string): Promise<{
98
- height: number;
99
- }>;
100
- /**
101
- * GET /blocks/heightByTimestamp
102
- * @param base
103
- */
104
- export declare function fetchHeightByTimestamp(base: string, timestamp: number, options?: RequestInit): Promise<{
105
- height: number;
106
- }>;
107
- export interface IBlockHeader {
108
- id: string;
109
- blocksize: number;
110
- reward: TLong;
111
- signature: string;
112
- VRF: string;
113
- generator: string;
114
- generatorPublicKey: string;
115
- version: number;
116
- reference: string;
117
- features: Array<string>;
118
- totalFee: TLong;
119
- desiredReward: number;
120
- transactionCount: number;
121
- timestamp: number;
122
- height: number;
123
- 'nxt-consensus': {
124
- 'base-target': number;
125
- 'generation-signature': string;
126
- };
127
- }
128
- export interface IBlock extends IBlockHeader {
129
- fee: TLong;
130
- transactions: Array<TransactionFromNode & WithApiMixin>;
131
- }
1
+ import { TLong } from '../../interface';
2
+ import { TransactionFromNode, WithApiMixin } from '@waves/ts-types';
3
+ /**
4
+ * GET /blocks/headers/seq/{from}/{to}
5
+ * Get block headers at specified heights
6
+ * @param base
7
+ * @param from
8
+ * @param to
9
+ */
10
+ export declare function fetchHeadersSeq(base: string, from: number, to: number, options?: RequestInit): Promise<Array<IBlockHeader>>;
11
+ /**
12
+ * GET /blocks/headers/last
13
+ * Last block header
14
+ * @param base
15
+ */
16
+ export declare function fetchHeadersLast(base: string, options?: RequestInit): Promise<IBlockHeader>;
17
+ /**
18
+ * GET /blocks/height/{id}
19
+ * Height of a block by its id
20
+ * @param base
21
+ * @param id
22
+ */
23
+ export declare function fetchHeightById(base: string, id: string): Promise<{
24
+ height: number;
25
+ }>;
26
+ /**
27
+ * GET /blocks/headers/at/{height}
28
+ * Block header at height
29
+ * @param base
30
+ * @param height
31
+ */
32
+ export declare function fetchHeadersAt(base: string, height: number, options?: RequestInit): Promise<IBlockHeader>;
33
+ /**
34
+ * GET /blocks/headers/{id}
35
+ * Get block at specified height
36
+ * @param base
37
+ * @param height
38
+ */
39
+ export declare function fetchHeadersById(base: string, id: string, options?: RequestInit): Promise<IBlock>;
40
+ /**
41
+ * GET /blocks/at/{height}
42
+ * Get block at specified height
43
+ * @param base
44
+ * @param height
45
+ */
46
+ export declare function fetchBlockAt(base: string, height: number, options?: RequestInit): Promise<IBlock>;
47
+ /**
48
+ * GET /blocks/seq/{from}/{to}
49
+ * Block range
50
+ * @param base
51
+ * @param from
52
+ * @param to
53
+ */
54
+ export declare function fetchSeq(base: string, from: number, to: number, options?: RequestInit): Promise<Array<IBlock>>;
55
+ /**
56
+ * GET /blocks/{id}
57
+ * Get block by its id
58
+ * @param base
59
+ * @param id
60
+ */
61
+ export declare function fetchBlockById(base: string, id: string, options?: RequestInit): Promise<IBlock>;
62
+ /**
63
+ * GET /blocks/first
64
+ * Get genesis block
65
+ * @param base
66
+ */
67
+ export declare function fetchFirst(base: string, options?: RequestInit): Promise<IBlock>;
68
+ /**
69
+ * /blocks/address/{address}/{from}/{to}
70
+ * Get list of blocks generated by specified address
71
+ * @param base
72
+ * @param address
73
+ * @param from
74
+ * @param to
75
+ */
76
+ export declare function fetchBlocksByAddress(base: string, address: string, from: number, to: number, options?: RequestInit): Promise<Array<IBlock>>;
77
+ /**
78
+ * GET /blocks/last
79
+ * Last block
80
+ * @param base
81
+ */
82
+ export declare function fetchLast(base: string, options?: RequestInit): Promise<IBlock>;
83
+ /**
84
+ * GET /blocks/delay/{id}/{blockNum}
85
+ * Average delay in milliseconds between last blockNum blocks starting from block with id
86
+ * @param base
87
+ * @param id
88
+ * @param blockNum
89
+ */
90
+ export declare function fetchDelay(base: string, id: string, blockNum: number): Promise<{
91
+ delay: number;
92
+ }>;
93
+ /**
94
+ * GET /blocks/height
95
+ * @param base
96
+ */
97
+ export declare function fetchHeight(base: string): Promise<{
98
+ height: number;
99
+ }>;
100
+ /**
101
+ * GET /blocks/heightByTimestamp
102
+ * @param base
103
+ */
104
+ export declare function fetchHeightByTimestamp(base: string, timestamp: number, options?: RequestInit): Promise<{
105
+ height: number;
106
+ }>;
107
+ export interface IBlockHeader {
108
+ id: string;
109
+ blocksize: number;
110
+ reward: TLong;
111
+ signature: string;
112
+ VRF: string;
113
+ generator: string;
114
+ generatorPublicKey: string;
115
+ version: number;
116
+ reference: string;
117
+ features: Array<number>;
118
+ totalFee: TLong;
119
+ desiredReward: number;
120
+ transactionCount: number;
121
+ timestamp: number;
122
+ height: number;
123
+ 'nxt-consensus': {
124
+ 'base-target': number;
125
+ 'generation-signature': string;
126
+ };
127
+ stateHash?: string;
128
+ rewardShares?: {
129
+ [key: string]: TLong;
130
+ };
131
+ challengedHeader?: {
132
+ headerSignature: string;
133
+ features: Array<string>;
134
+ generator: string;
135
+ generatorPublicKey: string;
136
+ desiredReward: TLong;
137
+ stateHash: string;
138
+ };
139
+ }
140
+ export interface IBlock extends IBlockHeader {
141
+ fee: TLong;
142
+ transactions: Array<TransactionFromNode & WithApiMixin>;
143
+ }