@zuhaibnoor/zigchain-sdk 1.0.3 → 1.1.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 (185) hide show
  1. package/README.md +1 -1
  2. package/dist/auth/ChainAuthApi.d.ts +0 -3
  3. package/dist/auth/ChainAuthApi.d.ts.map +1 -1
  4. package/dist/auth/ChainAuthApi.js +0 -26
  5. package/dist/auth/ChainAuthApi.js.map +1 -1
  6. package/dist/bank/ChainBankApi.d.ts +0 -9
  7. package/dist/bank/ChainBankApi.d.ts.map +1 -1
  8. package/dist/bank/ChainBankApi.js +0 -18
  9. package/dist/bank/ChainBankApi.js.map +1 -1
  10. package/dist/circuit/ChainCircuitApi.d.ts.map +1 -1
  11. package/dist/circuit/ChainCircuitApi.js.map +1 -1
  12. package/dist/client/http.d.ts +1 -0
  13. package/dist/client/http.d.ts.map +1 -1
  14. package/dist/client/http.js +10 -0
  15. package/dist/client/http.js.map +1 -1
  16. package/dist/dex/ChainDexApi.d.ts.map +1 -1
  17. package/dist/dex/ChainDexApi.js.map +1 -1
  18. package/dist/distribution/ChainDistributionApi.d.ts +47 -0
  19. package/dist/distribution/ChainDistributionApi.d.ts.map +1 -0
  20. package/dist/distribution/ChainDistributionApi.js +74 -0
  21. package/dist/distribution/ChainDistributionApi.js.map +1 -0
  22. package/dist/distribution/types.d.ts +71 -0
  23. package/dist/distribution/types.d.ts.map +1 -0
  24. package/dist/distribution/types.js +2 -0
  25. package/dist/distribution/types.js.map +1 -0
  26. package/dist/evidence/ChainEvidenceApi.d.ts +15 -0
  27. package/dist/evidence/ChainEvidenceApi.d.ts.map +1 -0
  28. package/dist/evidence/ChainEvidenceApi.js +22 -0
  29. package/dist/evidence/ChainEvidenceApi.js.map +1 -0
  30. package/dist/evidence/types.d.ts +15 -0
  31. package/dist/evidence/types.d.ts.map +1 -0
  32. package/dist/evidence/types.js +2 -0
  33. package/dist/evidence/types.js.map +1 -0
  34. package/dist/feegrant/ChainFeegrantApi.d.ts +22 -0
  35. package/dist/feegrant/ChainFeegrantApi.d.ts.map +1 -0
  36. package/dist/feegrant/ChainFeegrantApi.js +32 -0
  37. package/dist/feegrant/ChainFeegrantApi.js.map +1 -0
  38. package/dist/feegrant/types.d.ts +17 -0
  39. package/dist/feegrant/types.d.ts.map +1 -0
  40. package/dist/feegrant/types.js +2 -0
  41. package/dist/feegrant/types.js.map +1 -0
  42. package/dist/ibc/ChainIbcApi.d.ts +55 -0
  43. package/dist/ibc/ChainIbcApi.d.ts.map +1 -0
  44. package/dist/ibc/ChainIbcApi.js +82 -0
  45. package/dist/ibc/ChainIbcApi.js.map +1 -0
  46. package/dist/ibc/ibcChannel/ChainIbcChannelApi.d.ts +55 -0
  47. package/dist/ibc/ibcChannel/ChainIbcChannelApi.d.ts.map +1 -0
  48. package/dist/ibc/ibcChannel/ChainIbcChannelApi.js +82 -0
  49. package/dist/ibc/ibcChannel/ChainIbcChannelApi.js.map +1 -0
  50. package/dist/ibc/ibcChannel/types.d.ts +106 -0
  51. package/dist/ibc/ibcChannel/types.d.ts.map +1 -0
  52. package/dist/ibc/ibcChannel/types.js +2 -0
  53. package/dist/ibc/ibcChannel/types.js.map +1 -0
  54. package/dist/ibc/ibcChannelV2/ChainIbcChannelV2.d.ts +14 -0
  55. package/dist/ibc/ibcChannelV2/ChainIbcChannelV2.d.ts.map +1 -0
  56. package/dist/ibc/ibcChannelV2/ChainIbcChannelV2.js +38 -0
  57. package/dist/ibc/ibcChannelV2/ChainIbcChannelV2.js.map +1 -0
  58. package/dist/ibc/ibcChannelV2/types.d.ts +26 -0
  59. package/dist/ibc/ibcChannelV2/types.d.ts.map +1 -0
  60. package/dist/ibc/ibcChannelV2/types.js +3 -0
  61. package/dist/ibc/ibcChannelV2/types.js.map +1 -0
  62. package/dist/ibc/ibcClient/ChainIbcClientApi.d.ts +15 -0
  63. package/dist/ibc/ibcClient/ChainIbcClientApi.d.ts.map +1 -0
  64. package/dist/ibc/ibcClient/ChainIbcClientApi.js +39 -0
  65. package/dist/ibc/ibcClient/ChainIbcClientApi.js.map +1 -0
  66. package/dist/ibc/ibcClient/types.d.ts +53 -0
  67. package/dist/ibc/ibcClient/types.d.ts.map +1 -0
  68. package/dist/ibc/ibcClient/types.js +2 -0
  69. package/dist/ibc/ibcClient/types.js.map +1 -0
  70. package/dist/ibc/ibcConnection/ChainIbcConnectionApi.d.ts +11 -0
  71. package/dist/ibc/ibcConnection/ChainIbcConnectionApi.d.ts.map +1 -0
  72. package/dist/ibc/ibcConnection/ChainIbcConnectionApi.js +24 -0
  73. package/dist/ibc/ibcConnection/ChainIbcConnectionApi.js.map +1 -0
  74. package/dist/ibc/ibcConnection/types.d.ts +18 -0
  75. package/dist/ibc/ibcConnection/types.d.ts.map +1 -0
  76. package/dist/ibc/ibcConnection/types.js +2 -0
  77. package/dist/ibc/ibcConnection/types.js.map +1 -0
  78. package/dist/ibc/types.d.ts +106 -0
  79. package/dist/ibc/types.d.ts.map +1 -0
  80. package/dist/ibc/types.js +2 -0
  81. package/dist/ibc/types.js.map +1 -0
  82. package/dist/ibc-transfer/ChainIbcTransferApi.d.ts +12 -0
  83. package/dist/ibc-transfer/ChainIbcTransferApi.d.ts.map +1 -0
  84. package/dist/ibc-transfer/ChainIbcTransferApi.js +30 -0
  85. package/dist/ibc-transfer/ChainIbcTransferApi.js.map +1 -0
  86. package/dist/ibc-transfer/types.d.ts +26 -0
  87. package/dist/ibc-transfer/types.d.ts.map +1 -0
  88. package/dist/ibc-transfer/types.js +2 -0
  89. package/dist/ibc-transfer/types.js.map +1 -0
  90. package/dist/index.d.ts +26 -0
  91. package/dist/index.d.ts.map +1 -1
  92. package/dist/index.js +26 -0
  93. package/dist/index.js.map +1 -1
  94. package/dist/interchain-accounts/ChainInterChainAccApi.d.ts +9 -0
  95. package/dist/interchain-accounts/ChainInterChainAccApi.d.ts.map +1 -0
  96. package/dist/interchain-accounts/ChainInterChainAccApi.js +16 -0
  97. package/dist/interchain-accounts/ChainInterChainAccApi.js.map +1 -0
  98. package/dist/interchain-accounts/types.d.ts +12 -0
  99. package/dist/interchain-accounts/types.d.ts.map +1 -0
  100. package/dist/interchain-accounts/types.js +2 -0
  101. package/dist/interchain-accounts/types.js.map +1 -0
  102. package/dist/networks/endpoints.js +2 -2
  103. package/dist/networks/endpoints.js.map +1 -1
  104. package/dist/runtime/ChainRuntimeApi.d.ts +12 -0
  105. package/dist/runtime/ChainRuntimeApi.d.ts.map +1 -0
  106. package/dist/runtime/ChainRuntimeApi.js +16 -0
  107. package/dist/runtime/ChainRuntimeApi.js.map +1 -0
  108. package/dist/runtime/types.d.ts +4 -0
  109. package/dist/runtime/types.d.ts.map +1 -0
  110. package/dist/runtime/types.js +2 -0
  111. package/dist/runtime/types.js.map +1 -0
  112. package/dist/staking/ChainStakingApi.d.ts +1 -5
  113. package/dist/staking/ChainStakingApi.d.ts.map +1 -1
  114. package/dist/staking/ChainStakingApi.js +9 -7
  115. package/dist/staking/ChainStakingApi.js.map +1 -1
  116. package/dist/tokenwrapper/ChainTokenWrapperApi.d.ts +19 -0
  117. package/dist/tokenwrapper/ChainTokenWrapperApi.d.ts.map +1 -0
  118. package/dist/tokenwrapper/ChainTokenWrapperApi.js +26 -0
  119. package/dist/tokenwrapper/ChainTokenWrapperApi.js.map +1 -0
  120. package/dist/tokenwrapper/types.d.ts +15 -0
  121. package/dist/tokenwrapper/types.d.ts.map +1 -0
  122. package/dist/tokenwrapper/types.js +2 -0
  123. package/dist/tokenwrapper/types.js.map +1 -0
  124. package/dist/txs/ChainTxsApi.d.ts +12 -0
  125. package/dist/txs/ChainTxsApi.d.ts.map +1 -0
  126. package/dist/txs/ChainTxsApi.js +17 -0
  127. package/dist/txs/ChainTxsApi.js.map +1 -0
  128. package/dist/txs/types.d.ts +22 -0
  129. package/dist/txs/types.d.ts.map +1 -0
  130. package/dist/txs/types.js +5 -0
  131. package/dist/txs/types.js.map +1 -0
  132. package/dist/upgrade/ChainUpgradeApi.d.ts +22 -0
  133. package/dist/upgrade/ChainUpgradeApi.d.ts.map +1 -0
  134. package/dist/upgrade/ChainUpgradeApi.js +40 -0
  135. package/dist/upgrade/ChainUpgradeApi.js.map +1 -0
  136. package/dist/upgrade/types.d.ts +24 -0
  137. package/dist/upgrade/types.d.ts.map +1 -0
  138. package/dist/upgrade/types.js +5 -0
  139. package/dist/upgrade/types.js.map +1 -0
  140. package/dist/validator-set/ChainCometValidator.d.ts +8 -0
  141. package/dist/validator-set/ChainCometValidator.d.ts.map +1 -0
  142. package/dist/validator-set/ChainCometValidator.js +15 -0
  143. package/dist/validator-set/ChainCometValidator.js.map +1 -0
  144. package/dist/validator-set/ChainValidator.d.ts +8 -0
  145. package/dist/validator-set/ChainValidator.d.ts.map +1 -0
  146. package/dist/validator-set/ChainValidator.js +15 -0
  147. package/dist/validator-set/ChainValidator.js.map +1 -0
  148. package/dist/validator-set/types.d.ts +18 -0
  149. package/dist/validator-set/types.d.ts.map +1 -0
  150. package/dist/validator-set/types.js +2 -0
  151. package/dist/validator-set/types.js.map +1 -0
  152. package/dist/wasm/ChainWasmApi.d.ts +57 -0
  153. package/dist/wasm/ChainWasmApi.d.ts.map +1 -0
  154. package/dist/wasm/ChainWasmApi.js +78 -0
  155. package/dist/wasm/ChainWasmApi.js.map +1 -0
  156. package/dist/wasm/types.d.ts +77 -0
  157. package/dist/wasm/types.d.ts.map +1 -0
  158. package/dist/wasm/types.js +2 -0
  159. package/dist/wasm/types.js.map +1 -0
  160. package/docs/auth.md +438 -72
  161. package/docs/bank.md +782 -123
  162. package/docs/block-results.md +328 -21
  163. package/docs/block.md +325 -38
  164. package/docs/circuit.md +164 -35
  165. package/docs/dex.md +313 -63
  166. package/docs/distribution.md +772 -0
  167. package/docs/evidence.md +194 -0
  168. package/docs/factory.md +308 -62
  169. package/docs/feegrant.md +206 -0
  170. package/docs/gov.md +364 -0
  171. package/docs/ibc/ibcChannel.md +977 -0
  172. package/docs/ibc/ibcClient.md +771 -0
  173. package/docs/ibc/ibcConnection.md +214 -0
  174. package/docs/ibc-transfer.md +463 -0
  175. package/docs/interchain-accounts.md +223 -0
  176. package/docs/mint.md +270 -0
  177. package/docs/runtime.md +120 -0
  178. package/docs/slashing.md +287 -0
  179. package/docs/staking.md +756 -0
  180. package/docs/tokenwrapper.md +294 -0
  181. package/docs/txs.md +447 -0
  182. package/docs/upgrade.md +356 -0
  183. package/docs/validator-set.md +177 -0
  184. package/docs/wasm.md +916 -0
  185. package/package.json +1 -1
package/docs/block.md CHANGED
@@ -1,7 +1,87 @@
1
- # Block Info
1
+ # Block
2
2
 
3
- The **ChainBlockApi** lets you query blockchain blocks and block data.
4
- It is mainly used to fetch the latest block or retrieve a block at a specific height, including historical state queries.
3
+ ## What does this class do?
4
+
5
+ The **Block** provides access to **raw block data** on ZigChain.
6
+
7
+ Every block contains the transactions included in it, the header metadata that links it to the rest of the chain, the validator signatures that committed it, and evidence of any misbehaviour. This class lets you retrieve any of that data by height or fetch the current chain tip.
8
+
9
+ ---
10
+
11
+ ## Important Terminology
12
+
13
+ ### Block
14
+
15
+ A **block** is a sealed, immutable unit of the blockchain. Each block contains an ordered list of transactions, a header with metadata, validator commit signatures, and a link back to the previous block.
16
+
17
+ ---
18
+
19
+ ### Block Height
20
+
21
+ The sequential position of a block in the chain, starting from `1`. Every new block increments the height by one.
22
+
23
+ ```
24
+ height = 2990050
25
+ ```
26
+
27
+ ---
28
+
29
+ ### Block Header
30
+
31
+ Metadata that describes a block and cryptographically links it to the chain. Contains chain ID, timestamps, hashes, and the proposer address.
32
+
33
+ ---
34
+
35
+ ### Block Hash
36
+
37
+ A cryptographic hash uniquely identifying a block. Represented as a Base64-encoded string in responses.
38
+
39
+ ```
40
+ hash = 'r08gjOcW8lS6yGkwecQttOBbLiKP9gjBXOx6GO75B1I='
41
+ ```
42
+
43
+ ---
44
+
45
+ ### Proposer
46
+
47
+ The validator that was selected to propose (create) a given block. Identified by their consensus address.
48
+
49
+ ---
50
+
51
+ ### Transactions (`txs`)
52
+
53
+ Raw Base64-encoded transaction data included in the block.
54
+
55
+ ---
56
+
57
+ ### Last Commit
58
+
59
+ The set of validator signatures that committed the **previous block**. Each signature entry identifies the validator and confirms they voted for that block.
60
+
61
+ ---
62
+
63
+ ### `block` vs `sdk_block`
64
+
65
+ The response contains two representations of the same block:
66
+
67
+ | Field | Description |
68
+ | ----------- | --------------------------------------------------------------------------- |
69
+ | `block` | Raw Tendermint/CometBFT block — proposer address is raw bytes (Base64) |
70
+ | `sdk_block` | Cosmos SDK-enhanced block — proposer address is a bech32 `zigvalcons` address |
71
+
72
+ For most use cases, `sdk_block` is easier to work with because addresses are human-readable.
73
+
74
+ ---
75
+
76
+ ### Block ID Flag
77
+
78
+ Each validator signature in `last_commit.signatures` includes a `block_id_flag` indicating how that validator voted:
79
+
80
+ | Flag | Meaning |
81
+ | ----------------------- | -------------------------------------------- |
82
+ | `BLOCK_ID_FLAG_COMMIT` | Validator signed and committed this block |
83
+ | `BLOCK_ID_FLAG_ABSENT` | Validator did not participate |
84
+ | `BLOCK_ID_FLAG_NIL` | Validator voted nil (no block) |
5
85
 
6
86
  ---
7
87
 
@@ -20,78 +100,285 @@ const blockApi = new ChainBlockApi(endpoints)
20
100
 
21
101
  ---
22
102
 
23
- ## `getLatestBlock`
103
+ # 1️⃣ getBlockByHeight
104
+
105
+ ## Method
24
106
 
25
- Fetch the **latest committed block** on the chain.
26
- You can also query how the latest block looked at a specific historical height.
107
+ ```ts
108
+ async getBlockByHeight(height: number, atHeight?: number)
109
+ ```
27
110
 
28
- **CLI equivalent**
111
+ ## CLI Equivalent
29
112
 
30
113
  ```bash
31
- zigchaind query block
32
- zigchaind query block --height <H>
114
+ zigchaind query block --type=height <height>
115
+ zigchaind query block --type=height <height> --height <H>
33
116
  ```
34
117
 
35
- **Method**
118
+ ---
119
+
120
+ ## Description
121
+
122
+ Fetches the **full block data for a specific block height**.
123
+
124
+ Returns the block header, all raw transactions included in the block, validator commit signatures, and evidence. The response includes both the raw Tendermint representation (`block`) and the Cosmos SDK-enhanced representation (`sdk_block`) with human-readable addresses.
125
+
126
+ The optional `atHeight` parameter allows querying this block as seen from a specific historical chain state — useful for advanced historical state comparisons.
127
+
128
+ ---
129
+
130
+ ## Parameters
131
+
132
+ | Name | Type | Required | Description |
133
+ | -------- | ------ | -------- | ------------------------------------------------------------------------------------ |
134
+ | height | number | ✅ Yes | The block height to fetch |
135
+ | atHeight | number | ❌ No | Query the block from this historical chain state. Omit for latest state. |
136
+
137
+ > ⚠️ Using `atHeight` may fail if the node has pruned state at that height.
138
+
139
+ ---
140
+
141
+ ## Usage Example
142
+
143
+ **Fetch a specific block:**
36
144
 
37
145
  ```ts
38
- getLatestBlock(atHeight?: number)
146
+ const block = await blockApi.getBlockByHeight(2990050)
147
+ console.dir(block, { depth: null })
39
148
  ```
40
149
 
41
- **Example (latest block)**
150
+ **Fetch a block as seen from a historical chain state:**
42
151
 
43
152
  ```ts
44
- const latestBlock = await blockApi.getLatestBlock()
45
- console.log(latestBlock)
153
+ const block = await blockApi.getBlockByHeight(2990050, 3000000)
154
+ console.dir(block, { depth: null })
46
155
  ```
47
156
 
48
- **Example (latest block at a specific height)**
157
+ ## Example Response
49
158
 
50
- ```ts
51
- const latestAtHeight = await blockApi.getLatestBlock(120000)
52
- console.log(latestAtHeight)
159
+ ```json
160
+ {
161
+ "block_id": {
162
+ "hash": "r08gjOcW8lS6yGkwecQttOBbLiKP9gjBXOx6GO75B1I=",
163
+ "part_set_header": {
164
+ "total": 1,
165
+ "hash": "Bg/0BUwDfIUGfmmzD4aPGEoB9UdkY4JIRnWe8P8t+Hc="
166
+ }
167
+ },
168
+ "block": {
169
+ "header": {
170
+ "version": { "block": "11", "app": "0" },
171
+ "chain_id": "zig-test-2",
172
+ "height": "2990050",
173
+ "time": "2025-11-08T22:46:27.230010252Z",
174
+ "proposer_address": "j1fOFWcZJdBrtOxW6WFT42/v65k="
175
+ },
176
+ "data": {
177
+ "txs": [
178
+ "CvADCtYDCiQvY29zbXdhc20ud2FzbS52MS5Nc2dFeGVjdXRlQ29udHJhY3QS..."
179
+ ]
180
+ },
181
+ "evidence": { "evidence": [] },
182
+ "last_commit": {
183
+ "height": "2990049",
184
+ "round": 0,
185
+ "signatures": [
186
+ {
187
+ "block_id_flag": "BLOCK_ID_FLAG_COMMIT",
188
+ "validator_address": "pfDCXVd4xiHCDhc16B4iUyulD7M=",
189
+ "timestamp": "2025-11-08T22:46:27.230010252Z",
190
+ "signature": "R9qDAUn+aLgeZ0l5fAc2..."
191
+ }
192
+ ]
193
+ }
194
+ },
195
+ "sdk_block": {
196
+ "header": {
197
+ "chain_id": "zig-test-2",
198
+ "height": "2990050",
199
+ "time": "2025-11-08T22:46:27.230010252Z",
200
+ "proposer_address": "zigvalcons13atuu9t8ryjaq6a5a3twjc2nudh7l6uemvgmes"
201
+ }
202
+ }
203
+ }
53
204
  ```
54
205
 
206
+ ## Response Field Explanation
207
+
208
+ ### `block_id`
209
+
210
+ | Field | Description |
211
+ | ------------------------ | ---------------------------------------------------- |
212
+ | hash | Base64-encoded hash uniquely identifying this block |
213
+ | part_set_header.total | Number of block parts (always `1` for normal blocks) |
214
+ | part_set_header.hash | Hash of the block part set |
215
+
216
+ ### `block.header` / `sdk_block.header`
217
+
218
+ | Field | Description |
219
+ | -------------------- | --------------------------------------------------------------------- |
220
+ | version.block | CometBFT protocol version |
221
+ | chain_id | Network identifier (e.g. `zig-test-2`) |
222
+ | height | This block's height |
223
+ | time | Timestamp when the block was committed |
224
+ | last_block_id.hash | Hash of the previous block — links the chain together |
225
+ | last_commit_hash | Hash of the previous block's commit signatures |
226
+ | data_hash | Hash of the transactions in this block |
227
+ | validators_hash | Hash of the current validator set |
228
+ | next_validators_hash | Hash of the next block's validator set |
229
+ | app_hash | Application state hash after all transactions were applied |
230
+ | last_results_hash | Hash of the previous block's transaction results |
231
+ | evidence_hash | Hash of any misbehaviour evidence included in this block |
232
+ | proposer_address | In `block`: raw Base64. In `sdk_block`: bech32 `zigvalcons` address |
233
+
234
+ ### `block.data`
235
+
236
+ | Field | Description |
237
+ | ----- | -------------------------------------------------------------------- |
238
+ | txs | Array of raw Base64-encoded transactions included in this block |
239
+
240
+ > An empty `txs` array means the block contained no transactions (an empty block).
241
+
242
+ ### `block.last_commit`
243
+
244
+ | Field | Description |
245
+ | ---------- | -------------------------------------------------------- |
246
+ | height | Height of the block this commit finalised (current - 1) |
247
+ | round | Consensus round in which this block was committed |
248
+ | block_id | Hash reference to the previous block |
249
+ | signatures | Array of validator commit signatures |
250
+
251
+ Each signature entry:
252
+
253
+ | Field | Description |
254
+ | ----------------- | ------------------------------------------------------- |
255
+ | block_id_flag | Validator's vote type (`COMMIT`, `ABSENT`, or `NIL`) |
256
+ | validator_address | Base64-encoded validator consensus address |
257
+ | timestamp | When the validator signed |
258
+ | signature | Base64-encoded cryptographic signature |
259
+
260
+ ## When to Use
261
+
262
+ * Fetching full block contents for a known height
263
+ * Verifying which transactions were included in a block
264
+ * Checking which validators signed a specific block
265
+ * Building block explorer block detail pages
266
+ * Auditing chain state at a specific point in time
267
+
55
268
  ---
56
269
 
57
- ## `getBlockByHeight`
270
+ # 2️⃣ getLatestBlock
271
+
272
+ ## Method
58
273
 
59
- Query a **specific block by its height**.
60
- Optionally, you can query the result from a historical chain state.
274
+ ```ts
275
+ async getLatestBlock(atHeight?: number)
276
+ ```
61
277
 
62
- **CLI equivalent**
278
+ ## CLI Equivalent
63
279
 
64
280
  ```bash
65
- zigchaind query block --type=height <height>
66
- zigchaind query block --type=height <height> --height <H>
281
+ zigchaind query block
282
+ zigchaind query block --height <H>
67
283
  ```
68
284
 
69
- **Method**
285
+ ---
286
+
287
+ ## Description
288
+
289
+ Fetches the **most recently committed block** on the chain.
290
+
291
+ This is the equivalent of checking the current chain tip — it tells you the latest block height, when it was produced, how many transactions it contained, and which validator proposed it.
292
+
293
+ The optional `atHeight` parameter is an advanced option that queries the latest block as seen from a specific historical chain state.
294
+
295
+ ---
296
+
297
+ ## Parameters
298
+
299
+ | Name | Type | Required | Description |
300
+ | -------- | ------ | -------- | ---------------------------------------------------------------------------- |
301
+ | atHeight | number | ❌ No | Query from this historical chain state. Omit to query current latest block. |
302
+
303
+ ---
304
+
305
+ ## Usage Example
306
+
307
+ **Fetch the current latest block:**
70
308
 
71
309
  ```ts
72
- getBlockByHeight(height: number, atHeight?: number)
310
+ const latestBlock = await blockApi.getLatestBlock()
311
+ console.dir(latestBlock, { depth: null })
73
312
  ```
74
313
 
75
- **Example (specific block)**
314
+ **Fetch the latest block as seen from a historical state:**
76
315
 
77
316
  ```ts
78
- const block = await blockApi.getBlockByHeight(150000)
79
- console.log(block)
317
+ const latestAtHeight = await blockApi.getLatestBlock(3000000)
318
+ console.dir(latestAtHeight, { depth: null })
80
319
  ```
81
320
 
82
- **Example (block queried at historical height)**
321
+ ## Example Response
83
322
 
84
- ```ts
85
- const blockAtHeight = await blockApi.getBlockByHeight(150000, 160000)
86
- console.log(blockAtHeight)
323
+ ```json
324
+ {
325
+ "block_id": {
326
+ "hash": "mDilLWqtCONHxux337yRYE8VgZN84E/2I4OQ2av0ysA=",
327
+ "part_set_header": { "total": 1, "hash": "X3COeE3KT8GuDahnnLUXJdabG++b68n+ELxm3OJ1P1g=" }
328
+ },
329
+ "block": {
330
+ "header": {
331
+ "chain_id": "zig-test-2",
332
+ "height": "4600308",
333
+ "time": "2026-02-21T05:56:32.495366040Z",
334
+ "proposer_address": "kf+/IYvD2VICszA7kymoXAyX+y4="
335
+ },
336
+ "data": { "txs": [] },
337
+ "evidence": { "evidence": [] },
338
+ "last_commit": {
339
+ "height": "4600307",
340
+ "round": 0,
341
+ "signatures": [
342
+ {
343
+ "block_id_flag": "BLOCK_ID_FLAG_COMMIT",
344
+ "validator_address": "pfDCXVd4xiHCDhc16B4iUyulD7M=",
345
+ "timestamp": "2026-02-21T05:56:32.495335987Z",
346
+ "signature": "YXHcv+uwO2/qPktnHfSWjCnQ6CU4..."
347
+ }
348
+ ]
349
+ }
350
+ },
351
+ "sdk_block": {
352
+ "header": {
353
+ "chain_id": "zig-test-2",
354
+ "height": "4600308",
355
+ "time": "2026-02-21T05:56:32.495366040Z",
356
+ "proposer_address": "zigvalcons1j8lm7gvtc0v4yq4nxqaex2dgtsxf07ewjvh3rh"
357
+ },
358
+ "data": { "txs": [] }
359
+ }
360
+ }
87
361
  ```
88
362
 
89
- ---
363
+ The response structure is identical to `getBlockByHeight` — refer to that section for the full field-by-field breakdown.
364
+
365
+ ### Quick Reads from the Latest Block
366
+
367
+ Here are the most commonly needed values and where to find them:
368
+
369
+ | Information needed | Field path |
370
+ | --------------------------- | --------------------------------------- |
371
+ | Current block height | `sdk_block.header.height` |
372
+ | Block timestamp | `sdk_block.header.time` |
373
+ | Proposing validator address | `sdk_block.header.proposer_address` |
374
+ | Number of transactions | `sdk_block.data.txs.length` |
375
+ | Chain ID | `sdk_block.header.chain_id` |
90
376
 
91
- ## Notes
377
+ ## When to Use
92
378
 
93
- * Block queries are **read-only** and do not require any wallet.
94
- * Querying at historical heights may fail if the node has pruned old data.
95
- * LCD does **not** support querying blocks by hash (height-based queries only).
379
+ * Getting the current block height and chain tip
380
+ * Checking whether the chain is live and producing blocks
381
+ * Syncing an indexer to the latest state
382
+ * Displaying live block information in dashboards or explorers
96
383
 
97
384
  ---
package/docs/circuit.md CHANGED
@@ -1,7 +1,50 @@
1
1
  # Circuit Module
2
2
 
3
- The **ChainCircuitApi** lets you query **account-level transaction permissions** for the circuit module.
4
- It is mainly used to check which accounts are **blocked or restricted** from sending transactions on the chain.
3
+ ## What is the Circuit Module?
4
+
5
+ The **Circuit module** provides a **transaction permission and circuit breaker** system for ZigChain.
6
+
7
+ It allows designated super-admin accounts to selectively disable specific message types on the chain — acting as an emergency brake. This is a governance and safety mechanism, not something that affects normal users under typical chain operation.
8
+
9
+ ---
10
+
11
+ ## Important Terminology
12
+
13
+ ### Circuit Breaker
14
+
15
+ A **circuit breaker** is a safety mechanism that allows authorized accounts to disable specific transaction types on the chain without requiring a full governance vote. This is used in emergency situations — for example, if a vulnerability is discovered in a particular module.
16
+
17
+ ---
18
+
19
+ ### Permission Level
20
+
21
+ Each account in the circuit module is assigned a **permission level** that defines what authority they have over circuit controls.
22
+
23
+ | Level | Description |
24
+ | ------------------- | --------------------------------------------------------------------------- |
25
+ | `LEVEL_NONE_UNSPECIFIED` | No circuit permissions — standard account |
26
+ | `LEVEL_SOME_MSGS` | Can disable a specific limited set of message types only |
27
+ | `LEVEL_ALL_MSGS` | Can disable any message type on the chain |
28
+ | `LEVEL_SUPER_ADMIN` | Full control — can disable messages and grant/revoke permissions to others |
29
+
30
+ ---
31
+
32
+ ### Limit Type URLs
33
+
34
+ When a permission level is `LEVEL_SOME_MSGS`, the `limit_type_urls` field specifies exactly which message types that account is authorized to circuit-break.
35
+
36
+ An empty `limit_type_urls` combined with `LEVEL_SUPER_ADMIN` means the account has **unrestricted** circuit breaker authority — no specific limits apply.
37
+
38
+ Example of a type URL:
39
+ ```
40
+ /cosmos.bank.v1beta1.MsgSend
41
+ ```
42
+
43
+ ---
44
+
45
+ ### Disabled List
46
+
47
+ The set of message type URLs that are currently disabled (circuit-broken) on the chain. Any transaction containing a disabled message type will be rejected until the circuit is reset.
5
48
 
6
49
  ---
7
50
 
@@ -16,78 +59,164 @@ import {
16
59
 
17
60
  const endpoints = getNetworkEndpoints(Network.Testnet)
18
61
  const circuitApi = new ChainCircuitApi(endpoints)
62
+
63
+ const address = 'zig15yk64u7zc9g9k2yr2wmzeva5qgwxps6y8c2amk'
19
64
  ```
20
65
 
21
66
  ---
22
67
 
23
- ## `getAccountPermissions`
68
+ # 1️⃣ getAccountPermissions
24
69
 
25
- Fetch the **circuit permissions for a specific account**.
70
+ ## Method
71
+
72
+ ```ts
73
+ async getAccountPermissions(address: string)
74
+ ```
26
75
 
27
- **CLI equivalent**
76
+ ## CLI Equivalent
28
77
 
29
78
  ```bash
30
79
  zigchaind query circuit account <address>
31
80
  ```
32
81
 
33
- **Method**
82
+ ## Description
83
+
84
+ Fetches the **circuit breaker permissions** assigned to a specific account.
85
+
86
+ This tells you what level of circuit authority an account holds and, if applicable, which message types they are restricted to controlling. Most regular accounts will have no circuit permissions at all — only specifically designated addresses will appear in the circuit module with elevated levels.
87
+
88
+ ## Parameters
89
+
90
+ | Name | Type | Description |
91
+ | ------- | ------ | ----------------------------------------------------- |
92
+ | address | string | Bech32 address of the account to query permissions for |
93
+
94
+ ## Usage Example
34
95
 
35
96
  ```ts
36
- getAccountPermissions(address: string)
97
+ const account = await circuitApi.getAccountPermissions(address)
98
+ console.dir(account, { depth: null })
37
99
  ```
38
100
 
39
- **Parameters**
101
+ ## Example Response
40
102
 
41
- * `address: string` – The account address to query.
103
+ ```json
104
+ {
105
+ "permission": {
106
+ "level": "LEVEL_SUPER_ADMIN",
107
+ "limit_type_urls": []
108
+ }
109
+ }
110
+ ```
42
111
 
43
- **Returns**
112
+ ## Response Field Explanation
44
113
 
45
- * `CircuitAccountResponse` – Contains whether the account is blocked or restricted.
114
+ ### `permission`
46
115
 
47
- **Example**
116
+ | Field | Description |
117
+ | ---------------- | --------------------------------------------------------------------------------- |
118
+ | level | Permission level assigned to this account |
119
+ | limit_type_urls | Specific message type URLs this account can circuit-break. Empty if unrestricted |
48
120
 
49
- ```ts
50
- const address = 'zig1svkn4sqrlz8r6krq96ty6kze54n2ec03u0vat5'
51
- const permissions = await circuitApi.getAccountPermissions(address)
52
- console.log(`Circuit permissions for ${address}:`)
53
- console.dir(permissions, { depth: null })
54
- ```
121
+ ### Permission Level Values
122
+
123
+ | Value | Meaning |
124
+ | ------------------------ | -------------------------------------------------------------------- |
125
+ | `LEVEL_NONE_UNSPECIFIED` | No circuit permissions |
126
+ | `LEVEL_SOME_MSGS` | Can only circuit-break the specific types listed in `limit_type_urls` |
127
+ | `LEVEL_ALL_MSGS` | Can circuit-break any message type |
128
+ | `LEVEL_SUPER_ADMIN` | Full authority — can circuit-break messages and manage permissions |
129
+
130
+ > In the example above, `LEVEL_SUPER_ADMIN` with an empty `limit_type_urls` means this account has unrestricted circuit breaker authority over the entire chain.
131
+
132
+ ## When to Use
133
+
134
+ * Verifying whether a specific address holds circuit breaker authority
135
+ * Auditing which accounts can perform emergency interventions
136
+ * Security reviews of chain admin key holders
137
+ * Building governance monitoring tools
55
138
 
56
139
  ---
57
140
 
58
- ## `getAllAccountPermissions`
141
+ # 2️⃣ getAllAccountPermissions
142
+
143
+ ## Method
59
144
 
60
- Fetch **all accounts with circuit restrictions or permissions**.
145
+ ```ts
146
+ async getAllAccountPermissions()
147
+ ```
61
148
 
62
- **CLI equivalent**
149
+ ## CLI Equivalent
63
150
 
64
151
  ```bash
65
152
  zigchaind query circuit accounts
66
153
  ```
67
154
 
68
- **Method**
155
+ ## Description
69
156
 
70
- ```ts
71
- getAllAccountPermissions()
72
- ```
157
+ Fetches **all accounts** that have been assigned circuit breaker permissions on the chain.
158
+
159
+ On ZigChain testnet, only one account currently holds circuit permissions (`LEVEL_SUPER_ADMIN`). This reflects the typical setup where circuit authority is granted to a small number of trusted admin addresses for emergency use.
73
160
 
74
- **Returns**
161
+ ## Parameters
75
162
 
76
- * `CircuitAccountsResponse` – Contains a list of all accounts and their circuit permission status.
163
+ None.
77
164
 
78
- **Example**
165
+ ## Usage Example
79
166
 
80
167
  ```ts
81
- const allPermissions = await circuitApi.getAllAccountPermissions()
82
- console.log('All accounts with circuit permissions:')
83
- console.dir(allPermissions, { depth: null })
168
+ const accounts = await circuitApi.getAllAccountPermissions()
169
+ console.dir(accounts, { depth: null })
84
170
  ```
85
171
 
86
- ---
172
+ ## Example Response
173
+
174
+ ```json
175
+ {
176
+ "accounts": [
177
+ {
178
+ "address": "zig15yk64u7zc9g9k2yr2wmzeva5qgwxps6y8c2amk",
179
+ "permissions": {
180
+ "level": "LEVEL_SUPER_ADMIN",
181
+ "limit_type_urls": []
182
+ }
183
+ }
184
+ ],
185
+ "pagination": {
186
+ "next_key": null,
187
+ "total": "1"
188
+ }
189
+ }
190
+ ```
191
+
192
+ ## Response Field Explanation
87
193
 
88
- ## Notes
194
+ ### `accounts`
89
195
 
90
- * Useful for **auditing and monitoring** restricted accounts.
91
- * The `getAllAccountPermissions` method may return large datasets if many accounts are restricted.
196
+ Array of all accounts holding circuit breaker permissions.
92
197
 
198
+ Each entry contains:
93
199
 
200
+ | Field | Description |
201
+ | --------------------------- | ------------------------------------------------------------------------ |
202
+ | address | Bech32 address of the account with circuit permissions |
203
+ | permissions.level | Permission level assigned to this account |
204
+ | permissions.limit_type_urls | Message types this account can control. Empty if unrestricted |
205
+
206
+ ### `pagination`
207
+
208
+ | Field | Description |
209
+ | -------- | -------------------------------------------------------------------- |
210
+ | next_key | Cursor for next page. `null` if all results are returned |
211
+ | total | Total number of accounts with circuit permissions on the chain |
212
+
213
+ > On ZigChain testnet, `total` is `"1"` — only one super admin account exists. A healthy, normally-operating chain will typically have a very small number of circuit-permissioned accounts.
214
+
215
+ ## When to Use
216
+
217
+ * Full audit of all accounts with emergency chain intervention authority
218
+ * Verifying the complete set of circuit admins
219
+ * Chain governance and security dashboards
220
+ * Monitoring for unexpected changes to the circuit permission list
221
+
222
+ ---