Skip to content

Commit

Permalink
fixes the deprecated fns in the contracts
Browse files Browse the repository at this point in the history
  • Loading branch information
gangov committed Nov 21, 2024
1 parent c27fb82 commit a6fd644
Show file tree
Hide file tree
Showing 7 changed files with 10 additions and 18 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
SUBDIRS := contracts/token contracts/collections contracts/deployer contracts/auctions
SUBDIRS := contracts/token contracts/collections contracts/deployer
BUILD_FLAGS ?=

default: build
Expand Down
6 changes: 1 addition & 5 deletions contracts/collections/src/contract.rs
Original file line number Diff line number Diff line change
Expand Up @@ -589,7 +589,6 @@ impl Collections {
}

#[allow(dead_code)]
#[cfg(not(tarpaulin_include))]
pub fn upgrade(env: Env, new_wasm_hash: BytesN<32>) -> Result<(), ContractError> {
let admin: Address = get_admin(&env)?;
admin.require_auth();
Expand All @@ -599,14 +598,11 @@ impl Collections {
Ok(())
}

#[cfg(test)]
#[allow(dead_code)]
pub fn show_admin(env: &Env) -> Result<Address, ContractError> {
let maybe_admin = crate::storage::utils::get_admin(env)?;
Ok(maybe_admin)
}
#[cfg(test)]
#[allow(dead_code)]

pub fn show_config(env: &Env) -> Result<Config, ContractError> {
let mabye_config = crate::storage::utils::get_config(env)?;
Ok(mabye_config)
Expand Down
2 changes: 0 additions & 2 deletions contracts/collections/src/storage.rs
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,6 @@ pub mod utils {
}

#[allow(dead_code)]
#[cfg(not(tarpaulin_include))]
pub fn get_config(env: &Env) -> Result<Config, ContractError> {
let config = env
.storage()
Expand All @@ -121,7 +120,6 @@ pub mod utils {
Ok(())
}

#[cfg(not(tarpaulin_include))]
pub fn get_admin(env: &Env) -> Result<Address, ContractError> {
let admin = env
.storage()
Expand Down
2 changes: 1 addition & 1 deletion contracts/collections/src/test/setup.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ pub fn initialize_collection_contract<'a>(
name: Option<&String>,
symbol: Option<&String>,
) -> CollectionsClient<'a> {
let collections = CollectionsClient::new(env, &env.register_contract(None, Collections {}));
let collections = CollectionsClient::new(env, &env.register(Collections, ()));

let alt_admin = &Address::generate(env);
let alt_name = &String::from_str(env, "Stellar kitties");
Expand Down
2 changes: 1 addition & 1 deletion contracts/collections/src/test/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ fn initialization_should_fail_when_done_twice() {
let name = &String::from_str(&env, "Stellar kitties");
let symbol = &String::from_str(&env, "STK");

let collections = CollectionsClient::new(&env, &env.register_contract(None, Collections {}));
let collections = CollectionsClient::new(&env, &env.register(Collections, ()));

collections.initialize(&admin, name, symbol);

Expand Down
6 changes: 3 additions & 3 deletions contracts/deployer/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
#![no_std]

use soroban_sdk::{
contract, contracterror, contractimpl, contractmeta, contracttype, log, vec, Address, BytesN,
Env, IntoVal, String, Symbol, Val, Vec,
contract, contractimpl, contractmeta, contracttype, log, vec, Address, BytesN, Env, IntoVal,
String, Symbol, Val, Vec,
};

// Values used to extend the TTL of storage
Expand Down Expand Up @@ -51,7 +51,7 @@ impl CollectionsDeployer {
let deployed_collection = env
.deployer()
.with_address(admin.clone(), salt)
.deploy(collections_wasm_hash);
.deploy_v2(collections_wasm_hash, ());

let init_fn = Symbol::new(&env, "initialize");
let init_fn_args: Vec<Val> = vec![
Expand Down
8 changes: 3 additions & 5 deletions contracts/deployer/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,7 @@ mod collections {
#[test]
fn test_deploy_collection_from_contract() {
let env = Env::default();
let client =
CollectionsDeployerClient::new(&env, &env.register_contract(None, CollectionsDeployer));
let client = CollectionsDeployerClient::new(&env, &env.register(CollectionsDeployer, ()));

// Upload the Wasm to be deployed from the deployer contract.
// This can also be called from within a contract if needed.
Expand Down Expand Up @@ -47,8 +46,7 @@ fn test_deploy_multiple_collections() {
let env = Env::default();
env.mock_all_auths();

let client =
CollectionsDeployerClient::new(&env, &env.register_contract(None, CollectionsDeployer));
let client = CollectionsDeployerClient::new(&env, &env.register(CollectionsDeployer, ()));

// Upload the Wasm to be deployed from the deployer contract.
// This can also be called from within a contract if needed.
Expand Down Expand Up @@ -134,7 +132,7 @@ fn test_deploy_multiple_collections() {
fn initialize_twice() {
let env = Env::default();
let deployer_client =
CollectionsDeployerClient::new(&env, &env.register_contract(None, CollectionsDeployer));
CollectionsDeployerClient::new(&env, &env.register(CollectionsDeployer, ()));

let wasm_hash = env.deployer().upload_contract_wasm(collections::WASM);
deployer_client.initialize(&wasm_hash);
Expand Down

0 comments on commit a6fd644

Please sign in to comment.