@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
@@ -0,0 +1,206 @@
1
+ # Feegrant Module
2
+
3
+ ## Module Overview
4
+
5
+ The **Feegrant module** allows one account (**granter**) to **pay transaction fees for another account (**grantee**)**.
6
+ This is useful when a user needs to submit transactions but does not have tokens to pay gas fees themselves.
7
+
8
+ Fee grants are created **explicitly by the granter** and exist only between specific address pairs.
9
+
10
+ ---
11
+
12
+ ## When Should You Use Feegrant?
13
+
14
+ * When an application wants to **sponsor transaction fees** for its users
15
+ * When fees should be paid **from a different account**
16
+
17
+ ---
18
+
19
+ ## ChainFeegrantApi
20
+
21
+ This module provides read-only access to fee grant information available on-chain.
22
+
23
+ ### `fetchGrant(granter, grantee)`
24
+
25
+ **Purpose:**
26
+ Fetch details of a fee grant between a specific granter and grantee.
27
+
28
+ **What it tells you:**
29
+
30
+ * Whether a fee grant exists
31
+ * Spend limit (if any)
32
+ * Expiration time (if set)
33
+
34
+ **When to use:**
35
+
36
+ * To check if a grantee is allowed to use the granter’s balance for fees
37
+ * Before sending a transaction using fee grants
38
+
39
+ ---
40
+
41
+ ### `fetchGrantsByGrantee(grantee)`
42
+
43
+ **Purpose:**
44
+ Fetch all fee grants **received by a given grantee**.
45
+
46
+ **What it tells you:**
47
+
48
+ * Which accounts are paying fees for this grantee
49
+ * Limits and expiration details for each grant
50
+
51
+ **When to use:**
52
+
53
+ * To show a user who is sponsoring their transaction fees
54
+ * To decide which grant to use when multiple grants exist
55
+
56
+ ---
57
+
58
+ ### `fetchGrantsByGranter(granter)`
59
+
60
+ **Purpose:**
61
+ Fetch all fee grants **created by a given granter**.
62
+
63
+ **What it tells you:**
64
+
65
+ * Which accounts can use the granter’s tokens to pay fees
66
+ * How much fee allowance has been given
67
+
68
+ **When to use:**
69
+
70
+ * To monitor sponsored users
71
+ * To audit or manage fee sponsorships
72
+
73
+ ---
74
+
75
+ ## Important Notes
76
+
77
+ * Fee grants **do not exist by default**
78
+ * If no fee grants are created, queries will return **empty results**
79
+ * There is **no global list of all fee grants** on the chain
80
+ * Fee grants are always **address-to-address**
81
+
82
+ ---
83
+
84
+ ## Feegrant vs Authz (Clear & Simple)
85
+
86
+ This section is critical, so let’s be **very explicit**.
87
+
88
+ ### Feegrant Module
89
+
90
+ **What it controls:**
91
+ 👉 **Who pays the transaction fee**
92
+
93
+ **What changes:**
94
+
95
+ * The **fee** is paid by the granter
96
+ * The **transaction content** still belongs to the sender
97
+
98
+ **Example:**
99
+
100
+ * Alice submits a transaction
101
+ * Bob pays the gas fee for Alice
102
+ * Alice’s transaction still affects Alice’s account, not Bob’s
103
+
104
+ ---
105
+
106
+ ### Authz Module
107
+
108
+ **What it controls:**
109
+ 👉 **Who is allowed to submit transactions on someone else’s behalf**
110
+
111
+ **What changes:**
112
+
113
+ * One account submits transactions **for another account**
114
+ * The transaction affects the **owner’s account**, not the sender
115
+
116
+ **Example:**
117
+
118
+ * Bob submits a transaction
119
+ * The transaction modifies Alice’s account
120
+ * Bob is acting *on behalf of Alice*
121
+
122
+ ---
123
+
124
+ ### Simple Comparison Table
125
+
126
+ | Feature | Feegrant | Authz |
127
+ | ------------------------ | ---------------- | ------------------ |
128
+ | Pays transaction fee | Someone else | Sender |
129
+ | Submits transaction | Original account | Authorized account |
130
+ | Changes account state of | Sender | Account owner |
131
+ | Main purpose | Fee sponsorship | Account delegation |
132
+
133
+ ---
134
+
135
+ ## Key Takeaway
136
+
137
+ * **Feegrant = “Who pays the fee?”**
138
+ * **Authz = “Who is allowed to submit the transaction?”**
139
+
140
+ They solve **different problems** and are often used **together**, but they are **not the same**.
141
+
142
+ Perfect 👍 — below is a **complete, copy-pasteable testing example** written exactly in the style you’ve been using for other modules.
143
+ It’s **doc-ready**, beginner-friendly, and explains *what is being tested* and *why*.
144
+
145
+ You can drop this straight into your **Feegrant module documentation**.
146
+
147
+ ---
148
+
149
+ # Testing Example
150
+
151
+ ## Test Setup
152
+
153
+ ```ts
154
+ import {
155
+ ChainFeegrantApi,
156
+ getNetworkEndpoints,
157
+ Network
158
+ } from '@zuhaibnoor/zigchain-sdk'
159
+ ```
160
+
161
+ ---
162
+
163
+ ## Full Test Example
164
+
165
+ ```ts
166
+ async function main() {
167
+ // 1. Select network
168
+ const endpoints = getNetworkEndpoints(Network.Testnet)
169
+
170
+ // 2. Initialize Feegrant module
171
+ const feegrant = new ChainFeegrantApi(endpoints)
172
+
173
+ // Replace these with REAL addresses that have an existing fee grant
174
+ const granter = 'zig1xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx'
175
+ const grantee = 'zig1yyyyyyyyyyyyyyyyyyyyyyyyyyyyyy'
176
+
177
+ // --------------------------------------------------
178
+ // Query a specific fee grant (granter -> grantee)
179
+ // --------------------------------------------------
180
+ console.log('\n--- Fee Grant (Granter → Grantee) ---')
181
+ try {
182
+ const grant = await feegrant.fetchGrant(granter, grantee)
183
+ console.dir(grant, { depth: null })
184
+ } catch (err) {
185
+ console.log('No direct fee grant found between granter and grantee')
186
+ }
187
+
188
+ // --------------------------------------------------
189
+ // Query all grants received by a grantee
190
+ // --------------------------------------------------
191
+ console.log('\n--- Grants By Grantee ---')
192
+ const grantsByGrantee = await feegrant.fetchGrantsByGrantee(grantee)
193
+ console.dir(grantsByGrantee, { depth: null })
194
+
195
+ // --------------------------------------------------
196
+ // Query all grants created by a granter
197
+ // --------------------------------------------------
198
+ console.log('\n--- Grants By Granter ---')
199
+ const grantsByGranter = await feegrant.fetchGrantsByGranter(granter)
200
+ console.dir(grantsByGranter, { depth: null })
201
+ }
202
+
203
+ main()
204
+ ```
205
+
206
+ ---
package/docs/gov.md ADDED
@@ -0,0 +1,364 @@
1
+ # Governance (Gov) Module
2
+
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 |
80
+
81
+ ---
82
+
83
+ ## Setup
84
+
85
+ ```ts
86
+ import {
87
+ ChainGovApi,
88
+ getNetworkEndpoints,
89
+ Network
90
+ } from '@zuhaibnoor/zigchain-sdk'
91
+
92
+ const endpoints = getNetworkEndpoints(Network.Testnet)
93
+ const govApi = new ChainGovApi(endpoints)
94
+ ```
95
+
96
+ ---
97
+
98
+ # 1️⃣ fetchConstitution
99
+
100
+ ## Method
101
+
102
+ ```ts
103
+ async fetchConstitution()
104
+ ```
105
+
106
+ ## CLI Equivalent
107
+
108
+ ```bash
109
+ zigchaind query gov constitution
110
+ ```
111
+
112
+ ## Description
113
+
114
+ Returns the **chain constitution text**.
115
+
116
+ This defines the high-level vision or guiding principle of ZigChain governance.
117
+
118
+ ### Example Response
119
+
120
+ ```json
121
+ {
122
+ "constitution": "Enabling wealth generation to everyone."
123
+ }
124
+ ```
125
+
126
+ ## When to Use
127
+
128
+ * Display governance philosophy in explorers
129
+ * Governance dashboards
130
+ * Public documentation tools
131
+
132
+ ---
133
+
134
+ # 2️⃣ fetchAllProposals
135
+
136
+ ## Method
137
+
138
+ ```ts
139
+ async fetchAllProposals()
140
+ ```
141
+
142
+ ## CLI Equivalent
143
+
144
+ ```bash
145
+ zigchaind query gov proposals
146
+ ```
147
+
148
+ ## Description
149
+
150
+ Returns **all governance proposals** on the chain (paginated).
151
+
152
+ On ZigChain testnet:
153
+
154
+ ```json
155
+ {
156
+ "pagination": {
157
+ "next_key": null,
158
+ "total": "79"
159
+ }
160
+ }
161
+ ```
162
+
163
+ This means 79 proposals currently exist.
164
+
165
+ ## Usage Example
166
+
167
+ ```ts
168
+ const proposals = await govApi.fetchAllProposals()
169
+ console.dir(proposals, { depth: null })
170
+ ```
171
+
172
+ ## Response Structure
173
+
174
+ Each proposal contains:
175
+
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 |
189
+
190
+
191
+ # 3️⃣ fetchProposal
192
+
193
+ ## Method
194
+
195
+ ```ts
196
+ async fetchProposal(proposalId: string | number)
197
+ ```
198
+
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
216
+
217
+ ```ts
218
+ const proposal = await govApi.fetchProposal(59)
219
+ console.dir(proposal, { depth: null })
220
+ ```
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
+
241
+ ---
242
+
243
+ # 4️⃣ fetchTally
244
+
245
+ ## Method
246
+
247
+ ```ts
248
+ async fetchTally(proposalId: string | number)
249
+ ```
250
+
251
+ ## CLI Equivalent
252
+
253
+ ```bash
254
+ zigchaind query gov tally <proposal_id>
255
+ ```
256
+
257
+ ## Description
258
+
259
+ Returns the **current or final vote tally** for a proposal.
260
+
261
+ ## Example Response
262
+
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
+ ```
273
+
274
+ ## When to Use
275
+
276
+ * Live governance dashboards
277
+ * Displaying vote breakdowns
278
+ * Monitoring active proposals
279
+
280
+ ---
281
+
282
+ # 5️⃣ fetchParams
283
+
284
+ ## Method
285
+
286
+ ```ts
287
+ async fetchParams(params_type: string)
288
+ ```
289
+
290
+ ## CLI Equivalent
291
+
292
+ ```bash
293
+ zigchaind query gov params <type>
294
+ ```
295
+
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
307
+
308
+ ```ts
309
+ await govApi.fetchParams("voting")
310
+ await govApi.fetchParams("deposit")
311
+ await govApi.fetchParams("tallying")
312
+ ```
313
+
314
+ ## Example (Voting Params)
315
+
316
+ ```json
317
+ {
318
+ "voting_params": {
319
+ "voting_period": "600s"
320
+ }
321
+ }
322
+ ```
323
+
324
+ This means proposals remain open for voting for **600 seconds (10 minutes)**.
325
+
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
+ }
336
+ ```
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
+
351
+ ---
352
+
353
+ ## Summary Table
354
+
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 |
362
+
363
+ ---
364
+