Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update stellar-xdr, soroban-env and get BytesM/StringM #726

Merged
merged 6 commits into from
Oct 13, 2022
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
303 changes: 297 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 = "b065e3f3" }
soroban-env-guest = { git = "https://github.com/stellar/rs-soroban-env", rev = "b065e3f3" }
soroban-env-host = { git = "https://github.com/stellar/rs-soroban-env", rev = "b065e3f3" }
soroban-env-macros = { git = "https://github.com/stellar/rs-soroban-env", rev = "b065e3f3" }
soroban-native-sdk-macros = { git = "https://github.com/stellar/rs-soroban-env", rev = "b065e3f3" }
stellar-xdr = { git = "https://github.com/stellar/rs-stellar-xdr", rev = "390f182a" }
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