Skip to content

Commit

Permalink
Update env (#1150)
Browse files Browse the repository at this point in the history
### What

[TODO: Short statement about what is changing.]

### Why

[TODO: Why this change is being made. Include any context required to
understand the why.]

### Known limitations

[TODO or N/A]

---------

Co-authored-by: Leigh McCulloch <351529+leighmcculloch@users.noreply.github.com>
  • Loading branch information
jayz22 and leighmcculloch committed Nov 13, 2023
1 parent ae2d25e commit 77a760b
Show file tree
Hide file tree
Showing 92 changed files with 555 additions and 1,478 deletions.
33 changes: 23 additions & 10 deletions Cargo.lock

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

12 changes: 5 additions & 7 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -42,27 +42,25 @@ soroban-token-sdk = { version = "20.0.0-rc2", path = "soroban-token-sdk" }
[workspace.dependencies.soroban-env-common]
version = "20.0.0-rc2"
git = "https://github.com/stellar/rs-soroban-env"
rev = "6d26ca68170ecf9d19b8c55bfcc157a1ad62b7e9"
rev = "472486c9dba96e09746522df0c9052cd50568e62"

[workspace.dependencies.soroban-env-guest]
version = "20.0.0-rc2"
git = "https://github.com/stellar/rs-soroban-env"
rev = "6d26ca68170ecf9d19b8c55bfcc157a1ad62b7e9"
rev = "472486c9dba96e09746522df0c9052cd50568e62"

[workspace.dependencies.soroban-env-host]
version = "20.0.0-rc2"
git = "https://github.com/stellar/rs-soroban-env"
rev = "6d26ca68170ecf9d19b8c55bfcc157a1ad62b7e9"
rev = "472486c9dba96e09746522df0c9052cd50568e62"

[workspace.dependencies.stellar-strkey]
version = "0.0.7"
git = "https://github.com/stellar/rs-stellar-strkey"
rev = "e6ba45c60c16de28c7522586b80ed0150157df73"
version = "0.0.8"

[workspace.dependencies.stellar-xdr]
version = "20.0.0-rc1"
git = "https://github.com/stellar/rs-stellar-xdr"
rev = "9c97e4fa909a0b6455547a4f4a95800696b2a69a"
rev = "957273d7b8092888849219a3ad2aa054059ca89d"
default-features = false
features = ["curr"]

Expand Down
4 changes: 2 additions & 2 deletions soroban-sdk-macros/src/derive_enum.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use stellar_xdr::{
ScSpecUdtUnionCaseVoidV0, ScSpecUdtUnionV0, StringM, VecM, WriteXdr, SCSYMBOL_LIMIT,
};

use crate::{doc::docs_from_attrs, map_type::map_type};
use crate::{doc::docs_from_attrs, map_type::map_type, DEFAULT_XDR_RW_LIMITS};

pub fn derive_type_enum(
path: &Path,
Expand Down Expand Up @@ -144,7 +144,7 @@ pub fn derive_type_enum(
name: enum_ident.to_string().try_into().unwrap(),
cases: spec_cases.try_into().unwrap(),
});
let spec_xdr = spec_entry.to_xdr().unwrap();
let spec_xdr = spec_entry.to_xdr(DEFAULT_XDR_RW_LIMITS).unwrap();
let spec_xdr_lit = proc_macro2::Literal::byte_string(spec_xdr.as_slice());
let spec_xdr_len = spec_xdr.len();
let spec_ident = format_ident!("__SPEC_XDR_TYPE_{}", enum_ident.to_string().to_uppercase());
Expand Down
4 changes: 2 additions & 2 deletions soroban-sdk-macros/src/derive_enum_int.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use syn::{spanned::Spanned, Attribute, DataEnum, Error, ExprLit, Ident, Lit, Pat

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

use crate::doc::docs_from_attrs;
use crate::{doc::docs_from_attrs, DEFAULT_XDR_RW_LIMITS};

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

Expand Down Expand Up @@ -73,7 +73,7 @@ pub fn derive_type_enum_int(
name: enum_ident.to_string().try_into().unwrap(),
cases: spec_cases.try_into().unwrap(),
});
let spec_xdr = spec_entry.to_xdr().unwrap();
let spec_xdr = spec_entry.to_xdr(DEFAULT_XDR_RW_LIMITS).unwrap();
let spec_xdr_lit = proc_macro2::Literal::byte_string(spec_xdr.as_slice());
let spec_xdr_len = spec_xdr.len();
let spec_ident = format_ident!("__SPEC_XDR_TYPE_{}", enum_ident.to_string().to_uppercase());
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
Expand Up @@ -5,7 +5,7 @@ use stellar_xdr::curr as stellar_xdr;
use stellar_xdr::{ScSpecEntry, ScSpecUdtErrorEnumCaseV0, ScSpecUdtErrorEnumV0, StringM, WriteXdr};
use syn::{spanned::Spanned, Attribute, DataEnum, Error, ExprLit, Ident, Lit, Path};

use crate::doc::docs_from_attrs;
use crate::{doc::docs_from_attrs, DEFAULT_XDR_RW_LIMITS};

pub fn derive_type_error_enum_int(
path: &Path,
Expand Down Expand Up @@ -69,7 +69,7 @@ pub fn derive_type_error_enum_int(
name: enum_ident.to_string().try_into().unwrap(),
cases: spec_cases.try_into().unwrap(),
});
let spec_xdr = spec_entry.to_xdr().unwrap();
let spec_xdr = spec_entry.to_xdr(DEFAULT_XDR_RW_LIMITS).unwrap();
let spec_xdr_lit = proc_macro2::Literal::byte_string(spec_xdr.as_slice());
let spec_xdr_len = spec_xdr.len();
let spec_ident = format_ident!("__SPEC_XDR_TYPE_{}", enum_ident.to_string().to_uppercase());
Expand Down
4 changes: 2 additions & 2 deletions soroban-sdk-macros/src/derive_spec_fn.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ use syn::{
ReturnType, Type, TypePath,
};

use crate::{doc::docs_from_attrs, map_type::map_type};
use crate::{doc::docs_from_attrs, map_type::map_type, DEFAULT_XDR_RW_LIMITS};

#[allow(clippy::too_many_arguments)]
pub fn derive_fn_spec(
Expand Down Expand Up @@ -134,7 +134,7 @@ pub fn derive_fn_spec(
}),
outputs: spec_result.try_into().unwrap(),
});
let spec_xdr = spec_entry.to_xdr().unwrap();
let spec_xdr = spec_entry.to_xdr(DEFAULT_XDR_RW_LIMITS).unwrap();
let spec_xdr_lit = proc_macro2::Literal::byte_string(spec_xdr.as_slice());
let spec_xdr_len = spec_xdr.len();
let spec_ident = format_ident!("__SPEC_XDR_FN_{}", ident.to_string().to_uppercase());
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 @@ -9,7 +9,7 @@ use stellar_xdr::{
SCSYMBOL_LIMIT,
};

use crate::{doc::docs_from_attrs, map_type::map_type};
use crate::{doc::docs_from_attrs, map_type::map_type, DEFAULT_XDR_RW_LIMITS};

// TODO: Add field attribute for including/excluding fields in types.
// TODO: Better handling of partial types and types without all their fields and
Expand Down Expand Up @@ -84,7 +84,7 @@ pub fn derive_type_struct(
name: ident.to_string().try_into().unwrap(),
fields: spec_fields.try_into().unwrap(),
});
let spec_xdr = spec_entry.to_xdr().unwrap();
let spec_xdr = spec_entry.to_xdr(DEFAULT_XDR_RW_LIMITS).unwrap();
let spec_xdr_lit = proc_macro2::Literal::byte_string(spec_xdr.as_slice());
let spec_xdr_len = spec_xdr.len();
let spec_ident = format_ident!("__SPEC_XDR_TYPE_{}", ident.to_string().to_uppercase());
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 @@ -8,7 +8,7 @@ use stellar_xdr::{
ScSpecEntry, ScSpecTypeDef, ScSpecUdtStructFieldV0, ScSpecUdtStructV0, StringM, WriteXdr,
};

use crate::{doc::docs_from_attrs, map_type::map_type};
use crate::{doc::docs_from_attrs, map_type::map_type, DEFAULT_XDR_RW_LIMITS};

pub fn derive_type_struct_tuple(
path: &Path,
Expand Down Expand Up @@ -71,7 +71,7 @@ pub fn derive_type_struct_tuple(
name: ident.to_string().try_into().unwrap(),
fields: field_specs.try_into().unwrap(),
});
let spec_xdr = spec_entry.to_xdr().unwrap();
let spec_xdr = spec_entry.to_xdr(DEFAULT_XDR_RW_LIMITS).unwrap();
let spec_xdr_lit = proc_macro2::Literal::byte_string(spec_xdr.as_slice());
let spec_xdr_len = spec_xdr.len();
let spec_ident = format_ident!("__SPEC_XDR_TYPE_{}", ident.to_string().to_uppercase());
Expand Down
9 changes: 7 additions & 2 deletions soroban-sdk-macros/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,15 @@ use syn_ext::HasFnsItem;
use soroban_spec_rust::{generate_from_wasm, GenerateFromFileError};

use stellar_xdr::curr as stellar_xdr;
use stellar_xdr::{ScMetaEntry, ScMetaV0, StringM, WriteXdr};
use stellar_xdr::{Limits, ScMetaEntry, ScMetaV0, StringM, WriteXdr};

use soroban_env_common::Symbol;

pub(crate) const DEFAULT_XDR_RW_LIMITS: Limits = Limits {
depth: 500,
len: 0x1000000,
};

#[proc_macro]
pub fn internal_symbol_short(input: TokenStream) -> TokenStream {
let input = parse_macro_input!(input as LitStr);
Expand Down Expand Up @@ -327,7 +332,7 @@ pub fn contractmeta(metadata: TokenStream) -> TokenStream {

let meta_v0 = ScMetaV0 { key, val };
let meta_entry = ScMetaEntry::ScMetaV0(meta_v0);
let metadata_xdr: Vec<u8> = match meta_entry.to_xdr() {
let metadata_xdr: Vec<u8> = match meta_entry.to_xdr(DEFAULT_XDR_RW_LIMITS) {
Ok(v) => v,
Err(e) => {
return Error::new(Span::call_site(), e.to_string())
Expand Down
6 changes: 4 additions & 2 deletions soroban-sdk/src/tests/contract_add_i32.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
use crate as soroban_sdk;
use soroban_sdk::{contract, contractimpl, Env};
use stellar_xdr::curr as stellar_xdr;
use stellar_xdr::{ReadXdr, ScSpecEntry, ScSpecFunctionInputV0, ScSpecFunctionV0, ScSpecTypeDef};
use stellar_xdr::{
Limits, ReadXdr, ScSpecEntry, ScSpecFunctionInputV0, ScSpecFunctionV0, ScSpecTypeDef,
};

#[contract]
pub struct Contract;
Expand All @@ -26,7 +28,7 @@ fn test_functional() {

#[test]
fn test_spec() {
let entries = ScSpecEntry::from_xdr(__SPEC_XDR_FN_ADD).unwrap();
let entries = ScSpecEntry::from_xdr(__SPEC_XDR_FN_ADD, Limits::none()).unwrap();
let expect = ScSpecEntry::FunctionV0(ScSpecFunctionV0 {
doc: "".try_into().unwrap(),
name: "add".try_into().unwrap(),
Expand Down
26 changes: 14 additions & 12 deletions soroban-sdk/src/tests/contract_docs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ mod fn_ {
use crate as soroban_sdk;
use soroban_sdk::{contract, contractimpl, Env};
use stellar_xdr::curr as stellar_xdr;
use stellar_xdr::{ReadXdr, ScSpecEntry, ScSpecFunctionV0};
use stellar_xdr::{Limits, ReadXdr, ScSpecEntry, ScSpecFunctionV0};

#[contract]
pub struct Contract;
Expand All @@ -25,7 +25,7 @@ mod fn_ {

#[test]
fn test_spec() {
let entry = ScSpecEntry::from_xdr(__SPEC_XDR_FN_ADD).unwrap();
let entry = ScSpecEntry::from_xdr(__SPEC_XDR_FN_ADD, Limits::none()).unwrap();
let expect = ScSpecEntry::FunctionV0(ScSpecFunctionV0 {
doc: "Add adds\nthings together.".try_into().unwrap(),
name: "add".try_into().unwrap(),
Expand All @@ -40,7 +40,7 @@ mod struct_ {
use crate as soroban_sdk;
use soroban_sdk::contracttype;
use stellar_xdr::curr as stellar_xdr;
use stellar_xdr::{ReadXdr, ScSpecEntry, ScSpecUdtStructFieldV0, ScSpecUdtStructV0};
use stellar_xdr::{Limits, ReadXdr, ScSpecEntry, ScSpecUdtStructFieldV0, ScSpecUdtStructV0};

/// S holds a and
// TODO: Implement.
Expand All @@ -56,7 +56,7 @@ mod struct_ {

#[test]
fn test_spec() {
let entry = ScSpecEntry::from_xdr(__SPEC_XDR_TYPE_S).unwrap();
let entry = ScSpecEntry::from_xdr(__SPEC_XDR_TYPE_S, Limits::none()).unwrap();
let expect = ScSpecEntry::UdtStructV0(ScSpecUdtStructV0 {
doc: "S holds a and\nb.".try_into().unwrap(),
name: "S".try_into().unwrap(),
Expand Down Expand Up @@ -84,7 +84,7 @@ mod struct_tuple {
use crate as soroban_sdk;
use soroban_sdk::contracttype;
use stellar_xdr::curr as stellar_xdr;
use stellar_xdr::{ReadXdr, ScSpecEntry, ScSpecUdtStructFieldV0, ScSpecUdtStructV0};
use stellar_xdr::{Limits, ReadXdr, ScSpecEntry, ScSpecUdtStructFieldV0, ScSpecUdtStructV0};

/// S holds two u64s.
#[contracttype]
Expand All @@ -98,7 +98,7 @@ mod struct_tuple {

#[test]
fn test_spec() {
let entry = ScSpecEntry::from_xdr(__SPEC_XDR_TYPE_S).unwrap();
let entry = ScSpecEntry::from_xdr(__SPEC_XDR_TYPE_S, Limits::none()).unwrap();
let expect = ScSpecEntry::UdtStructV0(ScSpecUdtStructV0 {
doc: "S holds two u64s.".try_into().unwrap(),
name: "S".try_into().unwrap(),
Expand Down Expand Up @@ -127,7 +127,7 @@ mod enum_ {
use soroban_sdk::contracttype;
use stellar_xdr::curr as stellar_xdr;
use stellar_xdr::{
ReadXdr, ScSpecEntry, ScSpecUdtUnionCaseTupleV0, ScSpecUdtUnionCaseV0,
Limits, ReadXdr, ScSpecEntry, ScSpecUdtUnionCaseTupleV0, ScSpecUdtUnionCaseV0,
ScSpecUdtUnionCaseVoidV0, ScSpecUdtUnionV0,
};

Expand All @@ -145,7 +145,7 @@ mod enum_ {

#[test]
fn test_spec() {
let entry = ScSpecEntry::from_xdr(__SPEC_XDR_TYPE_E).unwrap();
let entry = ScSpecEntry::from_xdr(__SPEC_XDR_TYPE_E, Limits::none()).unwrap();
let expect = ScSpecEntry::UdtUnionV0(ScSpecUdtUnionV0 {
doc: "E has variants A and B.".try_into().unwrap(),
lib: "".try_into().unwrap(),
Expand Down Expand Up @@ -178,7 +178,7 @@ mod enum_int {
use crate as soroban_sdk;
use soroban_sdk::contracttype;
use stellar_xdr::curr as stellar_xdr;
use stellar_xdr::{ReadXdr, ScSpecEntry, ScSpecUdtEnumCaseV0, ScSpecUdtEnumV0};
use stellar_xdr::{Limits, ReadXdr, ScSpecEntry, ScSpecUdtEnumCaseV0, ScSpecUdtEnumV0};

/// E has variants A and B.
#[contracttype]
Expand All @@ -193,7 +193,7 @@ mod enum_int {

#[test]
fn test_spec() {
let entry = ScSpecEntry::from_xdr(__SPEC_XDR_TYPE_E).unwrap();
let entry = ScSpecEntry::from_xdr(__SPEC_XDR_TYPE_E, Limits::none()).unwrap();
let expect = ScSpecEntry::UdtEnumV0(ScSpecUdtEnumV0 {
doc: "E has variants A and B.".try_into().unwrap(),
name: "E".try_into().unwrap(),
Expand Down Expand Up @@ -221,7 +221,9 @@ mod enum_error_int {
use crate as soroban_sdk;
use soroban_sdk::contracterror;
use stellar_xdr::curr as stellar_xdr;
use stellar_xdr::{ReadXdr, ScSpecEntry, ScSpecUdtErrorEnumCaseV0, ScSpecUdtErrorEnumV0};
use stellar_xdr::{
Limits, ReadXdr, ScSpecEntry, ScSpecUdtErrorEnumCaseV0, ScSpecUdtErrorEnumV0,
};

/// E has variants A and B.
#[contracterror]
Expand All @@ -236,7 +238,7 @@ mod enum_error_int {

#[test]
fn test_spec() {
let entry = ScSpecEntry::from_xdr(__SPEC_XDR_TYPE_E).unwrap();
let entry = ScSpecEntry::from_xdr(__SPEC_XDR_TYPE_E, Limits::none()).unwrap();
let expect = ScSpecEntry::UdtErrorEnumV0(ScSpecUdtErrorEnumV0 {
doc: "E has variants A and B.".try_into().unwrap(),
name: "E".try_into().unwrap(),
Expand Down

0 comments on commit 77a760b

Please sign in to comment.