postchain-client 2.0.1 → 2.0.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 (74) hide show
  1. package/built/cjs/index.js +99 -25
  2. package/built/cjs/index.js.map +1 -1
  3. package/built/esm/index.js +99 -25
  4. package/built/esm/index.js.map +1 -1
  5. package/built/src/ICCF/IccfProofTxMaterialBuilder.js +1 -1
  6. package/built/src/ICCF/IccfProofTxMaterialBuilder.js.map +1 -1
  7. package/built/src/ICCF/utils.js.map +1 -1
  8. package/built/src/blockchainClient/blockchainClient.js +61 -3
  9. package/built/src/blockchainClient/blockchainClient.js.map +1 -1
  10. package/built/src/blockchainClient/clientStub.js +5 -1
  11. package/built/src/blockchainClient/clientStub.js.map +1 -1
  12. package/built/src/blockchainClient/enums.d.ts +2 -1
  13. package/built/src/blockchainClient/enums.js +1 -0
  14. package/built/src/blockchainClient/enums.js.map +1 -1
  15. package/built/src/blockchainClient/failoverStrategies.js +3 -1
  16. package/built/src/blockchainClient/failoverStrategies.js.map +1 -1
  17. package/built/src/blockchainClient/interface.d.ts +1 -0
  18. package/built/src/blockchainClient/types.d.ts +3 -1
  19. package/built/src/blockchainClient/utils.d.ts +2 -1
  20. package/built/src/blockchainClient/utils.js +15 -13
  21. package/built/src/blockchainClient/utils.js.map +1 -1
  22. package/built/src/gtv/index.js +7 -0
  23. package/built/src/gtv/index.js.map +1 -1
  24. package/built/src/gtx/gtx.d.ts +1 -1
  25. package/built/src/gtx/gtx.js +3 -3
  26. package/built/src/gtx/gtx.js.map +1 -1
  27. package/built/src/utils/constants.d.ts +1 -0
  28. package/built/src/utils/constants.js +1 -0
  29. package/built/src/utils/constants.js.map +1 -1
  30. package/built/test/common/mocks.d.ts +17 -0
  31. package/built/test/common/mocks.js +21 -1
  32. package/built/test/common/mocks.js.map +1 -1
  33. package/built/test/integration/clientGetTransactionStatus.test.js +2 -2
  34. package/built/test/integration/clientGetTransactionStatus.test.js.map +1 -1
  35. package/built/test/integration/clientQuery.test.js +2 -2
  36. package/built/test/integration/clientQuery.test.js.map +1 -1
  37. package/built/test/integration/clientSendTransaction.test.js +1 -1
  38. package/built/test/integration/clientSendTransaction.test.js.map +1 -1
  39. package/built/test/integration/clientSignAndSendUniqueTransaction.test.js +1 -1
  40. package/built/test/integration/clientSignAndSendUniqueTransaction.test.js.map +1 -1
  41. package/built/test/integration/createClientIntegration.test.js +3 -0
  42. package/built/test/integration/createClientIntegration.test.js.map +1 -1
  43. package/built/test/integration/signAndSendUniqueTransaction.test.js +7 -6
  44. package/built/test/integration/signAndSendUniqueTransaction.test.js.map +1 -1
  45. package/built/test/integrationChromiaNetwork/getTransactionConfirmationLevel.test.js +1 -0
  46. package/built/test/integrationChromiaNetwork/getTransactionConfirmationLevel.test.js.map +1 -1
  47. package/built/test/integrationChromiaNetwork/requestWithFailoverStrategy.test.js +4 -3
  48. package/built/test/integrationChromiaNetwork/requestWithFailoverStrategy.test.js.map +1 -1
  49. package/built/test/integrationChromiaNetwork/signAndSendUniqueTransaction.test.js +10 -7
  50. package/built/test/integrationChromiaNetwork/signAndSendUniqueTransaction.test.js.map +1 -1
  51. package/built/test/pcctf/getSuites.test.js +1 -1
  52. package/built/test/pcctf/getSuites.test.js.map +1 -1
  53. package/built/test/pcctf/helpers.js +1 -1
  54. package/built/test/pcctf/helpers.js.map +1 -1
  55. package/built/test/unit/blockchainClient/client.test.js +2 -1
  56. package/built/test/unit/blockchainClient/client.test.js.map +1 -1
  57. package/built/test/unit/blockchainClient/getTransactionConfirmationLevel.test.js +2 -2
  58. package/built/test/unit/blockchainClient/getTransactionConfirmationLevel.test.js.map +1 -1
  59. package/built/test/unit/blockchainClient/sendTransaction.test.js +14 -8
  60. package/built/test/unit/blockchainClient/sendTransaction.test.js.map +1 -1
  61. package/built/test/unit/blockchainClient/statusPollIntervals.test.js +35 -28
  62. package/built/test/unit/blockchainClient/statusPollIntervals.test.js.map +1 -1
  63. package/built/test/unit/failoverStrategies.test.js +15 -14
  64. package/built/test/unit/failoverStrategies.test.js.map +1 -1
  65. package/built/test/unit/gtv/gtvHash.test.js +44 -0
  66. package/built/test/unit/gtv/gtvHash.test.js.map +1 -1
  67. package/built/test/unit/gtx/newSignatureProvider.test.js +4 -4
  68. package/built/test/unit/gtx/newSignatureProvider.test.js.map +1 -1
  69. package/built/test/unit/httpUtil.test.js +4 -0
  70. package/built/test/unit/httpUtil.test.js.map +1 -1
  71. package/built/umd/index.js +99 -25
  72. package/built/umd/index.js.map +1 -1
  73. package/changelog.md +671 -0
  74. package/package.json +1 -1
package/changelog.md ADDED
@@ -0,0 +1,671 @@
1
+ Version 2.0.3
2
+
3
+ # Changelog
4
+
5
+ All notable changes to this project will be documented in this file.
6
+
7
+ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
8
+ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
9
+
10
+ ## [x.x.x]
11
+
12
+ ### Fixed
13
+
14
+ ### Added
15
+
16
+ - node optional field in transaction receipt
17
+ - nodeIdentifierURL optional parameter in createIccfProofTx
18
+
19
+ ### Changed
20
+
21
+ - all createIccfProfTx transactions are now sticky
22
+ - the JS implementation of merkle hash was removed and replaced with a TS implementation contained in the `merklehashts` package
23
+ - merklehash version now has to be explicitly 1 or 2 when calculating hashes
24
+ - the client will retry transactions if they have an iccf proof
25
+
26
+ ### Removed
27
+
28
+ ## [2.0.0]
29
+
30
+ ### Fixed
31
+
32
+ - Fixed a bug of `sendTransaction` that did not consider status polling assignements through `client.config`, but instead, did only considering assignements through `config`
33
+
34
+ ### Added
35
+
36
+ - Support for response headers `X-Transaction-Timestamp`
37
+ - Support for contentType `application/octet-stream` in `GET` requests
38
+ - An optional attribute `transactionTimestamp` to the type `ResponseObject` that is filled through response headers
39
+ - The client function `getWaitingTransactions` that fetches a list of waiting transaction RIDs from a specified blockchain
40
+ - The client function `getWaitingTransaction` that fetches a specific waiting transaction's binary data and the transaction's timestamp from the specified blockchain
41
+ - The client function `getRejectedTransactions` that fetches a list of rejected transactions with their rejection reasons from a specified blockchain
42
+ - The types `WaitingTransaction`, `RejectedTransaction` and `RejectedTransactionResponse`
43
+ - A new zod validation function `isRawGtx` that parses an `unknown` value and returns `value is RawGtx`
44
+ - The zod validation function `validateStatusObject` that parses an `unknown` input and returns `StatusObject` or an error
45
+ - The value `Pending` in the enum `ResponseStatus`, that indicates a `TransactionReceipt` has been created in its initial state, without receiving any confirmation yet from the `Dapp` or `System` clusters.
46
+ - A new zod validation function `isRawGtx` that parses an `unknown` value and returns value is RawGtx
47
+ - The type `GtvExtra`
48
+
49
+ ### Changed
50
+
51
+ - Renamed `StatusObject` to `TransactionStatusReponse`
52
+ - The response type of the function `getTransactionStatus` from `Promise<TransactionReceipt | StatusObject>` to `Promise<StatusObject>`
53
+ - `Web3EventMap` refactored to generic
54
+ - The custom error `UnexpectedStatusError` constructor argument `error` type from `any` to `string | undefined`
55
+ - The client query function `getBlocks` argument `callback` type changed from `TransactionInfo[]` to `BlockInfo[]`
56
+ - The client query function `getBlocksInfo` argument `callback` type changed from `TransactionInfo[]` to `BlockInfo[]`
57
+ - The type `QueryObject` has now a default type of `RawGtv` for `TReturn` and a phantom `_returnType` field to preserve the return type at compile time, without runtime impact
58
+ - The argument `response` of the type `QueryCallback` changed from `TReturn` to `TReturn | null`
59
+ - The function `callbackPromiseBuilder` to use generics `<T, U = T>` for stronger type safety and replaced all `any` type usages with typed parameters
60
+ - The property `rspBody` of the function `handlePostResponsePromisified` was changed from `any` to `RawGtv | null | undefined`
61
+ - Made `handlePostResponse` generic by adding `<T extends RawGtv>` and updated its callback type from `ClientCallback<RawGtv>` to `ClientCallback<T>`
62
+ - The function `convertToPrintable` has now return type of `string`. In addition, the input argument `responseObject` type was changed from `any` to `unknown`
63
+ - The argument `value` type of the function `checkGtvType` from `any` to `unknown`
64
+ - The argument `value` type of the function `checkGtxType` from `any` to `unknown`
65
+ - The argument `obj` type of the function `gtvHash` from `any` to `RawGtv`
66
+ - The custom error `UnexpectedArgumentTypeError` constructor argument `typedArg` type from `any` to `ASNValue`
67
+ - The `gtvExtra` type attribute from `any` to `GtvExtra`
68
+
69
+ ### Removed
70
+
71
+ - The function `signRawTransaction`
72
+ - Moved the function `requestWithFailoverStrategy` from `./failoverStrategies` to `./requestWithFailoverStrategy`
73
+ - The deprecated client function `getTransactionRid`. The function `calculateTransactionRid` that can be found in `src/utils/calculateTransactionRid` should be used instead, to calculate the transaction rid
74
+ - The deprecated client function `getBlocksInfo`. The client function `getBlocks` should be used instead
75
+ - The deprecated client function `encodeTransaction`. The function `encodeTransaction` that can be found in `src/utils/encodeTransaction.ts` should be used instead
76
+ - The deprecated client function `decodeTransactionToGtx`. The function `decodeTransactionToGtx` that can be found in `src/utils/encodeTransaction.ts` should be used instead
77
+ - The type `Web3EventMap` that was used to handle the event types of `Web3EventEmitter`
78
+
79
+ ## [1.22.0]
80
+
81
+ ### Added
82
+
83
+ - The validation functions `isTransactionInfo` and `isTransactionInfoArray`
84
+ - The optional input arguments `afterTime` and `signerPubKey` to the client function `getTransactionsInfo`. These input arguments are used as query parameters for the GET api `/transactions/{blockchainRid}/`
85
+
86
+ ### Fixed
87
+
88
+ - Merkle hash calculation corrected for big arrays
89
+ - Changed logging to warn instead of error when the feature endpoint `/config/{blockchainRid}/features` is not available
90
+
91
+ ## [1.21.1]
92
+
93
+ ### Breaking
94
+
95
+ - The following functions now expect an additional input of `merkleHashVersion`
96
+ - `gtvHash` as its second argument
97
+ - `newSignatureProvider` as its first argument
98
+ - `sign` as its third argument
99
+ - `getDigestToSign` as its second argument
100
+ - `getSystemAnchoringTransaction` as its sixth  argument
101
+ - `getBlockchainRidFromIid` as its fourth argument
102
+ - `chromiaClientProvider` as its third argument
103
+ - `getDigestToSignFromRawGtxBody` as its second argument
104
+ - `createClient` (gtx client) as its fourth argument
105
+ - `calculateBlockRID` as its second argument
106
+ - `calculateTransactionRid` as its second argument
107
+
108
+ ### Fixed
109
+
110
+ - An issue of the `createClient` functions `sendTransaction` and `signAndSendUniqueTransaction` that did performed a directory chain query to `cm_get_blockchain_api_urls` and that was causing local integration tests to fail, as well as local development (when running local nodes)
111
+
112
+ ### Added
113
+
114
+ - The type `ClientConfig` to have a new parameter `merkleHashVersion` that can be used to specify the merkle hash version to be used. If not provided, the function will try to get the merkle hash version from the dapp, by using the feature endpoint `/config/{blockchainRid}/features`.
115
+ - The type `NetworkSettings` was extended and now contains an optional additional attribute `merkleHashVersion`
116
+
117
+ ## [1.21.0]
118
+
119
+ ### Changed
120
+
121
+ - Various input types of `Buffer` or `string` to `BufferId` (`Buffer | string`) for function parameters that expected transaction RIDs or blockchain RIDs. The following functions are affected:
122
+ - `getTransaction` parameter `transactionRid`
123
+ - `getTransactionStatus` parameter `transactionRid`
124
+ - `getTransactionInfo` parameter `transactionRid`
125
+ - `getTransactionConfirmationLevel` parameter `transactionRid`
126
+ - `getConfirmationProof` parameter `txRID`
127
+ - `getClusterAnchoringTransactionConfirmation` parameter `transactionRid`
128
+ - `getSystemAnchoringTransactionConfirmation` parameter `anchoredTxRid`
129
+ - `getGTXFromBufferOrTransactionOrOperation` parameter `blockchainRid`
130
+ - `ConfirmationProofException` constructor parameter `transactionRid`
131
+ - `createIccfProofTx` parameters `txToProveRid`, `sourceBlockchainRid` and `targetBlockchainRid`
132
+ - `getBlockAnchoringTransaction` parameter `txRid`
133
+ - `isBlockAnchored` parameter `txRid`
134
+ - `getAnchoringClient` parameter `dappBlockchainRid`
135
+ - `fetchAndVerifyTransaction` parameter `txToProveRID`
136
+ - `composeProofTransactionObject` parameter `sourceBlockchainRid`
137
+ - The `client` function `getClusterAnchoringTransactionConfirmation` now takes an additional input argument of `anchoringClient`
138
+ - The `client` function `getSystemAnchoringTransactionConfirmation` now takes two additional input arguments of `anchoringClient` and `systemAnchoringChainRid`
139
+ - Changed the response type of the function `getSystemAnchoringChain` to now return `Buffer` instead of `Buffer | null`. The function will instead
140
+ throw a `SystemChainException` instead if `null` is returned from the query, informing the user an invalid client was provided.
141
+ - The `client` function `getClusterAnchoringTransactionConfirmation` now takes an additional input argument of `anchoringClient`
142
+ - The `client` function `getSystemAnchoringTransactionConfirmation` now takes two additional input arguments of `anchoringClient` and `systemAnchoringChainRid`
143
+ - Changed the response type of the function `getSystemAnchoringChain` to now return `Buffer` instead of `Buffer | null`. The function will instead
144
+ throw a `SystemChainException` instead if `null` is returned from the query, informing the user an invalid client was provided.
145
+ - Updated the types `ClientConfig` and `NetworkSettings` to contain separate status polling configurations (interval and count),
146
+ allowing for different polling setups for dapp, cluster and system requests
147
+ - Updated the polling functions `getBlockAnchoringTransaction` and `awaitGetAnchoringTransactionForBlockRid` to receive the correct status polling properties
148
+ - The function `checkDigestSignature` to expect a `Buffer` signature instead of `Buffer` or `undefined`.
149
+
150
+ ### Added
151
+
152
+ - The function `ensureString` that receives a `BufferId` and returns a hex string in upper case
153
+ - Updated the interface `TransactionReceipt` to contain the optional parameters `clusterAnchoringClientBrid` and `systemAnchoringClientBrid` that are populated
154
+ once a transaction is anchored in Cluster Anchoring Chain and System Anchoring Chain
155
+ - The utility function `getAnchoringClientAndSystemChainRid` that returns the type `AnchoringClientAndSystemBrid` providing it with a dapp `client`.
156
+ This utility function should be used to provide the correct inputs for the client functions `clusterAnchoringClientBrid` and `systemAnchoringClientBrid`
157
+ - The type `AnchoringClientAndSystemBrid` that returns an `anchoringClient` and the `systemAnchoringChainBridString`
158
+ - The types `TransactionsCount` and `TransactionConfirmationProof`
159
+ - Several zod validation functions, to be used for the api responses under the type `ResponseObject` and property `rspBody`
160
+ - The function `getSystemAnchoringTransaction` that returns a system anchored transaction or null if the cluster anchoring transaction is not anchored in the system anchoring chain
161
+ - The client function `getAnchoringStatusForBlockRid` that returns `BlockAnchoringState`
162
+ - The type `BlockAnchoringState` to be used as return type for `getAnchoringStatusForBlockRid`
163
+ - Created the utility function `setStatusPolling` that can be used to initialize default status polling properties if not specified
164
+ - The type `StatusPolling` to be used for the dapp, cluster and system polling config in the types `ClientConfig` and `NetworkSettings`
165
+ - Promi event enums `TransactionEvent` with values `ClusterAnchorConfirmed`, `SystemAnchorConfirmed`, `DappConfirmed`, `DappReceived`, `Signed`
166
+ - Promi events are emitted in the order of the transaction lifecycle/confirmation steps
167
+
168
+ ### Fixed
169
+
170
+ - The `client` function `getClusterAnchoringTransactionConfirmation` now takes an additional input argument of `anchoringClient`
171
+ - The `client` function `getSystemAnchoringTransactionConfirmation` now takes two additional input arguments of `anchoringClient` and `systemAnchoringChainRid`
172
+ - Changed the response type of the function `getSystemAnchoringChain` to now return `Buffer` instead of `Buffer | null`. The function will instead
173
+ throw a `SystemChainException` instead if `null` is returned from the query, informing the user an invalid client was provided.
174
+ - Changed the generic `ResponseObject` to a strict type. The property `rspBody` is of type `unknown` and it is validated for each different case
175
+ using zod validation functions for the expected type
176
+ - An issue in the function `checkGTXSignatures` that will now return `false` if the `gtx.signatures` array is empty or not an array
177
+
178
+ ### Removed
179
+
180
+ - The types `GetBlocksResponse` and `GetBlockResponse`
181
+ - The promi event "sent" is no longer emitted
182
+
183
+ ## [1.20.2]
184
+
185
+ ### Fixed
186
+
187
+ - Resolved an issue where retrieving an anchoring transaction and its ICCF proof could result in mismatch if the queries were made against unsynchronized nodes
188
+
189
+ ## [1.20.1]
190
+
191
+ ### Fixed
192
+
193
+ - An issue with the escaping of characters in the generated package.json content of the esm build
194
+ - Added @types/bn.js as runtime dependencies to fix the missing decleration one gets after installing postchain-client and trying to transpile from typescript to javascript
195
+
196
+ ## [1.20.0]
197
+
198
+ ### Added
199
+
200
+ - The function nullable `getTransactionConfirmationLevel` in `createClient` that expects a `transactionRid` and returns a `TransactionReceipt`
201
+ that indicates the last successful confirmation of a transaction, as well as an anchoring transaction if the transaction is added in a block (Cluster Anchoring Confirmation).
202
+ - The function `getClusterAnchoringTransactionConfirmation` in `createClient`, that given a `transactionRid` will return an anchoring transaction
203
+ - Added `rollup-plugin-visualizer` to the Rollup configuration for bundle analysis.
204
+ - Added tests coverage scripts in package.json
205
+ - Created the client function `getSystemAnchoringTransactionConfirmation` that returns a system anchored transaction based on the provided anchored transaction rid
206
+ - Added the util function `getSystemAnchoringChain` that queries the directory client and returns the system anchoring chain rid
207
+ - Extended the logic of the function `sendTransaction`, `signAndSendUniqueTransaction` and `getTransactionConfirmationLevel` to also include system anchoring cluster confirmation
208
+ - Added the type `BufferId = string | Buffer` that also supports `ensureBuffer`
209
+
210
+ ### Fixed
211
+
212
+ - A bug in the function `getAnchoringTransactionForBlockRid` that was not handling nullable response, given the query
213
+ `get_anchoring_transaction_for_block_rid` can return null
214
+ - Moved validation tests from the `src/blockchainClient/validation` to `test/unit/validation`
215
+ - Fixed a bug in the function `getAnchoringClient` that did not set the created client network settings to the one provided as input argument to the function
216
+
217
+ ### Changed
218
+
219
+ - Extended the `createClient` functions `sendTransaction` and `signAndSendUniqueTransaction` to accept a new input parameter `confirmationLevel`
220
+ that will resolve the promise based on the configurable confirmation selection and will emit a “sent” promiEvent with the confirmation status in each confirmation step
221
+ - Extended the parameters of the types `ClientConfig` and `NetworkSettings` to contain `directoryChainRid`
222
+ - Extended the function `getBlockAnchoringTransaction` to retrieve an anchoring transaction with polling
223
+ - Updated the callback type of `getTransactionStatus` to `RestClientCallback<TransactionReceipt> | RestClientCallback<StatusObject>`
224
+ - Updated the callback type of `getTransactionConfirmationLevel` to `RestClientCallback<StatusObject | TransactionReceipt>`
225
+ - Updated the callback type of `getClusterAnchoringTransactionConfirmation` to `RestClientCallback<TransactionReceipt>`
226
+ - Updated the rest client `postTransaction` function, to support binary formatted transactions
227
+
228
+ ## [1.19.1]
229
+
230
+ ### Fixed
231
+
232
+ - bumped secp256k1 dependency to 4.0.4, to fix vulnerability
233
+
234
+ ## [1.19.0]
235
+
236
+ ### Added
237
+
238
+ - added new request strategy `Query Majority`. (See README for more information)
239
+ - new `getBlocks` method that has additional query params to search for blocks
240
+
241
+ ### Fixed
242
+
243
+ - bug in decodeTransactionToGtx that occurs when data has Bigint values
244
+
245
+ ### Deprecated
246
+
247
+ - `getBlocksInfo` method in `IClient` interface. Use `getBlocks` instead.
248
+
249
+ ## [1.18.0]
250
+
251
+ ### Changed
252
+
253
+ - release pipeline
254
+ - replace node.js server with MSW in iccf unit tests
255
+ - replace node.js server with MSW in restClient unit tests
256
+ - replace node.js server with MSW in blockChainClient utils' unit tests
257
+
258
+ ### Added
259
+
260
+ - the possibliity to set `useStickyNode` in the config of `blockchainClient` and `restClient`.
261
+ - release guideline
262
+ - dumpGtx and dumpGtv util functions for debugging purposes. This functions transforms a GTX or GTV object into a human-readable string.
263
+
264
+ ## [1.17.0]
265
+
266
+ ### Added
267
+
268
+ - `getAppStructure` method to `IClient` interface that returns app structure in JSON format
269
+
270
+ ### Changed
271
+
272
+ - Husky will no longer install in CI
273
+ - Added deprecation annotation as a function signature overload for `setLogLevel`
274
+ - pipelines for version release
275
+ - rework ResponseObject and add generic types TData, TErorr to it
276
+ - add RetryRequestProps type to RetryRequest and singleEndpoint methods
277
+
278
+ ### Fixed
279
+
280
+ - typos across all app
281
+ - Updates wrong types for nodeUrl and nodeUrlPool in MissingNodeUrlError
282
+
283
+ ## [1.16.1]
284
+
285
+ ### Added
286
+
287
+ - `convertToRellOperation` is now part of pcl public API
288
+
289
+ ## [1.16.0]
290
+
291
+ ### Changed
292
+
293
+ - Separated non-backend dependent functions from interface `IClient`. Functions `getTransactionRid`, `encodeTransaction`, and `decodeTransactionToGtx` have been extracted and are now separate utility functions.
294
+ - Renamed `getTransactionRid` to `calculateTransactionRid` for clarity. Its input type has been changed to `RawGtxBody`. Conversion functions have been introduced to facilitate this transition.
295
+ - Modified the input type of `encodeTransaction` to `GTX`.
296
+
297
+ - Use PascalCase for types and class names:
298
+ - `getTransactionRidException` -> `GetTransactionRidException`.
299
+ - `transactionInfoInBlockResponse`-> `TransactionInfoInBlockResponse`.
300
+ - `transactionInfoInBlock` -> `TransactionInfoInBlock`.
301
+ - change `npm install` to `npm ci` command
302
+
303
+ - split unit tests for `sendTransaction` to separate file. Replace Express mock server with MSW.
304
+ - rework validation for client and server errors. Now it covers all 4xx and status codes.
305
+ - Replace node server with MSW for unit tests in blockchainClient.test.ts.
306
+
307
+ ### Added
308
+
309
+ - function for fetching information about the latest block for a chain. The funcition is added to the `IClient` interface and is called `getLatestBlock`.
310
+ - verify if changelog changed in pipeline to prevent merging branch without updating it
311
+ - create a custom error which include the http status code. Exported as `CustomError`.
312
+ - automate integration tests to get BRID from running test node.
313
+ - strictNullChecks in tsconfig.json to provide better type checking
314
+
315
+ ### Fixed
316
+
317
+ - bug in retryRequest function which in some cases treated https errors as a successfull request.
318
+
319
+ ## [1.15.2]
320
+
321
+ ### Fixed
322
+
323
+ - promiEvent ts error in npm package
324
+
325
+ ## [1.15.1]
326
+
327
+ ### Changed
328
+
329
+ - Removed library dependency: `web3-core-promievent`.
330
+ - The type `Web3PromiEvent` is now exported publicly.
331
+
332
+ ## [1.15.0]
333
+
334
+ ### Changed
335
+
336
+ - The types `RawGtxBody` and `RawGtxOp`are now exported publicly.
337
+ - function `getDigestToSignFromRawGtxBody`is now exported publicly.
338
+ - Changes `SignatureProvider` type callback method `sign()` to provide a paramater of type `rawGtxBody` instead of a `digest`. This change is implemented to make it possible to review the content of a transaction before signing.
339
+
340
+ ## [1.14.0]
341
+
342
+ ### Added
343
+
344
+ - better input validation for blockChainClient
345
+
346
+ ### Fixed
347
+
348
+ - logLevel=ERROR will now only logs errors
349
+ - getConfirmationProof will now properly retrieve the transaction index
350
+
351
+ ## [1.13.0]
352
+
353
+ ### Added
354
+
355
+ - Both `sendTransaction` and `signAndSendUniqueTransaction` now takes a new flag parameter `doStatusPolling` which can be set to either `true` or `false`. Setting the flag to `false` will prevent any further automatic status polling requests from being sent for the transaction. The method will in this case return with a final transaction status of `waiting`.
356
+ - logLevel can be enum with values: [DEBUG, INFO, WARNING, ERROR]
357
+ - logger can be configured through node env i.e. LOG_LEVEL=DEBUG
358
+ - add `disable` method to logger
359
+ - Adds a `createStubClient` function returning an `IClient`. All methods returning a `Promise` return a rejected `Promise`, all methods which return `Web3PromiEvent` return a rejected `Web3PromiEvent` and other methods just throw an `Error`.
360
+
361
+ ### Fixed
362
+
363
+ - bug in return type of `getAnchoringTransactionForBlockRid`.
364
+ - enhanced the README by providing a more detailed guide on creating a client, including an expanded description of its configuration settings.
365
+
366
+ ## [1.12.0]
367
+
368
+ ### Added
369
+
370
+ - Node URLs in the pool will be marked as 'unreachable' if a request returns a 50\* status. This feature, part of FailoverConfig, suspends a node's usage for a default duration of 30,000 milliseconds (5 minutes). Clients can be configure during initialization for tailored duration.
371
+
372
+ ## [1.11.0]
373
+
374
+ ### Added
375
+
376
+ - Adds client method `getBlockInfo` to enable the user to fetch the data for a single block by providing either `height` or `txRid`.
377
+
378
+ ## [1.10.0]
379
+
380
+ ### Changed
381
+
382
+ - `pollingInterval` has changed name to `statusPollInterval` in `NetworkSettings`. The reason is to easier understand what the polling interval is used for.
383
+ - `sendTransaction` and `signAndSendUniqueTransaction` continue polling the status of the transaction if the last returned status was `unknown`. Previously only status `waiting` triggered new fetching. To avoid polling infinitely, a maximum number has been added. It is configurable when creating a client, see section Added.
384
+ - remove index signature in exported type `GTX`.
385
+
386
+ ```
387
+ export type GTX = {
388
+ [x: string]: unknown; // <---- removed
389
+ blockchainRid: Buffer;
390
+ operations: RellOperation[];
391
+ signers: Buffer[];
392
+ signatures?: Buffer[];
393
+ };
394
+ ```
395
+
396
+ ### Added
397
+
398
+ - possibility to configure the maximum number of times `sendTransaction` and`signAndSendUniqueTransaction` should poll for the status before quitting. It is included in `NetworkSettings` and is called `statusPollCount`. Default value is 20.
399
+
400
+ ### Fixed
401
+
402
+ - `@types/node` as `devDependencies` instead of `dependencies`.
403
+
404
+ ## [1.9.0]
405
+
406
+ ### Added
407
+
408
+ - add the package `events` as peer-dependency. Solves users issue of missing `events` when using the lib in a non Node environment.
409
+ - function in IClient for fetching blocks info for a chain. It is called `getBlocksInfo`.
410
+
411
+ ### Fixed
412
+
413
+ - correct small mistakes in README.
414
+ - fix bug in function `getDigestToSignFromBody`. It should take an input as type `RawGtxBody` instead of `GtxBody`. The function is renamed to `getDigestToSignFromRawGtxBody`.
415
+ - correct mistake in README in the instructions of a function called `askUserBToSign`.
416
+
417
+ ## [1.8.1]
418
+
419
+ ### Fixed
420
+
421
+ - export enum `FailoverStrategy`.
422
+
423
+ ## [1.8.0]
424
+
425
+ ### Changed
426
+
427
+ - Type called `KeyPair` changed from having `pubKey`as optional to being mandatory.
428
+ - `signTransaction` and `signAndSendUniqueTransaction` no longer accept `signMethod` as type `PrivKey`, instead it have to be a `KeyPair` or `SignatureProvider`.
429
+ - Changed plugin `commonJS()` of ESM build-step in `Rollup.config.mjs` to transform mixed modules to ESM modules.
430
+ - Moved up plugin `resolve()` of ESM build-step in `Rollup.config.mjs` to top of plugin list.
431
+
432
+ ### Fixed
433
+
434
+ - randomly pick node from `directoryNodeUrlPool` when querying for the brid of directory chain.
435
+ - `txRejectedError` to have public properties.
436
+
437
+ ## [1.7.1] - 2023-09-28
438
+
439
+ ### Fixed
440
+
441
+ - When using `QueryObject`, you must specify return type.
442
+ - Use type `DictPair` instead of `QueryArguments` alias.
443
+
444
+ ## [1.7.0] - 2023-09-27
445
+
446
+ ### Fixed
447
+
448
+ - Change order of generic types of `query` to `query<TReturn, TArgs>`.
449
+
450
+ ### Added
451
+
452
+ - Generic type of QueryObject, `QueryObject<TReturn, TArgs>`.
453
+
454
+ ## [1.6.0] - 2023-09-22
455
+
456
+ ### Added
457
+
458
+ - `BlockchainUrlUndefinedException` exported.
459
+ - in IClient, `getTransactionsInfo` which fetch info about transactions on the chain.
460
+ - in IClient, `getTransactionInfo` which fetch info about a transaction.
461
+ - in IClient, `getTransactionCount` which fetch number of successful transactions on the chain.
462
+
463
+ ### Fixed
464
+
465
+ - bug in `TxRejectedError`, the error will print the rejection reason if it exist. From the error it is possible to get `shortReason`, `rellLine`, and `operation` (used like `error.operation`).
466
+ - updating to camelCase for the abbreviations. blockchainRID -> blockchainRid.
467
+
468
+ ## [1.5.10] - 2023-09-15
469
+
470
+ ### Added
471
+
472
+ - Ability to choose a failover strategy for a client. The following three are available: `AbortOnError`, `TryNextOnError`, `SingleEndpoint`. A description can be found in the README.
473
+
474
+ ### Fixed
475
+
476
+ - encode txProof and anchroingProof that are included as arguments in iccf_proof operation
477
+ - remove check for only blockchainRid when initialize client, new flow either blockchainRid or blockchainIid need to exist.
478
+
479
+ ## [1.5.9] - 2023-08-30
480
+
481
+ ### Fixed
482
+
483
+ - Set content-type to octet-stream when making post requests
484
+
485
+ ## [1.5.8] - 2023-08-25
486
+
487
+ ### Added
488
+
489
+ - Abillity to check if transaction is anchored, `isBlockAnchored`, `getBlockAnchoringTransaction`,
490
+ - create client configured to anchoring chain, `getAnchoringClient`
491
+ - export ICCF types and errors
492
+ - improved error handling in get requests. When status code is not 200, it returns error
493
+ containing information from servers error message.
494
+
495
+ ## [1.5.7] - 2023-08-15
496
+
497
+ ### Added
498
+
499
+ - Export custom errors
500
+ - ICCF experimental feature, exported function called `createIccfProofTx`
501
+
502
+ ## [1.5.6] - 2023-07-07
503
+
504
+ ### Fixed
505
+
506
+ - Add type `ReadonlyArray<RawGtv>` to union of `RawGtv`
507
+ - uncought promise in send transaction
508
+
509
+ ## [1.5.5] - 2023-07-03
510
+
511
+ ### Fixed
512
+
513
+ - Sort string maps before encoding
514
+ - Because of postchain update, add HTTP header to accept response as binary instead of JSON
515
+
516
+ ## [1.5.4] - 2023-06-28
517
+
518
+ ### Fixed
519
+
520
+ - Explicit import of Buffer
521
+ - Export type IClient
522
+ - Fix bug when using client initialized with blockchainID
523
+
524
+ ## [1.5.3] - 2023-06-22
525
+
526
+ ### Fixed
527
+
528
+ - Buffer as peer dependency
529
+
530
+ ## [1.5.2] - 2023-06-20
531
+
532
+ ### Fixed
533
+
534
+ - Export commonly used types
535
+
536
+ ## [1.5.1] - 2023-06-20
537
+
538
+ ### Fixed
539
+
540
+ - Move lodash from devDependency to dependency
541
+
542
+ ## [1.5.0] - 2023-06-14
543
+
544
+ ### Added
545
+
546
+ - support for negative numbers
547
+
548
+ ## [1.4.0] - 2023-06-14
549
+
550
+ ### Added
551
+
552
+ - simplifyed API, exported as `createClient` from `index.js`, simplifies usage by reducing boilerplate code for users. Its design focuses on streamlining the API and minimizing setup complexities, resulting in a more user-friendly experience.
553
+
554
+ ## [1.3.2] - 2023-04-28
555
+
556
+ ### Fixed
557
+
558
+ - bug when logger prints a bigInt
559
+
560
+ ## [1.3.1] - 2023-04-26
561
+
562
+ ### Fixed
563
+
564
+ - bug when sending big integer in transaction
565
+
566
+ ## [1.3.0] - 2023-04-19
567
+
568
+ ### Added
569
+
570
+ - bigInt support
571
+
572
+ ## [1.2.0] - 2023-03-27
573
+
574
+ ### Added
575
+
576
+ - integration tests for merkle root calculation
577
+
578
+ ### Changed
579
+
580
+ - `newSignatureProvider()` now has keyPair as optional argument. If no keyPair is provided it will instead be generated.
581
+
582
+ ## [1.1.0] - 2023-02-17
583
+
584
+ ### Added
585
+
586
+ - signatureProvider interface and newSignatureProvider()
587
+
588
+ ### Removed
589
+
590
+ - `RestClient.getConfirmationProof` function
591
+
592
+ ### Changed
593
+
594
+ - `ITransaction.sign` now can be used with a single argument, which can implement the signatureProvider interface or be the privKey. This function is now async
595
+ - `GTX.sign` now has two overloads, both of which are async. The GTX is now passed as first parameter.
596
+ - `RestClient.query`and `GtxClient.query` now has two overloads, the new signature takes the query name and query arguments as separate inputs. The old signature is marked as depricated an will be removed in the future.
597
+
598
+ ### Fixed
599
+
600
+ - `gtx` is now correctly typed in both `GTX.sign` and `GTX.addSignature`
601
+
602
+ ## [1.0.3] - 2023-02-03
603
+
604
+ ### Added
605
+
606
+ - Compatible with ESM, CommonJS and UMD
607
+ - Boolean support
608
+
609
+ ### Changed
610
+
611
+ - A query uses postchain endpoint called `query_gtv` which means that data is sent and recieved in GTV-encoded format.
612
+ - Release notes now in changelog file.
613
+ - Node 18 required when using this library in a Node environment.
614
+
615
+ ## [1.0.2] - 2022-12-23
616
+
617
+ ### Added
618
+
619
+ - DecodeValueGtx ensures type of RawGtx before return. (commit missed in last release)
620
+
621
+ ### Changed
622
+
623
+ - Rename export from chromiaClientProvider to chromiaClient.
624
+
625
+ ## [1.0.1] - 2022-12-21
626
+
627
+ ### Changed
628
+
629
+ - Update types of input parameters and return types of the following functions:
630
+
631
+ - encodeValue (serialization.ts)
632
+ - decodeValue (serialization.ts)
633
+ - gtvHash (src/gtv/index.ts)
634
+
635
+ - Set default logging to be less verbose
636
+
637
+ ### Fixed
638
+
639
+ - Bug in function blockchainConnection (chromiaClientProvider.ts)
640
+
641
+ ## [1.0.0] - 2022-12-09
642
+
643
+ ### Added
644
+
645
+ - New logger accessible in index.ts.
646
+ - Enable the client to connect to a blockchain through multiple nodes running the blockchain.
647
+ - Load balancing by randomly distributing transactions and queries between nodes.
648
+ - Retry policy added for request to the blockchain.
649
+ - Enables you to discover the nodes running your blockchain by querying D1 with your dapp´s blockchain RID. Read more in the Chromia client providers [Readme](./src/chromia/README.md).
650
+
651
+ ### Changed
652
+
653
+ - Previously a rest client was initialized with one string containing the address of the node running your blockchain. Now an instance of the rest client is initiated with a list of strings representing the addresses of the nodes where your dapp is running.
654
+ - Previously a rest client query was called with two parameters; queryName and queryObject. Now this call only takes one parameter called queryObject, which is defined as:
655
+
656
+ ```javascript
657
+ {
658
+ type: string;
659
+ [Arg
660
+ :
661
+ string
662
+ ]:
663
+ RawGtv;
664
+ }
665
+ ```
666
+
667
+ where type is what previously was called query name.
668
+
669
+ ## [0.\*.*]
670
+
671
+ Early version of the postchain-client written in javascript.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "postchain-client",
3
- "version": "2.0.1",
3
+ "version": "2.0.3",
4
4
  "main": "built/cjs/index.js",
5
5
  "browser": "built/esm/index.js",
6
6
  "types": "built/index.d.ts",