@waves/node-api-js 1.2.10 → 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 (180) 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 -99
  30. package/cjs/api-node/utils/index.js +210 -192
  31. package/cjs/api-node/utils/index.js.map +1 -1
  32. package/cjs/api-node/wallet/index.d.ts +5 -5
  33. package/cjs/api-node/wallet/index.js +6 -6
  34. package/cjs/constants.d.ts +40 -40
  35. package/cjs/constants.js +42 -42
  36. package/cjs/create.d.ts +1238 -1240
  37. package/cjs/create.js +115 -118
  38. package/cjs/create.js.map +1 -1
  39. package/cjs/index.d.ts +9 -9
  40. package/cjs/index.js +17 -17
  41. package/cjs/interface.d.ts +44 -44
  42. package/cjs/interface.js +9 -9
  43. package/cjs/tools/adresses/availableSponsoredBalances.d.ts +7 -7
  44. package/cjs/tools/adresses/availableSponsoredBalances.js +29 -29
  45. package/cjs/tools/adresses/ethAddress2waves.d.ts +1 -1
  46. package/cjs/tools/adresses/ethAddress2waves.js +46 -46
  47. package/cjs/tools/adresses/getAssetIdListByTx.d.ts +2 -2
  48. package/cjs/tools/adresses/getAssetIdListByTx.js +47 -47
  49. package/cjs/tools/adresses/getAssetsByTransaction.d.ts +3 -3
  50. package/cjs/tools/adresses/getAssetsByTransaction.js +13 -13
  51. package/cjs/tools/adresses/getTransactionsWithAssets.d.ts +6 -6
  52. package/cjs/tools/adresses/getTransactionsWithAssets.js +12 -12
  53. package/cjs/tools/adresses/watch.d.ts +24 -24
  54. package/cjs/tools/adresses/watch.js +167 -167
  55. package/cjs/tools/adresses/wavesAddress2eth.d.ts +1 -1
  56. package/cjs/tools/adresses/wavesAddress2eth.js +9 -9
  57. package/cjs/tools/assets/wavesAsset2eth.d.ts +1 -1
  58. package/cjs/tools/assets/wavesAsset2eth.js +9 -9
  59. package/cjs/tools/blocks/detectInterval.d.ts +1 -1
  60. package/cjs/tools/blocks/detectInterval.js +11 -11
  61. package/cjs/tools/blocks/getNetworkByte.d.ts +1 -1
  62. package/cjs/tools/blocks/getNetworkByte.js +53 -53
  63. package/cjs/tools/blocks/getNetworkCode.d.ts +1 -1
  64. package/cjs/tools/blocks/getNetworkCode.js +10 -10
  65. package/cjs/tools/blocks/waitHeight.d.ts +3 -3
  66. package/cjs/tools/blocks/waitHeight.js +64 -64
  67. package/cjs/tools/parse.d.ts +1 -1
  68. package/cjs/tools/parse.js +7 -7
  69. package/cjs/tools/query.d.ts +4 -4
  70. package/cjs/tools/query.js +40 -40
  71. package/cjs/tools/request.d.ts +64 -64
  72. package/cjs/tools/request.js +41 -41
  73. package/cjs/tools/resolve.d.ts +1 -1
  74. package/cjs/tools/resolve.js +6 -6
  75. package/cjs/tools/stringify.d.ts +1 -1
  76. package/cjs/tools/stringify.js +20 -20
  77. package/cjs/tools/transactions/broadcast.d.ts +14 -14
  78. package/cjs/tools/transactions/broadcast.js +59 -59
  79. package/cjs/tools/transactions/ethTxId2waves.d.ts +1 -1
  80. package/cjs/tools/transactions/ethTxId2waves.js +10 -10
  81. package/cjs/tools/transactions/wait.d.ts +10 -10
  82. package/cjs/tools/transactions/wait.js +41 -41
  83. package/cjs/tools/utils.d.ts +32 -32
  84. package/cjs/tools/utils.js +117 -117
  85. package/dist/node-api.js +2368 -2402
  86. package/dist/node-api.min.js +2 -2
  87. package/es/api-node/activation/index.d.ts +21 -21
  88. package/es/api-node/activation/index.js +12 -12
  89. package/es/api-node/addresses/index.d.ts +81 -81
  90. package/es/api-node/addresses/index.js +110 -110
  91. package/es/api-node/addresses/index.js.map +1 -1
  92. package/es/api-node/alias/index.d.ts +6 -6
  93. package/es/api-node/alias/index.js +13 -13
  94. package/es/api-node/assets/index.d.ts +79 -79
  95. package/es/api-node/assets/index.js +102 -102
  96. package/es/api-node/blocks/index.d.ts +143 -131
  97. package/es/api-node/blocks/index.js +178 -178
  98. package/es/api-node/consensus/index.d.ts +39 -39
  99. package/es/api-node/consensus/index.js +26 -26
  100. package/es/api-node/debug/index.d.ts +189 -189
  101. package/es/api-node/debug/index.js +200 -200
  102. package/es/api-node/eth/index.d.ts +3 -3
  103. package/es/api-node/eth/index.js +7 -7
  104. package/es/api-node/leasing/index.d.ts +22 -22
  105. package/es/api-node/leasing/index.js +21 -21
  106. package/es/api-node/node/index.d.ts +11 -11
  107. package/es/api-node/node/index.js +9 -9
  108. package/es/api-node/peers/index.d.ts +46 -46
  109. package/es/api-node/peers/index.js +45 -45
  110. package/es/api-node/rewards/index.d.ts +21 -21
  111. package/es/api-node/rewards/index.js +12 -12
  112. package/es/api-node/transactions/index.d.ts +73 -73
  113. package/es/api-node/transactions/index.js +136 -136
  114. package/es/api-node/utils/index.d.ts +110 -99
  115. package/es/api-node/utils/index.js +192 -175
  116. package/es/api-node/utils/index.js.map +1 -1
  117. package/es/api-node/wallet/index.d.ts +5 -5
  118. package/es/api-node/wallet/index.js +6 -6
  119. package/es/constants.d.ts +40 -40
  120. package/es/constants.js +39 -39
  121. package/es/create.d.ts +1238 -1240
  122. package/es/create.js +89 -92
  123. package/es/create.js.map +1 -1
  124. package/es/index.d.ts +9 -9
  125. package/es/index.js +8 -8
  126. package/es/interface.d.ts +44 -44
  127. package/es/interface.js +2 -2
  128. package/es/tools/adresses/availableSponsoredBalances.d.ts +7 -7
  129. package/es/tools/adresses/availableSponsoredBalances.js +26 -26
  130. package/es/tools/adresses/ethAddress2waves.d.ts +1 -1
  131. package/es/tools/adresses/ethAddress2waves.js +30 -30
  132. package/es/tools/adresses/getAssetIdListByTx.d.ts +2 -2
  133. package/es/tools/adresses/getAssetIdListByTx.js +23 -23
  134. package/es/tools/adresses/getAssetsByTransaction.d.ts +3 -3
  135. package/es/tools/adresses/getAssetsByTransaction.js +7 -7
  136. package/es/tools/adresses/getTransactionsWithAssets.d.ts +6 -6
  137. package/es/tools/adresses/getTransactionsWithAssets.js +6 -6
  138. package/es/tools/adresses/watch.d.ts +24 -24
  139. package/es/tools/adresses/watch.js +133 -133
  140. package/es/tools/adresses/wavesAddress2eth.d.ts +1 -1
  141. package/es/tools/adresses/wavesAddress2eth.js +6 -6
  142. package/es/tools/assets/wavesAsset2eth.d.ts +1 -1
  143. package/es/tools/assets/wavesAsset2eth.js +6 -6
  144. package/es/tools/blocks/detectInterval.d.ts +1 -1
  145. package/es/tools/blocks/detectInterval.js +8 -8
  146. package/es/tools/blocks/getNetworkByte.d.ts +1 -1
  147. package/es/tools/blocks/getNetworkByte.js +50 -50
  148. package/es/tools/blocks/getNetworkCode.d.ts +1 -1
  149. package/es/tools/blocks/getNetworkCode.js +4 -4
  150. package/es/tools/blocks/waitHeight.d.ts +3 -3
  151. package/es/tools/blocks/waitHeight.js +35 -35
  152. package/es/tools/parse.d.ts +1 -1
  153. package/es/tools/parse.js +4 -4
  154. package/es/tools/query.d.ts +4 -4
  155. package/es/tools/query.js +11 -11
  156. package/es/tools/request.d.ts +64 -64
  157. package/es/tools/request.js +21 -21
  158. package/es/tools/resolve.d.ts +1 -1
  159. package/es/tools/resolve.js +3 -3
  160. package/es/tools/stringify.d.ts +1 -1
  161. package/es/tools/stringify.js +17 -17
  162. package/es/tools/transactions/broadcast.d.ts +14 -14
  163. package/es/tools/transactions/broadcast.js +42 -42
  164. package/es/tools/transactions/ethTxId2waves.d.ts +1 -1
  165. package/es/tools/transactions/ethTxId2waves.js +7 -7
  166. package/es/tools/transactions/wait.d.ts +10 -10
  167. package/es/tools/transactions/wait.js +38 -38
  168. package/es/tools/utils.d.ts +32 -32
  169. package/es/tools/utils.js +72 -72
  170. package/package.json +66 -66
  171. package/cjs/tools/transactions/transactions.d.ts +0 -0
  172. package/cjs/tools/transactions/transactions.js +0 -2
  173. package/cjs/tools/transactions/transactions.js.map +0 -1
  174. package/dist/0.node-api.js +0 -467
  175. package/dist/node-api.min.js.LICENSE.txt +0 -17
  176. package/dist/node_fs-node_path.node-api.js +0 -23
  177. package/dist/vendors-node_modules_node-fetch_src_utils_multipart-parser_js.node-api.js +0 -599
  178. package/es/tools/transactions/transactions.d.ts +0 -0
  179. package/es/tools/transactions/transactions.js +0 -2
  180. package/es/tools/transactions/transactions.js.map +0 -1
@@ -1,64 +1,64 @@
1
- export default function <T>(params: IRequestParams<T>): Promise<T>;
2
- export declare function parseResponse<T>(r: Response): Promise<T>;
3
- export interface IRequestParams<T> {
4
- url: string;
5
- base: string;
6
- options?: RequestInit | undefined;
7
- }
8
- export interface RequestInit {
9
- /**
10
- * A BodyInit object or null to set request's body.
11
- */
12
- body?: BodyInit | null;
13
- /**
14
- * A string indicating how the request will interact with the browser's cache to set request's cache.
15
- * Not supported in nodejs environment
16
- */
17
- cache?: RequestCache;
18
- /**
19
- * A string indicating whether credentials will be sent with the request always, never, or only when sent to a same-origin URL. Sets request's credentials.
20
- */
21
- credentials?: RequestCredentials;
22
- /**
23
- * A Headers object, an object literal, or an array of two-item arrays to set request's headers.
24
- * Not supported in nodejs environment
25
- */
26
- headers?: HeadersInit;
27
- /**
28
- * A cryptographic hash of the resource to be fetched by request. Sets request's integrity.
29
- */
30
- integrity?: string;
31
- /**
32
- * A boolean to set request's keepalive.
33
- */
34
- keepalive?: boolean;
35
- /**
36
- * A string to set request's method.
37
- */
38
- method?: string;
39
- /**
40
- * A string to indicate whether the request will use CORS, or will be restricted to same-origin URLs. Sets request's mode.
41
- * Not supported in nodejs environment
42
- */
43
- mode?: RequestMode;
44
- /**
45
- * A string indicating whether request follows redirects, results in an error upon encountering a redirect, or returns the redirect (in an opaque fashion). Sets request's redirect.
46
- */
47
- redirect?: RequestRedirect;
48
- /**
49
- * A string whose value is a same-origin URL, "about:client", or the empty string, to set request's referrer.
50
- */
51
- referrer?: string;
52
- /**
53
- * A referrer policy to set request's referrerPolicy.
54
- */
55
- referrerPolicy?: ReferrerPolicy;
56
- /**
57
- * An AbortSignal to set request's signal.
58
- */
59
- signal?: AbortSignal | null;
60
- /**
61
- * Can only be null. Used to disassociate request from any Window.
62
- */
63
- window?: any;
64
- }
1
+ export default function <T>(params: IRequestParams<T>): Promise<T>;
2
+ export declare function parseResponse<T>(r: Response): Promise<T>;
3
+ export interface IRequestParams<T> {
4
+ url: string;
5
+ base: string;
6
+ options?: RequestInit | undefined;
7
+ }
8
+ export interface RequestInit {
9
+ /**
10
+ * A BodyInit object or null to set request's body.
11
+ */
12
+ body?: BodyInit | null;
13
+ /**
14
+ * A string indicating how the request will interact with the browser's cache to set request's cache.
15
+ * Not supported in nodejs environment
16
+ */
17
+ cache?: RequestCache;
18
+ /**
19
+ * A string indicating whether credentials will be sent with the request always, never, or only when sent to a same-origin URL. Sets request's credentials.
20
+ */
21
+ credentials?: RequestCredentials;
22
+ /**
23
+ * A Headers object, an object literal, or an array of two-item arrays to set request's headers.
24
+ * Not supported in nodejs environment
25
+ */
26
+ headers?: HeadersInit;
27
+ /**
28
+ * A cryptographic hash of the resource to be fetched by request. Sets request's integrity.
29
+ */
30
+ integrity?: string;
31
+ /**
32
+ * A boolean to set request's keepalive.
33
+ */
34
+ keepalive?: boolean;
35
+ /**
36
+ * A string to set request's method.
37
+ */
38
+ method?: string;
39
+ /**
40
+ * A string to indicate whether the request will use CORS, or will be restricted to same-origin URLs. Sets request's mode.
41
+ * Not supported in nodejs environment
42
+ */
43
+ mode?: RequestMode;
44
+ /**
45
+ * A string indicating whether request follows redirects, results in an error upon encountering a redirect, or returns the redirect (in an opaque fashion). Sets request's redirect.
46
+ */
47
+ redirect?: RequestRedirect;
48
+ /**
49
+ * A string whose value is a same-origin URL, "about:client", or the empty string, to set request's referrer.
50
+ */
51
+ referrer?: string;
52
+ /**
53
+ * A referrer policy to set request's referrerPolicy.
54
+ */
55
+ referrerPolicy?: ReferrerPolicy;
56
+ /**
57
+ * An AbortSignal to set request's signal.
58
+ */
59
+ signal?: AbortSignal | null;
60
+ /**
61
+ * Can only be null. Used to disassociate request from any Window.
62
+ */
63
+ window?: any;
64
+ }
@@ -1,22 +1,22 @@
1
- import resolve from './resolve';
2
- import parse from './parse';
3
- const request = typeof fetch === 'function' ? fetch : require('node-fetch');
4
- export default function (params) {
5
- return request(resolve(params.url, params.base), updateHeaders(params.options))
6
- .then(parseResponse);
7
- }
8
- export function parseResponse(r) {
9
- return r.text().then(message => r.ok ? parse(message) : Promise.reject(tryParse(message)));
10
- }
11
- function tryParse(message) {
12
- try {
13
- return JSON.parse(message);
14
- }
15
- catch (e) {
16
- return message;
17
- }
18
- }
19
- function updateHeaders(options = Object.create(null)) {
20
- return Object.assign({ credentials: 'include' }, options);
21
- }
1
+ import resolve from './resolve';
2
+ import parse from './parse';
3
+ const request = typeof fetch === 'function' ? fetch : require('node-fetch');
4
+ export default function (params) {
5
+ return request(resolve(params.url, params.base), updateHeaders(params.options))
6
+ .then(parseResponse);
7
+ }
8
+ export function parseResponse(r) {
9
+ return r.text().then(message => r.ok ? parse(message) : Promise.reject(tryParse(message)));
10
+ }
11
+ function tryParse(message) {
12
+ try {
13
+ return JSON.parse(message);
14
+ }
15
+ catch (e) {
16
+ return message;
17
+ }
18
+ }
19
+ function updateHeaders(options = Object.create(null)) {
20
+ return Object.assign({ credentials: 'include' }, options);
21
+ }
22
22
  //# sourceMappingURL=request.js.map
@@ -1 +1 @@
1
- export default function (path: string, base: string): string;
1
+ export default function (path: string, base: string): string;
@@ -1,4 +1,4 @@
1
- export default function (path, base) {
2
- return new URL(path, base).toString();
3
- }
1
+ export default function (path, base) {
2
+ return new URL(path, base).toString();
3
+ }
4
4
  //# sourceMappingURL=resolve.js.map
@@ -1 +1 @@
1
- export default function <T extends Record<string, any>>(data: T): string;
1
+ export default function <T extends Record<string, any>>(data: T): string;
@@ -1,18 +1,18 @@
1
- const FIELDS = ['amount', 'matcherFee', 'price', 'minSponsoredAssetFee', 'fee', 'quantity', 'sellMatcherFee', 'buyMatcherFee'];
2
- export default function (data) {
3
- return JSON.stringify(data, function (key, value) {
4
- if (FIELDS.includes(key) && value) {
5
- return `!${value}!`;
6
- }
7
- else if (key === 'value' && this['type'] === 'integer') {
8
- return `!${value}!`;
9
- }
10
- else if (key === 'minSponsoredAssetFee' && value == null) {
11
- return null;
12
- }
13
- else {
14
- return value;
15
- }
16
- }, 0).replace(/"\!(-?\d+)\!"/g, '$1');
17
- }
1
+ const FIELDS = ['amount', 'matcherFee', 'price', 'minSponsoredAssetFee', 'fee', 'quantity', 'sellMatcherFee', 'buyMatcherFee'];
2
+ export default function (data) {
3
+ return JSON.stringify(data, function (key, value) {
4
+ if (FIELDS.includes(key) && value) {
5
+ return `!${value}!`;
6
+ }
7
+ else if (key === 'value' && this['type'] === 'integer') {
8
+ return `!${value}!`;
9
+ }
10
+ else if (key === 'minSponsoredAssetFee' && value == null) {
11
+ return null;
12
+ }
13
+ else {
14
+ return value;
15
+ }
16
+ }, 0).replace(/"\!(-?\d+)\!"/g, '$1');
17
+ }
18
18
  //# sourceMappingURL=stringify.js.map
@@ -1,14 +1,14 @@
1
- import { TLong } from '../../interface';
2
- import { SignedTransaction, Transaction, TransactionMap, WithApiMixin } from '@waves/ts-types';
3
- export declare type TMap<MAP extends Record<string | number, any>, Key extends keyof MAP> = MAP[Key];
4
- export declare type TMapTuple<T extends Array<Record<string | number, any>>, TO_MAP extends Record<string | number, Record<string | number, any>>, KEY> = {
5
- [K in keyof T]: KEY extends keyof T[K] ? T[K][KEY] extends infer R ? R extends keyof TO_MAP ? TO_MAP[R] : never : never : never;
6
- };
7
- export default function <T extends Array<SignedTransaction<Transaction<TLong>>>>(base: string, list: T): Promise<TMapTuple<T, TransactionMap, 'type'> & WithApiMixin>;
8
- export default function <T extends Transaction<TLong>>(base: string, tx: SignedTransaction<T>, options?: Partial<IOptions>): Promise<TMap<TransactionMap<TLong>, T['type']> & WithApiMixin>;
9
- export interface IOptions {
10
- chain: boolean;
11
- confirmations: number;
12
- maxWaitTime: number;
13
- requestInterval: number;
14
- }
1
+ import { TLong } from '../../interface';
2
+ import { SignedTransaction, Transaction, TransactionMap, WithApiMixin } from '@waves/ts-types';
3
+ export declare type TMap<MAP extends Record<string | number, any>, Key extends keyof MAP> = MAP[Key];
4
+ export declare type TMapTuple<T extends Array<Record<string | number, any>>, TO_MAP extends Record<string | number, Record<string | number, any>>, KEY> = {
5
+ [K in keyof T]: KEY extends keyof T[K] ? T[K][KEY] extends infer R ? R extends keyof TO_MAP ? TO_MAP[R] : never : never : never;
6
+ };
7
+ export default function <T extends Array<SignedTransaction<Transaction<TLong>>>>(base: string, list: T): Promise<TMapTuple<T, TransactionMap, 'type'> & WithApiMixin>;
8
+ export default function <T extends Transaction<TLong>>(base: string, tx: SignedTransaction<T>, options?: Partial<IOptions>): Promise<TMap<TransactionMap<TLong>, T['type']> & WithApiMixin>;
9
+ export interface IOptions {
10
+ chain: boolean;
11
+ confirmations: number;
12
+ maxWaitTime: number;
13
+ requestInterval: number;
14
+ }
@@ -1,43 +1,43 @@
1
- import { broadcast } from '../../api-node/transactions';
2
- import { head, toArray } from '../utils';
3
- import wait from './wait';
4
- const DEFAULT_BROADCAST_OPTIONS = {
5
- chain: false,
6
- confirmations: -1,
7
- maxWaitTime: 0,
8
- requestInterval: 0
9
- };
10
- export default function (base, list, options) {
11
- const opt = Object.assign(Object.assign({}, DEFAULT_BROADCAST_OPTIONS), (options || {}));
12
- const isOnce = !Array.isArray(list);
13
- const confirmations = opt.confirmations > 0 ? 1 : 0;
14
- return (opt.chain
15
- ? chainBroadcast(base, toArray(list), Object.assign(Object.assign({}, opt), { confirmations }))
16
- : simpleBroadcast(base, toArray(list)))
17
- .then(list => opt.confirmations <= 0 ? list : wait(base, list, opt))
18
- .then(list => isOnce ? head(list) : list);
19
- }
20
- function simpleBroadcast(base, list) {
21
- return Promise.all(list.map(tx => broadcast(base, tx)));
22
- }
23
- function chainBroadcast(base, list, options) {
24
- return new Promise((resolve, reject) => {
25
- const toBroadcast = list.slice().reverse();
26
- const result = [];
27
- const loop = () => {
28
- if (!toBroadcast.length) {
29
- resolve(result);
30
- return null;
31
- }
32
- const tx = toBroadcast.pop();
33
- broadcast(base, tx)
34
- .then(tx => wait(base, tx, options))
35
- .then(tx => {
36
- result.push(tx);
37
- loop();
38
- }, reject);
39
- };
40
- loop();
41
- });
42
- }
1
+ import { broadcast } from '../../api-node/transactions';
2
+ import { head, toArray } from '../utils';
3
+ import wait from './wait';
4
+ const DEFAULT_BROADCAST_OPTIONS = {
5
+ chain: false,
6
+ confirmations: -1,
7
+ maxWaitTime: 0,
8
+ requestInterval: 0
9
+ };
10
+ export default function (base, list, options) {
11
+ const opt = Object.assign(Object.assign({}, DEFAULT_BROADCAST_OPTIONS), (options || {}));
12
+ const isOnce = !Array.isArray(list);
13
+ const confirmations = opt.confirmations > 0 ? 1 : 0;
14
+ return (opt.chain
15
+ ? chainBroadcast(base, toArray(list), Object.assign(Object.assign({}, opt), { confirmations }))
16
+ : simpleBroadcast(base, toArray(list)))
17
+ .then(list => opt.confirmations <= 0 ? list : wait(base, list, opt))
18
+ .then(list => isOnce ? head(list) : list);
19
+ }
20
+ function simpleBroadcast(base, list) {
21
+ return Promise.all(list.map(tx => broadcast(base, tx)));
22
+ }
23
+ function chainBroadcast(base, list, options) {
24
+ return new Promise((resolve, reject) => {
25
+ const toBroadcast = list.slice().reverse();
26
+ const result = [];
27
+ const loop = () => {
28
+ if (!toBroadcast.length) {
29
+ resolve(result);
30
+ return null;
31
+ }
32
+ const tx = toBroadcast.pop();
33
+ broadcast(base, tx)
34
+ .then(tx => wait(base, tx, options))
35
+ .then(tx => {
36
+ result.push(tx);
37
+ loop();
38
+ }, reject);
39
+ };
40
+ loop();
41
+ });
42
+ }
43
43
  //# sourceMappingURL=broadcast.js.map
@@ -1 +1 @@
1
- export default function ethTxId2waves(ethTxId: string): string;
1
+ export default function ethTxId2waves(ethTxId: string): string;
@@ -1,8 +1,8 @@
1
- import { base16Decode, base58Encode } from '@waves/ts-lib-crypto';
2
- export default function ethTxId2waves(ethTxId) {
3
- let id = ethTxId;
4
- if (ethTxId.startsWith('0x'))
5
- id = ethTxId.slice(2);
6
- return base58Encode(base16Decode(id));
7
- }
1
+ import { base16Decode, base58Encode } from '@waves/ts-lib-crypto';
2
+ export default function ethTxId2waves(ethTxId) {
3
+ let id = ethTxId;
4
+ if (ethTxId.startsWith('0x'))
5
+ id = ethTxId.slice(2);
6
+ return base58Encode(base16Decode(id));
7
+ }
8
8
  //# sourceMappingURL=ethTxId2waves.js.map
@@ -1,10 +1,10 @@
1
- import { TLong } from '../../interface';
2
- import { Transaction, WithApiMixin } from '@waves/ts-types';
3
- export default function <T extends Transaction<TLong> & WithApiMixin>(base: string, tx: T, options?: IWaitOptions): Promise<T>;
4
- export default function <T extends Transaction<TLong> & WithApiMixin>(base: string, list: Array<T>, options?: IWaitOptions): Promise<Array<T>>;
5
- export default function <T extends Transaction<TLong> & WithApiMixin>(base: string, tx: T | Array<T>, options?: IWaitOptions): Promise<T | Array<T>>;
6
- export interface IWaitOptions {
7
- confirmations?: number;
8
- maxWaitTime?: number;
9
- requestInterval?: number;
10
- }
1
+ import { TLong } from '../../interface';
2
+ import { Transaction, WithApiMixin } from '@waves/ts-types';
3
+ export default function <T extends Transaction<TLong> & WithApiMixin>(base: string, tx: T, options?: IWaitOptions): Promise<T>;
4
+ export default function <T extends Transaction<TLong> & WithApiMixin>(base: string, list: Array<T>, options?: IWaitOptions): Promise<Array<T>>;
5
+ export default function <T extends Transaction<TLong> & WithApiMixin>(base: string, tx: T | Array<T>, options?: IWaitOptions): Promise<T | Array<T>>;
6
+ export interface IWaitOptions {
7
+ confirmations?: number;
8
+ maxWaitTime?: number;
9
+ requestInterval?: number;
10
+ }
@@ -1,39 +1,39 @@
1
- import { head, indexBy, prop, toArray, wait } from '../utils';
2
- import { fetchStatus } from '../../api-node/transactions';
3
- import { TRANSACTION_STATUSES } from '../../constants';
4
- export default function (base, tx, options) {
5
- const isOnce = !Array.isArray(tx);
6
- const start = Date.now();
7
- const confirmed = [];
8
- const confirmations = options && options.confirmations || 0;
9
- const maxWaitTime = options && options.maxWaitTime || 0;
10
- const requestInterval = options && options.requestInterval || 250;
11
- const waitTx = (list) => {
12
- return fetchStatus(base, list.map(prop('id')))
13
- .then(status => {
14
- const hash = indexBy(prop('id'), status.statuses);
15
- const hasError = list.some(tx => hash[tx.id].status === TRANSACTION_STATUSES.NOT_FOUND);
16
- if (hasError) {
17
- throw new Error('One transaction is not in blockchain!');
18
- }
19
- const toRequest = list.filter(tx => {
20
- if (hash[tx.id].confirmations >= confirmations) {
21
- confirmed.push(tx);
22
- return false;
23
- }
24
- else {
25
- return true;
26
- }
27
- });
28
- if (!toRequest.length) {
29
- return void 0;
30
- }
31
- if (maxWaitTime && Date.now() - start > maxWaitTime) {
32
- return Promise.reject('Timeout error!');
33
- }
34
- return wait(requestInterval).then(() => waitTx(toRequest));
35
- });
36
- };
37
- return waitTx(toArray(tx)).then(() => isOnce ? head(confirmed) : confirmed);
38
- }
1
+ import { head, indexBy, prop, toArray, wait } from '../utils';
2
+ import { fetchStatus } from '../../api-node/transactions';
3
+ import { TRANSACTION_STATUSES } from '../../constants';
4
+ export default function (base, tx, options) {
5
+ const isOnce = !Array.isArray(tx);
6
+ const start = Date.now();
7
+ const confirmed = [];
8
+ const confirmations = options && options.confirmations || 0;
9
+ const maxWaitTime = options && options.maxWaitTime || 0;
10
+ const requestInterval = options && options.requestInterval || 250;
11
+ const waitTx = (list) => {
12
+ return fetchStatus(base, list.map(prop('id')))
13
+ .then(status => {
14
+ const hash = indexBy(prop('id'), status.statuses);
15
+ const hasError = list.some(tx => hash[tx.id].status === TRANSACTION_STATUSES.NOT_FOUND);
16
+ if (hasError) {
17
+ throw new Error('One transaction is not in blockchain!');
18
+ }
19
+ const toRequest = list.filter(tx => {
20
+ if (hash[tx.id].confirmations >= confirmations) {
21
+ confirmed.push(tx);
22
+ return false;
23
+ }
24
+ else {
25
+ return true;
26
+ }
27
+ });
28
+ if (!toRequest.length) {
29
+ return void 0;
30
+ }
31
+ if (maxWaitTime && Date.now() - start > maxWaitTime) {
32
+ return Promise.reject('Timeout error!');
33
+ }
34
+ return wait(requestInterval).then(() => waitTx(toRequest));
35
+ });
36
+ };
37
+ return waitTx(toArray(tx)).then(() => isOnce ? head(confirmed) : confirmed);
38
+ }
39
39
  //# sourceMappingURL=wait.js.map
@@ -1,32 +1,32 @@
1
- import { TransactionMap, Transaction } from '@waves/ts-types';
2
- import { TLong } from '../interface';
3
- export declare function isObject(obj: any): boolean;
4
- export declare function toArray<T>(data: T | Array<T>): Array<T>;
5
- export declare function head<T>(data: Array<T>): T | undefined;
6
- export declare function wait(time: number): Promise<void>;
7
- export declare function prop<T extends Record<string, any>, P extends keyof T>(key: P): (data: T) => T[P];
8
- export declare const keys: <T extends Record<import("@waves/ts-types").Long, any>>(obj: T) => (keyof T)[];
9
- export declare const entries: <T extends Record<import("@waves/ts-types").Long, any>>(obj: T) => [keyof T, T[keyof T]][];
10
- export declare const values: <T extends Record<import("@waves/ts-types").Long, any>>(obj: T) => T[keyof T][];
11
- export declare const assign: <T extends Record<import("@waves/ts-types").Long, any>, R extends Record<import("@waves/ts-types").Long, any>>(target: T, merge: R) => T & R;
12
- export declare const deepAssign: <T extends Record<import("@waves/ts-types").Long, any>[]>(...objects: T) => TUnionToIntersection<T[number]>;
13
- export declare function map<T, U>(process: (data: T, index: number) => U): (list: Array<T>) => Array<U>;
14
- export declare function filter<T>(process: (data: T, index: number) => boolean): (list: Array<T>) => Array<T>;
15
- export declare function filter<T, S extends T>(process: (data: T, index: number) => data is S): (list: Array<T>) => Array<S>;
16
- export declare function indexBy<T extends Record<string, any>, P extends (data: T) => string | number>(process: (data: T) => T[keyof T], data: Array<T>): Record<ReturnType<P>, T>;
17
- export declare const uniq: (list: Array<string | null>) => Array<string | null>;
18
- declare type TChoices = {
19
- [Key in keyof TransactionMap<TLong>]?: (data: TransactionMap<TLong>[Key]) => any;
20
- };
21
- export interface ISwitchTransactionResult<R extends TChoices> {
22
- <T extends Transaction<TLong>>(tx: T): R[T['type']] extends (data: TransactionMap<TLong>[T['type']]) => infer A ? A : undefined;
23
- }
24
- export declare function switchTransactionByType<R extends TChoices>(choices: R): ISwitchTransactionResult<R>;
25
- export declare const pipe: IPipe;
26
- export interface IPipe {
27
- <A, B, R>(a: (data: A) => B, b: (data: B) => R): (a: A) => R;
28
- <A, B, C, R>(a: (data: A) => B, b: (data: B) => C, c: (data: C) => R): (a: A) => R;
29
- <A, B, C, D, R>(a: (data: A) => B, b: (data: B) => C, c: (data: C) => D, d: (data: D) => R): (a: A) => R;
30
- }
31
- export declare type TUnionToIntersection<U> = (U extends any ? (k: U) => void : never) extends (k: infer I) => void ? I : never;
32
- export {};
1
+ import { TransactionMap, Transaction } from '@waves/ts-types';
2
+ import { TLong } from '../interface';
3
+ export declare function isObject(obj: any): boolean;
4
+ export declare function toArray<T>(data: T | Array<T>): Array<T>;
5
+ export declare function head<T>(data: Array<T>): T | undefined;
6
+ export declare function wait(time: number): Promise<void>;
7
+ export declare function prop<T extends Record<string, any>, P extends keyof T>(key: P): (data: T) => T[P];
8
+ export declare const keys: <T extends Record<import("@waves/ts-types").Long, any>>(obj: T) => (keyof T)[];
9
+ export declare const entries: <T extends Record<import("@waves/ts-types").Long, any>>(obj: T) => [keyof T, T[keyof T]][];
10
+ export declare const values: <T extends Record<import("@waves/ts-types").Long, any>>(obj: T) => T[keyof T][];
11
+ export declare const assign: <T extends Record<import("@waves/ts-types").Long, any>, R extends Record<import("@waves/ts-types").Long, any>>(target: T, merge: R) => T & R;
12
+ export declare const deepAssign: <T extends Record<import("@waves/ts-types").Long, any>[]>(...objects: T) => TUnionToIntersection<T[number]>;
13
+ export declare function map<T, U>(process: (data: T, index: number) => U): (list: Array<T>) => Array<U>;
14
+ export declare function filter<T>(process: (data: T, index: number) => boolean): (list: Array<T>) => Array<T>;
15
+ export declare function filter<T, S extends T>(process: (data: T, index: number) => data is S): (list: Array<T>) => Array<S>;
16
+ export declare function indexBy<T extends Record<string, any>, P extends (data: T) => string | number>(process: (data: T) => T[keyof T], data: Array<T>): Record<ReturnType<P>, T>;
17
+ export declare const uniq: (list: Array<string | null>) => Array<string | null>;
18
+ declare type TChoices = {
19
+ [Key in keyof TransactionMap<TLong>]?: (data: TransactionMap<TLong>[Key]) => any;
20
+ };
21
+ export interface ISwitchTransactionResult<R extends TChoices> {
22
+ <T extends Transaction<TLong>>(tx: T): R[T['type']] extends (data: TransactionMap<TLong>[T['type']]) => infer A ? A : undefined;
23
+ }
24
+ export declare function switchTransactionByType<R extends TChoices>(choices: R): ISwitchTransactionResult<R>;
25
+ export declare const pipe: IPipe;
26
+ export interface IPipe {
27
+ <A, B, R>(a: (data: A) => B, b: (data: B) => R): (a: A) => R;
28
+ <A, B, C, R>(a: (data: A) => B, b: (data: B) => C, c: (data: C) => R): (a: A) => R;
29
+ <A, B, C, D, R>(a: (data: A) => B, b: (data: B) => C, c: (data: C) => D, d: (data: D) => R): (a: A) => R;
30
+ }
31
+ export declare type TUnionToIntersection<U> = (U extends any ? (k: U) => void : never) extends (k: infer I) => void ? I : never;
32
+ export {};