mirror of
https://github.com/oceanprotocol/ocean.js.git
synced 2024-11-26 20:39:05 +01:00
use keccak256 and asciiToHex for key and value
This commit is contained in:
parent
6493688ae5
commit
436e873833
@ -1183,10 +1183,18 @@ export class Nft {
|
|||||||
this.config
|
this.config
|
||||||
)
|
)
|
||||||
|
|
||||||
const estGas = await estimateGas(address, nftContract.methods.setNewData, key, value)
|
const keyHash = this.web3.utils.keccak256(key)
|
||||||
|
const valueHex = this.web3.utils.asciiToHex(value)
|
||||||
|
|
||||||
|
const estGas = await estimateGas(
|
||||||
|
address,
|
||||||
|
nftContract.methods.setNewData,
|
||||||
|
keyHash,
|
||||||
|
valueHex
|
||||||
|
)
|
||||||
|
|
||||||
// Call setData function of the contract
|
// Call setData function of the contract
|
||||||
const trxReceipt = await nftContract.methods.setNewData(key, value).send({
|
const trxReceipt = await nftContract.methods.setNewData(keyHash, valueHex).send({
|
||||||
from: address,
|
from: address,
|
||||||
gas: estGas + 1,
|
gas: estGas + 1,
|
||||||
gasPrice: await getFairGasPrice(this.web3, this.config)
|
gasPrice: await getFairGasPrice(this.web3, this.config)
|
||||||
@ -1258,8 +1266,9 @@ export class Nft {
|
|||||||
new this.web3.eth.Contract(this.nftAbi, nftAddress),
|
new this.web3.eth.Contract(this.nftAbi, nftAddress),
|
||||||
this.config
|
this.config
|
||||||
)
|
)
|
||||||
const data = await nftContract.methods.getData(key).call()
|
const keyHash = this.web3.utils.keccak256(key)
|
||||||
return data
|
const data = await nftContract.methods.getData(keyHash).call()
|
||||||
|
return data ? this.web3.utils.hexToAscii(data) : null
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Gets data at a given `key`
|
/** Gets data at a given `key`
|
||||||
|
Loading…
x
Reference in New Issue
Block a user