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

get addresses from config file instead of deploying it

This commit is contained in:
Miquel A. Cabot 2022-05-09 11:19:34 +02:00
parent 1749b0d989
commit 55fec840c3

View File

@ -113,8 +113,7 @@ import {
TokenInOutMarket, TokenInOutMarket,
ZERO_ADDRESS ZERO_ADDRESS
} from '../../src' } from '../../src'
import { getTestConfig, web3 } from '../config' import { getAddresses, getTestConfig, web3 } from '../config'
import { Addresses, deployContracts } from '../TestContractHandler'
/// ``` /// ```
/// <!-- /// <!--
@ -130,7 +129,7 @@ describe('Marketplace flow tests', async () => {
let publisherAccount: string let publisherAccount: string
let consumerAccount: string let consumerAccount: string
let stakerAccount: string let stakerAccount: string
let contracts: Addresses let addresses: any
let poolNftAddress: string let poolNftAddress: string
let poolDatatokenAddress: string let poolDatatokenAddress: string
let poolAddress: string let poolAddress: string
@ -224,9 +223,9 @@ describe('Marketplace flow tests', async () => {
}) /// }) ///
/// ``` /// ```
it('5.2 Next, lets deploy the contracts', async () => { it('5.2 Next, lets get the address of the deployed contracts', async () => {
/// ```Typescript /// ```Typescript
contracts = await deployContracts(web3, publisherAccount) addresses = getAddresses()
}) /// }) ///
/// ``` /// ```
@ -234,7 +233,7 @@ describe('Marketplace flow tests', async () => {
/// ```Typescript /// ```Typescript
const oceanContract = new web3.eth.Contract( const oceanContract = new web3.eth.Contract(
MockERC20.abi as AbiItem[], MockERC20.abi as AbiItem[],
contracts.oceanAddress addresses.Ocean
) )
await oceanContract.methods await oceanContract.methods
@ -253,7 +252,7 @@ describe('Marketplace flow tests', async () => {
it('6.1 Publish a dataset (create NFT + Datatoken) with a liquidity pool', async () => { it('6.1 Publish a dataset (create NFT + Datatoken) with a liquidity pool', async () => {
/// ```Typescript /// ```Typescript
const factory = new NftFactory(contracts.erc721FactoryAddress, web3) const factory = new NftFactory(addresses.ERC721Factory, web3)
const nftParams: NftCreateData = { const nftParams: NftCreateData = {
name: POOL_NFT_NAME, name: POOL_NFT_NAME,
@ -275,12 +274,12 @@ describe('Marketplace flow tests', async () => {
} }
const poolParams: PoolCreationParams = { const poolParams: PoolCreationParams = {
ssContract: contracts.sideStakingAddress, ssContract: addresses.Staking,
baseTokenAddress: contracts.oceanAddress, baseTokenAddress: addresses.Ocean,
baseTokenSender: contracts.erc721FactoryAddress, baseTokenSender: addresses.ERC721Factory,
publisherAddress: publisherAccount, publisherAddress: publisherAccount,
marketFeeCollector: publisherAccount, marketFeeCollector: publisherAccount,
poolTemplateAddress: contracts.poolTemplateAddress, poolTemplateAddress: addresses.poolTemplate,
rate: '1', rate: '1',
baseTokenDecimals: 18, baseTokenDecimals: 18,
vestingAmount: '10000', vestingAmount: '10000',
@ -295,8 +294,8 @@ describe('Marketplace flow tests', async () => {
await approve( await approve(
web3, web3,
publisherAccount, publisherAccount,
contracts.oceanAddress, addresses.Ocean,
contracts.erc721FactoryAddress, addresses.ERC721Factory,
poolParams.vestingAmount poolParams.vestingAmount
) )
@ -367,7 +366,7 @@ describe('Marketplace flow tests', async () => {
/// ``` /// ```
/// Before we call the contract we have to call `approve` so that the contract can move our tokens. This is standard when using any ERC20 tokens /// Before we call the contract we have to call `approve` so that the contract can move our tokens. This is standard when using any ERC20 tokens
/// ```Typescript /// ```Typescript
await approve(web3, stakerAccount, contracts.oceanAddress, poolAddress, '5', true) await approve(web3, stakerAccount, addresses.Ocean, poolAddress, '5', true)
/// ``` /// ```
/// Now we can make the contract call /// Now we can make the contract call
@ -382,7 +381,7 @@ describe('Marketplace flow tests', async () => {
const prices = await pool.getAmountInExactOut( const prices = await pool.getAmountInExactOut(
poolAddress, poolAddress,
poolDatatokenAddress, poolDatatokenAddress,
contracts.oceanAddress, addresses.Ocean,
'1', '1',
'0.01' '0.01'
) )
@ -404,7 +403,7 @@ describe('Marketplace flow tests', async () => {
console.log(`Consumer ETH balance: ${consumerETHBalance}`) console.log(`Consumer ETH balance: ${consumerETHBalance}`)
let consumerOCEANBalance = await balance( let consumerOCEANBalance = await balance(
web3, web3,
contracts.oceanAddress, addresses.Ocean,
consumerAccount consumerAccount
) )
/// ``` /// ```
@ -420,11 +419,11 @@ describe('Marketplace flow tests', async () => {
/// ``` /// ```
/// Before we call the contract we have to call `approve` so that the contract can move our tokens. This is standard when using any ERC20 tokens /// Before we call the contract we have to call `approve` so that the contract can move our tokens. This is standard when using any ERC20 tokens
/// ```Typescript /// ```Typescript
await approve(web3, consumerAccount, contracts.oceanAddress, poolAddress, '100') await approve(web3, consumerAccount, addresses.Ocean, poolAddress, '100')
const pool = new Pool(web3) const pool = new Pool(web3)
const tokenInOutMarket: TokenInOutMarket = { const tokenInOutMarket: TokenInOutMarket = {
tokenIn: contracts.oceanAddress, tokenIn: addresses.Ocean,
tokenOut: poolDatatokenAddress, tokenOut: poolDatatokenAddress,
marketFeeAddress: consumerAccount marketFeeAddress: consumerAccount
} }
@ -444,7 +443,7 @@ describe('Marketplace flow tests', async () => {
amountsInOutMaxFee amountsInOutMaxFee
) )
consumerOCEANBalance = await balance(web3, contracts.oceanAddress, consumerAccount) consumerOCEANBalance = await balance(web3, addresses.Ocean, consumerAccount)
/// ``` /// ```
/// Now let's console log the Consumer OCEAN balance after swap to check everything is working /// Now let's console log the Consumer OCEAN balance after swap to check everything is working
/// ```Typescript /// ```Typescript
@ -509,7 +508,7 @@ describe('Marketplace flow tests', async () => {
/// ```Typescript /// ```Typescript
console.log(`Download URL: ${downloadURL}`) console.log(`Download URL: ${downloadURL}`)
consumerOCEANBalance = await balance(web3, contracts.oceanAddress, consumerAccount) consumerOCEANBalance = await balance(web3, addresses.Ocean, consumerAccount)
console.log(`Consumer OCEAN balance after order: ${consumerOCEANBalance}`) console.log(`Consumer OCEAN balance after order: ${consumerOCEANBalance}`)
consumerDTBalance = await balance(web3, poolDatatokenAddress, consumerAccount) consumerDTBalance = await balance(web3, poolDatatokenAddress, consumerAccount)
@ -531,7 +530,7 @@ describe('Marketplace flow tests', async () => {
it('7.1 Publish a dataset (create NFT + Datatoken) with a fixed rate exchange', async () => { it('7.1 Publish a dataset (create NFT + Datatoken) with a fixed rate exchange', async () => {
/// ```Typescript /// ```Typescript
const factory = new NftFactory(contracts.erc721FactoryAddress, web3) const factory = new NftFactory(addresses.ERC721Factory, web3)
const nftParams: NftCreateData = { const nftParams: NftCreateData = {
name: FRE_NFT_NAME, name: FRE_NFT_NAME,
@ -553,8 +552,8 @@ describe('Marketplace flow tests', async () => {
} }
const freParams: FreCreationParams = { const freParams: FreCreationParams = {
fixedRateAddress: contracts.fixedRateAddress, fixedRateAddress: addresses.FixedPrice,
baseTokenAddress: contracts.oceanAddress, baseTokenAddress: addresses.Ocean,
owner: publisherAccount, owner: publisherAccount,
marketFeeCollector: publisherAccount, marketFeeCollector: publisherAccount,
baseTokenDecimals: 18, baseTokenDecimals: 18,
@ -656,7 +655,7 @@ describe('Marketplace flow tests', async () => {
console.log(`Consumer ETH balance: ${consumerETHBalance}`) console.log(`Consumer ETH balance: ${consumerETHBalance}`)
let consumerOCEANBalance = await balance( let consumerOCEANBalance = await balance(
web3, web3,
contracts.oceanAddress, addresses.Ocean,
consumerAccount consumerAccount
) )
console.log(`Consumer OCEAN balance before swap: ${consumerOCEANBalance}`) console.log(`Consumer OCEAN balance before swap: ${consumerOCEANBalance}`)
@ -666,7 +665,7 @@ describe('Marketplace flow tests', async () => {
/// ``` /// ```
/// Before we call the contract we have to call `approve` so that the contract can move our tokens. This is standard when using any ERC20 tokens /// Before we call the contract we have to call `approve` so that the contract can move our tokens. This is standard when using any ERC20 tokens
/// ```Typescript /// ```Typescript
await approve(web3, consumerAccount, contracts.oceanAddress, freAddress, '100') await approve(web3, consumerAccount, addresses.Ocean, freAddress, '100')
await approve( await approve(
web3, web3,
publisherAccount, publisherAccount,
@ -681,7 +680,7 @@ describe('Marketplace flow tests', async () => {
/// ```Typescript /// ```Typescript
await fixedRate.buyDT(consumerAccount, freId, '1', '2') await fixedRate.buyDT(consumerAccount, freId, '1', '2')
consumerOCEANBalance = await balance(web3, contracts.oceanAddress, consumerAccount) consumerOCEANBalance = await balance(web3, addresses.Ocean, consumerAccount)
console.log(`Consumer OCEAN balance after swap: ${consumerOCEANBalance}`) console.log(`Consumer OCEAN balance after swap: ${consumerOCEANBalance}`)
consumerDTBalance = await balance(web3, freDatatokenAddress, consumerAccount) consumerDTBalance = await balance(web3, freDatatokenAddress, consumerAccount)
console.log(`Consumer ${FRE_NFT_SYMBOL} balance after swap: ${consumerDTBalance}`) console.log(`Consumer ${FRE_NFT_SYMBOL} balance after swap: ${consumerDTBalance}`)
@ -739,7 +738,7 @@ describe('Marketplace flow tests', async () => {
/// ```Typescript /// ```Typescript
console.log(`Download URL: ${downloadURL}`) console.log(`Download URL: ${downloadURL}`)
consumerOCEANBalance = await balance(web3, contracts.oceanAddress, consumerAccount) consumerOCEANBalance = await balance(web3, addresses.Ocean, consumerAccount)
console.log(`Consumer OCEAN balance after order: ${consumerOCEANBalance}`) console.log(`Consumer OCEAN balance after order: ${consumerOCEANBalance}`)
consumerDTBalance = await balance(web3, freDatatokenAddress, consumerAccount) consumerDTBalance = await balance(web3, freDatatokenAddress, consumerAccount)
console.log(`Consumer ${FRE_NFT_SYMBOL} balance after order: ${consumerDTBalance}`) console.log(`Consumer ${FRE_NFT_SYMBOL} balance after order: ${consumerDTBalance}`)
@ -757,7 +756,7 @@ describe('Marketplace flow tests', async () => {
it('8.1 Publish a dataset (create NFT + Datatoken) with a dispenser', async () => { it('8.1 Publish a dataset (create NFT + Datatoken) with a dispenser', async () => {
/// ```Typescript /// ```Typescript
const factory = new NftFactory(contracts.erc721FactoryAddress, web3) const factory = new NftFactory(addresses.ERC721Factory, web3)
const nftParams: NftCreateData = { const nftParams: NftCreateData = {
name: DISP_NFT_NAME, name: DISP_NFT_NAME,
@ -779,7 +778,7 @@ describe('Marketplace flow tests', async () => {
} }
const dispenserParams: DispenserCreationParams = { const dispenserParams: DispenserCreationParams = {
dispenserAddress: contracts.dispenserAddress, dispenserAddress: addresses.Dispenser,
maxTokens: '1', maxTokens: '1',
maxBalance: '1', maxBalance: '1',
withMint: true, withMint: true,
@ -846,7 +845,7 @@ describe('Marketplace flow tests', async () => {
it('8.3 Consumer gets a dispenser data asset, and downloads it', async () => { it('8.3 Consumer gets a dispenser data asset, and downloads it', async () => {
/// ```Typescript /// ```Typescript
const datatoken = new Datatoken(web3) const datatoken = new Datatoken(web3)
const dispenser = new Dispenser(web3, null, contracts.dispenserAddress) const dispenser = new Dispenser(web3, null, addresses.Dispenser)
let consumerDTBalance = await balance( let consumerDTBalance = await balance(
web3, web3,