Skip to content

Commit aacc9b8

Browse files
committed
rm prefix in path
1 parent 096aa08 commit aacc9b8

File tree

1 file changed

+28
-105
lines changed
  • ibc-eureka-core/ics24-host/types/src

1 file changed

+28
-105
lines changed

ibc-eureka-core/ics24-host/types/src/path.rs

Lines changed: 28 additions & 105 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,7 @@ pub const NEXT_CHANNEL_SEQUENCE: &str = "nextChannelSequence";
1717

1818
pub const EUREKA: &str = "eureka";
1919
pub const SOURCE_CLIENT_ON_TARGET: &str = "sourceClientOnTarget";
20-
pub const SOURCE_PREFIX: &str = "sourcePrefix";
2120
pub const TARGET_CLIENT_ON_SOURCE: &str = "targetClientOnSource";
22-
pub const TARGET_PREFIX: &str = "targetPrefix";
2321

2422
pub const CLIENT_PREFIX: &str = "clients";
2523
pub const CLIENT_STATE: &str = "clientState";
@@ -515,27 +513,18 @@ impl SeqSendPath {
515513
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
516514
#[derive(Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash, Display)]
517515
#[display(
518-
fmt = "{EUREKA}/{NEXT_SEQ_SEND_PREFIX}/{SOURCE_CLIENT_ON_TARGET}/{source_client_on_target}/{SOURCE_PREFIX}/{source_prefix}/{TARGET_CLIENT_ON_SOURCE}/{target_client_on_source}/{TARGET_PREFIX}/{target_prefix}"
516+
fmt = "{EUREKA}/{NEXT_SEQ_SEND_PREFIX}/{SOURCE_CLIENT_ON_TARGET}/{source_client_on_target}/{TARGET_CLIENT_ON_SOURCE}/{target_client_on_source}"
519517
)]
520518
pub struct SeqSendPathV2 {
521519
pub source_client_on_target: ClientId,
522-
pub source_prefix: String,
523520
pub target_client_on_source: ClientId,
524-
pub target_prefix: String,
525521
}
526522

527523
impl SeqSendPathV2 {
528-
pub fn new(
529-
source_client_on_target: &ClientId,
530-
source_prefix: &str,
531-
target_client_on_source: &ClientId,
532-
target_prefix: &str,
533-
) -> Self {
524+
pub fn new(source_client_on_target: &ClientId, target_client_on_source: &ClientId) -> Self {
534525
Self {
535526
source_client_on_target: source_client_on_target.clone(),
536-
source_prefix: source_prefix.to_string(),
537527
target_client_on_source: target_client_on_source.clone(),
538-
target_prefix: target_prefix.to_string(),
539528
}
540529
}
541530
}
@@ -578,27 +567,18 @@ impl SeqRecvPath {
578567
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
579568
#[derive(Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash, Display)]
580569
#[display(
581-
fmt = "{EUREKA}/{NEXT_SEQ_RECV_PREFIX}/{SOURCE_CLIENT_ON_TARGET}/{source_client_on_target}/{SOURCE_PREFIX}/{source_prefix}/{TARGET_CLIENT_ON_SOURCE}/{target_client_on_source}/{TARGET_PREFIX}/{target_prefix}"
570+
fmt = "{EUREKA}/{NEXT_SEQ_RECV_PREFIX}/{SOURCE_CLIENT_ON_TARGET}/{source_client_on_target}/{TARGET_CLIENT_ON_SOURCE}/{target_client_on_source}"
582571
)]
583572
pub struct SeqRecvPathV2 {
584573
pub source_client_on_target: ClientId,
585-
pub source_prefix: String,
586574
pub target_client_on_source: ClientId,
587-
pub target_prefix: String,
588575
}
589576

590577
impl SeqRecvPathV2 {
591-
pub fn new(
592-
source_client_on_target: &ClientId,
593-
source_prefix: &str,
594-
target_client_on_source: &ClientId,
595-
target_prefix: &str,
596-
) -> Self {
578+
pub fn new(source_client_on_target: &ClientId, target_client_on_source: &ClientId) -> Self {
597579
Self {
598580
source_client_on_target: source_client_on_target.clone(),
599-
source_prefix: source_prefix.to_string(),
600581
target_client_on_source: target_client_on_source.clone(),
601-
target_prefix: target_prefix.to_string(),
602582
}
603583
}
604584
}
@@ -641,27 +621,18 @@ impl SeqAckPath {
641621
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
642622
#[derive(Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash, Display)]
643623
#[display(
644-
fmt = "{EUREKA}/{NEXT_SEQ_ACK_PREFIX}/{SOURCE_CLIENT_ON_TARGET}/{source_client_on_target}/{SOURCE_PREFIX}/{source_prefix}/{TARGET_CLIENT_ON_SOURCE}/{target_client_on_source}/{TARGET_PREFIX}/{target_prefix}"
624+
fmt = "{EUREKA}/{NEXT_SEQ_ACK_PREFIX}/{SOURCE_CLIENT_ON_TARGET}/{source_client_on_target}/{TARGET_CLIENT_ON_SOURCE}/{target_client_on_source}"
645625
)]
646626
pub struct SeqAckPathV2 {
647627
pub source_client_on_target: ClientId,
648-
pub source_prefix: String,
649628
pub target_client_on_source: ClientId,
650-
pub target_prefix: String,
651629
}
652630

653631
impl SeqAckPathV2 {
654-
pub fn new(
655-
source_client_on_target: &ClientId,
656-
source_prefix: &str,
657-
target_client_on_source: &ClientId,
658-
target_prefix: &str,
659-
) -> Self {
632+
pub fn new(source_client_on_target: &ClientId, target_client_on_source: &ClientId) -> Self {
660633
Self {
661634
source_client_on_target: source_client_on_target.clone(),
662-
source_prefix: source_prefix.to_string(),
663635
target_client_on_source: target_client_on_source.clone(),
664-
target_prefix: target_prefix.to_string(),
665636
}
666637
}
667638
}
@@ -720,29 +691,25 @@ impl CommitmentPath {
720691
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
721692
#[derive(Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash, Display)]
722693
#[display(
723-
fmt = "{EUREKA}/{PACKET_COMMITMENT_PREFIX}/{SOURCE_CLIENT_ON_TARGET}/{source_client_on_target}/{SOURCE_PREFIX}/{source_prefix}/{TARGET_CLIENT_ON_SOURCE}/{target_client_on_source}/{TARGET_PREFIX}/{target_prefix}/{SEQUENCE_PREFIX}/{sequence}"
694+
fmt = "{EUREKA}/{PACKET_COMMITMENT_PREFIX}/{SOURCE_CLIENT_ON_TARGET}/{source_client_on_target}/{TARGET_CLIENT_ON_SOURCE}/{target_client_on_source}/{SEQUENCE_PREFIX}/{sequence}"
724695
)]
725696
pub struct CommitmentPathV2 {
726697
pub source_client_on_target: ClientId,
727-
pub source_prefix: String,
698+
728699
pub target_client_on_source: ClientId,
729-
pub target_prefix: String,
700+
730701
pub sequence: Sequence,
731702
}
732703

733704
impl CommitmentPathV2 {
734705
pub fn new(
735706
source_client_on_target: &ClientId,
736-
source_prefix: &str,
737707
target_client_on_source: &ClientId,
738-
target_prefix: &str,
739708
sequence: &Sequence,
740709
) -> Self {
741710
Self {
742711
source_client_on_target: source_client_on_target.clone(),
743-
source_prefix: source_prefix.to_string(),
744712
target_client_on_source: target_client_on_source.clone(),
745-
target_prefix: target_prefix.to_string(),
746713
sequence: *sequence,
747714
}
748715
}
@@ -808,29 +775,23 @@ impl AckPath {
808775
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
809776
#[derive(Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash, Display)]
810777
#[display(
811-
fmt = "{EUREKA}/{PACKET_ACK_PREFIX}/{SOURCE_CLIENT_ON_TARGET}/{source_client_on_target}/{SOURCE_PREFIX}/{source_prefix}/{TARGET_CLIENT_ON_SOURCE}/{target_client_on_source}/{TARGET_PREFIX}/{target_prefix}/{SEQUENCE_PREFIX}/{sequence}"
778+
fmt = "{EUREKA}/{PACKET_ACK_PREFIX}/{SOURCE_CLIENT_ON_TARGET}/{source_client_on_target}/{TARGET_CLIENT_ON_SOURCE}/{target_client_on_source}/{SEQUENCE_PREFIX}/{sequence}"
812779
)]
813780
pub struct AckPathV2 {
814781
pub source_client_on_target: ClientId,
815-
pub source_prefix: String,
816782
pub target_client_on_source: ClientId,
817-
pub target_prefix: String,
818783
pub sequence: Sequence,
819784
}
820785

821786
impl AckPathV2 {
822787
pub fn new(
823788
source_client_on_target: &ClientId,
824-
source_prefix: &str,
825789
target_client_on_source: &ClientId,
826-
target_prefix: &str,
827790
sequence: &Sequence,
828791
) -> Self {
829792
Self {
830793
source_client_on_target: source_client_on_target.clone(),
831-
source_prefix: source_prefix.to_string(),
832794
target_client_on_source: target_client_on_source.clone(),
833-
target_prefix: target_prefix.to_string(),
834795
sequence: *sequence,
835796
}
836797
}
@@ -896,29 +857,23 @@ impl ReceiptPath {
896857
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
897858
#[derive(Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash, Display)]
898859
#[display(
899-
fmt = "{EUREKA}/{PACKET_RECEIPT_PREFIX}/{SOURCE_CLIENT_ON_TARGET}/{source_client_on_target}/{SOURCE_PREFIX}/{source_prefix}/{TARGET_CLIENT_ON_SOURCE}/{target_client_on_source}/{TARGET_PREFIX}/{target_prefix}/{SEQUENCE_PREFIX}/{sequence}"
860+
fmt = "{EUREKA}/{PACKET_RECEIPT_PREFIX}/{SOURCE_CLIENT_ON_TARGET}/{source_client_on_target}/{TARGET_CLIENT_ON_SOURCE}/{target_client_on_source}/{SEQUENCE_PREFIX}/{sequence}"
900861
)]
901862
pub struct ReceiptPathV2 {
902863
pub source_client_on_target: ClientId,
903-
pub source_prefix: String,
904864
pub target_client_on_source: ClientId,
905-
pub target_prefix: String,
906865
pub sequence: Sequence,
907866
}
908867

909868
impl ReceiptPathV2 {
910869
pub fn new(
911870
source_client_on_target: &ClientId,
912-
source_prefix: &str,
913871
target_client_on_source: &ClientId,
914-
target_prefix: &str,
915872
sequence: &Sequence,
916873
) -> Self {
917874
Self {
918875
source_client_on_target: source_client_on_target.clone(),
919-
source_prefix: source_prefix.to_string(),
920876
target_client_on_source: target_client_on_source.clone(),
921-
target_prefix: target_prefix.to_string(),
922877
sequence: *sequence,
923878
}
924879
}
@@ -1357,15 +1312,13 @@ fn parse_receipts(components: &[&str]) -> Option<Path> {
13571312
}
13581313

13591314
fn parse_commit_ack_receipt_seqs_v2(components: &[&str]) -> Option<Path> {
1360-
if components.len() != 10 {
1315+
if components.len() != 6 {
13611316
return None;
13621317
}
13631318

13641319
if !(components[0] == EUREKA
13651320
&& components[2] == SOURCE_CLIENT_ON_TARGET
1366-
&& components[4] == SOURCE_PREFIX
1367-
&& components[6] == TARGET_CLIENT_ON_SOURCE
1368-
&& components[8] == TARGET_PREFIX)
1321+
&& components[4] == TARGET_CLIENT_ON_SOURCE)
13691322
{
13701323
return None;
13711324
}
@@ -1378,53 +1331,31 @@ fn parse_commit_ack_receipt_seqs_v2(components: &[&str]) -> Option<Path> {
13781331
}
13791332

13801333
let source_client_on_target = ClientId::from_str(components[3]).ok()?;
1381-
let source_prefix = components[5];
1382-
let target_client_on_source = ClientId::from_str(components[7]).ok()?;
1383-
let target_prefix = components[9];
1334+
let target_client_on_source = ClientId::from_str(components[5]).ok()?;
13841335

13851336
match components[1] {
1386-
NEXT_SEQ_SEND_PREFIX => Some(
1387-
SeqSendPathV2::new(
1388-
&source_client_on_target,
1389-
source_prefix,
1390-
&target_client_on_source,
1391-
target_prefix,
1392-
)
1393-
.into(),
1394-
),
1395-
NEXT_SEQ_RECV_PREFIX => Some(
1396-
SeqRecvPathV2::new(
1397-
&source_client_on_target,
1398-
source_prefix,
1399-
&target_client_on_source,
1400-
target_prefix,
1401-
)
1402-
.into(),
1403-
),
1404-
NEXT_SEQ_ACK_PREFIX => Some(
1405-
SeqAckPathV2::new(
1406-
&source_client_on_target,
1407-
source_prefix,
1408-
&target_client_on_source,
1409-
target_prefix,
1410-
)
1411-
.into(),
1412-
),
1337+
NEXT_SEQ_SEND_PREFIX => {
1338+
Some(SeqSendPathV2::new(&source_client_on_target, &target_client_on_source).into())
1339+
}
1340+
NEXT_SEQ_RECV_PREFIX => {
1341+
Some(SeqRecvPathV2::new(&source_client_on_target, &target_client_on_source).into())
1342+
}
1343+
NEXT_SEQ_ACK_PREFIX => {
1344+
Some(SeqAckPathV2::new(&source_client_on_target, &target_client_on_source).into())
1345+
}
14131346
_ => None,
14141347
}
14151348
}
14161349

14171350
fn parse_commit_ack_receipt_v2(components: &[&str]) -> Option<Path> {
1418-
if components.len() != 12 {
1351+
if components.len() != 8 {
14191352
return None;
14201353
}
14211354

14221355
if !(components[0] == EUREKA
14231356
&& components[2] == SOURCE_CLIENT_ON_TARGET
1424-
&& components[4] == SOURCE_PREFIX
1425-
&& components[6] == TARGET_CLIENT_ON_SOURCE
1426-
&& components[8] == TARGET_PREFIX
1427-
&& components[10] == SEQUENCE_PREFIX)
1357+
&& components[4] == TARGET_CLIENT_ON_SOURCE
1358+
&& components[6] == SEQUENCE_PREFIX)
14281359
{
14291360
return None;
14301361
}
@@ -1437,38 +1368,30 @@ fn parse_commit_ack_receipt_v2(components: &[&str]) -> Option<Path> {
14371368
}
14381369

14391370
let source_client_on_target = ClientId::from_str(components[3]).ok()?;
1440-
let source_prefix = components[5];
1441-
let target_client_on_source = ClientId::from_str(components[7]).ok()?;
1442-
let target_prefix = components[9];
1443-
let sequence = Sequence::from_str(components[11]).ok()?;
1371+
let target_client_on_source = ClientId::from_str(components[5]).ok()?;
1372+
let sequence = Sequence::from_str(components[7]).ok()?;
14441373

14451374
match components[1] {
14461375
PACKET_COMMITMENT_PREFIX => Some(
14471376
CommitmentPathV2::new(
14481377
&source_client_on_target,
1449-
source_prefix,
14501378
&target_client_on_source,
1451-
target_prefix,
14521379
&sequence,
14531380
)
14541381
.into(),
14551382
),
14561383
PACKET_ACK_PREFIX => Some(
14571384
AckPathV2::new(
14581385
&source_client_on_target,
1459-
source_prefix,
14601386
&target_client_on_source,
1461-
target_prefix,
14621387
&sequence,
14631388
)
14641389
.into(),
14651390
),
14661391
PACKET_RECEIPT_PREFIX => Some(
14671392
ReceiptPathV2::new(
14681393
&source_client_on_target,
1469-
source_prefix,
14701394
&target_client_on_source,
1471-
target_prefix,
14721395
&sequence,
14731396
)
14741397
.into(),

0 commit comments

Comments
 (0)