Skip to content

Commit

Permalink
Basic SDK update to support auth changes.
Browse files Browse the repository at this point in the history
This just makes code compile and tests pass. There are still some broken parts (account contract) and some missing functionality (new host functions).
  • Loading branch information
dmkozh committed Jun 2, 2023
1 parent 28167ef commit 9265910
Show file tree
Hide file tree
Showing 11 changed files with 210 additions and 167 deletions.
14 changes: 8 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 @@ -36,17 +36,17 @@ soroban-token-sdk = { version = "0.8.4", path = "soroban-token-sdk" }
[workspace.dependencies.soroban-env-common]
version = "0.0.16"
git = "https://github.com/stellar/rs-soroban-env"
rev = "3762edfe52aafc6c0935619211d76d2d05fe87e6"
rev = "d7ceb0a327e19d00faaeca6e6463cb526ca70bbc"

[workspace.dependencies.soroban-env-guest]
version = "0.0.16"
git = "https://github.com/stellar/rs-soroban-env"
rev = "3762edfe52aafc6c0935619211d76d2d05fe87e6"
rev = "d7ceb0a327e19d00faaeca6e6463cb526ca70bbc"

[workspace.dependencies.soroban-env-host]
version = "0.0.16"
git = "https://github.com/stellar/rs-soroban-env"
rev = "3762edfe52aafc6c0935619211d76d2d05fe87e6"
rev = "d7ceb0a327e19d00faaeca6e6463cb526ca70bbc"

[workspace.dependencies.stellar-strkey]
version = "0.0.7"
Expand All @@ -55,7 +55,7 @@ git = "https://github.com/stellar/rs-stellar-strkey"
[workspace.dependencies.stellar-xdr]
version = "0.0.16"
git = "https://github.com/stellar/rs-stellar-xdr"
rev = "b283ec0bcb791610013107b9eab7d7ff07a65db1"
rev = "a2f370c930bb94f7bc0c9ea0426ecef3700b90a9"
default-features = false

#[patch."https://github.com/stellar/rs-soroban-env"]
Expand Down
4 changes: 2 additions & 2 deletions soroban-sdk-macros/src/derive_client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ pub fn derive_client(crate_path: &Path, ty: &str, name: &str, fns: &[syn_ext::Fn
_phantom: core::marker::PhantomData<&'a ()>,
#[doc(hidden)]
#[cfg(any(test, feature = "testutils"))]
set_auths: Option<&'a [#crate_path::xdr::ContractAuth]>,
set_auths: Option<&'a [#crate_path::xdr::SorobanAuthorizationEntry]>,
#[doc(hidden)]
#[cfg(any(test, feature = "testutils"))]
mock_auths: Option<&'a [#crate_path::testutils::MockAuth<'a>]>,
Expand Down Expand Up @@ -160,7 +160,7 @@ pub fn derive_client(crate_path: &Path, ty: &str, name: &str, fns: &[syn_ext::Fn
///
/// See `soroban_sdk::Env::set_auths` for more details and examples.
#[cfg(any(test, feature = "testutils"))]
pub fn set_auths(&self, auths: &'a [#crate_path::xdr::ContractAuth]) -> Self {
pub fn set_auths(&self, auths: &'a [#crate_path::xdr::SorobanAuthorizationEntry]) -> Self {
Self {
env: self.env.clone(),
address: self.address.clone(),
Expand Down
15 changes: 8 additions & 7 deletions soroban-sdk/src/deploy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,21 +21,22 @@
//! # pub fn f(env: Env, wasm_hash: BytesN<32>) {
//! # let salt = [0u8; 32];
//! let deployer = env.deployer().with_current_contract(&salt);
//! let contract_id = deployer.deploy(&wasm_hash);
//! let contract_address = deployer.deploy(&wasm_hash);
//! # }
//! # }
//! #
//! # #[cfg(feature = "testutils")]
//! # fn main() {
//! # let env = Env::default();
//! # let contract_id = env.register_contract(None, Contract);
//! # let contract_address = env.register_contract(None, Contract);
//! # // Install the contract code before deploying its instance.
//! # let wasm_hash = env.install_contract_wasm(&[0u8; 100]);
//! # ContractClient::new(&env, &contract_id).f(&wasm_hash);
//! # ContractClient::new(&env, &contract_address).f(&wasm_hash);
//! # }
//! # #[cfg(not(feature = "testutils"))]
//! # fn main() { }
//! ```
use crate::{env::internal::Env as _, unwrap::UnwrapInfallible, Address, BytesN, Env, IntoVal};

/// Deployer provides access to deploying contracts.
Expand Down Expand Up @@ -104,14 +105,14 @@ impl DeployerWithCurrentContract {
/// Returns the deployed contract's ID.
pub fn deploy(&self, wasm_hash: &impl IntoVal<Env, BytesN<32>>) -> Address {
let env = &self.env;
let id = env
.create_contract_from_contract(
let address_obj = env
.create_contract(
env.current_contract_address().to_object(),
wasm_hash.into_val(env).to_object(),
self.salt.to_object(),
)
.unwrap_infallible();
let id = unsafe { BytesN::<32>::unchecked_new(env.clone(), id) };
Address::from_contract_id(&id)
unsafe { Address::unchecked_new(env.clone(), address_obj) }
}
}

Expand Down
Loading

0 comments on commit 9265910

Please sign in to comment.