mirror of
https://github.com/oceanprotocol/ocean.js.git
synced 2024-11-26 20:39:05 +01:00
fix lint errors
This commit is contained in:
parent
bce7c6c9d2
commit
552d976ffc
@ -2,7 +2,6 @@
|
||||
'use strict'
|
||||
|
||||
const packageInfo = require('../package.json')
|
||||
|
||||
const execSync = require('child_process').execSync
|
||||
|
||||
process.stdout.write(
|
||||
|
@ -5,7 +5,6 @@ const defaultDatatokensABI = require('../datatokens/DatatokensABI.json')
|
||||
|
||||
/**
|
||||
* Provides a interface to DataTokens
|
||||
|
||||
*/
|
||||
export class DataTokens {
|
||||
public factoryAddress: string
|
||||
@ -40,34 +39,13 @@ export class DataTokens {
|
||||
* @param {Account} account
|
||||
* @return {Promise<string>} datatoken address
|
||||
*/
|
||||
public async create(
|
||||
metaDataStoreURI: string,
|
||||
account: Account
|
||||
): Promise<string> {
|
||||
public async create(metaDataStoreURI: string, account: Account): Promise<string> {
|
||||
// Create factory contract object
|
||||
const tokenAddress = null
|
||||
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
|
||||
})
|
||||
// Invoke createToken function of the contract
|
||||
const trxReceipt = await factory.methods
|
||||
.createToken(metaDataStoreURI)
|
||||
.send({
|
||||
from: account,
|
||||
gas: estGas+1,
|
||||
gasPrice: '3000000000'
|
||||
})
|
||||
|
||||
let tokenAddress = null
|
||||
try {
|
||||
tokenAddress = trxReceipt.events.TokenCreated.returnValues[0]
|
||||
} catch (e) {
|
||||
console.error(e)
|
||||
}
|
||||
// TODO:
|
||||
return tokenAddress
|
||||
}
|
||||
|
||||
@ -114,19 +92,8 @@ export class DataTokens {
|
||||
dataTokenAddress,
|
||||
{ from: account }
|
||||
)
|
||||
|
||||
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*2,
|
||||
gasPrice: '3000000000'
|
||||
})
|
||||
|
||||
const trxReceipt = null
|
||||
// TODO:
|
||||
return trxReceipt
|
||||
}
|
||||
|
||||
@ -253,4 +220,4 @@ export class DataTokens {
|
||||
const trxReceipt = await datatoken.methods.cap().call()
|
||||
return trxReceipt
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -52,8 +52,7 @@ export class Assets extends Instantiable {
|
||||
const publisherURI = this.ocean.brizo.getURI()
|
||||
const jsonBlob = { t: 0, url: publisherURI }
|
||||
const { datatokens } = this.ocean
|
||||
return datatokens.create( JSON.stringify(jsonBlob), publisher)
|
||||
|
||||
return datatokens.create(JSON.stringify(jsonBlob), publisher)
|
||||
}
|
||||
|
||||
/**
|
||||
@ -80,7 +79,7 @@ export class Assets extends Instantiable {
|
||||
const metadataStoreURI = this.ocean.aquarius.getURI()
|
||||
const jsonBlob = { t: 1, url: metadataStoreURI }
|
||||
const { datatokens } = this.ocean
|
||||
dtAddress = await datatokens.create(JSON.stringify(jsonBlob), publisher )
|
||||
dtAddress = await datatokens.create(JSON.stringify(jsonBlob), publisher)
|
||||
this.logger.log('DataToken creted')
|
||||
observer.next(CreateProgressStep.DataTokenCreated)
|
||||
}
|
||||
|
9
test/integration/tsconfig.json
Normal file
9
test/integration/tsconfig.json
Normal file
@ -0,0 +1,9 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"resolveJsonModule": true,
|
||||
"lib": ["es6", "es7", "dom"],
|
||||
"noUnusedLocals": true,
|
||||
"esModuleInterop": true,
|
||||
"allowSyntheticDefaultImports": true
|
||||
}
|
||||
}
|
@ -1,66 +0,0 @@
|
||||
import { assert } from 'chai'
|
||||
import { TestContractHandler } from './TestContractHandler'
|
||||
import { DataTokens } from '../../src/datatokens/Datatokens'
|
||||
|
||||
const Web3 = require('web3')
|
||||
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('DataTokens', () => {
|
||||
|
||||
let minter
|
||||
let spender
|
||||
let balance
|
||||
let contracts
|
||||
let datatoken
|
||||
let tokenAddress
|
||||
|
||||
let tokenAmount = 100
|
||||
let blob = 'https://example.com/dataset-1'
|
||||
|
||||
describe('#test', () => {
|
||||
it('should deploy contracts', async () => {
|
||||
contracts = new TestContractHandler(factoryABI,datatokensABI)
|
||||
await contracts.getAccounts()
|
||||
minter = contracts.accounts[0]
|
||||
spender = contracts.accounts[1]
|
||||
await contracts.deployContracts(minter)
|
||||
})
|
||||
|
||||
it('should create Datatoken object', async () => {
|
||||
datatoken = new DataTokens(contracts.factoryAddress, factoryABI, datatokensABI, web3)
|
||||
assert(datatoken !== null)
|
||||
})
|
||||
|
||||
it('should create Datatoken contract', async () => {
|
||||
tokenAddress = await datatoken.create(blob, minter)
|
||||
assert(tokenAddress !== null)
|
||||
})
|
||||
|
||||
it('should mint Datatokens', async () => {
|
||||
await datatoken.mint(tokenAddress, minter, tokenAmount)
|
||||
balance = await datatoken.balance(tokenAddress, minter)
|
||||
assert(balance.toString() === tokenAmount.toString())
|
||||
})
|
||||
|
||||
it('should transfer Datatokens to spender', async () => {
|
||||
await datatoken.transfer(tokenAddress, spender, tokenAmount, minter)
|
||||
balance = await datatoken.balance(tokenAddress, spender)
|
||||
assert(balance.toString() === tokenAmount.toString())
|
||||
|
||||
})
|
||||
|
||||
it('should approve Datatokens to spend', async () => {
|
||||
await datatoken.approve(tokenAddress, minter, tokenAmount, spender)
|
||||
})
|
||||
|
||||
it('should transferFrom Datatokens back to the minter', async () => {
|
||||
await datatoken.transferFrom(tokenAddress, spender, tokenAmount, minter)
|
||||
minter = await datatoken.balance(tokenAddress, spender)
|
||||
assert(balance.toString() === tokenAmount.toString())
|
||||
})
|
||||
|
||||
})
|
||||
})
|
File diff suppressed because one or more lines are too long
@ -1,8 +0,0 @@
|
||||
--require ts-node/register
|
||||
--require source-map-support/register
|
||||
--require mock-local-storage
|
||||
--full-trace
|
||||
--bail
|
||||
--exit
|
||||
--timeout 20000
|
||||
test/unit/config.ts test/unit/**/*.test.ts
|
9
test/unit/tsconfig.json
Normal file
9
test/unit/tsconfig.json
Normal file
@ -0,0 +1,9 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"resolveJsonModule": true,
|
||||
"lib": ["es6", "es7"],
|
||||
"noUnusedLocals": true,
|
||||
"esModuleInterop": true,
|
||||
"allowSyntheticDefaultImports": true
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user