File tree Expand file tree Collapse file tree 3 files changed +14
-9
lines changed
Expand file tree Collapse file tree 3 files changed +14
-9
lines changed Original file line number Diff line number Diff line change @@ -279,13 +279,13 @@ impl TryFromVal<Env, ScAddress> for MuxedAddress {
279279#[ cfg( any( test, feature = "testutils" ) ) ]
280280#[ cfg_attr( feature = "docs" , doc( cfg( feature = "testutils" ) ) ) ]
281281impl crate :: testutils:: MuxedAddress for MuxedAddress {
282- fn generate ( env : & Env , id : u64 ) -> crate :: MuxedAddress {
282+ fn generate ( env : & Env ) -> crate :: MuxedAddress {
283283 let sc_val = ScVal :: Address ( crate :: env:: internal:: xdr:: ScAddress :: MuxedAccount (
284284 crate :: env:: internal:: xdr:: MuxedEd25519Account {
285285 ed25519 : crate :: env:: internal:: xdr:: Uint256 (
286286 env. with_generator ( |mut g| g. address ( ) ) ,
287287 ) ,
288- id,
288+ id : env . with_generator ( | mut g| g . mux_id ( ) ) ,
289289 } ,
290290 ) ) ;
291291 sc_val. try_into_val ( env) . unwrap ( )
Original file line number Diff line number Diff line change @@ -31,7 +31,7 @@ fn test_contract_address_to_muxed_address_conversion() {
3131#[ test]
3232fn test_muxed_address_component_getters ( ) {
3333 let env = Env :: default ( ) ;
34- let muxed_address = MuxedAddress :: generate ( & env, 123_456 ) ;
34+ let muxed_address = MuxedAddress :: generate ( & env) ;
3535 let mut expected_id = [ 0_u8 ; 32 ] ;
3636 expected_id[ 31 ] = 1 ;
3737 let expected_address = Address :: try_from_val (
@@ -42,7 +42,6 @@ fn test_muxed_address_component_getters() {
4242 )
4343 . unwrap ( ) ;
4444 assert_eq ! ( muxed_address. address( ) , expected_address) ;
45- assert_eq ! ( muxed_address. id( ) , Some ( 123_456 ) ) ;
4645
4746 let muxed_address_with_another_id = MuxedAddress :: new ( muxed_address, u64:: MAX ) ;
4847 assert_eq ! ( muxed_address_with_another_id. address( ) , expected_address) ;
Original file line number Diff line number Diff line change @@ -178,14 +178,16 @@ impl AuthSnapshot {
178178#[ serde( rename_all = "snake_case" ) ]
179179pub struct Generators {
180180 address : u64 ,
181- nonce : u64 ,
181+ nonce : i64 ,
182+ mux_id : u64 ,
182183}
183184
184185impl Default for Generators {
185186 fn default ( ) -> Generators {
186187 Generators {
187188 address : 0 ,
188189 nonce : 0 ,
190+ mux_id : 0 ,
189191 }
190192 }
191193}
@@ -230,7 +232,12 @@ impl Generators {
230232
231233 pub fn nonce ( & mut self ) -> i64 {
232234 self . nonce = self . nonce . checked_add ( 1 ) . unwrap ( ) ;
233- self . nonce as i64
235+ self . nonce
236+ }
237+
238+ pub fn mux_id ( & mut self ) -> u64 {
239+ self . mux_id = self . mux_id . checked_add ( 1 ) . unwrap ( ) ;
240+ self . mux_id
234241 }
235242}
236243
@@ -439,12 +446,11 @@ pub trait Address {
439446}
440447
441448pub trait MuxedAddress {
442- /// Create a new MuxedAddress with arbitrary `Address` part and provided
443- /// multiplexing identifier.
449+ /// Create a new MuxedAddress with arbitrary `Address` and id parts.
444450 ///
445451 /// Note, that since currently only accounts can be multiplexed, the
446452 /// underlying `Address` will be an account (not contract) address.
447- fn generate ( env : & Env , id : u64 ) -> crate :: MuxedAddress ;
453+ fn generate ( env : & Env ) -> crate :: MuxedAddress ;
448454
449455 /// Returns a new `MuxedAddress` that has the same `Address` part as the
450456 /// provided `address` and the provided multiplexing id.
You can’t perform that action at this time.
0 commit comments