postchain-client 1.5.9 → 1.6.0

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 (68) hide show
  1. package/README.md +53 -4
  2. package/built/cjs/index.js +297 -187
  3. package/built/cjs/index.js.map +1 -1
  4. package/built/esm/index.js +390 -285
  5. package/built/esm/index.js.map +1 -1
  6. package/built/src/ICCF/IccfProofTxMaterialBuilder.d.ts +4 -4
  7. package/built/src/ICCF/IccfProofTxMaterialBuilder.js +15 -15
  8. package/built/src/ICCF/interfaces.d.ts +11 -0
  9. package/built/src/ICCF/interfaces.js +2 -0
  10. package/built/src/ICCF/interfaces.js.map +1 -0
  11. package/built/src/ICCF/utils.d.ts +1 -1
  12. package/built/src/ICCF/utils.js +11 -12
  13. package/built/src/ICCF/utils.js.map +1 -1
  14. package/built/src/blockchainClient/blockchainClient.js +63 -45
  15. package/built/src/blockchainClient/blockchainClient.js.map +1 -1
  16. package/built/src/blockchainClient/errors.d.ts +7 -1
  17. package/built/src/blockchainClient/errors.js +12 -1
  18. package/built/src/blockchainClient/errors.js.map +1 -1
  19. package/built/src/blockchainClient/interface.d.ts +44 -8
  20. package/built/src/blockchainClient/types.d.ts +28 -6
  21. package/built/src/blockchainClient/types.js.map +1 -1
  22. package/built/src/blockchainClient/utils.d.ts +5 -4
  23. package/built/src/blockchainClient/utils.js +51 -34
  24. package/built/src/blockchainClient/utils.js.map +1 -1
  25. package/built/src/chromia/chromiaClientProvider.js +1 -1
  26. package/built/src/chromia/chromiaClientProvider.js.map +1 -1
  27. package/built/src/formatter.d.ts +5 -0
  28. package/built/src/formatter.js +15 -2
  29. package/built/src/formatter.js.map +1 -1
  30. package/built/src/gtx/gtx.d.ts +1 -1
  31. package/built/src/gtx/gtx.js +7 -7
  32. package/built/src/gtx/gtx.js.map +1 -1
  33. package/built/src/gtx/gtxclient.d.ts +1 -1
  34. package/built/src/gtx/gtxclient.js +2 -2
  35. package/built/src/gtx/types.d.ts +3 -3
  36. package/built/src/merkle/binarytree.d.ts +0 -6
  37. package/built/src/merkle/path.d.ts +0 -4
  38. package/built/src/merkle/proof/merkleprooftree.d.ts +0 -6
  39. package/built/src/restclient/enums.d.ts +9 -0
  40. package/built/src/restclient/enums.js +12 -0
  41. package/built/src/restclient/enums.js.map +1 -0
  42. package/built/src/restclient/errors.js +6 -7
  43. package/built/src/restclient/errors.js.map +1 -1
  44. package/built/src/restclient/failoverStrategies.d.ts +5 -0
  45. package/built/src/restclient/failoverStrategies.js +57 -0
  46. package/built/src/restclient/failoverStrategies.js.map +1 -0
  47. package/built/src/restclient/httpUtil.d.ts +2 -1
  48. package/built/src/restclient/httpUtil.js +2 -2
  49. package/built/src/restclient/httpUtil.js.map +1 -1
  50. package/built/src/restclient/restclient.d.ts +1 -1
  51. package/built/src/restclient/restclient.js +8 -6
  52. package/built/src/restclient/restclient.js.map +1 -1
  53. package/built/src/restclient/restclientutil.d.ts +2 -1
  54. package/built/src/restclient/restclientutil.js +14 -19
  55. package/built/src/restclient/restclientutil.js.map +1 -1
  56. package/built/src/restclient/types.d.ts +10 -3
  57. package/built/src/restclient/types.js +0 -5
  58. package/built/src/restclient/types.js.map +1 -1
  59. package/built/umd/index.js +392 -285
  60. package/built/umd/index.js.map +1 -1
  61. package/changelog.md +200 -0
  62. package/package.json +1 -1
  63. package/built/src/chromia/errors.d.ts +0 -3
  64. package/built/src/chromia/errors.js +0 -6
  65. package/built/src/chromia/errors.js.map +0 -1
  66. package/built/test/integration/iccfProofTxIntegration.d.ts +0 -1
  67. package/built/test/integration/iccfProofTxIntegration.js +0 -116
  68. package/built/test/integration/iccfProofTxIntegration.js.map +0 -1
package/README.md CHANGED
@@ -28,7 +28,7 @@ const signerPubKeyB = secp256k1.publicKeyCreate(signerPrivKeyB);
28
28
  Each blockchain has a Blockchain RID (`blockchainRID`) that identifies the specific blockchain we wish to interact with. This blockchainRID should match the Blockchain RID encoded into the first block of the blockchain. How the blockchainRID is structured depends on the blockchain's creator. In this example, we use the Linux command: `echo "A blockchain example"| sha256sum`.
29
29
 
30
30
  ```typescript
31
- const blockchainRID =
31
+ const blockchainRid =
32
32
  "7d565d92fd15bd1cdac2dc276cbcbc5581349d05a9e94ba919e1155ef4daf8f9";
33
33
  ```
34
34
 
@@ -37,7 +37,7 @@ Next, create a Chromia client instance and configure it with a specific set of b
37
37
  ```typescript
38
38
  const chromiaClient = await createClient({
39
39
  nodeURLPool: "http://localhost:7740",
40
- blockchainRID,
40
+ blockchainRid,
41
41
  });
42
42
  ```
43
43
 
@@ -45,10 +45,29 @@ Connecting to a network is achieved through the Directory System Chain. The `dir
45
45
 
46
46
  ```typescript
47
47
  const chromiaClient = await createClient({
48
- directoryNodeURLPool: ["url1", "url2", "url3", "etc."],
49
- blockchainRID,
48
+ directoryNodeUrlPool: ["url1", "url2", "url3", "etc."],
49
+ blockchainRid,
50
50
  });
51
51
  ```
52
+ ### Failover strategies
53
+ When initializing a client, you have the option to configure the failover strategy for the client. Additionally, you can modify certain parameters within the failover configuration, such as the number of attempts per endpoint and the interval between attempts.
54
+
55
+ The Postchain client offers three failover strategies:
56
+ #### Abort On Error
57
+ The request strategy will abort on client error and retry
58
+ on server error. This means that if a client error occurs, such as an
59
+ invalid query parameter, the request strategy will not retry the query.
60
+ However, if a server error occurs, such as a timeout or internal server
61
+ error, the request strategy will retry the query on another node.
62
+
63
+ #### Try Next On Error
64
+ The Try Next On Error request strategy is similar to Abort On Error, but
65
+ will also retry on client error. This means that if a client error
66
+ occurs, the request strategy will retry the query on another node, as
67
+ well as retrying on server error.
68
+
69
+ #### Single Endpoint
70
+ The Single Endpoint request strategy will not retry on another node.
52
71
 
53
72
  ## Queries
54
73
 
@@ -248,7 +267,37 @@ const signatureProviderB = {
248
267
  sign: askUserBToSign,
249
268
  };
250
269
  ```
270
+ ## ICCF
271
+ Creates an [ICCF](https://docs.chromia.com/overview/cross-chain-communication) (Inter-Chain Communication Framework) proof transaction. This function generates a proof that a specific transaction has occurred on the source blockchain. The function returns a transaction object with an operation called iccf_proof and the operation that should be accompanied by the proof should be added to this transaction object. The transaction can then be signed and posted to the target blockchain.
251
272
 
273
+ ```typescript
274
+ const managementBlockchainRid = "7d565d92fd15bd1cdac2dc276cbcbc5581349d05a9e94ba919e1155ef4daf8f9";
275
+
276
+ const chromiaClient = await createClient({
277
+ nodeUrlPool: "<url-node-running-managementchain>",
278
+ managementBlockchainRid,
279
+ });
280
+
281
+ const txToProveRid: Buffer = <txRid>;
282
+ const txToProveHash: Buffer = <txHash>;
283
+ const txToProveSigners: Pubkey[] = [<signer1>, <signer2>];
284
+ const sourceBlockchainRid: string = "<sourceBlockchainRid>";
285
+ const targetBlockchainRid: string = "<targetBlockchainRid>";
286
+
287
+ const { iccfTx, verifiedTx } = createIccfProofTx(chromiaClient, txToProveRID,txToProveHash,txToProveSigners, sourceBlockchainRid, targetBlockchainRid);
288
+ ```
289
+
290
+ `iccfTx` is a transaction object with an operation called `iccf_proof` with argument containing the composed proof. To this transaction object you can now add the operation that will need the proof. Finally, the transaction object is ready to be signed and sent.
291
+
292
+ If necessary, it is possible to solely verify whether a specific transaction has been included in the anchoring blockchain:
293
+ ```typescript
294
+ isBlockAnchored(sourceClient, anchoringClient, txRid);
295
+ ```
296
+
297
+ To create an anchoring client there is an utility function:
298
+ ```typescript
299
+ const anchoringClient = getAnchoringClient()
300
+ ```
252
301
  ## Architecture
253
302
 
254
303
  In the Postchain client, Generic Transactions (GTX) are used to simplify user implementations of Postchain. Users do not need to invent a binary format for their transactions. The client will serialize the function calls, sign them, and send them to Postchain. Read more about GTX in the [docs](https://docs.chromia.com/category/gtx).