@waves/node-api-js 1.3.10-beta.1 → 1.3.10-beta.3

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 +2300 -2300
  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,46 +1,46 @@
1
- import request from '../../tools/request';
2
- /**
3
- * GET /peers/all
4
- * Peer list
5
- */
6
- export function fetchAll(base, options = Object.create(null)) {
7
- return request({
8
- base,
9
- url: '/peers/all',
10
- options
11
- });
12
- }
13
- /**
14
- * GET /peers/connected
15
- * Connected peers list
16
- */
17
- export function fetchConnected(base, options = Object.create(null)) {
18
- return request({
19
- base,
20
- url: '/peers/connected',
21
- options
22
- });
23
- }
24
- /**
25
- * GET /peers/blacklisted
26
- * Blacklisted peers list
27
- */
28
- export function fetchBlackListed(base, options = Object.create(null)) {
29
- return request({
30
- base,
31
- url: '/peers/blacklisted',
32
- options
33
- });
34
- }
35
- /**
36
- * GET /peers/suspended
37
- * Suspended peers list
38
- */
39
- export function fetchSuspended(base, options = Object.create(null)) {
40
- return request({
41
- base,
42
- url: '/peers/suspended',
43
- options
44
- });
45
- }
1
+ import request from '../../tools/request';
2
+ /**
3
+ * GET /peers/all
4
+ * Peer list
5
+ */
6
+ export function fetchAll(base, options = Object.create(null)) {
7
+ return request({
8
+ base,
9
+ url: '/peers/all',
10
+ options
11
+ });
12
+ }
13
+ /**
14
+ * GET /peers/connected
15
+ * Connected peers list
16
+ */
17
+ export function fetchConnected(base, options = Object.create(null)) {
18
+ return request({
19
+ base,
20
+ url: '/peers/connected',
21
+ options
22
+ });
23
+ }
24
+ /**
25
+ * GET /peers/blacklisted
26
+ * Blacklisted peers list
27
+ */
28
+ export function fetchBlackListed(base, options = Object.create(null)) {
29
+ return request({
30
+ base,
31
+ url: '/peers/blacklisted',
32
+ options
33
+ });
34
+ }
35
+ /**
36
+ * GET /peers/suspended
37
+ * Suspended peers list
38
+ */
39
+ export function fetchSuspended(base, options = Object.create(null)) {
40
+ return request({
41
+ base,
42
+ url: '/peers/suspended',
43
+ options
44
+ });
45
+ }
46
46
  //# sourceMappingURL=index.js.map
@@ -1,21 +1,21 @@
1
- import { TLong } from '../../interface';
2
- /**
3
- * GET /blockchain/rewards
4
- * Current reward status
5
- */
6
- export declare function fetchRewards(base: string, height?: number, options?: RequestInit): Promise<TRewards<TLong>>;
7
- export declare type TRewards<LONG> = {
8
- height: number;
9
- totalWavesAmount: LONG;
10
- currentReward: LONG;
11
- minIncrement: LONG;
12
- term: number;
13
- nextCheck: number;
14
- votingIntervalStart: number;
15
- votingInterval: number;
16
- votingThreshold: number;
17
- votes: {
18
- increase: number;
19
- decrease: number;
20
- };
21
- };
1
+ import { TLong } from '../../interface';
2
+ /**
3
+ * GET /blockchain/rewards
4
+ * Current reward status
5
+ */
6
+ export declare function fetchRewards(base: string, height?: number, options?: RequestInit): Promise<TRewards<TLong>>;
7
+ export declare type TRewards<LONG> = {
8
+ height: number;
9
+ totalWavesAmount: LONG;
10
+ currentReward: LONG;
11
+ minIncrement: LONG;
12
+ term: number;
13
+ nextCheck: number;
14
+ votingIntervalStart: number;
15
+ votingInterval: number;
16
+ votingThreshold: number;
17
+ votes: {
18
+ increase: number;
19
+ decrease: number;
20
+ };
21
+ };
@@ -1,13 +1,13 @@
1
- import request from '../../tools/request';
2
- /**
3
- * GET /blockchain/rewards
4
- * Current reward status
5
- */
6
- export function fetchRewards(base, height, options = Object.create(null)) {
7
- return request({
8
- base,
9
- url: height ? `/blockchain/rewards/${height}` : '/blockchain/rewards',
10
- options
11
- });
12
- }
1
+ import request from '../../tools/request';
2
+ /**
3
+ * GET /blockchain/rewards
4
+ * Current reward status
5
+ */
6
+ export function fetchRewards(base, height, options = Object.create(null)) {
7
+ return request({
8
+ base,
9
+ url: height ? `/blockchain/rewards/${height}` : '/blockchain/rewards',
10
+ options
11
+ });
12
+ }
13
13
  //# sourceMappingURL=index.js.map
@@ -1,73 +1,73 @@
1
- import { TTransactionStatuses } from '../../constants';
2
- import { TLong } from '../../interface';
3
- import { RequestInit } from '../../tools/request';
4
- import { SignedTransaction, Transaction, TransactionFromNode, TransactionMap, WithApiMixin } from '@waves/ts-types';
5
- /**
6
- * GET /transactions/unconfirmed/size
7
- * Number of unconfirmed transactions
8
- */
9
- export declare function fetchUnconfirmedSize(base: string): Promise<IUnconfirmedSize>;
10
- interface IUnconfirmedSize {
11
- size: number;
12
- }
13
- /**
14
- * POST /transactions/sign/{signerAddress}
15
- * Sign a transaction with a non-default private key
16
- */
17
- /**
18
- * POST /transactions/calculateFee
19
- * Calculate transaction fee
20
- */
21
- export declare function fetchCalculateFee<T extends keyof TransactionMap<TLong>>(base: string, tx: Partial<TransactionMap<TLong>[T]> & {
22
- type: T;
23
- }, options?: RequestInit): Promise<TFeeInfo>;
24
- export declare type TFeeInfo<LONG = TLong> = {
25
- feeAssetId: string | null;
26
- feeAmount: LONG;
27
- };
28
- /**
29
- * GET /transactions/unconfirmed
30
- * Unconfirmed transactions
31
- */
32
- export declare function fetchUnconfirmed(base: string, options?: RequestInit): Promise<Array<Transaction<TLong> & WithApiMixin>>;
33
- /**
34
- * Список транзакций по адресу
35
- * @param address
36
- * @param limit максимальное количество транзакций в результате
37
- * @param after искать транзакции после ID указанного в after
38
- * @param retry количество попыток на выполнение запроса
39
- */
40
- export declare function fetchTransactions(base: string, address: string, limit: number, after?: string, retry?: number, options?: RequestInit): Promise<Array<TransactionFromNode>>;
41
- /**
42
- * GET /transactions/unconfirmed/info/{id}
43
- * Unconfirmed transaction info
44
- */
45
- export declare function fetchUnconfirmedInfo(base: string, id: string, options?: RequestInit): Promise<Transaction<TLong> & WithApiMixin>;
46
- /**
47
- * POST /transactions/sign
48
- * Sign a transaction
49
- */
50
- /**
51
- * GET /transactions/info/{id}
52
- * Transaction info
53
- */
54
- export declare function fetchInfo(base: string, id: string, options?: RequestInit): Promise<TransactionFromNode>;
55
- /**
56
- * GET /transactions/info/
57
- * Get transactions by IDs
58
- */
59
- export declare function fetchMultipleInfo(base: string, ids: string[], options?: RequestInit): Promise<Array<TransactionFromNode>>;
60
- export declare function fetchStatus(base: string, list: Array<string>): Promise<ITransactionsStatus>;
61
- export interface ITransactionsStatus {
62
- height: number;
63
- statuses: Array<ITransactionStatus>;
64
- }
65
- export interface ITransactionStatus {
66
- id: string;
67
- status: TTransactionStatuses;
68
- inUTX: boolean;
69
- confirmations: number;
70
- height: number;
71
- }
72
- export declare function broadcast<T extends SignedTransaction<Transaction<TLong>>>(base: string, tx: T, options?: RequestInit): Promise<T & WithApiMixin>;
73
- export {};
1
+ import { TTransactionStatuses } from '../../constants';
2
+ import { TLong } from '../../interface';
3
+ import { RequestInit } from '../../tools/request';
4
+ import { SignedTransaction, Transaction, TransactionFromNode, TransactionMap, WithApiMixin } from '@waves/ts-types';
5
+ /**
6
+ * GET /transactions/unconfirmed/size
7
+ * Number of unconfirmed transactions
8
+ */
9
+ export declare function fetchUnconfirmedSize(base: string): Promise<IUnconfirmedSize>;
10
+ interface IUnconfirmedSize {
11
+ size: number;
12
+ }
13
+ /**
14
+ * POST /transactions/sign/{signerAddress}
15
+ * Sign a transaction with a non-default private key
16
+ */
17
+ /**
18
+ * POST /transactions/calculateFee
19
+ * Calculate transaction fee
20
+ */
21
+ export declare function fetchCalculateFee<T extends keyof TransactionMap<TLong>>(base: string, tx: Partial<TransactionMap<TLong>[T]> & {
22
+ type: T;
23
+ }, options?: RequestInit): Promise<TFeeInfo>;
24
+ export declare type TFeeInfo<LONG = TLong> = {
25
+ feeAssetId: string | null;
26
+ feeAmount: LONG;
27
+ };
28
+ /**
29
+ * GET /transactions/unconfirmed
30
+ * Unconfirmed transactions
31
+ */
32
+ export declare function fetchUnconfirmed(base: string, options?: RequestInit): Promise<Array<Transaction<TLong> & WithApiMixin>>;
33
+ /**
34
+ * Список транзакций по адресу
35
+ * @param address
36
+ * @param limit максимальное количество транзакций в результате
37
+ * @param after искать транзакции после ID указанного в after
38
+ * @param retry количество попыток на выполнение запроса
39
+ */
40
+ export declare function fetchTransactions(base: string, address: string, limit: number, after?: string, retry?: number, options?: RequestInit): Promise<Array<TransactionFromNode>>;
41
+ /**
42
+ * GET /transactions/unconfirmed/info/{id}
43
+ * Unconfirmed transaction info
44
+ */
45
+ export declare function fetchUnconfirmedInfo(base: string, id: string, options?: RequestInit): Promise<Transaction<TLong> & WithApiMixin>;
46
+ /**
47
+ * POST /transactions/sign
48
+ * Sign a transaction
49
+ */
50
+ /**
51
+ * GET /transactions/info/{id}
52
+ * Transaction info
53
+ */
54
+ export declare function fetchInfo(base: string, id: string, options?: RequestInit): Promise<TransactionFromNode>;
55
+ /**
56
+ * GET /transactions/info/
57
+ * Get transactions by IDs
58
+ */
59
+ export declare function fetchMultipleInfo(base: string, ids: string[], options?: RequestInit): Promise<Array<TransactionFromNode>>;
60
+ export declare function fetchStatus(base: string, list: Array<string>): Promise<ITransactionsStatus>;
61
+ export interface ITransactionsStatus {
62
+ height: number;
63
+ statuses: Array<ITransactionStatus>;
64
+ }
65
+ export interface ITransactionStatus {
66
+ id: string;
67
+ status: TTransactionStatuses;
68
+ inUTX: boolean;
69
+ confirmations: number;
70
+ height: number;
71
+ }
72
+ export declare function broadcast<T extends SignedTransaction<Transaction<TLong>>>(base: string, tx: T, options?: RequestInit): Promise<T & WithApiMixin>;
73
+ export {};
@@ -1,137 +1,137 @@
1
- import { TRANSACTION_STATUSES } from '../../constants';
2
- import { fetchHeight } from '../blocks';
3
- import request from '../../tools/request';
4
- import query from '../../tools/query';
5
- import { deepAssign } from '../../tools/utils';
6
- import stringify from '../../tools/stringify';
7
- /**
8
- * GET /transactions/unconfirmed/size
9
- * Number of unconfirmed transactions
10
- */
11
- export function fetchUnconfirmedSize(base) {
12
- return request({
13
- base,
14
- url: '/transactions/unconfirmed/size'
15
- });
16
- }
17
- // @TODO: when correct API key is received
18
- /**
19
- * POST /transactions/sign/{signerAddress}
20
- * Sign a transaction with a non-default private key
21
- */
22
- /**
23
- * POST /transactions/calculateFee
24
- * Calculate transaction fee
25
- */
26
- export function fetchCalculateFee(base, tx, options = Object.create(null)) {
27
- return request({
28
- base,
29
- url: '/transactions/calculateFee',
30
- options: deepAssign(Object.assign({}, options), {
31
- method: 'POST',
32
- body: stringify(tx),
33
- headers: {
34
- 'Content-Type': 'application/json'
35
- }
36
- })
37
- });
38
- }
39
- /**
40
- * GET /transactions/unconfirmed
41
- * Unconfirmed transactions
42
- */
43
- export function fetchUnconfirmed(base, options = Object.create(null)) {
44
- return request({
45
- base,
46
- url: '/transactions/unconfirmed',
47
- options
48
- });
49
- }
50
- /**
51
- * Список транзакций по адресу
52
- * @param address
53
- * @param limit максимальное количество транзакций в результате
54
- * @param after искать транзакции после ID указанного в after
55
- * @param retry количество попыток на выполнение запроса
56
- */
57
- export function fetchTransactions(base, address, limit, after, retry, options = Object.create(null)) {
58
- return request({
59
- base,
60
- url: `/transactions/address/${address}/limit/${limit}${query({ after })}`,
61
- options
62
- }).then(([list]) => {
63
- return list;
64
- });
65
- }
66
- /**
67
- * GET /transactions/unconfirmed/info/{id}
68
- * Unconfirmed transaction info
69
- */
70
- export function fetchUnconfirmedInfo(base, id, options = Object.create(null)) {
71
- return request({
72
- base,
73
- url: `/transactions/unconfirmed/info/${id}`,
74
- options
75
- });
76
- }
77
- // @TODO when correct API key is received
78
- /**
79
- * POST /transactions/sign
80
- * Sign a transaction
81
- */
82
- /**
83
- * GET /transactions/info/{id}
84
- * Transaction info
85
- */
86
- export function fetchInfo(base, id, options = Object.create(null)) {
87
- return request({
88
- base,
89
- url: `/transactions/info/${id}`,
90
- options
91
- });
92
- }
93
- /**
94
- * GET /transactions/info/
95
- * Get transactions by IDs
96
- */
97
- export function fetchMultipleInfo(base, ids, options = Object.create(null)) {
98
- return request({
99
- base,
100
- url: `/transactions/info${query({ id: ids })}`,
101
- options
102
- });
103
- }
104
- export function fetchStatus(base, list) {
105
- const DEFAULT_STATUS = {
106
- id: '',
107
- confirmations: -1,
108
- height: -1,
109
- inUTX: false,
110
- status: TRANSACTION_STATUSES.NOT_FOUND
111
- };
112
- const loadAllTxInfo = list.map(id => fetchUnconfirmedInfo(base, id)
113
- .then(() => (Object.assign(Object.assign({}, DEFAULT_STATUS), { id, status: TRANSACTION_STATUSES.UNCONFIRMED, inUTX: true })))
114
- .catch(() => fetchInfo(base, id)
115
- .then(tx => (Object.assign(Object.assign({}, DEFAULT_STATUS), { id, status: TRANSACTION_STATUSES.IN_BLOCKCHAIN, height: tx.height, applicationStatus: tx.applicationStatus }))))
116
- .catch(() => (Object.assign(Object.assign({}, DEFAULT_STATUS), { id }))));
117
- return Promise.all([
118
- fetchHeight(base),
119
- Promise.all(loadAllTxInfo)
120
- ]).then(([{ height }, statuses]) => ({
121
- height,
122
- statuses: statuses.map(item => (Object.assign(Object.assign({}, item), { confirmations: item.status === TRANSACTION_STATUSES.IN_BLOCKCHAIN ? height - item.height : item.confirmations })))
123
- }));
124
- }
125
- export function broadcast(base, tx, options = Object.create(null)) {
126
- return request({
127
- base, url: '/transactions/broadcast',
128
- options: deepAssign(Object.assign({}, options), {
129
- method: 'POST',
130
- body: stringify(tx),
131
- headers: {
132
- 'Content-Type': 'application/json'
133
- }
134
- })
135
- });
136
- }
1
+ import { TRANSACTION_STATUSES } from '../../constants';
2
+ import { fetchHeight } from '../blocks';
3
+ import request from '../../tools/request';
4
+ import query from '../../tools/query';
5
+ import { deepAssign } from '../../tools/utils';
6
+ import stringify from '../../tools/stringify';
7
+ /**
8
+ * GET /transactions/unconfirmed/size
9
+ * Number of unconfirmed transactions
10
+ */
11
+ export function fetchUnconfirmedSize(base) {
12
+ return request({
13
+ base,
14
+ url: '/transactions/unconfirmed/size'
15
+ });
16
+ }
17
+ // @TODO: when correct API key is received
18
+ /**
19
+ * POST /transactions/sign/{signerAddress}
20
+ * Sign a transaction with a non-default private key
21
+ */
22
+ /**
23
+ * POST /transactions/calculateFee
24
+ * Calculate transaction fee
25
+ */
26
+ export function fetchCalculateFee(base, tx, options = Object.create(null)) {
27
+ return request({
28
+ base,
29
+ url: '/transactions/calculateFee',
30
+ options: deepAssign(Object.assign({}, options), {
31
+ method: 'POST',
32
+ body: stringify(tx),
33
+ headers: {
34
+ 'Content-Type': 'application/json'
35
+ }
36
+ })
37
+ });
38
+ }
39
+ /**
40
+ * GET /transactions/unconfirmed
41
+ * Unconfirmed transactions
42
+ */
43
+ export function fetchUnconfirmed(base, options = Object.create(null)) {
44
+ return request({
45
+ base,
46
+ url: '/transactions/unconfirmed',
47
+ options
48
+ });
49
+ }
50
+ /**
51
+ * Список транзакций по адресу
52
+ * @param address
53
+ * @param limit максимальное количество транзакций в результате
54
+ * @param after искать транзакции после ID указанного в after
55
+ * @param retry количество попыток на выполнение запроса
56
+ */
57
+ export function fetchTransactions(base, address, limit, after, retry, options = Object.create(null)) {
58
+ return request({
59
+ base,
60
+ url: `/transactions/address/${address}/limit/${limit}${query({ after })}`,
61
+ options
62
+ }).then(([list]) => {
63
+ return list;
64
+ });
65
+ }
66
+ /**
67
+ * GET /transactions/unconfirmed/info/{id}
68
+ * Unconfirmed transaction info
69
+ */
70
+ export function fetchUnconfirmedInfo(base, id, options = Object.create(null)) {
71
+ return request({
72
+ base,
73
+ url: `/transactions/unconfirmed/info/${id}`,
74
+ options
75
+ });
76
+ }
77
+ // @TODO when correct API key is received
78
+ /**
79
+ * POST /transactions/sign
80
+ * Sign a transaction
81
+ */
82
+ /**
83
+ * GET /transactions/info/{id}
84
+ * Transaction info
85
+ */
86
+ export function fetchInfo(base, id, options = Object.create(null)) {
87
+ return request({
88
+ base,
89
+ url: `/transactions/info/${id}`,
90
+ options
91
+ });
92
+ }
93
+ /**
94
+ * GET /transactions/info/
95
+ * Get transactions by IDs
96
+ */
97
+ export function fetchMultipleInfo(base, ids, options = Object.create(null)) {
98
+ return request({
99
+ base,
100
+ url: `/transactions/info${query({ id: ids })}`,
101
+ options
102
+ });
103
+ }
104
+ export function fetchStatus(base, list) {
105
+ const DEFAULT_STATUS = {
106
+ id: '',
107
+ confirmations: -1,
108
+ height: -1,
109
+ inUTX: false,
110
+ status: TRANSACTION_STATUSES.NOT_FOUND
111
+ };
112
+ const loadAllTxInfo = list.map(id => fetchUnconfirmedInfo(base, id)
113
+ .then(() => (Object.assign(Object.assign({}, DEFAULT_STATUS), { id, status: TRANSACTION_STATUSES.UNCONFIRMED, inUTX: true })))
114
+ .catch(() => fetchInfo(base, id)
115
+ .then(tx => (Object.assign(Object.assign({}, DEFAULT_STATUS), { id, status: TRANSACTION_STATUSES.IN_BLOCKCHAIN, height: tx.height, applicationStatus: tx.applicationStatus }))))
116
+ .catch(() => (Object.assign(Object.assign({}, DEFAULT_STATUS), { id }))));
117
+ return Promise.all([
118
+ fetchHeight(base),
119
+ Promise.all(loadAllTxInfo)
120
+ ]).then(([{ height }, statuses]) => ({
121
+ height,
122
+ statuses: statuses.map(item => (Object.assign(Object.assign({}, item), { confirmations: item.status === TRANSACTION_STATUSES.IN_BLOCKCHAIN ? height - item.height : item.confirmations })))
123
+ }));
124
+ }
125
+ export function broadcast(base, tx, options = Object.create(null)) {
126
+ return request({
127
+ base, url: '/transactions/broadcast',
128
+ options: deepAssign(Object.assign({}, options), {
129
+ method: 'POST',
130
+ body: stringify(tx),
131
+ headers: {
132
+ 'Content-Type': 'application/json'
133
+ }
134
+ })
135
+ });
136
+ }
137
137
  //# sourceMappingURL=index.js.map