Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/main' into bls12-381
Browse files Browse the repository at this point in the history
  • Loading branch information
sisuresh committed Sep 27, 2024
2 parents 401388f + abbba12 commit 153c026
Show file tree
Hide file tree
Showing 74 changed files with 930 additions and 352 deletions.
27 changes: 15 additions & 12 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -26,17 +26,17 @@ soroban-token-sdk = { version = "22.0.0-rc.1", path = "soroban-token-sdk" }
[workspace.dependencies.soroban-env-common]
version = "=22.0.0"
git = "https://github.com/stellar/rs-soroban-env"
rev = "0497816694bef2b103494c8c61b7c8a06a72c7d3"
rev = "60e9be87a157cc9b5132056e1314faabd485b5fb"

[workspace.dependencies.soroban-env-guest]
version = "=22.0.0"
git = "https://github.com/stellar/rs-soroban-env"
rev = "0497816694bef2b103494c8c61b7c8a06a72c7d3"
rev = "60e9be87a157cc9b5132056e1314faabd485b5fb"

[workspace.dependencies.soroban-env-host]
version = "=22.0.0"
git = "https://github.com/stellar/rs-soroban-env"
rev = "0497816694bef2b103494c8c61b7c8a06a72c7d3"
rev = "60e9be87a157cc9b5132056e1314faabd485b5fb"

[workspace.dependencies.stellar-strkey]
version = "=0.0.9"
Expand All @@ -46,7 +46,7 @@ version = "=22.0.0"
default-features = false
features = ["curr"]
git = "https://github.com/stellar/rs-stellar-xdr"
rev = "b5516843b6379e4e29520bf2ba156484f62edc46"
rev = "67be5955a15f1d3a4df83fe86e6ae107f687141b"

#[patch."https://github.com/stellar/rs-soroban-env"]
#soroban-env-common = { path = "../rs-soroban-env/soroban-env-common" }
Expand Down
5 changes: 2 additions & 3 deletions deny.toml
Original file line number Diff line number Diff line change
Expand Up @@ -243,9 +243,8 @@ deny = [

# Certain crates/versions that will be skipped when doing duplicate detection.
skip = [
#{ name = "ansi_term", version = "=0.11.0" },
{ name = "hashbrown", version = "=0.14.5" },
{ name = "syn", version = "=2.0.77" },
{ name = "hashbrown", version = "=0.13.2" },
{ name = "syn", version = "=1.0.109" },
]
# Similarly to `skip` allows you to skip certain crates during duplicate
# detection. Unlike skip, it also includes the entire tree of transitive
Expand Down
9 changes: 6 additions & 3 deletions soroban-sdk-macros/src/derive_enum_int.rs
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,6 @@ pub fn derive_type_enum_int(
// Output.
let mut output = quote! {
#spec_gen
const _: () = { fn assert_copy(v: #enum_ident) -> impl Copy { v } };

impl #path::TryFromVal<#path::Env, #path::Val> for #enum_ident {
type Error = #path::ConversionError;
Expand Down Expand Up @@ -144,15 +143,19 @@ pub fn derive_type_enum_int(
type Error = #path::xdr::Error;
#[inline(always)]
fn try_into(self) -> Result<#path::xdr::ScVal, #path::xdr::Error> {
Ok((*self as u32).into())
Ok(match self {
#(#try_intos,)*
})
}
}

impl TryInto<#path::xdr::ScVal> for #enum_ident {
type Error = #path::xdr::Error;
#[inline(always)]
fn try_into(self) -> Result<#path::xdr::ScVal, #path::xdr::Error> {
Ok((self as u32).into())
Ok(match self {
#(#try_intos,)*
})
}
}

Expand Down
17 changes: 8 additions & 9 deletions soroban-sdk-macros/src/derive_error_enum_int.rs
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,6 @@ pub fn derive_type_error_enum_int(
// Output.
quote! {
#spec_gen
const _: () = { fn assert_copy(v: #enum_ident) -> impl Copy { v } };

impl TryFrom<#path::Error> for #enum_ident {
type Error = #path::Error;
Expand Down Expand Up @@ -121,16 +120,16 @@ pub fn derive_type_error_enum_int(
impl From<#enum_ident> for #path::Error {
#[inline(always)]
fn from(val: #enum_ident) -> #path::Error {
match val {
#(#into_errors,)*
}
<_ as From<&#enum_ident>>::from(&val)
}
}

impl From<&#enum_ident> for #path::Error {
#[inline(always)]
fn from(val: &#enum_ident) -> #path::Error {
<_ as From<#enum_ident>>::from(*val)
match val {
#(#into_errors,)*
}
}
}

Expand Down Expand Up @@ -159,16 +158,16 @@ pub fn derive_type_error_enum_int(
impl From<#enum_ident> for #path::InvokeError {
#[inline(always)]
fn from(val: #enum_ident) -> #path::InvokeError {
match val {
#(#into_invoke_errors,)*
}
<_ as From<&#enum_ident>>::from(&val)
}
}

impl From<&#enum_ident> for #path::InvokeError {
#[inline(always)]
fn from(val: &#enum_ident) -> #path::InvokeError {
<_ as From<#enum_ident>>::from(*val)
match val {
#(#into_invoke_errors,)*
}
}
}

Expand Down
2 changes: 1 addition & 1 deletion soroban-sdk/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ fn test() {
# #[cfg(feature = "testutils")]
# fn main() {
let env = Env::default();
let contract_id = env.register_contract(None, HelloContract);
let contract_id = env.register(HelloContract, ());
let client = HelloContractClient::new(&env, &contract_id);

let words = client.hello(&symbol_short!("Dev"));
Expand Down
37 changes: 19 additions & 18 deletions soroban-sdk/src/address.rs
Original file line number Diff line number Diff line change
Expand Up @@ -124,18 +124,21 @@ impl TryFromVal<Env, &Address> for Val {
}

#[cfg(not(target_family = "wasm"))]
impl TryFrom<&Address> for ScVal {
type Error = ConversionError;
fn try_from(v: &Address) -> Result<Self, ConversionError> {
Ok(ScVal::try_from_val(&v.env, &v.obj.to_val())?)
impl From<&Address> for ScVal {
fn from(v: &Address) -> Self {
// This conversion occurs only in test utilities, and theoretically all
// values should convert to an ScVal because the Env won't let the host
// type to exist otherwise, unwrapping. Even if there are edge cases
// that don't, this is a trade off for a better test developer
// experience.
ScVal::try_from_val(&v.env, &v.obj.to_val()).unwrap()
}
}

#[cfg(not(target_family = "wasm"))]
impl TryFrom<Address> for ScVal {
type Error = ConversionError;
fn try_from(v: Address) -> Result<Self, ConversionError> {
(&v).try_into()
impl From<Address> for ScVal {
fn from(v: Address) -> Self {
(&v).into()
}
}

Expand All @@ -152,21 +155,19 @@ impl TryFromVal<Env, ScVal> for Address {
}

#[cfg(not(target_family = "wasm"))]
impl TryFrom<&Address> for ScAddress {
type Error = ConversionError;
fn try_from(v: &Address) -> Result<Self, Self::Error> {
match ScVal::try_from_val(&v.env, &v.obj.to_val())? {
ScVal::Address(a) => Ok(a),
_ => Err(ConversionError),
impl From<&Address> for ScAddress {
fn from(v: &Address) -> Self {
match ScVal::try_from_val(&v.env, &v.obj.to_val()).unwrap() {
ScVal::Address(a) => a,
_ => panic!("expected ScVal::Address"),
}
}
}

#[cfg(not(target_family = "wasm"))]
impl TryFrom<Address> for ScAddress {
type Error = ConversionError;
fn try_from(v: Address) -> Result<Self, Self::Error> {
(&v).try_into()
impl From<Address> for ScAddress {
fn from(v: Address) -> Self {
(&v).into()
}
}

Expand Down
19 changes: 11 additions & 8 deletions soroban-sdk/src/bytes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -328,18 +328,21 @@ impl From<&Bytes> for Bytes {
}

#[cfg(not(target_family = "wasm"))]
impl TryFrom<&Bytes> for ScVal {
type Error = ConversionError;
fn try_from(v: &Bytes) -> Result<Self, ConversionError> {
Ok(ScVal::try_from_val(&v.env, &v.obj.to_val())?)
impl From<&Bytes> for ScVal {
fn from(v: &Bytes) -> Self {
// This conversion occurs only in test utilities, and theoretically all
// values should convert to an ScVal because the Env won't let the host
// type to exist otherwise, unwrapping. Even if there are edge cases
// that don't, this is a trade off for a better test developer
// experience.
ScVal::try_from_val(&v.env, &v.obj.to_val()).unwrap()
}
}

#[cfg(not(target_family = "wasm"))]
impl TryFrom<Bytes> for ScVal {
type Error = ConversionError;
fn try_from(v: Bytes) -> Result<Self, ConversionError> {
(&v).try_into()
impl From<Bytes> for ScVal {
fn from(v: Bytes) -> Self {
(&v).into()
}
}

Expand Down
4 changes: 2 additions & 2 deletions soroban-sdk/src/deploy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
//! # #[cfg(feature = "testutils")]
//! # fn main() {
//! let env = Env::default();
//! let contract_address = env.register_contract(None, Contract);
//! let contract_address = env.register(Contract, ());
//! let contract = ContractClient::new(&env, &contract_address);
//! // Upload the contract code before deploying its instance.
//! let wasm_hash = env.deployer().upload_contract_wasm(DEPLOYED_WASM);
Expand Down Expand Up @@ -71,7 +71,7 @@
//! # #[cfg(feature = "testutils")]
//! # fn main() {
//! let env = Env::default();
//! let contract_address = env.register_contract(None, Contract);
//! let contract_address = env.register(Contract, ());
//! let contract = ContractClient::new(&env, &contract_address);
//! // Upload the contract code before deploying its instance.
//! let wasm_hash = env.deployer().upload_contract_wasm(DEPLOYED_WASM_WITH_CTOR);
Expand Down
Loading

0 comments on commit 153c026

Please sign in to comment.