mirror of
https://github.com/oceanprotocol/ocean.js.git
synced 2024-11-26 20:39:05 +01:00
Merge pull request #1506 from oceanprotocol/issue-1474-refactoring-rename-from-erc721-to-nft
Issue-#1474: Refactoring (7): Rename from erc721 to nft
This commit is contained in:
commit
641ddfc19e
@ -13,7 +13,7 @@ export interface DDO {
|
||||
|
||||
/**
|
||||
* DID, descentralized ID.
|
||||
* Computed as sha256(address of ERC721 contract + chainId)
|
||||
* Computed as sha256(address of NFT contract + chainId)
|
||||
* @type {string}
|
||||
*/
|
||||
id: string
|
||||
|
@ -8,9 +8,9 @@ export * from './Compute'
|
||||
export * from './Dispenser'
|
||||
export * from './DownloadResponse'
|
||||
export * from './Erc20'
|
||||
export * from './Erc721'
|
||||
export * from './FileMetadata'
|
||||
export * from './FixedPrice'
|
||||
export * from './NFT'
|
||||
export * from './NFTFactory'
|
||||
export * from './Pool'
|
||||
export * from './Provider'
|
||||
|
@ -42,13 +42,7 @@ export class Config {
|
||||
* Factory address
|
||||
* @type {string}
|
||||
*/
|
||||
public erc721FactoryAddress?: string
|
||||
|
||||
/**
|
||||
* Factory ABI
|
||||
* @type {string}
|
||||
*/
|
||||
public erc721FFactoryABI?: AbiItem | AbiItem[]
|
||||
public nftFactoryAddress?: string
|
||||
|
||||
/**
|
||||
* datatokens ABI
|
||||
|
@ -161,7 +161,7 @@ export class ConfigHelper {
|
||||
startBlock
|
||||
} = customAddresses[network]
|
||||
configAddresses = {
|
||||
erc721FactoryAddress: ERC721Factory,
|
||||
nftFactoryAddress: ERC721Factory,
|
||||
sideStakingAddress: Staking,
|
||||
opfCommunityFeeCollector: OPFCommunityFeeCollector,
|
||||
poolTemplateAddress: poolTemplate,
|
||||
@ -191,7 +191,7 @@ export class ConfigHelper {
|
||||
startBlock
|
||||
} = DefaultContractsAddresses[network]
|
||||
configAddresses = {
|
||||
erc721FactoryAddress: ERC721Factory,
|
||||
nftFactoryAddress: ERC721Factory,
|
||||
sideStakingAddress: Staking,
|
||||
opfCommunityFeeCollector: OPFCommunityFeeCollector,
|
||||
poolTemplateAddress: poolTemplate,
|
||||
|
@ -208,7 +208,7 @@ export class NftFactory extends SmartContractWithAddress {
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a new erc721 token template - only factory Owner
|
||||
* Add a new NFT token template - only factory Owner
|
||||
* @param {String} address
|
||||
* @param {String} templateAddress template address to add
|
||||
* @return {Promise<TransactionReceipt>}
|
||||
@ -367,7 +367,7 @@ export class NftFactory extends SmartContractWithAddress {
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a new erc721 token template - only factory Owner
|
||||
* Add a new NFT token template - only factory Owner
|
||||
* @param {String} address
|
||||
* @param {String} templateAddress template address to add
|
||||
* @return {Promise<TransactionReceipt>}
|
||||
|
@ -192,7 +192,7 @@ export class Datatoken extends SmartContract {
|
||||
|
||||
const withMint = fixedRateParams.withMint ? 1 : 0
|
||||
|
||||
// should check ERC20Deployer role using erc721 level ..
|
||||
// should check ERC20Deployer role using NFT level ..
|
||||
|
||||
const estGas = await estimateGas(
|
||||
address,
|
||||
@ -296,7 +296,7 @@ export class Datatoken extends SmartContract {
|
||||
|
||||
if (!dispenserParams.withMint) dispenserParams.withMint = false
|
||||
|
||||
// should check ERC20Deployer role using erc721 level ..
|
||||
// should check ERC20Deployer role using NFT level ..
|
||||
|
||||
const estGas = await estimateGas(
|
||||
address,
|
||||
@ -434,7 +434,7 @@ export class Datatoken extends SmartContract {
|
||||
): Promise<any> {
|
||||
const dtContract = contractInstance || this.getContract(dtAddress)
|
||||
|
||||
// should check ERC20Deployer role using erc721 level ..
|
||||
// should check ERC20Deployer role using NFT level ..
|
||||
|
||||
return estimateGas(address, dtContract.methods.removeMinter, minter)
|
||||
}
|
||||
|
@ -13,7 +13,7 @@ export class Nft extends SmartContract {
|
||||
|
||||
/**
|
||||
* Estimate gas cost for createERC20 token creation
|
||||
* @param {String} nftAddress ERC721 addreess
|
||||
* @param {String} nftAddress NFT address
|
||||
* @param {String} address User address
|
||||
* @param {String} minter User set as initial minter for the ERC20
|
||||
* @param {String} paymentCollector initial paymentCollector for this DT
|
||||
@ -55,7 +55,7 @@ export class Nft extends SmartContract {
|
||||
|
||||
/**
|
||||
* Create new ERC20 datatoken - only user with ERC20Deployer permission can succeed
|
||||
* @param {String} nftAddress ERC721 addreess
|
||||
* @param {String} nftAddress NFT address
|
||||
* @param {String} address User address
|
||||
* @param {String} minter User set as initial minter for the ERC20
|
||||
* @param {String} paymentCollector initial paymentCollector for this DT
|
||||
@ -130,7 +130,7 @@ export class Nft extends SmartContract {
|
||||
|
||||
/**
|
||||
* Estimate gas cost for add manager call
|
||||
* @param {String} nftAddress erc721 contract adress
|
||||
* @param {String} nftAddress NFT contract address
|
||||
* @param {String} address NFT Owner adress
|
||||
* @param {String} manager User adress which is going to be assing manager
|
||||
* @param {Contract} nftContract optional contract instance
|
||||
@ -149,7 +149,7 @@ export class Nft extends SmartContract {
|
||||
|
||||
/**
|
||||
* Add Manager for NFT Contract (only NFT Owner can succeed)
|
||||
* @param {String} nftAddress erc721 contract adress
|
||||
* @param {String} nftAddress NFT contract address
|
||||
* @param {String} address NFT Owner adress
|
||||
* @param {String} manager User adress which is going to be assing manager
|
||||
* @return {Promise<TransactionReceipt>} trxReceipt
|
||||
@ -175,7 +175,7 @@ export class Nft extends SmartContract {
|
||||
|
||||
/**
|
||||
* Estimate gas cost for removeManager method
|
||||
* @param {String} nftAddress erc721 contract adress
|
||||
* @param {String} nftAddress NFT contract address
|
||||
* @param {String} address NFT Owner adress
|
||||
* @param {String} manager User adress which is going to be removed as manager
|
||||
* @param {Contract} nftContract optional contract instance
|
||||
@ -193,7 +193,7 @@ export class Nft extends SmartContract {
|
||||
|
||||
/**
|
||||
* Removes a specific manager for NFT Contract (only NFT Owner can succeed)
|
||||
* @param {String} nftAddress erc721 contract adress
|
||||
* @param {String} nftAddress NFT contract address
|
||||
* @param {String} address NFT Owner adress
|
||||
* @param {String} manager User adress which is going to be removed as manager
|
||||
* @return {Promise<TransactionReceipt>} trxReceipt
|
||||
@ -219,7 +219,7 @@ export class Nft extends SmartContract {
|
||||
|
||||
/**
|
||||
* Estimate gas cost for addToCreateERC20List method
|
||||
* @param {String} nftAddress erc721 contract adress
|
||||
* @param {String} nftAddress NFT contract address
|
||||
* @param {String} address NFT Manager adress
|
||||
* @param {String} erc20Deployer User adress which is going to have erc20Deployer permission
|
||||
* @param {Contract} nftContract optional contract instance
|
||||
@ -237,7 +237,7 @@ export class Nft extends SmartContract {
|
||||
|
||||
/**
|
||||
* Add ERC20Deployer permission - only Manager can succeed
|
||||
* @param {String} nftAddress erc721 contract adress
|
||||
* @param {String} nftAddress NFT contract address
|
||||
* @param {String} address NFT Manager adress
|
||||
* @param {String} erc20Deployer User adress which is going to have erc20Deployer permission
|
||||
* @return {Promise<TransactionReceipt>} trxReceipt
|
||||
@ -274,7 +274,7 @@ export class Nft extends SmartContract {
|
||||
|
||||
/**
|
||||
* Estimate gas cost for removeFromCreateERC20List method
|
||||
* @param {String} nftAddress erc721 contract adress
|
||||
* @param {String} nftAddress NFT contract address
|
||||
* @param {String} address NFT Manager adress
|
||||
* @param {String} erc20Deployer Address of the user to be revoked ERC20Deployer Permission
|
||||
* @param {Contract} nftContract optional contract instance
|
||||
@ -297,7 +297,7 @@ export class Nft extends SmartContract {
|
||||
|
||||
/**
|
||||
* Remove ERC20Deployer permission - only Manager can succeed
|
||||
* @param {String} nftAddress erc721 contract adress
|
||||
* @param {String} nftAddress NFT contract address
|
||||
* @param {String} address NFT Manager adress
|
||||
* @param {String} erc20Deployer Address of the user to be revoked ERC20Deployer Permission
|
||||
* @return {Promise<TransactionReceipt>} trxReceipt
|
||||
@ -336,7 +336,7 @@ export class Nft extends SmartContract {
|
||||
|
||||
/**
|
||||
* Estimate gas cost for addToMetadataList method
|
||||
* @param {String} nftAddress erc721 contract adress
|
||||
* @param {String} nftAddress NFT contract address
|
||||
* @param {String} address NFT Manager adress
|
||||
* @param {String} metadataUpdater User adress which is going to have Metadata Updater permission
|
||||
* @param {Contract} nftContract optional contract instance
|
||||
@ -355,7 +355,7 @@ export class Nft extends SmartContract {
|
||||
|
||||
/**
|
||||
* Add Metadata Updater permission - only Manager can succeed
|
||||
* @param {String} nftAddress erc721 contract adress
|
||||
* @param {String} nftAddress NFT contract address
|
||||
* @param {String} address NFT Manager adress
|
||||
* @param {String} metadataUpdater User adress which is going to have Metadata Updater permission
|
||||
* @return {Promise<TransactionReceipt>} trxReceipt
|
||||
@ -389,7 +389,7 @@ export class Nft extends SmartContract {
|
||||
|
||||
/**
|
||||
* Estimate gas cost for removeFromMetadataList method
|
||||
* @param {String} nftAddress erc721 contract adress
|
||||
* @param {String} nftAddress NFT contract address
|
||||
* @param {String} address NFT Manager adress
|
||||
* @param {String} metadataUpdater Address of the user to be revoked Metadata updater Permission
|
||||
* @param {Contract} nftContract optional contract instance
|
||||
@ -412,7 +412,7 @@ export class Nft extends SmartContract {
|
||||
|
||||
/**
|
||||
* Remove Metadata Updater permission - only Manager can succeed
|
||||
* @param {String} nftAddress erc721 contract adress
|
||||
* @param {String} nftAddress NFT contract address
|
||||
* @param {String} address NFT Manager adress
|
||||
* @param {String} metadataUpdater Address of the user to be revoked Metadata updater Permission
|
||||
* @return {Promise<TransactionReceipt>} trxReceipt
|
||||
@ -453,7 +453,7 @@ export class Nft extends SmartContract {
|
||||
|
||||
/**
|
||||
* Estimate gas cost for addTo725StoreList method
|
||||
* @param {String} nftAddress erc721 contract adress
|
||||
* @param {String} nftAddress NFT contract address
|
||||
* @param {String} address NFT Manager adress
|
||||
* @param {String} storeUpdater User adress which is going to have Store Updater permission
|
||||
* @param {Contract} nftContract optional contract instance
|
||||
@ -472,7 +472,7 @@ export class Nft extends SmartContract {
|
||||
|
||||
/**
|
||||
* Add Store Updater permission - only Manager can succeed
|
||||
* @param {String} nftAddress erc721 contract adress
|
||||
* @param {String} nftAddress NFT contract address
|
||||
* @param {String} address NFT Manager adress
|
||||
* @param {String} storeUpdater User adress which is going to have Store Updater permission
|
||||
* @return {Promise<TransactionReceipt>} trxReceipt
|
||||
@ -506,7 +506,7 @@ export class Nft extends SmartContract {
|
||||
|
||||
/**
|
||||
* Estimate gas cost for removeFrom725StoreList method
|
||||
* @param {String} nftAddress erc721 contract adress
|
||||
* @param {String} nftAddress NFT contract address
|
||||
* @param {String} address NFT Manager adress
|
||||
* @param {String} storeUpdater Address of the user to be revoked Store Updater Permission
|
||||
* @param {Contract} nftContract optional contract instance
|
||||
@ -525,7 +525,7 @@ export class Nft extends SmartContract {
|
||||
|
||||
/**
|
||||
* Remove Store Updater permission - only Manager can succeed
|
||||
* @param {String} nftAddress erc721 contract adress
|
||||
* @param {String} nftAddress NFT contract address
|
||||
* @param {String} address NFT Manager adress
|
||||
* @param {String} storeUpdater Address of the user to be revoked Store Updater Permission
|
||||
* @return {Promise<TransactionReceipt>} trxReceipt
|
||||
@ -565,7 +565,7 @@ export class Nft extends SmartContract {
|
||||
|
||||
/**
|
||||
* Estimate gas cost for cleanPermissions method
|
||||
* @param {String} nftAddress erc721 contract adress
|
||||
* @param {String} nftAddress NFT contract address
|
||||
* @param {String} address NFT Owner adress
|
||||
* @param {Contract} nftContract optional contract instance
|
||||
* @return {Promise<any>}
|
||||
@ -581,11 +581,11 @@ export class Nft extends SmartContract {
|
||||
}
|
||||
|
||||
/**
|
||||
* This function allows to remove all ROLES at erc721 level: Managers, ERC20Deployer, MetadataUpdater, StoreUpdater
|
||||
* This function allows to remove all ROLES at NFT level: Managers, ERC20Deployer, MetadataUpdater, StoreUpdater
|
||||
* Even NFT Owner has to readd himself as Manager
|
||||
* Permissions at erc20 level stay.
|
||||
* Only NFT Owner can call it.
|
||||
* @param {String} nftAddress erc721 contract adress
|
||||
* @param {String} nftAddress NFT contract address
|
||||
* @param {String} address NFT Owner adress
|
||||
* @return {Promise<TransactionReceipt>} trxReceipt
|
||||
*/
|
||||
@ -614,7 +614,7 @@ export class Nft extends SmartContract {
|
||||
|
||||
/**
|
||||
* Estimate gas cost for transfer NFT method
|
||||
* @param {String} nftAddress erc721 contract adress
|
||||
* @param {String} nftAddress NFT contract address
|
||||
* @param {String} nftOwner Current NFT Owner adress
|
||||
* @param {String} nftReceiver User which will receive the NFT, will also be set as Manager
|
||||
* @param {Number} tokenId The id of the token to be transfered
|
||||
@ -641,8 +641,8 @@ export class Nft extends SmartContract {
|
||||
|
||||
/**
|
||||
* Transfers the NFT
|
||||
* will clean all permissions both on erc721 and erc20 level.
|
||||
* @param {String} nftAddress erc721 contract adress
|
||||
* will clean all permissions both on NFT and erc20 level.
|
||||
* @param {String} nftAddress NFT contract address
|
||||
* @param {String} nftOwner Current NFT Owner adress
|
||||
* @param {String} nftReceiver User which will receive the NFT, will also be set as Manager
|
||||
* @param {Number} tokenId The id of the token to be transfered
|
||||
@ -684,7 +684,7 @@ export class Nft extends SmartContract {
|
||||
|
||||
/**
|
||||
* Estimate gas cost for safeTransfer NFT method
|
||||
* @param {String} nftAddress erc721 contract adress
|
||||
* @param {String} nftAddress NFT contract address
|
||||
* @param {String} nftOwner Current NFT Owner adress
|
||||
* @param {String} nftReceiver User which will receive the NFT, will also be set as Manager
|
||||
* @param {Number} tokenId The id of the token to be transfered
|
||||
@ -711,8 +711,8 @@ export class Nft extends SmartContract {
|
||||
|
||||
/**
|
||||
* safeTransferNFT Used for transferring the NFT, can be used by an approved relayer
|
||||
* will clean all permissions both on erc721 and erc20 level.
|
||||
* @param {String} nftAddress erc721 contract adress
|
||||
* will clean all permissions both on NFT and erc20 level.
|
||||
* @param {String} nftAddress NFT contract address
|
||||
* @param {String} nftOwner Current NFT Owner adress
|
||||
* @param {String} nftReceiver User which will receive the NFT, will also be set as Manager
|
||||
* @param {Number} tokenId The id of the token to be transfered
|
||||
@ -755,7 +755,7 @@ export class Nft extends SmartContract {
|
||||
// TODO: Finish this description
|
||||
/**
|
||||
* Estimate gas cost for setMetadata method
|
||||
* @param {String} nftAddress erc721 contract adress
|
||||
* @param {String} nftAddress NFT contract address
|
||||
* @param {String} metadataUpdater metadataUpdater address
|
||||
* @param {Number} metadataState User which will receive the NFT, will also be set as Manager
|
||||
* @param {String} metadataDecryptorUrl
|
||||
@ -792,8 +792,8 @@ export class Nft extends SmartContract {
|
||||
|
||||
/**
|
||||
* safeTransferNFT Used for transferring the NFT, can be used by an approved relayer
|
||||
* will clean all permissions both on erc721 and erc20 level.
|
||||
* @param {String} nftAddress erc721 contract adress
|
||||
* will clean all permissions both on NFT and erc20 level.
|
||||
* @param {String} nftAddress NFT contract address
|
||||
* @param {String} address Caller address NFT Owner adress
|
||||
* @return {Promise<TransactionReceipt>} trxReceipt
|
||||
*/
|
||||
@ -845,7 +845,7 @@ export class Nft extends SmartContract {
|
||||
|
||||
/**
|
||||
* Estimate gas cost for setMetadata method
|
||||
* @param {String} nftAddress erc721 contract adress
|
||||
* @param {String} nftAddress NFT contract address
|
||||
* @param {String} metadataUpdater metadataUpdater address
|
||||
* @param {MetaDataAndTokenURI} metadataAndTokenURI metaDataAndTokenURI object
|
||||
* @param {Contract} nftContract optional contract instance
|
||||
@ -871,7 +871,7 @@ export class Nft extends SmartContract {
|
||||
|
||||
/**
|
||||
* Helper function to improve UX sets both MetaData & TokenURI in one tx
|
||||
* @param {String} nftAddress erc721 contract adress
|
||||
* @param {String} nftAddress NFT contract address
|
||||
* @param {String} address Caller address
|
||||
* @param {MetadataAndTokenURI} metadataAndTokenURI metaDataAndTokenURI object
|
||||
* @return {Promise<TransactionReceipt>} trxReceipt
|
||||
@ -907,7 +907,7 @@ export class Nft extends SmartContract {
|
||||
|
||||
/**
|
||||
* Estimate gas cost for setMetadataState method
|
||||
* @param {String} nftAddress erc721 contract adress
|
||||
* @param {String} nftAddress NFT contract address
|
||||
* @param {String} nftOwner Current NFT Owner adress
|
||||
* @param {Number} metadataState new metadata state
|
||||
* @param {Contract} nftContract optional contract instance
|
||||
@ -930,7 +930,7 @@ export class Nft extends SmartContract {
|
||||
|
||||
/**
|
||||
* setMetadataState Used for updating the metadata State
|
||||
* @param {String} nftAddress erc721 contract adress
|
||||
* @param {String} nftAddress NFT contract address
|
||||
* @param {String} address Caller address => metadata updater
|
||||
* @param {Number} metadataState new metadata state
|
||||
* @return {Promise<TransactionReceipt>} trxReceipt
|
||||
@ -963,7 +963,7 @@ export class Nft extends SmartContract {
|
||||
}
|
||||
|
||||
/** Estimate gas cost for setTokenURI method
|
||||
* @param nftAddress erc721 contract adress
|
||||
* @param nftAddress NFT contract address
|
||||
* @param address user adress
|
||||
* @param data input data for TokenURI
|
||||
* @return {Promise<TransactionReceipt>} transaction receipt
|
||||
@ -979,7 +979,7 @@ export class Nft extends SmartContract {
|
||||
}
|
||||
|
||||
/** set TokenURI on an nft
|
||||
* @param nftAddress erc721 contract adress
|
||||
* @param nftAddress NFT contract address
|
||||
* @param address user adress
|
||||
* @param data input data for TokenURI
|
||||
* @return {Promise<TransactionReceipt>} transaction receipt
|
||||
@ -1001,7 +1001,7 @@ export class Nft extends SmartContract {
|
||||
}
|
||||
|
||||
/** Get Owner
|
||||
* @param {String} nftAddress erc721 contract adress
|
||||
* @param {String} nftAddress NFT contract address
|
||||
* @return {Promise<string>} string
|
||||
*/
|
||||
public async getNftOwner(nftAddress: string): Promise<string> {
|
||||
@ -1011,7 +1011,7 @@ export class Nft extends SmartContract {
|
||||
}
|
||||
|
||||
/** Get users NFT Permissions
|
||||
* @param {String} nftAddress erc721 contract adress
|
||||
* @param {String} nftAddress NFT contract address
|
||||
* @param {String} address user adress
|
||||
* @return {Promise<NftRoles>}
|
||||
*/
|
||||
@ -1022,7 +1022,7 @@ export class Nft extends SmartContract {
|
||||
}
|
||||
|
||||
/** Get users Metadata, return Metadata details
|
||||
* @param {String} nftAddress erc721 contract adress
|
||||
* @param {String} nftAddress NFT contract address
|
||||
* @return {Promise<Objecta>}
|
||||
*/
|
||||
public async getMetadata(nftAddress: string): Promise<Object> {
|
||||
@ -1031,7 +1031,7 @@ export class Nft extends SmartContract {
|
||||
}
|
||||
|
||||
/** Get users ERC20Deployer role
|
||||
* @param {String} nftAddress erc721 contract adress
|
||||
* @param {String} nftAddress NFT contract address
|
||||
* @param {String} address user adress
|
||||
* @return {Promise<boolean>}
|
||||
*/
|
||||
@ -1042,7 +1042,7 @@ export class Nft extends SmartContract {
|
||||
}
|
||||
|
||||
/** Gets data at a given `key`
|
||||
* @param {String} nftAddress erc721 contract adress
|
||||
* @param {String} nftAddress NFT contract address
|
||||
* @param {String} key the key which value to retrieve
|
||||
* @return {Promise<string>} The data stored at the key
|
||||
*/
|
||||
@ -1053,7 +1053,7 @@ export class Nft extends SmartContract {
|
||||
}
|
||||
|
||||
/** Gets data at a given `key`
|
||||
* @param {String} nftAddress erc721 contract adress
|
||||
* @param {String} nftAddress NFT contract address
|
||||
* @param {String} id
|
||||
* @return {Promise<string>} The data stored at the key
|
||||
*/
|
||||
|
@ -2,9 +2,9 @@ import sha256 from 'crypto-js/sha256'
|
||||
import Web3 from 'web3'
|
||||
import { LoggerInstance } from '.'
|
||||
|
||||
export function generateDid(erc721Address: string, chainId: number): string {
|
||||
erc721Address = Web3.utils.toChecksumAddress(erc721Address)
|
||||
const checksum = sha256(erc721Address + chainId.toString(10))
|
||||
export function generateDid(nftAddress: string, chainId: number): string {
|
||||
nftAddress = Web3.utils.toChecksumAddress(nftAddress)
|
||||
const checksum = sha256(nftAddress + chainId.toString(10))
|
||||
return `did:op:${checksum.toString()}`
|
||||
}
|
||||
|
||||
|
@ -50,13 +50,13 @@ export interface Addresses {
|
||||
opfCommunityFeeCollectorAddress: string
|
||||
poolTemplateAddress: string
|
||||
erc20TemplateAddress: string
|
||||
erc721TemplateAddress: string
|
||||
nftTemplateAddress: string
|
||||
oceanAddress: string
|
||||
routerAddress: string
|
||||
sideStakingAddress: string
|
||||
fixedRateAddress: string
|
||||
dispenserAddress: string
|
||||
erc721FactoryAddress: string
|
||||
nftFactoryAddress: string
|
||||
daiAddress: string
|
||||
usdcAddress: string
|
||||
}
|
||||
@ -98,8 +98,8 @@ export const deployContracts = async (web3: Web3, owner: string): Promise<Addres
|
||||
owner
|
||||
))
|
||||
|
||||
// deploy ERC721 template
|
||||
addresses.erc721TemplateAddress =
|
||||
// deploy NFT template
|
||||
addresses.nftTemplateAddress =
|
||||
configAddresses.ERC721Template['1'] ||
|
||||
(await estimateGasAndDeployContract(
|
||||
web3,
|
||||
@ -170,15 +170,15 @@ export const deployContracts = async (web3: Web3, owner: string): Promise<Addres
|
||||
owner
|
||||
))
|
||||
|
||||
// deploy ERC721 factory
|
||||
addresses.erc721FactoryAddress =
|
||||
// deploy NFT factory
|
||||
addresses.nftFactoryAddress =
|
||||
configAddresses.ERC721Factory ||
|
||||
(await estimateGasAndDeployContract(
|
||||
web3,
|
||||
ERC721Factory.abi as AbiItem[],
|
||||
ERC721Factory.bytecode,
|
||||
[
|
||||
addresses.erc721TemplateAddress,
|
||||
addresses.nftTemplateAddress,
|
||||
addresses.erc20TemplateAddress,
|
||||
addresses.opfCommunityFeeCollectorAddress,
|
||||
addresses.routerAddress
|
||||
@ -215,7 +215,7 @@ export const deployContracts = async (web3: Web3, owner: string): Promise<Addres
|
||||
)
|
||||
|
||||
await RouterContract.methods
|
||||
.addFactory(addresses.erc721FactoryAddress)
|
||||
.addFactory(addresses.nftFactoryAddress)
|
||||
.send({ from: owner })
|
||||
await RouterContract.methods
|
||||
.addFixedRateContract(addresses.fixedRateAddress)
|
||||
|
@ -244,7 +244,7 @@ async function createAsset(
|
||||
|
||||
const result = await Factory.createNftWithErc20(owner, nftParamsAsset, erc20ParamsAsset)
|
||||
|
||||
const erc721AddressAsset = result.events.NFTCreated.returnValues[0]
|
||||
const nftAddress = result.events.NFTCreated.returnValues[0]
|
||||
const datatokenAddressAsset = result.events.TokenCreated.returnValues[0]
|
||||
// create the files encrypted string
|
||||
let providerResponse = await ProviderInstance.encrypt(assetUrl, providerUrl)
|
||||
@ -252,16 +252,15 @@ async function createAsset(
|
||||
ddo.services[0].datatokenAddress = datatokenAddressAsset
|
||||
ddo.services[0].serviceEndpoint = providerUrl
|
||||
// update ddo and set the right did
|
||||
ddo.nftAddress = web3.utils.toChecksumAddress(erc721AddressAsset)
|
||||
ddo.nftAddress = web3.utils.toChecksumAddress(nftAddress)
|
||||
ddo.id =
|
||||
'did:op:' +
|
||||
SHA256(web3.utils.toChecksumAddress(erc721AddressAsset) + chain.toString(10))
|
||||
'did:op:' + SHA256(web3.utils.toChecksumAddress(nftAddress) + chain.toString(10))
|
||||
providerResponse = await ProviderInstance.encrypt(ddo, providerUrl)
|
||||
const encryptedResponse = await providerResponse
|
||||
const validateResult = await aquarius.validate(ddo)
|
||||
assert(validateResult.valid, 'Could not validate metadata')
|
||||
await nft.setMetadata(
|
||||
erc721AddressAsset,
|
||||
nftAddress,
|
||||
owner,
|
||||
0,
|
||||
providerUrl,
|
||||
|
@ -97,7 +97,7 @@ describe('Simple Publish & consume test', async () => {
|
||||
}
|
||||
|
||||
const tx = await Factory.createNftWithErc20(publisherAccount, nftParams, erc20Params)
|
||||
const erc721Address = tx.events.NFTCreated.returnValues[0]
|
||||
const nftAddress = tx.events.NFTCreated.returnValues[0]
|
||||
const datatokenAddress = tx.events.TokenCreated.returnValues[0]
|
||||
|
||||
// create the files encrypted string
|
||||
@ -105,16 +105,16 @@ describe('Simple Publish & consume test', async () => {
|
||||
ddo.services[0].files = await providerResponse
|
||||
ddo.services[0].datatokenAddress = datatokenAddress
|
||||
// update ddo and set the right did
|
||||
ddo.nftAddress = erc721Address
|
||||
ddo.nftAddress = nftAddress
|
||||
const chain = await web3.eth.getChainId()
|
||||
ddo.id =
|
||||
'did:op:' + SHA256(web3.utils.toChecksumAddress(erc721Address) + chain.toString(10))
|
||||
'did:op:' + SHA256(web3.utils.toChecksumAddress(nftAddress) + chain.toString(10))
|
||||
|
||||
providerResponse = await ProviderInstance.encrypt(ddo, providerUrl)
|
||||
const encryptedResponse = await providerResponse
|
||||
const metadataHash = getHash(JSON.stringify(ddo))
|
||||
await nft.setMetadata(
|
||||
erc721Address,
|
||||
nftAddress,
|
||||
publisherAccount,
|
||||
0,
|
||||
providerUrl,
|
||||
|
@ -73,7 +73,7 @@ describe('Nft Factory test', () => {
|
||||
})
|
||||
|
||||
it('should initiate NFTFactory instance', async () => {
|
||||
nftFactory = new NftFactory(contracts.erc721FactoryAddress, web3)
|
||||
nftFactory = new NftFactory(contracts.nftFactoryAddress, web3)
|
||||
})
|
||||
|
||||
it('#getOwner - should return actual owner', async () => {
|
||||
@ -84,7 +84,7 @@ describe('Nft Factory test', () => {
|
||||
it('#getNFTTemplate - should return NFT template struct', async () => {
|
||||
const nftTemplate = await nftFactory.getNFTTemplate(1)
|
||||
assert(nftTemplate.isActive === true)
|
||||
assert(nftTemplate.templateAddress === contracts.erc721TemplateAddress)
|
||||
assert(nftTemplate.templateAddress === contracts.nftTemplateAddress)
|
||||
})
|
||||
|
||||
it('#getTokenTemplate - should return Token template struct', async () => {
|
||||
@ -131,7 +131,7 @@ describe('Nft Factory test', () => {
|
||||
const poolParams: PoolCreationParams = {
|
||||
ssContract: contracts.sideStakingAddress,
|
||||
baseTokenAddress: contracts.daiAddress,
|
||||
baseTokenSender: contracts.erc721FactoryAddress,
|
||||
baseTokenSender: contracts.nftFactoryAddress,
|
||||
publisherAddress: nftOwner,
|
||||
marketFeeCollector: nftOwner,
|
||||
poolTemplateAddress: contracts.poolTemplateAddress,
|
||||
@ -156,7 +156,7 @@ describe('Nft Factory test', () => {
|
||||
web3,
|
||||
nftOwner,
|
||||
contracts.daiAddress,
|
||||
contracts.erc721FactoryAddress,
|
||||
contracts.nftFactoryAddress,
|
||||
poolParams.vestingAmount
|
||||
)
|
||||
|
||||
@ -246,7 +246,7 @@ describe('Nft Factory test', () => {
|
||||
|
||||
// user1 approves NFTFactory to move his DATA_TOKEN_AMOUNT
|
||||
await dtContract.methods
|
||||
.approve(contracts.erc721FactoryAddress, DATA_TOKEN_AMOUNT)
|
||||
.approve(contracts.nftFactoryAddress, DATA_TOKEN_AMOUNT)
|
||||
.send({ from: user1 })
|
||||
|
||||
// we reuse another DT created in a previous test
|
||||
@ -257,7 +257,7 @@ describe('Nft Factory test', () => {
|
||||
await dtContract2.methods.mint(user1, DATA_TOKEN_AMOUNT).send({ from: nftOwner })
|
||||
// user1 approves NFTFactory to move his DATA_TOKEN_AMOUNT
|
||||
await dtContract2.methods
|
||||
.approve(contracts.erc721FactoryAddress, DATA_TOKEN_AMOUNT)
|
||||
.approve(contracts.nftFactoryAddress, DATA_TOKEN_AMOUNT)
|
||||
.send({ from: user1 })
|
||||
|
||||
// we check user1 has enought DTs
|
||||
@ -325,17 +325,17 @@ describe('Nft Factory test', () => {
|
||||
assert((await nftFactory.checkNFT(nftAddress)) === nftAddress)
|
||||
})
|
||||
|
||||
it('#addNFTTemplate - should add a new erc721 token template', async () => {
|
||||
it('#addNFTTemplate - should add a new NFT token template', async () => {
|
||||
const currentNFTTemplateCount = await nftFactory.getCurrentNFTTemplateCount()
|
||||
|
||||
await nftFactory.addNFTTemplate(factoryOwner, contracts.erc721TemplateAddress)
|
||||
await nftFactory.addNFTTemplate(factoryOwner, contracts.nftTemplateAddress)
|
||||
|
||||
expect(
|
||||
(await nftFactory.getCurrentNFTTemplateCount()) === currentNFTTemplateCount + 1
|
||||
)
|
||||
})
|
||||
|
||||
it('#disableNFTTemplate - should disable an erc721 token template', async () => {
|
||||
it('#disableNFTTemplate - should disable an NFT token template', async () => {
|
||||
const currentNFTTemplateCount = await nftFactory.getCurrentNFTTemplateCount()
|
||||
|
||||
let nftTemplate = await nftFactory.getNFTTemplate(currentNFTTemplateCount)
|
||||
@ -347,7 +347,7 @@ describe('Nft Factory test', () => {
|
||||
assert(nftTemplate.isActive === false)
|
||||
})
|
||||
|
||||
it('#reactivateNFTTemplate - should reactivate an erc721 previously disabled token template', async () => {
|
||||
it('#reactivateNFTTemplate - should reactivate an NFT previously disabled token template', async () => {
|
||||
const currentNFTTemplateCount = await nftFactory.getCurrentNFTTemplateCount()
|
||||
|
||||
let nftTemplate = await nftFactory.getNFTTemplate(currentNFTTemplateCount)
|
||||
|
@ -82,7 +82,7 @@ describe('Router unit test', () => {
|
||||
web3,
|
||||
factoryOwner,
|
||||
contracts.daiAddress,
|
||||
contracts.erc721FactoryAddress,
|
||||
contracts.nftFactoryAddress,
|
||||
web3.utils.toWei('10000')
|
||||
)
|
||||
})
|
||||
@ -98,7 +98,7 @@ describe('Router unit test', () => {
|
||||
|
||||
it('#getNFTFactory - should return NFT Factory address', async () => {
|
||||
const factory = await router.getNFTFactory()
|
||||
assert(factory === contracts.erc721FactoryAddress)
|
||||
assert(factory === contracts.nftFactoryAddress)
|
||||
})
|
||||
|
||||
it('#isOceanTokens - should return true if in oceanTokens list', async () => {
|
||||
@ -138,7 +138,7 @@ describe('Router unit test', () => {
|
||||
const poolParams: PoolCreationParams = {
|
||||
ssContract: contracts.sideStakingAddress,
|
||||
baseTokenAddress: contracts.daiAddress,
|
||||
baseTokenSender: contracts.erc721FactoryAddress,
|
||||
baseTokenSender: contracts.nftFactoryAddress,
|
||||
publisherAddress: factoryOwner,
|
||||
marketFeeCollector: factoryOwner,
|
||||
poolTemplateAddress: contracts.poolTemplateAddress,
|
||||
@ -151,7 +151,7 @@ describe('Router unit test', () => {
|
||||
swapFeeMarketRunner: FEE
|
||||
}
|
||||
|
||||
const nftFactory = new NftFactory(contracts.erc721FactoryAddress, web3)
|
||||
const nftFactory = new NftFactory(contracts.nftFactoryAddress, web3)
|
||||
const txReceipt = await nftFactory.createNftErc20WithPool(
|
||||
factoryOwner,
|
||||
NFT_DATA,
|
||||
|
@ -73,7 +73,7 @@ describe('Pool unit test', () => {
|
||||
web3,
|
||||
factoryOwner,
|
||||
contracts.daiAddress,
|
||||
contracts.erc721FactoryAddress,
|
||||
contracts.nftFactoryAddress,
|
||||
'2000'
|
||||
)
|
||||
|
||||
@ -83,7 +83,7 @@ describe('Pool unit test', () => {
|
||||
web3,
|
||||
contracts.daiAddress,
|
||||
factoryOwner,
|
||||
contracts.erc721FactoryAddress
|
||||
contracts.nftFactoryAddress
|
||||
)
|
||||
) >= 2000
|
||||
)
|
||||
@ -92,7 +92,7 @@ describe('Pool unit test', () => {
|
||||
web3,
|
||||
factoryOwner,
|
||||
contracts.usdcAddress,
|
||||
contracts.erc721FactoryAddress,
|
||||
contracts.nftFactoryAddress,
|
||||
'10000'
|
||||
)
|
||||
|
||||
@ -102,7 +102,7 @@ describe('Pool unit test', () => {
|
||||
web3,
|
||||
contracts.usdcAddress,
|
||||
factoryOwner,
|
||||
contracts.erc721FactoryAddress
|
||||
contracts.nftFactoryAddress
|
||||
)
|
||||
) >= 10000
|
||||
)
|
||||
@ -115,7 +115,7 @@ describe('Pool unit test', () => {
|
||||
const poolParams: PoolCreationParams = {
|
||||
ssContract: contracts.sideStakingAddress,
|
||||
baseTokenAddress: contracts.daiAddress,
|
||||
baseTokenSender: contracts.erc721FactoryAddress,
|
||||
baseTokenSender: contracts.nftFactoryAddress,
|
||||
publisherAddress: factoryOwner,
|
||||
marketFeeCollector: factoryOwner,
|
||||
poolTemplateAddress: contracts.poolTemplateAddress,
|
||||
@ -128,7 +128,7 @@ describe('Pool unit test', () => {
|
||||
swapFeeMarketRunner: '0.001'
|
||||
}
|
||||
|
||||
const nftFactory = new NftFactory(contracts.erc721FactoryAddress, web3, 8996)
|
||||
const nftFactory = new NftFactory(contracts.nftFactoryAddress, web3, 8996)
|
||||
|
||||
const txReceipt = await nftFactory.createNftErc20WithPool(
|
||||
factoryOwner,
|
||||
@ -510,7 +510,7 @@ describe('Pool unit test', () => {
|
||||
const poolParams: PoolCreationParams = {
|
||||
ssContract: contracts.sideStakingAddress,
|
||||
baseTokenAddress: contracts.usdcAddress,
|
||||
baseTokenSender: contracts.erc721FactoryAddress,
|
||||
baseTokenSender: contracts.nftFactoryAddress,
|
||||
publisherAddress: factoryOwner,
|
||||
marketFeeCollector: factoryOwner,
|
||||
poolTemplateAddress: contracts.poolTemplateAddress,
|
||||
@ -523,7 +523,7 @@ describe('Pool unit test', () => {
|
||||
swapFeeMarketRunner: '0.001'
|
||||
}
|
||||
|
||||
const nftFactory = new NftFactory(contracts.erc721FactoryAddress, web3, 8996)
|
||||
const nftFactory = new NftFactory(contracts.nftFactoryAddress, web3, 8996)
|
||||
|
||||
const txReceipt = await nftFactory.createNftErc20WithPool(
|
||||
factoryOwner,
|
||||
|
@ -64,7 +64,7 @@ describe('Dispenser flow', () => {
|
||||
})
|
||||
|
||||
it('#createNftwithErc - should create an NFT and a Datatoken ', async () => {
|
||||
nftFactory = new NftFactory(contracts.erc721FactoryAddress, web3)
|
||||
nftFactory = new NftFactory(contracts.nftFactoryAddress, web3)
|
||||
|
||||
const txReceipt = await nftFactory.createNftWithErc20(
|
||||
factoryOwner,
|
||||
|
@ -71,7 +71,7 @@ describe('Fixed Rate unit test', () => {
|
||||
// CREATE AN Exchange
|
||||
// we prepare transaction parameters objects
|
||||
|
||||
const nftFactory = new NftFactory(contracts.erc721FactoryAddress, web3)
|
||||
const nftFactory = new NftFactory(contracts.nftFactoryAddress, web3)
|
||||
|
||||
const freParams: FreCreationParams = {
|
||||
fixedRateAddress: contracts.fixedRateAddress,
|
||||
@ -380,7 +380,7 @@ describe('Fixed Rate unit test', () => {
|
||||
// CREATE AN Exchange
|
||||
// we prepare transaction parameters objects
|
||||
|
||||
const nftFactory = new NftFactory(contracts.erc721FactoryAddress, web3)
|
||||
const nftFactory = new NftFactory(contracts.nftFactoryAddress, web3)
|
||||
|
||||
const freParams: FreCreationParams = {
|
||||
fixedRateAddress: contracts.fixedRateAddress,
|
||||
|
@ -96,7 +96,7 @@ describe('SideStaking unit test', () => {
|
||||
web3,
|
||||
factoryOwner,
|
||||
contracts.daiAddress,
|
||||
contracts.erc721FactoryAddress,
|
||||
contracts.nftFactoryAddress,
|
||||
BASE_TOKEN_LIQUIDITY.toString()
|
||||
)
|
||||
|
||||
@ -106,7 +106,7 @@ describe('SideStaking unit test', () => {
|
||||
web3,
|
||||
contracts.daiAddress,
|
||||
factoryOwner,
|
||||
contracts.erc721FactoryAddress
|
||||
contracts.nftFactoryAddress
|
||||
)
|
||||
) >= BASE_TOKEN_LIQUIDITY
|
||||
)
|
||||
@ -115,7 +115,7 @@ describe('SideStaking unit test', () => {
|
||||
web3,
|
||||
factoryOwner,
|
||||
contracts.usdcAddress,
|
||||
contracts.erc721FactoryAddress,
|
||||
contracts.nftFactoryAddress,
|
||||
BASE_TOKEN_LIQUIDITY.toString()
|
||||
)
|
||||
|
||||
@ -125,7 +125,7 @@ describe('SideStaking unit test', () => {
|
||||
web3,
|
||||
contracts.usdcAddress,
|
||||
factoryOwner,
|
||||
contracts.erc721FactoryAddress
|
||||
contracts.nftFactoryAddress
|
||||
)
|
||||
) >= BASE_TOKEN_LIQUIDITY
|
||||
)
|
||||
@ -135,12 +135,12 @@ describe('SideStaking unit test', () => {
|
||||
it('#create a pool', async () => {
|
||||
// CREATE A POOL
|
||||
// we prepare transaction parameters objects
|
||||
const nftFactory = new NftFactory(contracts.erc721FactoryAddress, web3)
|
||||
const nftFactory = new NftFactory(contracts.nftFactoryAddress, web3)
|
||||
|
||||
const poolParams: PoolCreationParams = {
|
||||
ssContract: contracts.sideStakingAddress,
|
||||
baseTokenAddress: contracts.daiAddress,
|
||||
baseTokenSender: contracts.erc721FactoryAddress,
|
||||
baseTokenSender: contracts.nftFactoryAddress,
|
||||
publisherAddress: factoryOwner,
|
||||
marketFeeCollector: factoryOwner,
|
||||
poolTemplateAddress: contracts.poolTemplateAddress,
|
||||
@ -349,12 +349,12 @@ describe('SideStaking unit test', () => {
|
||||
it('#create a pool', async () => {
|
||||
// CREATE A POOL
|
||||
// we prepare transaction parameters objects
|
||||
const nftFactory = new NftFactory(contracts.erc721FactoryAddress, web3)
|
||||
const nftFactory = new NftFactory(contracts.nftFactoryAddress, web3)
|
||||
|
||||
const poolParams: PoolCreationParams = {
|
||||
ssContract: contracts.sideStakingAddress,
|
||||
baseTokenAddress: contracts.usdcAddress,
|
||||
baseTokenSender: contracts.erc721FactoryAddress,
|
||||
baseTokenSender: contracts.nftFactoryAddress,
|
||||
publisherAddress: factoryOwner,
|
||||
marketFeeCollector: factoryOwner,
|
||||
poolTemplateAddress: contracts.poolTemplateAddress,
|
||||
|
@ -65,7 +65,7 @@ describe('Datatoken', () => {
|
||||
})
|
||||
|
||||
it('should initialize NFTFactory instance and create a new NFT', async () => {
|
||||
nftFactory = new NftFactory(contracts.erc721FactoryAddress, web3, 8996)
|
||||
nftFactory = new NftFactory(contracts.nftFactoryAddress, web3, 8996)
|
||||
|
||||
nftAddress = await nftFactory.createNFT(nftOwner, nftData)
|
||||
nftDatatoken = new Nft(web3, 8996)
|
||||
@ -541,9 +541,9 @@ describe('Datatoken', () => {
|
||||
)
|
||||
})
|
||||
|
||||
it('#getERC721Address - should succeed to get the parent ERC721 address', async () => {
|
||||
it('#getNFTAddress - should succeed to get the parent NFT address', async () => {
|
||||
const address = await datatoken.getNFTAddress(datatokenAddress)
|
||||
assert(address, 'Not able to get the parent ERC721 address')
|
||||
assert(address, 'Not able to get the parent NFT address')
|
||||
})
|
||||
|
||||
it('#setData - should set a value into 725Y standard, if Caller has ERC20Deployer permission', async () => {
|
||||
|
@ -39,7 +39,7 @@ describe('NFT', () => {
|
||||
})
|
||||
|
||||
it('should initialize NFTFactory instance and create a new NFT', async () => {
|
||||
nftFactory = new NftFactory(contracts.erc721FactoryAddress, web3, 8996)
|
||||
nftFactory = new NftFactory(contracts.nftFactoryAddress, web3, 8996)
|
||||
|
||||
nftAddress = await nftFactory.createNFT(nftOwner, nftData)
|
||||
nftDatatoken = new Nft(web3, 8996)
|
||||
|
Loading…
x
Reference in New Issue
Block a user