I want to call the mint function:
#[payable]
pub fn buy_nft(&mut self, token_id: String) {
self.tokens.mint(
token_id,
new_owner_id,
Some(token_metadata),
)
}
But the predecessor needs to by owner_id, my owner_id is the contract id on which contract is deployed.
Link
assert_eq!(env::predecessor_account_id(), self.owner_id, "Unauthorized");
When I call this function by say charlie, it gives Uauthorized error:
call!(
charlie,
contract.buy_nft("123".to_owned()),
deposit = to_yocto("10")
).assert_success();
Error:
Smart contract panicked: panicked at 'assertion failed: `(left == right)`
left: `"charlie"`,
right: `"contractname"`: Unauthorized'
How can I call self.token_mint by the contract, through charlie?
Currently the answer is to copy the mint
function from the standard implementation and customize as you see fit.
The better interface will be coming in the future updates.