Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

implement cw721 methods #2

Merged
merged 4 commits into from
Jul 2, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
allow convert string error to Contract error
  • Loading branch information
tubackkhoa committed Jul 1, 2024
commit 019fdee67d30187cf7348d0abfafadcd99704ad4
2 changes: 1 addition & 1 deletion contracts/oraiswap-v3/src/entrypoints/common.rs
Original file line number Diff line number Diff line change
Expand Up @@ -457,7 +457,7 @@ pub fn transfer_nft(
) -> Result<Position, ContractError> {
let owner_raw = &token_id[..token_id.len() - 4];
let index = u32::from_be_bytes(token_id[token_id.len() - 4..].try_into().unwrap());
let account_id = Addr::unchecked(String::from_utf8(owner_raw.to_vec()).unwrap());
let account_id = Addr::unchecked(String::from_utf8(owner_raw.to_vec())?);
let mut pos = state::get_position_by_key(deps.storage, token_id)?;
// ensure we have permissions
check_can_send(deps.as_ref(), env, info, owner_raw, &pos)?;
Expand Down
6 changes: 2 additions & 4 deletions contracts/oraiswap-v3/src/entrypoints/query.rs
Original file line number Diff line number Diff line change
Expand Up @@ -400,8 +400,7 @@ pub fn query_owner_of(
token_id: Binary,
include_expired: bool,
) -> Result<OwnerOfResponse, ContractError> {
let owner =
Addr::unchecked(String::from_utf8(token_id[..token_id.len() - 4].to_vec()).unwrap());
let owner = Addr::unchecked(String::from_utf8(token_id[..token_id.len() - 4].to_vec())?);
let pos = state::get_position_by_key(deps.storage, &token_id)?;
Ok(OwnerOfResponse {
owner,
Expand Down Expand Up @@ -448,8 +447,7 @@ pub fn query_all_nft_info(
token_id: Binary,
include_expired: bool,
) -> Result<AllNftInfoResponse, ContractError> {
let owner =
Addr::unchecked(String::from_utf8(token_id[..token_id.len() - 4].to_vec()).unwrap());
let owner = Addr::unchecked(String::from_utf8(token_id[..token_id.len() - 4].to_vec())?);
let pos = state::get_position_by_key(deps.storage, &token_id)?;
Ok(AllNftInfoResponse {
access: OwnerOfResponse {
Expand Down
5 changes: 5 additions & 0 deletions contracts/oraiswap-v3/src/error.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
use std::string::FromUtf8Error;

use cosmwasm_std::{StdError, Uint128};
use thiserror::Error;

Expand All @@ -6,6 +8,9 @@ pub enum ContractError {
#[error("{0}")]
Std(#[from] StdError),

#[error("{0}")]
FromUtf8(#[from] FromUtf8Error),

#[error("invalid tick spacing")]
InvalidTickSpacing,

Expand Down