Skip to content

Bug: Error on transferring name token by token operator #15

@Volodymyr-Kuchinskyi

Description

@Volodymyr-Kuchinskyi

Problem:
When transferring name token by token/contract level operator, we receive an error

here is an example transaction - https://testnet.cspr.live/deploy/e1d2e4b384d3cef0e63eddb2a4355c5ce6963eafa8fcee0d250b363b4ac1f238

447a7c9 - this commit does not seem to resolve the issue because we have both checks:

  1. The caller has an admin role
  2. The caller is the token owner (which should still fail in our case)

If the name token is a caller and has an admin role, we should probably process with the next check:

pub fn cleanup(&mut self, token_id: TokenId) {
        let env = self.env();
        let caller = env.caller();

        if !self.has_role(&DEFAULT_ADMIN_ROLE, &caller) {
            self.env().revert(ResolverError::UnauthorizedCleanup);
        }

        let owner = self.owner_of(token_id);

        if owner != Some(caller) || !self.approved_for(token_id) != Some(caller) || !self.is_approved_for_all(owner, caller) {
            self.env().revert(ResolverError::UnauthorizedCleanup);
        }

        self.nonces.add(&token_id, 1);

        env.emit_event(ResolutionCleared { token_id });
}

if we could just simply process with a cleanup

pub fn cleanup(&mut self, token_id: TokenId) {
        let env = self.env();
        let caller = env.caller();

        if !self.has_role(&DEFAULT_ADMIN_ROLE, &caller) || self.owner_of(token_id) != Some(caller) {
            self.env().revert(ResolverError::UnauthorizedCleanup);
        }

        self.nonces.add(&token_id, 1);

        env.emit_event(ResolutionCleared { token_id });
}

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions