Skip to content

Commit f8be55e

Browse files
committed
Muxed address support for Soroban SDK.
This introduces the `MuxedAddress` type that maps to either `AddressObject` or `MuxedAddressObject`.
1 parent 97ab125 commit f8be55e

File tree

113 files changed

+749
-309
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

113 files changed

+749
-309
lines changed

Cargo.lock

Lines changed: 223 additions & 179 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -24,19 +24,19 @@ soroban-ledger-snapshot = { version = "22.0.7", path = "soroban-ledger-snapshot"
2424
soroban-token-sdk = { version = "22.0.7", path = "soroban-token-sdk" }
2525

2626
[workspace.dependencies.soroban-env-common]
27-
version = "=22.1.3"
28-
#git = "https://github.com/stellar/rs-soroban-env"
29-
#rev = "bd0c80a1fe171e75f8d745f17975a73927d44ecd"
27+
version = "=23.0.0"
28+
git = "https://github.com/stellar/rs-soroban-env"
29+
rev = "b4a68ce18227b7c9c52850554478e047359160e4"
3030

3131
[workspace.dependencies.soroban-env-guest]
32-
version = "=22.1.3"
33-
#git = "https://github.com/stellar/rs-soroban-env"
34-
#rev = "bd0c80a1fe171e75f8d745f17975a73927d44ecd"
32+
version = "=23.0.0"
33+
git = "https://github.com/stellar/rs-soroban-env"
34+
rev = "b4a68ce18227b7c9c52850554478e047359160e4"
3535

3636
[workspace.dependencies.soroban-env-host]
37-
version = "=22.1.3"
38-
#git = "https://github.com/stellar/rs-soroban-env"
39-
#rev = "bd0c80a1fe171e75f8d745f17975a73927d44ecd"
37+
version = "=23.0.0"
38+
git = "https://github.com/stellar/rs-soroban-env"
39+
rev = "b4a68ce18227b7c9c52850554478e047359160e4"
4040

4141
[workspace.dependencies.stellar-strkey]
4242
version = "=0.0.9"
@@ -45,8 +45,8 @@ version = "=0.0.9"
4545
version = "=22.1.0"
4646
default-features = false
4747
features = ["curr"]
48-
#git = "https://github.com/stellar/rs-stellar-xdr"
49-
#rev = "67be5955a15f1d3a4df83fe86e6ae107f687141b"
48+
git = "https://github.com/stellar/rs-stellar-xdr"
49+
rev = "fdd0c4f467ea654c3aaf139e8e914e1c416a39b8"
5050

5151
#[patch.crates-io]
5252
#soroban-env-common = { path = "../rs-soroban-env/soroban-env-common" }

soroban-sdk-macros/src/map_type.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ pub fn map_type(t: &Type, allow_hash: bool) -> Result<ScSpecTypeDef, Error> {
3535
"Error" => Ok(ScSpecTypeDef::Error),
3636
"Bytes" => Ok(ScSpecTypeDef::Bytes),
3737
"Address" => Ok(ScSpecTypeDef::Address),
38+
"MuxedAddress" => Ok(ScSpecTypeDef::MuxedAddress),
3839
"Timepoint" => Ok(ScSpecTypeDef::Timepoint),
3940
"Duration" => Ok(ScSpecTypeDef::Duration),
4041
s => Ok(ScSpecTypeDef::Udt(ScSpecTypeUdt {

soroban-sdk/src/address.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ impl Debug for Address {
5555
let strkey = Strkey::Contract(Contract(contract_id.0));
5656
write!(f, "Contract({})", strkey.to_string())?;
5757
}
58+
_ => return Err(core::fmt::Error),
5859
}
5960
} else {
6061
return Err(core::fmt::Error);

soroban-sdk/src/env.rs

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -122,8 +122,8 @@ use crate::{
122122
};
123123
use internal::{
124124
AddressObject, Bool, BytesObject, DurationObject, I128Object, I256Object, I256Val, I64Object,
125-
StorageType, StringObject, Symbol, SymbolObject, TimepointObject, U128Object, U256Object,
126-
U256Val, U32Val, U64Object, U64Val, Void,
125+
MuxedAddressObject, StorageType, StringObject, Symbol, SymbolObject, TimepointObject,
126+
U128Object, U256Object, U256Val, U32Val, U64Object, U64Val, Void,
127127
};
128128

129129
#[doc(hidden)]
@@ -354,6 +354,27 @@ impl Env {
354354
internal::Env::require_auth(self, address.to_object()).unwrap_infallible();
355355
}
356356

357+
#[doc(hidden)]
358+
pub(crate) fn get_address_from_muxed_address(
359+
&self,
360+
muxed_address: MuxedAddressObject,
361+
) -> Address {
362+
Address::try_from_val(
363+
self,
364+
&internal::Env::get_address_from_muxed_address(self, muxed_address).unwrap_infallible(),
365+
)
366+
.unwrap_infallible()
367+
}
368+
369+
#[doc(hidden)]
370+
pub(crate) fn get_id_from_muxed_address(&self, muxed_address: MuxedAddressObject) -> u64 {
371+
u64::try_from_val(
372+
self,
373+
&internal::Env::get_id_from_muxed_address(self, muxed_address).unwrap_infallible(),
374+
)
375+
.unwrap()
376+
}
377+
357378
/// Invokes a function of a contract that is registered in the [Env].
358379
///
359380
/// # Panics
@@ -514,7 +535,7 @@ impl Env {
514535

515536
let rf = Rc::new(EmptySnapshotSource());
516537
let info = internal::LedgerInfo {
517-
protocol_version: 22,
538+
protocol_version: 23,
518539
sequence_number: 0,
519540
timestamp: 0,
520541
network_id: [0; 32],

soroban-sdk/src/lib.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -736,6 +736,7 @@ pub mod unwrap;
736736
mod env;
737737

738738
mod address;
739+
mod muxed_address;
739740
mod symbol;
740741

741742
pub use env::{ConversionError, Env};
@@ -797,6 +798,7 @@ mod vec;
797798
pub use address::Address;
798799
pub use bytes::{Bytes, BytesN};
799800
pub use map::Map;
801+
pub use muxed_address::MuxedAddress;
800802
pub use symbol::Symbol;
801803
pub use vec::Vec;
802804
mod num;

0 commit comments

Comments
 (0)