@@ -25,7 +25,7 @@ use ckb_ics_axon::handler::{IbcChannel, IbcConnections, IbcPacket, PacketStatus}
25
25
use ckb_ics_axon:: message:: Envelope ;
26
26
use ckb_ics_axon:: object:: Ordering ;
27
27
use ckb_ics_axon:: { ChannelArgs , PacketArgs } ;
28
- use ckb_jsonrpc_types:: { JsonBytes , Status , TransactionView } ;
28
+ use ckb_jsonrpc_types:: { Status , TransactionView } ;
29
29
use ckb_sdk:: constants:: TYPE_ID_CODE_HASH ;
30
30
use ckb_sdk:: traits:: SecpCkbRawKeySigner ;
31
31
use ckb_sdk:: unlock:: { ScriptSigner , SecpSighashScriptSigner } ;
@@ -369,13 +369,17 @@ impl Ckb4IbcChain {
369
369
. build ( ) ;
370
370
let capacity: u64 = cell. output . capacity . into ( ) ;
371
371
let client_id = hex:: encode ( cell. output . lock . args . into_bytes ( ) ) ;
372
- resps. push ( ( tx, cell_input, capacity, client_id) ) ;
372
+ if let Ok ( client_type) = self . config . lc_client_type ( & client_id) {
373
+ resps. push ( ( tx, cell_input, capacity, client_type) ) ;
374
+ } else {
375
+ warn ! ( "skip local missing client_id found on-chain: {client_id}" ) ;
376
+ }
373
377
}
374
378
Ok ( resps)
375
379
} ) ;
376
380
let mut cache = self . connection_cache . borrow_mut ( ) ;
377
381
let prefix = self . query_commitment_prefix ( ) ?;
378
- for ( transaction, cell_input, capacity, client_id ) in self . rt . block_on ( future) ? {
382
+ for ( transaction, cell_input, capacity, client_type ) in self . rt . block_on ( future) ? {
379
383
let tx = transaction
380
384
. expect ( "empty transaction response" )
381
385
. transaction
@@ -387,7 +391,6 @@ impl Ckb4IbcChain {
387
391
}
388
392
} ;
389
393
let ( connections, ibc_connection) = extract_connections_from_tx ( tx, & prefix) ?;
390
- let client_type = self . config . lc_client_type ( & client_id) ?;
391
394
cache. insert (
392
395
client_type,
393
396
( ibc_connection, cell_input, capacity, connections) ,
@@ -506,7 +509,7 @@ impl ChainEndpoint for Ckb4IbcChain {
506
509
) in & config. onchain_light_clients
507
510
{
508
511
let client_cell = rt. block_on ( rpc_client. search_cell_by_typescript (
509
- & TYPE_ID_CODE_HASH . pack ( ) ,
512
+ & config . client_code_hash . pack ( ) ,
510
513
& client_cell_type_args. as_bytes ( ) . to_owned ( ) ,
511
514
) ) ?;
512
515
let Some ( cell) = client_cell else {
@@ -710,6 +713,13 @@ impl ChainEndpoint for Ckb4IbcChain {
710
713
match response {
711
714
Ok ( height) => {
712
715
if let Some ( event) = events. get ( i) . unwrap ( ) . clone ( ) {
716
+ if let IbcEvent :: CreateClient ( e) = & event {
717
+ let client_type = e. 0 . client_type ;
718
+ info ! (
719
+ "the counterparty client type of Ckb4Ibc is set as {client_type}"
720
+ ) ;
721
+ self . sync_counterparty_client_type ( client_type) ;
722
+ }
713
723
let tx_hash: [ u8 ; 32 ] = tx_hashes. get ( i) . unwrap ( ) . clone ( ) . into ( ) ;
714
724
let ibc_event_with_height = IbcEventWithHeight {
715
725
event,
@@ -968,32 +978,32 @@ impl ChainEndpoint for Ckb4IbcChain {
968
978
969
979
fn query_connection_channels (
970
980
& self ,
971
- _request : QueryConnectionChannelsRequest ,
981
+ request : QueryConnectionChannelsRequest ,
972
982
) -> Result < Vec < IdentifiedChannelEnd > , Error > {
973
- self . query_channels ( QueryChannelsRequest { pagination : None } )
983
+ let connection_channels = self
984
+ . query_channels ( QueryChannelsRequest { pagination : None } ) ?
985
+ . into_iter ( )
986
+ . filter ( |channel| {
987
+ channel
988
+ . channel_end
989
+ . connection_hops
990
+ . contains ( & request. connection_id )
991
+ } )
992
+ . collect ( ) ;
993
+ Ok ( connection_channels)
974
994
}
975
995
976
996
fn query_channels (
977
997
& self ,
978
- request : QueryChannelsRequest ,
998
+ _request : QueryChannelsRequest ,
979
999
) -> Result < Vec < IdentifiedChannelEnd > , Error > {
980
1000
let channel_code_hash = self . get_converter ( ) ?. get_channel_code_hash ( ) ;
981
1001
let script = Script :: new_builder ( )
982
1002
. code_hash ( channel_code_hash)
983
- . args ( "" . pack ( ) )
984
1003
. hash_type ( ScriptHashType :: Type . into ( ) )
985
1004
. build ( ) ;
986
1005
let search_key = get_prefix_search_key ( script) ;
987
- let ( limit, index) = {
988
- if let Some ( pagination) = request. pagination {
989
- ( pagination. limit as u32 , pagination. offset as u32 )
990
- } else {
991
- ( u32:: MAX , 0 )
992
- }
993
- } ;
994
- let json_bytes = JsonBytes :: from_vec ( index. to_be_bytes ( ) . to_vec ( ) ) ;
995
- let cursor = Some ( json_bytes) ;
996
- let cells_rpc_result = self . rpc_client . fetch_live_cells ( search_key, limit, cursor) ;
1006
+ let cells_rpc_result = self . rpc_client . fetch_live_cells ( search_key, u32:: MAX , None ) ;
997
1007
let txs_rpc_result = self
998
1008
. rt
999
1009
. block_on ( cells_rpc_result) ?
0 commit comments