@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/gov.md
CHANGED
|
@@ -1,7 +1,82 @@
|
|
|
1
|
-
# Governance Module
|
|
1
|
+
# Governance (Gov) Module
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
3
|
+
## What is the Gov Module?
|
|
4
|
+
|
|
5
|
+
The **Governance (Gov) module** enables **on-chain decision making** on ZigChain.
|
|
6
|
+
|
|
7
|
+
It allows token holders to:
|
|
8
|
+
|
|
9
|
+
* Submit proposals
|
|
10
|
+
* Deposit tokens to activate proposals
|
|
11
|
+
* Vote on proposals
|
|
12
|
+
* Update critical chain parameters
|
|
13
|
+
|
|
14
|
+
Governance is how ZigChain evolves — parameter changes, validator set updates and other core settings are modified through this module.
|
|
15
|
+
|
|
16
|
+
---
|
|
17
|
+
|
|
18
|
+
## Governance Flow (High Level)
|
|
19
|
+
|
|
20
|
+
1. A proposer submits a proposal
|
|
21
|
+
2. Deposits are collected
|
|
22
|
+
3. Voting period begins
|
|
23
|
+
4. Validators & delegators vote
|
|
24
|
+
5. Tally is calculated
|
|
25
|
+
6. Proposal is **Passed** or **Rejected**
|
|
26
|
+
7. If passed → state changes are executed automatically
|
|
27
|
+
|
|
28
|
+
---
|
|
29
|
+
|
|
30
|
+
## Important Terminology
|
|
31
|
+
|
|
32
|
+
### Proposal
|
|
33
|
+
|
|
34
|
+
A **proposal** is a request to modify the chain state.
|
|
35
|
+
|
|
36
|
+
Each proposal contains:
|
|
37
|
+
|
|
38
|
+
* `messages` → The actual state-changing messages (e.g., `MsgUpdateParams`)
|
|
39
|
+
* `title` and `summary`
|
|
40
|
+
* Voting period timestamps
|
|
41
|
+
* Final tally result
|
|
42
|
+
* Status
|
|
43
|
+
|
|
44
|
+
---
|
|
45
|
+
|
|
46
|
+
### Proposal Status
|
|
47
|
+
|
|
48
|
+
| Status | Meaning |
|
|
49
|
+
| -------------------------------- | -------------------------- |
|
|
50
|
+
| `PROPOSAL_STATUS_DEPOSIT_PERIOD` | Waiting for enough deposit |
|
|
51
|
+
| `PROPOSAL_STATUS_VOTING_PERIOD` | Voting is ongoing |
|
|
52
|
+
| `PROPOSAL_STATUS_PASSED` | Approved and executed |
|
|
53
|
+
| `PROPOSAL_STATUS_REJECTED` | Did not pass |
|
|
54
|
+
| `PROPOSAL_STATUS_FAILED` | Execution failed |
|
|
55
|
+
|
|
56
|
+
---
|
|
57
|
+
|
|
58
|
+
### Tally
|
|
59
|
+
|
|
60
|
+
The **tally** is the final vote count:
|
|
61
|
+
|
|
62
|
+
* `yes_count`
|
|
63
|
+
* `no_count`
|
|
64
|
+
* `abstain_count`
|
|
65
|
+
* `no_with_veto_count`
|
|
66
|
+
|
|
67
|
+
Governance parameters define quorum and thresholds required for passing.
|
|
68
|
+
|
|
69
|
+
---
|
|
70
|
+
|
|
71
|
+
### Governance Parameters
|
|
72
|
+
|
|
73
|
+
Governance behavior is controlled by three parameter groups:
|
|
74
|
+
|
|
75
|
+
| Type | Controls |
|
|
76
|
+
| ---------- | -------------------------------- |
|
|
77
|
+
| `deposit` | Minimum deposit & deposit period |
|
|
78
|
+
| `voting` | Voting duration |
|
|
79
|
+
| `tallying` | Quorum, threshold, veto rules |
|
|
5
80
|
|
|
6
81
|
---
|
|
7
82
|
|
|
@@ -11,7 +86,7 @@ It is used to query **proposals**, **votes**, **tallies**, **governance paramete
|
|
|
11
86
|
import {
|
|
12
87
|
ChainGovApi,
|
|
13
88
|
getNetworkEndpoints,
|
|
14
|
-
Network
|
|
89
|
+
Network
|
|
15
90
|
} from '@zuhaibnoor/zigchain-sdk'
|
|
16
91
|
|
|
17
92
|
const endpoints = getNetworkEndpoints(Network.Testnet)
|
|
@@ -20,147 +95,270 @@ const govApi = new ChainGovApi(endpoints)
|
|
|
20
95
|
|
|
21
96
|
---
|
|
22
97
|
|
|
23
|
-
|
|
98
|
+
# 1️⃣ fetchConstitution
|
|
24
99
|
|
|
25
|
-
|
|
100
|
+
## Method
|
|
26
101
|
|
|
27
|
-
|
|
102
|
+
```ts
|
|
103
|
+
async fetchConstitution()
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
## CLI Equivalent
|
|
28
107
|
|
|
29
108
|
```bash
|
|
30
109
|
zigchaind query gov constitution
|
|
31
110
|
```
|
|
32
111
|
|
|
33
|
-
|
|
112
|
+
## Description
|
|
34
113
|
|
|
35
|
-
|
|
36
|
-
fetchConstitution()
|
|
37
|
-
```
|
|
114
|
+
Returns the **chain constitution text**.
|
|
38
115
|
|
|
39
|
-
|
|
116
|
+
This defines the high-level vision or guiding principle of ZigChain governance.
|
|
40
117
|
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
118
|
+
### Example Response
|
|
119
|
+
|
|
120
|
+
```json
|
|
121
|
+
{
|
|
122
|
+
"constitution": "Enabling wealth generation to everyone."
|
|
123
|
+
}
|
|
44
124
|
```
|
|
45
125
|
|
|
126
|
+
## When to Use
|
|
127
|
+
|
|
128
|
+
* Display governance philosophy in explorers
|
|
129
|
+
* Governance dashboards
|
|
130
|
+
* Public documentation tools
|
|
131
|
+
|
|
46
132
|
---
|
|
47
133
|
|
|
48
|
-
|
|
134
|
+
# 2️⃣ fetchAllProposals
|
|
49
135
|
|
|
50
|
-
|
|
136
|
+
## Method
|
|
51
137
|
|
|
52
|
-
|
|
138
|
+
```ts
|
|
139
|
+
async fetchAllProposals()
|
|
140
|
+
```
|
|
141
|
+
|
|
142
|
+
## CLI Equivalent
|
|
53
143
|
|
|
54
144
|
```bash
|
|
55
|
-
zigchaind query gov
|
|
145
|
+
zigchaind query gov proposals
|
|
56
146
|
```
|
|
57
147
|
|
|
58
|
-
|
|
148
|
+
## Description
|
|
59
149
|
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
150
|
+
Returns **all governance proposals** on the chain (paginated).
|
|
151
|
+
|
|
152
|
+
On ZigChain testnet:
|
|
63
153
|
|
|
64
|
-
|
|
154
|
+
```json
|
|
155
|
+
{
|
|
156
|
+
"pagination": {
|
|
157
|
+
"next_key": null,
|
|
158
|
+
"total": "79"
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
```
|
|
65
162
|
|
|
66
|
-
|
|
163
|
+
This means 79 proposals currently exist.
|
|
67
164
|
|
|
68
|
-
|
|
165
|
+
## Usage Example
|
|
69
166
|
|
|
70
167
|
```ts
|
|
71
|
-
const
|
|
72
|
-
console.
|
|
168
|
+
const proposals = await govApi.fetchAllProposals()
|
|
169
|
+
console.dir(proposals, { depth: null })
|
|
73
170
|
```
|
|
74
171
|
|
|
75
|
-
|
|
172
|
+
## Response Structure
|
|
76
173
|
|
|
77
|
-
|
|
174
|
+
Each proposal contains:
|
|
78
175
|
|
|
79
|
-
|
|
176
|
+
| Field | Description |
|
|
177
|
+
| ------------------ | ------------------------------ |
|
|
178
|
+
| id | Unique proposal ID |
|
|
179
|
+
| messages | State-changing messages |
|
|
180
|
+
| status | Proposal status |
|
|
181
|
+
| final_tally_result | Vote counts |
|
|
182
|
+
| submit_time | Submission timestamp |
|
|
183
|
+
| voting_start_time | Voting start |
|
|
184
|
+
| voting_end_time | Voting end |
|
|
185
|
+
| total_deposit | Deposited tokens |
|
|
186
|
+
| proposer | Address of proposer |
|
|
187
|
+
| expedited | Whether proposal was expedited |
|
|
188
|
+
| failed_reason | Reason if rejected/failed |
|
|
80
189
|
|
|
81
|
-
**CLI equivalent**
|
|
82
190
|
|
|
83
|
-
|
|
84
|
-
zigchaind query gov proposals
|
|
85
|
-
```
|
|
191
|
+
# 3️⃣ fetchProposal
|
|
86
192
|
|
|
87
|
-
|
|
193
|
+
## Method
|
|
88
194
|
|
|
89
195
|
```ts
|
|
90
|
-
|
|
196
|
+
async fetchProposal(proposalId: string | number)
|
|
91
197
|
```
|
|
92
198
|
|
|
93
|
-
|
|
199
|
+
## CLI Equivalent
|
|
200
|
+
|
|
201
|
+
```bash
|
|
202
|
+
zigchaind query gov proposal <id>
|
|
203
|
+
```
|
|
204
|
+
|
|
205
|
+
## Description
|
|
206
|
+
|
|
207
|
+
Fetches detailed information for a **single proposal**.
|
|
208
|
+
|
|
209
|
+
## Parameters
|
|
210
|
+
|
|
211
|
+
| Name | Type | Description |
|
|
212
|
+
| ---------- | --------------- | ------------------ |
|
|
213
|
+
| proposalId | string | number | ID of the proposal |
|
|
214
|
+
|
|
215
|
+
## Usage Example
|
|
94
216
|
|
|
95
217
|
```ts
|
|
96
|
-
const
|
|
97
|
-
console.
|
|
218
|
+
const proposal = await govApi.fetchProposal(59)
|
|
219
|
+
console.dir(proposal, { depth: null })
|
|
98
220
|
```
|
|
99
221
|
|
|
222
|
+
## Example Response (Simplified)
|
|
223
|
+
|
|
224
|
+
```json
|
|
225
|
+
{
|
|
226
|
+
"proposal": {
|
|
227
|
+
"id": "59",
|
|
228
|
+
"status": "PROPOSAL_STATUS_REJECTED",
|
|
229
|
+
"title": "Proposal test",
|
|
230
|
+
"failed_reason": "proposal did not get enough votes to pass"
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
```
|
|
234
|
+
|
|
235
|
+
## When to Use
|
|
236
|
+
|
|
237
|
+
* Viewing detailed proposal metadata
|
|
238
|
+
* Explorer proposal pages
|
|
239
|
+
* Governance analytics
|
|
240
|
+
|
|
100
241
|
---
|
|
101
242
|
|
|
102
|
-
|
|
243
|
+
# 4️⃣ fetchTally
|
|
103
244
|
|
|
104
|
-
|
|
245
|
+
## Method
|
|
105
246
|
|
|
106
|
-
|
|
247
|
+
```ts
|
|
248
|
+
async fetchTally(proposalId: string | number)
|
|
249
|
+
```
|
|
250
|
+
|
|
251
|
+
## CLI Equivalent
|
|
107
252
|
|
|
108
253
|
```bash
|
|
109
254
|
zigchaind query gov tally <proposal_id>
|
|
110
255
|
```
|
|
111
256
|
|
|
112
|
-
|
|
257
|
+
## Description
|
|
113
258
|
|
|
114
|
-
|
|
115
|
-
fetchTally(proposalId: string | number)
|
|
116
|
-
```
|
|
259
|
+
Returns the **current or final vote tally** for a proposal.
|
|
117
260
|
|
|
118
|
-
|
|
261
|
+
## Example Response
|
|
119
262
|
|
|
120
|
-
|
|
263
|
+
```json
|
|
264
|
+
{
|
|
265
|
+
"tally": {
|
|
266
|
+
"yes_count": "0",
|
|
267
|
+
"abstain_count": "0",
|
|
268
|
+
"no_count": "0",
|
|
269
|
+
"no_with_veto_count": "0"
|
|
270
|
+
}
|
|
271
|
+
}
|
|
272
|
+
```
|
|
121
273
|
|
|
122
|
-
|
|
274
|
+
## When to Use
|
|
123
275
|
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
```
|
|
276
|
+
* Live governance dashboards
|
|
277
|
+
* Displaying vote breakdowns
|
|
278
|
+
* Monitoring active proposals
|
|
128
279
|
|
|
129
280
|
---
|
|
130
281
|
|
|
131
|
-
|
|
282
|
+
# 5️⃣ fetchParams
|
|
132
283
|
|
|
133
|
-
|
|
284
|
+
## Method
|
|
134
285
|
|
|
135
|
-
|
|
286
|
+
```ts
|
|
287
|
+
async fetchParams(params_type: string)
|
|
288
|
+
```
|
|
289
|
+
|
|
290
|
+
## CLI Equivalent
|
|
136
291
|
|
|
137
292
|
```bash
|
|
138
|
-
zigchaind query gov params <
|
|
293
|
+
zigchaind query gov params <type>
|
|
139
294
|
```
|
|
140
295
|
|
|
141
|
-
|
|
296
|
+
Where `<type>` can be:
|
|
297
|
+
|
|
298
|
+
* `deposit`
|
|
299
|
+
* `voting`
|
|
300
|
+
* `tallying`
|
|
301
|
+
|
|
302
|
+
## Description
|
|
303
|
+
|
|
304
|
+
Fetches governance parameters controlling proposal lifecycle rules.
|
|
305
|
+
|
|
306
|
+
## Usage Example
|
|
142
307
|
|
|
143
308
|
```ts
|
|
144
|
-
fetchParams(
|
|
309
|
+
await govApi.fetchParams("voting")
|
|
310
|
+
await govApi.fetchParams("deposit")
|
|
311
|
+
await govApi.fetchParams("tallying")
|
|
145
312
|
```
|
|
146
313
|
|
|
147
|
-
|
|
314
|
+
## Example (Voting Params)
|
|
148
315
|
|
|
149
|
-
|
|
150
|
-
|
|
316
|
+
```json
|
|
317
|
+
{
|
|
318
|
+
"voting_params": {
|
|
319
|
+
"voting_period": "600s"
|
|
320
|
+
}
|
|
321
|
+
}
|
|
322
|
+
```
|
|
151
323
|
|
|
152
|
-
**
|
|
324
|
+
This means proposals remain open for voting for **600 seconds (10 minutes)**.
|
|
153
325
|
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
326
|
+
## Example (Tallying Params)
|
|
327
|
+
|
|
328
|
+
```json
|
|
329
|
+
{
|
|
330
|
+
"tally_params": {
|
|
331
|
+
"quorum": "0.334",
|
|
332
|
+
"threshold": "0.51",
|
|
333
|
+
"veto_threshold": "0.334"
|
|
334
|
+
}
|
|
335
|
+
}
|
|
157
336
|
```
|
|
158
337
|
|
|
338
|
+
### Field Explanation
|
|
339
|
+
|
|
340
|
+
| Field | Meaning |
|
|
341
|
+
| -------------- | ---------------------------------- |
|
|
342
|
+
| quorum | Minimum participation required |
|
|
343
|
+
| threshold | % of yes votes required to pass |
|
|
344
|
+
| veto_threshold | % of veto votes required to reject |
|
|
345
|
+
|
|
346
|
+
## When to Use
|
|
347
|
+
|
|
348
|
+
* Governance analytics tools
|
|
349
|
+
* Chain configuration dashboards
|
|
350
|
+
|
|
159
351
|
---
|
|
160
352
|
|
|
161
|
-
##
|
|
353
|
+
## Summary Table
|
|
162
354
|
|
|
163
|
-
|
|
164
|
-
|
|
355
|
+
| Function | CLI Command | Purpose |
|
|
356
|
+
| ------------------- | ----------------------------------- | --------------------------- |
|
|
357
|
+
| `fetchConstitution` | `zigchaind query gov constitution` | Fetch chain constitution |
|
|
358
|
+
| `fetchAllProposals` | `zigchaind query gov proposals` | List all proposals |
|
|
359
|
+
| `fetchProposal` | `zigchaind query gov proposal <id>` | Get single proposal details |
|
|
360
|
+
| `fetchTally` | `zigchaind query gov tally <id>` | Get vote tally |
|
|
361
|
+
| `fetchParams` | `zigchaind query gov params <type>` | Fetch governance parameters |
|
|
165
362
|
|
|
363
|
+
---
|
|
166
364
|
|