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

added new file metadata structure and reorganize tokens and types

This commit is contained in:
Bogdan Fazakas 2021-12-08 17:08:30 +02:00
parent cb7e4dc948
commit 1bdef71d54
17 changed files with 71 additions and 67 deletions

View File

@ -97,7 +97,7 @@ export interface AssetLastEvent {
datetime: string datetime: string
} }
export class Asset extends DDO { export interface Asset extends DDO {
/** /**
* Contains information about the ERC721 NFT contract which represents the intellectual property of the publisher. * Contains information about the ERC721 NFT contract which represents the intellectual property of the publisher.
* @type {string} * @type {string}

View File

@ -6,49 +6,49 @@ import { Credentials } from './Credentials'
* DID Descriptor Object. * DID Descriptor Object.
* Contains metadata about the asset, and define access in at least one service. * Contains metadata about the asset, and define access in at least one service.
*/ */
export class DDO { export interface DDO {
/** /**
* Contexts used for validation. * Contexts used for validation.
* @type {string[]} * @type {string[]}
*/ */
public '@context': string[] '@context': string[]
/** /**
* DID, descentralized ID. * DID, descentralized ID.
* Computed as sha256(address of ERC721 contract + chainId) * Computed as sha256(address of ERC721 contract + chainId)
* @type {string} * @type {string}
*/ */
public id: string id: string
/** /**
* Version information in SemVer notation * Version information in SemVer notation
* referring to the DDO spec version * referring to the DDO spec version
* @type {string} * @type {string}
*/ */
public version: string version: string
/** /**
* ChainId of the network the DDO was published to. * ChainId of the network the DDO was published to.
* @type {number} * @type {number}
*/ */
public chainId: number chainId: number
/** /**
* Stores an object describing the asset. * Stores an object describing the asset.
* @type {Metadata} * @type {Metadata}
*/ */
public metadata: Metadata metadata: Metadata
/** /**
* Stores an array of services defining access to the asset. * Stores an array of services defining access to the asset.
* @type {Service[]} * @type {Service[]}
*/ */
public services: Service[] services: Service[]
/** /**
* Describes the credentials needed to access a dataset * Describes the credentials needed to access a dataset
* in addition to the services definition. * in addition to the services definition.
* @type {Credentials} * @type {Credentials}
*/ */
public credentials?: Credentials credentials?: Credentials
} }

View File

@ -1,10 +1,16 @@
export interface FileMetadata { export interface FileMetadata {
/**
* File URL.
* @type {string}
*/
type: string
/** /**
* File format, if applicable. * File format, if applicable.
* @type {string} * @type {string}
* @example "text/csv" * @example "text/csv"
*/ */
contentType: string contentType?: string
/** /**
* File content length. * File content length.
@ -23,4 +29,10 @@ export interface FileMetadata {
* @type {string} * @type {string}
*/ */
url?: string url?: string
/**
* HTTP method used
* @type {string}
*/
method?: string
} }

View File

@ -3,3 +3,4 @@ export * from './Asset'
export * from './Service' export * from './Service'
export * from './Credentials' export * from './Credentials'
export * from './Metadata' export * from './Metadata'
export * from './FileMetadata'

View File

@ -1,2 +0,0 @@
export * from './Datatoken'
export * from './NFTDatatoken'

View File

@ -1,5 +1,5 @@
export * from './pools' export * from './pools'
export * from './datatokens' export * from './tokens'
export * from './factories' export * from './factories'
export * from './models' export * from './models'
export * from './utils' export * from './utils'

View File

@ -5,7 +5,7 @@ import { TransactionReceipt } from 'web3-eth'
import Decimal from 'decimal.js' import Decimal from 'decimal.js'
import defaultDispenserABI from '@oceanprotocol/contracts/artifacts/contracts/pools/dispenser/Dispenser.sol/Dispenser.json' import defaultDispenserABI from '@oceanprotocol/contracts/artifacts/contracts/pools/dispenser/Dispenser.sol/Dispenser.json'
import { LoggerInstance as logger, getFairGasPrice } from '../../utils/' import { LoggerInstance as logger, getFairGasPrice } from '../../utils/'
import { Datatoken } from '.../../../src/datatokens/' import { Datatoken } from '../../tokens'
export interface DispenserToken { export interface DispenserToken {
active: boolean active: boolean

View File

@ -1,8 +1,7 @@
import Web3 from 'web3' import Web3 from 'web3'
import { Config } from '../models' import { Config } from '../models'
import { LoggerInstance } from '../utils' import { LoggerInstance } from '../utils'
import { Asset } from '../ddo/Asset' import { Asset, FileMetadata } from '../@types/'
import { FileMetadata } from '../interfaces/FileMetadata'
import { noZeroX } from '../utils/ConversionTypeHelper' import { noZeroX } from '../utils/ConversionTypeHelper'
import { signText } from '../utils/SignatureUtils' import { signText } from '../utils/SignatureUtils'

View File

@ -1,7 +1,7 @@
import Web3 from 'web3' import Web3 from 'web3'
import { AbiItem } from 'web3-utils' import { AbiItem } from 'web3-utils'
import { TransactionReceipt } from 'web3-eth' import { TransactionReceipt } from 'web3-eth'
import defaultNFTDatatokenABI from '@oceanprotocol/contracts/artifacts/contracts/templates/ERC721Template.sol/ERC721Template.json' import defaultNFTABI from '@oceanprotocol/contracts/artifacts/contracts/templates/ERC721Template.sol/ERC721Template.json'
import { LoggerInstance, getFairGasPrice, generateDtName } from '../utils' import { LoggerInstance, getFairGasPrice, generateDtName } from '../utils'
import { Contract } from 'web3-eth-contract' import { Contract } from 'web3-eth-contract'
@ -15,16 +15,16 @@ interface Roles {
store: boolean store: boolean
} }
export class NFTDatatoken { export class NFT {
public GASLIMIT_DEFAULT = 1000000 public GASLIMIT_DEFAULT = 1000000
public factory721Address: string public factory721Address: string
public factory721ABI: AbiItem | AbiItem[] public factory721ABI: AbiItem | AbiItem[]
public nftDatatokenABI: AbiItem | AbiItem[] public nftABI: AbiItem | AbiItem[]
public web3: Web3 public web3: Web3
public startBlock: number public startBlock: number
constructor(web3: Web3, nftDatatokenABI?: AbiItem | AbiItem[], startBlock?: number) { constructor(web3: Web3, nftABI?: AbiItem | AbiItem[], startBlock?: number) {
this.nftDatatokenABI = nftDatatokenABI || (defaultNFTDatatokenABI.abi as AbiItem[]) this.nftABI = nftABI || (defaultNFTABI.abi as AbiItem[])
this.web3 = web3 this.web3 = web3
this.startBlock = startBlock || 0 this.startBlock = startBlock || 0
} }
@ -60,7 +60,7 @@ export class NFTDatatoken {
contractInstance?: Contract contractInstance?: Contract
): Promise<any> { ): Promise<any> {
const nftContract = const nftContract =
contractInstance || new this.web3.eth.Contract(this.nftDatatokenABI, nftAddress) contractInstance || new this.web3.eth.Contract(this.nftABI, nftAddress)
const gasLimitDefault = this.GASLIMIT_DEFAULT const gasLimitDefault = this.GASLIMIT_DEFAULT
let estGas let estGas
try { try {
@ -115,7 +115,7 @@ export class NFTDatatoken {
} }
// Create 721contract object // Create 721contract object
const nftContract = new this.web3.eth.Contract(this.nftDatatokenABI, nftAddress) const nftContract = new this.web3.eth.Contract(this.nftABI, nftAddress)
const estGas = await this.estGasCreateERC20( const estGas = await this.estGasCreateERC20(
nftAddress, nftAddress,
@ -171,7 +171,7 @@ export class NFTDatatoken {
contractInstance?: Contract contractInstance?: Contract
) { ) {
const nftContract = const nftContract =
contractInstance || new this.web3.eth.Contract(this.nftDatatokenABI, nftAddress) contractInstance || new this.web3.eth.Contract(this.nftABI, nftAddress)
const gasLimitDefault = this.GASLIMIT_DEFAULT const gasLimitDefault = this.GASLIMIT_DEFAULT
let estGas let estGas
@ -193,7 +193,7 @@ export class NFTDatatoken {
* @return {Promise<TransactionReceipt>} trxReceipt * @return {Promise<TransactionReceipt>} trxReceipt
*/ */
public async addManager(nftAddress: string, address: string, manager: string) { public async addManager(nftAddress: string, address: string, manager: string) {
const nftContract = new this.web3.eth.Contract(this.nftDatatokenABI, nftAddress) const nftContract = new this.web3.eth.Contract(this.nftABI, nftAddress)
if ((await this.getNFTOwner(nftAddress)) !== address) { if ((await this.getNFTOwner(nftAddress)) !== address) {
throw new Error(`Caller is not NFT Owner`) throw new Error(`Caller is not NFT Owner`)
@ -226,7 +226,7 @@ export class NFTDatatoken {
contractInstance?: Contract contractInstance?: Contract
) { ) {
const nftContract = const nftContract =
contractInstance || new this.web3.eth.Contract(this.nftDatatokenABI, nftAddress) contractInstance || new this.web3.eth.Contract(this.nftABI, nftAddress)
const gasLimitDefault = this.GASLIMIT_DEFAULT const gasLimitDefault = this.GASLIMIT_DEFAULT
let estGas let estGas
try { try {
@ -247,7 +247,7 @@ export class NFTDatatoken {
* @return {Promise<TransactionReceipt>} trxReceipt * @return {Promise<TransactionReceipt>} trxReceipt
*/ */
public async removeManager(nftAddress: string, address: string, manager: string) { public async removeManager(nftAddress: string, address: string, manager: string) {
const nftContract = new this.web3.eth.Contract(this.nftDatatokenABI, nftAddress) const nftContract = new this.web3.eth.Contract(this.nftABI, nftAddress)
if ((await this.getNFTOwner(nftAddress)) !== address) { if ((await this.getNFTOwner(nftAddress)) !== address) {
throw new Error(`Caller is not NFT Owner`) throw new Error(`Caller is not NFT Owner`)
@ -285,7 +285,7 @@ export class NFTDatatoken {
contractInstance?: Contract contractInstance?: Contract
): Promise<any> { ): Promise<any> {
const nftContract = const nftContract =
contractInstance || new this.web3.eth.Contract(this.nftDatatokenABI, nftAddress) contractInstance || new this.web3.eth.Contract(this.nftABI, nftAddress)
const gasLimitDefault = this.GASLIMIT_DEFAULT const gasLimitDefault = this.GASLIMIT_DEFAULT
let estGas let estGas
try { try {
@ -311,7 +311,7 @@ export class NFTDatatoken {
address: string, address: string,
erc20Deployer: string erc20Deployer: string
): Promise<TransactionReceipt> { ): Promise<TransactionReceipt> {
const nftContract = new this.web3.eth.Contract(this.nftDatatokenABI, nftAddress) const nftContract = new this.web3.eth.Contract(this.nftABI, nftAddress)
// if ((await this.getNFTPermissions(nftAddress, address)).manager !== true) { // if ((await this.getNFTPermissions(nftAddress, address)).manager !== true) {
// throw new Error(`Caller is not Manager`) // throw new Error(`Caller is not Manager`)
@ -352,7 +352,7 @@ export class NFTDatatoken {
contractInstance?: Contract contractInstance?: Contract
): Promise<any> { ): Promise<any> {
const nftContract = const nftContract =
contractInstance || new this.web3.eth.Contract(this.nftDatatokenABI, nftAddress) contractInstance || new this.web3.eth.Contract(this.nftABI, nftAddress)
const gasLimitDefault = this.GASLIMIT_DEFAULT const gasLimitDefault = this.GASLIMIT_DEFAULT
let estGas let estGas
@ -379,7 +379,7 @@ export class NFTDatatoken {
address: string, address: string,
erc20Deployer: string erc20Deployer: string
): Promise<TransactionReceipt> { ): Promise<TransactionReceipt> {
const nftContract = new this.web3.eth.Contract(this.nftDatatokenABI, nftAddress) const nftContract = new this.web3.eth.Contract(this.nftABI, nftAddress)
// if ((await this.getNFTPermissions(nftAddress, address)).manager !== true) { // if ((await this.getNFTPermissions(nftAddress, address)).manager !== true) {
// throw new Error(`Caller is not Manager`) // throw new Error(`Caller is not Manager`)
@ -419,7 +419,7 @@ export class NFTDatatoken {
contractInstance?: Contract contractInstance?: Contract
): Promise<any> { ): Promise<any> {
const nftContract = const nftContract =
contractInstance || new this.web3.eth.Contract(this.nftDatatokenABI, nftAddress) contractInstance || new this.web3.eth.Contract(this.nftABI, nftAddress)
const gasLimitDefault = this.GASLIMIT_DEFAULT const gasLimitDefault = this.GASLIMIT_DEFAULT
let estGas let estGas
@ -445,7 +445,7 @@ export class NFTDatatoken {
address: string, address: string,
metadataUpdater: string metadataUpdater: string
): Promise<TransactionReceipt> { ): Promise<TransactionReceipt> {
const nftContract = new this.web3.eth.Contract(this.nftDatatokenABI, nftAddress) const nftContract = new this.web3.eth.Contract(this.nftABI, nftAddress)
// if ((await this.getNFTPermissions(nftAddress, address)).manager !== true) { // if ((await this.getNFTPermissions(nftAddress, address)).manager !== true) {
// throw new Error(`Caller is not Manager`) // throw new Error(`Caller is not Manager`)
@ -483,7 +483,7 @@ export class NFTDatatoken {
contractInstance?: Contract contractInstance?: Contract
): Promise<any> { ): Promise<any> {
const nftContract = const nftContract =
contractInstance || new this.web3.eth.Contract(this.nftDatatokenABI, nftAddress) contractInstance || new this.web3.eth.Contract(this.nftABI, nftAddress)
const gasLimitDefault = this.GASLIMIT_DEFAULT const gasLimitDefault = this.GASLIMIT_DEFAULT
let estGas let estGas
@ -510,7 +510,7 @@ export class NFTDatatoken {
address: string, address: string,
metadataUpdater: string metadataUpdater: string
): Promise<TransactionReceipt> { ): Promise<TransactionReceipt> {
const nftContract = new this.web3.eth.Contract(this.nftDatatokenABI, nftAddress) const nftContract = new this.web3.eth.Contract(this.nftABI, nftAddress)
// if ((await this.getNFTPermissions(nftAddress, address)).manager !== true) { // if ((await this.getNFTPermissions(nftAddress, address)).manager !== true) {
// throw new Error(`Caller is not Manager`) // throw new Error(`Caller is not Manager`)
@ -550,7 +550,7 @@ export class NFTDatatoken {
contractInstance?: Contract contractInstance?: Contract
): Promise<any> { ): Promise<any> {
const nftContract = const nftContract =
contractInstance || new this.web3.eth.Contract(this.nftDatatokenABI, nftAddress) contractInstance || new this.web3.eth.Contract(this.nftABI, nftAddress)
const gasLimitDefault = this.GASLIMIT_DEFAULT const gasLimitDefault = this.GASLIMIT_DEFAULT
let estGas let estGas
@ -576,7 +576,7 @@ export class NFTDatatoken {
address: string, address: string,
storeUpdater: string storeUpdater: string
): Promise<TransactionReceipt> { ): Promise<TransactionReceipt> {
const nftContract = new this.web3.eth.Contract(this.nftDatatokenABI, nftAddress) const nftContract = new this.web3.eth.Contract(this.nftABI, nftAddress)
// if ((await this.getNFTPermissions(nftAddress, address)).manager !== true) { // if ((await this.getNFTPermissions(nftAddress, address)).manager !== true) {
// throw new Error(`Caller is not Manager`) // throw new Error(`Caller is not Manager`)
@ -614,7 +614,7 @@ export class NFTDatatoken {
contractInstance?: Contract contractInstance?: Contract
): Promise<any> { ): Promise<any> {
const nftContract = const nftContract =
contractInstance || new this.web3.eth.Contract(this.nftDatatokenABI, nftAddress) contractInstance || new this.web3.eth.Contract(this.nftABI, nftAddress)
const gasLimitDefault = this.GASLIMIT_DEFAULT const gasLimitDefault = this.GASLIMIT_DEFAULT
let estGas let estGas
@ -640,7 +640,7 @@ export class NFTDatatoken {
address: string, address: string,
storeUpdater: string storeUpdater: string
): Promise<TransactionReceipt> { ): Promise<TransactionReceipt> {
const nftContract = new this.web3.eth.Contract(this.nftDatatokenABI, nftAddress) const nftContract = new this.web3.eth.Contract(this.nftABI, nftAddress)
// if ((await this.getNFTPermissions(nftAddress, address)).manager !== true) { // if ((await this.getNFTPermissions(nftAddress, address)).manager !== true) {
// throw new Error(`Caller is not Manager`) // throw new Error(`Caller is not Manager`)
@ -678,7 +678,7 @@ export class NFTDatatoken {
contractInstance?: Contract contractInstance?: Contract
): Promise<any> { ): Promise<any> {
const nftContract = const nftContract =
contractInstance || new this.web3.eth.Contract(this.nftDatatokenABI, nftAddress) contractInstance || new this.web3.eth.Contract(this.nftABI, nftAddress)
const gasLimitDefault = this.GASLIMIT_DEFAULT const gasLimitDefault = this.GASLIMIT_DEFAULT
let estGas let estGas
@ -706,7 +706,7 @@ export class NFTDatatoken {
nftAddress: string, nftAddress: string,
address: string address: string
): Promise<TransactionReceipt> { ): Promise<TransactionReceipt> {
const nftContract = new this.web3.eth.Contract(this.nftDatatokenABI, nftAddress) const nftContract = new this.web3.eth.Contract(this.nftABI, nftAddress)
if ((await this.getNFTOwner(nftAddress)) !== address) { if ((await this.getNFTOwner(nftAddress)) !== address) {
throw new Error(`Caller is not NFT Owner`) throw new Error(`Caller is not NFT Owner`)
@ -741,7 +741,7 @@ export class NFTDatatoken {
contractInstance?: Contract contractInstance?: Contract
): Promise<any> { ): Promise<any> {
const nftContract = const nftContract =
contractInstance || new this.web3.eth.Contract(this.nftDatatokenABI, nftAddress) contractInstance || new this.web3.eth.Contract(this.nftABI, nftAddress)
const gasLimitDefault = this.GASLIMIT_DEFAULT const gasLimitDefault = this.GASLIMIT_DEFAULT
let estGas let estGas
@ -773,7 +773,7 @@ export class NFTDatatoken {
nftReceiver: string, nftReceiver: string,
tokenId?: number tokenId?: number
): Promise<TransactionReceipt> { ): Promise<TransactionReceipt> {
const nftContract = new this.web3.eth.Contract(this.nftDatatokenABI, nftAddress) const nftContract = new this.web3.eth.Contract(this.nftABI, nftAddress)
if ((await this.getNFTOwner(nftAddress)) !== nftOwner) { if ((await this.getNFTOwner(nftAddress)) !== nftOwner) {
throw new Error(`Caller is not NFT Owner`) throw new Error(`Caller is not NFT Owner`)
@ -818,7 +818,7 @@ export class NFTDatatoken {
contractInstance?: Contract contractInstance?: Contract
): Promise<any> { ): Promise<any> {
const nftContract = const nftContract =
contractInstance || new this.web3.eth.Contract(this.nftDatatokenABI, nftAddress) contractInstance || new this.web3.eth.Contract(this.nftABI, nftAddress)
const gasLimitDefault = this.GASLIMIT_DEFAULT const gasLimitDefault = this.GASLIMIT_DEFAULT
let estGas let estGas
@ -850,7 +850,7 @@ export class NFTDatatoken {
nftReceiver: string, nftReceiver: string,
tokenId?: number tokenId?: number
): Promise<TransactionReceipt> { ): Promise<TransactionReceipt> {
const nftContract = new this.web3.eth.Contract(this.nftDatatokenABI, nftAddress) const nftContract = new this.web3.eth.Contract(this.nftABI, nftAddress)
if ((await this.getNFTOwner(nftAddress)) !== nftOwner) { if ((await this.getNFTOwner(nftAddress)) !== nftOwner) {
throw new Error(`Caller is not NFT Owner`) throw new Error(`Caller is not NFT Owner`)
@ -899,7 +899,7 @@ export class NFTDatatoken {
contractInstance?: Contract contractInstance?: Contract
): Promise<any> { ): Promise<any> {
const nftContract = const nftContract =
contractInstance || new this.web3.eth.Contract(this.nftDatatokenABI, nftAddress) contractInstance || new this.web3.eth.Contract(this.nftABI, nftAddress)
const gasLimitDefault = this.GASLIMIT_DEFAULT const gasLimitDefault = this.GASLIMIT_DEFAULT
let estGas let estGas
@ -942,7 +942,7 @@ export class NFTDatatoken {
data: string, data: string,
metadataHash: string metadataHash: string
): Promise<TransactionReceipt> { ): Promise<TransactionReceipt> {
const nftContract = new this.web3.eth.Contract(this.nftDatatokenABI, nftAddress) const nftContract = new this.web3.eth.Contract(this.nftABI, nftAddress)
// if (!(await this.getNFTPermissions(nftAddress, address)).updateMetadata) { // if (!(await this.getNFTPermissions(nftAddress, address)).updateMetadata) {
// throw new Error(`Caller is not NFT Owner`) // throw new Error(`Caller is not NFT Owner`)
@ -984,7 +984,7 @@ export class NFTDatatoken {
* @return {Promise<string>} string * @return {Promise<string>} string
*/ */
public async getNFTOwner(nftAddress: string): Promise<string> { public async getNFTOwner(nftAddress: string): Promise<string> {
const nftContract = new this.web3.eth.Contract(this.nftDatatokenABI, nftAddress) const nftContract = new this.web3.eth.Contract(this.nftABI, nftAddress)
const trxReceipt = await nftContract.methods.ownerOf(1).call() const trxReceipt = await nftContract.methods.ownerOf(1).call()
return trxReceipt return trxReceipt
} }
@ -995,7 +995,7 @@ export class NFTDatatoken {
* @return {Promise<Roles>} * @return {Promise<Roles>}
*/ */
public async getNFTPermissions(nftAddress: string, address: string): Promise<Roles> { public async getNFTPermissions(nftAddress: string, address: string): Promise<Roles> {
const nftContract = new this.web3.eth.Contract(this.nftDatatokenABI, nftAddress) const nftContract = new this.web3.eth.Contract(this.nftABI, nftAddress)
const roles = await nftContract.methods.getPermissions(address).call() const roles = await nftContract.methods.getPermissions(address).call()
return roles return roles
} }
@ -1006,7 +1006,7 @@ export class NFTDatatoken {
* @return {Promise<Roles>} * @return {Promise<Roles>}
*/ */
public async isErc20Deployer(nftAddress: string, address: string): Promise<boolean> { public async isErc20Deployer(nftAddress: string, address: string): Promise<boolean> {
const nftContract = new this.web3.eth.Contract(this.nftDatatokenABI, nftAddress) const nftContract = new this.web3.eth.Contract(this.nftABI, nftAddress)
const isERC20Deployer = await nftContract.methods.isERC20Deployer(address).call() const isERC20Deployer = await nftContract.methods.isERC20Deployer(address).call()
return isERC20Deployer return isERC20Deployer
} }
@ -1017,7 +1017,7 @@ export class NFTDatatoken {
* @return {Promise<string>} The data stored at the key * @return {Promise<string>} The data stored at the key
*/ */
public async getData(nftAddress: string, key: string): Promise<string> { public async getData(nftAddress: string, key: string): Promise<string> {
const nftContract = new this.web3.eth.Contract(this.nftDatatokenABI, nftAddress) const nftContract = new this.web3.eth.Contract(this.nftABI, nftAddress)
const data = await nftContract.methods.getData(key).call() const data = await nftContract.methods.getData(key).call()
return data return data
} }

2
src/tokens/index.ts Normal file
View File

@ -0,0 +1,2 @@
export * from './Datatoken'
export * from './NFT'

View File

@ -12,7 +12,7 @@ import MockERC20 from '@oceanprotocol/contracts/artifacts/contracts/utils/mock/M
import PoolTemplate from '@oceanprotocol/contracts/artifacts/contracts/pools/balancer/BPool.sol/BPool.json' import PoolTemplate from '@oceanprotocol/contracts/artifacts/contracts/pools/balancer/BPool.sol/BPool.json'
import OPFCollector from '@oceanprotocol/contracts/artifacts/contracts/communityFee/OPFCommunityFeeCollector.sol/OPFCommunityFeeCollector.json' import OPFCollector from '@oceanprotocol/contracts/artifacts/contracts/communityFee/OPFCommunityFeeCollector.sol/OPFCommunityFeeCollector.json'
import { NFTFactory, NFTCreateData } from '../../../../src/factories/' import { NFTFactory, NFTCreateData } from '../../../../src/factories/'
import { Datatoken, DispenserParams } from '../../../../src/datatokens/' import { Datatoken, DispenserParams } from '../../../../src/tokens/'
import { Dispenser } from '../../../../src/pools/dispenser/' import { Dispenser } from '../../../../src/pools/dispenser/'
import { TestContractHandler } from '../../../TestContractHandler' import { TestContractHandler } from '../../../TestContractHandler'
import { Erc20CreateParams } from '../../../../src/interfaces' import { Erc20CreateParams } from '../../../../src/interfaces'

View File

@ -14,12 +14,7 @@ import MockERC20 from '@oceanprotocol/contracts/artifacts/contracts/utils/mock/M
import { TestContractHandler } from '../../TestContractHandler' import { TestContractHandler } from '../../TestContractHandler'
import { NFTFactory, NFTCreateData } from '../../../src/factories/NFTFactory' import { NFTFactory, NFTCreateData } from '../../../src/factories/NFTFactory'
import { import { Datatoken, NFT, OrderParams, DispenserParams } from '../../../src/tokens'
Datatoken,
NFTDatatoken,
OrderParams,
DispenserParams
} from '../../../src/datatokens'
import { AbiItem } from 'web3-utils' import { AbiItem } from 'web3-utils'
import { LoggerInstance } from '../../../src/utils' import { LoggerInstance } from '../../../src/utils'
import { FreCreationParams, FreOrderParams } from '../../../src/interfaces' import { FreCreationParams, FreOrderParams } from '../../../src/interfaces'
@ -32,7 +27,7 @@ describe('Datatoken', () => {
let user2: string let user2: string
let user3: string let user3: string
let contractHandler: TestContractHandler let contractHandler: TestContractHandler
let nftDatatoken: NFTDatatoken let nftDatatoken: NFT
let datatoken: Datatoken let datatoken: Datatoken
let nftFactory: NFTFactory let nftFactory: NFTFactory
let nftAddress: string let nftAddress: string
@ -96,7 +91,7 @@ describe('Datatoken', () => {
} }
nftAddress = await nftFactory.createNFT(nftOwner, nftData) nftAddress = await nftFactory.createNFT(nftOwner, nftData)
nftDatatoken = new NFTDatatoken(web3, ERC721Template.abi as AbiItem[]) nftDatatoken = new NFT(web3, ERC721Template.abi as AbiItem[])
}) })
it('#createERC20 - should create a new ERC20 DT from NFT contract', async () => { it('#createERC20 - should create a new ERC20 DT from NFT contract', async () => {

View File

@ -10,23 +10,20 @@ import ERC20Template from '@oceanprotocol/contracts/artifacts/contracts/template
import Dispenser from '@oceanprotocol/contracts/artifacts/contracts/pools/dispenser/Dispenser.sol/Dispenser.json' import Dispenser from '@oceanprotocol/contracts/artifacts/contracts/pools/dispenser/Dispenser.sol/Dispenser.json'
import FixedRate from '@oceanprotocol/contracts/artifacts/contracts/pools/fixedRate/FixedRateExchange.sol/FixedRateExchange.json' import FixedRate from '@oceanprotocol/contracts/artifacts/contracts/pools/fixedRate/FixedRateExchange.sol/FixedRateExchange.json'
import OPFCollector from '@oceanprotocol/contracts/artifacts/contracts/communityFee/OPFCommunityFeeCollector.sol/OPFCommunityFeeCollector.json' import OPFCollector from '@oceanprotocol/contracts/artifacts/contracts/communityFee/OPFCommunityFeeCollector.sol/OPFCommunityFeeCollector.json'
import MockERC20 from '@oceanprotocol/contracts/artifacts/contracts/utils/mock/MockERC20Decimals.sol/MockERC20Decimals.json'
import { TestContractHandler } from '../../TestContractHandler' import { TestContractHandler } from '../../TestContractHandler'
import { NFTFactory, NFTCreateData } from '../../../src/factories/NFTFactory' import { NFTFactory, NFTCreateData } from '../../../src/factories/NFTFactory'
import { NFTDatatoken } from '../../../src/datatokens/NFTDatatoken' import { NFT } from '../../../src/tokens/NFT'
import { AbiItem } from 'web3-utils' import { AbiItem } from 'web3-utils'
import { LoggerInstance } from '../../../src/utils'
const web3 = new Web3('http://127.0.0.1:8545') const web3 = new Web3('http://127.0.0.1:8545')
describe('NFTDatatoken', () => { describe('NFT', () => {
let nftOwner: string let nftOwner: string
let user1: string let user1: string
let user2: string let user2: string
let user3: string let user3: string
let contractHandler: TestContractHandler let contractHandler: TestContractHandler
let nftDatatoken: NFTDatatoken let nftDatatoken: NFT
let nftFactory: NFTFactory let nftFactory: NFTFactory
let nftAddress: string let nftAddress: string
@ -80,7 +77,7 @@ describe('NFTDatatoken', () => {
} }
nftAddress = await nftFactory.createNFT(nftOwner, nftData) nftAddress = await nftFactory.createNFT(nftOwner, nftData)
nftDatatoken = new NFTDatatoken(web3, ERC721Template.abi as AbiItem[]) nftDatatoken = new NFT(web3, ERC721Template.abi as AbiItem[])
}) })
it('#createERC20 - should create a new ERC20 DT from NFT contract', async () => { it('#createERC20 - should create a new ERC20 DT from NFT contract', async () => {