@zuhaibnoor/zigchain-sdk 1.1.0 → 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.
- package/README.md +1 -1
- package/dist/circuit/ChainCircuitApi.d.ts.map +1 -1
- package/dist/circuit/ChainCircuitApi.js.map +1 -1
- package/dist/dex/ChainDexApi.d.ts.map +1 -1
- package/dist/dex/ChainDexApi.js.map +1 -1
- package/dist/distribution/ChainDistributionApi.d.ts.map +1 -1
- package/dist/distribution/ChainDistributionApi.js +0 -1
- package/dist/distribution/ChainDistributionApi.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/staking/ChainStakingApi.d.ts +1 -5
- package/dist/staking/ChainStakingApi.d.ts.map +1 -1
- package/dist/staking/ChainStakingApi.js +9 -7
- package/dist/staking/ChainStakingApi.js.map +1 -1
- package/dist/upgrade/ChainUpgradeApi.d.ts.map +1 -1
- package/dist/validator-set/ChainValidator.d.ts +8 -0
- package/dist/validator-set/ChainValidator.d.ts.map +1 -0
- package/dist/validator-set/ChainValidator.js +15 -0
- package/dist/validator-set/ChainValidator.js.map +1 -0
- package/docs/block.md +325 -38
- package/docs/circuit.md +164 -35
- package/docs/dex.md +313 -63
- package/docs/distribution.md +664 -93
- package/docs/evidence.md +117 -122
- package/docs/factory.md +308 -62
- package/docs/gov.md +268 -70
- package/docs/ibc/ibcChannel.md +736 -249
- package/docs/ibc/ibcClient.md +608 -139
- package/docs/ibc-transfer.md +349 -90
- package/docs/interchain-accounts.md +151 -48
- package/docs/mint.md +173 -36
- package/docs/runtime.md +81 -42
- package/docs/slashing.md +209 -61
- package/docs/staking.md +534 -411
- package/docs/tokenwrapper.md +221 -64
- package/docs/txs.md +447 -0
- package/docs/upgrade.md +281 -58
- package/docs/validator-set.md +177 -0
- package/package.json +1 -1
- package/docs/comet-validator-set.md +0 -70
package/docs/upgrade.md
CHANGED
|
@@ -1,18 +1,89 @@
|
|
|
1
1
|
# Upgrade Module
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
## What is the Upgrade Module?
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
This **Upgrade module** allows you to query information about chain upgrades, including:
|
|
6
|
+
|
|
7
|
+
* Current upgrade plans scheduled for the chain
|
|
8
|
+
* Who has authority to schedule upgrades
|
|
9
|
+
* Module versions currently running on the chain
|
|
10
|
+
|
|
11
|
+
Its module is essential for:
|
|
12
|
+
|
|
13
|
+
* Monitoring planned network upgrades
|
|
14
|
+
* Verifying upgrade governance
|
|
15
|
+
* Tracking module versions across the network
|
|
16
|
+
* Planning infrastructure updates
|
|
17
|
+
|
|
18
|
+
---
|
|
19
|
+
|
|
20
|
+
# Important Terminology
|
|
21
|
+
|
|
22
|
+
Before documenting functions, let's define key terms.
|
|
23
|
+
|
|
24
|
+
### Upgrade Plan
|
|
25
|
+
|
|
26
|
+
An **Upgrade Plan** is a scheduled network upgrade that will happen at a specific block height.
|
|
27
|
+
|
|
28
|
+
An upgrade plan contains:
|
|
29
|
+
|
|
30
|
+
* **Name** – Identifier for the upgrade
|
|
31
|
+
* **Height** – Block number when the upgrade takes effect
|
|
32
|
+
* **Info** – Description of what changes
|
|
33
|
+
|
|
34
|
+
Example:
|
|
35
|
+
|
|
36
|
+
```json
|
|
37
|
+
{
|
|
38
|
+
"name": "v2.0.0",
|
|
39
|
+
"height": 5000000,
|
|
40
|
+
"info": "Major network upgrade with new features"
|
|
41
|
+
}
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
⚠️ If no upgrade is currently planned, the plan will be `null`.
|
|
45
|
+
|
|
46
|
+
---
|
|
47
|
+
|
|
48
|
+
### Upgrade Authority
|
|
49
|
+
|
|
50
|
+
The **Upgrade Authority** is the address that has permission to schedule network upgrades.
|
|
51
|
+
|
|
52
|
+
Only this address can propose and approve upgrade plans (via governance).
|
|
53
|
+
|
|
54
|
+
Example:
|
|
55
|
+
|
|
56
|
+
```
|
|
57
|
+
zig10d07y265gmmuvt4z0w9aw880jnsr700jmgkh5m
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
---
|
|
61
|
+
|
|
62
|
+
### Module Version
|
|
63
|
+
|
|
64
|
+
Each **module** running on the chain has a **version number**.
|
|
65
|
+
|
|
66
|
+
Modules are components of the blockchain (e.g., `bank`, `staking`, `auth`).
|
|
67
|
+
|
|
68
|
+
Example module:
|
|
69
|
+
|
|
70
|
+
```json
|
|
71
|
+
{
|
|
72
|
+
"name": "bank",
|
|
73
|
+
"version": "4"
|
|
74
|
+
}
|
|
75
|
+
```
|
|
6
76
|
|
|
7
77
|
---
|
|
8
78
|
|
|
9
|
-
|
|
79
|
+
# Functions Documentation
|
|
10
80
|
|
|
81
|
+
Setup:
|
|
11
82
|
```ts
|
|
12
83
|
import {
|
|
13
84
|
ChainUpgradeApi,
|
|
14
85
|
getNetworkEndpoints,
|
|
15
|
-
Network
|
|
86
|
+
Network
|
|
16
87
|
} from '@zuhaibnoor/zigchain-sdk'
|
|
17
88
|
|
|
18
89
|
const endpoints = getNetworkEndpoints(Network.Testnet)
|
|
@@ -21,113 +92,265 @@ const upgradeApi = new ChainUpgradeApi(endpoints)
|
|
|
21
92
|
|
|
22
93
|
---
|
|
23
94
|
|
|
24
|
-
|
|
95
|
+
# 1️⃣ fetchCurrentPlan
|
|
96
|
+
|
|
97
|
+
## Method
|
|
25
98
|
|
|
26
|
-
|
|
99
|
+
```ts
|
|
100
|
+
async fetchCurrentPlan(): Promise<CurrentPlanResponse>
|
|
101
|
+
```
|
|
27
102
|
|
|
28
|
-
|
|
103
|
+
## CLI Equivalent
|
|
29
104
|
|
|
30
105
|
```bash
|
|
31
106
|
zigchaind query upgrade plan
|
|
32
107
|
```
|
|
33
108
|
|
|
34
|
-
|
|
109
|
+
## Description
|
|
35
110
|
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
111
|
+
Fetches the **current upgrade plan** scheduled on the chain.
|
|
112
|
+
|
|
113
|
+
Returns:
|
|
114
|
+
|
|
115
|
+
* Plan name
|
|
116
|
+
* Target block height
|
|
117
|
+
* Plan description
|
|
39
118
|
|
|
40
|
-
|
|
119
|
+
If no upgrade is planned, returns `plan: null`.
|
|
120
|
+
|
|
121
|
+
## Parameters
|
|
122
|
+
|
|
123
|
+
None.
|
|
124
|
+
|
|
125
|
+
## Usage Example
|
|
41
126
|
|
|
42
127
|
```ts
|
|
43
128
|
const plan = await upgradeApi.fetchCurrentPlan()
|
|
44
129
|
console.dir(plan, { depth: null })
|
|
45
130
|
```
|
|
46
131
|
|
|
132
|
+
## Example Response
|
|
133
|
+
|
|
134
|
+
### When an Upgrade is Planned
|
|
135
|
+
|
|
136
|
+
```json
|
|
137
|
+
{
|
|
138
|
+
"plan": {
|
|
139
|
+
"name": "v2.0.0",
|
|
140
|
+
"time": "0001-01-01T00:00:00Z",
|
|
141
|
+
"height": "5000000",
|
|
142
|
+
"info": "Major network upgrade introducing new governance features and performance improvements",
|
|
143
|
+
"upgraded_client_state": null
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
```
|
|
147
|
+
|
|
148
|
+
### When No Upgrade is Planned
|
|
149
|
+
|
|
150
|
+
```json
|
|
151
|
+
{
|
|
152
|
+
"plan": null
|
|
153
|
+
}
|
|
154
|
+
```
|
|
155
|
+
|
|
156
|
+
## Response Field Explanation
|
|
157
|
+
|
|
158
|
+
### `plan`
|
|
159
|
+
|
|
160
|
+
The upgrade plan object, or `null` if no upgrade is scheduled.
|
|
161
|
+
|
|
162
|
+
If present, contains:
|
|
163
|
+
|
|
164
|
+
| Field | Description |
|
|
165
|
+
| ------------------------ | ---------------------------------------------- |
|
|
166
|
+
| name | Name/identifier of the upgrade |
|
|
167
|
+
| time | Estimated time |
|
|
168
|
+
| height | Block height when upgrade takes effect |
|
|
169
|
+
| info | Human-readable description of changes |
|
|
170
|
+
| upgraded_client_state | IBC client state after upgrade |
|
|
171
|
+
|
|
172
|
+
## When to Use
|
|
173
|
+
|
|
174
|
+
* Monitoring network upgrade schedules
|
|
175
|
+
* Planning infrastructure maintenance
|
|
176
|
+
* Setting up notifications for upcoming upgrades
|
|
177
|
+
* Building chain status dashboards
|
|
178
|
+
* Verifying upgrade timing
|
|
179
|
+
|
|
47
180
|
---
|
|
48
181
|
|
|
49
|
-
|
|
182
|
+
# 2️⃣ fetchAuthority
|
|
50
183
|
|
|
51
|
-
|
|
184
|
+
## Method
|
|
52
185
|
|
|
53
|
-
|
|
186
|
+
```ts
|
|
187
|
+
async fetchAuthority(): Promise<UpgradeAuthorityResponse>
|
|
188
|
+
```
|
|
54
189
|
|
|
55
|
-
|
|
190
|
+
## CLI Equivalent
|
|
56
191
|
|
|
57
192
|
```bash
|
|
58
193
|
zigchaind query upgrade authority
|
|
59
194
|
```
|
|
60
195
|
|
|
61
|
-
|
|
196
|
+
## Description
|
|
62
197
|
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
198
|
+
Fetches the **address with authority to schedule upgrades**.
|
|
199
|
+
|
|
200
|
+
This is the account that can propose and execute upgrade plans through governance.
|
|
66
201
|
|
|
67
|
-
|
|
202
|
+
## Parameters
|
|
203
|
+
|
|
204
|
+
None.
|
|
205
|
+
|
|
206
|
+
## Usage Example
|
|
68
207
|
|
|
69
208
|
```ts
|
|
70
209
|
const authority = await upgradeApi.fetchAuthority()
|
|
71
|
-
console.
|
|
210
|
+
console.dir(authority, { depth: null })
|
|
72
211
|
```
|
|
73
212
|
|
|
74
|
-
|
|
213
|
+
## Example Response
|
|
75
214
|
|
|
76
|
-
|
|
215
|
+
```json
|
|
216
|
+
{
|
|
217
|
+
"address": "zig10d07y265gmmuvt4z0w9aw880jnsr700jmgkh5m"
|
|
218
|
+
}
|
|
219
|
+
```
|
|
77
220
|
|
|
78
|
-
|
|
221
|
+
## Response Field Explanation
|
|
79
222
|
|
|
80
|
-
|
|
223
|
+
| Field | Description |
|
|
224
|
+
| ------- | -------------------------------------------- |
|
|
225
|
+
| address | Bech32 address of the upgrade authority |
|
|
81
226
|
|
|
82
|
-
|
|
227
|
+
## When to Use
|
|
83
228
|
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
229
|
+
* Auditing governance configuration
|
|
230
|
+
* Verifying upgrade permissions
|
|
231
|
+
* Building chain dashboards
|
|
232
|
+
* Security analysis
|
|
233
|
+
* Understanding governance structure
|
|
234
|
+
|
|
235
|
+
---
|
|
236
|
+
|
|
237
|
+
# 3️⃣ fetchModuleVersions
|
|
87
238
|
|
|
88
|
-
|
|
239
|
+
## Method
|
|
89
240
|
|
|
90
241
|
```ts
|
|
91
|
-
fetchModuleVersions()
|
|
242
|
+
async fetchModuleVersions(): Promise<ModuleVersionsResponse>
|
|
92
243
|
```
|
|
93
244
|
|
|
94
|
-
|
|
245
|
+
## CLI Equivalent
|
|
95
246
|
|
|
96
|
-
```
|
|
97
|
-
|
|
98
|
-
console.dir(versions, { depth: null })
|
|
247
|
+
```bash
|
|
248
|
+
zigchaind query upgrade module-versions
|
|
99
249
|
```
|
|
250
|
+
## Description
|
|
100
251
|
|
|
101
|
-
|
|
252
|
+
Fetches the **versions of all modules** running on the chain.
|
|
102
253
|
|
|
103
|
-
|
|
254
|
+
Returns a list of every module with its current version number.
|
|
104
255
|
|
|
105
|
-
|
|
106
|
-
import {
|
|
107
|
-
ChainUpgradeApi,
|
|
108
|
-
getNetworkEndpoints,
|
|
109
|
-
Network
|
|
110
|
-
} from '@zuhaibnoor/zigchain-sdk'
|
|
256
|
+
This helps track which features and improvements are active on the network.
|
|
111
257
|
|
|
112
|
-
|
|
113
|
-
const endpoints = getNetworkEndpoints(Network.Testnet)
|
|
114
|
-
const upgradeApi = new ChainUpgradeApi(endpoints)
|
|
258
|
+
## Parameters
|
|
115
259
|
|
|
116
|
-
|
|
117
|
-
const plan = await upgradeApi.fetchCurrentPlan()
|
|
118
|
-
console.dir(plan, { depth: null })
|
|
260
|
+
None.
|
|
119
261
|
|
|
120
|
-
|
|
121
|
-
const authority = await upgradeApi.fetchAuthority()
|
|
122
|
-
console.log(authority)
|
|
262
|
+
## Usage Example
|
|
123
263
|
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
264
|
+
```ts
|
|
265
|
+
const versions = await upgradeApi.fetchModuleVersions()
|
|
266
|
+
console.dir(versions, { depth: null })
|
|
267
|
+
```
|
|
128
268
|
|
|
129
|
-
|
|
269
|
+
## Example Response
|
|
270
|
+
|
|
271
|
+
```json
|
|
272
|
+
{
|
|
273
|
+
"module_versions": [
|
|
274
|
+
{ "name": "06-solomachine", "version": "0" },
|
|
275
|
+
{ "name": "07-tendermint", "version": "0" },
|
|
276
|
+
{ "name": "auth", "version": "5" },
|
|
277
|
+
{ "name": "authz", "version": "2" },
|
|
278
|
+
{ "name": "bank", "version": "4" },
|
|
279
|
+
{ "name": "circuit", "version": "1" },
|
|
280
|
+
{ "name": "consensus", "version": "1" },
|
|
281
|
+
{ "name": "crisis", "version": "2" },
|
|
282
|
+
{ "name": "dex", "version": "2" },
|
|
283
|
+
{ "name": "distribution", "version": "3" },
|
|
284
|
+
{ "name": "evidence", "version": "1" },
|
|
285
|
+
{ "name": "factory", "version": "2" },
|
|
286
|
+
{ "name": "feegrant", "version": "2" },
|
|
287
|
+
{ "name": "genutil", "version": "1" },
|
|
288
|
+
{ "name": "gov", "version": "5" },
|
|
289
|
+
{ "name": "group", "version": "2" },
|
|
290
|
+
{ "name": "ibc", "version": "8" },
|
|
291
|
+
{ "name": "interchainaccounts", "version": "3" },
|
|
292
|
+
{ "name": "mint", "version": "2" },
|
|
293
|
+
{ "name": "nft", "version": "1" },
|
|
294
|
+
{ "name": "packetfowardmiddleware", "version": "3" },
|
|
295
|
+
{ "name": "params", "version": "1" },
|
|
296
|
+
{ "name": "ratelimit", "version": "1" },
|
|
297
|
+
{ "name": "runtime", "version": "0" },
|
|
298
|
+
{ "name": "slashing", "version": "4" },
|
|
299
|
+
{ "name": "staking", "version": "5" },
|
|
300
|
+
{ "name": "tokenwrapper", "version": "2" },
|
|
301
|
+
{ "name": "transfer", "version": "6" },
|
|
302
|
+
{ "name": "upgrade", "version": "2" },
|
|
303
|
+
{ "name": "vesting", "version": "1" },
|
|
304
|
+
{ "name": "wasm", "version": "4" }
|
|
305
|
+
]
|
|
306
|
+
}
|
|
130
307
|
```
|
|
131
308
|
|
|
309
|
+
## Response Field Explanation
|
|
310
|
+
|
|
311
|
+
### `module_versions`
|
|
312
|
+
|
|
313
|
+
Array of module version objects.
|
|
314
|
+
|
|
315
|
+
Each entry contains:
|
|
316
|
+
|
|
317
|
+
| Field | Description |
|
|
318
|
+
| ------- | ------------------------ |
|
|
319
|
+
| name | Module name/identifier |
|
|
320
|
+
| version | Current version number |
|
|
321
|
+
|
|
322
|
+
|
|
323
|
+
## Common ZigChain Modules
|
|
324
|
+
|
|
325
|
+
| Module Name | Purpose |
|
|
326
|
+
| ------------------------ | ------------------------------------------ |
|
|
327
|
+
| `auth` | Account authentication and management |
|
|
328
|
+
| `authz` | Authorization and delegation |
|
|
329
|
+
| `bank` | Token transfers and balances |
|
|
330
|
+
| `consensus` | Consensus parameters |
|
|
331
|
+
| `dex` | Decentralized exchange |
|
|
332
|
+
| `distribution` | Validator reward distribution |
|
|
333
|
+
| `factory` | Token factory for creating new assets |
|
|
334
|
+
| `gov` | On-chain governance and voting |
|
|
335
|
+
| `group` | Group account management |
|
|
336
|
+
| `ibc` | Inter-Blockchain Communication |
|
|
337
|
+
| `interchainaccounts` | IBC account abstraction |
|
|
338
|
+
| `mint` | Token minting and inflation |
|
|
339
|
+
| `nft` | NFT module |
|
|
340
|
+
| `slashing` | Validator punishment for misbehavior |
|
|
341
|
+
| `staking` | Validator staking and delegation |
|
|
342
|
+
| `transfer` | IBC asset transfers |
|
|
343
|
+
| `upgrade` | Network upgrade management |
|
|
344
|
+
| `wasm` | Smart contracts (WebAssembly) |
|
|
345
|
+
|
|
346
|
+
## When to Use
|
|
347
|
+
|
|
348
|
+
* Checking which features are available on the chain
|
|
349
|
+
* Verifying module compatibility
|
|
350
|
+
* Building chain status dashboards
|
|
351
|
+
* Comparing module versions across networks
|
|
352
|
+
* Planning development based on module versions
|
|
353
|
+
* Auditing chain capabilities
|
|
354
|
+
|
|
132
355
|
---
|
|
133
356
|
|
|
@@ -0,0 +1,177 @@
|
|
|
1
|
+
# Validator Set
|
|
2
|
+
|
|
3
|
+
## What is the Validator Set?
|
|
4
|
+
|
|
5
|
+
The **Validator Set** is the active set of nodes currently responsible for producing and signing blocks on ZigChain.
|
|
6
|
+
|
|
7
|
+
At any given block height, a fixed set of validators participates in consensus. Each validator has a voting power proportional to their stake, and one validator is selected as the **proposer** for each block based on a weighted round-robin algorithm driven by `proposer_priority`.
|
|
8
|
+
|
|
9
|
+
---
|
|
10
|
+
|
|
11
|
+
## Important Terminology
|
|
12
|
+
|
|
13
|
+
### Validator
|
|
14
|
+
|
|
15
|
+
A **validator** is a node actively participating in block production. They are identified here by their **consensus address** (`zigvalcons...`), which is distinct from their operator address (`zigvaloper...`) used in the staking module.
|
|
16
|
+
|
|
17
|
+
---
|
|
18
|
+
|
|
19
|
+
### Consensus Address
|
|
20
|
+
|
|
21
|
+
The `zigvalcons` address is the validator's identity. It is derived from their Ed25519 consensus public key.
|
|
22
|
+
|
|
23
|
+
Example:
|
|
24
|
+
```
|
|
25
|
+
zigvalcons15hcvyh2h0rrzrsswzu67s83z2v462rantszqnx
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
> This is different from the validator's staking operator address (`zigvaloper...`). The consensus address is used for block signing; the operator address is used for staking operations.
|
|
29
|
+
|
|
30
|
+
---
|
|
31
|
+
|
|
32
|
+
### Voting Power
|
|
33
|
+
|
|
34
|
+
A validator's **voting power** is their relative weight in the consensus process. It is proportional to the amount of stake bonded to that validator.
|
|
35
|
+
|
|
36
|
+
---
|
|
37
|
+
|
|
38
|
+
### Proposer Priority
|
|
39
|
+
|
|
40
|
+
An internal numeric value used by CometBFT's weighted round-robin algorithm to determine which validator proposes the next block. It adjusts each round based on voting power — validators with higher voting power propose more frequently.
|
|
41
|
+
|
|
42
|
+
This value oscillates between positive and negative and is not directly meaningful on its own.
|
|
43
|
+
|
|
44
|
+
---
|
|
45
|
+
|
|
46
|
+
### Historical Validator Set
|
|
47
|
+
|
|
48
|
+
The validator set is **not static** — validators can be added or removed via staking and governance. Querying at a specific height shows the exact set that was active at that point in chain history.
|
|
49
|
+
|
|
50
|
+
Comparing the validator set across heights lets you track validator churn — for example, the set at height `4009281` had 7 validators while the set at height `4646865` has 8, indicating a new validator joined during that period.
|
|
51
|
+
|
|
52
|
+
---
|
|
53
|
+
|
|
54
|
+
## Setup
|
|
55
|
+
|
|
56
|
+
```ts
|
|
57
|
+
import {
|
|
58
|
+
ChainValidatorSetApi,
|
|
59
|
+
getNetworkEndpoints,
|
|
60
|
+
Network,
|
|
61
|
+
} from '@zuhaibnoor/zigchain-sdk'
|
|
62
|
+
|
|
63
|
+
const endpoints = getNetworkEndpoints(Network.Testnet)
|
|
64
|
+
const validatorApi = new ChainValidatorSetApi(endpoints)
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
---
|
|
68
|
+
|
|
69
|
+
# 1️⃣ fetchValidatorSet
|
|
70
|
+
|
|
71
|
+
## Method
|
|
72
|
+
|
|
73
|
+
```ts
|
|
74
|
+
async fetchValidatorSet(height?: number | string)
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
## CLI Equivalent
|
|
78
|
+
|
|
79
|
+
```bash
|
|
80
|
+
# Latest validator set
|
|
81
|
+
zigchaind query comet-validator-set
|
|
82
|
+
|
|
83
|
+
# Validator set at a specific height
|
|
84
|
+
zigchaind query comet-validator-set <height>
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
## Description
|
|
88
|
+
|
|
89
|
+
Fetches the **full validator set** — either at the latest block or at a specific historical height.
|
|
90
|
+
|
|
91
|
+
Each entry in the set includes the validator's consensus address, their public key, current voting power, and proposer priority. This is the consensus-layer view of validators, as opposed to the staking-layer view available through the staking module.
|
|
92
|
+
|
|
93
|
+
Omit `height` to get the current active validator set. Pass a height to inspect the set at any past block.
|
|
94
|
+
|
|
95
|
+
## Parameters
|
|
96
|
+
|
|
97
|
+
| Name | Type | Required | Description |
|
|
98
|
+
| ------ | ---------------- | -------- | --------------------------------------------------------- |
|
|
99
|
+
| height | number \| string | ❌ No | Block height to query. Omit for the latest validator set. |
|
|
100
|
+
|
|
101
|
+
## Usage Example
|
|
102
|
+
|
|
103
|
+
**Latest validator set:**
|
|
104
|
+
|
|
105
|
+
```ts
|
|
106
|
+
const validatorSet = await validatorApi.fetchValidatorSet()
|
|
107
|
+
console.dir(validatorSet, { depth: null })
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
**Validator set at a specific height:**
|
|
111
|
+
|
|
112
|
+
```ts
|
|
113
|
+
const validatorSetAtHeight = await validatorApi.fetchValidatorSet('4009281')
|
|
114
|
+
console.dir(validatorSetAtHeight, { depth: null })
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
## Example Response
|
|
118
|
+
|
|
119
|
+
```json
|
|
120
|
+
{
|
|
121
|
+
"block_height": "4646865",
|
|
122
|
+
"validators": [
|
|
123
|
+
{
|
|
124
|
+
"address": "zigvalcons15hcvyh2h0rrzrsswzu67s83z2v462rantszqnx",
|
|
125
|
+
"pub_key": {
|
|
126
|
+
"@type": "/cosmos.crypto.ed25519.PubKey",
|
|
127
|
+
"key": "f+akljJ8Y0dKwWz3bKkRN+RDz9EM+yA/j7Gre+Hn02c="
|
|
128
|
+
},
|
|
129
|
+
"voting_power": "25350158",
|
|
130
|
+
"proposer_priority": "17577896"
|
|
131
|
+
},
|
|
132
|
+
{
|
|
133
|
+
"address": "zigvalcons13atuu9t8ryjaq6a5a3twjc2nudh7l6uemvgmes",
|
|
134
|
+
"pub_key": {
|
|
135
|
+
"@type": "/cosmos.crypto.ed25519.PubKey",
|
|
136
|
+
"key": "SBjHwAbgG2ZfZtbBMJgcr+z+S/2BuPQZROVLnvS4QHM="
|
|
137
|
+
},
|
|
138
|
+
"voting_power": "25227820",
|
|
139
|
+
"proposer_priority": "28755507"
|
|
140
|
+
}
|
|
141
|
+
],
|
|
142
|
+
"pagination": {
|
|
143
|
+
"next_key": null,
|
|
144
|
+
"total": "8"
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
```
|
|
148
|
+
|
|
149
|
+
## Response Field Explanation
|
|
150
|
+
|
|
151
|
+
### Top-level fields
|
|
152
|
+
|
|
153
|
+
| Field | Description |
|
|
154
|
+
| ------------ | ---------------------------------------------------- |
|
|
155
|
+
| block_height | The block height this validator set corresponds to |
|
|
156
|
+
| validators | Array of all active validators at this height |
|
|
157
|
+
| pagination | Pagination info for the validator list |
|
|
158
|
+
|
|
159
|
+
### `validators[]` — Per-Validator Entry
|
|
160
|
+
|
|
161
|
+
| Field | Description |
|
|
162
|
+
| ----------------- | ------------------------------------------------------------------------ |
|
|
163
|
+
| address | Validator's consensus address (`zigvalcons...`) |
|
|
164
|
+
| pub_key.@type | Cryptographic key type — always `ed25519` for CometBFT validators |
|
|
165
|
+
| pub_key.key | Base64-encoded Ed25519 public key used for block signing |
|
|
166
|
+
| voting_power | Validator's weighted vote in consensus, proportional to bonded stake |
|
|
167
|
+
| proposer_priority | Internal CometBFT value used to select the next block proposer |
|
|
168
|
+
|
|
169
|
+
---
|
|
170
|
+
|
|
171
|
+
## When to Use
|
|
172
|
+
|
|
173
|
+
* Displaying the active validator set in a block explorer
|
|
174
|
+
* Checking current voting power distribution
|
|
175
|
+
* Tracking validator set changes over time
|
|
176
|
+
* Verifying which validators were active at a specific block
|
|
177
|
+
---
|
package/package.json
CHANGED
|
@@ -1,70 +0,0 @@
|
|
|
1
|
-
# Comet Validator Set Module
|
|
2
|
-
|
|
3
|
-
The **Comet Validator Set** module allows you to query the **full CometBFT validator set** on ZigChain.
|
|
4
|
-
|
|
5
|
-
Think of it as a way to see **all the nodes that are currently validating blocks** at any given height.
|
|
6
|
-
|
|
7
|
-
---
|
|
8
|
-
|
|
9
|
-
## Setup
|
|
10
|
-
|
|
11
|
-
```ts
|
|
12
|
-
import {
|
|
13
|
-
ChainCometValidatorSetApi,
|
|
14
|
-
getNetworkEndpoints,
|
|
15
|
-
Network
|
|
16
|
-
} from '@zuhaibnoor/zigchain-sdk'
|
|
17
|
-
|
|
18
|
-
const endpoints = getNetworkEndpoints(Network.Testnet)
|
|
19
|
-
const validatorApi = new ChainCometValidatorSetApi(endpoints)
|
|
20
|
-
```
|
|
21
|
-
|
|
22
|
-
---
|
|
23
|
-
|
|
24
|
-
## `fetchValidatorSet(height?: number)`
|
|
25
|
-
|
|
26
|
-
### What it does
|
|
27
|
-
|
|
28
|
-
Fetches the **full list of validators** for a specific block height.
|
|
29
|
-
|
|
30
|
-
* If `height` is **not provided**, it returns the **latest validator set**.
|
|
31
|
-
* If `height` is provided, it returns the **validator set at that block height**.
|
|
32
|
-
|
|
33
|
-
---
|
|
34
|
-
|
|
35
|
-
### Validator Info
|
|
36
|
-
|
|
37
|
-
Each validator object contains:
|
|
38
|
-
|
|
39
|
-
* `operator_address` → the validator’s address
|
|
40
|
-
* `consensus_pubkey` → their public key used for block signing
|
|
41
|
-
* `voting_power` → the validator’s current voting weight
|
|
42
|
-
* `proposer_priority` → used internally to determine which validator proposes the next block
|
|
43
|
-
|
|
44
|
-
---
|
|
45
|
-
|
|
46
|
-
### CLI Equivalent
|
|
47
|
-
|
|
48
|
-
```bash
|
|
49
|
-
# Latest validator set
|
|
50
|
-
zigchaind query comet-validator-set
|
|
51
|
-
|
|
52
|
-
# Validator set at specific height
|
|
53
|
-
zigchaind query comet-validator-set <height>
|
|
54
|
-
```
|
|
55
|
-
|
|
56
|
-
---
|
|
57
|
-
|
|
58
|
-
### Example
|
|
59
|
-
|
|
60
|
-
```ts
|
|
61
|
-
// Latest validator set
|
|
62
|
-
const latestValidators = await validatorApi.fetchValidatorSet()
|
|
63
|
-
console.dir(latestValidators, { depth: null })
|
|
64
|
-
|
|
65
|
-
// Validator set at height 2990010
|
|
66
|
-
const validatorsAtHeight = await validatorApi.fetchValidatorSet(2990010)
|
|
67
|
-
console.dir(validatorsAtHeight, { depth: null })
|
|
68
|
-
```
|
|
69
|
-
|
|
70
|
-
---
|