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

Audit revision v2 #87

Closed
Closed
Changes from 1 commit
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
04fd6a8
new CW721_ADMIN store
taitruong Jan 21, 2024
5016c3a
use latest optimizer version
taitruong Jan 21, 2024
b5c4acb
rename CW721_ADMIN > ADMIN_USED_FOR_CW721
taitruong Jan 22, 2024
09da354
Merge pull request #81 from arkprotocol/cw721_admin
taitruong Jan 23, 2024
fb52da8
test backtransfer to banned recipient, but also to to regular recpient
taitruong Jan 25, 2024
be897b8
e2e ts relayer test:
taitruong Jan 26, 2024
ae6c7d3
fix back transfer, remove entries in outgoing channel only in case al…
taitruong Jan 26, 2024
2afbce7
rename
taitruong Jan 26, 2024
6357673
simplify receive_ibc_packet(), create sub message directly, remove ac…
taitruong Jan 27, 2024
f903de4
fix move to sub message for saving incoming channel entries
taitruong Jan 27, 2024
f43f9c0
move to dedicated functions
taitruong Jan 27, 2024
31ab7b5
docs
taitruong Jan 27, 2024
dec10c1
cleanup
taitruong Jan 27, 2024
94557a5
cargo schema
taitruong Jan 28, 2024
c5a6548
2 new admin msgs for fixing forked NFTs
taitruong Jan 29, 2024
80995ed
docs
taitruong Jan 29, 2024
dc32c5f
test admin msgs
taitruong Jan 29, 2024
545909f
cargo schema
taitruong Jan 29, 2024
1d96023
Merge pull request #83 from arkprotocol/fix_back_transfer
taitruong Jan 31, 2024
2da4752
rename
taitruong Feb 1, 2024
5059fc0
pass nft contract, instead of overriding info.sender
taitruong Jan 22, 2024
d6d6383
remove NFT_CONTRACT_TO_CLASS_ID and CLASS_ID_TO_NFT_CONTRACT and merg…
taitruong Jan 23, 2024
36e0567
test migration
taitruong Jan 23, 2024
86537cb
migrate only in case CLASS_ID_AND_NFT_CONTRACT_INFO is not populated …
taitruong Feb 1, 2024
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
pass nft contract, instead of overriding info.sender
taitruong committed Feb 1, 2024
commit 5059fc0e6831a6005fb7dcc0ee80295f46904984
43 changes: 18 additions & 25 deletions packages/ics721/src/execute.rs
Original file line number Diff line number Diff line change
@@ -297,30 +297,23 @@ where
}
from_json::<IbcOutgoingProxyMsg>(msg.clone())
.ok()
.map(|msg| {
let mut info = info;
match deps.api.addr_validate(&msg.collection) {
Ok(collection_addr) => {
// set collection address as (initial) sender
info.sender = collection_addr;
self.receive_nft(
deps,
env,
info,
TokenId::new(token_id),
nft_owner,
msg.msg,
)
}
Err(err) => Err(ContractError::Std(err)),
}
.map(|msg| match deps.api.addr_validate(&msg.collection) {
Ok(nft_contract) => self.receive_nft(
deps,
env,
&nft_contract,
TokenId::new(token_id),
nft_owner,
msg.msg,
),
Err(err) => Err(ContractError::Std(err)),
})
}
None => from_json::<IbcOutgoingMsg>(msg.clone()).ok().map(|_| {
self.receive_nft(
deps,
env,
info,
&info.sender,
TokenId::new(token_id),
nft_owner,
msg.clone(),
@@ -336,32 +329,32 @@ where
&self,
deps: DepsMut,
env: Env,
info: MessageInfo,
nft_contract: &Addr,
token_id: TokenId,
nft_owner: String,
msg: Binary,
) -> Result<Response<T>, ContractError> {
let nft_owner = deps.api.addr_validate(&nft_owner)?;
let msg: IbcOutgoingMsg = from_json(msg)?;

let class = match NFT_CONTRACT_TO_CLASS_ID.may_load(deps.storage, info.sender.clone())? {
let class = match NFT_CONTRACT_TO_CLASS_ID.may_load(deps.storage, nft_contract.clone())? {
Some(class_id) => CLASS_ID_TO_CLASS.load(deps.storage, class_id)?,
// No class ID being present means that this is a local NFT
// that has never been sent out of this contract.
None => {
let class_data = self.get_class_data(&deps, &info.sender)?;
let class_data = self.get_class_data(&deps, nft_contract)?;
let data = class_data.as_ref().map(to_json_binary).transpose()?;
let class = Class {
id: ClassId::new(info.sender.to_string()),
id: ClassId::new(nft_contract.to_string()),
// There is no collection-level uri nor data in the
// cw721 specification so we set those values to
// `None` for local, cw721 NFTs.
uri: None,
data,
};

NFT_CONTRACT_TO_CLASS_ID.save(deps.storage, info.sender.clone(), &class.id)?;
CLASS_ID_TO_NFT_CONTRACT.save(deps.storage, class.id.clone(), &info.sender)?;
NFT_CONTRACT_TO_CLASS_ID.save(deps.storage, nft_contract.clone(), &class.id)?;
CLASS_ID_TO_NFT_CONTRACT.save(deps.storage, class.id.clone(), nft_contract)?;

// Merging and usage of this PR may change that:
// <https://github.com/CosmWasm/cw-nfts/pull/75>
@@ -372,7 +365,7 @@ where

// make sure NFT is escrowed by ics721
let UniversalAllNftInfoResponse { access, info } = deps.querier.query_wasm_smart(
info.sender,
nft_contract,
&cw721::Cw721QueryMsg::AllNftInfo {
token_id: token_id.clone().into(),
include_expired: None,
8 changes: 4 additions & 4 deletions packages/ics721/src/testing/contract.rs
Original file line number Diff line number Diff line change
@@ -221,7 +221,7 @@ fn test_receive_nft() {
.receive_nft(
deps.as_mut(),
env,
info,
&info.sender,
TokenId::new(token_id),
sender.clone(),
msg,
@@ -302,7 +302,7 @@ fn test_receive_nft() {
.receive_nft(
deps.as_mut(),
env,
info,
&info.sender,
TokenId::new(token_id),
sender.clone(),
msg,
@@ -383,7 +383,7 @@ fn test_receive_nft() {
.receive_nft(
deps.as_mut(),
env,
info,
&info.sender,
TokenId::new(token_id),
sender.clone(),
msg,
@@ -454,7 +454,7 @@ fn test_receive_sets_uri() {
.unwrap();

Ics721Contract {}
.receive_nft(deps.as_mut(), env, info, token_id, sender, msg)
.receive_nft(deps.as_mut(), env, &info.sender, token_id, sender, msg)
.unwrap();

let class = CLASS_ID_TO_CLASS