I wrote a smart contract, implementing a psp34 token (docs). Inside the smart contract, it is no problem using the methods provided by openbrush. However, when I deploy it on chain and want to call a method (like for example owner_of), using the pokadot{.js} api, I run into the following problem:
When looking at the metadata of my contract, a typical method looks like this:
{
"args": [
{
"label": "id",
"type": {
"displayName": [
"Vec"
],
"type": 7
}
}
],
"docs": [
" Returns the owner of a token."
],
"label": "owner_of",
"mutates": false,
"payable": false,
"returnType": {
"displayName": [
"Option"
],
"type": 24
},
"selector": "..."
},
But a method from the openbrush looks like this:
{
"args": [
{
"label": "id",
"type": {
"displayName": [
"psp34_external",
"OwnerOfInput1"
],
"type": 1
}
}
],
"docs": [
" Returns the owner of the token if any."
],
"label": "PSP34::owner_of",
"mutates": false,
"payable": false,
"returnType": {
"displayName": [
"psp34_external",
"OwnerOfOutput"
],
"type": 24
},
"selector": "..."
}
From my understanding the polkadot api changes the label from 'owner_of' to 'ownerOf'. But what does it to 'PSP34::owner_of'?
I tried to call the original PSP34 owner_of method like this:
const { gasRequired, storageDeposit, result, output } = await contract.query.ownerOf(
accountId,
{
gasLimit,
storageDepositLimit,
},
id
)
But it does gives the error 'ownerOf is not a function'. My solution so far was to just implement a method in my contract which calls on the PSP34 owner_of method, and to then call this new method with the API.
Although this works, it strikes me as not pretty. Especially, since the original PSP34 owner_of method is still visible on chain.
My question now is: Is it possible to call the PSP34::owner_of method with the polkadot api? And if not, how can I overwrite the method so only the method in my contract is visible to the chain and I can call it with the polkadot api like before.