diff --git a/package-lock.json b/package-lock.json index 3fe1eb40..bf924945 100644 --- a/package-lock.json +++ b/package-lock.json @@ -881,9 +881,9 @@ } }, "@oceanprotocol/contracts": { - "version": "0.2.3", - "resolved": "https://registry.npmjs.org/@oceanprotocol/contracts/-/contracts-0.2.3.tgz", - "integrity": "sha512-5Oohzno3tnISMYG1jhtHxKMMkcIypTZAPlIoFjE5vDlAW51tyuxwYxBXHYQ2/FLRVFkmUmy5yASKg9zbnKKwQw==" + "version": "0.3.1", + "resolved": "https://registry.npmjs.org/@oceanprotocol/contracts/-/contracts-0.3.1.tgz", + "integrity": "sha512-LaOPxTID+iMRaUYneAOyG6jQQL8Gz9XA0jEqXvhJOqB/WL2zySL2StXpXPpMxzFq6APdpbnQ70s4jBgVChBN2w==" }, "@octokit/auth-token": { "version": "2.4.2", diff --git a/package.json b/package.json index 7bb54e05..55f2bddf 100644 --- a/package.json +++ b/package.json @@ -38,7 +38,7 @@ }, "dependencies": { "@ethereum-navigator/navigator": "^0.5.0", - "@oceanprotocol/contracts": "^0.2.3", + "@oceanprotocol/contracts": "^0.3.1", "bignumber.js": "^9.0.0", "fs": "0.0.1-security", "node-fetch": "^2.6.0", diff --git a/src/balancer/OceanPool.ts b/src/balancer/OceanPool.ts index ea563b4a..4868a5ca 100644 --- a/src/balancer/OceanPool.ts +++ b/src/balancer/OceanPool.ts @@ -316,7 +316,7 @@ export class OceanPool extends Pool { const factory = new this.web3.eth.Contract(this.FactoryABI, this.factoryAddress, { from: account }) - const events = await factory.getPastEvents('LOG_NEW_POOL', { + const events = await factory.getPastEvents('SPoolRegistered', { filter: {}, fromBlock: 0, toBlock: 'latest' @@ -324,9 +324,9 @@ export class OceanPool extends Pool { for (let i = 0; i < events.length; i++) { const constituents = await super.getCurrentTokens( account, - events[i].returnValues[1] + events[i].returnValues[0] ) - if (constituents.includes(dtAddress)) result.push(events[i].returnValues[1]) + if (constituents.includes(dtAddress)) result.push(events[i].returnValues[0]) } return result } diff --git a/src/balancer/balancerlib.ts b/src/balancer/balancerlib.ts index 58074111..7ca8111a 100644 --- a/src/balancer/balancerlib.ts +++ b/src/balancer/balancerlib.ts @@ -1,8 +1,8 @@ // import * as jsonFactoryABI from './artifacts/SFactory.json' // import * as jsonPoolABI from './artifacts/SPool.json' -import * as jsonFactoryABI from './artifacts/BFactory.json' -import * as jsonPoolABI from './artifacts/BPool.json' +import * as jsonFactoryABI from '@oceanprotocol/contracts/artifacts/development/SFactory.json' +import * as jsonPoolABI from '@oceanprotocol/contracts/artifacts/development/SPool.json' /** * Provides a interface to Balancer BPool & BFactory @@ -52,11 +52,11 @@ export class PoolFactory { from: account }) const transactiondata = await factory.methods - .newBPool() + .newSPool() .send({ from: account, gas: this.GASLIMIT_DEFAULT }) let pooladdress = null try { - pooladdress = transactiondata.events.LOG_NEW_POOL.returnValues[1] + pooladdress = transactiondata.events.SPoolRegistered.returnValues[0] } catch (e) { console.error(e) } diff --git a/src/models/Config.ts b/src/models/Config.ts index 475571a9..171be846 100644 --- a/src/models/Config.ts +++ b/src/models/Config.ts @@ -66,7 +66,7 @@ export class Config { * Pool Factory ABI * @type {string} */ - public pollFactoryABI?: object + public poolFactoryABI?: object /** * Pool ABI diff --git a/src/ocean/Ocean.ts b/src/ocean/Ocean.ts index d1275796..ba566fb7 100644 --- a/src/ocean/Ocean.ts +++ b/src/ocean/Ocean.ts @@ -58,7 +58,7 @@ export class Ocean extends Instantiable { ) instance.pool = new OceanPool( instanceConfig.config.web3Provider, - instanceConfig.config.pollFactoryABI, + instanceConfig.config.poolFactoryABI, instanceConfig.config.poolABI, instanceConfig.config.poolFactoryAddress, instanceConfig.config.oceanTokenAddress diff --git a/src/utils/ConfigHelper.ts b/src/utils/ConfigHelper.ts index 8520b360..a6018568 100644 --- a/src/utils/ConfigHelper.ts +++ b/src/utils/ConfigHelper.ts @@ -17,23 +17,14 @@ const configs = [ providerUri: 'http://127.0.0.1:8030', poolFactoryAddress: null }, - { - network: 'pacific', - url: 'https://pacific.oceanprotocol.com', - factoryAddress: '0x1234', - oceanTokenAddress: '0x012578f9381e876A9E2a9111Dfd436FF91A451ae', - metadataStoreUri: null, - providerUri: null, - poolFactoryAddress: null - }, { network: 'rinkeby', url: 'https://rinkeby.infura.io/v3/YOUR-PROJECT-ID', - factoryAddress: '0xB9d406D24B310A7D821D0b782a36909e8c925471', + factoryAddress: '0xcDfEe5D80041224cDCe9AE2334E85B3236385EA3', oceanTokenAddress: '0x8967BCF84170c91B0d24D4302C2376283b0B3a07', metadataStoreUri: 'https://aquarius.rinkeby.v3.dev-ocean.com/', providerUri: 'https://provider.rinkeby.v3.dev-ocean.com/', - poolFactoryAddress: null + poolFactoryAddress: '0xA4531C624A3D88323a1e178DABe1233AF178701B' }, { network: 'mainnet', diff --git a/test/BalancerContractHandler.ts b/test/BalancerContractHandler.ts index 0efb5004..c9574e2d 100644 --- a/test/BalancerContractHandler.ts +++ b/test/BalancerContractHandler.ts @@ -56,8 +56,6 @@ export class BalancerContractHandler { public async SdeployContracts(minter: string) { let estGas - console.log('Trying to deploy SPool') - console.log('Bytecode size:' + this.poolBytecode.length) estGas = await this.pool .deploy({ data: this.poolBytecode, @@ -68,7 +66,6 @@ export class BalancerContractHandler { return estGas }) // deploy the contract and get it's address - console.log('Pool estGas:' + estGas) this.poolAddress = await this.pool .deploy({ data: this.poolBytecode, @@ -82,7 +79,6 @@ export class BalancerContractHandler { .then(function (contract) { return contract.options.address }) - console.log('Pool deployed:' + this.poolAddress) estGas = await this.factory .deploy({ data: this.factoryBytecode, @@ -92,7 +88,6 @@ export class BalancerContractHandler { if (err) console.log('DeployContracts: ' + err) return estGas }) - console.log('estGas:' + estGas) // deploy the contract and get it's address this.factoryAddress = await this.factory .deploy({ diff --git a/test/unit/balancer/Balancer.test.ts b/test/unit/balancer/Balancer.test.ts index 4de68e29..818d9c5a 100644 --- a/test/unit/balancer/Balancer.test.ts +++ b/test/unit/balancer/Balancer.test.ts @@ -13,11 +13,8 @@ const factory = require('@oceanprotocol/contracts/artifacts/development/DTFactor const datatokensTemplate = require('@oceanprotocol/contracts/artifacts/development/DataTokenTemplate.json') // this will be replaced by our SFactory/SPool -const SFactory = require('@oceanprotocol/contracts/artifacts/development/SFactory.json') -const SPool = require('@oceanprotocol/contracts/artifacts/development/SPool.json') - -const OceanPoolFactory = require('../../../src/balancer/artifacts/BFactory.json') -const OceanPoolPool = require('../../../src/balancer/artifacts/BPool.json') +const OceanPoolFactory = require('@oceanprotocol/contracts/artifacts/development/SFactory.json') +const OceanPoolPool = require('@oceanprotocol/contracts/artifacts/development/SPool.json') describe('Balancer flow', () => { let oceanTokenAddress @@ -39,7 +36,23 @@ describe('Balancer flow', () => { const transferAmount = '200' const blob = 'http://localhost:8030/api/v1/services/consume' describe('#test', () => { - it('Initialize Ocean contracts v3', async () => { + before(async () => { + // deploy SFactory + const SContracts = new BalancerContractHandler( + OceanPoolFactory.abi, + OceanPoolFactory.bytecode, + OceanPoolPool.abi, + OceanPoolPool.bytecode, + web3 + ) + await SContracts.getAccounts() + owner = SContracts.accounts[0] + + await SContracts.SdeployContracts(owner) + OceanPoolFactoryAddress = SContracts.factoryAddress + assert(OceanPoolFactoryAddress !== null) + + // deploy DT Factory contracts = new TestContractHandler( factory.abi, datatokensTemplate.abi, @@ -52,8 +65,8 @@ describe('Balancer flow', () => { alice = contracts.accounts[1] bob = contracts.accounts[2] await contracts.deployContracts(owner) - }) - it('should initialize datatokens class', async () => { + + // initialize DataTokens datatoken = new DataTokens( contracts.factoryAddress, factory.abi, @@ -77,38 +90,6 @@ describe('Balancer flow', () => { ) oceanTokenAddress = await oceandatatoken.create(blob, alice) }) - it('Deploy OceanPool Factory', async () => { - OceanPoolContracts = new BalancerContractHandler( - OceanPoolFactory.abi, - OceanPoolFactory.bytecode, - OceanPoolPool.abi, - OceanPoolPool.bytecode, - web3 - ) - await OceanPoolContracts.getAccounts() - owner = OceanPoolContracts.accounts[0] - - await OceanPoolContracts.deployContracts(owner) - OceanPoolFactoryAddress = OceanPoolContracts.factoryAddress - assert(OceanPoolFactoryAddress !== null) - }) - /* it('Deploy Spool/SFactory', async () => { - const SContracts = new BalancerContractHandler( - SFactory.abi, - SFactory.bytecode, - SPool.abi, - SPool.bytecode, - web3 - ) - await SContracts.getAccounts() - owner = SContracts.accounts[0] - - await SContracts.SdeployContracts(owner) - const SFactoryAddress = SContracts.factoryAddress - assert(SFactoryAddress !== null) - }) - */ - it('should initialize OceanPool class', async () => { Pool = new OceanPool( web3,