Skip to content

Commit

Permalink
Merge pull request #64 from balancednetwork/fix/remove-icon-address-r…
Browse files Browse the repository at this point in the history
…equirements

fix: Allow deposits to be to any networkAddress
  • Loading branch information
ibrizsabin authored May 30, 2024
2 parents 0dc3649 + 5df3a57 commit 74be3a5
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 28 deletions.
12 changes: 12 additions & 0 deletions .github/workflows/Basic.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ jobs:

- name: Install Rust
run: rustup update stable

- name: Lock Rust Version
run: rustup override set nightly-2023-03-27

- name: Cache Rust dependencies
uses: Swatinem/rust-cache@v2
Expand All @@ -49,6 +52,15 @@ jobs:

- name: Install Rust
run: rustup update stable

- name: Lock Rust Version
run: rustup override set nightly-2023-03-27

- name: Install cargo-fmt
run: rustup component add --toolchain nightly-2023-03-27-x86_64-unknown-linux-gnu rustfmt

- name: Install clippy
run: rustup component add --toolchain nightly-2023-03-27-x86_64-unknown-linux-gnu clippy

- name: Cache Rust dependencies
uses: Swatinem/rust-cache@v2
Expand Down
3 changes: 3 additions & 0 deletions .github/workflows/cw-codecov.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ jobs:

- name: Install Rust
run: rustup update stable

- name: Lock Rust Version
run: rustup override set nightly-2023-03-27

- name: Cache Rust dependencies
uses: Swatinem/rust-cache@v2
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/deploy-cw-contracts.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ jobs:

- name: Install cw-check
run: |
cargo install cosmwasm-check --locked
cargo install cosmwasm-check@1.4.1 --locked
- name: Compile WASM
run: |
Expand Down
31 changes: 7 additions & 24 deletions contracts/core-contracts/cw-asset-manager/src/contract.rs
Original file line number Diff line number Diff line change
Expand Up @@ -135,13 +135,7 @@ pub fn execute(
);

let recipient: NetworkAddress = match to {
Some(to_address) => {
let nw_addr = NetworkAddress::from_str(&to_address).unwrap();
if !nw_addr.validate_foreign_addresses() {
return Err(ContractError::InvalidRecipientAddress);
}
nw_addr
}
Some(to_address) => NetworkAddress::from_str(&to_address).unwrap(),
// if `to` is not provided, sender address is used as recipient
None => depositor,
};
Expand Down Expand Up @@ -175,13 +169,7 @@ pub fn execute(
ensure!(!amount.is_zero(), ContractError::InvalidAmount);

let recipient: NetworkAddress = match to {
Some(to_address) => {
let nw_addr = NetworkAddress::from_str(&to_address).unwrap();
if !nw_addr.validate_foreign_addresses() {
return Err(ContractError::InvalidRecipientAddress);
}
nw_addr
}
Some(to_address) => NetworkAddress::from_str(&to_address).unwrap(),
// if `to` is not provided, sender address is used as recipient
None => depositor,
};
Expand Down Expand Up @@ -924,7 +912,7 @@ mod tests {
};
let info = mock_info("user", &[funds, fee]);

let response = execute(deps.as_mut(), env.clone(), info.clone(), msg).unwrap();
let response = execute(deps.as_mut(), env, info, msg).unwrap();
// Verify the response contains the expected sub-messages
assert_eq!(response.messages.len(), 1);

Expand Down Expand Up @@ -962,7 +950,7 @@ mod tests {
};
let info = mock_info("user", &[funds]);

let response = execute(deps.as_mut(), env.clone(), info.clone(), msg).unwrap();
let response = execute(deps.as_mut(), env, info, msg).unwrap();
// Verify the response contains the expected sub-messages
assert_eq!(response.messages.len(), 1);

Expand Down Expand Up @@ -1096,12 +1084,7 @@ mod tests {
data: withdraw_msg.rlp_bytes().to_vec(),
protocols: None,
};
let resp = execute(
deps.as_mut(),
env.clone(),
mocked_xcall_info.clone(),
exe_msg,
);
let resp = execute(deps.as_mut(), env, mocked_xcall_info, exe_msg);
assert!(resp.is_ok());
}

Expand All @@ -1118,9 +1101,9 @@ mod tests {
period: 100,
percentage: 9000,
};
let mock_info = mock_info(&owner.to_string(), &[]);
let mock_info = mock_info(owner.as_ref(), &[]);

let resp = execute(deps.as_mut(), env.clone(), mock_info.clone(), exe_msg);
let resp = execute(deps.as_mut(), env.clone(), mock_info, exe_msg);
assert!(resp.is_ok());

deps.querier.update_balance(
Expand Down
3 changes: 0 additions & 3 deletions contracts/token-contracts/cw-hub-bnusd/src/contract.rs
Original file line number Diff line number Diff line change
Expand Up @@ -295,9 +295,6 @@ mod execute {
amount: u128,
data: Vec<u8>,
) -> Result<Response, ContractError> {
if !to.validate_foreign_addresses() {
return Err(ContractError::InvalidNetworkAddress);
}
ensure!(amount > 0, ContractError::InvalidAmount);

let funds = info.funds.clone();
Expand Down
4 changes: 4 additions & 0 deletions toolchain.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
[toolchain]
channel = "nightly-2023-03-27"
components = [ "rustfmt", "rustc-dev","cargo-fmt" ]
targets = [ "wasm32-unknown-unknown"]

0 comments on commit 74be3a5

Please sign in to comment.