fn approve_for(&mut self, to: &AccountId, id: TokenId) -> Result<(), Error> {
            let caller = self.env().caller();
            let owner = self.owner_of(id);
            if !(owner == Some(caller)
                || self.approved_for_all(owner.expect("Error with AccountId"), caller))
            {
                return Err(Error::NotAllowed);
            };
            if *to == AccountId::from([0x0; 32]) {
                return Err(Error::NotAllowed);
            };

            if self.token_approvals.insert(id, *to).is_some() {
                return Err(Error::CannotInsert);
            };
            self.env().emit_event(Approval {
                from: caller,
                to: *to,
                id,
            });
            Ok(())
        }
/// Approve the passed AccountId to transfer the specified token on behalf of the message's sender.
Approve the passed AccountId to transfer the specified token on behalf of the message's sender.
Approve the passed AccountId to transfer the specified token on behalf of the message ' s sender .
fn approve_for(&mut self, to: &AccountId, id: TokenId) -> Result<(), Error> {
            let caller = self.env().caller();
            let owner = self.owner_of(id);
            if !(owner == Some(caller)
                || self.approved_for_all(owner.expect("Error with AccountId"), caller))
            {
                return Err(Error::NotAllowed);
            };
            if *to == AccountId::from([0x0; 32]) {
                return Err(Error::NotAllowed);
            };
            if self.token_approvals.insert(id, *to).is_some() {
                return Err(Error::CannotInsert);
            };
            self.env().emit_event(Approval {
                from: caller,
                to: *to,
                id,
            });
            Ok(())
        }
fn approve_for ( & mut self , to : & AccountId , id : TokenId ) -> Result < ( ) , Error > { let caller = self . env ( ) . caller ( ) ; let owner = self . owner_of ( id ) ; if ! ( owner == Some ( caller ) || self . approved_for_all ( owner . expect ( " " ) , caller ) ) { return Err ( Error :: NotAllowed ) ; } ; if * to == AccountId :: from ( [ 0x0 ; 32 ] ) { return Err ( Error :: NotAllowed ) ; } ; if self . token_approvals . insert ( id , * to ) . is_some ( ) { return Err ( Error :: CannotInsert ) ; } ; self . env ( ) . emit_event ( Approval { from : caller , to : * to , id , } ) ; Ok ( ( ) ) }
Approve the passed AccountId to transfer the specified token on behalf of the message's sender.
Approve the passed AccountId to transfer the specified token on behalf of the message ' s sender .
&mut self
to
&AccountId
id
TokenId
&mut self
to
&AccountId
id
TokenId