mirror of
https://github.com/oceanprotocol/ocean.js.git
synced 2024-11-26 20:39:05 +01:00
add getTokenURI, add test
This commit is contained in:
parent
39ded52003
commit
4826cafba3
@ -1166,4 +1166,15 @@ export class Nft {
|
||||
const data = await nftContract.methods.getData(key).call()
|
||||
return data
|
||||
}
|
||||
|
||||
/** Gets data at a given `key`
|
||||
* @param {String} nftAddress erc721 contract adress
|
||||
* @param {String} id
|
||||
* @return {Promise<string>} The data stored at the key
|
||||
*/
|
||||
public async getTokenURI(nftAddress: string, id: number): Promise<string> {
|
||||
const nftContract = new this.web3.eth.Contract(this.nftAbi, nftAddress)
|
||||
const data = await nftContract.methods.tokenURI(id).call()
|
||||
return data
|
||||
}
|
||||
}
|
||||
|
@ -78,6 +78,13 @@ describe('NFT', () => {
|
||||
|
||||
nftAddress = await nftFactory.createNFT(nftOwner, nftData)
|
||||
nftDatatoken = new Nft(web3, ERC721Template.abi as AbiItem[])
|
||||
|
||||
})
|
||||
it('#getTokenURI', async ()=> {
|
||||
const tokenURI = await nftDatatoken.getTokenURI(nftAddress,1)
|
||||
assert(tokenURI === 'https://oceanprotocol.com/nft/'
|
||||
)
|
||||
console.log(tokenURI)
|
||||
})
|
||||
|
||||
it('#createERC20 - should create a new ERC20 DT from NFT contract', async () => {
|
||||
|
Loading…
x
Reference in New Issue
Block a user