@@ -48,24 +48,33 @@ impl PartialEq<ContractEventBody> for VerifierSetConfirmation {
48
48
fn eq ( & self , event : & ContractEventBody ) -> bool {
49
49
let ContractEventBody :: V0 ( body) = event;
50
50
51
- if body. topics . len ( ) != 3 {
51
+ if body. topics . len ( ) != 1 {
52
52
return false ;
53
53
}
54
54
55
- let [ symbol, _ , signer_hash ] = & body. topics [ ..] else {
55
+ let [ symbol] = & body. topics [ ..] else {
56
56
return false ;
57
57
} ;
58
58
59
59
let expected_topic: ScVal =
60
60
ScSymbol ( StringM :: from_str ( TOPIC_ROTATED ) . expect ( "must convert str to ScSymbol" ) )
61
61
. into ( ) ;
62
62
63
+ let rotated_signers = match & body. data {
64
+ ScVal :: Vec ( Some ( data) ) if data. len ( ) == 1 => {
65
+ let [ rotated_signers] = & data[ ..] else {
66
+ return false ;
67
+ } ;
68
+ rotated_signers. clone ( )
69
+ }
70
+ _ => return false ,
71
+ } ;
72
+
63
73
WeightedSigners :: try_from ( & self . verifier_set )
64
74
. ok ( )
65
- . and_then ( |signers| signers. hash ( ) . ok ( ) )
66
- . and_then ( |hash| ScVal :: try_from ( hash) . ok ( ) )
67
- . map_or ( false , |hash| {
68
- symbol == & expected_topic && signer_hash == & hash
75
+ . and_then ( |signers| ScVal :: try_from ( signers) . ok ( ) )
76
+ . map_or ( false , |signers : ScVal | {
77
+ symbol == & expected_topic && signers == rotated_signers
69
78
} )
70
79
}
71
80
}
@@ -138,7 +147,7 @@ mod test {
138
147
use stellar:: WeightedSigners ;
139
148
use stellar_xdr:: curr:: {
140
149
AccountId , BytesM , ContractEvent , ContractEventBody , ContractEventType , ContractEventV0 ,
141
- PublicKey , ScAddress , ScBytes , ScString , ScSymbol , ScVal , StringM , Uint256 ,
150
+ PublicKey , ScAddress , ScBytes , ScString , ScSymbol , ScVal , ScVec , StringM , Uint256 ,
142
151
} ;
143
152
144
153
use crate :: handlers:: stellar_verify_msg:: Message ;
@@ -293,7 +302,7 @@ mod test {
293
302
let signing_key = SigningKey :: generate ( & mut OsRng ) ;
294
303
295
304
let msg = Message {
296
- tx_id : Hash :: random ( ) . to_string ( ) ,
305
+ tx_id : format ! ( "{:x}" , Hash :: random( ) ) ,
297
306
event_index : 0 ,
298
307
source_address : ScAddress :: Account ( AccountId ( PublicKey :: PublicKeyTypeEd25519 (
299
308
Uint256 :: from ( signing_key. verifying_key ( ) . to_bytes ( ) ) ,
@@ -351,7 +360,7 @@ mod test {
351
360
let threshold = Uint128 :: new ( 2u128 ) ;
352
361
353
362
let verifier_set_confirmation = VerifierSetConfirmation {
354
- tx_id : Hash :: random ( ) . to_string ( ) ,
363
+ tx_id : format ! ( "{:x}" , Hash :: random( ) ) ,
355
364
event_index : 0 ,
356
365
verifier_set : VerifierSet {
357
366
signers : signers
@@ -363,21 +372,19 @@ mod test {
363
372
} ,
364
373
} ;
365
374
366
- let weighted_signers =
367
- WeightedSigners :: try_from ( & verifier_set_confirmation. verifier_set ) . unwrap ( ) ;
368
- let signer_hash = weighted_signers. hash ( ) . unwrap ( ) ;
375
+ let weighted_signers: ScVal =
376
+ WeightedSigners :: try_from ( & verifier_set_confirmation. verifier_set )
377
+ . unwrap ( )
378
+ . try_into ( )
379
+ . unwrap ( ) ;
369
380
370
381
let event_body = ContractEventBody :: V0 ( ContractEventV0 {
371
- topics : vec ! [
372
- ScVal :: Symbol ( ScSymbol ( StringM :: from_str( TOPIC_ROTATED ) . unwrap( ) ) ) ,
373
- ScVal :: Bytes ( ScBytes (
374
- BytesM :: try_from( Hash :: random( ) . to_fixed_bytes( ) ) . unwrap( ) ,
375
- ) ) ,
376
- ScVal :: try_from( signer_hash) . unwrap( ) ,
377
- ]
382
+ topics : vec ! [ ScVal :: Symbol ( ScSymbol (
383
+ StringM :: from_str( TOPIC_ROTATED ) . unwrap( ) ,
384
+ ) ) ]
378
385
. try_into ( )
379
386
. unwrap ( ) ,
380
- data : ScVal :: Vec ( None ) ,
387
+ data : ScVal :: Vec ( Some ( ScVec :: try_from ( vec ! [ weighted_signers ] ) . unwrap ( ) ) ) ,
381
388
} ) ;
382
389
383
390
let event = ContractEvent {
0 commit comments