@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.
Files changed (42) hide show
  1. package/README.md +1 -1
  2. package/dist/circuit/ChainCircuitApi.d.ts.map +1 -1
  3. package/dist/circuit/ChainCircuitApi.js.map +1 -1
  4. package/dist/dex/ChainDexApi.d.ts.map +1 -1
  5. package/dist/dex/ChainDexApi.js.map +1 -1
  6. package/dist/distribution/ChainDistributionApi.d.ts.map +1 -1
  7. package/dist/distribution/ChainDistributionApi.js +0 -1
  8. package/dist/distribution/ChainDistributionApi.js.map +1 -1
  9. package/dist/index.d.ts +1 -1
  10. package/dist/index.d.ts.map +1 -1
  11. package/dist/index.js +1 -1
  12. package/dist/index.js.map +1 -1
  13. package/dist/staking/ChainStakingApi.d.ts +1 -5
  14. package/dist/staking/ChainStakingApi.d.ts.map +1 -1
  15. package/dist/staking/ChainStakingApi.js +9 -7
  16. package/dist/staking/ChainStakingApi.js.map +1 -1
  17. package/dist/upgrade/ChainUpgradeApi.d.ts.map +1 -1
  18. package/dist/validator-set/ChainValidator.d.ts +8 -0
  19. package/dist/validator-set/ChainValidator.d.ts.map +1 -0
  20. package/dist/validator-set/ChainValidator.js +15 -0
  21. package/dist/validator-set/ChainValidator.js.map +1 -0
  22. package/docs/block.md +325 -38
  23. package/docs/circuit.md +164 -35
  24. package/docs/dex.md +313 -63
  25. package/docs/distribution.md +664 -93
  26. package/docs/evidence.md +117 -122
  27. package/docs/factory.md +308 -62
  28. package/docs/gov.md +268 -70
  29. package/docs/ibc/ibcChannel.md +736 -249
  30. package/docs/ibc/ibcClient.md +608 -139
  31. package/docs/ibc-transfer.md +349 -90
  32. package/docs/interchain-accounts.md +151 -48
  33. package/docs/mint.md +173 -36
  34. package/docs/runtime.md +81 -42
  35. package/docs/slashing.md +209 -61
  36. package/docs/staking.md +534 -411
  37. package/docs/tokenwrapper.md +221 -64
  38. package/docs/txs.md +447 -0
  39. package/docs/upgrade.md +281 -58
  40. package/docs/validator-set.md +177 -0
  41. package/package.json +1 -1
  42. package/docs/comet-validator-set.md +0 -70
@@ -1,22 +1,75 @@
1
1
  # Token Wrapper Module
2
2
 
3
- The **Token Wrapper module** keeps track of ZIG tokens that move **out of ZigChain to other blockchains** and come **back again**.
4
- It helps the chain maintain balance by **locking tokens when they leave** and **unlocking them when they return**, so no extra tokens are ever created.
3
+ ## What is the Token Wrapper Module?
4
+
5
+ The **Token Wrapper module** is a ZigChain module that handles **wrapping and unwrapping tokens** transferred via IBC.
6
+
7
+ It acts as a controlled gateway between ZigChain and a counterparty chain. Tokens that arrive via IBC are held by the module and a corresponding wrapped representation is issued on ZigChain. When tokens are sent back out, the wrapped tokens are burned and the originals are released.
5
8
 
6
9
  ---
7
10
 
8
- ## How Token Wrapping Works (Simple Explanation)
11
+ ## Important Terminology
12
+
13
+ ### Token Wrapping
14
+
15
+ The process of converting an IBC-received token into a ZigChain-native wrapped representation. The original IBC token is held in custody by the module while the wrapped version circulates on ZigChain.
16
+
17
+ ### Unwrapping
9
18
 
10
- 1. You send **ZIG tokens out of ZigChain**
11
- 2. Those ZIG tokens are **locked** on ZigChain
12
- 3. You receive **wrapped ZIG** on another chain
13
- 4. If wrapped ZIG comes back:
19
+ The reverse process burning the wrapped token on ZigChain and releasing the original IBC token back to the counterparty chain.
20
+
21
+ ### IBC Denom
22
+
23
+ A token received via IBC has a denom in the format:
24
+
25
+ ```
26
+ ibc/<hash>
27
+ ```
14
28
 
15
- * Wrapped tokens are **destroyed**
16
- * Original ZIG tokens are **unlocked**
29
+ The hash is derived from the channel and original denom path, making each IBC token globally unique on the receiving chain.
17
30
 
18
- If wrapped ZIG is **spent on the other chain and never returned**,
19
- the corresponding ZIG **remains locked forever** on ZigChain.
31
+ ### Native vs Counterparty
32
+
33
+ | Term | Description |
34
+ | ------------------- | ------------------------------------------------------- |
35
+ | Native (ZigChain) | ZigChain's side of the IBC connection |
36
+ | Counterparty | The remote chain on the other end of the IBC channel |
37
+
38
+ ### IBC Channel
39
+
40
+ The specific IBC channel this module uses for transfers. Each direction has its own channel ID.
41
+
42
+ ```
43
+ native_channel = 'channel-0' (ZigChain's channel)
44
+ counterparty_channel = 'channel-612' (remote chain's channel)
45
+ ```
46
+
47
+ ### Client ID
48
+
49
+ The IBC light client ID tracking the counterparty chain's state.
50
+
51
+ ```
52
+ native_client_id = '07-tendermint-0'
53
+ counterparty_client_id = '07-tendermint-1163'
54
+ ```
55
+
56
+ ---
57
+
58
+ ### Operator Address
59
+
60
+ The address authorized to manage and configure the Token Wrapper module. A `proposed_operator_address` indicates a pending operator transfer that has not yet been accepted.
61
+
62
+ ---
63
+
64
+ ### Pauser Addresses
65
+
66
+ Addresses authorized to **pause** the Token Wrapper module in an emergency. When paused, wrapping and unwrapping are disabled to protect users.
67
+
68
+ ---
69
+
70
+ ### Total Transfers
71
+
72
+ Cumulative counters tracking the total volume of tokens moved through the module in each direction since deployment.
20
73
 
21
74
  ---
22
75
 
@@ -26,7 +79,7 @@ the corresponding ZIG **remains locked forever** on ZigChain.
26
79
  import {
27
80
  ChainTokenWrapperApi,
28
81
  getNetworkEndpoints,
29
- Network
82
+ Network,
30
83
  } from '@zuhaibnoor/zigchain-sdk'
31
84
 
32
85
  const endpoints = getNetworkEndpoints(Network.Testnet)
@@ -35,103 +88,207 @@ const tokenWrapperApi = new ChainTokenWrapperApi(endpoints)
35
88
 
36
89
  ---
37
90
 
38
- ## `fetchModuleInfo`
91
+ # 1️⃣ fetchModuleInfo
39
92
 
40
- Returns basic information about the Token Wrapper module.
93
+ ## Method
41
94
 
95
+ ```ts
96
+ async fetchModuleInfo()
97
+ ```
42
98
 
43
- **Method**
99
+ ## CLI Equivalent
44
100
 
45
- ```ts
46
- fetchModuleInfo()
101
+ ```bash
102
+ zigchaind query tokenwrapper module-info
47
103
  ```
48
104
 
49
- **Example**
105
+ ## Description
106
+
107
+ Fetches the **full configuration and current state** of the Token Wrapper module.
108
+
109
+ This is the most comprehensive query for this module — it returns the module's on-chain address and current token balances, the operator and pauser configuration, the IBC channel and client details connecting ZigChain to the counterparty chain, the wrapped token denom, and whether the module is currently enabled.
110
+
111
+ ## Parameters
112
+
113
+ None.
114
+
115
+ ## Usage Example
50
116
 
51
117
  ```ts
52
- const info = await tokenWrapperApi.fetchModuleInfo()
53
- console.log(info)
118
+ const moduleInfo = await tokenWrapperApi.fetchModuleInfo()
119
+ console.dir(moduleInfo, { depth: null })
120
+ ```
121
+
122
+ ## Example Response
123
+
124
+ ```json
125
+ {
126
+ "module_address": "zig1hdq87rzf327fwz8rw9rnmchj7qa3uxrpxds2fw",
127
+ "balances": [
128
+ {
129
+ "denom": "ibc/2CC0B1B7A981ACC74854717F221008484603BB8360E81B262411B0D830EDE9B0",
130
+ "amount": "1028"
131
+ },
132
+ {
133
+ "denom": "ibc/B6863C1B541063B17C757293EC2E45BD2984AAC8CADD5ED7EDC2DA58B99445DC",
134
+ "amount": "261743802259999999900"
135
+ },
136
+ { "denom": "uzig", "amount": "20166055" }
137
+ ],
138
+ "operator_address": "zig1fw7yrucw09guffffdac64c3x5yc6rtlpt0nm5a",
139
+ "proposed_operator_address": "zig126kn23lxurns83w2n59a7e0v2wprjdrrfv4xw8",
140
+ "pauser_addresses": [
141
+ "zig19n4c3nmegkt06e0zj0yydhppfe6pzz53y3zxlz",
142
+ "zig155tasjju2zne3dnnh8ns2zqqcpfuljmke8hedt"
143
+ ],
144
+ "token_wrapper_enabled": true,
145
+ "native_client_id": "07-tendermint-0",
146
+ "counterparty_client_id": "07-tendermint-1163",
147
+ "native_port": "transfer",
148
+ "counterparty_port": "transfer",
149
+ "native_channel": "channel-0",
150
+ "counterparty_channel": "channel-612",
151
+ "denom": "unit-zig",
152
+ "decimal_difference": 12
153
+ }
54
154
  ```
55
155
 
56
- **Use case**
156
+ ## Response Field Explanation
57
157
 
58
- * Verify that the Token Wrapper module is available and active on the chain
158
+ ### Module Identity and State
59
159
 
60
- ---
160
+ | Field | Description |
161
+ | ------------------------- | ----------------------------------------------------------------------------------- |
162
+ | module_address | On-chain address of the Token Wrapper module — holds IBC tokens in custody |
163
+ | token_wrapper_enabled | `true` if wrapping and unwrapping are currently active. `false` means paused |
164
+ | denom | The name of the wrapped token representation on ZigChain |
165
+ | decimal_difference | Decimal scaling factor between the wrapped and original token (12 = 10^12 scale) |
166
+
167
+ ### `balances`
168
+
169
+ The current token holdings of the module's custody address. These are the IBC tokens being held in reserve plus any native `uzig` for operational use.
170
+
171
+ | Field | Description |
172
+ | ------ | --------------------------------------------------------- |
173
+ | denom | Token denomination (`ibc/<hash>` or native denom) |
174
+ | amount | Amount currently held in the module's custody account |
61
175
 
62
- ## `fetchParams`
176
+ ### Access Control
63
177
 
64
- Fetches the **configuration parameters** of the Token Wrapper module.
178
+ | Field | Description |
179
+ | ------------------------- | -------------------------------------------------------------------------------- |
180
+ | operator_address | Address with authority to configure the module |
181
+ | proposed_operator_address | Pending operator transfer — this address has been proposed but not yet accepted |
182
+ | pauser_addresses | Addresses that can pause the module in an emergency (2 pausers on testnet) |
65
183
 
66
- **Method**
184
+ ### IBC Connection Configuration
185
+
186
+ | Field | Description |
187
+ | ----------------------- | -------------------------------------------------------------------- |
188
+ | native_client_id | ZigChain's IBC light client tracking the counterparty chain |
189
+ | counterparty_client_id | Counterparty chain's IBC light client tracking ZigChain |
190
+ | native_port | IBC port on ZigChain's side (always `transfer`) |
191
+ | counterparty_port | IBC port on the counterparty chain's side (always `transfer`) |
192
+ | native_channel | ZigChain's IBC channel ID for this connection (`channel-0`) |
193
+ | counterparty_channel | Counterparty chain's IBC channel ID (`channel-612`) |
194
+
195
+ ---
196
+
197
+ # 2️⃣ fetchParams
198
+
199
+ ## Method
67
200
 
68
201
  ```ts
69
- fetchParams()
202
+ async fetchParams()
70
203
  ```
71
204
 
72
- **Example**
205
+ ## CLI Equivalent
206
+
207
+ ```bash
208
+ zigchaind query tokenwrapper params
209
+ ```
210
+
211
+ ## Description
212
+
213
+ Fetches the **Token Wrapper module parameters**.
214
+
215
+ On ZigChain testnet, the params object is currently empty — all configuration is managed directly through the module info rather than a separate params structure. This endpoint is included for completeness and forward compatibility as the module evolves.
216
+
217
+ ## Parameters
218
+
219
+ None.
220
+
221
+ ## Usage Example
73
222
 
74
223
  ```ts
75
224
  const params = await tokenWrapperApi.fetchParams()
76
- console.log(params)
225
+ console.dir(params, { depth: null })
77
226
  ```
78
227
 
79
- **Use case**
228
+ ## Example Response
80
229
 
81
- * Check whether token wrapping is enabled
82
- * Inspect module behavior settings
230
+ ```json
231
+ {
232
+ "params": {}
233
+ }
234
+ ```
83
235
 
84
- ---
236
+ ## Response Field Explanation
237
+
238
+ | Field | Description |
239
+ | ------ | ------------------------------------------------------------------------ |
240
+ | params | Module parameter object. Currently empty on ZigChain testnet |
85
241
 
86
- ## `fetchTotalTransfers`
242
+ > The Token Wrapper module's operational configuration (channel IDs, operator address, pauser addresses, enabled state) is stored directly in module state and returned by `fetchModuleInfo`. The `params` endpoint is reserved for governance-controlled parameters that may be added in future module versions.
87
243
 
88
- Returns the **total amount of ZIG tokens**:
244
+ ---
89
245
 
90
- * Sent **out of ZigChain**
91
- * Returned **back to ZigChain**
246
+ # 3️⃣ fetchTotalTransfers
92
247
 
93
- **Method**
248
+ ## Method
94
249
 
95
250
  ```ts
96
- fetchTotalTransfers()
251
+ async fetchTotalTransfers()
97
252
  ```
98
253
 
99
- **Example**
254
+ ## CLI Equivalent
100
255
 
101
- ```ts
102
- const totals = await tokenWrapperApi.fetchTotalTransfers()
103
- console.log(totals)
256
+ ```bash
257
+ zigchaind query tokenwrapper total-transfers
104
258
  ```
105
259
 
106
- **What this tells you**
260
+ ## Description
107
261
 
108
- * How much ZIG is currently **locked**
109
- * How much ZIG has **returned**
110
- * Helps audit cross-chain token movement
262
+ Fetches the **cumulative transfer volume** through the Token Wrapper module since its deployment — the total amount of tokens that have been wrapped (transferred in) and unwrapped (transferred out).
111
263
 
112
- ---
264
+ This provides a lifetime volume metric for the bridge, useful for analytics and monitoring net flow direction.
113
265
 
114
- ## Real-World Example
266
+ ## Parameters
115
267
 
116
- * You send **10 ZIG** out of ZigChain
117
- * ZigChain **locks 10 ZIG**
118
- * You receive **10 wrapped ZIG** on another chain
119
- * You spend **5 wrapped ZIG**
120
- * You return **5 wrapped ZIG** back
268
+ None.
121
269
 
122
- Result:
270
+ ## Usage Example
123
271
 
124
- * **5 ZIG unlocked and returned**
125
- * **5 ZIG remain locked forever** (because they were spent)
272
+ ```ts
273
+ const totals = await tokenWrapperApi.fetchTotalTransfers()
274
+ console.dir(totals, { depth: null })
275
+ ```
126
276
 
127
- ---
277
+ ## Example Response
278
+
279
+ ```json
280
+ {
281
+ "total_transferred_in": "490615709",
282
+ "total_transferred_out": "191529021"
283
+ }
284
+ ```
128
285
 
129
- ## Summary Table
286
+ ## Response Field Explanation
130
287
 
131
- | Function | Purpose |
132
- | --------------------- | ----------------------------------------------- |
133
- | `fetchModuleInfo` | Shows basic info about the Token Wrapper module |
134
- | `fetchParams` | Displays module configuration settings |
135
- | `fetchTotalTransfers` | Shows total ZIG moved out and returned |
288
+ | Field | Description |
289
+ | ---------------------- | ---------------------------------------------------------------------------- |
290
+ | total_transferred_in | Cumulative amount of tokens wrapped (received from counterparty chain) |
291
+ | total_transferred_out | Cumulative amount of tokens unwrapped (sent back to counterparty chain) |
136
292
 
137
293
 
294
+ ---