mirror of
https://github.com/oceanprotocol/ocean.js.git
synced 2024-11-26 20:39:05 +01:00
use getContract() in Datatoken
This commit is contained in:
parent
674e971075
commit
b6a9002bce
@ -1147,9 +1147,7 @@ export class Datatoken extends SmartContract {
|
|||||||
* @return {Promise<String>} balance Number of datatokens. Will be converted from wei
|
* @return {Promise<String>} balance Number of datatokens. Will be converted from wei
|
||||||
*/
|
*/
|
||||||
public async balance(datatokenAddress: string, address: string): Promise<string> {
|
public async balance(datatokenAddress: string, address: string): Promise<string> {
|
||||||
const dtContract = new this.web3.eth.Contract(this.abi, datatokenAddress, {
|
const dtContract = this.getContract(datatokenAddress, address)
|
||||||
from: address
|
|
||||||
})
|
|
||||||
const balance = await dtContract.methods.balanceOf(address).call()
|
const balance = await dtContract.methods.balanceOf(address).call()
|
||||||
return this.web3.utils.fromWei(balance)
|
return this.web3.utils.fromWei(balance)
|
||||||
}
|
}
|
||||||
@ -1171,9 +1169,7 @@ export class Datatoken extends SmartContract {
|
|||||||
address: string
|
address: string
|
||||||
): Promise<number> {
|
): Promise<number> {
|
||||||
// Estimate gas cost for publishMarketFeeAddress method
|
// Estimate gas cost for publishMarketFeeAddress method
|
||||||
const dtContract = new this.web3.eth.Contract(this.abi, datatokenAddress, {
|
const dtContract = this.getContract(datatokenAddress, address)
|
||||||
from: address
|
|
||||||
})
|
|
||||||
return estimateGas(
|
return estimateGas(
|
||||||
address,
|
address,
|
||||||
dtContract.methods.setPublishingMarketFee,
|
dtContract.methods.setPublishingMarketFee,
|
||||||
@ -1200,9 +1196,7 @@ export class Datatoken extends SmartContract {
|
|||||||
publishMarketFeeAmount: string,
|
publishMarketFeeAmount: string,
|
||||||
address: string
|
address: string
|
||||||
) {
|
) {
|
||||||
const dtContract = new this.web3.eth.Contract(this.abi, datatokenAddress, {
|
const dtContract = this.getContract(datatokenAddress, address)
|
||||||
from: address
|
|
||||||
})
|
|
||||||
const mktFeeAddress = (await dtContract.methods.getPublishingMarketFee().call())[0]
|
const mktFeeAddress = (await dtContract.methods.getPublishingMarketFee().call())[0]
|
||||||
if (mktFeeAddress !== address) {
|
if (mktFeeAddress !== address) {
|
||||||
throw new Error(`Caller is not the Publishing Market Fee Address`)
|
throw new Error(`Caller is not the Publishing Market Fee Address`)
|
||||||
@ -1239,9 +1233,7 @@ export class Datatoken extends SmartContract {
|
|||||||
datatokenAddress: string,
|
datatokenAddress: string,
|
||||||
address: string
|
address: string
|
||||||
): Promise<PublishingMarketFee> {
|
): Promise<PublishingMarketFee> {
|
||||||
const dtContract = new this.web3.eth.Contract(this.abi, datatokenAddress, {
|
const dtContract = this.getContract(datatokenAddress, address)
|
||||||
from: address
|
|
||||||
})
|
|
||||||
|
|
||||||
const publishingMarketFee = await dtContract.methods.getPublishingMarketFee().call()
|
const publishingMarketFee = await dtContract.methods.getPublishingMarketFee().call()
|
||||||
const returnValues = {
|
const returnValues = {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user