mirror of
https://github.com/oceanprotocol/ocean.js.git
synced 2024-11-26 20:39:05 +01:00
add isERC20Deployer fix
This commit is contained in:
parent
a9b95d3c15
commit
5dde9f4da7
@ -7,7 +7,7 @@ import defaultDatatokensAbi from '@oceanprotocol/contracts/artifacts/contracts/t
|
|||||||
import defaultDatatokensEnterpriseAbi from '@oceanprotocol/contracts/artifacts/contracts/templates/ERC20TemplateEnterprise.sol/ERC20TemplateEnterprise.json'
|
import defaultDatatokensEnterpriseAbi from '@oceanprotocol/contracts/artifacts/contracts/templates/ERC20TemplateEnterprise.sol/ERC20TemplateEnterprise.json'
|
||||||
import { LoggerInstance, getFairGasPrice } from '../utils'
|
import { LoggerInstance, getFairGasPrice } from '../utils'
|
||||||
import { FreOrderParams, FreCreationParams } from '../interfaces'
|
import { FreOrderParams, FreCreationParams } from '../interfaces'
|
||||||
|
import { Nft } from "./NFT"
|
||||||
/**
|
/**
|
||||||
* ERC20 ROLES
|
* ERC20 ROLES
|
||||||
*/
|
*/
|
||||||
@ -40,6 +40,7 @@ export class Datatoken {
|
|||||||
public datatokensEnterpriseAbi: AbiItem | AbiItem[]
|
public datatokensEnterpriseAbi: AbiItem | AbiItem[]
|
||||||
public web3: Web3
|
public web3: Web3
|
||||||
public startBlock: number
|
public startBlock: number
|
||||||
|
public nft: Nft
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Instantiate ERC20 DataTokens
|
* Instantiate ERC20 DataTokens
|
||||||
@ -57,6 +58,7 @@ export class Datatoken {
|
|||||||
this.datatokensEnterpriseAbi =
|
this.datatokensEnterpriseAbi =
|
||||||
datatokensEnterpriseAbi || (defaultDatatokensEnterpriseAbi.abi as AbiItem[])
|
datatokensEnterpriseAbi || (defaultDatatokensEnterpriseAbi.abi as AbiItem[])
|
||||||
this.startBlock = startBlock || 0
|
this.startBlock = startBlock || 0
|
||||||
|
this.nft = new Nft(this.web3)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -444,8 +446,9 @@ export class Datatoken {
|
|||||||
): Promise<TransactionReceipt> {
|
): Promise<TransactionReceipt> {
|
||||||
const dtContract = new this.web3.eth.Contract(this.datatokensAbi, dtAddress)
|
const dtContract = new this.web3.eth.Contract(this.datatokensAbi, dtAddress)
|
||||||
|
|
||||||
// should check ERC20Deployer role using erc721 level ..
|
if (await this.isERC20Deployer(dtAddress,address) !== true) {
|
||||||
|
throw new Error(`Caller is not ERC20Deployer`)
|
||||||
|
}
|
||||||
// Estimate gas cost for addMinter method
|
// Estimate gas cost for addMinter method
|
||||||
const estGas = await this.estGasAddMinter(dtAddress, address, minter, dtContract)
|
const estGas = await this.estGasAddMinter(dtAddress, address, minter, dtContract)
|
||||||
|
|
||||||
@ -508,7 +511,9 @@ export class Datatoken {
|
|||||||
): Promise<TransactionReceipt> {
|
): Promise<TransactionReceipt> {
|
||||||
const dtContract = new this.web3.eth.Contract(this.datatokensAbi, dtAddress)
|
const dtContract = new this.web3.eth.Contract(this.datatokensAbi, dtAddress)
|
||||||
|
|
||||||
// should check ERC20Deployer role using erc721 level ..
|
if (await this.isERC20Deployer(dtAddress,address) !== true) {
|
||||||
|
throw new Error(`Caller is not ERC20Deployer`)
|
||||||
|
}
|
||||||
|
|
||||||
const estGas = await this.estGasRemoveMinter(dtAddress, address, minter, dtContract)
|
const estGas = await this.estGasRemoveMinter(dtAddress, address, minter, dtContract)
|
||||||
|
|
||||||
@ -568,7 +573,9 @@ export class Datatoken {
|
|||||||
): Promise<TransactionReceipt> {
|
): Promise<TransactionReceipt> {
|
||||||
const dtContract = new this.web3.eth.Contract(this.datatokensAbi, dtAddress)
|
const dtContract = new this.web3.eth.Contract(this.datatokensAbi, dtAddress)
|
||||||
|
|
||||||
// should check ERC20Deployer role using erc721 level ..
|
if (await this.isERC20Deployer(dtAddress,address) !== true) {
|
||||||
|
throw new Error(`Caller is not ERC20Deployer`)
|
||||||
|
}
|
||||||
|
|
||||||
const estGas = await this.estGasAddPaymentManager(
|
const estGas = await this.estGasAddPaymentManager(
|
||||||
dtAddress,
|
dtAddress,
|
||||||
@ -631,7 +638,10 @@ export class Datatoken {
|
|||||||
): Promise<TransactionReceipt> {
|
): Promise<TransactionReceipt> {
|
||||||
const dtContract = new this.web3.eth.Contract(this.datatokensAbi, dtAddress)
|
const dtContract = new this.web3.eth.Contract(this.datatokensAbi, dtAddress)
|
||||||
|
|
||||||
// should check ERC20Deployer role using erc721 level ..
|
if (await this.isERC20Deployer(dtAddress,address) !== true) {
|
||||||
|
throw new Error(`Caller is not ERC20Deployer`)
|
||||||
|
}
|
||||||
|
|
||||||
const estGas = await this.estGasRemovePaymentManager(
|
const estGas = await this.estGasRemovePaymentManager(
|
||||||
dtAddress,
|
dtAddress,
|
||||||
address,
|
address,
|
||||||
@ -1209,9 +1219,9 @@ export class Datatoken {
|
|||||||
/** Returns true if address has deployERC20 role
|
/** Returns true if address has deployERC20 role
|
||||||
* @param {String} dtAddress Datatoken adress
|
* @param {String} dtAddress Datatoken adress
|
||||||
* @param {String} dtAddress Datatoken adress
|
* @param {String} dtAddress Datatoken adress
|
||||||
* @return {Promise<number>}
|
* @return {Promise<boolean>}
|
||||||
*/
|
*/
|
||||||
public async isERC20Deployer(dtAddress: string, adddress: string): Promise<string> {
|
public async isERC20Deployer(dtAddress: string, adddress: string): Promise<boolean> {
|
||||||
const dtContract = new this.web3.eth.Contract(this.datatokensAbi, dtAddress)
|
const dtContract = new this.web3.eth.Contract(this.datatokensAbi, dtAddress)
|
||||||
const isERC20Deployer = await dtContract.methods.isERC20Deployer(adddress).call()
|
const isERC20Deployer = await dtContract.methods.isERC20Deployer(adddress).call()
|
||||||
return isERC20Deployer
|
return isERC20Deployer
|
||||||
|
Loading…
x
Reference in New Issue
Block a user