Skip to content

Commit

Permalink
Remove rlib (stellar#166)
Browse files Browse the repository at this point in the history
* remove rlib from single offer and router contracts

* Remove rlib from single_offer_xfer_from

* Remove rlib from liquidity pool and router contracts

* remove token-wasm feature

* Remove unused imports
  • Loading branch information
sisuresh authored Nov 3, 2022
1 parent fa441fc commit 3f0388b
Show file tree
Hide file tree
Showing 10 changed files with 8 additions and 68 deletions.
2 changes: 0 additions & 2 deletions Cargo.lock

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

2 changes: 0 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ all: build test
test: build
cargo test
cargo test --features testutils
cargo test --features token-wasm

build:
cargo build --target wasm32-unknown-unknown --release -p soroban-token-contract
Expand All @@ -21,7 +20,6 @@ build:
test-optimized: build-optimized
cargo test
cargo test --features testutils
cargo test --features token-wasm

build-optimized:
cargo +nightly build --target wasm32-unknown-unknown --release -Z build-std=std,panic_abort -Z build-std-features=panic_immediate_abort -p soroban-token-contract
Expand Down
2 changes: 1 addition & 1 deletion liquidity_pool/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ edition = "2021"
publish = false

[lib]
crate-type = ["cdylib", "rlib"]
crate-type = ["cdylib"]

[features]
token-wasm = []
Expand Down
7 changes: 2 additions & 5 deletions liquidity_pool_router/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ edition = "2021"
publish = false

[lib]
crate-type = ["cdylib", "rlib"]
crate-type = ["cdylib"]

[features]
testutils = ["soroban-sdk/testutils", "soroban-auth/testutils","soroban-liquidity-pool-contract/testutils","dep:ed25519-dalek", "dep:sha2", "dep:stellar-xdr"]
testutils = ["soroban-sdk/testutils", "soroban-auth/testutils" ,"dep:ed25519-dalek", "dep:sha2", "dep:stellar-xdr"]

[dependencies]
soroban-sdk = "0.1.0"
Expand All @@ -17,13 +17,10 @@ ed25519-dalek = { version = "1.0.1", optional = true }
stellar-xdr = { version = "0.0.6", features = ["next", "std"], optional = true }
sha2 = { version = "0.10.2", optional = true }

[target.'cfg(not(target_family="wasm"))'.dependencies]
soroban-liquidity-pool-contract = { path = "../liquidity_pool", version = "0.0.0", default-features = false, optional = true }

[dev_dependencies]
soroban-sdk = { version = "0.1.0", features = ["testutils"] }
soroban-auth = { version = "0.1.0", features = ["testutils"] }
soroban-liquidity-pool-contract = { path = "../liquidity_pool", version = "0.0.0", default-features = false, features = ["testutils"] }
stellar-xdr = { version = "0.0.6", features = ["next", "std"] }
ed25519-dalek = { version = "1.0.1" }
sha2 = { version = "0.10.2" }
Expand Down
24 changes: 0 additions & 24 deletions liquidity_pool_router/src/pool_contract.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,32 +5,8 @@ soroban_sdk::contractimport!(
);
pub type LiquidityPoolClient = Client;

#[cfg(not(all(any(test, feature = "testutils"), not(feature = "token-wasm"))))]
pub fn create_contract(e: &Env, salt: &BytesN<32>) -> BytesN<32> {
use soroban_sdk::Bytes;
let bin = Bytes::from_slice(e, WASM);
e.deployer().with_current_contract(salt).deploy(bin)
}

#[cfg(all(any(test, feature = "testutils"), not(feature = "token-wasm")))]
extern crate std;

#[cfg(all(any(test, feature = "testutils"), not(feature = "token-wasm")))]
pub fn create_contract(e: &Env, salt: &BytesN<32>) -> BytesN<32> {
use sha2::{Digest, Sha256};
use stellar_xdr::{Hash, HashIdPreimage, HashIdPreimageContractId, Uint256, WriteXdr};

use std::vec::Vec;

let contract_id = Hash(e.get_current_contract().into());
let pre_image = HashIdPreimage::ContractIdFromContract(HashIdPreimageContractId {
contract_id,
salt: Uint256(salt.clone().into()),
});
let mut buf = Vec::new();
pre_image.write_xdr(&mut buf).unwrap();
let new_contract_id = Sha256::digest(buf).into();

soroban_liquidity_pool_contract::testutils::register_test_contract(e, &new_contract_id);
BytesN::from_array(e, &new_contract_id)
}
3 changes: 1 addition & 2 deletions liquidity_pool_router/src/test.rs
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
#![cfg(test)]

use crate::pool_contract::LiquidityPoolClient;
use crate::token::{self, TokenMetadata};

use crate::testutils::{
register_test_contract as register_liquidity_pool_router, LiquidityPoolRouter,
};
use liquidity_pool::LiquidityPoolClient;
use rand::{thread_rng, RngCore};
use soroban_auth::{Identifier, Signature};
use soroban_liquidity_pool_contract as liquidity_pool;
use soroban_sdk::{testutils::Accounts, AccountId, BigInt, BytesN, Env, IntoVal};

fn generate_sorted_contract_ids() -> ([u8; 32], [u8; 32]) {
Expand Down
2 changes: 1 addition & 1 deletion single_offer/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ edition = "2021"
publish = false

[lib]
crate-type = ["cdylib", "rlib"]
crate-type = ["cdylib"]

[features]
testutils = ["soroban-sdk/testutils", "soroban-auth/testutils", "dep:ed25519-dalek"]
Expand Down
8 changes: 2 additions & 6 deletions single_offer_router/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ edition = "2021"
publish = false

[lib]
crate-type = ["cdylib", "rlib"]
crate-type = ["cdylib"]

[features]
testutils = ["soroban-sdk/testutils", "soroban-auth/testutils","soroban-single-offer-contract/testutils","dep:ed25519-dalek", "dep:sha2", "dep:stellar-xdr"]
testutils = ["soroban-sdk/testutils", "soroban-auth/testutils","dep:ed25519-dalek", "dep:sha2", "dep:stellar-xdr"]

[dependencies]
soroban-sdk = "0.1.0"
Expand All @@ -17,13 +17,9 @@ ed25519-dalek = { version = "1.0.1", optional = true }
stellar-xdr = { version = "0.0.6", features = ["next", "std"], optional = true }
sha2 = { version = "0.10.2", optional = true }

[target.'cfg(not(target_family="wasm"))'.dependencies]
soroban-single-offer-contract = { path = "../single_offer", version = "0.0.0", default-features = false, optional = true }

[dev_dependencies]
soroban-sdk = { version = "0.1.0", features = ["testutils"] }
soroban-auth = { version = "0.1.0", features = ["testutils"] }
soroban-single-offer-contract = { path = "../single_offer", version = "0.0.0", default-features = false, features = ["testutils"] }
stellar-xdr = { version = "0.0.6", features = ["next", "std"] }
ed25519-dalek = { version = "1.0.1" }
sha2 = { version = "0.10.2" }
Expand Down
24 changes: 0 additions & 24 deletions single_offer_router/src/offer_contract.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,32 +5,8 @@ soroban_sdk::contractimport!(
);
pub type SingleOfferClient = Client;

#[cfg(not(all(any(test, feature = "testutils"), not(feature = "token-wasm"))))]
pub fn create_contract(e: &Env, salt: &BytesN<32>) -> BytesN<32> {
use soroban_sdk::Bytes;
let bin = Bytes::from_slice(e, WASM);
e.deployer().with_current_contract(salt).deploy(bin)
}

#[cfg(all(any(test, feature = "testutils"), not(feature = "token-wasm")))]
extern crate std;

#[cfg(all(any(test, feature = "testutils"), not(feature = "token-wasm")))]
pub fn create_contract(e: &Env, salt: &BytesN<32>) -> BytesN<32> {
use sha2::{Digest, Sha256};
use stellar_xdr::{Hash, HashIdPreimage, HashIdPreimageContractId, Uint256, WriteXdr};

use std::vec::Vec;

let contract_id = Hash(e.get_current_contract().into());
let pre_image = HashIdPreimage::ContractIdFromContract(HashIdPreimageContractId {
contract_id,
salt: Uint256(salt.clone().into()),
});
let mut buf = Vec::new();
pre_image.write_xdr(&mut buf).unwrap();
let new_contract_id = Sha256::digest(buf).into();

soroban_single_offer_contract::testutils::register_test_contract(e, &new_contract_id);
BytesN::from_array(e, &new_contract_id)
}
2 changes: 1 addition & 1 deletion single_offer_xfer_from/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ edition = "2021"
publish = false

[lib]
crate-type = ["cdylib", "rlib"]
crate-type = ["cdylib"]

[features]
testutils = ["soroban-sdk/testutils", "soroban-auth/testutils", "dep:ed25519-dalek"]
Expand Down

0 comments on commit 3f0388b

Please sign in to comment.