mirror of
https://github.com/oceanprotocol/ocean.js.git
synced 2024-11-26 20:39:05 +01:00
update to SFactory/SPool and fixes
This commit is contained in:
parent
8a76cd7f70
commit
e2b2c16e2a
6
package-lock.json
generated
6
package-lock.json
generated
@ -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",
|
||||
|
@ -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",
|
||||
|
@ -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
|
||||
}
|
||||
|
@ -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)
|
||||
}
|
||||
|
@ -66,7 +66,7 @@ export class Config {
|
||||
* Pool Factory ABI
|
||||
* @type {string}
|
||||
*/
|
||||
public pollFactoryABI?: object
|
||||
public poolFactoryABI?: object
|
||||
|
||||
/**
|
||||
* Pool ABI
|
||||
|
@ -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
|
||||
|
@ -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',
|
||||
|
@ -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({
|
||||
|
@ -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,
|
||||
|
Loading…
x
Reference in New Issue
Block a user