mirror of
https://github.com/oceanprotocol/ocean.js.git
synced 2024-11-26 20:39:05 +01:00
fix more linting errors
This commit is contained in:
parent
52260cdf7f
commit
4554f420e3
@ -40,26 +40,20 @@ export class DataTokens {
|
||||
*/
|
||||
public async create(metaDataStoreURI: string, account: Account): Promise<string> {
|
||||
// Create factory contract object
|
||||
const factory = new this.web3.eth.Contract(
|
||||
this.factoryABI,
|
||||
this.factoryAddress,
|
||||
{
|
||||
from: account
|
||||
}
|
||||
)
|
||||
const factory = new this.web3.eth.Contract(this.factoryABI, this.factoryAddress, {
|
||||
from: account
|
||||
})
|
||||
const estGas = await factory.methods
|
||||
.createToken(metaDataStoreURI)
|
||||
.estimateGas(function(err, estGas){
|
||||
return estGas
|
||||
})
|
||||
.createToken(metaDataStoreURI)
|
||||
.estimateGas(function (err, estGas) {
|
||||
return estGas
|
||||
})
|
||||
// Invoke createToken function of the contract
|
||||
const trxReceipt = await factory.methods
|
||||
.createToken(metaDataStoreURI)
|
||||
.send({
|
||||
from: account,
|
||||
gas: estGas+1,
|
||||
gasPrice: '3000000000'
|
||||
})
|
||||
const trxReceipt = await factory.methods.createToken(metaDataStoreURI).send({
|
||||
from: account,
|
||||
gas: estGas + 1,
|
||||
gasPrice: '3000000000'
|
||||
})
|
||||
|
||||
let tokenAddress = null
|
||||
try {
|
||||
@ -113,17 +107,17 @@ export class DataTokens {
|
||||
dataTokenAddress,
|
||||
{ from: account }
|
||||
)
|
||||
const estGas = await datatoken.methods.mint(address, amount)
|
||||
.estimateGas(function(err, estGas){
|
||||
return estGas
|
||||
})
|
||||
const estGas = await datatoken.methods
|
||||
.mint(address, amount)
|
||||
.estimateGas(function (err, estGas) {
|
||||
return estGas
|
||||
})
|
||||
|
||||
const trxReceipt = await datatoken.methods.mint(address, amount)
|
||||
.send({
|
||||
from:account,
|
||||
gas: estGas+1,
|
||||
gasPrice: '3000000000'
|
||||
})
|
||||
const trxReceipt = await datatoken.methods.mint(address, amount).send({
|
||||
from: account,
|
||||
gas: estGas + 1,
|
||||
gasPrice: '3000000000'
|
||||
})
|
||||
|
||||
return trxReceipt
|
||||
}
|
||||
|
@ -178,13 +178,12 @@ export class Assets extends Instantiable {
|
||||
txId: string,
|
||||
account: string
|
||||
): Promise<string> {
|
||||
|
||||
let consumeUrl = serviceEndpoint
|
||||
consumeUrl += `?consumerAddress=${account}`
|
||||
consumeUrl += `&tokenAddress=${dtAddress}`
|
||||
consumeUrl += `&transferTxId=${txId}`
|
||||
|
||||
let serviceConnector = new WebServiceConnector(this.logger)
|
||||
const serviceConnector = new WebServiceConnector(this.logger)
|
||||
|
||||
try {
|
||||
await serviceConnector.downloadFile(consumeUrl)
|
||||
@ -196,5 +195,4 @@ export class Assets extends Instantiable {
|
||||
|
||||
return serviceEndpoint
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,7 +1,7 @@
|
||||
import { Contract } from 'web3-eth-contract'
|
||||
|
||||
const Web3 = require('web3')
|
||||
const web3 = new Web3("http://127.0.0.1:8545")
|
||||
const web3 = new Web3('http://127.0.0.1:8545')
|
||||
|
||||
export class TestContractHandler {
|
||||
public factory: Contract
|
||||
@ -17,8 +17,8 @@ export class TestContractHandler {
|
||||
datatokensABI: Contract,
|
||||
templateBytecode: string,
|
||||
factoryBytecode: string
|
||||
){
|
||||
this.factory = new web3.eth.Contract(factoryABI)
|
||||
) {
|
||||
this.factory = new web3.eth.Contract(factoryABI)
|
||||
this.template = new web3.eth.Contract(datatokensABI)
|
||||
this.templateBytecode = templateBytecode
|
||||
this.factoryBytecode = factoryBytecode
|
||||
@ -28,53 +28,57 @@ export class TestContractHandler {
|
||||
this.accounts = await web3.eth.getAccounts()
|
||||
}
|
||||
|
||||
public async deployContracts(minter: string) {
|
||||
public async deployContracts(minter: string) {
|
||||
let estGas
|
||||
|
||||
let blob = 'https://example.com/dataset-1'
|
||||
let cap = 1400000000
|
||||
const blob = 'https://example.com/dataset-1'
|
||||
const cap = 1400000000
|
||||
|
||||
// get est gascost
|
||||
estGas = await this.template.deploy({
|
||||
data: this.templateBytecode,
|
||||
arguments:['Template Contract', 'TEMPLATE', minter, cap, blob]
|
||||
})
|
||||
.estimateGas(function(err, estGas){
|
||||
return estGas
|
||||
})
|
||||
estGas = await this.template
|
||||
.deploy({
|
||||
data: this.templateBytecode,
|
||||
arguments: ['Template Contract', 'TEMPLATE', minter, cap, blob]
|
||||
})
|
||||
.estimateGas(function (err, estGas) {
|
||||
return estGas
|
||||
})
|
||||
// deploy the contract and get it's address
|
||||
this.templateAddress = await this.template.deploy({
|
||||
data: this.templateBytecode,
|
||||
arguments:['Template Contract', 'TEMPLATE', minter, cap, blob]
|
||||
})
|
||||
.send({
|
||||
from: minter,
|
||||
gas: estGas+1,
|
||||
gasPrice: '12345678'
|
||||
})
|
||||
.then(function(contract){
|
||||
return contract.options.address
|
||||
})
|
||||
this.templateAddress = await this.template
|
||||
.deploy({
|
||||
data: this.templateBytecode,
|
||||
arguments: ['Template Contract', 'TEMPLATE', minter, cap, blob]
|
||||
})
|
||||
.send({
|
||||
from: minter,
|
||||
gas: estGas + 1,
|
||||
gasPrice: '12345678'
|
||||
})
|
||||
.then(function (contract) {
|
||||
return contract.options.address
|
||||
})
|
||||
|
||||
estGas = await this.factory.deploy({
|
||||
data: this.factoryBytecode,
|
||||
arguments:[this.templateAddress]
|
||||
})
|
||||
.estimateGas(function(err, estGas){
|
||||
return estGas
|
||||
})
|
||||
estGas = await this.factory
|
||||
.deploy({
|
||||
data: this.factoryBytecode,
|
||||
arguments: [this.templateAddress]
|
||||
})
|
||||
.estimateGas(function (err, estGas) {
|
||||
return estGas
|
||||
})
|
||||
// deploy the contract and get it's address
|
||||
this.factoryAddress = await this.factory.deploy({
|
||||
data: this.factoryBytecode,
|
||||
arguments:[this.templateAddress]
|
||||
})
|
||||
.send({
|
||||
from: minter,
|
||||
gas: estGas+1,
|
||||
gasPrice: '12345678'
|
||||
})
|
||||
.then(function(contract){
|
||||
return contract.options.address
|
||||
})
|
||||
this.factoryAddress = await this.factory
|
||||
.deploy({
|
||||
data: this.factoryBytecode,
|
||||
arguments: [this.templateAddress]
|
||||
})
|
||||
.send({
|
||||
from: minter,
|
||||
gas: estGas + 1,
|
||||
gasPrice: '12345678'
|
||||
})
|
||||
.then(function (contract) {
|
||||
return contract.options.address
|
||||
})
|
||||
}
|
||||
}
|
@ -4,15 +4,13 @@ import { DataTokens } from '../../src/datatokens/Datatokens'
|
||||
import { Ocean } from '../../src/ocean/Ocean'
|
||||
import { Config } from '../../src/models/Config'
|
||||
|
||||
|
||||
const Web3 = require('web3')
|
||||
const web3 = new Web3("http://127.0.0.1:8545")
|
||||
const web3 = new Web3('http://127.0.0.1:8545')
|
||||
|
||||
const factoryABI = require('../../src/datatokens/FactoryABI.json')
|
||||
const datatokensABI = require('../../src/datatokens/DatatokensABI.json')
|
||||
|
||||
describe('Simple flow', () => {
|
||||
|
||||
let owner
|
||||
let bob
|
||||
let alice
|
||||
@ -22,13 +20,13 @@ describe('Simple flow', () => {
|
||||
let tokenAddress
|
||||
let transactionId
|
||||
|
||||
let tokenAmount = 100
|
||||
let transferAmount = 1
|
||||
let blob = 'http://localhost:8030/api/v1/provider/services'
|
||||
const tokenAmount = 100
|
||||
const transferAmount = 1
|
||||
const blob = 'http://localhost:8030/api/v1/provider/services'
|
||||
|
||||
describe('#test', () => {
|
||||
it('Initialize Ocean contracts v3', async () => {
|
||||
contracts = new TestContractHandler(factoryABI,datatokensABI)
|
||||
contracts = new TestContractHandler(factoryABI, datatokensABI)
|
||||
await contracts.getAccounts()
|
||||
owner = contracts.accounts[0]
|
||||
alice = contracts.accounts[1]
|
||||
@ -38,7 +36,12 @@ describe('Simple flow', () => {
|
||||
|
||||
it('Alice publishes a dataset', async () => {
|
||||
// Alice creates a Datatoken
|
||||
datatoken = new DataTokens(contracts.factoryAddress, factoryABI, datatokensABI, web3)
|
||||
datatoken = new DataTokens(
|
||||
contracts.factoryAddress,
|
||||
factoryABI,
|
||||
datatokensABI,
|
||||
web3
|
||||
)
|
||||
tokenAddress = await datatoken.create(blob, alice)
|
||||
})
|
||||
|
||||
@ -48,12 +51,12 @@ describe('Simple flow', () => {
|
||||
|
||||
it('Alice transfers 1 token to Bob', async () => {
|
||||
const ts = await datatoken.transfer(tokenAddress, bob, tokenAmount, alice)
|
||||
transactionId = ts['transactionHash']
|
||||
transactionId = ts.transactionHash
|
||||
})
|
||||
|
||||
it('Bob consumes dataset', async () => {
|
||||
const config = new Config()
|
||||
let ocean = await Ocean.getInstance(config)
|
||||
const ocean = await Ocean.getInstance(config)
|
||||
await ocean.assets.download(tokenAddress, blob, transactionId, bob)
|
||||
})
|
||||
})
|
||||
|
@ -6,20 +6,17 @@ import Web3 from 'web3'
|
||||
const factory = require('@oceanprotocol/contracts/artifacts/development/Factory.json')
|
||||
const datatokensTemplate = require('@oceanprotocol/contracts/artifacts/development/DataTokenTemplate.json')
|
||||
|
||||
|
||||
const web3 = new Web3("http://127.0.0.1:8545")
|
||||
|
||||
const web3 = new Web3('http://127.0.0.1:8545')
|
||||
|
||||
describe('DataTokens', () => {
|
||||
|
||||
let minter
|
||||
let spender
|
||||
let balance
|
||||
let contracts
|
||||
let datatoken
|
||||
let tokenAddress
|
||||
let tokenAmount = 100
|
||||
let blob = 'https://example.com/dataset-1'
|
||||
const tokenAmount = 100
|
||||
const blob = 'https://example.com/dataset-1'
|
||||
|
||||
describe('#test', () => {
|
||||
it('#deploy', async () => {
|
||||
|
Loading…
x
Reference in New Issue
Block a user