Skip to content

Commit

Permalink
cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
taitruong committed Dec 27, 2023
1 parent 4e2e5e3 commit c70fdbe
Show file tree
Hide file tree
Showing 13 changed files with 90 additions and 123 deletions.
117 changes: 34 additions & 83 deletions Cargo.lock

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

6 changes: 2 additions & 4 deletions contracts/sg-ics721/src/execute.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
use cosmwasm_std::{from_json, to_json_binary, Addr, Binary, Deps, DepsMut, Env, StdResult};
use ics721::{
execute::Ics721Execute, state::CollectionData, utils::get_collection_data,
};
use ics721_types::token_types::{Class};
use ics721::{execute::Ics721Execute, state::CollectionData, utils::get_collection_data};
use ics721_types::token_types::Class;

use sg721_base::msg::{CollectionInfoResponse, QueryMsg};

Expand Down
1 change: 0 additions & 1 deletion packages/ics721-types/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,4 @@ pub enum ValidationError {

#[error("tokenIds, tokenUris, and tokenData must have the same length")]
TokenInfoLenMissmatch {},

}
5 changes: 4 additions & 1 deletion packages/ics721-types/src/ibc.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
use cosmwasm_schema::cw_serde;
use cosmwasm_std::Binary;

use crate::{token_types::{ClassId, TokenId}, error::ValidationError};
use crate::{
error::ValidationError,
token_types::{ClassId, TokenId},
};

#[cw_serde]
#[serde(rename_all = "camelCase")]
Expand Down
9 changes: 6 additions & 3 deletions packages/ics721/src/execute.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,18 @@ use cosmwasm_std::{
from_json, to_json_binary, Addr, Binary, Deps, DepsMut, Empty, Env, IbcMsg, MessageInfo,
Response, StdResult, SubMsg, WasmMsg,
};
use ics721_types::{token_types::{TokenId, Class, ClassId, Token}, ibc::NonFungibleTokenPacketData};
use ics721_types::{
ibc::NonFungibleTokenPacketData,
token_types::{Class, ClassId, Token, TokenId},
};
use serde::{de::DeserializeOwned, Serialize};
use sha2::{Digest, Sha256};

use crate::{
helpers::get_instantiate2_address,
ibc::{
INSTANTIATE_CW721_REPLY_ID,
INSTANTIATE_INCOMING_PROXY_REPLY_ID, INSTANTIATE_OUTGOING_PROXY_REPLY_ID,
INSTANTIATE_CW721_REPLY_ID, INSTANTIATE_INCOMING_PROXY_REPLY_ID,
INSTANTIATE_OUTGOING_PROXY_REPLY_ID,
},
msg::{CallbackMsg, ExecuteMsg, IbcOutgoingMsg, InstantiateMsg, MigrateMsg},
state::{
Expand Down
14 changes: 7 additions & 7 deletions packages/ics721/src/helpers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@ use cosmwasm_std::{
};
use serde::Deserialize;

use crate::{
ibc::ACK_CALLBACK_REPLY_ID,
ContractError,
use crate::{ibc::ACK_CALLBACK_REPLY_ID, ContractError};
use ics721_types::{
ibc::NonFungibleTokenPacketData,
types::{
Ics721AckCallbackMsg, Ics721Callbacks, Ics721Memo, Ics721ReceiveCallbackMsg, Ics721Status,
ReceiverExecuteMsg,
},
};
use ics721_types::{types::{
Ics721AckCallbackMsg, Ics721Callbacks, Ics721Memo, Ics721ReceiveCallbackMsg, Ics721Status,
ReceiverExecuteMsg,
}, ibc::NonFungibleTokenPacketData};

/// Parse the memo field into the type we want
/// Ideally it would be `Ics721Memo` type or any type that extends it
Expand Down
7 changes: 1 addition & 6 deletions packages/ics721/src/ibc_helpers.rs
Original file line number Diff line number Diff line change
@@ -1,13 +1,9 @@
use cosmwasm_std::{
from_json, to_json_binary, Binary, IbcAcknowledgement, IbcChannel, IbcEndpoint, IbcOrder,
};
use ics721_types::ibc::NonFungibleTokenPacketData;
use serde::{Deserialize, Serialize};

use crate::{
ibc::IBC_VERSION,
ContractError,
};
use crate::{ibc::IBC_VERSION, ContractError};

/// Tries to remove the source prefix from a given class_id. If the
/// class_id does not begin with the given prefix, returns
Expand Down Expand Up @@ -124,7 +120,6 @@ pub(crate) fn validate_order_and_version(
#[cfg(test)]
mod tests {
use super::*;
use ics721_types::token_types::{ClassId, TokenId};

#[test]
fn test_pop_source_simple() {
Expand Down
8 changes: 6 additions & 2 deletions packages/ics721/src/ibc_packet_receive.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use zip_optional::Zippable;

use crate::{
helpers::{generate_receive_callback_msg, get_instantiate2_address, get_receive_callback},
ibc::{ACK_AND_DO_NOTHING},
ibc::ACK_AND_DO_NOTHING,
ibc_helpers::{get_endpoint_prefix, try_pop_source_prefix},
msg::{CallbackMsg, ExecuteMsg},
state::{
Expand All @@ -17,7 +17,11 @@ use crate::{
token_types::{VoucherCreation, VoucherRedemption},
ContractError,
};
use ics721_types::{token_types::{Class, ClassId, Token, TokenId}, ibc::NonFungibleTokenPacketData, types::Ics721ReceiveIbcPacketMsg};
use ics721_types::{
ibc::NonFungibleTokenPacketData,
token_types::{Class, ClassId, Token, TokenId},
types::Ics721ReceiveIbcPacketMsg,
};

/// Every incoming token has some associated action.
enum Action {
Expand Down
5 changes: 4 additions & 1 deletion packages/ics721/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,11 @@ pub mod query;
pub mod state;
pub mod token_types;
pub mod utils;
use ics721_types::{token_types::{Class, ClassId, Token, TokenId}, ibc::NonFungibleTokenPacketData};
pub use crate::error::ContractError;
pub use ics721_types::{
ibc::NonFungibleTokenPacketData,
token_types::{Class, ClassId, Token, TokenId},
};

#[cfg(test)]
pub mod testing;
Loading

0 comments on commit c70fdbe

Please sign in to comment.