diff --git a/contracts/cw721-base/src/contract_tests.rs b/contracts/cw721-base/src/contract_tests.rs index fc64c10b2..2b840249c 100644 --- a/contracts/cw721-base/src/contract_tests.rs +++ b/contracts/cw721-base/src/contract_tests.rs @@ -335,6 +335,26 @@ fn approving_revoking() { .execute(deps.as_mut(), mock_env(), minter, mint_msg) .unwrap(); + // token owner shows in approval query + let res = contract + .approval( + deps.as_ref(), + mock_env(), + token_id.clone(), + String::from("demeter"), + false, + ) + .unwrap(); + assert_eq!( + res, + ApprovalResponse { + approval: Approval { + spender: String::from("demeter"), + expires: Expiration::Never {} + } + } + ); + // Give random transferring power let approve_msg = ExecuteMsg::Approve { spender: String::from("random"), diff --git a/contracts/cw721-base/src/query.rs b/contracts/cw721-base/src/query.rs index 130897d08..885afcd21 100644 --- a/contracts/cw721-base/src/query.rs +++ b/contracts/cw721-base/src/query.rs @@ -90,6 +90,16 @@ where include_expired: bool, ) -> StdResult { let token = self.tokens.load(deps.storage, &token_id)?; + + // token owner has absolute approval + if token.owner == spender { + let approval = cw721::Approval { + spender: token.owner.to_string(), + expires: Expiration::Never {}, + }; + return Ok(ApprovalResponse { approval }); + } + let filtered: Vec<_> = token .approvals .into_iter()