1
0
mirror of https://github.com/oceanprotocol/ocean.js.git synced 2024-11-26 20:39:05 +01:00

Checking if the caller is Publishing Market Fee Address before calling the smart contract

This commit is contained in:
Jamie Hewitt 2022-05-18 17:01:05 +03:00
parent cd8f892d38
commit 4b9f6c9c00
2 changed files with 7 additions and 4 deletions

View File

@ -1362,6 +1362,12 @@ export class Datatoken {
const dtContract = new this.web3.eth.Contract(this.datatokensAbi, datatokenAddress, {
from: address
})
const publishingMarketFeeAddress = (
await dtContract.methods.getPublishingMarketFee().call()
)[0]
if (publishingMarketFeeAddress !== address) {
throw new Error(`Caller is not the Publishing Market Fee Address`)
}
const estGas = await this.estGasSetPublishingMarketFee(
datatokenAddress,
publishMarketFeeAddress,

View File

@ -611,10 +611,7 @@ describe('Datatoken', () => {
)
} catch (e) {
console.log('Message:', e.message)
assert(
e.message ===
'Returned error: VM Exception while processing transaction: revert ERC20Template: not publishMarketFeeAddress'
)
assert(e.message === 'Caller is not the Publishing Market Fee Address')
}
const newPublishingMarketFee = await datatoken.getPublishingMarketFee(
datatokenAddress,