@zuhaibnoor/zigchain-sdk 1.1.0 → 1.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/dist/circuit/ChainCircuitApi.d.ts.map +1 -1
- package/dist/circuit/ChainCircuitApi.js.map +1 -1
- package/dist/dex/ChainDexApi.d.ts.map +1 -1
- package/dist/dex/ChainDexApi.js.map +1 -1
- package/dist/distribution/ChainDistributionApi.d.ts.map +1 -1
- package/dist/distribution/ChainDistributionApi.js +0 -1
- package/dist/distribution/ChainDistributionApi.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/staking/ChainStakingApi.d.ts +1 -5
- package/dist/staking/ChainStakingApi.d.ts.map +1 -1
- package/dist/staking/ChainStakingApi.js +9 -7
- package/dist/staking/ChainStakingApi.js.map +1 -1
- package/dist/upgrade/ChainUpgradeApi.d.ts.map +1 -1
- package/dist/validator-set/ChainValidator.d.ts +8 -0
- package/dist/validator-set/ChainValidator.d.ts.map +1 -0
- package/dist/validator-set/ChainValidator.js +15 -0
- package/dist/validator-set/ChainValidator.js.map +1 -0
- package/docs/block.md +325 -38
- package/docs/circuit.md +164 -35
- package/docs/dex.md +313 -63
- package/docs/distribution.md +664 -93
- package/docs/evidence.md +117 -122
- package/docs/factory.md +308 -62
- package/docs/gov.md +268 -70
- package/docs/ibc/ibcChannel.md +736 -249
- package/docs/ibc/ibcClient.md +608 -139
- package/docs/ibc-transfer.md +349 -90
- package/docs/interchain-accounts.md +151 -48
- package/docs/mint.md +173 -36
- package/docs/runtime.md +81 -42
- package/docs/slashing.md +209 -61
- package/docs/staking.md +534 -411
- package/docs/tokenwrapper.md +221 -64
- package/docs/txs.md +447 -0
- package/docs/upgrade.md +281 -58
- package/docs/validator-set.md +177 -0
- package/package.json +1 -1
- package/docs/comet-validator-set.md +0 -70
package/docs/ibc/ibcChannel.md
CHANGED
|
@@ -1,490 +1,977 @@
|
|
|
1
|
-
# IBC Module
|
|
1
|
+
# IBC Channel Module
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
## What is IBC?
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
**IBC (Inter-Blockchain Communication)** is a protocol that allows independent blockchains to securely exchange messages and tokens. ZigChain uses IBC to connect with other Cosmos ecosystem chains.
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
The IBC stack has four layers that build on each other:
|
|
8
8
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
9
|
+
```
|
|
10
|
+
Packets → the messages/tokens being transferred
|
|
11
|
+
Channels → the lanes packets travel through
|
|
12
|
+
Connections → the secured links between two chains
|
|
13
|
+
Clients → light clients that verify the other chain's state
|
|
14
|
+
```
|
|
15
|
+
---
|
|
13
16
|
|
|
14
|
-
|
|
17
|
+
## Important Terminology
|
|
15
18
|
|
|
16
|
-
|
|
17
|
-
import {
|
|
18
|
-
ChainIbcChannelApi,
|
|
19
|
-
getNetworkEndpoints,
|
|
20
|
-
Network,
|
|
21
|
-
} from '@zuhaibnoor/zigchain-sdk'
|
|
19
|
+
### Channel
|
|
22
20
|
|
|
23
|
-
|
|
24
|
-
|
|
21
|
+
A **channel** is a communication lane between a specific port on ZigChain and a specific port on a counterparty chain. All IBC token transfers go through channels. Each channel is built on top of a connection.
|
|
22
|
+
|
|
23
|
+
```
|
|
24
|
+
channel-0 (ZigChain) ↔ channel-612 (counterparty)
|
|
25
25
|
```
|
|
26
26
|
|
|
27
27
|
---
|
|
28
|
-
## `fetchChannels()`
|
|
29
28
|
|
|
30
|
-
###
|
|
29
|
+
### Port
|
|
31
30
|
|
|
32
|
-
|
|
31
|
+
A **port** is an application-level identifier that specifies which module on a chain handles the packets. The standard token transfer port is `transfer`. NFT transfers use `wasm.<contract-address>` ports.
|
|
33
32
|
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
33
|
+
```
|
|
34
|
+
port_id = 'transfer'
|
|
35
|
+
```
|
|
37
36
|
|
|
38
|
-
|
|
37
|
+
---
|
|
39
38
|
|
|
40
|
-
|
|
41
|
-
* Channel = lane inside that cable
|
|
42
|
-
* Packet = message sent through the lane
|
|
39
|
+
### Channel State
|
|
43
40
|
|
|
44
|
-
|
|
41
|
+
| State | Meaning |
|
|
42
|
+
| ------------ | ---------------------------------------------------------- |
|
|
43
|
+
| `STATE_OPEN` | Channel is active and can send/receive packets |
|
|
44
|
+
| `STATE_INIT` | Channel is being opened — handshake in progress |
|
|
45
|
+
| `STATE_TRYOPEN` | Counterparty acknowledged the open, waiting for confirmation |
|
|
46
|
+
| `STATE_CLOSED` | Channel has been closed — no longer usable |
|
|
45
47
|
|
|
46
48
|
---
|
|
47
49
|
|
|
48
|
-
###
|
|
50
|
+
### Channel Ordering
|
|
49
51
|
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
52
|
+
| Ordering | Meaning |
|
|
53
|
+
| ------------------ | --------------------------------------------------------------- |
|
|
54
|
+
| `ORDER_UNORDERED` | Packets can be received in any order — used for token transfers |
|
|
55
|
+
| `ORDER_ORDERED` | Packets must be received in sequence — used for ordered apps |
|
|
53
56
|
|
|
54
|
-
|
|
57
|
+
All ZigChain IBC channels use `ORDER_UNORDERED`.
|
|
55
58
|
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
```
|
|
59
|
+
---
|
|
60
|
+
|
|
61
|
+
### Connection Hops
|
|
60
62
|
|
|
61
|
-
|
|
63
|
+
The list of connections a channel traverses. For a direct channel this is always one connection. Multi-hop channels (not yet standard) would have multiple hops.
|
|
62
64
|
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
* whether the channel is OPEN or CLOSED
|
|
65
|
+
```
|
|
66
|
+
connection_hops = ['connection-0']
|
|
67
|
+
```
|
|
67
68
|
|
|
68
69
|
---
|
|
69
70
|
|
|
70
|
-
|
|
71
|
+
### Packet Sequence Number
|
|
71
72
|
|
|
72
|
-
|
|
73
|
-
|
|
73
|
+
Every packet sent through a channel gets an incrementing integer sequence number. This prevents duplicates, ensures ordering where required, and allows tracking of specific packets.
|
|
74
|
+
|
|
75
|
+
```
|
|
76
|
+
sequence = 70
|
|
74
77
|
```
|
|
75
78
|
|
|
76
|
-
|
|
79
|
+
---
|
|
80
|
+
|
|
81
|
+
### Packet Commitment
|
|
77
82
|
|
|
78
|
-
|
|
83
|
+
A **cryptographic hash** stored on the sending chain when a packet is created. It proves the packet exists and was committed to chain state. Used by the receiving chain to verify the packet is legitimate.
|
|
79
84
|
|
|
80
85
|
---
|
|
81
86
|
|
|
82
|
-
###
|
|
87
|
+
### Packet Acknowledgement
|
|
83
88
|
|
|
84
|
-
|
|
89
|
+
A **confirmation** sent back from the receiving chain after processing a packet. It proves the packet was received and whether it succeeded or failed.
|
|
85
90
|
|
|
86
|
-
|
|
87
|
-
* Confirms that the other chain is valid
|
|
91
|
+
---
|
|
88
92
|
|
|
89
|
-
|
|
90
|
-
It is NOT a wallet.
|
|
93
|
+
### Packet Receipt
|
|
91
94
|
|
|
92
|
-
|
|
95
|
+
A record stored on the receiving chain after a packet is processed. Proves the packet was received — used to prevent replay attacks.
|
|
93
96
|
|
|
94
97
|
---
|
|
95
98
|
|
|
96
|
-
###
|
|
99
|
+
### Proof Height
|
|
97
100
|
|
|
98
|
-
|
|
101
|
+
The block height at which the returned proof or data was generated.
|
|
99
102
|
|
|
100
|
-
|
|
103
|
+
```json
|
|
104
|
+
{ "revision_number": "2", "revision_height": "4647092" }
|
|
105
|
+
```
|
|
101
106
|
|
|
102
|
-
|
|
107
|
+
`revision_number` is the chain's revision (incremented on resets). `revision_height` is the block number.
|
|
103
108
|
|
|
104
|
-
|
|
109
|
+
---
|
|
105
110
|
|
|
106
|
-
|
|
107
|
-
* latest height
|
|
108
|
-
* trust level
|
|
109
|
-
* proof parameters
|
|
111
|
+
## Setup
|
|
110
112
|
|
|
111
|
-
|
|
113
|
+
```ts
|
|
114
|
+
import {
|
|
115
|
+
ChainIbcChannelApi,
|
|
116
|
+
getNetworkEndpoints,
|
|
117
|
+
Network,
|
|
118
|
+
} from '@zuhaibnoor/zigchain-sdk'
|
|
112
119
|
|
|
113
|
-
|
|
120
|
+
const endpoints = getNetworkEndpoints(Network.Testnet)
|
|
121
|
+
const ibcChannelApi = new ChainIbcChannelApi(endpoints)
|
|
114
122
|
|
|
115
|
-
|
|
116
|
-
|
|
123
|
+
const portId = 'transfer'
|
|
124
|
+
const channelId = 'channel-0'
|
|
117
125
|
```
|
|
118
126
|
|
|
119
|
-
|
|
127
|
+
---
|
|
128
|
+
|
|
129
|
+
# 1️⃣ fetchChannels
|
|
130
|
+
|
|
131
|
+
## Method
|
|
120
132
|
|
|
121
133
|
```ts
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
'channel-0'
|
|
125
|
-
)
|
|
134
|
+
async fetchChannels()
|
|
135
|
+
```
|
|
126
136
|
|
|
127
|
-
|
|
137
|
+
## CLI Equivalent
|
|
138
|
+
|
|
139
|
+
```bash
|
|
140
|
+
zigchaind query ibc channel channels
|
|
128
141
|
```
|
|
142
|
+
## Description
|
|
129
143
|
|
|
130
|
-
|
|
144
|
+
Fetches **all IBC channels** registered on ZigChain across all ports and connections.
|
|
131
145
|
|
|
132
|
-
##
|
|
146
|
+
## Parameters
|
|
147
|
+
|
|
148
|
+
None.
|
|
149
|
+
|
|
150
|
+
## Usage Example
|
|
133
151
|
|
|
134
152
|
```ts
|
|
135
|
-
|
|
153
|
+
const channels = await ibcChannelApi.fetchChannels()
|
|
154
|
+
console.dir(channels, { depth: null })
|
|
136
155
|
```
|
|
137
156
|
|
|
138
|
-
|
|
157
|
+
## Example Response
|
|
158
|
+
|
|
159
|
+
```json
|
|
160
|
+
{
|
|
161
|
+
"channels": [
|
|
162
|
+
{
|
|
163
|
+
"state": "STATE_OPEN",
|
|
164
|
+
"ordering": "ORDER_UNORDERED",
|
|
165
|
+
"counterparty": {
|
|
166
|
+
"port_id": "transfer",
|
|
167
|
+
"channel_id": "channel-612"
|
|
168
|
+
},
|
|
169
|
+
"connection_hops": ["connection-0"],
|
|
170
|
+
"version": "ics20-1",
|
|
171
|
+
"port_id": "transfer",
|
|
172
|
+
"channel_id": "channel-0"
|
|
173
|
+
},
|
|
174
|
+
{
|
|
175
|
+
"state": "STATE_OPEN",
|
|
176
|
+
"ordering": "ORDER_UNORDERED",
|
|
177
|
+
"counterparty": {
|
|
178
|
+
"port_id": "wasm.inj1wvtzf6s4rdpttgvpvgwwfpepv8uw0gxvs5qwxp",
|
|
179
|
+
"channel_id": "channel-77060"
|
|
180
|
+
},
|
|
181
|
+
"connection_hops": ["connection-39"],
|
|
182
|
+
"version": "ics721-1",
|
|
183
|
+
"port_id": "wasm.zig12gmfscd27ercy99t9tlmntljnr87muhtpykygpjssf5m63xrma3qymqjp2",
|
|
184
|
+
"channel_id": "channel-25"
|
|
185
|
+
}
|
|
186
|
+
],
|
|
187
|
+
"pagination": { "next_key": null, "total": "48" },
|
|
188
|
+
"height": { "revision_number": "2", "revision_height": "4647091" }
|
|
189
|
+
}
|
|
190
|
+
```
|
|
139
191
|
|
|
140
|
-
|
|
192
|
+
## Response Field Explanation
|
|
141
193
|
|
|
142
|
-
|
|
194
|
+
### `channels[]`
|
|
195
|
+
|
|
196
|
+
| Field | Description |
|
|
197
|
+
| ---------------- | -------------------------------------------------------------------- |
|
|
198
|
+
| state | Current channel state (`STATE_OPEN`, `STATE_INIT`, etc.) |
|
|
199
|
+
| ordering | Packet ordering mode (`ORDER_UNORDERED` for all ZigChain channels) |
|
|
200
|
+
| counterparty.port_id | Port on the remote chain this channel connects to |
|
|
201
|
+
| counterparty.channel_id | Channel ID on the remote chain |
|
|
202
|
+
| connection_hops | Connection(s) this channel is built on |
|
|
203
|
+
| version | IBC application protocol (`ics20-1` for tokens, `ics721-1` for NFTs)|
|
|
204
|
+
| port_id | Port on ZigChain this channel is bound to |
|
|
205
|
+
| channel_id | ZigChain's channel identifier |
|
|
206
|
+
|
|
207
|
+
### `height`
|
|
143
208
|
|
|
144
|
-
|
|
209
|
+
The block height at which this data was read.
|
|
145
210
|
|
|
146
|
-
|
|
211
|
+
### Channel Types on ZigChain Testnet
|
|
147
212
|
|
|
148
|
-
|
|
213
|
+
| Version | Port Type | Use Case | Example |
|
|
214
|
+
| ---------- | ---------------- | -------------------- | ---------------------- |
|
|
215
|
+
| `ics20-1` | `transfer` | Fungible token IBC | `channel-0` to Axelar |
|
|
216
|
+
| `ics721-1` | `wasm.<address>` | NFT IBC transfers | `channel-25` to Injective |
|
|
149
217
|
|
|
150
|
-
|
|
151
|
-
* Connection = secured bridge
|
|
152
|
-
* Channel = lane on the bridge
|
|
218
|
+
## When to Use
|
|
153
219
|
|
|
154
|
-
|
|
220
|
+
* Building IBC channel explorers or dashboards
|
|
221
|
+
* Discovering which chains ZigChain is connected to
|
|
222
|
+
* Finding the correct channel ID before initiating an IBC transfer
|
|
223
|
+
* Monitoring for new channel openings or closures
|
|
155
224
|
|
|
156
225
|
---
|
|
157
226
|
|
|
158
|
-
|
|
227
|
+
# 2️⃣ fetchChannelClientState
|
|
228
|
+
|
|
229
|
+
## Method
|
|
230
|
+
|
|
231
|
+
```ts
|
|
232
|
+
async fetchChannelClientState(portId: string, channelId: string)
|
|
233
|
+
```
|
|
234
|
+
|
|
235
|
+
## CLI Equivalent
|
|
159
236
|
|
|
160
237
|
```bash
|
|
161
|
-
zigchaind query ibc channel
|
|
238
|
+
zigchaind query ibc channel client-state <port-id> <channel-id>
|
|
162
239
|
```
|
|
163
240
|
|
|
164
|
-
|
|
241
|
+
## Description
|
|
242
|
+
|
|
243
|
+
Fetches the **IBC light client state** associated with a specific channel.
|
|
244
|
+
|
|
245
|
+
The light client is ZigChain's internal verifier for the counterparty chain. Its state includes the counterparty chain's ID, the latest tracked height, trust parameters, and proof specifications. This tells you what chain is on the other end of the channel and how ZigChain is currently tracking it.
|
|
246
|
+
|
|
247
|
+
## Parameters
|
|
248
|
+
|
|
249
|
+
| Name | Type | Description |
|
|
250
|
+
| --------- | ------ | ----------------------------------------------------- |
|
|
251
|
+
| portId | string | Port the channel is bound to (e.g. `'transfer'`) |
|
|
252
|
+
| channelId | string | Channel identifier (e.g. `'channel-0'`) |
|
|
253
|
+
|
|
254
|
+
## Usage Example
|
|
165
255
|
|
|
166
256
|
```ts
|
|
167
|
-
const
|
|
168
|
-
|
|
169
|
-
|
|
257
|
+
const clientState = await ibcChannelApi.fetchChannelClientState('transfer', 'channel-0')
|
|
258
|
+
console.dir(clientState, { depth: null })
|
|
259
|
+
```
|
|
170
260
|
|
|
171
|
-
|
|
261
|
+
## Example Response
|
|
262
|
+
|
|
263
|
+
```json
|
|
264
|
+
{
|
|
265
|
+
"identified_client_state": {
|
|
266
|
+
"client_id": "07-tendermint-0",
|
|
267
|
+
"client_state": {
|
|
268
|
+
"@type": "/ibc.lightclients.tendermint.v1.ClientState",
|
|
269
|
+
"chain_id": "axelar-testnet-lisbon-3",
|
|
270
|
+
"trust_level": { "numerator": "2", "denominator": "3" },
|
|
271
|
+
"trusting_period": "403200s",
|
|
272
|
+
"unbonding_period": "604800s",
|
|
273
|
+
"max_clock_drift": "40s",
|
|
274
|
+
"frozen_height": { "revision_number": "0", "revision_height": "0" },
|
|
275
|
+
"latest_height": { "revision_number": "3", "revision_height": "26422416" }
|
|
276
|
+
}
|
|
277
|
+
},
|
|
278
|
+
"proof": null,
|
|
279
|
+
"proof_height": { "revision_number": "2", "revision_height": "4647092" }
|
|
280
|
+
}
|
|
172
281
|
```
|
|
173
282
|
|
|
283
|
+
## Response Field Explanation
|
|
284
|
+
|
|
285
|
+
### `identified_client_state`
|
|
286
|
+
|
|
287
|
+
| Field | Description |
|
|
288
|
+
| ---------------- | ------------------------------------------------------------------ |
|
|
289
|
+
| client_id | IBC light client ID tracking this counterparty (`07-tendermint-0`) |
|
|
290
|
+
| client_state.@type | Client implementation type — Tendermint for Cosmos chains |
|
|
291
|
+
| client_state.chain_id | The counterparty chain's chain ID |
|
|
292
|
+
| trust_level | Fraction of validators needed to trust an update (2/3 = standard) |
|
|
293
|
+
| trusting_period | How long a header can be trusted without an update (in seconds) |
|
|
294
|
+
| unbonding_period | Counterparty chain's unbonding period |
|
|
295
|
+
| max_clock_drift | Maximum allowed time difference between chains |
|
|
296
|
+
| frozen_height | If non-zero, the client is frozen due to misbehaviour |
|
|
297
|
+
| latest_height | Most recent counterparty block this client has verified |
|
|
298
|
+
|
|
299
|
+
> `channel-0` connects ZigChain to `axelar-testnet-lisbon-3` via client `07-tendermint-0`. The counterparty is at block height `26,422,416`.
|
|
300
|
+
|
|
301
|
+
> A `frozen_height` of `0` means the client is healthy and not frozen.
|
|
302
|
+
|
|
303
|
+
## When to Use
|
|
304
|
+
|
|
305
|
+
* Identifying which chain is on the other end of a channel
|
|
306
|
+
* Verifying the light client is not frozen before attempting a transfer
|
|
307
|
+
* Debugging IBC transfer failures caused by expired or outdated clients
|
|
308
|
+
* Chain connectivity dashboards showing counterparty chain details
|
|
309
|
+
|
|
174
310
|
---
|
|
175
311
|
|
|
176
|
-
|
|
312
|
+
# 3️⃣ fetchChannelsByConnection
|
|
313
|
+
|
|
314
|
+
## Method
|
|
177
315
|
|
|
178
316
|
```ts
|
|
179
|
-
|
|
317
|
+
async fetchChannelsByConnection(connectionId: string)
|
|
180
318
|
```
|
|
181
319
|
|
|
182
|
-
|
|
320
|
+
## CLI Equivalent
|
|
183
321
|
|
|
184
|
-
|
|
322
|
+
```bash
|
|
323
|
+
zigchaind query ibc channel connections <connection-id>
|
|
324
|
+
```
|
|
185
325
|
|
|
186
|
-
|
|
326
|
+
## Description
|
|
187
327
|
|
|
188
|
-
|
|
328
|
+
Fetches **all channels built on a specific connection**.
|
|
189
329
|
|
|
190
|
-
|
|
330
|
+
A single IBC connection can host multiple channels for different applications. This lets you see all the communication lanes running over a particular secured link between two chains.
|
|
191
331
|
|
|
192
|
-
|
|
332
|
+
## Parameters
|
|
193
333
|
|
|
194
|
-
|
|
334
|
+
| Name | Type | Description |
|
|
335
|
+
| ------------ | ------ | ----------------------------------------- |
|
|
336
|
+
| connectionId | string | Connection identifier (e.g. `'connection-0'`) |
|
|
195
337
|
|
|
196
|
-
|
|
197
|
-
* The other chain has another end
|
|
338
|
+
## Usage Example
|
|
198
339
|
|
|
199
|
-
|
|
340
|
+
```ts
|
|
341
|
+
const byConnection = await ibcChannelApi.fetchChannelsByConnection('connection-0')
|
|
342
|
+
console.dir(byConnection, { depth: null })
|
|
343
|
+
```
|
|
200
344
|
|
|
201
|
-
|
|
345
|
+
## Example Response
|
|
346
|
+
|
|
347
|
+
```json
|
|
348
|
+
{
|
|
349
|
+
"channels": [
|
|
350
|
+
{
|
|
351
|
+
"state": "STATE_OPEN",
|
|
352
|
+
"ordering": "ORDER_UNORDERED",
|
|
353
|
+
"counterparty": { "port_id": "transfer", "channel_id": "channel-612" },
|
|
354
|
+
"connection_hops": ["connection-0"],
|
|
355
|
+
"version": "ics20-1",
|
|
356
|
+
"port_id": "transfer",
|
|
357
|
+
"channel_id": "channel-0"
|
|
358
|
+
},
|
|
359
|
+
{
|
|
360
|
+
"state": "STATE_OPEN",
|
|
361
|
+
"ordering": "ORDER_UNORDERED",
|
|
362
|
+
"counterparty": { "port_id": "transfer", "channel_id": "channel-614" },
|
|
363
|
+
"connection_hops": ["connection-0"],
|
|
364
|
+
"version": "ics20-1",
|
|
365
|
+
"port_id": "transfer",
|
|
366
|
+
"channel_id": "channel-1"
|
|
367
|
+
}
|
|
368
|
+
],
|
|
369
|
+
"pagination": { "next_key": null, "total": "2" },
|
|
370
|
+
"height": { "revision_number": "2", "revision_height": "4647092" }
|
|
371
|
+
}
|
|
372
|
+
```
|
|
202
373
|
|
|
203
|
-
|
|
374
|
+
## Response Field Explanation
|
|
204
375
|
|
|
205
|
-
|
|
206
|
-
zigchaind query ibc channel end <port-id> <channel-id>
|
|
207
|
-
```
|
|
376
|
+
Same channel object structure as `fetchChannels`. See that section for full field descriptions.
|
|
208
377
|
|
|
209
378
|
---
|
|
210
379
|
|
|
211
|
-
|
|
380
|
+
# 4️⃣ fetchChannelEnd
|
|
381
|
+
|
|
382
|
+
## Method
|
|
212
383
|
|
|
213
384
|
```ts
|
|
214
|
-
|
|
385
|
+
async fetchChannelEnd(portId: string, channelId: string)
|
|
386
|
+
```
|
|
387
|
+
|
|
388
|
+
## CLI Equivalent
|
|
389
|
+
|
|
390
|
+
```bash
|
|
391
|
+
zigchaind query ibc channel end <port-id> <channel-id>
|
|
215
392
|
```
|
|
216
393
|
|
|
217
|
-
|
|
394
|
+
## Description
|
|
218
395
|
|
|
219
|
-
|
|
396
|
+
Fetches the **channel end** — ZigChain's stored state for a specific channel.
|
|
220
397
|
|
|
221
|
-
|
|
398
|
+
A channel exists on both chains simultaneously; each chain stores its own "end." This function returns ZigChain's end, which includes the channel's state, ordering, counterparty identifiers, connection, and version. It is the single-channel equivalent of an entry in `fetchChannels`.
|
|
222
399
|
|
|
223
|
-
|
|
400
|
+
## Parameters
|
|
224
401
|
|
|
225
|
-
|
|
402
|
+
| Name | Type | Description |
|
|
403
|
+
| --------- | ------ | ------------------------------------------------ |
|
|
404
|
+
| portId | string | Port the channel is bound to (e.g. `'transfer'`) |
|
|
405
|
+
| channelId | string | Channel identifier (e.g. `'channel-0'`) |
|
|
226
406
|
|
|
227
|
-
|
|
228
|
-
2
|
|
229
|
-
3
|
|
230
|
-
4
|
|
407
|
+
## Usage Example
|
|
231
408
|
|
|
232
|
-
|
|
409
|
+
```ts
|
|
410
|
+
const channelEnd = await ibcChannelApi.fetchChannelEnd('transfer', 'channel-0')
|
|
411
|
+
console.dir(channelEnd, { depth: null })
|
|
412
|
+
```
|
|
233
413
|
|
|
234
|
-
|
|
414
|
+
## Example Response
|
|
415
|
+
|
|
416
|
+
```json
|
|
417
|
+
{
|
|
418
|
+
"channel": {
|
|
419
|
+
"state": "STATE_OPEN",
|
|
420
|
+
"ordering": "ORDER_UNORDERED",
|
|
421
|
+
"counterparty": { "port_id": "transfer", "channel_id": "channel-612" },
|
|
422
|
+
"connection_hops": ["connection-0"],
|
|
423
|
+
"version": "ics20-1"
|
|
424
|
+
},
|
|
425
|
+
"proof": null,
|
|
426
|
+
"proof_height": { "revision_number": "2", "revision_height": "4647092" }
|
|
427
|
+
}
|
|
428
|
+
```
|
|
235
429
|
|
|
236
|
-
|
|
237
|
-
* No skipped packets
|
|
238
|
-
* Proper ordering
|
|
430
|
+
## Response Field Explanation
|
|
239
431
|
|
|
240
|
-
|
|
432
|
+
### `channel`
|
|
241
433
|
|
|
242
|
-
|
|
434
|
+
| Field | Description |
|
|
435
|
+
| --------------- | ------------------------------------------------------- |
|
|
436
|
+
| state | Current channel state |
|
|
437
|
+
| ordering | Packet ordering mode |
|
|
438
|
+
| counterparty | Port and channel ID on the remote chain |
|
|
439
|
+
| connection_hops | Connection(s) this channel uses |
|
|
440
|
+
| version | IBC application protocol version |
|
|
243
441
|
|
|
244
|
-
|
|
442
|
+
### `fetchChannels` vs `fetchChannelEnd`
|
|
245
443
|
|
|
246
|
-
|
|
444
|
+
| Feature | fetchChannels | fetchChannelEnd |
|
|
445
|
+
| --------------------- | ----------------------- | ---------------------------- |
|
|
446
|
+
| Scope | All channels | Single channel |
|
|
447
|
+
| Includes channel ID | ✅ Yes | ❌ No (you provide it) |
|
|
448
|
+
| Includes proof_height | ❌ No | ✅ Yes |
|
|
449
|
+
| Use case | Full channel discovery | Single channel verification |
|
|
247
450
|
|
|
248
|
-
|
|
249
|
-
|
|
451
|
+
## When to Use
|
|
452
|
+
|
|
453
|
+
* Verifying a specific channel is open before initiating a transfer
|
|
454
|
+
* Checking counterparty channel and port for a known channel
|
|
250
455
|
|
|
251
456
|
---
|
|
252
457
|
|
|
253
|
-
|
|
458
|
+
# 5️⃣ fetchNextSequenceReceive
|
|
459
|
+
|
|
460
|
+
## Method
|
|
461
|
+
|
|
462
|
+
```ts
|
|
463
|
+
async fetchNextSequenceReceive(portId: string, channelId: string)
|
|
464
|
+
```
|
|
465
|
+
|
|
466
|
+
## CLI Equivalent
|
|
254
467
|
|
|
255
468
|
```bash
|
|
256
469
|
zigchaind query ibc channel next-sequence-receive <port-id> <channel-id>
|
|
257
470
|
```
|
|
258
471
|
|
|
259
|
-
|
|
472
|
+
## Description
|
|
260
473
|
|
|
261
|
-
|
|
474
|
+
Fetches the **next packet sequence number ZigChain expects to receive** on a channel.
|
|
475
|
+
|
|
476
|
+
If this returns `15`, ZigChain has already processed packets 1–14 and is waiting for packet 15. A value of `0` on ZigChain testnet's `channel-0` reflects that this channel is primarily used for outbound transfers.
|
|
477
|
+
|
|
478
|
+
## Parameters
|
|
479
|
+
|
|
480
|
+
| Name | Type | Description |
|
|
481
|
+
| --------- | ------ | ------------------------------------------------ |
|
|
482
|
+
| portId | string | Port the channel is bound to (e.g. `'transfer'`) |
|
|
483
|
+
| channelId | string | Channel identifier (e.g. `'channel-0'`) |
|
|
484
|
+
|
|
485
|
+
## Usage Example
|
|
262
486
|
|
|
263
487
|
```ts
|
|
264
|
-
|
|
488
|
+
const nextRecv = await ibcChannelApi.fetchNextSequenceReceive('transfer', 'channel-0')
|
|
489
|
+
console.dir(nextRecv, { depth: null })
|
|
265
490
|
```
|
|
266
491
|
|
|
267
|
-
|
|
492
|
+
## Example Response
|
|
268
493
|
|
|
269
|
-
|
|
494
|
+
```json
|
|
495
|
+
{
|
|
496
|
+
"next_sequence_receive": "0",
|
|
497
|
+
"proof": null,
|
|
498
|
+
"proof_height": { "revision_number": "2", "revision_height": "4647093" }
|
|
499
|
+
}
|
|
500
|
+
```
|
|
270
501
|
|
|
271
|
-
|
|
502
|
+
## Response Field Explanation
|
|
272
503
|
|
|
273
|
-
|
|
504
|
+
| Field | Description |
|
|
505
|
+
| --------------------- | ---------------------------------------------------------------------- |
|
|
506
|
+
| next_sequence_receive | The next packet sequence this chain expects to receive on this channel |
|
|
507
|
+
| proof | Merkle proof (null for simple queries) |
|
|
508
|
+
| proof_height | Block height at which this data was read |
|
|
274
509
|
|
|
275
|
-
|
|
276
|
-
then the next packet you send will be sequence number 20.
|
|
510
|
+
## When to Use
|
|
277
511
|
|
|
278
|
-
|
|
512
|
+
* Monitoring incoming packet delivery progress
|
|
513
|
+
* Detecting stuck inbound packets
|
|
514
|
+
* Verifying a channel is actively receiving packets
|
|
279
515
|
|
|
280
516
|
---
|
|
281
517
|
|
|
282
|
-
|
|
518
|
+
# 6️⃣ fetchNextSequenceSend
|
|
519
|
+
|
|
520
|
+
## Method
|
|
521
|
+
|
|
522
|
+
```ts
|
|
523
|
+
async fetchNextSequenceSend(portId: string, channelId: string)
|
|
524
|
+
```
|
|
525
|
+
|
|
526
|
+
## CLI Equivalent
|
|
283
527
|
|
|
284
528
|
```bash
|
|
285
529
|
zigchaind query ibc channel next-sequence-send <port-id> <channel-id>
|
|
286
530
|
```
|
|
287
531
|
|
|
288
|
-
|
|
532
|
+
## Description
|
|
533
|
+
|
|
534
|
+
Fetches the **next packet sequence number that will be assigned** when a new packet is sent on this channel.
|
|
535
|
+
|
|
536
|
+
If this returns `74`, then 73 packets have already been sent and the next outbound transfer on this channel will be sequence `74`.
|
|
537
|
+
|
|
538
|
+
## Parameters
|
|
289
539
|
|
|
290
|
-
|
|
540
|
+
| Name | Type | Description |
|
|
541
|
+
| --------- | ------ | ------------------------------------------------ |
|
|
542
|
+
| portId | string | Port the channel is bound to (e.g. `'transfer'`) |
|
|
543
|
+
| channelId | string | Channel identifier (e.g. `'channel-0'`) |
|
|
544
|
+
|
|
545
|
+
## Usage Example
|
|
291
546
|
|
|
292
547
|
```ts
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
channelId: string,
|
|
296
|
-
sequence: number | string
|
|
297
|
-
)
|
|
548
|
+
const nextSend = await ibcChannelApi.fetchNextSequenceSend('transfer', 'channel-0')
|
|
549
|
+
console.dir(nextSend, { depth: null })
|
|
298
550
|
```
|
|
299
551
|
|
|
300
|
-
|
|
552
|
+
## Example Response
|
|
553
|
+
|
|
554
|
+
```json
|
|
555
|
+
{
|
|
556
|
+
"next_sequence_send": "74",
|
|
557
|
+
"proof": null,
|
|
558
|
+
"proof_height": { "revision_number": "2", "revision_height": "4647093" }
|
|
559
|
+
}
|
|
560
|
+
```
|
|
561
|
+
|
|
562
|
+
## Response Field Explanation
|
|
563
|
+
|
|
564
|
+
| Field | Description |
|
|
565
|
+
| ----------------- | ----------------------------------------------------------------- |
|
|
566
|
+
| next_sequence_send | The sequence number the next outbound packet will be assigned |
|
|
567
|
+
| proof | Merkle proof (null for simple queries) |
|
|
568
|
+
| proof_height | Block height at which this data was read |
|
|
569
|
+
|
|
570
|
+
## When to Use
|
|
301
571
|
|
|
302
|
-
|
|
572
|
+
* Tracking total outbound transfer volume on a channel
|
|
573
|
+
* Predicting the sequence number of the next transfer
|
|
574
|
+
* Auditing outbound packet counts
|
|
303
575
|
|
|
304
576
|
---
|
|
305
577
|
|
|
306
|
-
|
|
578
|
+
# 7️⃣ fetchPacketAcknowledgement
|
|
307
579
|
|
|
308
|
-
|
|
580
|
+
## Method
|
|
309
581
|
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
582
|
+
```ts
|
|
583
|
+
async fetchPacketAcknowledgement(portId: string, channelId: string, sequence: number | string)
|
|
584
|
+
```
|
|
313
585
|
|
|
314
|
-
|
|
586
|
+
## CLI Equivalent
|
|
315
587
|
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
588
|
+
```bash
|
|
589
|
+
zigchaind query ibc channel packet-ack <port-id> <channel-id> <sequence>
|
|
590
|
+
```
|
|
319
591
|
|
|
320
|
-
|
|
592
|
+
## Description
|
|
593
|
+
|
|
594
|
+
Fetches the **acknowledgement stored for a specific packet**.
|
|
321
595
|
|
|
322
|
-
|
|
596
|
+
When a packet is processed on the counterparty chain, it sends back an acknowledgement that ZigChain stores. This acknowledgement proves the packet was received and contains information about whether processing succeeded or failed.
|
|
323
597
|
|
|
324
|
-
|
|
598
|
+
## Parameters
|
|
325
599
|
|
|
326
|
-
|
|
327
|
-
|
|
600
|
+
| Name | Type | Description |
|
|
601
|
+
| --------- | ----------------- | ------------------------------------------------ |
|
|
602
|
+
| portId | string | Port the channel is bound to |
|
|
603
|
+
| channelId | string | Channel identifier |
|
|
604
|
+
| sequence | number \| string | Packet sequence number to query |
|
|
328
605
|
|
|
606
|
+
## Usage Example
|
|
607
|
+
|
|
608
|
+
```ts
|
|
609
|
+
const ack = await ibcChannelApi.fetchPacketAcknowledgement('transfer', 'channel-0', 70)
|
|
610
|
+
console.dir(ack, { depth: null })
|
|
611
|
+
```
|
|
612
|
+
|
|
613
|
+
## Example Response
|
|
614
|
+
|
|
615
|
+
```json
|
|
616
|
+
{
|
|
617
|
+
"acknowledgement": "CPdVftUYJv4Y2EUSvyTsdQAe268hI6R333KgqfNkCnw=",
|
|
618
|
+
"proof": null,
|
|
619
|
+
"proof_height": { "revision_number": "2", "revision_height": "4647093" }
|
|
620
|
+
}
|
|
621
|
+
```
|
|
622
|
+
|
|
623
|
+
## Response Field Explanation
|
|
624
|
+
|
|
625
|
+
| Field | Description |
|
|
626
|
+
| --------------- | ------------------------------------------------------------------------ |
|
|
627
|
+
| acknowledgement | Base64-encoded acknowledgement data returned by the counterparty chain |
|
|
628
|
+
| proof | Merkle proof (null for simple queries) |
|
|
629
|
+
| proof_height | Block height at which this data was read |
|
|
630
|
+
|
|
631
|
+
## When to Use
|
|
632
|
+
|
|
633
|
+
* Verifying a specific packet was acknowledged by the counterparty
|
|
634
|
+
* Checking whether a transfer succeeded or failed on the remote chain
|
|
635
|
+
* Building packet status trackers for IBC explorers
|
|
329
636
|
---
|
|
330
637
|
|
|
331
|
-
|
|
638
|
+
# 8️⃣ fetchPacketCommitment
|
|
639
|
+
|
|
640
|
+
## Method
|
|
641
|
+
|
|
642
|
+
```ts
|
|
643
|
+
async fetchPacketCommitment(portId: string, channelId: string, sequence: number | string)
|
|
644
|
+
```
|
|
645
|
+
|
|
646
|
+
## CLI Equivalent
|
|
332
647
|
|
|
333
648
|
```bash
|
|
334
|
-
zigchaind query ibc channel packet-
|
|
649
|
+
zigchaind query ibc channel packet-commitment <port-id> <channel-id> <sequence>
|
|
335
650
|
```
|
|
336
651
|
|
|
652
|
+
## Description
|
|
653
|
+
|
|
654
|
+
Fetches the **packet commitment** stored for a specific outbound packet.
|
|
655
|
+
|
|
656
|
+
When ZigChain sends a packet, it stores a cryptographic hash (commitment) of that packet. This commitment remains on-chain until the packet is acknowledged by the counterparty. If a commitment exists, it means the packet was sent but the acknowledgement has not yet been received back.
|
|
657
|
+
|
|
337
658
|
---
|
|
338
659
|
|
|
339
|
-
##
|
|
660
|
+
## Parameters
|
|
661
|
+
|
|
662
|
+
| Name | Type | Description |
|
|
663
|
+
| --------- | ----------------- | -------------------------------------------- |
|
|
664
|
+
| portId | string | Port the channel is bound to |
|
|
665
|
+
| channelId | string | Channel identifier |
|
|
666
|
+
| sequence | number \| string | Packet sequence number to query |
|
|
667
|
+
|
|
668
|
+
## Usage Example
|
|
340
669
|
|
|
341
670
|
```ts
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
channelId: string,
|
|
345
|
-
sequence: number | string
|
|
346
|
-
)
|
|
671
|
+
const commitment = await ibcChannelApi.fetchPacketCommitment('transfer', 'channel-0', 55)
|
|
672
|
+
console.dir(commitment, { depth: null })
|
|
347
673
|
```
|
|
348
674
|
|
|
349
|
-
|
|
675
|
+
## Example Response
|
|
350
676
|
|
|
351
|
-
|
|
677
|
+
```json
|
|
678
|
+
{
|
|
679
|
+
"commitment": "TGCM/XS6O6oh0TgzrQfICRxgJ0Fxb2AerhtOtSfaG3U=",
|
|
680
|
+
"proof": null,
|
|
681
|
+
"proof_height": { "revision_number": "2", "revision_height": "4647094" }
|
|
682
|
+
}
|
|
683
|
+
```
|
|
684
|
+
|
|
685
|
+
## Response Field Explanation
|
|
352
686
|
|
|
353
|
-
|
|
354
|
-
|
|
687
|
+
| Field | Description |
|
|
688
|
+
| ------------ | ------------------------------------------------------------------------ |
|
|
689
|
+
| commitment | Base64-encoded hash of the packet data — proves the packet was committed |
|
|
690
|
+
| proof | Merkle proof (null for simple queries) |
|
|
691
|
+
| proof_height | Block height at which this data was read |
|
|
355
692
|
|
|
356
|
-
|
|
693
|
+
## When to Use
|
|
357
694
|
|
|
358
|
-
|
|
695
|
+
* Checking if a specific packet is still awaiting acknowledgement
|
|
696
|
+
* Debugging in-flight or stuck transfers
|
|
359
697
|
|
|
360
698
|
---
|
|
361
699
|
|
|
362
|
-
|
|
700
|
+
# 9️⃣ fetchPacketCommitments
|
|
363
701
|
|
|
364
|
-
|
|
365
|
-
* **channelId** – The IBC channel identifier (e.g., `"channel-0"`).
|
|
366
|
-
* **sequence** – The packet sequence number.
|
|
702
|
+
## Method
|
|
367
703
|
|
|
368
|
-
|
|
704
|
+
```ts
|
|
705
|
+
async fetchPacketCommitments(portId: string, channelId: string)
|
|
706
|
+
```
|
|
369
707
|
|
|
370
|
-
##
|
|
708
|
+
## CLI Equivalent
|
|
709
|
+
|
|
710
|
+
```bash
|
|
711
|
+
zigchaind query ibc channel packet-commitments <port-id> <channel-id>
|
|
712
|
+
```
|
|
713
|
+
|
|
714
|
+
## Description
|
|
715
|
+
|
|
716
|
+
Fetches **all outstanding packet commitments** on a channel — every packet that has been sent but not yet acknowledged.
|
|
717
|
+
|
|
718
|
+
## Parameters
|
|
719
|
+
|
|
720
|
+
| Name | Type | Description |
|
|
721
|
+
| --------- | ------ | ------------------------------------------------ |
|
|
722
|
+
| portId | string | Port the channel is bound to (e.g. `'transfer'`) |
|
|
723
|
+
| channelId | string | Channel identifier (e.g. `'channel-0'`) |
|
|
724
|
+
|
|
725
|
+
## Usage Example
|
|
371
726
|
|
|
372
727
|
```ts
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
channelId: string
|
|
376
|
-
)
|
|
728
|
+
const commitments = await ibcChannelApi.fetchPacketCommitments('transfer', 'channel-0')
|
|
729
|
+
console.dir(commitments, { depth: null })
|
|
377
730
|
```
|
|
378
731
|
|
|
379
|
-
|
|
732
|
+
## Example Response
|
|
733
|
+
|
|
734
|
+
```json
|
|
735
|
+
{
|
|
736
|
+
"commitments": [
|
|
737
|
+
{
|
|
738
|
+
"port_id": "transfer",
|
|
739
|
+
"channel_id": "channel-0",
|
|
740
|
+
"sequence": "53",
|
|
741
|
+
"data": "o6Kf3yL0iV5BVzwm0O/j8sOHy+bvO0foTqBgBZx0Bt4="
|
|
742
|
+
},
|
|
743
|
+
{
|
|
744
|
+
"port_id": "transfer",
|
|
745
|
+
"channel_id": "channel-0",
|
|
746
|
+
"sequence": "54",
|
|
747
|
+
"data": "Hn9W269hLobcNGLWmTMDXI8ITsXlEUubBdR3pjYOyTI="
|
|
748
|
+
},
|
|
749
|
+
{
|
|
750
|
+
"port_id": "transfer",
|
|
751
|
+
"channel_id": "channel-0",
|
|
752
|
+
"sequence": "55",
|
|
753
|
+
"data": "TGCM/XS6O6oh0TgzrQfICRxgJ0Fxb2AerhtOtSfaG3U="
|
|
754
|
+
}
|
|
755
|
+
],
|
|
756
|
+
"pagination": { "next_key": null, "total": "3" },
|
|
757
|
+
"height": { "revision_number": "2", "revision_height": "4647094" }
|
|
758
|
+
}
|
|
759
|
+
```
|
|
380
760
|
|
|
381
|
-
|
|
761
|
+
## Response Field Explanation
|
|
382
762
|
|
|
383
|
-
|
|
763
|
+
### `commitments[]`
|
|
384
764
|
|
|
385
|
-
|
|
386
|
-
|
|
765
|
+
| Field | Description |
|
|
766
|
+
| ---------- | --------------------------------------------------------------- |
|
|
767
|
+
| port_id | Port this commitment belongs to |
|
|
768
|
+
| channel_id | Channel this commitment belongs to |
|
|
769
|
+
| sequence | Packet sequence number |
|
|
770
|
+
| data | Base64-encoded commitment hash of the packet |
|
|
387
771
|
|
|
388
|
-
|
|
772
|
+
### `fetchPacketCommitment` vs `fetchPacketCommitments`
|
|
773
|
+
|
|
774
|
+
| Feature | fetchPacketCommitment | fetchPacketCommitments |
|
|
775
|
+
| ------------------- | ------------------------- | ------------------------------- |
|
|
776
|
+
| Scope | Single sequence | All outstanding commitments |
|
|
777
|
+
| Use case | Check one specific packet | Overview of all in-flight packets |
|
|
389
778
|
|
|
390
779
|
---
|
|
391
780
|
|
|
392
|
-
|
|
781
|
+
# 🔟 fetchPacketReceipt
|
|
782
|
+
|
|
783
|
+
## Method
|
|
393
784
|
|
|
394
|
-
|
|
395
|
-
|
|
785
|
+
```ts
|
|
786
|
+
async fetchPacketReceipt(portId: string, channelId: string, sequence: number | string)
|
|
787
|
+
```
|
|
788
|
+
|
|
789
|
+
## CLI Equivalent
|
|
790
|
+
|
|
791
|
+
```bash
|
|
792
|
+
zigchaind query ibc channel packet-receipt <port-id> <channel-id> <sequence>
|
|
793
|
+
```
|
|
794
|
+
|
|
795
|
+
## Description
|
|
796
|
+
|
|
797
|
+
Checks whether a **specific inbound packet has been received** by ZigChain.
|
|
798
|
+
|
|
799
|
+
A packet receipt is stored on the receiving chain after the packet is processed. This is the definitive proof that ZigChain received and executed a specific packet from the counterparty. Returns `received: true` if the packet was processed, `false` if not.
|
|
800
|
+
|
|
801
|
+
## Parameters
|
|
802
|
+
|
|
803
|
+
| Name | Type | Description |
|
|
804
|
+
| --------- | ----------------- | -------------------------------------------- |
|
|
805
|
+
| portId | string | Port the channel is bound to |
|
|
806
|
+
| channelId | string | Channel identifier |
|
|
807
|
+
| sequence | number \| string | Packet sequence number to check |
|
|
396
808
|
|
|
397
809
|
---
|
|
398
810
|
|
|
399
|
-
##
|
|
811
|
+
## Usage Example
|
|
400
812
|
|
|
401
813
|
```ts
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
channelId: string,
|
|
405
|
-
sequence: number | string
|
|
406
|
-
)
|
|
814
|
+
const receipt = await ibcChannelApi.fetchPacketReceipt('transfer', 'channel-0', 70)
|
|
815
|
+
console.dir(receipt, { depth: null })
|
|
407
816
|
```
|
|
408
817
|
|
|
409
|
-
|
|
818
|
+
## Example Response
|
|
410
819
|
|
|
411
|
-
|
|
820
|
+
```json
|
|
821
|
+
{
|
|
822
|
+
"received": true,
|
|
823
|
+
"proof": null,
|
|
824
|
+
"proof_height": { "revision_number": "2", "revision_height": "4647094" }
|
|
825
|
+
}
|
|
826
|
+
```
|
|
412
827
|
|
|
413
|
-
|
|
414
|
-
It confirms that the packet was received.
|
|
828
|
+
## Response Field Explanation
|
|
415
829
|
|
|
416
|
-
|
|
830
|
+
| Field | Description |
|
|
831
|
+
| ------------ | ------------------------------------------------------------------ |
|
|
832
|
+
| received | `true` if ZigChain has received and processed this packet |
|
|
833
|
+
| proof | Merkle proof (null for simple queries) |
|
|
834
|
+
| proof_height | Block height at which this data was read |
|
|
417
835
|
|
|
418
|
-
|
|
836
|
+
## When to Use
|
|
419
837
|
|
|
838
|
+
* Verifying an inbound packet was successfully received
|
|
839
|
+
* Confirming an incoming IBC transfer reached ZigChain
|
|
420
840
|
---
|
|
421
841
|
|
|
422
|
-
|
|
842
|
+
# 1️⃣1️⃣ fetchUnreceivedAcks
|
|
423
843
|
|
|
424
|
-
|
|
425
|
-
* **channelId** – The IBC channel identifier.
|
|
426
|
-
* **sequence** – The packet sequence number.
|
|
844
|
+
## Method
|
|
427
845
|
|
|
428
|
-
|
|
846
|
+
```ts
|
|
847
|
+
async fetchUnreceivedAcks(portId: string, channelId: string, sequences: (number | string)[])
|
|
848
|
+
```
|
|
429
849
|
|
|
430
|
-
##
|
|
850
|
+
## CLI Equivalent
|
|
851
|
+
|
|
852
|
+
```bash
|
|
853
|
+
zigchaind query ibc channel unreceived-acks <port-id> <channel-id> <sequences>
|
|
854
|
+
```
|
|
855
|
+
|
|
856
|
+
## Description
|
|
857
|
+
|
|
858
|
+
Given a list of packet sequences, returns which ones have **acknowledgements that ZigChain has not yet received back**.
|
|
859
|
+
|
|
860
|
+
This identifies packets that were sent from ZigChain, processed on the counterparty, but whose acknowledgements haven't been relayed back to ZigChain yet. These are packets with commitments still stored on ZigChain waiting to be cleared.
|
|
861
|
+
|
|
862
|
+
## Parameters
|
|
863
|
+
|
|
864
|
+
| Name | Type | Description |
|
|
865
|
+
| --------- | ----------------------- | -------------------------------------------------------- |
|
|
866
|
+
| portId | string | Port the channel is bound to |
|
|
867
|
+
| channelId | string | Channel identifier |
|
|
868
|
+
| sequences | (number \| string)[] | List of sequence numbers to check for missing acks |
|
|
869
|
+
|
|
870
|
+
## Usage Example
|
|
431
871
|
|
|
432
872
|
```ts
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
873
|
+
const unreceivedAcks = await ibcChannelApi.fetchUnreceivedAcks(
|
|
874
|
+
'transfer',
|
|
875
|
+
'channel-0',
|
|
876
|
+
[53, 54, 71]
|
|
437
877
|
)
|
|
878
|
+
console.dir(unreceivedAcks, { depth: null })
|
|
438
879
|
```
|
|
439
880
|
|
|
440
|
-
|
|
881
|
+
## Example Response
|
|
441
882
|
|
|
442
|
-
|
|
883
|
+
```json
|
|
884
|
+
{
|
|
885
|
+
"sequences": ["53", "54"],
|
|
886
|
+
"height": { "revision_number": "2", "revision_height": "4647095" }
|
|
887
|
+
}
|
|
888
|
+
```
|
|
889
|
+
|
|
890
|
+
## Response Field Explanation
|
|
443
891
|
|
|
444
|
-
|
|
892
|
+
| Field | Description |
|
|
893
|
+
| --------- | ---------------------------------------------------------------------------------- |
|
|
894
|
+
| sequences | The subset of queried sequences whose acknowledgements have not yet been received |
|
|
895
|
+
| height | Block height at which this data was read |
|
|
445
896
|
|
|
446
|
-
|
|
897
|
+
## When to Use
|
|
447
898
|
|
|
448
|
-
|
|
899
|
+
* Checking which packets need ack relaying
|
|
900
|
+
* Identifying the workload for an IBC relayer
|
|
901
|
+
* Monitoring channel health and ack latency
|
|
902
|
+
* Alerting when acks are pending for too long
|
|
449
903
|
|
|
450
904
|
---
|
|
451
905
|
|
|
452
|
-
|
|
906
|
+
# 1️⃣2️⃣ fetchUnreceivedPackets
|
|
453
907
|
|
|
454
|
-
|
|
455
|
-
* **channelId** – The IBC channel identifier.
|
|
456
|
-
* **sequences** – List of packet sequence numbers to check.
|
|
908
|
+
## Method
|
|
457
909
|
|
|
458
|
-
|
|
910
|
+
```ts
|
|
911
|
+
async fetchUnreceivedPackets(portId: string, channelId: string, sequences: (number | string)[])
|
|
912
|
+
```
|
|
913
|
+
|
|
914
|
+
## CLI Equivalent
|
|
915
|
+
|
|
916
|
+
```bash
|
|
917
|
+
zigchaind query ibc channel unreceived-packets <port-id> <channel-id> <sequences>
|
|
918
|
+
```
|
|
919
|
+
|
|
920
|
+
## Description
|
|
921
|
+
|
|
922
|
+
Given a list of packet sequences, returns which ones have been **committed on the counterparty but not yet received by ZigChain**.
|
|
923
|
+
|
|
924
|
+
This is the inbound counterpart to `fetchUnreceivedAcks` — it identifies packets sent to ZigChain that haven't arrived yet. An empty result means all queried packets have already been received.
|
|
925
|
+
|
|
926
|
+
|
|
927
|
+
## Parameters
|
|
459
928
|
|
|
460
|
-
|
|
929
|
+
| Name | Type | Description |
|
|
930
|
+
| --------- | ----------------------- | --------------------------------------------------------- |
|
|
931
|
+
| portId | string | Port the channel is bound to |
|
|
932
|
+
| channelId | string | Channel identifier |
|
|
933
|
+
| sequences | (number \| string)[] | List of sequence numbers to check for missing receipts |
|
|
934
|
+
|
|
935
|
+
## Usage Example
|
|
461
936
|
|
|
462
937
|
```ts
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
938
|
+
const unreceivedPackets = await ibcChannelApi.fetchUnreceivedPackets(
|
|
939
|
+
'transfer',
|
|
940
|
+
'channel-0',
|
|
941
|
+
[53, 54, 71]
|
|
467
942
|
)
|
|
943
|
+
console.dir(unreceivedPackets, { depth: null })
|
|
468
944
|
```
|
|
469
945
|
|
|
470
|
-
|
|
946
|
+
## Example Response
|
|
471
947
|
|
|
472
|
-
|
|
948
|
+
```json
|
|
949
|
+
{
|
|
950
|
+
"sequences": [],
|
|
951
|
+
"height": { "revision_number": "2", "revision_height": "4647095" }
|
|
952
|
+
}
|
|
953
|
+
```
|
|
473
954
|
|
|
474
|
-
|
|
955
|
+
## Response Field Explanation
|
|
475
956
|
|
|
476
|
-
|
|
957
|
+
| Field | Description |
|
|
958
|
+
| --------- | -------------------------------------------------------------------------------- |
|
|
959
|
+
| sequences | The subset of queried sequences that have not yet been received by ZigChain |
|
|
960
|
+
| height | Block height at which this data was read |
|
|
477
961
|
|
|
478
|
-
>
|
|
962
|
+
> An empty `sequences` array means all queried packets (`53`, `54`, `71`) have already been received by ZigChain — no inbound delivery is pending.
|
|
479
963
|
|
|
480
|
-
|
|
964
|
+
### `fetchUnreceivedAcks` vs `fetchUnreceivedPackets`
|
|
481
965
|
|
|
482
|
-
|
|
966
|
+
| Feature | fetchUnreceivedAcks | fetchUnreceivedPackets |
|
|
967
|
+
| --------- | ------------------------------------ | ------------------------------------ |
|
|
968
|
+
| Direction | Outbound (sent from ZigChain) | Inbound (sent to ZigChain) |
|
|
969
|
+
| Question | Which acks haven't come back yet? | Which packets haven't arrived yet? |
|
|
970
|
+
| Result | Sequences `[53, 54]` pending | Empty — all received |
|
|
483
971
|
|
|
484
|
-
|
|
485
|
-
* **channelId** – The IBC channel identifier.
|
|
486
|
-
* **sequences** – List of packet sequence numbers to check.
|
|
487
|
-
|
|
488
|
-
---
|
|
972
|
+
## When to Use
|
|
489
973
|
|
|
974
|
+
* Checking for packets in transit toward ZigChain
|
|
975
|
+
* Detecting dropped or stuck inbound IBC transfers
|
|
490
976
|
|
|
977
|
+
---
|