@partisiablockchain/blockchain-api-transaction-client 5.96.0 → 5.102.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 (2) hide show
  1. package/README.md +105 -3
  2. package/package.json +2 -2
package/README.md CHANGED
@@ -1,4 +1,106 @@
1
- # blockchain-client-ts
1
+ # Blockchain Clients
2
2
 
3
- ## Generate client code
4
- The client code can be generated by running `mvn compile` in `java/client`.
3
+ This library contains three different clients for interaction with the Partisia Blockchain. These are
4
+
5
+ - `ChainControllerApi` - Used to get information of contracts and accounts from the blockchain
6
+ - `ShardControllerApi` - Used to get information of blocks and transaction from the blockchain
7
+ - `BlockchainTransactionClient` - Client used to help build, sign, and send transactions to the blockchain
8
+
9
+ The `ChainControllerApi` and `ShardControllerApi` clients are generated from the OpenAPI spec
10
+ found [here](https://reader.partisiablockchain.com/openapi).
11
+ The `BlockchainTransactionClient` is instead built on top of the other clients and uses them to build, sign and send
12
+ transactions.
13
+
14
+ ## ChainControllerApi
15
+
16
+ You can create a `ChainControllerApi` targeting a specific reader url as follows
17
+
18
+ ```ts
19
+ const chainController = new ChainControllerApi(
20
+ new Configuration({basePath: "https://node1.testnet.partisiablockchain.com"})
21
+ );
22
+ ```
23
+
24
+ ### Get generic chain information
25
+
26
+ ```ts
27
+ const chain = await chainController.getChain();
28
+ ```
29
+
30
+ ### Get the latest state of a contract
31
+
32
+ ```ts
33
+ const state = await chainController.getContract({
34
+ address: "02e1e09358e543e8b1cf97d5e19d5b287983cee8f6",
35
+ });
36
+ ```
37
+
38
+ ### Get an AvlTreeMap value from a contract
39
+
40
+ ```ts
41
+ const avlValue = await chainController.getContractAvlValue({
42
+ address: "02e1e09358e543e8b1cf97d5e19d5b287983cee8f6",
43
+ treeId: 0,
44
+ key: "00e72e44eab933faaf1fd4ce94bb57e08bff98a1ed"
45
+ });
46
+ ```
47
+
48
+ ### Get account data
49
+
50
+ ```ts
51
+ const account = await chainController.getAccount({
52
+ address: "02e1e09358e543e8b1cf97d5e19d5b287983cee8f6",
53
+ });
54
+ ```
55
+
56
+ ## ShardControllerApi
57
+
58
+ A `ShardControllerApi` is created the same way as a `ChainControllerApi`
59
+
60
+ ```ts
61
+ const shardController = new ShardControllerApi(
62
+ new Configuration({basePath: "https://node1.testnet.partisiablockchain.com"})
63
+ );
64
+ ```
65
+
66
+ ### Get latest block for a specific shard
67
+
68
+ ```ts
69
+ const block = await shardController.getLatestBlock({shardId: "Shard0"});
70
+ ```
71
+
72
+ ### Get transaction information
73
+
74
+ ```ts
75
+ const transaction = await shardController.getTransaction({
76
+ shardId: "Shard0",
77
+ transactionId: "9356779565b80548a1cd07800d2e2508e530f39cbd7eb71e057acf7bcb18ce0b",
78
+ });
79
+ ```
80
+
81
+ ## BlockchainTransactionClient
82
+
83
+ When creating a transaction client you have to provide a way to generate signature. This is done through the
84
+ interface `SenderAuthentication`. The most basic implementation of this is the `SenderAuthenticationKeyPair` which uses
85
+ a private key to sign with. Other ways to sign includes wallets such as Metamask Snap, or Parti Wallet.
86
+
87
+ ```ts
88
+ const senderAuthentication = SenderAuthenticationKeyPair.fromString(privateKey);
89
+ const transactionSender = BlockchainTransactionClient.create(
90
+ "https://node1.testnet.partisiablockchain.com",
91
+ senderAuthentication
92
+ );
93
+ ```
94
+
95
+ ### Sign and send a transaction
96
+
97
+ ```ts
98
+ const transaction: Transaction = {address: contractAddress, rpc: actionRpc};
99
+ const sentTransaction = await transactionSender.signAndSend(transaction, gasCost);
100
+ ```
101
+
102
+ ### Wait for spawned events of a transaction
103
+
104
+ ```ts
105
+ const transactionTree = await transactionSender.waitForSpawnedEvents(sentTransaction);
106
+ ```
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@partisiablockchain/blockchain-api-transaction-client",
3
- "version": "5.96.0",
3
+ "version": "5.102.0",
4
4
  "description": "",
5
5
  "author": "",
6
6
  "license": "AGPL-3.0",
@@ -23,7 +23,7 @@
23
23
  "eslint-plugin-jsdoc": "^50.0.0",
24
24
  "globals": "^16.0.0",
25
25
  "jest": "^29.7.0",
26
- "prettier": "3.5.2",
26
+ "prettier": "3.5.3",
27
27
  "ts-jest": "^29.1.1",
28
28
  "typescript": "^5.4.5"
29
29
  },