mirror of
https://github.com/oceanprotocol/ocean.js.git
synced 2024-11-26 20:39:05 +01:00
rename isERC20Deployer to isDatatokenDeployer
This commit is contained in:
parent
8f76167a28
commit
f374230638
@ -185,7 +185,7 @@ export class Datatoken extends SmartContract {
|
||||
fixedRateParams: FreCreationParams
|
||||
): Promise<TransactionReceipt> {
|
||||
const dtContract = this.getContract(dtAddress)
|
||||
if (!(await this.isERC20Deployer(dtAddress, address))) {
|
||||
if (!(await this.isDatatokenDeployer(dtAddress, address))) {
|
||||
throw new Error(`User is not ERC20 Deployer`)
|
||||
}
|
||||
if (!fixedRateParams.allowedConsumer) fixedRateParams.allowedConsumer = ZERO_ADDRESS
|
||||
@ -286,7 +286,7 @@ export class Datatoken extends SmartContract {
|
||||
dispenserAddress: string,
|
||||
dispenserParams: DispenserParams
|
||||
): Promise<TransactionReceipt> {
|
||||
if (!(await this.isERC20Deployer(dtAddress, address))) {
|
||||
if (!(await this.isDatatokenDeployer(dtAddress, address))) {
|
||||
throw new Error(`User is not ERC20 Deployer`)
|
||||
}
|
||||
|
||||
@ -402,7 +402,7 @@ export class Datatoken extends SmartContract {
|
||||
): Promise<TransactionReceipt> {
|
||||
const dtContract = this.getContract(dtAddress)
|
||||
|
||||
if ((await this.isERC20Deployer(dtAddress, address)) !== true) {
|
||||
if ((await this.isDatatokenDeployer(dtAddress, address)) !== true) {
|
||||
throw new Error(`Caller is not ERC20Deployer`)
|
||||
}
|
||||
// Estimate gas cost for addMinter method
|
||||
@ -455,7 +455,7 @@ export class Datatoken extends SmartContract {
|
||||
): Promise<TransactionReceipt> {
|
||||
const dtContract = this.getContract(dtAddress)
|
||||
|
||||
if ((await this.isERC20Deployer(dtAddress, address)) !== true) {
|
||||
if ((await this.isDatatokenDeployer(dtAddress, address)) !== true) {
|
||||
throw new Error(`Caller is not ERC20Deployer`)
|
||||
}
|
||||
|
||||
@ -505,7 +505,7 @@ export class Datatoken extends SmartContract {
|
||||
): Promise<TransactionReceipt> {
|
||||
const dtContract = this.getContract(dtAddress)
|
||||
|
||||
if ((await this.isERC20Deployer(dtAddress, address)) !== true) {
|
||||
if ((await this.isDatatokenDeployer(dtAddress, address)) !== true) {
|
||||
throw new Error(`Caller is not ERC20Deployer`)
|
||||
}
|
||||
|
||||
@ -559,7 +559,7 @@ export class Datatoken extends SmartContract {
|
||||
): Promise<TransactionReceipt> {
|
||||
const dtContract = this.getContract(dtAddress)
|
||||
|
||||
if ((await this.isERC20Deployer(dtAddress, address)) !== true) {
|
||||
if ((await this.isDatatokenDeployer(dtAddress, address)) !== true) {
|
||||
throw new Error(`Caller is not ERC20Deployer`)
|
||||
}
|
||||
|
||||
@ -621,8 +621,8 @@ export class Datatoken extends SmartContract {
|
||||
const isNftOwner = nftAddress && (await this.nft.getNftOwner(nftAddress)) === address
|
||||
const nftPermissions =
|
||||
nftAddress && !isNftOwner && (await this.nft.getNftPermissions(nftAddress, address))
|
||||
const isErc20Deployer = nftPermissions?.deployERC20
|
||||
if (!isPaymentManager && !isNftOwner && !isErc20Deployer) {
|
||||
const isDatatokenDeployer = nftPermissions?.deployERC20
|
||||
if (!isPaymentManager && !isNftOwner && !isDatatokenDeployer) {
|
||||
throw new Error(`Caller is not Fee Manager, owner or erc20 Deployer`)
|
||||
}
|
||||
|
||||
@ -1023,7 +1023,7 @@ export class Datatoken extends SmartContract {
|
||||
address: string,
|
||||
value: string
|
||||
): Promise<TransactionReceipt> {
|
||||
if (!(await this.isERC20Deployer(dtAddress, address))) {
|
||||
if (!(await this.isDatatokenDeployer(dtAddress, address))) {
|
||||
throw new Error(`User is not ERC20 Deployer`)
|
||||
}
|
||||
|
||||
@ -1134,10 +1134,10 @@ export class Datatoken extends SmartContract {
|
||||
* @param {String} dtAddress Datatoken adress
|
||||
* @return {Promise<boolean>}
|
||||
*/
|
||||
public async isERC20Deployer(dtAddress: string, address: string): Promise<boolean> {
|
||||
public async isDatatokenDeployer(dtAddress: string, address: string): Promise<boolean> {
|
||||
const dtContract = this.getContract(dtAddress)
|
||||
const isERC20Deployer = await dtContract.methods.isERC20Deployer(address).call()
|
||||
return isERC20Deployer
|
||||
const isDatatokenDeployer = await dtContract.methods.isERC20Deployer(address).call()
|
||||
return isDatatokenDeployer
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1035,10 +1035,13 @@ export class Nft extends SmartContract {
|
||||
* @param {String} address user adress
|
||||
* @return {Promise<boolean>}
|
||||
*/
|
||||
public async isErc20Deployer(nftAddress: string, address: string): Promise<boolean> {
|
||||
public async isDatatokenDeployer(
|
||||
nftAddress: string,
|
||||
address: string
|
||||
): Promise<boolean> {
|
||||
const nftContract = this.getContract(nftAddress)
|
||||
const isERC20Deployer = await nftContract.methods.isERC20Deployer(address).call()
|
||||
return isERC20Deployer
|
||||
const isDatatokenDeployer = await nftContract.methods.isERC20Deployer(address).call()
|
||||
return isDatatokenDeployer
|
||||
}
|
||||
|
||||
/** Gets data at a given `key`
|
||||
|
@ -103,7 +103,7 @@ describe('Datatoken', () => {
|
||||
})
|
||||
|
||||
it('#addMinter - should add user1 as minter, if user has ERC20Deployer permission', async () => {
|
||||
assert((await nftDatatoken.isErc20Deployer(nftAddress, nftOwner)) === true)
|
||||
assert((await nftDatatoken.isDatatokenDeployer(nftAddress, nftOwner)) === true)
|
||||
assert((await datatoken.getDTPermissions(datatokenAddress, user1)).minter === false)
|
||||
|
||||
await datatoken.addMinter(datatokenAddress, nftOwner, user1)
|
||||
@ -112,7 +112,7 @@ describe('Datatoken', () => {
|
||||
})
|
||||
|
||||
it('#addMinter - should FAIL TO add user1 as minter, if user has ERC20Deployer permission', async () => {
|
||||
assert((await nftDatatoken.isErc20Deployer(nftAddress, user3)) === false)
|
||||
assert((await nftDatatoken.isDatatokenDeployer(nftAddress, user3)) === false)
|
||||
assert((await datatoken.getDTPermissions(datatokenAddress, user2)).minter === false)
|
||||
|
||||
try {
|
||||
@ -140,7 +140,7 @@ describe('Datatoken', () => {
|
||||
})
|
||||
|
||||
it('#createFixedRate - should FAIL create FRE if NOT ERC20Deployer', async () => {
|
||||
assert((await nftDatatoken.isErc20Deployer(nftAddress, user3)) === false)
|
||||
assert((await nftDatatoken.isDatatokenDeployer(nftAddress, user3)) === false)
|
||||
try {
|
||||
await datatoken.createFixedRate(datatokenAddress, user3, freParams)
|
||||
assert(false)
|
||||
@ -169,7 +169,7 @@ describe('Datatoken', () => {
|
||||
maxTokens: '10',
|
||||
maxBalance: '100'
|
||||
}
|
||||
assert((await nftDatatoken.isErc20Deployer(nftAddress, user3)) === false)
|
||||
assert((await nftDatatoken.isDatatokenDeployer(nftAddress, user3)) === false)
|
||||
try {
|
||||
await datatoken.createDispenser(
|
||||
datatokenAddress,
|
||||
@ -184,7 +184,7 @@ describe('Datatoken', () => {
|
||||
})
|
||||
|
||||
it('#removeMinter - should FAIL to remove user1 as minter, if caller is NOT ERC20Deployer', async () => {
|
||||
assert((await nftDatatoken.isErc20Deployer(nftAddress, user2)) === false)
|
||||
assert((await nftDatatoken.isDatatokenDeployer(nftAddress, user2)) === false)
|
||||
assert((await datatoken.getDTPermissions(datatokenAddress, user1)).minter === true)
|
||||
|
||||
try {
|
||||
@ -197,7 +197,7 @@ describe('Datatoken', () => {
|
||||
})
|
||||
|
||||
it('#removeMinter - should remove user1 as minter, if nftDatatoken has ERC20Deployer permission', async () => {
|
||||
assert((await nftDatatoken.isErc20Deployer(nftAddress, nftOwner)) === true)
|
||||
assert((await nftDatatoken.isDatatokenDeployer(nftAddress, nftOwner)) === true)
|
||||
assert((await datatoken.getDTPermissions(datatokenAddress, user1)).minter === true)
|
||||
|
||||
await datatoken.removeMinter(datatokenAddress, nftOwner, user1)
|
||||
@ -206,7 +206,7 @@ describe('Datatoken', () => {
|
||||
})
|
||||
|
||||
it('#addPaymentManager - should FAIL TO add user2 as paymentManager, if caller is NOT ERC20Deployer', async () => {
|
||||
assert((await nftDatatoken.isErc20Deployer(nftAddress, user1)) === false)
|
||||
assert((await nftDatatoken.isDatatokenDeployer(nftAddress, user1)) === false)
|
||||
assert(
|
||||
(await datatoken.getDTPermissions(datatokenAddress, user2)).paymentManager === false
|
||||
)
|
||||
@ -223,7 +223,7 @@ describe('Datatoken', () => {
|
||||
})
|
||||
|
||||
it('#addPaymentManager - should add user2 as paymentManager, if caller has ERC20Deployer permission', async () => {
|
||||
assert((await nftDatatoken.isErc20Deployer(nftAddress, nftOwner)) === true)
|
||||
assert((await nftDatatoken.isDatatokenDeployer(nftAddress, nftOwner)) === true)
|
||||
assert(
|
||||
(await datatoken.getDTPermissions(datatokenAddress, user2)).paymentManager === false
|
||||
)
|
||||
@ -236,7 +236,7 @@ describe('Datatoken', () => {
|
||||
})
|
||||
|
||||
it('#removePaymentManager - should FAIL TO remove user2 as paymentManager, if nftDatatoken has ERC20Deployer permission', async () => {
|
||||
assert((await nftDatatoken.isErc20Deployer(nftAddress, user1)) === false)
|
||||
assert((await nftDatatoken.isDatatokenDeployer(nftAddress, user1)) === false)
|
||||
assert(
|
||||
(await datatoken.getDTPermissions(datatokenAddress, user2)).paymentManager === true
|
||||
)
|
||||
@ -253,7 +253,7 @@ describe('Datatoken', () => {
|
||||
})
|
||||
|
||||
it('#removePaymentManager - should remove user2 as paymentManager, if Caller has ERC20Deployer permission', async () => {
|
||||
assert((await nftDatatoken.isErc20Deployer(nftAddress, nftOwner)) === true)
|
||||
assert((await nftDatatoken.isDatatokenDeployer(nftAddress, nftOwner)) === true)
|
||||
assert(
|
||||
(await datatoken.getDTPermissions(datatokenAddress, user2)).paymentManager === true
|
||||
)
|
||||
@ -549,7 +549,7 @@ describe('Datatoken', () => {
|
||||
it('#setData - should set a value into 725Y standard, if Caller has ERC20Deployer permission', async () => {
|
||||
const data = web3.utils.asciiToHex('SomeData')
|
||||
|
||||
assert((await nftDatatoken.isErc20Deployer(nftAddress, nftOwner)) === true)
|
||||
assert((await nftDatatoken.isDatatokenDeployer(nftAddress, nftOwner)) === true)
|
||||
|
||||
await datatoken.setData(datatokenAddress, nftOwner, data)
|
||||
|
||||
@ -560,7 +560,7 @@ describe('Datatoken', () => {
|
||||
it('#setData - should FAIL to set a value into 725Y standard, if Caller has NOT ERC20Deployer permission', async () => {
|
||||
const data = web3.utils.asciiToHex('NewData')
|
||||
const OldData = web3.utils.asciiToHex('SomeData')
|
||||
assert((await nftDatatoken.isErc20Deployer(nftAddress, user1)) === false)
|
||||
assert((await nftDatatoken.isDatatokenDeployer(nftAddress, user1)) === false)
|
||||
|
||||
try {
|
||||
await datatoken.setData(datatokenAddress, user1, data)
|
||||
|
@ -125,11 +125,11 @@ describe('NFT', () => {
|
||||
|
||||
// ERC20Deployer
|
||||
it('#addERC20Deployer -should add ERC20deployer if Manager', async () => {
|
||||
assert((await nftDatatoken.isErc20Deployer(nftAddress, user1)) === false)
|
||||
assert((await nftDatatoken.isDatatokenDeployer(nftAddress, user1)) === false)
|
||||
|
||||
await nftDatatoken.addErc20Deployer(nftAddress, nftOwner, user1)
|
||||
|
||||
assert((await nftDatatoken.isErc20Deployer(nftAddress, user1)) === true)
|
||||
assert((await nftDatatoken.isDatatokenDeployer(nftAddress, user1)) === true)
|
||||
})
|
||||
|
||||
it('#addERC20Deployer - should fail to add ERC20deployer if NOT Manager', async () => {
|
||||
@ -142,34 +142,34 @@ describe('NFT', () => {
|
||||
})
|
||||
|
||||
it('#removeERC20Deployer - remove ERC20deployer if Manager', async () => {
|
||||
assert((await nftDatatoken.isErc20Deployer(nftAddress, user1)) === true)
|
||||
assert((await nftDatatoken.isDatatokenDeployer(nftAddress, user1)) === true)
|
||||
|
||||
await nftDatatoken.removeErc20Deployer(nftAddress, nftOwner, user1)
|
||||
|
||||
assert((await nftDatatoken.isErc20Deployer(nftAddress, user1)) === false)
|
||||
assert((await nftDatatoken.isDatatokenDeployer(nftAddress, user1)) === false)
|
||||
})
|
||||
|
||||
it('#removeERC20Deployer - should fail and remove ERC20deployer if NOT Manager nor himself an ERC20Deployer', async () => {
|
||||
await nftDatatoken.addErc20Deployer(nftAddress, nftOwner, user1)
|
||||
assert((await nftDatatoken.isErc20Deployer(nftAddress, user1)) === true)
|
||||
assert((await nftDatatoken.isDatatokenDeployer(nftAddress, user1)) === true)
|
||||
try {
|
||||
await nftDatatoken.removeErc20Deployer(nftAddress, user1, user1)
|
||||
assert(false)
|
||||
} catch (e) {
|
||||
assert(e.message === 'Caller is not Manager nor ERC20Deployer')
|
||||
}
|
||||
assert((await nftDatatoken.isErc20Deployer(nftAddress, user1)) === true)
|
||||
assert((await nftDatatoken.isDatatokenDeployer(nftAddress, user1)) === true)
|
||||
})
|
||||
|
||||
it('#removeERC20Deployer - should fail to remove himself as an ERC20Deployer', async () => {
|
||||
assert((await nftDatatoken.isErc20Deployer(nftAddress, user1)) === true)
|
||||
assert((await nftDatatoken.isDatatokenDeployer(nftAddress, user1)) === true)
|
||||
try {
|
||||
await nftDatatoken.removeErc20Deployer(nftAddress, user1, user1)
|
||||
assert(false)
|
||||
} catch (e) {
|
||||
assert(e.message === 'Caller is not Manager nor ERC20Deployer')
|
||||
}
|
||||
assert((await nftDatatoken.isErc20Deployer(nftAddress, user1)) === true)
|
||||
assert((await nftDatatoken.isDatatokenDeployer(nftAddress, user1)) === true)
|
||||
})
|
||||
|
||||
// MetadataUpdate
|
||||
@ -265,14 +265,14 @@ describe('NFT', () => {
|
||||
it('#transferNFT - should transfer the NFT and clean all permissions, set new owner as manager', async () => {
|
||||
await nftDatatoken.addManager(nftAddress, nftOwner, user2)
|
||||
await nftDatatoken.addErc20Deployer(nftAddress, user2, user1)
|
||||
assert((await nftDatatoken.isErc20Deployer(nftAddress, user1)) === true)
|
||||
assert((await nftDatatoken.isDatatokenDeployer(nftAddress, user1)) === true)
|
||||
|
||||
assert((await nftDatatoken.getNftOwner(nftAddress)) === nftOwner)
|
||||
await nftDatatoken.transferNft(nftAddress, nftOwner, user1, 1)
|
||||
assert((await nftDatatoken.getNftOwner(nftAddress)) === user1)
|
||||
|
||||
assert((await nftDatatoken.isErc20Deployer(nftAddress, nftOwner)) === false)
|
||||
assert((await nftDatatoken.isErc20Deployer(nftAddress, user2)) === false)
|
||||
assert((await nftDatatoken.isDatatokenDeployer(nftAddress, nftOwner)) === false)
|
||||
assert((await nftDatatoken.isDatatokenDeployer(nftAddress, user2)) === false)
|
||||
})
|
||||
|
||||
// Safe transfer test
|
||||
@ -293,7 +293,7 @@ describe('NFT', () => {
|
||||
it('#safeTransferNft - should transfer the NFT and clean all permissions, set new owner as manager', async () => {
|
||||
await nftDatatoken.addManager(nftAddress, nftOwner, user2)
|
||||
await nftDatatoken.addErc20Deployer(nftAddress, user2, user1)
|
||||
assert((await nftDatatoken.isErc20Deployer(nftAddress, user1)) === true)
|
||||
assert((await nftDatatoken.isDatatokenDeployer(nftAddress, user1)) === true)
|
||||
|
||||
assert((await nftDatatoken.getNftOwner(nftAddress)) === nftOwner)
|
||||
await nftDatatoken.safeTransferNft(nftAddress, nftOwner, user1, 1)
|
||||
@ -313,11 +313,11 @@ describe('NFT', () => {
|
||||
it('#cleanPermissions - should cleanPermissions if NFTOwner', async () => {
|
||||
await nftDatatoken.addManager(nftAddress, user1, user1)
|
||||
await nftDatatoken.addErc20Deployer(nftAddress, user1, user2)
|
||||
assert((await nftDatatoken.isErc20Deployer(nftAddress, user2)) === true)
|
||||
assert((await nftDatatoken.isDatatokenDeployer(nftAddress, user2)) === true)
|
||||
|
||||
await nftDatatoken.cleanPermissions(nftAddress, user1)
|
||||
|
||||
assert((await nftDatatoken.isErc20Deployer(nftAddress, user2)) === false)
|
||||
assert((await nftDatatoken.isDatatokenDeployer(nftAddress, user2)) === false)
|
||||
assert((await nftDatatoken.getNftPermissions(nftAddress, nftOwner)).manager === false)
|
||||
})
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user