Skip to content

Commit

Permalink
Merge pull request #399 from icon-project/fix/stellar-external-audit-…
Browse files Browse the repository at this point in the history
…issues

fix: stellar external audit issues
  • Loading branch information
gcranju authored Nov 12, 2024
2 parents 9c03a0b + de9a293 commit 0f712e0
Show file tree
Hide file tree
Showing 25 changed files with 841 additions and 93 deletions.
6 changes: 1 addition & 5 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
[workspace]
members = [
"contracts/cosmwasm-vm/*",
"contracts/soroban/contracts/*",
"contracts/soroban/libs/*"
"contracts/cosmwasm-vm/*"
]

[workspace.package]
Expand Down Expand Up @@ -38,8 +36,6 @@ cw-common={ git="https://github.com/icon-project/IBC-Integration.git", branch =
cw-mock-dapp = {path="contracts/cosmwasm-vm/cw-mock-dapp"}
cw-mock-dapp-multi = { path="contracts/cosmwasm-vm/cw-mock-dapp-multi"}

soroban-sdk = "21.6.0"

[profile.release]
opt-level = 'z'
debug = false
Expand Down
91 changes: 59 additions & 32 deletions contracts/soroban/Cargo.lock

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

2 changes: 1 addition & 1 deletion contracts/soroban/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ members = [
]

[workspace.dependencies]
soroban-sdk = "20.5.0"
soroban-sdk = "21.7.4"

[profile.release]
opt-level = "z"
Expand Down
2 changes: 2 additions & 0 deletions contracts/soroban/contracts/centralized-connection/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ doctest = false

[dependencies]
soroban-sdk = { workspace = true, features = ["alloc"] }
xcall = { path = "../xcall" }
soroban-xcall-lib = { path = "../../libs/soroban-xcall-lib" }

[dev-dependencies]
soroban-sdk = { workspace = true, features = ["testutils"] }
Original file line number Diff line number Diff line change
Expand Up @@ -125,11 +125,13 @@ impl CentralizedConnection {
helpers::ensure_upgrade_authority(&env)?;
env.deployer().update_current_contract_wasm(new_wasm_hash);

let current_version = storage::get_contract_version(&env);
storage::set_contract_version(&env, current_version + 1);

Ok(())
}

pub fn extend_instance_storage(env: Env) -> Result<(), ContractError> {
storage::extend_instance(&env);
Ok(())
pub fn version(env: Env) -> u32 {
storage::get_contract_version(&env)
}
}
20 changes: 13 additions & 7 deletions contracts/soroban/contracts/centralized-connection/src/storage.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,13 +50,6 @@ pub fn native_token(e: &Env) -> Result<Address, ContractError> {
.ok_or(ContractError::Uninitialized)
}

pub fn get_conn_sn(e: &Env) -> Result<u128, ContractError> {
e.storage()
.instance()
.get(&StorageKey::ConnSn)
.ok_or(ContractError::Uninitialized)
}

pub fn get_next_conn_sn(e: &Env) -> u128 {
let mut sn = e.storage().instance().get(&StorageKey::ConnSn).unwrap_or(0);
sn += 1;
Expand Down Expand Up @@ -103,6 +96,19 @@ pub fn get_sn_receipt(e: &Env, network_id: String, sn: u128) -> bool {
is_received
}

pub fn get_contract_version(e: &Env) -> u32 {
e.storage()
.instance()
.get(&StorageKey::Version)
.unwrap_or(1)
}

pub fn set_contract_version(e: &Env, new_version: u32) {
e.storage()
.instance()
.set(&StorageKey::Version, &new_version);
}

pub fn store_receipt(e: &Env, network_id: String, sn: u128) {
let key = StorageKey::Receipts(network_id, sn);
e.storage().persistent().set(&key, &true);
Expand Down
Loading

0 comments on commit 0f712e0

Please sign in to comment.