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

Adapt to recent changes in env #1098

Merged
merged 1 commit into from
Sep 25, 2023
Merged
Show file tree
Hide file tree
Changes from all 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
12 changes: 6 additions & 6 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 @@ -42,17 +42,17 @@ 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 = "44cba6a72cd2cca9594de492298eea1a7ed0e031"
rev = "511337e0fc1f38cc0aaefe3616d39dcdf3e05ccb"

[workspace.dependencies.soroban-env-guest]
version = "20.0.0-rc2"
git = "https://github.com/stellar/rs-soroban-env"
rev = "44cba6a72cd2cca9594de492298eea1a7ed0e031"
rev = "511337e0fc1f38cc0aaefe3616d39dcdf3e05ccb"

[workspace.dependencies.soroban-env-host]
version = "20.0.0-rc2"
git = "https://github.com/stellar/rs-soroban-env"
rev = "44cba6a72cd2cca9594de492298eea1a7ed0e031"
rev = "511337e0fc1f38cc0aaefe3616d39dcdf3e05ccb"

[workspace.dependencies.stellar-strkey]
version = "0.0.7"
Expand All @@ -62,7 +62,7 @@ rev = "e6ba45c60c16de28c7522586b80ed0150157df73"
[workspace.dependencies.stellar-xdr]
version = "20.0.0-rc1"
git = "https://github.com/stellar/rs-stellar-xdr"
rev = "d5ce0c9e7aa83461773a6e81662067f35d39e4c1"
rev = "c9d24eb4fae1f9968f6620e06750c1fce7a5d6c3"
default-features = false
features = ["curr"]

Expand Down
1 change: 1 addition & 0 deletions soroban-sdk-macros/src/derive_enum.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ use proc_macro2::{Literal, TokenStream as TokenStream2};
use quote::{format_ident, quote};
use syn::{spanned::Spanned, Attribute, DataEnum, Error, Fields, Ident, Path, Visibility};

use stellar_xdr::curr as stellar_xdr;
use stellar_xdr::{
Error as XdrError, ScSpecEntry, ScSpecTypeDef, ScSpecUdtUnionCaseTupleV0, ScSpecUdtUnionCaseV0,
ScSpecUdtUnionCaseVoidV0, ScSpecUdtUnionV0, StringM, VecM, WriteXdr, SCSYMBOL_LIMIT,
Expand Down
1 change: 1 addition & 0 deletions soroban-sdk-macros/src/derive_enum_int.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
use itertools::MultiUnzip;
use proc_macro2::TokenStream as TokenStream2;
use quote::{format_ident, quote};
use stellar_xdr::curr as stellar_xdr;
use stellar_xdr::{ScSpecUdtEnumV0, StringM};
use syn::{spanned::Spanned, Attribute, DataEnum, Error, ExprLit, Ident, Lit, Path, Visibility};

Expand Down
1 change: 1 addition & 0 deletions soroban-sdk-macros/src/derive_error_enum_int.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
use itertools::MultiUnzip;
use proc_macro2::TokenStream as TokenStream2;
use quote::{format_ident, quote};
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};

Expand Down
1 change: 1 addition & 0 deletions soroban-sdk-macros/src/derive_spec_fn.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
use proc_macro2::TokenStream as TokenStream2;
use quote::{format_ident, quote};
use stellar_xdr::curr as stellar_xdr;
use stellar_xdr::{
ScSpecEntry, ScSpecFunctionInputV0, ScSpecFunctionV0, ScSpecTypeDef, ScSymbol, StringM, VecM,
WriteXdr, SCSYMBOL_LIMIT,
Expand Down
1 change: 1 addition & 0 deletions soroban-sdk-macros/src/derive_struct.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ use proc_macro2::{Literal, TokenStream as TokenStream2};
use quote::{format_ident, quote};
use syn::{Attribute, DataStruct, Error, Ident, Path, Visibility};

use stellar_xdr::curr as stellar_xdr;
use stellar_xdr::{
ScSpecEntry, ScSpecTypeDef, ScSpecUdtStructFieldV0, ScSpecUdtStructV0, StringM, WriteXdr,
SCSYMBOL_LIMIT,
Expand Down
1 change: 1 addition & 0 deletions soroban-sdk-macros/src/derive_struct_tuple.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ use proc_macro2::{Literal, TokenStream as TokenStream2};
use quote::{format_ident, quote};
use syn::{Attribute, DataStruct, Error, Ident, Path, Visibility};

use stellar_xdr::curr as stellar_xdr;
use stellar_xdr::{
ScSpecEntry, ScSpecTypeDef, ScSpecUdtStructFieldV0, ScSpecUdtStructV0, StringM, WriteXdr,
};
Expand Down
1 change: 1 addition & 0 deletions soroban-sdk-macros/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ 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 soroban_env_common::Symbol;
Expand Down
1 change: 1 addition & 0 deletions soroban-sdk-macros/src/map_type.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
use stellar_xdr::curr as stellar_xdr;
use stellar_xdr::{
ScSpecTypeBytesN, ScSpecTypeDef, ScSpecTypeMap, ScSpecTypeOption, ScSpecTypeResult,
ScSpecTypeTuple, ScSpecTypeUdt, ScSpecTypeVec,
Expand Down
51 changes: 0 additions & 51 deletions soroban-sdk/src/env.rs
Original file line number Diff line number Diff line change
Expand Up @@ -328,57 +328,6 @@ impl Env {
internal::Env::require_auth(self, address.to_object()).unwrap_infallible();
}

/// Returns the contract call stack as a [`Vec`]
/// of `(contract_id, function_name)`.
///
/// ### Examples
/// ```
/// use soroban_sdk::{contract, contractimpl, log, Env, Symbol};
///
/// #[contract]
/// pub struct Contract;
///
/// #[contractimpl]
/// impl Contract {
/// pub fn hello(env: Env) {
/// let stack = env.call_stack();
/// assert_eq!(stack.len(), 1);
///
/// let outer = stack.get_unchecked(0);
/// log!(&env, "{}", outer);
/// }
/// }
/// #[test]
/// fn test() {
/// # }
/// # #[cfg(feature = "testutils")]
/// # fn main() {
/// let env = Env::default();
/// let contract_id = env.register_contract(None, Contract);
/// let client = ContractClient::new(&env, &contract_id);
/// client.hello();
/// }
/// # #[cfg(not(feature = "testutils"))]
/// # fn main() { }
/// ```
pub fn call_stack(&self) -> Vec<(Address, crate::Symbol)> {
// TODO: Change host fn to return Addresses, so that contracts do not
// need to iterate over the call stack and do conversion.
let stack = internal::Env::get_current_call_stack(self).unwrap_infallible();

let stack =
unsafe { Vec::<(AddressObject, crate::Symbol)>::unchecked_new(self.clone(), stack) };

let mut stack_with_addresses = Vec::new(self);
for (ao, sym) in stack.iter() {
unsafe {
stack_with_addresses.push_back((Address::unchecked_new(self.clone(), ao), sym))
};
}

stack_with_addresses
}

/// Invokes a function of a contract that is registered in the [Env].
///
/// # Panics
Expand Down
1 change: 0 additions & 1 deletion soroban-sdk/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ mod auth;
mod budget;
mod contract_add_i32;
mod contract_assert;
mod contract_call_stack;
mod contract_docs;
mod contract_invoke;
mod contract_overlapping_type_fn_names;
Expand Down
1 change: 1 addition & 0 deletions soroban-sdk/src/tests/contract_add_i32.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
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};

#[contract]
Expand Down
69 changes: 0 additions & 69 deletions soroban-sdk/src/tests/contract_call_stack.rs

This file was deleted.

6 changes: 6 additions & 0 deletions soroban-sdk/src/tests/contract_docs.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,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};

#[contract]
Expand Down Expand Up @@ -38,6 +39,7 @@ mod fn_ {
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};

/// S holds a and
Expand Down Expand Up @@ -81,6 +83,7 @@ mod struct_ {
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};

/// S holds two u64s.
Expand Down Expand Up @@ -122,6 +125,7 @@ mod struct_tuple {
mod enum_ {
use crate as soroban_sdk;
use soroban_sdk::contracttype;
use stellar_xdr::curr as stellar_xdr;
use stellar_xdr::{
ReadXdr, ScSpecEntry, ScSpecUdtUnionCaseTupleV0, ScSpecUdtUnionCaseV0,
ScSpecUdtUnionCaseVoidV0, ScSpecUdtUnionV0,
Expand Down Expand Up @@ -173,6 +177,7 @@ mod enum_ {
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};

/// E has variants A and B.
Expand Down Expand Up @@ -215,6 +220,7 @@ mod enum_int {
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};

/// E has variants A and B.
Expand Down
2 changes: 1 addition & 1 deletion soroban-sdk/src/tests/contract_invoke.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ fn test_try_invoke() {
assert_eq!(
res,
Err(Ok(soroban_sdk::Error::from_type_and_code(
ScErrorType::WasmVm,
ScErrorType::Context,
ScErrorCode::InvalidAction
)))
);
Expand Down
1 change: 1 addition & 0 deletions soroban-sdk/src/tests/contract_udt_struct.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ use crate as soroban_sdk;
use soroban_sdk::{
contract, contractimpl, contracttype, map, symbol_short, ConversionError, Env, TryFromVal,
};
use stellar_xdr::curr as stellar_xdr;
use stellar_xdr::{
ReadXdr, ScSpecEntry, ScSpecFunctionInputV0, ScSpecFunctionV0, ScSpecTypeDef, ScSpecTypeTuple,
ScSpecTypeUdt,
Expand Down
1 change: 1 addition & 0 deletions soroban-sdk/src/tests/contract_udt_struct_tuple.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ use soroban_sdk::{
contract, contractimpl, contracttype, vec, ConversionError, Env, IntoVal, TryFromVal,
TryIntoVal, Val, Vec,
};
use stellar_xdr::curr as stellar_xdr;
use stellar_xdr::{
ReadXdr, ScSpecEntry, ScSpecFunctionInputV0, ScSpecFunctionV0, ScSpecTypeDef, ScSpecTypeTuple,
ScSpecTypeUdt,
Expand Down
1 change: 1 addition & 0 deletions soroban-sdk/src/tests/contractimport.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
use crate as soroban_sdk;
use soroban_sdk::{contract, contractimpl, Address, BytesN, Env};
use stellar_xdr::curr as stellar_xdr;
use stellar_xdr::{ScSpecEntry, ScSpecFunctionInputV0, ScSpecFunctionV0, ScSpecTypeDef};

mod addcontract {
Expand Down
1 change: 1 addition & 0 deletions soroban-sdk/src/tests/token_spec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ use soroban_sdk::{
token::{StellarAssetSpec, SPEC_XDR_INPUT, SPEC_XDR_LEN},
xdr::{Error, ReadXdr, ScSpecEntry},
};
use stellar_xdr::curr as stellar_xdr;
use stellar_xdr::DepthLimitedRead;

extern crate std;
Expand Down
3 changes: 2 additions & 1 deletion soroban-spec-rust/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ use std::{fs, io};
use proc_macro2::TokenStream;
use quote::quote;
use sha2::{Digest, Sha256};
use stellar_xdr::{self, ScSpecEntry};
use stellar_xdr::curr as stellar_xdr;
use stellar_xdr::ScSpecEntry;
use syn::Error;

use soroban_spec::read::{from_wasm, FromWasmError};
Expand Down
1 change: 1 addition & 0 deletions soroban-spec-rust/src/trait.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
use proc_macro2::TokenStream;
use quote::{format_ident, quote};
use stellar_xdr::curr as stellar_xdr;
use stellar_xdr::ScSpecFunctionV0;

use super::types::generate_type_ident;
Expand Down
1 change: 1 addition & 0 deletions soroban-spec-rust/src/types.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
use proc_macro2::{Literal, TokenStream};
use quote::{format_ident, quote};
use stellar_xdr::curr as stellar_xdr;
use stellar_xdr::{
ScSpecTypeDef, ScSpecUdtEnumV0, ScSpecUdtErrorEnumV0, ScSpecUdtStructV0, ScSpecUdtUnionV0,
};
Expand Down
Loading