@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/evidence.md
ADDED
|
@@ -0,0 +1,199 @@
|
|
|
1
|
+
# Evidence Module
|
|
2
|
+
|
|
3
|
+
The **Evidence module** exposes information about **misbehavior evidence** that has been submitted to the blockchain.
|
|
4
|
+
Evidence is used by the network to **prove validator misbehavior**, such as double-signing or light-client attacks, and is a critical part of the **slashing and security mechanism** in Cosmos-SDK–based chains like ZigChain.
|
|
5
|
+
|
|
6
|
+
This module allows developers to:
|
|
7
|
+
|
|
8
|
+
* Inspect individual evidence records by hash
|
|
9
|
+
* List all submitted evidence (paginated)
|
|
10
|
+
|
|
11
|
+
All queries in this module use **LCD endpoints**.
|
|
12
|
+
|
|
13
|
+
---
|
|
14
|
+
|
|
15
|
+
## Initialization
|
|
16
|
+
|
|
17
|
+
```ts
|
|
18
|
+
import {
|
|
19
|
+
ChainEvidenceApi,
|
|
20
|
+
getNetworkEndpoints,
|
|
21
|
+
Network
|
|
22
|
+
} from '@zuhaibnoor/zigchain-sdk'
|
|
23
|
+
|
|
24
|
+
const endpoints = getNetworkEndpoints(Network.Testnet)
|
|
25
|
+
const evidenceApi = new ChainEvidenceApi(endpoints)
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
---
|
|
29
|
+
|
|
30
|
+
## `fetchEvidence`
|
|
31
|
+
|
|
32
|
+
```ts
|
|
33
|
+
async fetchEvidence(hash: string)
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
**CLI equivalent**
|
|
37
|
+
|
|
38
|
+
```bash
|
|
39
|
+
zigchaind query evidence evidence <hash>
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
### Description
|
|
43
|
+
|
|
44
|
+
Fetches a **single evidence record** using its unique evidence hash.
|
|
45
|
+
This is useful when you already know an evidence hash (for example, from logs, explorers, or governance discussions) and want to inspect the exact misbehavior details.
|
|
46
|
+
|
|
47
|
+
### Parameters
|
|
48
|
+
|
|
49
|
+
| Name | Type | Description |
|
|
50
|
+
| ------ | -------- | ------------------------------------ |
|
|
51
|
+
| `hash` | `string` | Unique hash identifying the evidence |
|
|
52
|
+
|
|
53
|
+
### Example
|
|
54
|
+
|
|
55
|
+
```ts
|
|
56
|
+
const evidence = await evidenceApi.fetchEvidence(
|
|
57
|
+
'A1B2C3D4E5F6...'
|
|
58
|
+
)
|
|
59
|
+
|
|
60
|
+
console.dir(evidence, { depth: null })
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
### When to use
|
|
64
|
+
|
|
65
|
+
* Inspect a **specific validator misbehavior**
|
|
66
|
+
* Debug or audit slashing events
|
|
67
|
+
* Explorer or monitoring tools
|
|
68
|
+
|
|
69
|
+
---
|
|
70
|
+
|
|
71
|
+
## `fetchAllEvidence`
|
|
72
|
+
|
|
73
|
+
```ts
|
|
74
|
+
async fetchAllEvidence()
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
**CLI equivalent**
|
|
78
|
+
|
|
79
|
+
```bash
|
|
80
|
+
zigchaind query evidence list
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
### Description
|
|
84
|
+
|
|
85
|
+
Returns **all submitted evidence records** on the chain.
|
|
86
|
+
The response is **paginated**, meaning large networks may return results in chunks.
|
|
87
|
+
|
|
88
|
+
This method is ideal for:
|
|
89
|
+
|
|
90
|
+
* Block explorers
|
|
91
|
+
* Security dashboards
|
|
92
|
+
* Chain analytics tools
|
|
93
|
+
|
|
94
|
+
### Example
|
|
95
|
+
|
|
96
|
+
```ts
|
|
97
|
+
const allEvidence = await evidenceApi.fetchAllEvidence()
|
|
98
|
+
console.dir(allEvidence, { depth: null })
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
### Notes
|
|
102
|
+
|
|
103
|
+
* Evidence types can vary, so the `value` field is returned as a flexible structure.
|
|
104
|
+
* Pagination info is included if the dataset is large.
|
|
105
|
+
|
|
106
|
+
---
|
|
107
|
+
|
|
108
|
+
## Response Types Overview
|
|
109
|
+
|
|
110
|
+
### `Evidence`
|
|
111
|
+
|
|
112
|
+
```ts
|
|
113
|
+
{
|
|
114
|
+
type_url: string
|
|
115
|
+
value: any
|
|
116
|
+
}
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
* `type_url` → Identifies the evidence type (e.g. double-sign evidence)
|
|
120
|
+
* `value` → Evidence-specific data (structure depends on evidence type)
|
|
121
|
+
|
|
122
|
+
---
|
|
123
|
+
|
|
124
|
+
## Summary Table
|
|
125
|
+
|
|
126
|
+
| Function | CLI Command | Purpose |
|
|
127
|
+
| ------------------ | ------------------------------------------ | -------------------------------- |
|
|
128
|
+
| `fetchEvidence` | `zigchaind query evidence evidence <hash>` | Query a specific evidence record |
|
|
129
|
+
| `fetchAllEvidence` | `zigchaind query evidence list` | List all submitted evidence |
|
|
130
|
+
|
|
131
|
+
---
|
|
132
|
+
|
|
133
|
+
## How Evidence Works
|
|
134
|
+
|
|
135
|
+
### Who Submits Evidence?
|
|
136
|
+
|
|
137
|
+
Evidence is **not submitted by regular users**.
|
|
138
|
+
|
|
139
|
+
It is submitted by:
|
|
140
|
+
|
|
141
|
+
* **Validators** (automatically by their node software)
|
|
142
|
+
* **Full nodes** that detect misbehavior
|
|
143
|
+
* **Light clients** (for light-client attack proofs)
|
|
144
|
+
|
|
145
|
+
In most cases, evidence is **automatically generated and broadcast** by the blockchain software when a validator’s misbehavior is detected.
|
|
146
|
+
|
|
147
|
+
---
|
|
148
|
+
|
|
149
|
+
### What Does Evidence Contain?
|
|
150
|
+
|
|
151
|
+
Evidence is a **cryptographic proof** of validator misbehavior.
|
|
152
|
+
It contains enough information for the blockchain to **verify the fault without trust**.
|
|
153
|
+
|
|
154
|
+
Depending on the evidence type, it may include:
|
|
155
|
+
|
|
156
|
+
* Validator consensus address
|
|
157
|
+
* Block height at which misbehavior occurred
|
|
158
|
+
* Conflicting block headers or signatures
|
|
159
|
+
* Timestamp of the infraction
|
|
160
|
+
* Power (stake) of the validator at that time
|
|
161
|
+
|
|
162
|
+
Once verified, this evidence can trigger **slashing**, **jailing**, or **tombstoning** of the validator.
|
|
163
|
+
|
|
164
|
+
---
|
|
165
|
+
|
|
166
|
+
### Common Types of Evidence
|
|
167
|
+
|
|
168
|
+
The Cosmos SDK currently supports multiple evidence types, including:
|
|
169
|
+
|
|
170
|
+
* **Duplicate Vote Evidence**
|
|
171
|
+
Proof that a validator signed **two different blocks at the same height** (double-signing).
|
|
172
|
+
|
|
173
|
+
* **Light Client Attack Evidence**
|
|
174
|
+
Proof of malicious behavior aimed at misleading light clients.
|
|
175
|
+
|
|
176
|
+
Each evidence type is identified by its `type_url` field in the response.
|
|
177
|
+
|
|
178
|
+
---
|
|
179
|
+
|
|
180
|
+
### Why Evidence Is Important
|
|
181
|
+
|
|
182
|
+
The Evidence module ensures:
|
|
183
|
+
|
|
184
|
+
* **Network security** through objective proof
|
|
185
|
+
* **Automatic punishment** without human intervention
|
|
186
|
+
* **Trustless verification** of validator behavior
|
|
187
|
+
|
|
188
|
+
Because evidence is cryptographically verifiable, it **cannot be faked or disputed** once accepted by the chain.
|
|
189
|
+
|
|
190
|
+
---
|
|
191
|
+
|
|
192
|
+
### Key Characteristics
|
|
193
|
+
|
|
194
|
+
* Evidence is **immutable** once submitted
|
|
195
|
+
* Evidence is **publicly queryable**
|
|
196
|
+
* Evidence directly feeds into the **Slashing module**
|
|
197
|
+
* Evidence is **time-sensitive** (old evidence may be rejected)
|
|
198
|
+
|
|
199
|
+
|
package/docs/feegrant.md
ADDED
|
@@ -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,166 @@
|
|
|
1
|
+
# Governance Module
|
|
2
|
+
|
|
3
|
+
The **ChainGovApi** provides access to the on-chain governance system.
|
|
4
|
+
It is used to query **proposals**, **votes**, **tallies**, **governance parameters**.
|
|
5
|
+
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
## Setup
|
|
9
|
+
|
|
10
|
+
```ts
|
|
11
|
+
import {
|
|
12
|
+
ChainGovApi,
|
|
13
|
+
getNetworkEndpoints,
|
|
14
|
+
Network,
|
|
15
|
+
} from '@zuhaibnoor/zigchain-sdk'
|
|
16
|
+
|
|
17
|
+
const endpoints = getNetworkEndpoints(Network.Testnet)
|
|
18
|
+
const govApi = new ChainGovApi(endpoints)
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
---
|
|
22
|
+
|
|
23
|
+
## `fetchConstitution`
|
|
24
|
+
|
|
25
|
+
Fetch the **governance constitution** of the chain.
|
|
26
|
+
|
|
27
|
+
**CLI equivalent**
|
|
28
|
+
|
|
29
|
+
```bash
|
|
30
|
+
zigchaind query gov constitution
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
**Method**
|
|
34
|
+
|
|
35
|
+
```ts
|
|
36
|
+
fetchConstitution()
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
**Example**
|
|
40
|
+
|
|
41
|
+
```ts
|
|
42
|
+
const constitution = await govApi.fetchConstitution()
|
|
43
|
+
console.log(constitution)
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
---
|
|
47
|
+
|
|
48
|
+
## `fetchProposal`
|
|
49
|
+
|
|
50
|
+
Fetch a **single governance proposal by ID**.
|
|
51
|
+
|
|
52
|
+
**CLI equivalent**
|
|
53
|
+
|
|
54
|
+
```bash
|
|
55
|
+
zigchaind query gov proposal <id>
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
**Method**
|
|
59
|
+
|
|
60
|
+
```ts
|
|
61
|
+
fetchProposal(proposalId: string | number)
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
**Parameters**
|
|
65
|
+
|
|
66
|
+
* `proposalId` – Proposal ID to query.
|
|
67
|
+
|
|
68
|
+
**Example**
|
|
69
|
+
|
|
70
|
+
```ts
|
|
71
|
+
const proposal = await govApi.fetchProposal(12)
|
|
72
|
+
console.log(proposal)
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
---
|
|
76
|
+
|
|
77
|
+
## `fetchAllProposals`
|
|
78
|
+
|
|
79
|
+
Fetch **all governance proposals** on the chain.
|
|
80
|
+
|
|
81
|
+
**CLI equivalent**
|
|
82
|
+
|
|
83
|
+
```bash
|
|
84
|
+
zigchaind query gov proposals
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
**Method**
|
|
88
|
+
|
|
89
|
+
```ts
|
|
90
|
+
fetchAllProposals()
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
**Example**
|
|
94
|
+
|
|
95
|
+
```ts
|
|
96
|
+
const proposals = await govApi.fetchAllProposals()
|
|
97
|
+
console.log(proposals)
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
---
|
|
101
|
+
|
|
102
|
+
## `fetchTally`
|
|
103
|
+
|
|
104
|
+
Fetch the **vote tally for a proposal**.
|
|
105
|
+
|
|
106
|
+
**CLI equivalent**
|
|
107
|
+
|
|
108
|
+
```bash
|
|
109
|
+
zigchaind query gov tally <proposal_id>
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
**Method**
|
|
113
|
+
|
|
114
|
+
```ts
|
|
115
|
+
fetchTally(proposalId: string | number)
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
**Parameters**
|
|
119
|
+
|
|
120
|
+
* `proposalId` – Proposal ID to query tally for.
|
|
121
|
+
|
|
122
|
+
**Example**
|
|
123
|
+
|
|
124
|
+
```ts
|
|
125
|
+
const tally = await govApi.fetchTally(12)
|
|
126
|
+
console.log(tally)
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
---
|
|
130
|
+
|
|
131
|
+
## `fetchParams`
|
|
132
|
+
|
|
133
|
+
Fetch **governance module parameters** by type.
|
|
134
|
+
|
|
135
|
+
**CLI equivalent**
|
|
136
|
+
|
|
137
|
+
```bash
|
|
138
|
+
zigchaind query gov params <params_type>
|
|
139
|
+
```
|
|
140
|
+
|
|
141
|
+
**Method**
|
|
142
|
+
|
|
143
|
+
```ts
|
|
144
|
+
fetchParams(params_type: string)
|
|
145
|
+
```
|
|
146
|
+
|
|
147
|
+
**Parameters**
|
|
148
|
+
|
|
149
|
+
* `params_type` – Type of parameters to query
|
|
150
|
+
(e.g. `voting`, `deposit`, `tallying`).
|
|
151
|
+
|
|
152
|
+
**Example**
|
|
153
|
+
|
|
154
|
+
```ts
|
|
155
|
+
const votingParams = await govApi.fetchParams('voting')
|
|
156
|
+
console.log(votingParams)
|
|
157
|
+
```
|
|
158
|
+
|
|
159
|
+
---
|
|
160
|
+
|
|
161
|
+
## Notes
|
|
162
|
+
|
|
163
|
+
* All governance queries are **read-only**.
|
|
164
|
+
* Parameter queries must specify a valid `params_type`.
|
|
165
|
+
|
|
166
|
+
|