Skip to content

Commit

Permalink
Merge pull request #15 from octopus-network/fix/view-function-errors
Browse files Browse the repository at this point in the history
Upgrade to v1.0.2
  • Loading branch information
riversyang authored Jan 16, 2024
2 parents c87def7 + 1efb1bc commit 093a5cd
Show file tree
Hide file tree
Showing 25 changed files with 579 additions and 226 deletions.
62 changes: 31 additions & 31 deletions 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 channel-escrow/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "channel-escrow"
version = "0.1.0"
version = "1.0.1"
edition = "2021"

[lib]
Expand Down
25 changes: 24 additions & 1 deletion channel-escrow/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ use utils::{

mod migration;

const VERSION: &str = env!("CARGO_PKG_VERSION");

#[derive(BorshSerialize, BorshStorageKey)]
#[borsh(crate = "near_sdk::borsh")]
pub enum StorageKey {
Expand Down Expand Up @@ -89,6 +91,10 @@ impl Contract {
denom_to_token_contract_map: LookupMap::new(StorageKey::DenomToTokenContractMap),
}
}
///
pub fn version(&self) -> String {
VERSION.to_string()
}
/// Callback function for `ft_transfer_call` of NEP-141 compatible contracts
pub fn ft_on_transfer(
&mut self,
Expand Down Expand Up @@ -197,6 +203,7 @@ impl FtTransferCallback for Contract {

#[near_bindgen]
impl ChannelEscrow for Contract {
//
#[payable]
fn register_asset(&mut self, base_denom: String, token_contract: AccountId) {
self.assert_near_ibc_account();
Expand All @@ -214,7 +221,23 @@ impl ChannelEscrow for Contract {
self.denom_to_token_contract_map
.insert(asset_denom, token_contract);
}

//
fn unregister_asset(&mut self, base_denom: String) {
self.assert_near_ibc_account();
let asset_denom = AssetDenom {
trace_path: String::new(),
base_denom,
};
let maybe_existed_token_contract = self.denom_to_token_contract_map.get(&asset_denom);
assert!(
maybe_existed_token_contract.is_some(),
"ERR_INVALID_TOKEN_DENOM"
);
let token_contract = maybe_existed_token_contract.unwrap();
self.token_contracts.remove(token_contract);
self.denom_to_token_contract_map.remove(&asset_denom);
}
//
#[payable]
fn do_transfer(
&mut self,
Expand Down
Loading

0 comments on commit 093a5cd

Please sign in to comment.