Skip to content

Commit

Permalink
Update stellar-xdr, soroban-env and get BytesM/StringM (#726)
Browse files Browse the repository at this point in the history
  • Loading branch information
leighmcculloch authored Oct 13, 2022
1 parent 6cc9581 commit 5a6429c
Show file tree
Hide file tree
Showing 9 changed files with 303 additions and 28 deletions.
287 changes: 281 additions & 6 deletions Cargo.lock

Large diffs are not rendered by default.

12 changes: 6 additions & 6 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,12 @@ soroban-sdk = { path = "soroban-sdk" }
soroban-auth = { path = "soroban-auth" }
soroban-spec = { path = "soroban-spec" }
soroban-sdk-macros = { path = "soroban-sdk-macros" }
soroban-env-common = { git = "https://github.com/stellar/rs-soroban-env", rev = "91cf595" }
soroban-env-guest = { git = "https://github.com/stellar/rs-soroban-env", rev = "91cf595" }
soroban-env-host = { git = "https://github.com/stellar/rs-soroban-env", rev = "91cf595" }
soroban-env-macros = { git = "https://github.com/stellar/rs-soroban-env", rev = "91cf595" }
soroban-native-sdk-macros = { git = "https://github.com/stellar/rs-soroban-env", rev = "91cf595" }
stellar-xdr = { git = "https://github.com/stellar/rs-stellar-xdr", rev = "5cca712b" }
soroban-env-common = { git = "https://github.com/stellar/rs-soroban-env", rev = "4f2f3a2d" }
soroban-env-guest = { git = "https://github.com/stellar/rs-soroban-env", rev = "4f2f3a2d" }
soroban-env-host = { git = "https://github.com/stellar/rs-soroban-env", rev = "4f2f3a2d" }
soroban-env-macros = { git = "https://github.com/stellar/rs-soroban-env", rev = "4f2f3a2d" }
soroban-native-sdk-macros = { git = "https://github.com/stellar/rs-soroban-env", rev = "4f2f3a2d" }
stellar-xdr = { git = "https://github.com/stellar/rs-stellar-xdr", rev = "3ba13687" }
wasmi = { package = "soroban-wasmi", git = "https://github.com/stellar/wasmi", rev = "d1ec0036" }

# soroban-env-common = { path = "../rs-soroban-env/soroban-env-common" }
Expand Down
6 changes: 3 additions & 3 deletions soroban-sdk-macros/src/derive_enum.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use soroban_env_common::Symbol;
use syn::{spanned::Spanned, DataEnum, Error, Ident, Path};

use stellar_xdr::{
ScSpecEntry, ScSpecTypeDef, ScSpecUdtUnionCaseV0, ScSpecUdtUnionV0, VecM, WriteXdr,
ScSpecEntry, ScSpecTypeDef, ScSpecUdtUnionCaseV0, ScSpecUdtUnionV0, StringM, WriteXdr,
};

use crate::map_type::map_type;
Expand Down Expand Up @@ -55,7 +55,7 @@ pub fn derive_type_enum(
};
if let Some(f) = field {
let spec_case = ScSpecUdtUnionCaseV0 {
name: name.try_into().unwrap_or_else(|_| VecM::default()),
name: name.try_into().unwrap_or_else(|_| StringM::default()),
type_: Some(match map_type(&f.ty) {
Ok(t) => t,
Err(e) => {
Expand Down Expand Up @@ -86,7 +86,7 @@ pub fn derive_type_enum(
(spec_case, discriminant_const, try_from, into, try_from_xdr, into_xdr)
} else {
let spec_case = ScSpecUdtUnionCaseV0 {
name: name.try_into().unwrap_or_else(|_| VecM::default()),
name: name.try_into().unwrap_or_else(|_| StringM::default()),
type_: None,
};
let try_from = quote! {
Expand Down
6 changes: 3 additions & 3 deletions soroban-sdk-macros/src/derive_enum_int.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
use itertools::MultiUnzip;
use proc_macro2::TokenStream as TokenStream2;
use quote::{format_ident, quote};
use stellar_xdr::ScSpecUdtEnumV0;
use stellar_xdr::{ScSpecUdtEnumV0, StringM};
use syn::{spanned::Spanned, DataEnum, Error, ExprLit, Ident, Lit, Path};

use stellar_xdr::{ScSpecEntry, ScSpecUdtEnumCaseV0, VecM, WriteXdr};
use stellar_xdr::{ScSpecEntry, ScSpecUdtEnumCaseV0, WriteXdr};

// TODO: Add conversions to/from ScVal types.

Expand Down Expand Up @@ -44,7 +44,7 @@ pub fn derive_type_enum_int(
0
};
let spec_case = ScSpecUdtEnumCaseV0 {
name: name.try_into().unwrap_or_else(|_| VecM::default()),
name: name.try_into().unwrap_or_else(|_| StringM::default()),
value: discriminant,
};
let try_from = quote! { #discriminant => Self::#ident };
Expand Down
4 changes: 2 additions & 2 deletions soroban-sdk-macros/src/derive_error_enum_int.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use itertools::MultiUnzip;
use proc_macro2::TokenStream as TokenStream2;
use quote::{format_ident, quote};
use stellar_xdr::{ScSpecEntry, ScSpecUdtErrorEnumCaseV0, ScSpecUdtErrorEnumV0, VecM, WriteXdr};
use stellar_xdr::{ScSpecEntry, ScSpecUdtErrorEnumCaseV0, ScSpecUdtErrorEnumV0, StringM, WriteXdr};
use syn::{spanned::Spanned, DataEnum, Error, ExprLit, Ident, Lit, Path};

pub fn derive_type_error_enum_int(
Expand Down Expand Up @@ -40,7 +40,7 @@ pub fn derive_type_error_enum_int(
0
};
let spec_case = ScSpecUdtErrorEnumCaseV0 {
name: name.try_into().unwrap_or_else(|_| VecM::default()),
name: name.try_into().unwrap_or_else(|_| StringM::default()),
value: discriminant,
};
let try_from = quote! { #discriminant => Self::#ident };
Expand Down
6 changes: 3 additions & 3 deletions soroban-sdk-macros/src/derive_fn.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use itertools::MultiUnzip;
use proc_macro2::TokenStream as TokenStream2;
use quote::{format_ident, quote};
use stellar_xdr::{
ScSpecEntry, ScSpecFunctionInputV0, ScSpecFunctionV0, ScSpecTypeDef, VecM, WriteXdr,
ScSpecEntry, ScSpecFunctionInputV0, ScSpecFunctionV0, ScSpecTypeDef, StringM, VecM, WriteXdr,
};
use syn::{
punctuated::Punctuated,
Expand Down Expand Up @@ -66,7 +66,7 @@ pub fn derive_fn(
let name = name.try_into().unwrap_or_else(|_| {
const MAX: u32 = 30;
errors.push(Error::new(ident.span(), format!("argument name too long, max length {} characters", MAX)));
VecM::<_, MAX>::default()
StringM::<MAX>::default()
});
ScSpecFunctionInputV0{ name, type_ }
},
Expand Down Expand Up @@ -148,7 +148,7 @@ pub fn derive_fn(
MAX,
),
));
VecM::<_, MAX>::default()
StringM::<MAX>::default()
}),
inputs: spec_args.try_into().unwrap_or_else(|_| {
const MAX: u32 = 10;
Expand Down
4 changes: 2 additions & 2 deletions soroban-sdk-macros/src/derive_struct.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use soroban_env_common::Symbol;
use syn::{spanned::Spanned, DataStruct, Error, Ident, Path};

use stellar_xdr::{
ScSpecEntry, ScSpecTypeDef, ScSpecUdtStructFieldV0, ScSpecUdtStructV0, VecM, WriteXdr,
ScSpecEntry, ScSpecTypeDef, ScSpecUdtStructFieldV0, ScSpecUdtStructV0, StringM, WriteXdr,
};

use crate::map_type::map_type;
Expand Down Expand Up @@ -43,7 +43,7 @@ pub fn derive_type_struct(
errors.push(Error::new(ident.span(), format!("struct field name {}", e)));
}
let spec_field = ScSpecUdtStructFieldV0 {
name: name.clone().try_into().unwrap_or_else(|_| VecM::default()),
name: name.clone().try_into().unwrap_or_else(|_| StringM::default()),
type_: match map_type(&f.ty) {
Ok(t) => t,
Err(e) => {
Expand Down
4 changes: 2 additions & 2 deletions soroban-sdk-macros/src/derive_struct_tuple.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use quote::{format_ident, quote};
use syn::{spanned::Spanned, DataStruct, Error, Ident, Path};

use stellar_xdr::{
ScSpecEntry, ScSpecTypeDef, ScSpecUdtStructFieldV0, ScSpecUdtStructV0, VecM, WriteXdr,
ScSpecEntry, ScSpecTypeDef, ScSpecUdtStructFieldV0, ScSpecUdtStructV0, StringM, WriteXdr,
};

use crate::map_type::map_type;
Expand Down Expand Up @@ -37,7 +37,7 @@ pub fn derive_type_struct_tuple(
let ident = Literal::usize_unsuffixed(i);
let name = format!("{}", i);
let spec_field = ScSpecUdtStructFieldV0 {
name: name.try_into().unwrap_or_else(|_| VecM::default()),
name: name.try_into().unwrap_or_else(|_| StringM::default()),
type_: match map_type(&f.ty) {
Ok(t) => t,
Err(e) => {
Expand Down
2 changes: 1 addition & 1 deletion soroban-sdk/src/accounts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -472,7 +472,7 @@ impl Accounts {
account_id: id.clone(),
balance: 0,
flags: 0,
home_domain: xdr::VecM::default(),
home_domain: xdr::StringM::default(),
inflation_dest: None,
num_sub_entries: 0,
seq_num: xdr::SequenceNumber(0),
Expand Down

0 comments on commit 5a6429c

Please sign in to comment.