@zuhaibnoor/zigchain-sdk 1.0.3 → 1.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/auth/ChainAuthApi.d.ts +0 -3
- package/dist/auth/ChainAuthApi.d.ts.map +1 -1
- package/dist/auth/ChainAuthApi.js +0 -26
- package/dist/auth/ChainAuthApi.js.map +1 -1
- package/dist/bank/ChainBankApi.d.ts +0 -9
- package/dist/bank/ChainBankApi.d.ts.map +1 -1
- package/dist/bank/ChainBankApi.js +0 -18
- package/dist/bank/ChainBankApi.js.map +1 -1
- package/dist/client/http.d.ts +1 -0
- package/dist/client/http.d.ts.map +1 -1
- package/dist/client/http.js +10 -0
- package/dist/client/http.js.map +1 -1
- package/dist/distribution/ChainDistributionApi.d.ts +47 -0
- package/dist/distribution/ChainDistributionApi.d.ts.map +1 -0
- package/dist/distribution/ChainDistributionApi.js +75 -0
- package/dist/distribution/ChainDistributionApi.js.map +1 -0
- package/dist/distribution/types.d.ts +71 -0
- package/dist/distribution/types.d.ts.map +1 -0
- package/dist/distribution/types.js +2 -0
- package/dist/distribution/types.js.map +1 -0
- package/dist/evidence/ChainEvidenceApi.d.ts +15 -0
- package/dist/evidence/ChainEvidenceApi.d.ts.map +1 -0
- package/dist/evidence/ChainEvidenceApi.js +22 -0
- package/dist/evidence/ChainEvidenceApi.js.map +1 -0
- package/dist/evidence/types.d.ts +15 -0
- package/dist/evidence/types.d.ts.map +1 -0
- package/dist/evidence/types.js +2 -0
- package/dist/evidence/types.js.map +1 -0
- package/dist/feegrant/ChainFeegrantApi.d.ts +22 -0
- package/dist/feegrant/ChainFeegrantApi.d.ts.map +1 -0
- package/dist/feegrant/ChainFeegrantApi.js +32 -0
- package/dist/feegrant/ChainFeegrantApi.js.map +1 -0
- package/dist/feegrant/types.d.ts +17 -0
- package/dist/feegrant/types.d.ts.map +1 -0
- package/dist/feegrant/types.js +2 -0
- package/dist/feegrant/types.js.map +1 -0
- package/dist/ibc/ChainIbcApi.d.ts +55 -0
- package/dist/ibc/ChainIbcApi.d.ts.map +1 -0
- package/dist/ibc/ChainIbcApi.js +82 -0
- package/dist/ibc/ChainIbcApi.js.map +1 -0
- package/dist/ibc/ibcChannel/ChainIbcChannelApi.d.ts +55 -0
- package/dist/ibc/ibcChannel/ChainIbcChannelApi.d.ts.map +1 -0
- package/dist/ibc/ibcChannel/ChainIbcChannelApi.js +82 -0
- package/dist/ibc/ibcChannel/ChainIbcChannelApi.js.map +1 -0
- package/dist/ibc/ibcChannel/types.d.ts +106 -0
- package/dist/ibc/ibcChannel/types.d.ts.map +1 -0
- package/dist/ibc/ibcChannel/types.js +2 -0
- package/dist/ibc/ibcChannel/types.js.map +1 -0
- package/dist/ibc/ibcChannelV2/ChainIbcChannelV2.d.ts +14 -0
- package/dist/ibc/ibcChannelV2/ChainIbcChannelV2.d.ts.map +1 -0
- package/dist/ibc/ibcChannelV2/ChainIbcChannelV2.js +38 -0
- package/dist/ibc/ibcChannelV2/ChainIbcChannelV2.js.map +1 -0
- package/dist/ibc/ibcChannelV2/types.d.ts +26 -0
- package/dist/ibc/ibcChannelV2/types.d.ts.map +1 -0
- package/dist/ibc/ibcChannelV2/types.js +3 -0
- package/dist/ibc/ibcChannelV2/types.js.map +1 -0
- package/dist/ibc/ibcClient/ChainIbcClientApi.d.ts +15 -0
- package/dist/ibc/ibcClient/ChainIbcClientApi.d.ts.map +1 -0
- package/dist/ibc/ibcClient/ChainIbcClientApi.js +39 -0
- package/dist/ibc/ibcClient/ChainIbcClientApi.js.map +1 -0
- package/dist/ibc/ibcClient/types.d.ts +53 -0
- package/dist/ibc/ibcClient/types.d.ts.map +1 -0
- package/dist/ibc/ibcClient/types.js +2 -0
- package/dist/ibc/ibcClient/types.js.map +1 -0
- package/dist/ibc/ibcConnection/ChainIbcConnectionApi.d.ts +11 -0
- package/dist/ibc/ibcConnection/ChainIbcConnectionApi.d.ts.map +1 -0
- package/dist/ibc/ibcConnection/ChainIbcConnectionApi.js +24 -0
- package/dist/ibc/ibcConnection/ChainIbcConnectionApi.js.map +1 -0
- package/dist/ibc/ibcConnection/types.d.ts +18 -0
- package/dist/ibc/ibcConnection/types.d.ts.map +1 -0
- package/dist/ibc/ibcConnection/types.js +2 -0
- package/dist/ibc/ibcConnection/types.js.map +1 -0
- package/dist/ibc/types.d.ts +106 -0
- package/dist/ibc/types.d.ts.map +1 -0
- package/dist/ibc/types.js +2 -0
- package/dist/ibc/types.js.map +1 -0
- package/dist/ibc-transfer/ChainIbcTransferApi.d.ts +12 -0
- package/dist/ibc-transfer/ChainIbcTransferApi.d.ts.map +1 -0
- package/dist/ibc-transfer/ChainIbcTransferApi.js +30 -0
- package/dist/ibc-transfer/ChainIbcTransferApi.js.map +1 -0
- package/dist/ibc-transfer/types.d.ts +26 -0
- package/dist/ibc-transfer/types.d.ts.map +1 -0
- package/dist/ibc-transfer/types.js +2 -0
- package/dist/ibc-transfer/types.js.map +1 -0
- package/dist/index.d.ts +26 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +26 -0
- package/dist/index.js.map +1 -1
- package/dist/interchain-accounts/ChainInterChainAccApi.d.ts +9 -0
- package/dist/interchain-accounts/ChainInterChainAccApi.d.ts.map +1 -0
- package/dist/interchain-accounts/ChainInterChainAccApi.js +16 -0
- package/dist/interchain-accounts/ChainInterChainAccApi.js.map +1 -0
- package/dist/interchain-accounts/types.d.ts +12 -0
- package/dist/interchain-accounts/types.d.ts.map +1 -0
- package/dist/interchain-accounts/types.js +2 -0
- package/dist/interchain-accounts/types.js.map +1 -0
- package/dist/networks/endpoints.js +2 -2
- package/dist/networks/endpoints.js.map +1 -1
- package/dist/runtime/ChainRuntimeApi.d.ts +12 -0
- package/dist/runtime/ChainRuntimeApi.d.ts.map +1 -0
- package/dist/runtime/ChainRuntimeApi.js +16 -0
- package/dist/runtime/ChainRuntimeApi.js.map +1 -0
- package/dist/runtime/types.d.ts +4 -0
- package/dist/runtime/types.d.ts.map +1 -0
- package/dist/runtime/types.js +2 -0
- package/dist/runtime/types.js.map +1 -0
- package/dist/tokenwrapper/ChainTokenWrapperApi.d.ts +19 -0
- package/dist/tokenwrapper/ChainTokenWrapperApi.d.ts.map +1 -0
- package/dist/tokenwrapper/ChainTokenWrapperApi.js +26 -0
- package/dist/tokenwrapper/ChainTokenWrapperApi.js.map +1 -0
- package/dist/tokenwrapper/types.d.ts +15 -0
- package/dist/tokenwrapper/types.d.ts.map +1 -0
- package/dist/tokenwrapper/types.js +2 -0
- package/dist/tokenwrapper/types.js.map +1 -0
- package/dist/txs/ChainTxsApi.d.ts +12 -0
- package/dist/txs/ChainTxsApi.d.ts.map +1 -0
- package/dist/txs/ChainTxsApi.js +17 -0
- package/dist/txs/ChainTxsApi.js.map +1 -0
- package/dist/txs/types.d.ts +22 -0
- package/dist/txs/types.d.ts.map +1 -0
- package/dist/txs/types.js +5 -0
- package/dist/txs/types.js.map +1 -0
- package/dist/upgrade/ChainUpgradeApi.d.ts +22 -0
- package/dist/upgrade/ChainUpgradeApi.d.ts.map +1 -0
- package/dist/upgrade/ChainUpgradeApi.js +40 -0
- package/dist/upgrade/ChainUpgradeApi.js.map +1 -0
- package/dist/upgrade/types.d.ts +24 -0
- package/dist/upgrade/types.d.ts.map +1 -0
- package/dist/upgrade/types.js +5 -0
- package/dist/upgrade/types.js.map +1 -0
- package/dist/validator-set/ChainCometValidator.d.ts +8 -0
- package/dist/validator-set/ChainCometValidator.d.ts.map +1 -0
- package/dist/validator-set/ChainCometValidator.js +15 -0
- package/dist/validator-set/ChainCometValidator.js.map +1 -0
- package/dist/validator-set/types.d.ts +18 -0
- package/dist/validator-set/types.d.ts.map +1 -0
- package/dist/validator-set/types.js +2 -0
- package/dist/validator-set/types.js.map +1 -0
- package/dist/wasm/ChainWasmApi.d.ts +57 -0
- package/dist/wasm/ChainWasmApi.d.ts.map +1 -0
- package/dist/wasm/ChainWasmApi.js +78 -0
- package/dist/wasm/ChainWasmApi.js.map +1 -0
- package/dist/wasm/types.d.ts +77 -0
- package/dist/wasm/types.d.ts.map +1 -0
- package/dist/wasm/types.js +2 -0
- package/dist/wasm/types.js.map +1 -0
- package/docs/auth.md +438 -72
- package/docs/bank.md +782 -123
- package/docs/block-results.md +328 -21
- package/docs/comet-validator-set.md +70 -0
- package/docs/distribution.md +201 -0
- package/docs/evidence.md +199 -0
- package/docs/feegrant.md +206 -0
- package/docs/gov.md +166 -0
- package/docs/ibc/ibcChannel.md +490 -0
- package/docs/ibc/ibcClient.md +302 -0
- package/docs/ibc/ibcConnection.md +214 -0
- package/docs/ibc-transfer.md +204 -0
- package/docs/interchain-accounts.md +120 -0
- package/docs/mint.md +133 -0
- package/docs/runtime.md +81 -0
- package/docs/slashing.md +139 -0
- package/docs/staking.md +633 -0
- package/docs/tokenwrapper.md +137 -0
- package/docs/txs.md +0 -0
- package/docs/upgrade.md +133 -0
- package/docs/wasm.md +916 -0
- package/package.json +1 -1
package/docs/staking.md
ADDED
|
@@ -0,0 +1,633 @@
|
|
|
1
|
+
# Staking Module
|
|
2
|
+
|
|
3
|
+
The **Staking module** manages everything related to **validators**, **delegations**, **unbonding**, and **redelegation**.
|
|
4
|
+
|
|
5
|
+
In simple terms:
|
|
6
|
+
|
|
7
|
+
* **Delegators** stake tokens to validators
|
|
8
|
+
* **Validators** secure the network
|
|
9
|
+
* Rewards, slashing, and voting power all depend on staking state
|
|
10
|
+
|
|
11
|
+
The `ChainStakingApi` provides **read-only access** to staking data using LCD endpoints.
|
|
12
|
+
|
|
13
|
+
---
|
|
14
|
+
|
|
15
|
+
## Setup
|
|
16
|
+
|
|
17
|
+
```ts
|
|
18
|
+
import {
|
|
19
|
+
ChainStakingApi,
|
|
20
|
+
getNetworkEndpoints,
|
|
21
|
+
Network,
|
|
22
|
+
} from '@zuhaibnoor/zigchain-sdk'
|
|
23
|
+
|
|
24
|
+
const endpoints = getNetworkEndpoints(Network.Testnet)
|
|
25
|
+
const stakingApi = new ChainStakingApi(endpoints)
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
---
|
|
29
|
+
|
|
30
|
+
## `fetchDelegation`
|
|
31
|
+
|
|
32
|
+
Fetch **a single delegation relationship** between:
|
|
33
|
+
|
|
34
|
+
* one **delegator**
|
|
35
|
+
* one **validator**
|
|
36
|
+
|
|
37
|
+
Use this when you already know **both addresses** and want to check:
|
|
38
|
+
|
|
39
|
+
* delegated amount
|
|
40
|
+
* shares
|
|
41
|
+
* delegation status
|
|
42
|
+
|
|
43
|
+
**When to use**
|
|
44
|
+
|
|
45
|
+
* Checking if a delegator has staked with a specific validator
|
|
46
|
+
* Showing detailed info for one delegation
|
|
47
|
+
|
|
48
|
+
**CLI equivalent**
|
|
49
|
+
|
|
50
|
+
```bash
|
|
51
|
+
zigchaind query staking delegation <delegator> <validator>
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
**Method**
|
|
55
|
+
|
|
56
|
+
```ts
|
|
57
|
+
fetchDelegation(
|
|
58
|
+
delegatorAddress: string,
|
|
59
|
+
validatorAddress: string
|
|
60
|
+
)
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
**Example**
|
|
64
|
+
|
|
65
|
+
```ts
|
|
66
|
+
const delegation = await stakingApi.fetchDelegation(
|
|
67
|
+
delegatorAddr,
|
|
68
|
+
validatorAddr
|
|
69
|
+
)
|
|
70
|
+
|
|
71
|
+
console.dir(delegation, { depth: null })
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
---
|
|
75
|
+
|
|
76
|
+
## `fetchDelegations`
|
|
77
|
+
|
|
78
|
+
Fetch **all delegations made by a delegator** across **all validators**.
|
|
79
|
+
|
|
80
|
+
This returns a **list**, not a single delegation.
|
|
81
|
+
|
|
82
|
+
**When to use**
|
|
83
|
+
|
|
84
|
+
* Showing a delegator’s entire staking portfolio
|
|
85
|
+
* Wallet dashboards
|
|
86
|
+
* Calculating total staked amount for a user
|
|
87
|
+
|
|
88
|
+
**Difference from `fetchDelegation`**
|
|
89
|
+
|
|
90
|
+
* `fetchDelegation` → one validator
|
|
91
|
+
* `fetchDelegations` → all validators
|
|
92
|
+
|
|
93
|
+
**CLI equivalent**
|
|
94
|
+
|
|
95
|
+
```bash
|
|
96
|
+
zigchaind query staking delegations <delegator>
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
**Method**
|
|
100
|
+
|
|
101
|
+
```ts
|
|
102
|
+
fetchDelegations(delegatorAddress: string)
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
**Example**
|
|
106
|
+
|
|
107
|
+
```ts
|
|
108
|
+
const delegations = await stakingApi.fetchDelegations(delegatorAddr)
|
|
109
|
+
console.dir(delegations, { depth: null })
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
---
|
|
113
|
+
|
|
114
|
+
## `fetchValidatorDelegations`
|
|
115
|
+
|
|
116
|
+
Fetch **all delegations made to a specific validator** by **all delegators**.
|
|
117
|
+
|
|
118
|
+
This is the **validator-centric** view of delegations.
|
|
119
|
+
|
|
120
|
+
**When to use**
|
|
121
|
+
|
|
122
|
+
* Validator dashboards
|
|
123
|
+
* Showing who has delegated to a validator
|
|
124
|
+
* Calculating validator voting power
|
|
125
|
+
|
|
126
|
+
**Difference from `fetchDelegations`**
|
|
127
|
+
|
|
128
|
+
* `fetchDelegations` → delegator → validators
|
|
129
|
+
* `fetchValidatorDelegations` → validator → delegators
|
|
130
|
+
|
|
131
|
+
**CLI equivalent**
|
|
132
|
+
|
|
133
|
+
```bash
|
|
134
|
+
zigchaind query staking delegations-to <validator>
|
|
135
|
+
```
|
|
136
|
+
|
|
137
|
+
**Method**
|
|
138
|
+
|
|
139
|
+
```ts
|
|
140
|
+
fetchValidatorDelegations(validatorAddress: string)
|
|
141
|
+
```
|
|
142
|
+
|
|
143
|
+
**Example**
|
|
144
|
+
|
|
145
|
+
```ts
|
|
146
|
+
const validatorDelegations =
|
|
147
|
+
await stakingApi.fetchValidatorDelegations(validatorAddr)
|
|
148
|
+
|
|
149
|
+
console.dir(validatorDelegations, { depth: null })
|
|
150
|
+
```
|
|
151
|
+
|
|
152
|
+
---
|
|
153
|
+
|
|
154
|
+
## `fetchDelegatorValidator`
|
|
155
|
+
|
|
156
|
+
Fetch **validator information** for a **specific delegator–validator pair**.
|
|
157
|
+
|
|
158
|
+
This endpoint confirms:
|
|
159
|
+
|
|
160
|
+
* whether a validator exists for a delegator
|
|
161
|
+
* whether the delegator is bonded to that validator
|
|
162
|
+
|
|
163
|
+
⚠️ Even though the endpoint looks similar to `fetchDelegation`,
|
|
164
|
+
this method focuses on **validator details**, not delegation amounts.
|
|
165
|
+
|
|
166
|
+
**When to use**
|
|
167
|
+
|
|
168
|
+
* Validating a delegator–validator relationship
|
|
169
|
+
* Checking validator status (bonded / unbonded / jailed) for a delegator
|
|
170
|
+
* UI flows that depend on validator state
|
|
171
|
+
|
|
172
|
+
**Difference from `fetchDelegation`**
|
|
173
|
+
|
|
174
|
+
* `fetchDelegation` → delegation data (shares, balance)
|
|
175
|
+
* `fetchDelegatorValidator` → validator info in context of delegator
|
|
176
|
+
|
|
177
|
+
**CLI equivalent**
|
|
178
|
+
|
|
179
|
+
```bash
|
|
180
|
+
zigchaind query staking delegator-validator <delegator> <validator>
|
|
181
|
+
```
|
|
182
|
+
|
|
183
|
+
**Method**
|
|
184
|
+
|
|
185
|
+
```ts
|
|
186
|
+
fetchDelegatorValidator(
|
|
187
|
+
delegatorAddress: string,
|
|
188
|
+
validatorAddress: string
|
|
189
|
+
)
|
|
190
|
+
```
|
|
191
|
+
|
|
192
|
+
**Example**
|
|
193
|
+
|
|
194
|
+
```ts
|
|
195
|
+
const validatorInfo =
|
|
196
|
+
await stakingApi.fetchDelegatorValidator(
|
|
197
|
+
delegatorAddr,
|
|
198
|
+
validatorAddr
|
|
199
|
+
)
|
|
200
|
+
|
|
201
|
+
console.dir(validatorInfo, { depth: null })
|
|
202
|
+
```
|
|
203
|
+
|
|
204
|
+
---
|
|
205
|
+
|
|
206
|
+
## `fetchDelegatorValidators`
|
|
207
|
+
|
|
208
|
+
Fetch **all validator information associated with a delegator**.
|
|
209
|
+
|
|
210
|
+
This returns the **validators a delegator is bonded to**, along with each validator’s metadata and status.
|
|
211
|
+
|
|
212
|
+
**Key idea**
|
|
213
|
+
|
|
214
|
+
* This is **validator-focused**, not delegation-amount–focused.
|
|
215
|
+
* It answers *“Which validators am I connected to?”* rather than *“How much did I stake?”*
|
|
216
|
+
|
|
217
|
+
**When to use**
|
|
218
|
+
|
|
219
|
+
* Showing a delegator’s active validators
|
|
220
|
+
* Validator lists inside wallets
|
|
221
|
+
* Navigation links from delegator → validator pages
|
|
222
|
+
|
|
223
|
+
**Difference from similar methods**
|
|
224
|
+
|
|
225
|
+
* `fetchDelegations` → delegation amounts & shares
|
|
226
|
+
* `fetchDelegatorValidators` → validator identities & status
|
|
227
|
+
|
|
228
|
+
**CLI equivalent**
|
|
229
|
+
|
|
230
|
+
```bash
|
|
231
|
+
zigchaind query staking delegator-validators <delegator>
|
|
232
|
+
```
|
|
233
|
+
|
|
234
|
+
**Method**
|
|
235
|
+
|
|
236
|
+
```ts
|
|
237
|
+
fetchDelegatorValidators(delegatorAddress: string)
|
|
238
|
+
```
|
|
239
|
+
|
|
240
|
+
**Example**
|
|
241
|
+
|
|
242
|
+
```ts
|
|
243
|
+
const validators =
|
|
244
|
+
await stakingApi.fetchDelegatorValidators(delegatorAddr)
|
|
245
|
+
|
|
246
|
+
console.dir(validators, { depth: null })
|
|
247
|
+
```
|
|
248
|
+
|
|
249
|
+
---
|
|
250
|
+
|
|
251
|
+
## `fetchHistoricalInfo`
|
|
252
|
+
|
|
253
|
+
Fetch **historical staking state at a specific block height**.
|
|
254
|
+
|
|
255
|
+
This includes:
|
|
256
|
+
|
|
257
|
+
* validator set at that height
|
|
258
|
+
* total voting power
|
|
259
|
+
* staking-related metadata
|
|
260
|
+
|
|
261
|
+
This endpoint is mainly useful for **indexers, explorers, and analytics tools**.
|
|
262
|
+
|
|
263
|
+
**When to use**
|
|
264
|
+
|
|
265
|
+
* Analyzing past validator sets
|
|
266
|
+
* Replaying chain state for historical research
|
|
267
|
+
* Governance or slashing investigations
|
|
268
|
+
|
|
269
|
+
⚠️ This data is **not available for all heights** — only heights explicitly stored by the chain.
|
|
270
|
+
|
|
271
|
+
**CLI equivalent**
|
|
272
|
+
|
|
273
|
+
```bash
|
|
274
|
+
zigchaind query staking historical-info <height>
|
|
275
|
+
```
|
|
276
|
+
|
|
277
|
+
**Method**
|
|
278
|
+
|
|
279
|
+
```ts
|
|
280
|
+
fetchHistoricalInfo(height: number | string)
|
|
281
|
+
```
|
|
282
|
+
|
|
283
|
+
**Example**
|
|
284
|
+
|
|
285
|
+
```ts
|
|
286
|
+
const history = await stakingApi.fetchHistoricalInfo(100000)
|
|
287
|
+
console.dir(history, { depth: null })
|
|
288
|
+
```
|
|
289
|
+
|
|
290
|
+
---
|
|
291
|
+
|
|
292
|
+
## `fetchStakingParams`
|
|
293
|
+
|
|
294
|
+
Fetch the **global staking parameters** of the chain.
|
|
295
|
+
|
|
296
|
+
These parameters control:
|
|
297
|
+
|
|
298
|
+
* unbonding period
|
|
299
|
+
* maximum number of validators
|
|
300
|
+
* bond denomination
|
|
301
|
+
|
|
302
|
+
**When to use**
|
|
303
|
+
|
|
304
|
+
* Displaying chain staking rules
|
|
305
|
+
* Validating staking-related UI logic
|
|
306
|
+
* Tooling that depends on unbonding duration or validator limits
|
|
307
|
+
|
|
308
|
+
**CLI equivalent**
|
|
309
|
+
|
|
310
|
+
```bash
|
|
311
|
+
zigchaind query staking params
|
|
312
|
+
```
|
|
313
|
+
|
|
314
|
+
**Method**
|
|
315
|
+
|
|
316
|
+
```ts
|
|
317
|
+
fetchStakingParams()
|
|
318
|
+
```
|
|
319
|
+
|
|
320
|
+
**Example**
|
|
321
|
+
|
|
322
|
+
```ts
|
|
323
|
+
const params = await stakingApi.fetchStakingParams()
|
|
324
|
+
console.dir(params, { depth: null })
|
|
325
|
+
```
|
|
326
|
+
|
|
327
|
+
---
|
|
328
|
+
|
|
329
|
+
## `fetchStakingPool`
|
|
330
|
+
|
|
331
|
+
Fetch the **current staking pool state**.
|
|
332
|
+
|
|
333
|
+
This shows:
|
|
334
|
+
|
|
335
|
+
* total bonded tokens
|
|
336
|
+
* total not-bonded tokens
|
|
337
|
+
|
|
338
|
+
It represents the **global staking balance of the network**.
|
|
339
|
+
|
|
340
|
+
**When to use**
|
|
341
|
+
|
|
342
|
+
* Network health dashboards
|
|
343
|
+
* Calculating staking ratios
|
|
344
|
+
* Showing bonded vs unbonded supply
|
|
345
|
+
|
|
346
|
+
**Difference from params**
|
|
347
|
+
|
|
348
|
+
* Params → rules
|
|
349
|
+
* Pool → live staking state
|
|
350
|
+
|
|
351
|
+
**CLI equivalent**
|
|
352
|
+
|
|
353
|
+
```bash
|
|
354
|
+
zigchaind query staking pool
|
|
355
|
+
```
|
|
356
|
+
|
|
357
|
+
**Method**
|
|
358
|
+
|
|
359
|
+
```ts
|
|
360
|
+
fetchStakingPool()
|
|
361
|
+
```
|
|
362
|
+
|
|
363
|
+
**Example**
|
|
364
|
+
|
|
365
|
+
```ts
|
|
366
|
+
const pool = await stakingApi.fetchStakingPool()
|
|
367
|
+
console.dir(pool, { depth: null })
|
|
368
|
+
```
|
|
369
|
+
|
|
370
|
+
---
|
|
371
|
+
|
|
372
|
+
## `fetchRedelegation`
|
|
373
|
+
|
|
374
|
+
Fetch **all redelegations initiated by a delegator**.
|
|
375
|
+
|
|
376
|
+
Redelegation allows moving stake from:
|
|
377
|
+
|
|
378
|
+
* one validator → another
|
|
379
|
+
* **without unbonding**
|
|
380
|
+
|
|
381
|
+
This endpoint returns **ongoing and completed redelegations** for a delegator.
|
|
382
|
+
|
|
383
|
+
**When to use**
|
|
384
|
+
|
|
385
|
+
* Showing redelegation history
|
|
386
|
+
* Tracking in-progress redelegations
|
|
387
|
+
* Preventing invalid redelegation actions in UI
|
|
388
|
+
|
|
389
|
+
**Difference from delegation queries**
|
|
390
|
+
|
|
391
|
+
* Delegation → current stake
|
|
392
|
+
* Redelegation → stake movement between validators
|
|
393
|
+
|
|
394
|
+
**CLI equivalent**
|
|
395
|
+
|
|
396
|
+
```bash
|
|
397
|
+
zigchaind query staking redelegations <delegator>
|
|
398
|
+
```
|
|
399
|
+
|
|
400
|
+
**Method**
|
|
401
|
+
|
|
402
|
+
```ts
|
|
403
|
+
fetchRedelegation(delegatorAddress: string)
|
|
404
|
+
```
|
|
405
|
+
|
|
406
|
+
**Example**
|
|
407
|
+
|
|
408
|
+
```ts
|
|
409
|
+
const redelegations =
|
|
410
|
+
await stakingApi.fetchRedelegation(delegatorAddr)
|
|
411
|
+
|
|
412
|
+
console.dir(redelegations, { depth: null })
|
|
413
|
+
```
|
|
414
|
+
|
|
415
|
+
---
|
|
416
|
+
|
|
417
|
+
Perfect — with these, your **staking module is now complete**.
|
|
418
|
+
These functions cover **unbonding flows and validator discovery**, which are the last big pieces users usually get confused about. I’ll document them *very clearly* and show how they differ from each other.
|
|
419
|
+
|
|
420
|
+
You can paste this directly under the **Staking Module** section in your docs.
|
|
421
|
+
|
|
422
|
+
---
|
|
423
|
+
|
|
424
|
+
## `fetchUnbondingDelegation`
|
|
425
|
+
|
|
426
|
+
Fetch the **unbonding delegation between a specific delegator and validator**.
|
|
427
|
+
|
|
428
|
+
This shows stake that:
|
|
429
|
+
|
|
430
|
+
* has been undelegated
|
|
431
|
+
* is still in the **unbonding period**
|
|
432
|
+
* is **not yet liquid**
|
|
433
|
+
|
|
434
|
+
**What you get**
|
|
435
|
+
|
|
436
|
+
* balance currently unbonding
|
|
437
|
+
* completion time
|
|
438
|
+
* creation height
|
|
439
|
+
|
|
440
|
+
**When to use**
|
|
441
|
+
|
|
442
|
+
* Showing “pending unstake” information
|
|
443
|
+
* Tracking completion times in wallets
|
|
444
|
+
* Validator-level unbonding inspections
|
|
445
|
+
|
|
446
|
+
**Difference from other unbonding queries**
|
|
447
|
+
|
|
448
|
+
* This is **one delegator → one validator**
|
|
449
|
+
* Most granular unbonding query
|
|
450
|
+
|
|
451
|
+
**CLI equivalent**
|
|
452
|
+
|
|
453
|
+
```bash
|
|
454
|
+
zigchaind query staking unbonding-delegation <delegator> <validator>
|
|
455
|
+
```
|
|
456
|
+
|
|
457
|
+
**Method**
|
|
458
|
+
|
|
459
|
+
```ts
|
|
460
|
+
fetchUnbondingDelegation(delegator: string, validator: string)
|
|
461
|
+
```
|
|
462
|
+
|
|
463
|
+
**Example**
|
|
464
|
+
|
|
465
|
+
```ts
|
|
466
|
+
const unbonding =
|
|
467
|
+
await stakingApi.fetchUnbondingDelegation(delegator, validator)
|
|
468
|
+
|
|
469
|
+
console.dir(unbonding, { depth: null })
|
|
470
|
+
```
|
|
471
|
+
|
|
472
|
+
---
|
|
473
|
+
|
|
474
|
+
## `fetchUnbondingDelegations`
|
|
475
|
+
|
|
476
|
+
Fetch **all unbonding delegations for a delegator** across every validator.
|
|
477
|
+
|
|
478
|
+
This aggregates **all pending unbondings** initiated by a delegator.
|
|
479
|
+
|
|
480
|
+
**When to use**
|
|
481
|
+
|
|
482
|
+
* Wallet “Unstaking” screens
|
|
483
|
+
* Showing total pending unbonded stake
|
|
484
|
+
* Preventing double-unbonding actions
|
|
485
|
+
|
|
486
|
+
**Difference from similar methods**
|
|
487
|
+
|
|
488
|
+
* `fetchUnbondingDelegation` → one validator
|
|
489
|
+
* `fetchUnbondingDelegations` → all validators (delegator-wide)
|
|
490
|
+
|
|
491
|
+
⚠️ Even though the path contains `validators`, the **input is a delegator address**.
|
|
492
|
+
|
|
493
|
+
**CLI equivalent**
|
|
494
|
+
|
|
495
|
+
```bash
|
|
496
|
+
zigchaind query staking unbonding-delegations <delegator>
|
|
497
|
+
```
|
|
498
|
+
|
|
499
|
+
**Method**
|
|
500
|
+
|
|
501
|
+
```ts
|
|
502
|
+
fetchUnbondingDelegations(delegator: string)
|
|
503
|
+
```
|
|
504
|
+
|
|
505
|
+
**Example**
|
|
506
|
+
|
|
507
|
+
```ts
|
|
508
|
+
const unbondings =
|
|
509
|
+
await stakingApi.fetchUnbondingDelegations(delegator)
|
|
510
|
+
|
|
511
|
+
console.dir(unbondings, { depth: null })
|
|
512
|
+
```
|
|
513
|
+
|
|
514
|
+
---
|
|
515
|
+
|
|
516
|
+
## `fetchUnbondingDelegationsFrom`
|
|
517
|
+
|
|
518
|
+
Fetch **all unbonding delegations *from* a specific validator**.
|
|
519
|
+
|
|
520
|
+
This shows which delegators are currently unbonding **away from a validator**.
|
|
521
|
+
|
|
522
|
+
**When to use**
|
|
523
|
+
|
|
524
|
+
* Validator dashboards
|
|
525
|
+
* Monitoring validator stake outflows
|
|
526
|
+
* Risk and decentralization analysis
|
|
527
|
+
|
|
528
|
+
**Perspective**
|
|
529
|
+
|
|
530
|
+
* Delegator-focused → *who is unstaking*
|
|
531
|
+
* Validator-focused → *from where stake is leaving*
|
|
532
|
+
|
|
533
|
+
**CLI equivalent**
|
|
534
|
+
|
|
535
|
+
```bash
|
|
536
|
+
zigchaind query staking unbonding-delegations-from <validator>
|
|
537
|
+
```
|
|
538
|
+
|
|
539
|
+
**Method**
|
|
540
|
+
|
|
541
|
+
```ts
|
|
542
|
+
fetchUnbondingDelegationsFrom(validator: string)
|
|
543
|
+
```
|
|
544
|
+
|
|
545
|
+
**Example**
|
|
546
|
+
|
|
547
|
+
```ts
|
|
548
|
+
const validatorUnbondings =
|
|
549
|
+
await stakingApi.fetchUnbondingDelegationsFrom(validator)
|
|
550
|
+
|
|
551
|
+
console.dir(validatorUnbondings, { depth: null })
|
|
552
|
+
```
|
|
553
|
+
|
|
554
|
+
---
|
|
555
|
+
|
|
556
|
+
## `fetchValidator`
|
|
557
|
+
|
|
558
|
+
Fetch **detailed information about a single validator**.
|
|
559
|
+
|
|
560
|
+
Includes:
|
|
561
|
+
|
|
562
|
+
* status (bonded / unbonded / unbonding)
|
|
563
|
+
* commission rates
|
|
564
|
+
* operator address
|
|
565
|
+
* consensus public key
|
|
566
|
+
* voting power
|
|
567
|
+
|
|
568
|
+
**When to use**
|
|
569
|
+
|
|
570
|
+
* Validator profile pages
|
|
571
|
+
* Delegation confirmation screens
|
|
572
|
+
* Governance and slashing tools
|
|
573
|
+
|
|
574
|
+
**CLI equivalent**
|
|
575
|
+
|
|
576
|
+
```bash
|
|
577
|
+
zigchaind query staking validator <validator>
|
|
578
|
+
```
|
|
579
|
+
|
|
580
|
+
**Method**
|
|
581
|
+
|
|
582
|
+
```ts
|
|
583
|
+
fetchValidator(validator: string)
|
|
584
|
+
```
|
|
585
|
+
|
|
586
|
+
**Example**
|
|
587
|
+
|
|
588
|
+
```ts
|
|
589
|
+
const validatorInfo =
|
|
590
|
+
await stakingApi.fetchValidator(validatorAddr)
|
|
591
|
+
|
|
592
|
+
console.dir(validatorInfo, { depth: null })
|
|
593
|
+
```
|
|
594
|
+
|
|
595
|
+
---
|
|
596
|
+
|
|
597
|
+
## `fetchValidators`
|
|
598
|
+
|
|
599
|
+
Fetch **all validators in the network**.
|
|
600
|
+
|
|
601
|
+
This returns the **full validator set**, optionally filtered by status at the chain level.
|
|
602
|
+
|
|
603
|
+
**When to use**
|
|
604
|
+
|
|
605
|
+
* Validator explorer pages
|
|
606
|
+
* Delegation selection UI
|
|
607
|
+
* Network decentralization analysis
|
|
608
|
+
|
|
609
|
+
**Difference from delegator-validator queries**
|
|
610
|
+
|
|
611
|
+
* `fetchValidators` → network-wide
|
|
612
|
+
* `fetchDelegatorValidators` → user-specific
|
|
613
|
+
|
|
614
|
+
**CLI equivalent**
|
|
615
|
+
|
|
616
|
+
```bash
|
|
617
|
+
zigchaind query staking validators
|
|
618
|
+
```
|
|
619
|
+
|
|
620
|
+
**Method**
|
|
621
|
+
|
|
622
|
+
```ts
|
|
623
|
+
fetchValidators()
|
|
624
|
+
```
|
|
625
|
+
|
|
626
|
+
**Example**
|
|
627
|
+
|
|
628
|
+
```ts
|
|
629
|
+
const validators = await stakingApi.fetchValidators()
|
|
630
|
+
console.dir(validators, { depth: null })
|
|
631
|
+
```
|
|
632
|
+
---
|
|
633
|
+
|