mirror of
https://github.com/oceanprotocol/ocean.js.git
synced 2024-11-26 20:39:05 +01:00
Merge branch 'v4main' into feature/SideStaking
This commit is contained in:
commit
272fb9a17c
41892
package-lock.json
generated
41892
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@ -27,6 +27,8 @@
|
||||
"test:ss": "mocha --config=test/unit/.mocharc.json --node-env=test --exit 'test/unit/pools/ssContracts/SideStaking.test.ts'",
|
||||
"test:fixed": "mocha --config=test/unit/.mocharc.json --node-env=test --exit 'test/unit/pools/fixedRate/FixedRateExchange.test.ts'",
|
||||
"test:pool": "mocha --config=test/unit/.mocharc.json --node-env=test --exit 'test/unit/pools/balancer/Pool.test.ts'",
|
||||
"test:dt": "mocha --config=test/unit/.mocharc.json --node-env=test --exit 'test/unit/Datatoken.test.ts'",
|
||||
"test:nftDt": "mocha --config=test/unit/.mocharc.json --node-env=test --exit 'test/unit/NFTDatatoken.test.ts'",
|
||||
"test:router": "mocha --config=test/unit/.mocharc.json --node-env=test --exit 'test/unit/pools/Router.test.ts'",
|
||||
"test:unit": "mocha --config=test/unit/.mocharc.json --node-env=test --exit 'test/unit/**/*.test.ts'",
|
||||
"test:unit:cover": "nyc --report-dir coverage/unit npm run test:unit",
|
||||
@ -49,7 +51,7 @@
|
||||
},
|
||||
"dependencies": {
|
||||
"@ethereum-navigator/navigator": "^0.5.3",
|
||||
"@oceanprotocol/contracts": "https://github.com/oceanprotocol/contracts#v4main",
|
||||
"@oceanprotocol/contracts": "github:oceanprotocol/contracts#v4main",
|
||||
"cross-fetch": "^3.1.4",
|
||||
"crypto-js": "^4.0.0",
|
||||
"decimal.js": "^10.2.1",
|
||||
@ -57,6 +59,7 @@
|
||||
"lzma": "^2.3.2",
|
||||
"node-abort-controller": "^2.0.0",
|
||||
"save-file": "^2.3.1",
|
||||
"underscore": "^1.13.1",
|
||||
"uuid": "^8.3.2",
|
||||
"web3": ">=1.3.5",
|
||||
"web3-core": "^1.5.3",
|
||||
|
@ -1,108 +0,0 @@
|
||||
{
|
||||
"rinkeby": {
|
||||
"DTFactory": "0x3fd7A00106038Fb5c802c6d63fa7147Fe429E83a",
|
||||
"BFactory": "0x53eDF9289B0898e1652Ce009AACf8D25fA9A42F8",
|
||||
"FixedRateExchange": "0xeD1DfC5F3a589CfC4E8B91C1fbfC18FC6699Fbde",
|
||||
"Metadata": "0xFD8a7b6297153397B7eb4356C47dbd381d58bFF4",
|
||||
"Ocean": "0x8967BCF84170c91B0d24D4302C2376283b0B3a07",
|
||||
"Dispenser": "0x623744Cd25Ed553d3b4722667697F926cf99658B",
|
||||
"chainId": 4,
|
||||
"startBlock": 7294090
|
||||
},
|
||||
"ropsten": {
|
||||
"DTFactory": "0x6ebcCa6df2CAba986FCF44E64Ee82251c1455Dcc",
|
||||
"BFactory": "0x75be6e18c80A487C8b49663bf14f80A6495045B2",
|
||||
"FixedRateExchange": "0xA7a711A09396DF82D9be46A26B48BafdB9BB4fA6",
|
||||
"Metadata": "0x3cd7Ef1F207E1a46AAd7D5d7F5f0A5cF081Fc726",
|
||||
"Ocean": "0x5e8DCB2AfA23844bcc311B00Ad1A0C30025aADE9",
|
||||
"Dispenser": "0xc37F8341Ac6e4a94538302bCd4d49Cf0852D30C0",
|
||||
"chainId": 3,
|
||||
"startBlock": 9227563
|
||||
},
|
||||
"development": {
|
||||
"Ocean": "0x84eA74d481Ee0A5332c457a4d796187F6Ba67fEB",
|
||||
"OPFCommunityFeeCollector": "0x9E545E3C0baAB3E08CdfD552C960A1050f373042",
|
||||
"chainId": 31337,
|
||||
"startBlock": 0,
|
||||
"v4": {
|
||||
"Metadata": "0x851356ae760d987E095750cCeb3bC6014560891C",
|
||||
"ERC721Factory": "0x95401dc811bb5740090279Ba06cfA8fcF6113778",
|
||||
"ERC20Template": "0xa82fF9aFd8f496c3d6ac40E2a0F282E47488CFc9",
|
||||
"ERC721Template": "0xf5059a5D33d5853360D16C683c16e67980206f36",
|
||||
"Router": "0xc3e53F4d16Ae77Db1c982e75a937B9f60FE63690",
|
||||
"FixedPrice": "0x84eA74d481Ee0A5332c457a4d796187F6Ba67fEB",
|
||||
"Staking": "0x9E545E3C0baAB3E08CdfD552C960A1050f373042",
|
||||
"poolTemplate": "0xE6E340D132b5f46d1e472DebcD681B2aBc16e57E"
|
||||
},
|
||||
"v3": {}
|
||||
},
|
||||
"mainnet": {
|
||||
"DTFactory": "0x57317f97E9EA49eBd19f7c9bB7c180b8cDcbDeB9",
|
||||
"BFactory": "0xbe0083053744ECb871510C88dC0f6b77Da162706",
|
||||
"FixedRateExchange": "0x608d05214E42722B94a54cF6114d4840FCfF84e1",
|
||||
"Metadata": "0x1a4b70d8c9DcA47cD6D0Fb3c52BB8634CA1C0Fdf",
|
||||
"Ocean": "0x967da4048cD07aB37855c090aAF366e4ce1b9F48",
|
||||
"Dispenser": "0xDEfD0018969cd2d4E648209F876ADe184815f038",
|
||||
"chainId": 1,
|
||||
"startBlock": 11005222
|
||||
},
|
||||
"polygon": {
|
||||
"DTFactory": "0xF6410bf5d773C7a41ebFf972f38e7463FA242477",
|
||||
"BFactory": "0x69B6E54Ad2b3c2801d11d8Ad56ea1d892555b776",
|
||||
"FixedRateExchange": "0x2112Eb973af1DBf83a4f11eda82f7a7527D7Fde5",
|
||||
"Metadata": "0x80E63f73cAc60c1662f27D2DFd2EA834acddBaa8",
|
||||
"Ocean": "0x282d8efCe846A88B159800bd4130ad77443Fa1A1",
|
||||
"Dispenser": "0x30E4CC2C7A9c6aA2b2Ce93586E3Df24a3A00bcDD",
|
||||
"chainId": 137,
|
||||
"startBlock": 11005222
|
||||
},
|
||||
"moonbeamalpha": {
|
||||
"DTFactory": "0x80E63f73cAc60c1662f27D2DFd2EA834acddBaa8",
|
||||
"BFactory": "0x30E4CC2C7A9c6aA2b2Ce93586E3Df24a3A00bcDD",
|
||||
"FixedRateExchange": "0xDEfD0018969cd2d4E648209F876ADe184815f038",
|
||||
"Metadata": "0x9C9eE07b8Ce907D2f9244F8317C1Ed29A3193bAe",
|
||||
"Ocean": "0x3c21a90599b5B7f37014cA5Bf30d3f1b73d7e391",
|
||||
"Dispenser": "0x042D709b72B437d7d387F2679bD4ac060e561c9f",
|
||||
"chainId": 1287,
|
||||
"startBlock": 90707
|
||||
},
|
||||
"undefined": {
|
||||
"DTFactory": "0xC54b688d81b6B3bab9834D9D7afd8655641EEdA7",
|
||||
"BFactory": "0x082DD8b8A6eD335364739004280bD4eF41cB6Bd9",
|
||||
"FixedRateExchange": "0x19dcb303B4b56e7983b7F441696B326264c9008c",
|
||||
"Metadata": "0x5F71F2ffF1639D927d43e4965C2EC6cCe9505222",
|
||||
"Dispenser": "0xA4eD47bCAAe977fB1AE39A5DF905AC7420a5e095",
|
||||
"chainId": 0,
|
||||
"startBlock": 0
|
||||
},
|
||||
"gaiaxtestnet": {
|
||||
"DTFactory": "0x2720d405ef7cDC8a2E2e5AeBC8883C99611d893C",
|
||||
"BFactory": "0xc37F8341Ac6e4a94538302bCd4d49Cf0852D30C0",
|
||||
"FixedRateExchange": "0x3c21a90599b5B7f37014cA5Bf30d3f1b73d7e391",
|
||||
"Metadata": "0xCfDdA22C9837aE76E0faA845354f33C62E03653a",
|
||||
"Dispenser": "0x4E6058dC00e90C0DCA47A5d0D3346F409939A5ab",
|
||||
"Ocean": "0x80E63f73cAc60c1662f27D2DFd2EA834acddBaa8",
|
||||
"chainId": 2021000,
|
||||
"startBlock": 177644
|
||||
},
|
||||
"mumbai": {
|
||||
"DTFactory": "0x4E6058dC00e90C0DCA47A5d0D3346F409939A5ab",
|
||||
"BFactory": "0x159924ca0F47D6F704B97E29099b89e518A17B5E",
|
||||
"FixedRateExchange": "0xc313e19146Fc9a04470689C9d41a4D3054693531",
|
||||
"Metadata": "0x98679D582AB3398C03D3308dEB9c7AeC50B52ded",
|
||||
"Dispenser": "0x1d535147a97bd87c8443125376E6671B60556E07",
|
||||
"Ocean": "0xd8992Ed72C445c35Cb4A2be468568Ed1079357c8",
|
||||
"chainId": 80001,
|
||||
"startBlock": 14791845
|
||||
},
|
||||
"bsc": {
|
||||
"DTFactory": "0xE9397625Df9B63f0C152f975234b7988b54710B8",
|
||||
"BFactory": "0xc313e19146Fc9a04470689C9d41a4D3054693531",
|
||||
"FixedRateExchange": "0x98679D582AB3398C03D3308dEB9c7AeC50B52ded",
|
||||
"Metadata": "0x1d535147a97bd87c8443125376E6671B60556E07",
|
||||
"Dispenser": "0xFe7967A5176fDAFa8DE109b3507016B885a82D6e",
|
||||
"Ocean": "0xdce07662ca8ebc241316a15b611c89711414dd1a",
|
||||
"chainId": 56,
|
||||
"startBlock": 8114772
|
||||
}
|
||||
}
|
1203
src/datatokens/Datatoken.ts
Normal file
1203
src/datatokens/Datatoken.ts
Normal file
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@ -1 +1,2 @@
|
||||
export * from './Datatoken'
|
||||
export * from './NFTDatatoken'
|
||||
|
@ -1,17 +1,24 @@
|
||||
import { Contract } from 'web3-eth-contract'
|
||||
import Web3 from 'web3'
|
||||
import BigNumber from 'bignumber.js'
|
||||
import { TransactionReceipt } from 'web3-core'
|
||||
import { AbiItem } from 'web3-utils'
|
||||
import defaultFactory721ABI from '@oceanprotocol/contracts/artifacts/contracts/ERC721Factory.sol/ERC721Factory.json'
|
||||
import { Logger, getFairGasPrice, generateDtName } from '../utils'
|
||||
import {
|
||||
LoggerInstance,
|
||||
getFairGasPrice,
|
||||
generateDtName,
|
||||
getFreCreationParams,
|
||||
getErcCreationParams,
|
||||
getPoolCreationParams
|
||||
} from '../utils'
|
||||
import { FreCreationParams, Erc20CreateParams, PoolCreationParams } from '../interfaces'
|
||||
|
||||
interface Template {
|
||||
templateAddress: string
|
||||
isActive: boolean
|
||||
}
|
||||
|
||||
interface TokenOrder {
|
||||
export interface TokenOrder {
|
||||
tokenAddress: string
|
||||
consumer: string
|
||||
amount: string | number
|
||||
@ -21,32 +28,13 @@ interface TokenOrder {
|
||||
consumeFeeAmount: number
|
||||
}
|
||||
|
||||
interface NFTCreateData {
|
||||
export interface NFTCreateData {
|
||||
name: string
|
||||
symbol: string
|
||||
templateIndex: number
|
||||
baseURI: string
|
||||
}
|
||||
|
||||
interface ErcCreateData {
|
||||
templateIndex: number
|
||||
strings: string[]
|
||||
addresses: string[]
|
||||
uints: (string | number)[]
|
||||
bytess: string[]
|
||||
}
|
||||
|
||||
interface PoolData {
|
||||
addresses: string[]
|
||||
ssParams: (string | number | BigNumber)[]
|
||||
swapFees: number[]
|
||||
}
|
||||
|
||||
interface FixedData {
|
||||
fixedPriceAddress: string
|
||||
addresses: string[]
|
||||
uints: (string | number)[]
|
||||
}
|
||||
/**
|
||||
* Provides an interface for NFT Factory contract
|
||||
*/
|
||||
@ -55,7 +43,6 @@ export class NFTFactory {
|
||||
public factory721Address: string
|
||||
public factory721ABI: AbiItem | AbiItem[]
|
||||
public web3: Web3
|
||||
private logger: Logger
|
||||
public startBlock: number
|
||||
public factory721: Contract
|
||||
|
||||
@ -68,14 +55,12 @@ export class NFTFactory {
|
||||
constructor(
|
||||
factory721Address: string,
|
||||
web3: Web3,
|
||||
logger: Logger,
|
||||
factory721ABI?: AbiItem | AbiItem[],
|
||||
startBlock?: number
|
||||
) {
|
||||
this.factory721Address = factory721Address
|
||||
this.factory721ABI = factory721ABI || (defaultFactory721ABI.abi as AbiItem[])
|
||||
this.web3 = web3
|
||||
this.logger = logger
|
||||
this.startBlock = startBlock || 0
|
||||
this.factory721 = new this.web3.eth.Contract(
|
||||
this.factory721ABI,
|
||||
@ -84,39 +69,56 @@ export class NFTFactory {
|
||||
}
|
||||
|
||||
/**
|
||||
* Create new NFT
|
||||
* Get estimated gas cost for deployERC721Contract value
|
||||
* @param {String} address
|
||||
* @param {String} name Token name
|
||||
* @param {String} symbol Token symbol
|
||||
* @param {Number} templateIndex NFT template index
|
||||
* @param {String} nftData
|
||||
* @return {Promise<string>} NFT datatoken address
|
||||
*/
|
||||
public async createNFT(
|
||||
address: string,
|
||||
name?: string,
|
||||
symbol?: string,
|
||||
templateIndex?: number
|
||||
): Promise<string> {
|
||||
if (!templateIndex) templateIndex = 1
|
||||
// Generate name & symbol if not present
|
||||
if (!name || !symbol) {
|
||||
;({ name, symbol } = generateDtName())
|
||||
}
|
||||
|
||||
// Get estimated gas value
|
||||
public async estGasCreateNFT(address: string, nftData: NFTCreateData): Promise<string> {
|
||||
const gasLimitDefault = this.GASLIMIT_DEFAULT
|
||||
let estGas
|
||||
try {
|
||||
estGas = await this.factory721.methods
|
||||
.deployERC721Contract(name, symbol, templateIndex, null)
|
||||
.deployERC721Contract(
|
||||
nftData.name,
|
||||
nftData.symbol,
|
||||
nftData.templateIndex,
|
||||
'0x0000000000000000000000000000000000000000',
|
||||
nftData.baseURI
|
||||
)
|
||||
.estimateGas({ from: address }, (err, estGas) => (err ? gasLimitDefault : estGas))
|
||||
} catch (e) {
|
||||
estGas = gasLimitDefault
|
||||
}
|
||||
return estGas
|
||||
}
|
||||
|
||||
/**
|
||||
* Create new NFT
|
||||
* @param {String} address
|
||||
* @param {NFTCreateData} nftData
|
||||
* @return {Promise<string>} NFT datatoken address
|
||||
*/
|
||||
public async createNFT(address: string, nftData: NFTCreateData): Promise<string> {
|
||||
if (!nftData.templateIndex) nftData.templateIndex = 1
|
||||
|
||||
if (!nftData.name || !nftData.symbol) {
|
||||
const { name, symbol } = generateDtName()
|
||||
nftData.name = name
|
||||
nftData.symbol = symbol
|
||||
}
|
||||
|
||||
const estGas = await this.estGasCreateNFT(address, nftData)
|
||||
|
||||
// Invoke createToken function of the contract
|
||||
const trxReceipt = await this.factory721.methods
|
||||
.deployERC721Contract(name, symbol, templateIndex, null)
|
||||
.deployERC721Contract(
|
||||
nftData.name,
|
||||
nftData.symbol,
|
||||
nftData.templateIndex,
|
||||
'0x0000000000000000000000000000000000000000',
|
||||
nftData.baseURI
|
||||
)
|
||||
.send({
|
||||
from: address,
|
||||
gas: estGas + 1,
|
||||
@ -125,9 +127,9 @@ export class NFTFactory {
|
||||
|
||||
let tokenAddress = null
|
||||
try {
|
||||
tokenAddress = trxReceipt.events.TokenCreated.returnValues[0]
|
||||
tokenAddress = trxReceipt.events.NFTCreated.returnValues[0]
|
||||
} catch (e) {
|
||||
this.logger.error(`ERROR: Failed to create datatoken : ${e.message}`)
|
||||
LoggerInstance.error(`ERROR: Failed to create datatoken : ${e.message}`)
|
||||
}
|
||||
return tokenAddress
|
||||
}
|
||||
@ -208,6 +210,28 @@ export class NFTFactory {
|
||||
return confirmAddress
|
||||
}
|
||||
|
||||
/**
|
||||
* Estimate gas cost for add721TokenTemplate method
|
||||
* @param {String} address
|
||||
* @param {String} templateAddress template address to add
|
||||
* @return {Promise<TransactionReceipt>}
|
||||
*/
|
||||
public async estGasAddNFTTemplate(
|
||||
address: string,
|
||||
templateAddress: string
|
||||
): Promise<any> {
|
||||
const gasLimitDefault = this.GASLIMIT_DEFAULT
|
||||
let estGas
|
||||
try {
|
||||
estGas = await this.factory721.methods
|
||||
.add721TokenTemplate(templateAddress)
|
||||
.estimateGas({ from: address }, (err, estGas) => (err ? gasLimitDefault : estGas))
|
||||
} catch (e) {
|
||||
estGas = gasLimitDefault
|
||||
}
|
||||
return estGas
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a new erc721 token template - only factory Owner
|
||||
* @param {String} address
|
||||
@ -222,17 +246,9 @@ export class NFTFactory {
|
||||
throw new Error(`Caller is not Factory Owner`)
|
||||
}
|
||||
|
||||
const gasLimitDefault = this.GASLIMIT_DEFAULT
|
||||
let estGas
|
||||
try {
|
||||
estGas = await this.factory721.methods
|
||||
.add721TokenTemplate(templateAddress)
|
||||
.estimateGas({ from: address }, (err, estGas) => (err ? gasLimitDefault : estGas))
|
||||
} catch (e) {
|
||||
estGas = gasLimitDefault
|
||||
}
|
||||
const estGas = await this.estGasAddNFTTemplate(address, templateAddress)
|
||||
|
||||
// Invoke createToken function of the contract
|
||||
// Invoke add721TokenTemplate function of the contract
|
||||
const trxReceipt = await this.factory721.methods
|
||||
.add721TokenTemplate(templateAddress)
|
||||
.send({
|
||||
@ -244,6 +260,28 @@ export class NFTFactory {
|
||||
return trxReceipt
|
||||
}
|
||||
|
||||
/**
|
||||
* Estimate gas cost for disable721TokenTemplate method
|
||||
* @param {String} address
|
||||
* @param {Number} templateIndex index of the template we want to disable
|
||||
* @return {Promise<TransactionReceipt>} current token template count
|
||||
*/
|
||||
public async estGasDisableNFTTemplate(
|
||||
address: string,
|
||||
templateIndex: number
|
||||
): Promise<any> {
|
||||
const gasLimitDefault = this.GASLIMIT_DEFAULT
|
||||
let estGas
|
||||
try {
|
||||
estGas = await this.factory721.methods
|
||||
.disable721TokenTemplate(templateIndex)
|
||||
.estimateGas({ from: address }, (err, estGas) => (err ? gasLimitDefault : estGas))
|
||||
} catch (e) {
|
||||
estGas = gasLimitDefault
|
||||
}
|
||||
return estGas
|
||||
}
|
||||
|
||||
/**
|
||||
* Disable token template - only factory Owner
|
||||
* @param {String} address
|
||||
@ -258,15 +296,7 @@ export class NFTFactory {
|
||||
throw new Error(`Caller is not Factory Owner`)
|
||||
}
|
||||
|
||||
const gasLimitDefault = this.GASLIMIT_DEFAULT
|
||||
let estGas
|
||||
try {
|
||||
estGas = await this.factory721.methods
|
||||
.disable721TokenTemplate(templateIndex)
|
||||
.estimateGas({ from: address }, (err, estGas) => (err ? gasLimitDefault : estGas))
|
||||
} catch (e) {
|
||||
estGas = gasLimitDefault
|
||||
}
|
||||
const estGas = await this.estGasDisableNFTTemplate(address, templateIndex)
|
||||
|
||||
// Invoke createToken function of the contract
|
||||
const trxReceipt = await this.factory721.methods
|
||||
@ -286,14 +316,10 @@ export class NFTFactory {
|
||||
* @param {Number} templateIndex index of the template we want to reactivate
|
||||
* @return {Promise<TransactionReceipt>} current token template count
|
||||
*/
|
||||
public async reactivateNFTTemplate(
|
||||
public async estGasReactivateNFTTemplate(
|
||||
address: string,
|
||||
templateIndex: number
|
||||
): Promise<TransactionReceipt> {
|
||||
if ((await this.getOwner()) !== address) {
|
||||
throw new Error(`Caller is not Factory Owner`)
|
||||
}
|
||||
|
||||
): Promise<any> {
|
||||
const gasLimitDefault = this.GASLIMIT_DEFAULT
|
||||
let estGas
|
||||
try {
|
||||
@ -303,6 +329,24 @@ export class NFTFactory {
|
||||
} catch (e) {
|
||||
estGas = gasLimitDefault
|
||||
}
|
||||
return estGas
|
||||
}
|
||||
|
||||
/**
|
||||
* Reactivate a previously disabled token template - only factory Owner
|
||||
* @param {String} address
|
||||
* @param {Number} templateIndex index of the template we want to reactivate
|
||||
* @return {Promise<TransactionReceipt>} current token template count
|
||||
*/
|
||||
public async reactivateNFTTemplate(
|
||||
address: string,
|
||||
templateIndex: number
|
||||
): Promise<TransactionReceipt> {
|
||||
if ((await this.getOwner()) !== address) {
|
||||
throw new Error(`Caller is not Factory Owner`)
|
||||
}
|
||||
|
||||
const estGas = await this.estGasReactivateNFTTemplate(address, templateIndex)
|
||||
|
||||
// Invoke createToken function of the contract
|
||||
const trxReceipt = await this.factory721.methods
|
||||
@ -316,6 +360,29 @@ export class NFTFactory {
|
||||
return trxReceipt
|
||||
}
|
||||
|
||||
/**
|
||||
* Estimate gas cost for addTokenTemplate method
|
||||
* @param {String} address
|
||||
* @param {String} templateAddress template address to add
|
||||
* @return {Promise<TransactionReceipt>}
|
||||
*/
|
||||
public async estGasAddTokenTemplate(
|
||||
address: string,
|
||||
templateAddress: string
|
||||
): Promise<any> {
|
||||
const gasLimitDefault = this.GASLIMIT_DEFAULT
|
||||
let estGas
|
||||
try {
|
||||
estGas = await this.factory721.methods
|
||||
.addTokenTemplate(templateAddress)
|
||||
.estimateGas({ from: address }, (err, estGas) => (err ? gasLimitDefault : estGas))
|
||||
} catch (e) {
|
||||
estGas = gasLimitDefault
|
||||
}
|
||||
|
||||
return estGas
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a new erc721 token template - only factory Owner
|
||||
* @param {String} address
|
||||
@ -330,15 +397,7 @@ export class NFTFactory {
|
||||
throw new Error(`Caller is not Factory Owner`)
|
||||
}
|
||||
|
||||
const gasLimitDefault = this.GASLIMIT_DEFAULT
|
||||
let estGas
|
||||
try {
|
||||
estGas = await this.factory721.methods
|
||||
.addTokenTemplate(templateAddress)
|
||||
.estimateGas({ from: address }, (err, estGas) => (err ? gasLimitDefault : estGas))
|
||||
} catch (e) {
|
||||
estGas = gasLimitDefault
|
||||
}
|
||||
const estGas = await this.estGasAddTokenTemplate(address, templateAddress)
|
||||
|
||||
// Invoke createToken function of the contract
|
||||
const trxReceipt = await this.factory721.methods
|
||||
@ -352,6 +411,28 @@ export class NFTFactory {
|
||||
return trxReceipt
|
||||
}
|
||||
|
||||
/**
|
||||
* Estimate gas cost for disableTokenTemplate method
|
||||
* @param {String} address
|
||||
* @param {Number} templateIndex index of the template we want to disable
|
||||
* @return {Promise<TransactionReceipt>} current token template count
|
||||
*/
|
||||
public async estGasDisableTokenTemplate(
|
||||
address: string,
|
||||
templateIndex: number
|
||||
): Promise<any> {
|
||||
const gasLimitDefault = this.GASLIMIT_DEFAULT
|
||||
let estGas
|
||||
try {
|
||||
estGas = await this.factory721.methods
|
||||
.disableTokenTemplate(templateIndex)
|
||||
.estimateGas({ from: address }, (err, estGas) => (err ? gasLimitDefault : estGas))
|
||||
} catch (e) {
|
||||
estGas = gasLimitDefault
|
||||
}
|
||||
return estGas
|
||||
}
|
||||
|
||||
/**
|
||||
* Disable token template - only factory Owner
|
||||
* @param {String} address
|
||||
@ -366,15 +447,7 @@ export class NFTFactory {
|
||||
throw new Error(`Caller is not Factory Owner`)
|
||||
}
|
||||
|
||||
const gasLimitDefault = this.GASLIMIT_DEFAULT
|
||||
let estGas
|
||||
try {
|
||||
estGas = await this.factory721.methods
|
||||
.disableTokenTemplate(templateIndex)
|
||||
.estimateGas({ from: address }, (err, estGas) => (err ? gasLimitDefault : estGas))
|
||||
} catch (e) {
|
||||
estGas = gasLimitDefault
|
||||
}
|
||||
const estGas = await this.estGasDisableTokenTemplate(address, templateIndex)
|
||||
|
||||
// Invoke createToken function of the contract
|
||||
const trxReceipt = await this.factory721.methods
|
||||
@ -388,6 +461,28 @@ export class NFTFactory {
|
||||
return trxReceipt
|
||||
}
|
||||
|
||||
/**
|
||||
* Estimate gas cost for reactivateTokenTemplate method
|
||||
* @param {String} address
|
||||
* @param {Number} templateIndex index of the template we want to reactivate
|
||||
* @return {Promise<TransactionReceipt>} current token template count
|
||||
*/
|
||||
public async estGasReactivateTokenTemplate(
|
||||
address: string,
|
||||
templateIndex: number
|
||||
): Promise<any> {
|
||||
const gasLimitDefault = this.GASLIMIT_DEFAULT
|
||||
let estGas
|
||||
try {
|
||||
estGas = await this.factory721.methods
|
||||
.reactivateTokenTemplate(templateIndex)
|
||||
.estimateGas({ from: address }, (err, estGas) => (err ? gasLimitDefault : estGas))
|
||||
} catch (e) {
|
||||
estGas = gasLimitDefault
|
||||
}
|
||||
return estGas
|
||||
}
|
||||
|
||||
/**
|
||||
* Reactivate a previously disabled token template - only factory Owner
|
||||
* @param {String} address
|
||||
@ -402,15 +497,7 @@ export class NFTFactory {
|
||||
throw new Error(`Caller is not Factory Owner`)
|
||||
}
|
||||
|
||||
const gasLimitDefault = this.GASLIMIT_DEFAULT
|
||||
let estGas
|
||||
try {
|
||||
estGas = await this.factory721.methods
|
||||
.reactivateTokenTemplate(templateIndex)
|
||||
.estimateGas({ from: address }, (err, estGas) => (err ? gasLimitDefault : estGas))
|
||||
} catch (e) {
|
||||
estGas = gasLimitDefault
|
||||
}
|
||||
const estGas = await this.estGasReactivateTokenTemplate(address, templateIndex)
|
||||
|
||||
// Invoke createToken function of the contract
|
||||
const trxReceipt = await this.factory721.methods
|
||||
@ -424,23 +511,15 @@ export class NFTFactory {
|
||||
return trxReceipt
|
||||
}
|
||||
|
||||
/**
|
||||
* @dev startMultipleTokenOrder
|
||||
* Used as a proxy to order multiple services
|
||||
* Users can have inifinite approvals for fees for factory instead of having one approval/ erc20 contract
|
||||
* Requires previous approval of all :
|
||||
* - consumeFeeTokens
|
||||
* - publishMarketFeeTokens
|
||||
* - erc20 datatokens
|
||||
/** Estimate gas cost for startMultipleTokenOrder method
|
||||
* @param address Caller address
|
||||
* @param orders an array of struct tokenOrder
|
||||
* @return {Promise<TransactionReceipt>} transaction receipt
|
||||
* @return {Promise<TransactionReceipt>} transaction receipt
|
||||
*/
|
||||
|
||||
public async startMultipleTokenOrder(
|
||||
public async estGasStartMultipleTokenOrder(
|
||||
address: string,
|
||||
orders: TokenOrder[]
|
||||
): Promise<TransactionReceipt> {
|
||||
// Get estimated gas value
|
||||
): Promise<any> {
|
||||
const gasLimitDefault = this.GASLIMIT_DEFAULT
|
||||
let estGas
|
||||
try {
|
||||
@ -450,6 +529,26 @@ export class NFTFactory {
|
||||
} catch (e) {
|
||||
estGas = gasLimitDefault
|
||||
}
|
||||
return estGas
|
||||
}
|
||||
|
||||
/**
|
||||
* @dev startMultipleTokenOrder
|
||||
* Used as a proxy to order multiple services
|
||||
* Users can have inifinite approvals for fees for factory instead of having one approval/ erc20 contract
|
||||
* Requires previous approval of all :
|
||||
* - consumeFeeTokens
|
||||
* - publishMarketFeeTokens
|
||||
* - erc20 datatokens
|
||||
* @param address Caller address
|
||||
* @param orders an array of struct tokenOrder
|
||||
* @return {Promise<TransactionReceipt>} transaction receipt
|
||||
*/
|
||||
public async startMultipleTokenOrder(
|
||||
address: string,
|
||||
orders: TokenOrder[]
|
||||
): Promise<TransactionReceipt> {
|
||||
const estGas = await this.estGasStartMultipleTokenOrder(address, orders)
|
||||
|
||||
// Invoke createToken function of the contract
|
||||
const trxReceipt = await this.factory721.methods
|
||||
@ -464,28 +563,53 @@ export class NFTFactory {
|
||||
}
|
||||
|
||||
/**
|
||||
* @dev createNftWithErc
|
||||
* Creates a new NFT, then a ERC20,all in one call
|
||||
* Estimate gas cost for createNftWithErc method
|
||||
* @param address Caller address
|
||||
* @param _NftCreateData input data for nft creation
|
||||
* @param _ErcCreateData input data for erc20 creation
|
||||
* @return {Promise<TransactionReceipt>} transaction receipt
|
||||
*/
|
||||
|
||||
public async createNftWithErc(
|
||||
public async estGasCreateNftWithErc(
|
||||
address: string,
|
||||
nftCreateData: NFTCreateData,
|
||||
ercCreateData: ErcCreateData
|
||||
): Promise<TransactionReceipt> {
|
||||
ercParams: Erc20CreateParams
|
||||
): Promise<any> {
|
||||
// Get estimated gas value
|
||||
const gasLimitDefault = this.GASLIMIT_DEFAULT
|
||||
let estGas
|
||||
try {
|
||||
const ercCreateData = getErcCreationParams(ercParams, this.web3)
|
||||
estGas = await this.factory721.methods
|
||||
.createNftWithErc(nftCreateData, ercCreateData)
|
||||
.estimateGas({ from: address }, (err, estGas) => (err ? gasLimitDefault : estGas))
|
||||
} catch (e) {
|
||||
estGas = gasLimitDefault
|
||||
}
|
||||
return estGas
|
||||
}
|
||||
|
||||
/**
|
||||
* @dev createNftWithErc
|
||||
* Creates a new NFT, then a ERC20,all in one call
|
||||
* @param address Caller address
|
||||
* @param _NftCreateData input data for nft creation
|
||||
* @param _ErcCreateData input data for erc20 creation
|
||||
* @return {Promise<TransactionReceipt>} transaction receipt
|
||||
*/
|
||||
|
||||
public async createNftWithErc(
|
||||
address: string,
|
||||
nftCreateData: NFTCreateData,
|
||||
ercParams: Erc20CreateParams
|
||||
): Promise<TransactionReceipt> {
|
||||
const ercCreateData = getErcCreationParams(ercParams, this.web3)
|
||||
|
||||
const estGas = await this.estGasCreateNftWithErc(
|
||||
address,
|
||||
nftCreateData,
|
||||
ercCreateData
|
||||
)
|
||||
|
||||
// Invoke createToken function of the contract
|
||||
const trxReceipt = await this.factory721.methods
|
||||
@ -500,31 +624,57 @@ export class NFTFactory {
|
||||
}
|
||||
|
||||
/**
|
||||
* @dev createNftErcWithPool
|
||||
* Creates a new NFT, then a ERC20, then a Pool, all in one call
|
||||
* Use this carefully, because if Pool creation fails, you are still going to pay a lot of gas
|
||||
* @param _NftCreateData input data for NFT Creation
|
||||
* @param _ErcCreateData input data for ERC20 Creation
|
||||
* @param _PoolData input data for Pool Creation
|
||||
* @return {Promise<TransactionReceipt>} transaction receipt
|
||||
* Estimate gas cost for createNftErcWithPool method
|
||||
* @param address Caller address
|
||||
* @param nftCreateData input data for NFT Creation
|
||||
* @param ercParams input data for ERC20 Creation
|
||||
* @param poolParams input data for Pool Creation
|
||||
* @return {Promise<TransactionReceipt>} transaction receipt
|
||||
*/
|
||||
|
||||
public async createNftErcWithPool(
|
||||
public async estGasCreateNftErcWithPool(
|
||||
address: string,
|
||||
nftCreateData: NFTCreateData,
|
||||
ercCreateData: ErcCreateData,
|
||||
poolData: PoolData
|
||||
): Promise<TransactionReceipt> {
|
||||
// Get estimated gas value
|
||||
ercParams: Erc20CreateParams,
|
||||
poolParams: PoolCreationParams
|
||||
): Promise<any> {
|
||||
const gasLimitDefault = this.GASLIMIT_DEFAULT
|
||||
let estGas
|
||||
try {
|
||||
const ercCreateData = getErcCreationParams(ercParams, this.web3)
|
||||
const poolData = getPoolCreationParams(poolParams, this.web3)
|
||||
estGas = await this.factory721.methods
|
||||
.createNftErcWithPool(nftCreateData, ercCreateData, poolData)
|
||||
.estimateGas({ from: address }, (err, estGas) => (err ? gasLimitDefault : estGas))
|
||||
} catch (e) {
|
||||
estGas = gasLimitDefault
|
||||
}
|
||||
return estGas
|
||||
}
|
||||
|
||||
/**
|
||||
* @dev createNftErcWithPool
|
||||
* Creates a new NFT, then a ERC20, then a Pool, all in one call
|
||||
* Use this carefully, because if Pool creation fails, you are still going to pay a lot of gas
|
||||
* @param address Caller address
|
||||
* @param nftCreateData input data for NFT Creation
|
||||
* @param ercParams input data for ERC20 Creation
|
||||
* @param poolParams input data for Pool Creation
|
||||
* @return {Promise<TransactionReceipt>} transaction receipt
|
||||
*/
|
||||
public async createNftErcWithPool(
|
||||
address: string,
|
||||
nftCreateData: NFTCreateData,
|
||||
ercParams: Erc20CreateParams,
|
||||
poolParams: PoolCreationParams
|
||||
): Promise<TransactionReceipt> {
|
||||
const estGas = await this.estGasCreateNftErcWithPool(
|
||||
address,
|
||||
nftCreateData,
|
||||
ercParams,
|
||||
poolParams
|
||||
)
|
||||
const ercCreateData = getErcCreationParams(ercParams, this.web3)
|
||||
const poolData = getPoolCreationParams(poolParams, this.web3)
|
||||
|
||||
// Invoke createToken function of the contract
|
||||
const trxReceipt = await this.factory721.methods
|
||||
@ -538,25 +688,26 @@ export class NFTFactory {
|
||||
return trxReceipt
|
||||
}
|
||||
|
||||
/**
|
||||
* @dev createNftErcWithFixedRate
|
||||
* Creates a new NFT, then a ERC20, then a FixedRateExchange, all in one call
|
||||
* Use this carefully, because if Fixed Rate creation fails, you are still going to pay a lot of gas
|
||||
* @param _NftCreateData input data for NFT Creation
|
||||
* @param _ErcCreateData input data for ERC20 Creation
|
||||
* @param _FixedData input data for FixedRate Creation
|
||||
* @return {Promise<TransactionReceipt>} transaction receipt
|
||||
/** Estimate gas cost for createNftErcWithFixedRate method
|
||||
* @param address Caller address
|
||||
* @param nftCreateData input data for NFT Creation
|
||||
* @param ercParams input data for ERC20 Creation
|
||||
* @param freParams input data for FixedRate Creation
|
||||
* @return {Promise<TransactionReceipt>} transaction receipt
|
||||
*/
|
||||
|
||||
public async createNftErcWithFixedRate(
|
||||
public async estGasCreateNftErcWithFixedRate(
|
||||
address: string,
|
||||
nftCreateData: NFTCreateData,
|
||||
ercCreateData: ErcCreateData,
|
||||
fixedData: FixedData
|
||||
): Promise<TransactionReceipt> {
|
||||
// Get estimated gas value
|
||||
ercParams: Erc20CreateParams,
|
||||
freParams: FreCreationParams
|
||||
): Promise<any> {
|
||||
const gasLimitDefault = this.GASLIMIT_DEFAULT
|
||||
let estGas
|
||||
|
||||
const ercCreateData = getErcCreationParams(ercParams, this.web3)
|
||||
|
||||
const fixedData = getFreCreationParams(freParams, this.web3)
|
||||
|
||||
try {
|
||||
estGas = await this.factory721.methods
|
||||
.createNftErcWithFixedRate(nftCreateData, ercCreateData, fixedData)
|
||||
@ -564,6 +715,34 @@ export class NFTFactory {
|
||||
} catch (e) {
|
||||
estGas = gasLimitDefault
|
||||
}
|
||||
return estGas
|
||||
}
|
||||
|
||||
/**
|
||||
* @dev createNftErcWithFixedRate
|
||||
* Creates a new NFT, then a ERC20, then a FixedRateExchange, all in one call
|
||||
* Use this carefully, because if Fixed Rate creation fails, you are still going to pay a lot of gas
|
||||
* @param address Caller address
|
||||
* @param nftCreateData input data for NFT Creation
|
||||
* @param ercParams input data for ERC20 Creation
|
||||
* @param freParams input data for FixedRate Creation
|
||||
* @return {Promise<TransactionReceipt>} transaction receipt
|
||||
*/
|
||||
public async createNftErcWithFixedRate(
|
||||
address: string,
|
||||
nftCreateData: NFTCreateData,
|
||||
ercParams: Erc20CreateParams,
|
||||
freParams: FreCreationParams
|
||||
): Promise<TransactionReceipt> {
|
||||
const ercCreateData = getErcCreationParams(ercParams, this.web3)
|
||||
const fixedData = getFreCreationParams(freParams, this.web3)
|
||||
|
||||
const estGas = await this.estGasCreateNftErcWithFixedRate(
|
||||
address,
|
||||
nftCreateData,
|
||||
ercParams,
|
||||
freParams
|
||||
)
|
||||
|
||||
// Invoke createToken function of the contract
|
||||
const trxReceipt = await this.factory721.methods
|
||||
|
@ -1 +1,5 @@
|
||||
export * from './pools/index'
|
||||
export * from './pools'
|
||||
export * from './datatokens'
|
||||
export * from './factories'
|
||||
export * from './models'
|
||||
export * from './utils'
|
||||
|
6
src/interfaces/DispenserInterface.ts
Normal file
6
src/interfaces/DispenserInterface.ts
Normal file
@ -0,0 +1,6 @@
|
||||
export interface DispenserCreationParams {
|
||||
maxTokens: string
|
||||
maxBalance: string
|
||||
withMint?: boolean // true if we want to allow the dispenser to be a minter
|
||||
allowedSwapper?: string // only account that can ask tokens. set address(0) if not required
|
||||
}
|
11
src/interfaces/Erc20Interface.ts
Normal file
11
src/interfaces/Erc20Interface.ts
Normal file
@ -0,0 +1,11 @@
|
||||
export interface Erc20CreateParams {
|
||||
templateIndex: number
|
||||
minter: string
|
||||
feeManager: string
|
||||
mpFeeAddress: string
|
||||
feeToken: string
|
||||
feeAmount: string
|
||||
cap: string
|
||||
name?: string
|
||||
symbol?: string
|
||||
}
|
18
src/interfaces/FixedRateInterface.ts
Normal file
18
src/interfaces/FixedRateInterface.ts
Normal file
@ -0,0 +1,18 @@
|
||||
export interface FreCreationParams {
|
||||
fixedRateAddress: string
|
||||
baseTokenAddress: string
|
||||
owner: string
|
||||
marketFeeCollector: string
|
||||
baseTokenDecimals: number
|
||||
dataTokenDecimals: number
|
||||
fixedRate: string
|
||||
marketFee: number
|
||||
withMint?: boolean // add FixedPriced contract as minter if withMint == true
|
||||
allowedConsumer?: string // only account that consume the exhchange
|
||||
}
|
||||
|
||||
export interface FreOrderParams {
|
||||
exchangeContract: string
|
||||
exchangeId: string
|
||||
maxBaseTokenAmount: string
|
||||
}
|
15
src/interfaces/PoolInterface.ts
Normal file
15
src/interfaces/PoolInterface.ts
Normal file
@ -0,0 +1,15 @@
|
||||
export interface PoolCreationParams {
|
||||
ssContract: string
|
||||
basetokenAddress: string
|
||||
basetokenSender: string
|
||||
publisherAddress: string
|
||||
marketFeeCollector: string
|
||||
poolTemplateAddress: string
|
||||
rate: string
|
||||
basetokenDecimals: number
|
||||
vestingAmount: string
|
||||
vestedBlocks: number
|
||||
initialBasetokenLiquidity: string
|
||||
swapFeeLiquidityProvider: number
|
||||
swapFeeMarketPlaceRunner: number
|
||||
}
|
4
src/interfaces/index.ts
Normal file
4
src/interfaces/index.ts
Normal file
@ -0,0 +1,4 @@
|
||||
export * from './FixedRateInterface'
|
||||
export * from './PoolInterface'
|
||||
export * from './Erc20Interface'
|
||||
export * from './DispenserInterface'
|
1
src/models/index.ts
Normal file
1
src/models/index.ts
Normal file
@ -0,0 +1 @@
|
||||
export * from './Config'
|
@ -3,7 +3,7 @@ import Web3 from 'web3'
|
||||
import { TransactionReceipt } from 'web3-core'
|
||||
import { AbiItem } from 'web3-utils'
|
||||
import defaultRouter from '@oceanprotocol/contracts/artifacts/contracts/pools/FactoryRouter.sol/FactoryRouter.json'
|
||||
import { Logger, getFairGasPrice, generateDtName } from '../utils'
|
||||
import { LoggerInstance, getFairGasPrice } from '../utils'
|
||||
|
||||
interface Operations {
|
||||
exchangeIds: string
|
||||
@ -24,7 +24,6 @@ export class Router {
|
||||
public routerAddress: string
|
||||
public RouterABI: AbiItem | AbiItem[]
|
||||
public web3: Web3
|
||||
private logger: Logger
|
||||
public startBlock: number
|
||||
public router: Contract
|
||||
|
||||
@ -37,18 +36,35 @@ export class Router {
|
||||
constructor(
|
||||
routerAddress: string,
|
||||
web3: Web3,
|
||||
logger: Logger,
|
||||
RouterABI?: AbiItem | AbiItem[],
|
||||
startBlock?: number
|
||||
) {
|
||||
this.routerAddress = routerAddress
|
||||
this.RouterABI = RouterABI || (defaultRouter.abi as AbiItem[])
|
||||
this.web3 = web3
|
||||
this.logger = logger
|
||||
this.startBlock = startBlock || 0
|
||||
this.router = new this.web3.eth.Contract(this.RouterABI, this.routerAddress)
|
||||
}
|
||||
|
||||
/**
|
||||
* Estimate gas cost for buyDTBatch method
|
||||
* @param {String} address
|
||||
* @param {Operations} operations Operations objects array
|
||||
* @return {Promise<TransactionReceipt>} Transaction receipt
|
||||
*/
|
||||
public async estGasBuyDTBatch(address: string, operations: Operations[]): Promise<any> {
|
||||
const gasLimitDefault = this.GASLIMIT_DEFAULT
|
||||
let estGas
|
||||
try {
|
||||
estGas = await this.router.methods
|
||||
.buyDTBatch(operations)
|
||||
.estimateGas({ from: address }, (err, estGas) => (err ? gasLimitDefault : estGas))
|
||||
} catch (e) {
|
||||
estGas = gasLimitDefault
|
||||
}
|
||||
return estGas
|
||||
}
|
||||
|
||||
/**
|
||||
* BuyDTBatch
|
||||
* @param {String} address
|
||||
@ -59,16 +75,7 @@ export class Router {
|
||||
address: string,
|
||||
operations: Operations[]
|
||||
): Promise<TransactionReceipt> {
|
||||
// Get estimated gas value
|
||||
const gasLimitDefault = this.GASLIMIT_DEFAULT
|
||||
let estGas
|
||||
try {
|
||||
estGas = await this.router.methods
|
||||
.buyDTBatch(operations)
|
||||
.estimateGas({ from: address }, (err, estGas) => (err ? gasLimitDefault : estGas))
|
||||
} catch (e) {
|
||||
estGas = gasLimitDefault
|
||||
}
|
||||
const estGas = await this.estGasBuyDTBatch(address, operations)
|
||||
|
||||
// Invoke createToken function of the contract
|
||||
const trxReceipt = await this.router.methods.buyDTBatch(operations).send({
|
||||
@ -226,6 +233,26 @@ export class Router {
|
||||
return trxReceipt
|
||||
}
|
||||
|
||||
/**
|
||||
* Estimate gas cost for addSSContract method
|
||||
* @param {String} address
|
||||
* @param {String} tokenAddress contract address to add
|
||||
* @return {Promise<TransactionReceipt>}
|
||||
*/
|
||||
public async estGasAddSSContract(address: string, tokenAddress: string): Promise<any> {
|
||||
const gasLimitDefault = this.GASLIMIT_DEFAULT
|
||||
let estGas
|
||||
try {
|
||||
estGas = await this.router.methods
|
||||
.addSSContract(tokenAddress)
|
||||
.estimateGas({ from: address }, (err, estGas) => (err ? gasLimitDefault : estGas))
|
||||
} catch (e) {
|
||||
estGas = gasLimitDefault
|
||||
}
|
||||
|
||||
return estGas
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a new contract to ssContract list, after is added, can be used when deploying a new pool
|
||||
* @param {String} address
|
||||
@ -240,16 +267,7 @@ export class Router {
|
||||
throw new Error(`Caller is not Router Owner`)
|
||||
}
|
||||
|
||||
const gasLimitDefault = this.GASLIMIT_DEFAULT
|
||||
let estGas
|
||||
try {
|
||||
estGas = await this.router.methods
|
||||
.addSSContract(tokenAddress)
|
||||
.estimateGas({ from: address }, (err, estGas) => (err ? gasLimitDefault : estGas))
|
||||
} catch (e) {
|
||||
estGas = gasLimitDefault
|
||||
}
|
||||
|
||||
const estGas = await this.estGasAddSSContract(address, tokenAddress)
|
||||
// Invoke createToken function of the contract
|
||||
const trxReceipt = await this.router.methods.addSSContract(tokenAddress).send({
|
||||
from: address,
|
||||
@ -260,6 +278,29 @@ export class Router {
|
||||
return trxReceipt
|
||||
}
|
||||
|
||||
/**
|
||||
* Estimate gas cost for addFixedRateContract method
|
||||
* @param {String} address
|
||||
* @param {String} tokenAddress contract address to add
|
||||
* @return {Promise<TransactionReceipt>}
|
||||
*/
|
||||
public async estGasAddFixedRateContract(
|
||||
address: string,
|
||||
tokenAddress: string
|
||||
): Promise<any> {
|
||||
const gasLimitDefault = this.GASLIMIT_DEFAULT
|
||||
let estGas
|
||||
try {
|
||||
estGas = await this.router.methods
|
||||
.addFixedRateContract(tokenAddress)
|
||||
.estimateGas({ from: address }, (err, estGas) => (err ? gasLimitDefault : estGas))
|
||||
} catch (e) {
|
||||
estGas = gasLimitDefault
|
||||
}
|
||||
|
||||
return estGas
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a new contract to fixedRate list, after is added, can be used when deploying a new pool
|
||||
* @param {String} address
|
||||
@ -274,15 +315,7 @@ export class Router {
|
||||
throw new Error(`Caller is not Router Owner`)
|
||||
}
|
||||
|
||||
const gasLimitDefault = this.GASLIMIT_DEFAULT
|
||||
let estGas
|
||||
try {
|
||||
estGas = await this.router.methods
|
||||
.addFixedRateContract(tokenAddress)
|
||||
.estimateGas({ from: address }, (err, estGas) => (err ? gasLimitDefault : estGas))
|
||||
} catch (e) {
|
||||
estGas = gasLimitDefault
|
||||
}
|
||||
const estGas = await this.estGasAddFixedRateContract(address, tokenAddress)
|
||||
|
||||
// Invoke createToken function of the contract
|
||||
const trxReceipt = await this.router.methods.addFixedRateContract(tokenAddress).send({
|
||||
@ -308,6 +341,26 @@ export class Router {
|
||||
return await this.router.methods.swapOceanFee().call()
|
||||
}
|
||||
|
||||
/**
|
||||
* Estimate gas cost for updateOPFFee method
|
||||
* @param {String} address
|
||||
* @param {String} newFee new OPF Fee
|
||||
* @return {Promise<TransactionReceipt>}
|
||||
*/
|
||||
public async estGasUpdateOPFFee(address: string, newFee: number): Promise<any> {
|
||||
const gasLimitDefault = this.GASLIMIT_DEFAULT
|
||||
let estGas
|
||||
try {
|
||||
estGas = await this.router.methods
|
||||
.updateOPFFee(newFee)
|
||||
.estimateGas({ from: address }, (err, estGas) => (err ? gasLimitDefault : estGas))
|
||||
} catch (e) {
|
||||
estGas = gasLimitDefault
|
||||
}
|
||||
|
||||
return estGas
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a new contract to fixedRate list, after is added, can be used when deploying a new pool
|
||||
* @param {String} address
|
||||
@ -323,14 +376,7 @@ export class Router {
|
||||
}
|
||||
|
||||
const gasLimitDefault = this.GASLIMIT_DEFAULT
|
||||
let estGas
|
||||
try {
|
||||
estGas = await this.router.methods
|
||||
.updateOPFFee(newFee)
|
||||
.estimateGas({ from: address }, (err, estGas) => (err ? gasLimitDefault : estGas))
|
||||
} catch (e) {
|
||||
estGas = gasLimitDefault
|
||||
}
|
||||
const estGas = await this.estGasUpdateOPFFee(address, newFee)
|
||||
|
||||
// Invoke createToken function of the contract
|
||||
const trxReceipt = await this.router.methods.updateOPFFee(newFee).send({
|
||||
@ -342,6 +388,29 @@ export class Router {
|
||||
return trxReceipt
|
||||
}
|
||||
|
||||
/**
|
||||
* Estimate gas cost for addPoolTemplate method
|
||||
* @param {String} address
|
||||
* @param {String} templateAddress template address to add
|
||||
* @return {Promise<TransactionReceipt>}
|
||||
*/
|
||||
public async estGasAddPoolTemplate(
|
||||
address: string,
|
||||
templateAddress: string
|
||||
): Promise<any> {
|
||||
const gasLimitDefault = this.GASLIMIT_DEFAULT
|
||||
let estGas
|
||||
try {
|
||||
estGas = await this.router.methods
|
||||
.addPoolTemplate(templateAddress)
|
||||
.estimateGas({ from: address }, (err, estGas) => (err ? gasLimitDefault : estGas))
|
||||
} catch (e) {
|
||||
estGas = gasLimitDefault
|
||||
}
|
||||
|
||||
return estGas
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a new template to poolTemplates mapping, after template is added,it can be used
|
||||
* @param {String} address
|
||||
@ -356,15 +425,7 @@ export class Router {
|
||||
throw new Error(`Caller is not Router Owner`)
|
||||
}
|
||||
|
||||
const gasLimitDefault = this.GASLIMIT_DEFAULT
|
||||
let estGas
|
||||
try {
|
||||
estGas = await this.router.methods
|
||||
.addPoolTemplate(templateAddress)
|
||||
.estimateGas({ from: address }, (err, estGas) => (err ? gasLimitDefault : estGas))
|
||||
} catch (e) {
|
||||
estGas = gasLimitDefault
|
||||
}
|
||||
const estGas = await this.estGasAddPoolTemplate(address, templateAddress)
|
||||
|
||||
// Invoke createToken function of the contract
|
||||
const trxReceipt = await this.router.methods.addPoolTemplate(templateAddress).send({
|
||||
@ -376,6 +437,28 @@ export class Router {
|
||||
return trxReceipt
|
||||
}
|
||||
|
||||
/**
|
||||
* Estimate gas cost for removePoolTemplate method
|
||||
* @param {String} address
|
||||
* @param {String} templateAddress template address to remove
|
||||
* @return {Promise<TransactionReceipt>}
|
||||
*/
|
||||
public async estGasRemovePoolTemplate(
|
||||
address: string,
|
||||
templateAddress: string
|
||||
): Promise<any> {
|
||||
const gasLimitDefault = this.GASLIMIT_DEFAULT
|
||||
let estGas
|
||||
try {
|
||||
estGas = await this.router.methods
|
||||
.removePoolTemplate(templateAddress)
|
||||
.estimateGas({ from: address }, (err, estGas) => (err ? gasLimitDefault : estGas))
|
||||
} catch (e) {
|
||||
estGas = gasLimitDefault
|
||||
}
|
||||
return estGas
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove template from poolTemplates mapping, after template is removed,it can be used anymore
|
||||
* @param {String} address
|
||||
@ -390,15 +473,7 @@ export class Router {
|
||||
throw new Error(`Caller is not Router Owner`)
|
||||
}
|
||||
|
||||
const gasLimitDefault = this.GASLIMIT_DEFAULT
|
||||
let estGas
|
||||
try {
|
||||
estGas = await this.router.methods
|
||||
.removePoolTemplate(templateAddress)
|
||||
.estimateGas({ from: address }, (err, estGas) => (err ? gasLimitDefault : estGas))
|
||||
} catch (e) {
|
||||
estGas = gasLimitDefault
|
||||
}
|
||||
const estGas = await this.estGasRemovePoolTemplate(address, templateAddress)
|
||||
|
||||
// Invoke createToken function of the contract
|
||||
const trxReceipt = await this.router.methods
|
||||
|
@ -2,8 +2,8 @@ import Config from '../models/Config'
|
||||
import fs from 'fs'
|
||||
import { homedir } from 'os'
|
||||
// eslint-disable-next-line import/no-named-default
|
||||
import { default as DefaultContractsAddresses } from '../data/address.json' // temporary untill we can get them from the contract arficats
|
||||
import Logger from './Logger'
|
||||
import { default as DefaultContractsAddresses } from '@oceanprotocol/contracts/addresses/address.json'
|
||||
import LoggerInstance from './Logger'
|
||||
|
||||
export interface ConfigHelperConfig extends Config {
|
||||
networkId: number
|
||||
@ -231,7 +231,7 @@ export class ConfigHelper {
|
||||
let config = configHelperNetworks.find((c) => c[filterBy] === network)
|
||||
|
||||
if (!config) {
|
||||
Logger.error(`No config found for given network '${network}'`)
|
||||
LoggerInstance.error(`No config found for given network '${network}'`)
|
||||
return null
|
||||
}
|
||||
|
||||
|
68
src/utils/ContractParams.ts
Normal file
68
src/utils/ContractParams.ts
Normal file
@ -0,0 +1,68 @@
|
||||
import { Erc20CreateParams, FreCreationParams, PoolCreationParams } from '../interfaces'
|
||||
import { generateDtName } from '.'
|
||||
import Web3 from 'web3'
|
||||
|
||||
export function getErcCreationParams(ercParams: Erc20CreateParams, web3: Web3): any {
|
||||
let name: string, symbol: string
|
||||
// Generate name & symbol if not present
|
||||
if (!ercParams.name || !ercParams.symbol) {
|
||||
;({ name, symbol } = generateDtName())
|
||||
}
|
||||
|
||||
return {
|
||||
templateIndex: ercParams.templateIndex,
|
||||
strings: [ercParams.name || name, ercParams.symbol || symbol],
|
||||
addresses: [
|
||||
ercParams.minter,
|
||||
ercParams.feeManager,
|
||||
ercParams.mpFeeAddress,
|
||||
ercParams.feeToken
|
||||
],
|
||||
uints: [web3.utils.toWei(ercParams.cap), web3.utils.toWei(ercParams.feeAmount)],
|
||||
bytess: []
|
||||
}
|
||||
}
|
||||
|
||||
export function getFreCreationParams(freParams: FreCreationParams, web3: Web3): any {
|
||||
if (!freParams.allowedConsumer)
|
||||
freParams.allowedConsumer = '0x0000000000000000000000000000000000000000'
|
||||
const withMint = freParams.withMint ? 1 : 0
|
||||
|
||||
return {
|
||||
fixedPriceAddress: freParams.fixedRateAddress,
|
||||
addresses: [
|
||||
freParams.baseTokenAddress,
|
||||
freParams.owner,
|
||||
freParams.marketFeeCollector,
|
||||
freParams.allowedConsumer
|
||||
],
|
||||
uints: [
|
||||
freParams.baseTokenDecimals,
|
||||
freParams.dataTokenDecimals,
|
||||
freParams.fixedRate,
|
||||
freParams.marketFee,
|
||||
withMint
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
export function getPoolCreationParams(poolParams: PoolCreationParams, web3: Web3): any {
|
||||
return {
|
||||
addresses: [
|
||||
poolParams.ssContract,
|
||||
poolParams.basetokenAddress,
|
||||
poolParams.basetokenSender,
|
||||
poolParams.publisherAddress,
|
||||
poolParams.marketFeeCollector,
|
||||
poolParams.poolTemplateAddress
|
||||
],
|
||||
ssParams: [
|
||||
web3.utils.toWei(poolParams.rate),
|
||||
poolParams.basetokenDecimals,
|
||||
web3.utils.toWei(poolParams.vestingAmount),
|
||||
poolParams.vestedBlocks,
|
||||
web3.utils.toWei(poolParams.initialBasetokenLiquidity)
|
||||
],
|
||||
swapFees: [poolParams.swapFeeLiquidityProvider, poolParams.swapFeeMarketPlaceRunner]
|
||||
}
|
||||
}
|
@ -2,3 +2,4 @@ export * from './Logger'
|
||||
export * from './GasUtils'
|
||||
export * from './Logger'
|
||||
export * from './DatatokenName'
|
||||
export * from './ContractParams'
|
||||
|
@ -398,7 +398,7 @@ export class TestContractHandler {
|
||||
.addFixedRateContract(this.fixedRateAddress)
|
||||
.send({ from: owner })
|
||||
await RouterContract.methods
|
||||
.addFixedRateContract(this.dispenserAddress)
|
||||
.addDispenserContract(this.dispenserAddress)
|
||||
.send({ from: owner })
|
||||
await RouterContract.methods
|
||||
.addSSContract(this.sideStakingAddress)
|
||||
|
349
test/unit/Datatoken.test.ts
Normal file
349
test/unit/Datatoken.test.ts
Normal file
@ -0,0 +1,349 @@
|
||||
import { assert } from 'chai'
|
||||
import Web3 from 'web3'
|
||||
import ERC20TemplateEnterprise from '@oceanprotocol/contracts/artifacts/contracts/templates/ERC20TemplateEnterprise.sol/ERC20TemplateEnterprise.json'
|
||||
import PoolTemplate from '@oceanprotocol/contracts/artifacts/contracts/pools/balancer/BPool.sol/BPool.json'
|
||||
import ERC721Factory from '@oceanprotocol/contracts/artifacts/contracts/ERC721Factory.sol/ERC721Factory.json'
|
||||
import ERC721Template from '@oceanprotocol/contracts/artifacts/contracts/templates/ERC721Template.sol/ERC721Template.json'
|
||||
import SideStaking from '@oceanprotocol/contracts/artifacts/contracts/pools/ssContracts/SideStaking.sol/SideStaking.json'
|
||||
import Router from '@oceanprotocol/contracts/artifacts/contracts/pools/FactoryRouter.sol/FactoryRouter.json'
|
||||
import ERC20Template from '@oceanprotocol/contracts/artifacts/contracts/templates/ERC20Template.sol/ERC20Template.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 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 { NFTFactory } from '../../src/factories/NFTFactory'
|
||||
import {
|
||||
Datatoken,
|
||||
NFTDatatoken,
|
||||
OrderParams,
|
||||
DispenserParams
|
||||
} from '../../src/datatokens'
|
||||
import { AbiItem } from 'web3-utils'
|
||||
import { LoggerInstance } from '../../src/utils'
|
||||
import { FreCreationParams, FreOrderParams } from '../../src/interfaces'
|
||||
|
||||
const web3 = new Web3('http://127.0.0.1:8545')
|
||||
|
||||
describe('Datatoken', () => {
|
||||
let nftOwner: string
|
||||
let user1: string
|
||||
let user2: string
|
||||
let user3: string
|
||||
let contractHandler: TestContractHandler
|
||||
let nftDatatoken: NFTDatatoken
|
||||
let datatoken: Datatoken
|
||||
let nftFactory: NFTFactory
|
||||
let nftAddress: string
|
||||
let datatokenAddress: string
|
||||
let fixedRateAddress: string
|
||||
let exchangeId: string
|
||||
|
||||
const nftName = 'NFTName'
|
||||
const nftSymbol = 'NFTSymbol'
|
||||
|
||||
it('should deploy contracts', async () => {
|
||||
contractHandler = new TestContractHandler(
|
||||
web3,
|
||||
ERC721Template.abi as AbiItem[],
|
||||
ERC20Template.abi as AbiItem[],
|
||||
PoolTemplate.abi as AbiItem[],
|
||||
ERC721Factory.abi as AbiItem[],
|
||||
Router.abi as AbiItem[],
|
||||
SideStaking.abi as AbiItem[],
|
||||
FixedRate.abi as AbiItem[],
|
||||
Dispenser.abi as AbiItem[],
|
||||
OPFCollector.abi as AbiItem[],
|
||||
|
||||
ERC721Template.bytecode,
|
||||
ERC20Template.bytecode,
|
||||
PoolTemplate.bytecode,
|
||||
ERC721Factory.bytecode,
|
||||
Router.bytecode,
|
||||
SideStaking.bytecode,
|
||||
FixedRate.bytecode,
|
||||
Dispenser.bytecode,
|
||||
OPFCollector.bytecode
|
||||
)
|
||||
await contractHandler.getAccounts()
|
||||
nftOwner = contractHandler.accounts[0]
|
||||
user1 = contractHandler.accounts[1]
|
||||
user2 = contractHandler.accounts[2]
|
||||
user3 = contractHandler.accounts[3]
|
||||
await contractHandler.deployContracts(nftOwner, Router.abi as AbiItem[])
|
||||
|
||||
const daiContract = new web3.eth.Contract(
|
||||
contractHandler.MockERC20.options.jsonInterface,
|
||||
contractHandler.daiAddress
|
||||
)
|
||||
await daiContract.methods
|
||||
.approve(contractHandler.factory721Address, web3.utils.toWei('10000'))
|
||||
.send({ from: contractHandler.accounts[0] })
|
||||
})
|
||||
|
||||
it('should initialize NFTFactory instance and create a new NFT', async () => {
|
||||
nftFactory = new NFTFactory(
|
||||
contractHandler.factory721Address,
|
||||
web3,
|
||||
ERC721Factory.abi as AbiItem[]
|
||||
)
|
||||
const nftData = {
|
||||
name: nftName,
|
||||
symbol: nftSymbol,
|
||||
templateIndex: 1,
|
||||
baseURI: 'https://oceanprotocol.com/nft/'
|
||||
}
|
||||
|
||||
nftAddress = await nftFactory.createNFT(nftOwner, nftData)
|
||||
nftDatatoken = new NFTDatatoken(web3, ERC721Template.abi as AbiItem[])
|
||||
})
|
||||
|
||||
it('#createERC20 - should create a new ERC20 DT from NFT contract', async () => {
|
||||
// await nftDatatoken.addERC20Deployer(nftAddress, nftOwner, nftOwner)
|
||||
datatokenAddress = await nftDatatoken.createERC20(
|
||||
nftAddress,
|
||||
nftOwner,
|
||||
nftOwner,
|
||||
user1,
|
||||
user2,
|
||||
'0x0000000000000000000000000000000000000000',
|
||||
'0',
|
||||
'10000',
|
||||
nftName,
|
||||
nftSymbol,
|
||||
1
|
||||
)
|
||||
assert(datatokenAddress !== null)
|
||||
})
|
||||
|
||||
it('should initialize DT20 Instance', async () => {
|
||||
datatoken = new Datatoken(
|
||||
web3,
|
||||
ERC20Template.abi as AbiItem[],
|
||||
ERC20TemplateEnterprise.abi as AbiItem[]
|
||||
)
|
||||
})
|
||||
|
||||
it('#mint - should fail to mint DT20, if NOT Minter', async () => {
|
||||
// assert((await datatoken.getDTPermissions(datatokenAddress, user1)).minter === false)
|
||||
try {
|
||||
await datatoken.mint(datatokenAddress, user1, '10', user1)
|
||||
} catch (e) {
|
||||
assert(e.message === 'Caller is not Minter')
|
||||
}
|
||||
})
|
||||
|
||||
it('#addMinter - should add user1 as minter, if nftDatatoken has ERC20Deployer permission', async () => {
|
||||
assert((await nftDatatoken.isErc20Deployer(nftAddress, nftOwner)) === true)
|
||||
assert((await datatoken.getDTPermissions(datatokenAddress, user1)).minter === false)
|
||||
|
||||
await datatoken.addMinter(datatokenAddress, nftOwner, user1)
|
||||
|
||||
assert((await datatoken.getDTPermissions(datatokenAddress, user1)).minter === true)
|
||||
})
|
||||
|
||||
it('#mint - should mint ERC20 datatoken to user1, if Minter', async () => {
|
||||
assert((await datatoken.getDTPermissions(datatokenAddress, nftOwner)).minter === true)
|
||||
await datatoken.mint(datatokenAddress, nftOwner, '10', user1)
|
||||
|
||||
assert((await datatoken.balance(datatokenAddress, user1)) === '10')
|
||||
})
|
||||
|
||||
it('#createFixedRate - should create FRE for the erc20 dt', async () => {
|
||||
const freParams: FreCreationParams = {
|
||||
fixedRateAddress: contractHandler.fixedRateAddress,
|
||||
baseTokenAddress: contractHandler.daiAddress,
|
||||
owner: nftOwner,
|
||||
marketFeeCollector: nftOwner,
|
||||
baseTokenDecimals: 18,
|
||||
dataTokenDecimals: 18,
|
||||
fixedRate: web3.utils.toWei('1'),
|
||||
marketFee: 1e15
|
||||
}
|
||||
const fre = await datatoken.createFixedRate(datatokenAddress, nftOwner, freParams)
|
||||
assert(fre !== null)
|
||||
fixedRateAddress = fre.events.NewFixedRate.address
|
||||
exchangeId = fre.events.NewFixedRate.returnValues[0]
|
||||
})
|
||||
|
||||
it('#createDispenser - method creates a dispenser for the erc20DT', async () => {
|
||||
const dispenserParams: DispenserParams = {
|
||||
maxTokens: '10',
|
||||
maxBalance: '100'
|
||||
}
|
||||
|
||||
const dispenser = await datatoken.createDispenser(
|
||||
datatokenAddress,
|
||||
nftOwner,
|
||||
contractHandler.dispenserAddress,
|
||||
dispenserParams
|
||||
)
|
||||
assert(dispenser !== null)
|
||||
})
|
||||
|
||||
it('#removeMinter - should remove user1 as minter, if nftDatatoken has ERC20Deployer permission', async () => {
|
||||
assert((await nftDatatoken.isErc20Deployer(nftAddress, nftOwner)) === true)
|
||||
assert((await datatoken.getDTPermissions(datatokenAddress, user1)).minter === true)
|
||||
|
||||
await datatoken.removeMinter(datatokenAddress, nftOwner, user1)
|
||||
|
||||
assert((await datatoken.getDTPermissions(datatokenAddress, user1)).minter === false)
|
||||
})
|
||||
|
||||
it('#addFeeManager - should add user2 as feeManager, if nftDatatoken has ERC20Deployer permission', async () => {
|
||||
assert((await nftDatatoken.isErc20Deployer(nftAddress, nftOwner)) === true)
|
||||
assert(
|
||||
(await datatoken.getDTPermissions(datatokenAddress, user2)).feeManager === false
|
||||
)
|
||||
|
||||
await datatoken.addFeeManager(datatokenAddress, nftOwner, user2)
|
||||
|
||||
assert(
|
||||
(await datatoken.getDTPermissions(datatokenAddress, user2)).feeManager === true
|
||||
)
|
||||
})
|
||||
|
||||
it('#removeFeeManager - should remove user2 as feeManager, if nftDatatoken has ERC20Deployer permission', async () => {
|
||||
assert((await nftDatatoken.isErc20Deployer(nftAddress, nftOwner)) === true)
|
||||
assert(
|
||||
(await datatoken.getDTPermissions(datatokenAddress, user2)).feeManager === true
|
||||
)
|
||||
|
||||
await datatoken.removeFeeManager(datatokenAddress, nftOwner, user2)
|
||||
|
||||
assert(
|
||||
(await datatoken.getDTPermissions(datatokenAddress, user2)).feeManager === false
|
||||
)
|
||||
})
|
||||
|
||||
it('#setFeeCollector - should fail to set a new feeCollector, if NOT Fee Manager', async () => {
|
||||
await datatoken.removeFeeManager(datatokenAddress, nftOwner, user2)
|
||||
assert(
|
||||
(await datatoken.getDTPermissions(datatokenAddress, user2)).feeManager === false
|
||||
)
|
||||
|
||||
try {
|
||||
await datatoken.setFeeCollector(datatokenAddress, user1, user2)
|
||||
} catch (e) {
|
||||
assert(e.message === 'Caller is not Fee Manager')
|
||||
}
|
||||
})
|
||||
|
||||
it('#setFeeCollector - should set a new feeCollector, if FEE MANAGER', async () => {
|
||||
assert((await datatoken.getFeeCollector(datatokenAddress)) === user2)
|
||||
|
||||
assert(
|
||||
(await datatoken.getDTPermissions(datatokenAddress, user1)).feeManager === true
|
||||
)
|
||||
|
||||
await datatoken.setFeeCollector(datatokenAddress, user1, user3)
|
||||
assert((await datatoken.getFeeCollector(datatokenAddress)) === user3)
|
||||
})
|
||||
|
||||
it('#startOrder- user2 should create an order for DT ', async () => {
|
||||
assert(
|
||||
(await datatoken.balance(datatokenAddress, user1)) === '10',
|
||||
'User1 does not hold 10 datatokens'
|
||||
)
|
||||
assert(
|
||||
(await datatoken.balance(datatokenAddress, user2)) === '0',
|
||||
'User2 does not hold 0 datatokens'
|
||||
)
|
||||
|
||||
const order = await datatoken.startOrder(
|
||||
datatokenAddress,
|
||||
user1,
|
||||
user2,
|
||||
'1',
|
||||
1,
|
||||
user3,
|
||||
'0x0000000000000000000000000000000000000000',
|
||||
'0'
|
||||
)
|
||||
assert(order !== null)
|
||||
|
||||
assert(
|
||||
(await datatoken.balance(datatokenAddress, user1)) === '9',
|
||||
'Invalid user balance, DT was not substracted'
|
||||
)
|
||||
assert(
|
||||
(await datatoken.balance(
|
||||
datatokenAddress,
|
||||
await datatoken.getFeeCollector(datatokenAddress)
|
||||
)) === '1',
|
||||
'Invalid publisher reward, we should have 1 DT'
|
||||
)
|
||||
})
|
||||
|
||||
it('#buyFromDispenserAndOrder- Enterprise method', async () => {
|
||||
const order: OrderParams = {
|
||||
consumer: user1,
|
||||
amount: '1',
|
||||
serviceId: 1,
|
||||
consumeFeeAddress: user1,
|
||||
consumeFeeToken: '0x0000000000000000000000000000000000000000',
|
||||
consumeFeeAmount: '0'
|
||||
}
|
||||
|
||||
const buyFromDispenseTx = await datatoken.buyFromDispenserAndOrder(
|
||||
datatokenAddress,
|
||||
nftOwner,
|
||||
order,
|
||||
contractHandler.dispenserAddress
|
||||
)
|
||||
assert(buyFromDispenseTx !== null)
|
||||
})
|
||||
|
||||
it('#buyFromFreAndOrder - Enterprise method ', async () => {
|
||||
const order: OrderParams = {
|
||||
consumer: user1,
|
||||
amount: '1',
|
||||
serviceId: 1,
|
||||
consumeFeeAddress: user1,
|
||||
consumeFeeToken: '0x0000000000000000000000000000000000000000',
|
||||
consumeFeeAmount: '0'
|
||||
}
|
||||
const fre: FreOrderParams = {
|
||||
exchangeContract: fixedRateAddress,
|
||||
exchangeId: exchangeId,
|
||||
maxBaseTokenAmount: '1'
|
||||
}
|
||||
|
||||
const buyTx = await datatoken.buyFromFreAndOrder(datatokenAddress, user1, order, fre)
|
||||
assert(buyTx !== null)
|
||||
})
|
||||
|
||||
it('#cleanPermissions - should clean permissions at ERC20 level', async () => {
|
||||
assert((await datatoken.getDTPermissions(datatokenAddress, nftOwner)).minter === true)
|
||||
|
||||
assert((await datatoken.getFeeCollector(datatokenAddress)) === user3)
|
||||
|
||||
assert(
|
||||
(await datatoken.getDTPermissions(datatokenAddress, user1)).feeManager === true
|
||||
)
|
||||
|
||||
await datatoken.cleanPermissions(datatokenAddress, nftOwner)
|
||||
|
||||
assert((await datatoken.getFeeCollector(datatokenAddress)) === nftOwner)
|
||||
|
||||
assert(
|
||||
(await datatoken.getDTPermissions(datatokenAddress, nftOwner)).minter === false
|
||||
)
|
||||
|
||||
assert(
|
||||
(await datatoken.getDTPermissions(datatokenAddress, user1)).feeManager === false
|
||||
)
|
||||
})
|
||||
|
||||
it('#setData - should set a value into 725Y standard, if nftDatatoken has ERC20Deployer permission', async () => {
|
||||
const data = web3.utils.asciiToHex('SomeData')
|
||||
|
||||
assert((await nftDatatoken.isErc20Deployer(nftAddress, nftOwner)) === true)
|
||||
|
||||
await datatoken.setData(datatokenAddress, nftOwner, data)
|
||||
|
||||
const key = web3.utils.keccak256(datatokenAddress)
|
||||
assert((await nftDatatoken.getData(nftAddress, key)) === data)
|
||||
})
|
||||
})
|
304
test/unit/NFTDatatoken.test.ts
Normal file
304
test/unit/NFTDatatoken.test.ts
Normal file
@ -0,0 +1,304 @@
|
||||
import { assert } from 'chai'
|
||||
import Web3 from 'web3'
|
||||
import ERC20TemplateEnterprise from '@oceanprotocol/contracts/artifacts/contracts/templates/ERC20TemplateEnterprise.sol/ERC20TemplateEnterprise.json'
|
||||
import PoolTemplate from '@oceanprotocol/contracts/artifacts/contracts/pools/balancer/BPool.sol/BPool.json'
|
||||
import ERC721Factory from '@oceanprotocol/contracts/artifacts/contracts/ERC721Factory.sol/ERC721Factory.json'
|
||||
import ERC721Template from '@oceanprotocol/contracts/artifacts/contracts/templates/ERC721Template.sol/ERC721Template.json'
|
||||
import SideStaking from '@oceanprotocol/contracts/artifacts/contracts/pools/ssContracts/SideStaking.sol/SideStaking.json'
|
||||
import Router from '@oceanprotocol/contracts/artifacts/contracts/pools/FactoryRouter.sol/FactoryRouter.json'
|
||||
import ERC20Template from '@oceanprotocol/contracts/artifacts/contracts/templates/ERC20Template.sol/ERC20Template.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 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 { NFTFactory } from '../../src/factories/NFTFactory'
|
||||
import { NFTDatatoken } from '../../src/datatokens/NFTDatatoken'
|
||||
import { AbiItem } from 'web3-utils'
|
||||
import { LoggerInstance } from '../../src/utils'
|
||||
|
||||
const web3 = new Web3('http://127.0.0.1:8545')
|
||||
|
||||
describe('NFTDatatoken', () => {
|
||||
let nftOwner: string
|
||||
let user1: string
|
||||
let user2: string
|
||||
let user3: string
|
||||
let contractHandler: TestContractHandler
|
||||
let nftDatatoken: NFTDatatoken
|
||||
let nftFactory: NFTFactory
|
||||
let nftAddress: string
|
||||
|
||||
const nftName = 'NFTName'
|
||||
const nftSymbol = 'NFTSymbol'
|
||||
const publishMarketFeeAdress = '0xeE9300b7961e0a01d9f0adb863C7A227A07AaD75'
|
||||
const oceanAddress = '0x967da4048cd07ab37855c090aaf366e4ce1b9f48'
|
||||
|
||||
it('should deploy contracts', async () => {
|
||||
contractHandler = new TestContractHandler(
|
||||
web3,
|
||||
ERC721Template.abi as AbiItem[],
|
||||
ERC20Template.abi as AbiItem[],
|
||||
PoolTemplate.abi as AbiItem[],
|
||||
ERC721Factory.abi as AbiItem[],
|
||||
Router.abi as AbiItem[],
|
||||
SideStaking.abi as AbiItem[],
|
||||
FixedRate.abi as AbiItem[],
|
||||
Dispenser.abi as AbiItem[],
|
||||
OPFCollector.abi as AbiItem[],
|
||||
|
||||
ERC721Template.bytecode,
|
||||
ERC20Template.bytecode,
|
||||
PoolTemplate.bytecode,
|
||||
ERC721Factory.bytecode,
|
||||
Router.bytecode,
|
||||
SideStaking.bytecode,
|
||||
FixedRate.bytecode,
|
||||
Dispenser.bytecode,
|
||||
OPFCollector.bytecode
|
||||
)
|
||||
await contractHandler.getAccounts()
|
||||
nftOwner = contractHandler.accounts[0]
|
||||
user1 = contractHandler.accounts[1]
|
||||
user2 = contractHandler.accounts[2]
|
||||
user3 = contractHandler.accounts[3]
|
||||
await contractHandler.deployContracts(nftOwner, Router.abi as AbiItem[])
|
||||
})
|
||||
|
||||
it('should initialize NFTFactory instance and create a new NFT', async () => {
|
||||
nftFactory = new NFTFactory(
|
||||
contractHandler.factory721Address,
|
||||
web3,
|
||||
ERC721Factory.abi as AbiItem[]
|
||||
)
|
||||
const nftData = {
|
||||
name: nftName,
|
||||
symbol: nftSymbol,
|
||||
templateIndex: 1,
|
||||
baseURI: 'https://oceanprotocol.com/nft/'
|
||||
}
|
||||
|
||||
nftAddress = await nftFactory.createNFT(nftOwner, nftData)
|
||||
nftDatatoken = new NFTDatatoken(web3, ERC721Template.abi as AbiItem[])
|
||||
})
|
||||
|
||||
it('#createERC20 - should create a new ERC20 DT from NFT contract', async () => {
|
||||
const erc20Address = await nftDatatoken.createERC20(
|
||||
nftAddress,
|
||||
nftOwner,
|
||||
nftOwner,
|
||||
user1,
|
||||
user2,
|
||||
'0x0000000000000000000000000000000000000000',
|
||||
'0',
|
||||
'10000',
|
||||
nftName,
|
||||
nftSymbol,
|
||||
1
|
||||
)
|
||||
assert(erc20Address !== null)
|
||||
})
|
||||
|
||||
// Manager
|
||||
it('#addManager - should add a new Manager', async () => {
|
||||
assert((await nftDatatoken.getNFTPermissions(nftAddress, user1)).manager === false)
|
||||
|
||||
await nftDatatoken.addManager(nftAddress, nftOwner, user1)
|
||||
|
||||
assert((await nftDatatoken.getNFTPermissions(nftAddress, user1)).manager === true)
|
||||
})
|
||||
|
||||
it('#addManager - should fail to add a new Manager, if NOT NFT Owner', async () => {
|
||||
try {
|
||||
await nftDatatoken.addManager(nftAddress, user1, user1)
|
||||
} catch (e) {
|
||||
assert(e.message === 'Caller is not NFT Owner')
|
||||
}
|
||||
})
|
||||
|
||||
it('#removeManager - should remove a Manager', async () => {
|
||||
assert((await nftDatatoken.getNFTPermissions(nftAddress, user1)).manager === true)
|
||||
|
||||
await nftDatatoken.removeManager(nftAddress, nftOwner, user1)
|
||||
|
||||
assert((await nftDatatoken.getNFTPermissions(nftAddress, user1)).manager === false)
|
||||
})
|
||||
|
||||
it('#removeManager - should fail to remove a new Manager, if NOT NFT Owner', async () => {
|
||||
try {
|
||||
await nftDatatoken.removeManager(nftAddress, user1, nftOwner)
|
||||
} catch (e) {
|
||||
assert(e.message === 'Caller is not NFT Owner')
|
||||
}
|
||||
})
|
||||
|
||||
// ERC20Deployer
|
||||
it('#addERC20Deployer -should add ERC20deployer if Manager', async () => {
|
||||
assert((await nftDatatoken.isErc20Deployer(nftAddress, user1)) === false)
|
||||
|
||||
await nftDatatoken.addERC20Deployer(nftAddress, nftOwner, user1)
|
||||
|
||||
assert((await nftDatatoken.isErc20Deployer(nftAddress, user1)) === true)
|
||||
})
|
||||
|
||||
it('#addERC20Deployer - should fail to add ERC20deployer if NOT Manager', async () => {
|
||||
try {
|
||||
await nftDatatoken.addERC20Deployer(nftAddress, user1, user1)
|
||||
} catch (e) {
|
||||
assert(
|
||||
e.message ===
|
||||
'Returned error: VM Exception while processing transaction: revert ERC721RolesAddress: NOT MANAGER'
|
||||
)
|
||||
}
|
||||
})
|
||||
|
||||
it('#removeERC20Deployer - remove ERC20deployer if Manager', async () => {
|
||||
assert((await nftDatatoken.isErc20Deployer(nftAddress, user1)) === true)
|
||||
|
||||
await nftDatatoken.removeERC20Deployer(nftAddress, nftOwner, user1)
|
||||
|
||||
assert((await nftDatatoken.isErc20Deployer(nftAddress, user1)) === false)
|
||||
})
|
||||
|
||||
it('#removeERC20Deployer - should fail and remove ERC20deployer if NOT Manager', async () => {
|
||||
try {
|
||||
await nftDatatoken.removeERC20Deployer(nftAddress, user1, user1)
|
||||
} catch (e) {
|
||||
assert(
|
||||
e.message ===
|
||||
'Returned error: VM Exception while processing transaction: revert ERC721RolesAddress: Not enough permissions to remove from ERC20List'
|
||||
)
|
||||
}
|
||||
})
|
||||
|
||||
// MetadataUpdate
|
||||
it('#addMetadataUpdate - should add to remove Metadata Updater if Manager', async () => {
|
||||
assert(
|
||||
(await nftDatatoken.getNFTPermissions(nftAddress, user1)).updateMetadata === false
|
||||
)
|
||||
|
||||
await nftDatatoken.addMetadataUpdater(nftAddress, nftOwner, user1)
|
||||
|
||||
assert(
|
||||
(await nftDatatoken.getNFTPermissions(nftAddress, user1)).updateMetadata === true
|
||||
)
|
||||
})
|
||||
|
||||
it('#addMetadataUpdate - should fail to add Metadata Updater if NOT Manager', async () => {
|
||||
try {
|
||||
await nftDatatoken.addMetadataUpdater(nftAddress, user1, user1)
|
||||
} catch (e) {
|
||||
assert(
|
||||
e.message ===
|
||||
'Returned error: VM Exception while processing transaction: revert ERC721RolesAddress: NOT MANAGER'
|
||||
)
|
||||
}
|
||||
})
|
||||
|
||||
it('#removeMetadataUpdate - remove Metadata Updater if Manager', async () => {
|
||||
assert(
|
||||
(await nftDatatoken.getNFTPermissions(nftAddress, user1)).updateMetadata === true
|
||||
)
|
||||
|
||||
await nftDatatoken.removeMetadataUpdater(nftAddress, nftOwner, user1)
|
||||
|
||||
assert(
|
||||
(await nftDatatoken.getNFTPermissions(nftAddress, user1)).updateMetadata === false
|
||||
)
|
||||
})
|
||||
|
||||
it('#removeMetadataUpdate - should fail to remove Metadata Updater if NOT Manager', async () => {
|
||||
try {
|
||||
await nftDatatoken.removeMetadataUpdater(nftAddress, user1, user1)
|
||||
} catch (e) {
|
||||
assert(
|
||||
e.message ===
|
||||
'Returned error: VM Exception while processing transaction: revert ERC721RolesAddress: Not enough permissions to remove from metadata list'
|
||||
)
|
||||
}
|
||||
})
|
||||
|
||||
// StoreUpdater
|
||||
it('#addStoreUpdater - should add to remove Store Updater if Manager', async () => {
|
||||
assert((await nftDatatoken.getNFTPermissions(nftAddress, user1)).store === false)
|
||||
|
||||
await nftDatatoken.addStoreUpdater(nftAddress, nftOwner, user1)
|
||||
|
||||
assert((await nftDatatoken.getNFTPermissions(nftAddress, user1)).store === true)
|
||||
})
|
||||
|
||||
it('#addStoreUpdater - should fail to add Store Updater if NOT Manager', async () => {
|
||||
try {
|
||||
await nftDatatoken.addStoreUpdater(nftAddress, user1, user1)
|
||||
} catch (e) {
|
||||
assert(
|
||||
e.message ===
|
||||
'Returned error: VM Exception while processing transaction: revert ERC721RolesAddress: NOT MANAGER'
|
||||
)
|
||||
}
|
||||
})
|
||||
|
||||
it('#removeStoreUpdater - remove Metadata Updater if Manager', async () => {
|
||||
assert((await nftDatatoken.getNFTPermissions(nftAddress, user1)).store === true)
|
||||
|
||||
await nftDatatoken.removeStoreUpdater(nftAddress, nftOwner, user1)
|
||||
|
||||
assert((await nftDatatoken.getNFTPermissions(nftAddress, user1)).store === false)
|
||||
})
|
||||
|
||||
it('#removeStoreUpdater - should fail to remove Metadata Updater if NOT Manager', async () => {
|
||||
try {
|
||||
await nftDatatoken.removeStoreUpdater(nftAddress, user1, user1)
|
||||
} catch (e) {
|
||||
assert(
|
||||
e.message ===
|
||||
'Returned error: VM Exception while processing transaction: revert ERC721RolesAddress: Not enough permissions to remove from 725StoreList'
|
||||
)
|
||||
}
|
||||
})
|
||||
|
||||
// Transfer test
|
||||
it('#transferNFT - should fail to transfer the NFT and clean all permissions, if NOT NFT Owner', async () => {
|
||||
assert((await nftDatatoken.getNFTOwner(nftAddress)) !== user1)
|
||||
|
||||
try {
|
||||
await nftDatatoken.transferNFT(nftAddress, user1, user1, 1)
|
||||
} catch (e) {
|
||||
assert(e.message === 'Caller is not NFT Owner')
|
||||
}
|
||||
})
|
||||
|
||||
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.getNFTOwner(nftAddress)) === nftOwner)
|
||||
await nftDatatoken.transferNFT(nftAddress, nftOwner, user1, 1)
|
||||
assert((await nftDatatoken.getNFTOwner(nftAddress)) === user1)
|
||||
|
||||
// console.log(await nftDatatoken.isErc20Deployer(nftAddress, user1))
|
||||
// assert((await nftDatatoken.isErc20Deployer(nftAddress, user1)) === false)
|
||||
})
|
||||
|
||||
// Clear permisions
|
||||
it('#cleanPermissions - should fail to cleanPermissions if NOT NFTOwner', async () => {
|
||||
try {
|
||||
await nftDatatoken.cleanPermissions(nftAddress, user1)
|
||||
} catch (e) {
|
||||
assert(e.message === 'Caller is not NFT Owner')
|
||||
}
|
||||
})
|
||||
|
||||
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)
|
||||
|
||||
await nftDatatoken.cleanPermissions(nftAddress, user1)
|
||||
|
||||
assert((await nftDatatoken.isErc20Deployer(nftAddress, user2)) === false)
|
||||
assert((await nftDatatoken.getNFTPermissions(nftAddress, nftOwner)).manager === false)
|
||||
})
|
||||
})
|
@ -9,11 +9,17 @@ import Router from '@oceanprotocol/contracts/artifacts/contracts/pools/FactoryRo
|
||||
import ERC20Template from '@oceanprotocol/contracts/artifacts/contracts/templates/ERC20Template.sol/ERC20Template.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 OPFCommunityFeeCollector from '@oceanprotocol/contracts/artifacts/contracts/communityFee/OPFCommunityFeeCollector.sol/OPFCommunityFeeCollector.json'
|
||||
import MockERC20 from '@oceanprotocol/contracts/artifacts/contracts/utils/mock/MockERC20Decimals.sol/MockERC20Decimals.json'
|
||||
import PoolTemplate from '@oceanprotocol/contracts/artifacts/contracts/pools/balancer/BPool.sol/BPool.json'
|
||||
import { LoggerInstance } from '../../src/utils'
|
||||
// import { NFTDataToken } from '../../../src/datatokens/NFTDatatoken'
|
||||
import { NFTFactory } from '../../src/factories/NFTFactory'
|
||||
import { NFTFactory, NFTCreateData } from '../../src/factories/NFTFactory'
|
||||
import {
|
||||
FreCreationParams,
|
||||
Erc20CreateParams,
|
||||
PoolCreationParams
|
||||
} from '../../src/interfaces'
|
||||
|
||||
const web3 = new Web3('http://127.0.0.1:8545')
|
||||
|
||||
@ -40,6 +46,7 @@ describe('NFT Factory test', () => {
|
||||
SideStaking.abi as AbiItem[],
|
||||
FixedRate.abi as AbiItem[],
|
||||
Dispenser.abi as AbiItem[],
|
||||
OPFCommunityFeeCollector.abi as AbiItem[],
|
||||
|
||||
ERC721Template.bytecode,
|
||||
ERC20Template.bytecode,
|
||||
@ -48,7 +55,8 @@ describe('NFT Factory test', () => {
|
||||
Router.bytecode,
|
||||
SideStaking.bytecode,
|
||||
FixedRate.bytecode,
|
||||
Dispenser.bytecode
|
||||
Dispenser.bytecode,
|
||||
OPFCommunityFeeCollector.bytecode
|
||||
)
|
||||
await contracts.getAccounts()
|
||||
factoryOwner = contracts.accounts[0]
|
||||
@ -59,6 +67,17 @@ describe('NFT Factory test', () => {
|
||||
|
||||
await contracts.deployContracts(factoryOwner, Router.abi as AbiItem[])
|
||||
|
||||
console.log(
|
||||
'address',
|
||||
contracts.factory721Address,
|
||||
contracts.poolTemplateAddress,
|
||||
contracts.routerAddress,
|
||||
contracts.fixedRateAddress,
|
||||
contracts.dispenserAddress,
|
||||
contracts.sideStakingAddress,
|
||||
contracts.template721Address,
|
||||
contracts.template20Address
|
||||
)
|
||||
const daiContract = new web3.eth.Contract(
|
||||
contracts.MockERC20.options.jsonInterface,
|
||||
contracts.daiAddress
|
||||
@ -69,7 +88,7 @@ describe('NFT Factory test', () => {
|
||||
})
|
||||
|
||||
it('should initiate NFTFactory instance', async () => {
|
||||
nftFactory = new NFTFactory(contracts.factory721Address, web3, LoggerInstance)
|
||||
nftFactory = new NFTFactory(contracts.factory721Address, web3)
|
||||
})
|
||||
|
||||
it('#getCurrentNFTCount - should return actual nft count (0)', async () => {
|
||||
@ -155,29 +174,29 @@ describe('NFT Factory test', () => {
|
||||
|
||||
it('#createNftwithErc - should create an NFT and a Datatoken ', async () => {
|
||||
// we prepare transaction parameters objects
|
||||
const nftData = {
|
||||
const nftData: NFTCreateData = {
|
||||
name: '72120Bundle',
|
||||
symbol: '72Bundle',
|
||||
templateIndex: 1,
|
||||
baseURI: 'https://oceanprotocol.com/nft/'
|
||||
}
|
||||
const ercData = {
|
||||
|
||||
const ercParams: Erc20CreateParams = {
|
||||
templateIndex: 1,
|
||||
strings: ['ERC20B1', 'ERC20DT1Symbol'],
|
||||
addresses: [
|
||||
contracts.accounts[0],
|
||||
user3,
|
||||
user2,
|
||||
'0x0000000000000000000000000000000000000000'
|
||||
],
|
||||
uints: [web3.utils.toWei('10000'), 0],
|
||||
bytess: []
|
||||
minter: contracts.accounts[0],
|
||||
feeManager: user3,
|
||||
mpFeeAddress: user2,
|
||||
feeToken: '0x0000000000000000000000000000000000000000',
|
||||
cap: '10000',
|
||||
feeAmount: '0',
|
||||
name: 'ERC20B1',
|
||||
symbol: 'ERC20DT1Symbol'
|
||||
}
|
||||
|
||||
const txReceipt = await nftFactory.createNftWithErc(
|
||||
contracts.accounts[0],
|
||||
nftData,
|
||||
ercData
|
||||
ercParams
|
||||
)
|
||||
|
||||
// EVENTS HAVE BEEN EMITTED
|
||||
@ -191,47 +210,46 @@ describe('NFT Factory test', () => {
|
||||
|
||||
it('#createNftErcWithPool- should create an NFT, a Datatoken and a pool DT/DAI', async () => {
|
||||
// we prepare transaction parameters objects
|
||||
const nftData = {
|
||||
const nftData: NFTCreateData = {
|
||||
name: '72120Bundle',
|
||||
symbol: '72Bundle',
|
||||
templateIndex: 1,
|
||||
baseURI: 'https://oceanprotocol.com/nft/'
|
||||
}
|
||||
const ercData = {
|
||||
|
||||
const ercParams: Erc20CreateParams = {
|
||||
templateIndex: 1,
|
||||
strings: ['ERC20B1', 'ERC20DT1Symbol'],
|
||||
addresses: [user2, user3, user2, '0x0000000000000000000000000000000000000000'],
|
||||
uints: [web3.utils.toWei('1000000'), 0],
|
||||
bytess: []
|
||||
minter: user2,
|
||||
feeManager: user3,
|
||||
mpFeeAddress: user2,
|
||||
feeToken: '0x0000000000000000000000000000000000000000',
|
||||
cap: '1000000',
|
||||
feeAmount: '0',
|
||||
name: 'ERC20B1',
|
||||
symbol: 'ERC20DT1Symbol'
|
||||
}
|
||||
|
||||
const poolData = {
|
||||
addresses: [
|
||||
contracts.sideStakingAddress,
|
||||
contracts.daiAddress,
|
||||
contracts.factory721Address,
|
||||
contracts.accounts[0],
|
||||
contracts.accounts[0],
|
||||
contracts.poolTemplateAddress
|
||||
],
|
||||
ssParams: [
|
||||
web3.utils.toWei('1'), // rate
|
||||
18, // basetokenDecimals
|
||||
web3.utils.toWei('10000'),
|
||||
2500000, // vested blocks
|
||||
web3.utils.toWei('2000') // baseToken initial pool liquidity
|
||||
],
|
||||
swapFees: [
|
||||
1e15, //
|
||||
1e15
|
||||
]
|
||||
const poolParams: PoolCreationParams = {
|
||||
ssContract: contracts.sideStakingAddress,
|
||||
basetokenAddress: contracts.daiAddress,
|
||||
basetokenSender: contracts.factory721Address,
|
||||
publisherAddress: contracts.accounts[0],
|
||||
marketFeeCollector: contracts.accounts[0],
|
||||
poolTemplateAddress: contracts.poolTemplateAddress,
|
||||
rate: '1',
|
||||
basetokenDecimals: 18,
|
||||
vestingAmount: '10000',
|
||||
vestedBlocks: 2500000,
|
||||
initialBasetokenLiquidity: '2000',
|
||||
swapFeeLiquidityProvider: 1e15,
|
||||
swapFeeMarketPlaceRunner: 1e15
|
||||
}
|
||||
|
||||
const txReceipt = await nftFactory.createNftErcWithPool(
|
||||
contracts.accounts[0],
|
||||
nftData,
|
||||
ercData,
|
||||
poolData
|
||||
ercParams,
|
||||
poolParams
|
||||
)
|
||||
|
||||
// EVENTS HAVE BEEN EMITTED
|
||||
@ -242,36 +260,43 @@ describe('NFT Factory test', () => {
|
||||
|
||||
it('#createNftErcWithFixedRate- should create an NFT, a datatoken and create a Fixed Rate Exchange', async () => {
|
||||
// we prepare transaction parameters objects
|
||||
const nftData = {
|
||||
const nftData: NFTCreateData = {
|
||||
name: '72120Bundle',
|
||||
symbol: '72Bundle',
|
||||
templateIndex: 1,
|
||||
baseURI: 'https://oceanprotocol.com/nft/'
|
||||
}
|
||||
const ercData = {
|
||||
|
||||
const ercParams: Erc20CreateParams = {
|
||||
templateIndex: 1,
|
||||
strings: ['ERC20B1', 'ERC20DT1Symbol'],
|
||||
addresses: [
|
||||
contracts.accounts[0],
|
||||
user3,
|
||||
user2,
|
||||
'0x0000000000000000000000000000000000000000'
|
||||
],
|
||||
uints: [web3.utils.toWei('1000000'), 0],
|
||||
bytess: []
|
||||
minter: contracts.accounts[0],
|
||||
feeManager: user3,
|
||||
mpFeeAddress: user2,
|
||||
feeToken: '0x0000000000000000000000000000000000000000',
|
||||
cap: '1000000',
|
||||
feeAmount: '0',
|
||||
name: 'ERC20B1',
|
||||
symbol: 'ERC20DT1Symbol'
|
||||
}
|
||||
|
||||
const fixedData = {
|
||||
fixedPriceAddress: contracts.fixedRateAddress,
|
||||
addresses: [contracts.daiAddress, contracts.accounts[0], contracts.accounts[0]],
|
||||
uints: [18, 18, web3.utils.toWei('1'), 1e15]
|
||||
const freParams: FreCreationParams = {
|
||||
fixedRateAddress: contracts.fixedRateAddress,
|
||||
baseTokenAddress: contracts.daiAddress,
|
||||
owner: contracts.accounts[0],
|
||||
marketFeeCollector: contracts.accounts[0],
|
||||
baseTokenDecimals: 18,
|
||||
dataTokenDecimals: 18,
|
||||
fixedRate: '1',
|
||||
marketFee: 1e15,
|
||||
allowedConsumer: contracts.accounts[0],
|
||||
withMint: false
|
||||
}
|
||||
|
||||
const txReceipt = await nftFactory.createNftErcWithFixedRate(
|
||||
contracts.accounts[0],
|
||||
nftData,
|
||||
ercData,
|
||||
fixedData
|
||||
ercParams,
|
||||
freParams
|
||||
)
|
||||
|
||||
// EVENTS HAVE BEEN EMITTED
|
||||
@ -345,6 +370,7 @@ describe('NFT Factory test', () => {
|
||||
expect(await dtContract.methods.balanceOf(user2).call()).to.equal('0')
|
||||
expect(await dtContract2.methods.balanceOf(user2).call()).to.equal('0')
|
||||
})
|
||||
|
||||
it('#checkDatatoken - should confirm if DT is from the factory', async () => {
|
||||
assert((await nftFactory.checkDatatoken(dtAddress)) === true)
|
||||
assert((await nftFactory.checkDatatoken(dtAddress2)) === true)
|
||||
|
@ -10,10 +10,13 @@ import ERC20Template from '@oceanprotocol/contracts/artifacts/contracts/template
|
||||
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 MockERC20 from '@oceanprotocol/contracts/artifacts/contracts/utils/mock/MockERC20Decimals.sol/MockERC20Decimals.json'
|
||||
import OPFCommunityFeeCollector from '@oceanprotocol/contracts/artifacts/contracts/communityFee/OPFCommunityFeeCollector.sol/OPFCommunityFeeCollector.json'
|
||||
import PoolTemplate from '@oceanprotocol/contracts/artifacts/contracts/pools/balancer/BPool.sol/BPool.json'
|
||||
import { LoggerInstance } from '../../../src/utils'
|
||||
import { NFTFactory } from '../../../src/factories/NFTFactory'
|
||||
import { NFTFactory, NFTCreateData } from '../../../src/factories/NFTFactory'
|
||||
import { Router } from '../../../src/pools/Router'
|
||||
import { BigNumber } from 'bignumber.js'
|
||||
import { Erc20CreateParams, PoolCreationParams } from '../../../src/interfaces'
|
||||
const { keccak256 } = require('@ethersproject/keccak256')
|
||||
const web3 = new Web3('http://127.0.0.1:8545')
|
||||
const communityCollector = '0xeE9300b7961e0a01d9f0adb863C7A227A07AaD75'
|
||||
@ -41,6 +44,7 @@ describe('Router unit test', () => {
|
||||
SideStaking.abi as AbiItem[],
|
||||
FixedRate.abi as AbiItem[],
|
||||
Dispenser.abi as AbiItem[],
|
||||
OPFCommunityFeeCollector.abi as AbiItem[],
|
||||
|
||||
ERC721Template.bytecode,
|
||||
ERC20Template.bytecode,
|
||||
@ -49,7 +53,8 @@ describe('Router unit test', () => {
|
||||
FactoryRouter.bytecode,
|
||||
SideStaking.bytecode,
|
||||
FixedRate.bytecode,
|
||||
Dispenser.bytecode
|
||||
Dispenser.bytecode,
|
||||
OPFCommunityFeeCollector.bytecode
|
||||
)
|
||||
await contracts.getAccounts()
|
||||
factoryOwner = contracts.accounts[0]
|
||||
@ -74,7 +79,7 @@ describe('Router unit test', () => {
|
||||
})
|
||||
|
||||
it('should initiate Router instance', async () => {
|
||||
router = new Router(contracts.routerAddress, web3, LoggerInstance)
|
||||
router = new Router(contracts.routerAddress, web3)
|
||||
})
|
||||
|
||||
it('#getOwner - should return actual owner', async () => {
|
||||
@ -98,8 +103,6 @@ describe('Router unit test', () => {
|
||||
it('#isFixedPrice - should return true if in fixedPrice list', async () => {
|
||||
expect(await router.isFixedPrice(contracts.fixedRateAddress)).to.equal(true)
|
||||
expect(await router.isFixedPrice(contracts.daiAddress)).to.equal(false)
|
||||
// Dispenser contract is also a fixed price contract
|
||||
expect(await router.isFixedPrice(contracts.dispenserAddress)).to.equal(true)
|
||||
})
|
||||
it('#isPoolTemplate - should return true if in poolTemplates list', async () => {
|
||||
expect(await router.isPoolTemplate(contracts.poolTemplateAddress)).to.equal(true)
|
||||
@ -171,54 +174,52 @@ describe('Router unit test', () => {
|
||||
|
||||
// CREATE A FIRST POOL
|
||||
// we prepare transaction parameters objects
|
||||
const nftData = {
|
||||
const nftData: NFTCreateData = {
|
||||
name: '72120Bundle',
|
||||
symbol: '72Bundle',
|
||||
templateIndex: 1,
|
||||
baseURI: 'https://oceanprotocol.com/nft/'
|
||||
}
|
||||
const ercData = {
|
||||
|
||||
const ercParams: Erc20CreateParams = {
|
||||
templateIndex: 1,
|
||||
strings: ['ERC20B1', 'ERC20DT1Symbol'],
|
||||
addresses: [
|
||||
contracts.accounts[0],
|
||||
user3,
|
||||
contracts.accounts[0],
|
||||
'0x0000000000000000000000000000000000000000'
|
||||
],
|
||||
uints: [web3.utils.toWei('1000000'), 0],
|
||||
bytess: []
|
||||
minter: contracts.accounts[0],
|
||||
feeManager: user3,
|
||||
mpFeeAddress: contracts.accounts[0],
|
||||
feeToken: '0x0000000000000000000000000000000000000000',
|
||||
cap: '1000000',
|
||||
feeAmount: '0',
|
||||
name: 'ERC20B1',
|
||||
symbol: 'ERC20DT1Symbol'
|
||||
}
|
||||
|
||||
const poolData = {
|
||||
addresses: [
|
||||
contracts.sideStakingAddress,
|
||||
contracts.daiAddress,
|
||||
contracts.factory721Address,
|
||||
contracts.accounts[0],
|
||||
contracts.accounts[0],
|
||||
contracts.poolTemplateAddress
|
||||
],
|
||||
ssParams: [
|
||||
web3.utils.toWei('1'), // rate
|
||||
18, // basetokenDecimals
|
||||
web3.utils.toWei('10000'),
|
||||
2500000, // vested blocks
|
||||
web3.utils.toWei('2000') // baseToken initial pool liquidity
|
||||
],
|
||||
swapFees: [
|
||||
1e15, //
|
||||
1e15
|
||||
]
|
||||
const poolParams: PoolCreationParams = {
|
||||
ssContract: contracts.sideStakingAddress,
|
||||
basetokenAddress: contracts.daiAddress,
|
||||
basetokenSender: contracts.factory721Address,
|
||||
publisherAddress: contracts.accounts[0],
|
||||
marketFeeCollector: contracts.accounts[0],
|
||||
poolTemplateAddress: contracts.poolTemplateAddress,
|
||||
rate: '1',
|
||||
basetokenDecimals: 18,
|
||||
vestingAmount: '10000',
|
||||
vestedBlocks: 2500000,
|
||||
initialBasetokenLiquidity: '2000',
|
||||
swapFeeLiquidityProvider: 1e15,
|
||||
swapFeeMarketPlaceRunner: 1e15
|
||||
}
|
||||
|
||||
const nftFactory = new NFTFactory(contracts.factory721Address, web3, LoggerInstance)
|
||||
const nftFactory = new NFTFactory(
|
||||
contracts.factory721Address,
|
||||
web3,
|
||||
ERC721Factory.abi as AbiItem[]
|
||||
)
|
||||
|
||||
const txReceipt = await nftFactory.createNftErcWithPool(
|
||||
contracts.accounts[0],
|
||||
nftData,
|
||||
ercData,
|
||||
poolData
|
||||
ercParams,
|
||||
poolParams
|
||||
)
|
||||
|
||||
const erc20Token = txReceipt.events.TokenCreated.returnValues.newTokenAddress
|
||||
@ -226,52 +227,46 @@ describe('Router unit test', () => {
|
||||
|
||||
// CREATE A SECOND POOL
|
||||
|
||||
const nftData2 = {
|
||||
const nftData2: NFTCreateData = {
|
||||
name: '72120Bundle2',
|
||||
symbol: '72Bundle2',
|
||||
templateIndex: 1,
|
||||
baseURI: 'https://oceanprotocol.com/nft2/'
|
||||
}
|
||||
const ercData2 = {
|
||||
|
||||
const ercParams2: Erc20CreateParams = {
|
||||
templateIndex: 1,
|
||||
strings: ['ERC20B12', 'ERC20DT1Symbol2'],
|
||||
addresses: [
|
||||
contracts.accounts[0],
|
||||
user3,
|
||||
contracts.accounts[0],
|
||||
'0x0000000000000000000000000000000000000000'
|
||||
],
|
||||
uints: [web3.utils.toWei('1000000'), 0],
|
||||
bytess: []
|
||||
minter: contracts.accounts[0],
|
||||
feeManager: user3,
|
||||
mpFeeAddress: contracts.accounts[0],
|
||||
feeToken: '0x0000000000000000000000000000000000000000',
|
||||
cap: '1000000',
|
||||
feeAmount: '0',
|
||||
name: 'ERC20B12',
|
||||
symbol: 'ERC20DT1Symbol2'
|
||||
}
|
||||
|
||||
const poolData2 = {
|
||||
addresses: [
|
||||
contracts.sideStakingAddress,
|
||||
contracts.daiAddress,
|
||||
contracts.factory721Address,
|
||||
contracts.accounts[0],
|
||||
contracts.accounts[0],
|
||||
contracts.poolTemplateAddress
|
||||
],
|
||||
ssParams: [
|
||||
web3.utils.toWei('1'), // rate
|
||||
18, // basetokenDecimals
|
||||
web3.utils.toWei('10000'),
|
||||
2500000, // vested blocks
|
||||
web3.utils.toWei('2000') // baseToken initial pool liquidity
|
||||
],
|
||||
swapFees: [
|
||||
1e15, //
|
||||
1e15
|
||||
]
|
||||
const poolParams2: PoolCreationParams = {
|
||||
ssContract: contracts.sideStakingAddress,
|
||||
basetokenAddress: contracts.daiAddress,
|
||||
basetokenSender: contracts.factory721Address,
|
||||
publisherAddress: contracts.accounts[0],
|
||||
marketFeeCollector: contracts.accounts[0],
|
||||
poolTemplateAddress: contracts.poolTemplateAddress,
|
||||
rate: '1',
|
||||
basetokenDecimals: 18,
|
||||
vestingAmount: '10000',
|
||||
vestedBlocks: 2500000,
|
||||
initialBasetokenLiquidity: '2000',
|
||||
swapFeeLiquidityProvider: 1e15,
|
||||
swapFeeMarketPlaceRunner: 1e15
|
||||
}
|
||||
|
||||
const txReceipt2 = await nftFactory.createNftErcWithPool(
|
||||
contracts.accounts[0],
|
||||
nftData2,
|
||||
ercData2,
|
||||
poolData2
|
||||
ercParams2,
|
||||
poolParams2
|
||||
)
|
||||
|
||||
const erc20Token2 = txReceipt2.events.TokenCreated.returnValues.newTokenAddress
|
||||
|
@ -15,8 +15,9 @@ import MockERC20 from '@oceanprotocol/contracts/artifacts/contracts/utils/mock/M
|
||||
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 { LoggerInstance } from '../../../../src/utils'
|
||||
import { NFTFactory } from '../../../../src/factories/NFTFactory'
|
||||
import { NFTFactory, NFTCreateData } from '../../../../src/factories/NFTFactory'
|
||||
import { Pool } from '../../../../src/pools/balancer/Pool'
|
||||
import { PoolCreationParams, Erc20CreateParams } from '../../../../src/interfaces'
|
||||
const { keccak256 } = require('@ethersproject/keccak256')
|
||||
const web3 = new Web3('http://127.0.0.1:8545')
|
||||
const communityCollector = '0xeE9300b7961e0a01d9f0adb863C7A227A07AaD75'
|
||||
@ -131,56 +132,54 @@ describe('Pool unit test', () => {
|
||||
it('#create a pool', async () => {
|
||||
// CREATE A POOL
|
||||
// we prepare transaction parameters objects
|
||||
const nftData = {
|
||||
const nftData: NFTCreateData = {
|
||||
name: '72120Bundle',
|
||||
symbol: '72Bundle',
|
||||
templateIndex: 1,
|
||||
baseURI: 'https://oceanprotocol.com/nft/'
|
||||
}
|
||||
const ercData = {
|
||||
|
||||
const ercParams: Erc20CreateParams = {
|
||||
templateIndex: 1,
|
||||
strings: ['ERC20B1', 'ERC20DT1Symbol'],
|
||||
addresses: [
|
||||
contracts.accounts[0],
|
||||
user3,
|
||||
contracts.accounts[0],
|
||||
'0x0000000000000000000000000000000000000000'
|
||||
],
|
||||
uints: [web3.utils.toWei('1000000'), 0],
|
||||
bytess: []
|
||||
minter: contracts.accounts[0],
|
||||
feeManager: user3,
|
||||
mpFeeAddress: contracts.accounts[0],
|
||||
feeToken: '0x0000000000000000000000000000000000000000',
|
||||
cap: '1000000',
|
||||
feeAmount: '0',
|
||||
name: 'ERC20B1',
|
||||
symbol: 'ERC20DT1Symbol'
|
||||
}
|
||||
|
||||
const basetokenInitialLiq = await pool.amountToUnits(contracts.daiAddress, '2000')
|
||||
|
||||
const poolData = {
|
||||
addresses: [
|
||||
contracts.sideStakingAddress,
|
||||
contracts.daiAddress,
|
||||
contracts.factory721Address,
|
||||
contracts.accounts[0],
|
||||
contracts.accounts[0],
|
||||
contracts.poolTemplateAddress
|
||||
],
|
||||
ssParams: [
|
||||
web3.utils.toWei('1'), // rate
|
||||
18, // basetokenDecimals
|
||||
web3.utils.toWei('10000'),
|
||||
2500000, // vested blocks
|
||||
web3.utils.toWei('2000') // baseToken initial pool liquidity
|
||||
],
|
||||
swapFees: [
|
||||
1e15, //
|
||||
1e15
|
||||
]
|
||||
const poolParams: PoolCreationParams = {
|
||||
ssContract: contracts.sideStakingAddress,
|
||||
basetokenAddress: contracts.daiAddress,
|
||||
basetokenSender: contracts.factory721Address,
|
||||
publisherAddress: contracts.accounts[0],
|
||||
marketFeeCollector: contracts.accounts[0],
|
||||
poolTemplateAddress: contracts.poolTemplateAddress,
|
||||
rate: '1',
|
||||
basetokenDecimals: 18,
|
||||
vestingAmount: '10000',
|
||||
vestedBlocks: 2500000,
|
||||
initialBasetokenLiquidity: '2000',
|
||||
swapFeeLiquidityProvider: 1e15,
|
||||
swapFeeMarketPlaceRunner: 1e15
|
||||
}
|
||||
|
||||
const nftFactory = new NFTFactory(contracts.factory721Address, web3, LoggerInstance)
|
||||
const nftFactory = new NFTFactory(
|
||||
contracts.factory721Address,
|
||||
web3,
|
||||
ERC721Factory.abi as AbiItem[]
|
||||
)
|
||||
|
||||
const txReceipt = await nftFactory.createNftErcWithPool(
|
||||
contracts.accounts[0],
|
||||
nftData,
|
||||
ercData,
|
||||
poolData
|
||||
ercParams,
|
||||
poolParams
|
||||
)
|
||||
|
||||
erc20Token = txReceipt.events.TokenCreated.returnValues.newTokenAddress
|
||||
@ -576,57 +575,54 @@ describe('Pool unit test', () => {
|
||||
it('#create a pool', async () => {
|
||||
// CREATE A POOL
|
||||
// we prepare transaction parameters objects
|
||||
const nftData = {
|
||||
const nftData: NFTCreateData = {
|
||||
name: '72120Bundle',
|
||||
symbol: '72Bundle',
|
||||
templateIndex: 1,
|
||||
baseURI: 'https://oceanprotocol.com/nft/'
|
||||
}
|
||||
const ercData = {
|
||||
|
||||
const ercParams: Erc20CreateParams = {
|
||||
templateIndex: 1,
|
||||
strings: ['ERC20B1', 'ERC20DT1Symbol'],
|
||||
addresses: [
|
||||
contracts.accounts[0],
|
||||
user3,
|
||||
contracts.accounts[0],
|
||||
'0x0000000000000000000000000000000000000000'
|
||||
],
|
||||
uints: [web3.utils.toWei('1000000'), 0],
|
||||
bytess: []
|
||||
}
|
||||
const basetokenInitialLiq = Number(
|
||||
await pool.amountToUnits(contracts.usdcAddress, '2000')
|
||||
)
|
||||
console.log(basetokenInitialLiq.toString())
|
||||
const poolData = {
|
||||
addresses: [
|
||||
contracts.sideStakingAddress,
|
||||
contracts.usdcAddress,
|
||||
contracts.factory721Address,
|
||||
contracts.accounts[0],
|
||||
contracts.accounts[0],
|
||||
contracts.poolTemplateAddress
|
||||
],
|
||||
ssParams: [
|
||||
web3.utils.toWei('1'), // rate
|
||||
await usdcContract.methods.decimals().call(), // basetokenDecimals
|
||||
web3.utils.toWei('10000'),
|
||||
2500000, // vested blocks
|
||||
basetokenInitialLiq // baseToken initial pool liquidity
|
||||
],
|
||||
swapFees: [
|
||||
1e15, //
|
||||
1e15
|
||||
]
|
||||
minter: contracts.accounts[0],
|
||||
feeManager: user3,
|
||||
mpFeeAddress: contracts.accounts[0],
|
||||
feeToken: '0x0000000000000000000000000000000000000000',
|
||||
cap: '1000000',
|
||||
feeAmount: '0',
|
||||
name: 'ERC20B1',
|
||||
symbol: 'ERC20DT1Symbol'
|
||||
}
|
||||
|
||||
const nftFactory = new NFTFactory(contracts.factory721Address, web3, LoggerInstance)
|
||||
const poolParams: PoolCreationParams = {
|
||||
ssContract: contracts.sideStakingAddress,
|
||||
basetokenAddress: contracts.usdcAddress,
|
||||
basetokenSender: contracts.factory721Address,
|
||||
publisherAddress: contracts.accounts[0],
|
||||
marketFeeCollector: contracts.accounts[0],
|
||||
poolTemplateAddress: contracts.poolTemplateAddress,
|
||||
rate: '1',
|
||||
basetokenDecimals: await usdcContract.methods.decimals().call(),
|
||||
vestingAmount: '10000',
|
||||
vestedBlocks: 2500000,
|
||||
initialBasetokenLiquidity: web3.utils.fromWei(
|
||||
await pool.amountToUnits(contracts.usdcAddress, '2000')
|
||||
),
|
||||
swapFeeLiquidityProvider: 1e15,
|
||||
swapFeeMarketPlaceRunner: 1e15
|
||||
}
|
||||
|
||||
const nftFactory = new NFTFactory(
|
||||
contracts.factory721Address,
|
||||
web3,
|
||||
ERC721Factory.abi as AbiItem[]
|
||||
)
|
||||
|
||||
const txReceipt = await nftFactory.createNftErcWithPool(
|
||||
contracts.accounts[0],
|
||||
nftData,
|
||||
ercData,
|
||||
poolData
|
||||
ercParams,
|
||||
poolParams
|
||||
)
|
||||
|
||||
erc20Token = txReceipt.events.TokenCreated.returnValues.newTokenAddress
|
||||
|
Loading…
x
Reference in New Issue
Block a user