mirror of
https://github.com/oceanprotocol/ocean.js.git
synced 2024-11-26 20:39:05 +01:00
never stop typing
This commit is contained in:
parent
ad0922d7a5
commit
76423a4ff8
@ -20,8 +20,6 @@
|
|||||||
],
|
],
|
||||||
"plugins": ["@typescript-eslint", "prettier"],
|
"plugins": ["@typescript-eslint", "prettier"],
|
||||||
"rules": {
|
"rules": {
|
||||||
"@typescript-eslint/explicit-member-accessibility": "off",
|
|
||||||
"@typescript-eslint/no-var-requires": "off",
|
|
||||||
"no-empty": ["error", { "allowEmptyCatch": true }],
|
"no-empty": ["error", { "allowEmptyCatch": true }],
|
||||||
"prefer-destructuring": ["warn"],
|
"prefer-destructuring": ["warn"],
|
||||||
"no-dupe-class-members": ["warn"],
|
"no-dupe-class-members": ["warn"],
|
||||||
|
@ -13,7 +13,7 @@
|
|||||||
"lint": "eslint --ignore-path .gitignore --ext .ts,.tsx . && npm run type-check",
|
"lint": "eslint --ignore-path .gitignore --ext .ts,.tsx . && npm run type-check",
|
||||||
"lint:fix": "eslint --ignore-path .gitignore --ext .ts,.tsx . --fix",
|
"lint:fix": "eslint --ignore-path .gitignore --ext .ts,.tsx . --fix",
|
||||||
"format": "prettier --parser typescript --ignore-path .gitignore --write '**/*.{js,jsx,ts,tsx}'",
|
"format": "prettier --parser typescript --ignore-path .gitignore --write '**/*.{js,jsx,ts,tsx}'",
|
||||||
"type-check": "tsc --noEmit",
|
"type-check": "npm run build:metadata && tsc --noEmit",
|
||||||
"doc:json": "./scripts/typedoc.js",
|
"doc:json": "./scripts/typedoc.js",
|
||||||
"run": "ts-node",
|
"run": "ts-node",
|
||||||
"release": "release-it --non-interactive",
|
"release": "release-it --non-interactive",
|
||||||
|
@ -47,6 +47,7 @@ export default class ContractHandler extends Instantiable {
|
|||||||
|
|
||||||
private async load(what: string, where: string, networkId: number): Promise<Contract> {
|
private async load(what: string, where: string, networkId: number): Promise<Contract> {
|
||||||
this.logger.debug('Loading', what, 'from', where)
|
this.logger.debug('Loading', what, 'from', where)
|
||||||
|
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
||||||
const artifact = require(`@oceanprotocol/contracts/artifacts/${where}/${what}.json`)
|
const artifact = require(`@oceanprotocol/contracts/artifacts/${where}/${what}.json`)
|
||||||
// Logger.log('Loaded artifact', artifact)
|
// Logger.log('Loaded artifact', artifact)
|
||||||
const code = await this.web3.eth.getCode(artifact.address)
|
const code = await this.web3.eth.getCode(artifact.address)
|
||||||
|
@ -16,10 +16,9 @@ export class DataTokens {
|
|||||||
/**
|
/**
|
||||||
* Instantiate DataTokens (independently of Ocean).
|
* Instantiate DataTokens (independently of Ocean).
|
||||||
* @param {String} factoryAddress
|
* @param {String} factoryAddress
|
||||||
* @param {any} factoryABI
|
* @param {AbiItem | AbiItem[]} factoryABI
|
||||||
* @param {any} datatokensABI
|
* @param {AbiItem | AbiItem[]} datatokensABI
|
||||||
* @param {any} web3
|
* @param {Web3} web3
|
||||||
|
|
||||||
*/
|
*/
|
||||||
constructor(
|
constructor(
|
||||||
factoryAddress: string,
|
factoryAddress: string,
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import * as metadata from '../metadata.json'
|
import metadata from '../metadata.json'
|
||||||
|
|
||||||
import { Instantiable, InstantiableConfig } from '../Instantiable.abstract'
|
import { Instantiable, InstantiableConfig } from '../Instantiable.abstract'
|
||||||
|
|
||||||
|
@ -3,6 +3,7 @@ import fs from 'fs'
|
|||||||
import { Logger } from '../../utils'
|
import { Logger } from '../../utils'
|
||||||
import save from 'save-file'
|
import save from 'save-file'
|
||||||
|
|
||||||
|
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
||||||
const fetch = require('node-fetch')
|
const fetch = require('node-fetch')
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1,13 +1,14 @@
|
|||||||
|
import { AbiItem } from 'web3-utils/types'
|
||||||
import { TestContractHandler } from '../TestContractHandler'
|
import { TestContractHandler } from '../TestContractHandler'
|
||||||
import { DataTokens } from '../../src/datatokens/Datatokens'
|
import { DataTokens } from '../../src/datatokens/Datatokens'
|
||||||
import { Ocean } from '../../src/ocean/Ocean'
|
import { Ocean } from '../../src/ocean/Ocean'
|
||||||
import config from './config'
|
import config from './config'
|
||||||
import { assert } from 'console'
|
import { assert } from 'console'
|
||||||
import { ServiceComputePrivacy } from '../../src/ddo/interfaces/Service'
|
import { ServiceComputePrivacy } from '../../src/ddo/interfaces/Service'
|
||||||
const Web3 = require('web3')
|
import Web3 from 'web3'
|
||||||
|
import factory from '@oceanprotocol/contracts/artifacts/DTFactory.json'
|
||||||
|
import datatokensTemplate from '@oceanprotocol/contracts/artifacts/DataTokenTemplate.json'
|
||||||
const web3 = new Web3('http://127.0.0.1:8545')
|
const web3 = new Web3('http://127.0.0.1:8545')
|
||||||
const factory = require('@oceanprotocol/contracts/artifacts/DTFactory.json')
|
|
||||||
const datatokensTemplate = require('@oceanprotocol/contracts/artifacts/DataTokenTemplate.json')
|
|
||||||
|
|
||||||
describe('Compute flow', () => {
|
describe('Compute flow', () => {
|
||||||
let owner
|
let owner
|
||||||
@ -55,8 +56,8 @@ describe('Compute flow', () => {
|
|||||||
describe('#MarketplaceComputeFlow-Test', () => {
|
describe('#MarketplaceComputeFlow-Test', () => {
|
||||||
it('Initialize Ocean contracts v3', async () => {
|
it('Initialize Ocean contracts v3', async () => {
|
||||||
contracts = new TestContractHandler(
|
contracts = new TestContractHandler(
|
||||||
factory.abi,
|
factory.abi as AbiItem[],
|
||||||
datatokensTemplate.abi,
|
datatokensTemplate.abi as AbiItem[],
|
||||||
datatokensTemplate.bytecode,
|
datatokensTemplate.bytecode,
|
||||||
factory.bytecode,
|
factory.bytecode,
|
||||||
web3
|
web3
|
||||||
@ -74,8 +75,8 @@ describe('Compute flow', () => {
|
|||||||
it('Alice deploys datatoken contract', async () => {
|
it('Alice deploys datatoken contract', async () => {
|
||||||
datatoken = new DataTokens(
|
datatoken = new DataTokens(
|
||||||
contracts.factoryAddress,
|
contracts.factoryAddress,
|
||||||
factory.abi,
|
factory.abi as AbiItem[],
|
||||||
datatokensTemplate.abi,
|
datatokensTemplate.abi as AbiItem[],
|
||||||
web3
|
web3
|
||||||
)
|
)
|
||||||
tokenAddress = await datatoken.create(blob, alice.getId())
|
tokenAddress = await datatoken.create(blob, alice.getId())
|
||||||
|
@ -1,13 +1,14 @@
|
|||||||
|
import { AbiItem } from 'web3-utils/types'
|
||||||
import { TestContractHandler } from '../TestContractHandler'
|
import { TestContractHandler } from '../TestContractHandler'
|
||||||
import { DataTokens } from '../../src/datatokens/Datatokens'
|
import { DataTokens } from '../../src/datatokens/Datatokens'
|
||||||
import { Ocean } from '../../src/ocean/Ocean'
|
import { Ocean } from '../../src/ocean/Ocean'
|
||||||
import config from './config'
|
import config from './config'
|
||||||
import { assert } from 'console'
|
import { assert } from 'console'
|
||||||
|
|
||||||
const Web3 = require('web3')
|
import Web3 from 'web3'
|
||||||
|
import factory from '@oceanprotocol/contracts/artifacts/DTFactory.json'
|
||||||
|
import datatokensTemplate from '@oceanprotocol/contracts/artifacts/DataTokenTemplate.json'
|
||||||
const web3 = new Web3('http://127.0.0.1:8545')
|
const web3 = new Web3('http://127.0.0.1:8545')
|
||||||
const factory = require('@oceanprotocol/contracts/artifacts/DTFactory.json')
|
|
||||||
const datatokensTemplate = require('@oceanprotocol/contracts/artifacts/DataTokenTemplate.json')
|
|
||||||
|
|
||||||
describe('Marketplace flow', () => {
|
describe('Marketplace flow', () => {
|
||||||
let owner
|
let owner
|
||||||
@ -32,8 +33,8 @@ describe('Marketplace flow', () => {
|
|||||||
describe('#MarketplaceDownloadFlow-Test', () => {
|
describe('#MarketplaceDownloadFlow-Test', () => {
|
||||||
it('Initialize Ocean contracts v3', async () => {
|
it('Initialize Ocean contracts v3', async () => {
|
||||||
contracts = new TestContractHandler(
|
contracts = new TestContractHandler(
|
||||||
factory.abi,
|
factory.abi as AbiItem[],
|
||||||
datatokensTemplate.abi,
|
datatokensTemplate.abi as AbiItem[],
|
||||||
datatokensTemplate.bytecode,
|
datatokensTemplate.bytecode,
|
||||||
factory.bytecode,
|
factory.bytecode,
|
||||||
web3
|
web3
|
||||||
@ -52,8 +53,8 @@ describe('Marketplace flow', () => {
|
|||||||
it('Alice publishes a datatoken contract', async () => {
|
it('Alice publishes a datatoken contract', async () => {
|
||||||
datatoken = new DataTokens(
|
datatoken = new DataTokens(
|
||||||
contracts.factoryAddress,
|
contracts.factoryAddress,
|
||||||
factory.abi,
|
factory.abi as AbiItem[],
|
||||||
datatokensTemplate.abi,
|
datatokensTemplate.abi as AbiItem[],
|
||||||
web3
|
web3
|
||||||
)
|
)
|
||||||
tokenAddress = await datatoken.create(blob, alice.getId())
|
tokenAddress = await datatoken.create(blob, alice.getId())
|
||||||
|
@ -1,10 +1,10 @@
|
|||||||
import { TestContractHandler } from '../TestContractHandler'
|
import { TestContractHandler } from '../TestContractHandler'
|
||||||
import { DataTokens } from '../../src/datatokens/Datatokens'
|
import { DataTokens } from '../../src/datatokens/Datatokens'
|
||||||
|
|
||||||
const Web3 = require('web3')
|
import Web3 from 'web3'
|
||||||
|
import factory from '@oceanprotocol/contracts/artifacts/DTFactory.json'
|
||||||
|
import datatokensTemplate from '@oceanprotocol/contracts/artifacts/DataTokenTemplate.json'
|
||||||
const web3 = new Web3('wss://rinkeby.infura.io/ws/v3/357f2fe737db4304bd2f7285c5602d0d')
|
const web3 = new Web3('wss://rinkeby.infura.io/ws/v3/357f2fe737db4304bd2f7285c5602d0d')
|
||||||
const factory = require('@oceanprotocol/contracts/artifacts/DTFactory.json')
|
|
||||||
const datatokensTemplate = require('@oceanprotocol/contracts/artifacts/DataTokenTemplate.json')
|
|
||||||
|
|
||||||
describe('Rinkeby test', () => {
|
describe('Rinkeby test', () => {
|
||||||
// let account
|
// let account
|
||||||
|
@ -1,12 +1,11 @@
|
|||||||
import { TestContractHandler } from '../TestContractHandler'
|
import { TestContractHandler } from '../TestContractHandler'
|
||||||
import { DataTokens } from '../../src/datatokens/Datatokens'
|
import { DataTokens } from '../../src/datatokens/Datatokens'
|
||||||
import { Ocean } from '../../src/ocean/Ocean'
|
import { AbiItem } from 'web3-utils/types'
|
||||||
import { Config } from '../../src/models/Config'
|
|
||||||
|
|
||||||
const Web3 = require('web3')
|
import Web3 from 'web3'
|
||||||
|
import factory from '@oceanprotocol/contracts/artifacts/DTFactory.json'
|
||||||
|
import datatokensTemplate from '@oceanprotocol/contracts/artifacts/DataTokenTemplate.json'
|
||||||
const web3 = new Web3('http://127.0.0.1:8545')
|
const web3 = new Web3('http://127.0.0.1:8545')
|
||||||
const factory = require('@oceanprotocol/contracts/artifacts/DTFactory.json')
|
|
||||||
const datatokensTemplate = require('@oceanprotocol/contracts/artifacts/DataTokenTemplate.json')
|
|
||||||
|
|
||||||
describe('Simple flow', () => {
|
describe('Simple flow', () => {
|
||||||
let owner
|
let owner
|
||||||
@ -22,8 +21,8 @@ describe('Simple flow', () => {
|
|||||||
describe('#test', () => {
|
describe('#test', () => {
|
||||||
it('Initialize Ocean contracts v3', async () => {
|
it('Initialize Ocean contracts v3', async () => {
|
||||||
contracts = new TestContractHandler(
|
contracts = new TestContractHandler(
|
||||||
factory.abi,
|
factory.abi as AbiItem[],
|
||||||
datatokensTemplate.abi,
|
datatokensTemplate.abi as AbiItem[],
|
||||||
datatokensTemplate.bytecode,
|
datatokensTemplate.bytecode,
|
||||||
factory.bytecode,
|
factory.bytecode,
|
||||||
web3
|
web3
|
||||||
@ -38,8 +37,8 @@ describe('Simple flow', () => {
|
|||||||
// Alice creates a Datatoken
|
// Alice creates a Datatoken
|
||||||
datatoken = new DataTokens(
|
datatoken = new DataTokens(
|
||||||
contracts.factoryAddress,
|
contracts.factoryAddress,
|
||||||
factory.abi,
|
factory.abi as AbiItem[],
|
||||||
datatokensTemplate.abi,
|
datatokensTemplate.abi as AbiItem[],
|
||||||
web3
|
web3
|
||||||
)
|
)
|
||||||
tokenAddress = await datatoken.create(blob, alice)
|
tokenAddress = await datatoken.create(blob, alice)
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
import { Config, LogLevel } from '../../src/models/Config'
|
import { Config, LogLevel } from '../../src/models/Config'
|
||||||
import { LoggerInstance } from '../../src/utils'
|
import { LoggerInstance } from '../../src/utils'
|
||||||
|
|
||||||
LoggerInstance.setLevel(LogLevel.Error)
|
import Web3 from 'web3'
|
||||||
|
|
||||||
const Web3 = require('web3')
|
LoggerInstance.setLevel(LogLevel.Error)
|
||||||
const web3 = new Web3('http://127.0.0.1:8545')
|
const web3 = new Web3('http://127.0.0.1:8545')
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
|
@ -1,10 +1,11 @@
|
|||||||
import { assert } from 'chai'
|
import { assert } from 'chai'
|
||||||
|
import { AbiItem } from 'web3-utils/types'
|
||||||
import { TestContractHandler } from '../TestContractHandler'
|
import { TestContractHandler } from '../TestContractHandler'
|
||||||
import { DataTokens } from '../../src/datatokens/Datatokens'
|
import { DataTokens } from '../../src/datatokens/Datatokens'
|
||||||
|
|
||||||
const Web3 = require('web3')
|
import Web3 from 'web3'
|
||||||
const factory = require('@oceanprotocol/contracts/artifacts/DTFactory.json')
|
import factory from '@oceanprotocol/contracts/artifacts/DTFactory.json'
|
||||||
const datatokensTemplate = require('@oceanprotocol/contracts/artifacts/DataTokenTemplate.json')
|
import datatokensTemplate from '@oceanprotocol/contracts/artifacts/DataTokenTemplate.json'
|
||||||
|
|
||||||
const web3 = new Web3('http://127.0.0.1:8545')
|
const web3 = new Web3('http://127.0.0.1:8545')
|
||||||
|
|
||||||
@ -21,8 +22,8 @@ describe('DataTokens', () => {
|
|||||||
describe('#test', () => {
|
describe('#test', () => {
|
||||||
it('should deploy contracts', async () => {
|
it('should deploy contracts', async () => {
|
||||||
contracts = new TestContractHandler(
|
contracts = new TestContractHandler(
|
||||||
factory.abi,
|
factory.abi as AbiItem[],
|
||||||
datatokensTemplate.abi,
|
datatokensTemplate.abi as AbiItem[],
|
||||||
datatokensTemplate.bytecode,
|
datatokensTemplate.bytecode,
|
||||||
factory.bytecode,
|
factory.bytecode,
|
||||||
web3
|
web3
|
||||||
@ -36,8 +37,8 @@ describe('DataTokens', () => {
|
|||||||
it('should initialize datatokens class', async () => {
|
it('should initialize datatokens class', async () => {
|
||||||
datatoken = new DataTokens(
|
datatoken = new DataTokens(
|
||||||
contracts.factoryAddress,
|
contracts.factoryAddress,
|
||||||
factory.abi,
|
factory.abi as AbiItem[],
|
||||||
datatokensTemplate.abi,
|
datatokensTemplate.abi as AbiItem[],
|
||||||
web3
|
web3
|
||||||
)
|
)
|
||||||
assert(datatoken !== null)
|
assert(datatoken !== null)
|
||||||
|
@ -1,17 +1,18 @@
|
|||||||
import { assert } from 'chai'
|
import { assert } from 'chai'
|
||||||
|
import { AbiItem } from 'web3-utils/types'
|
||||||
import { TestContractHandler } from '../../TestContractHandler'
|
import { TestContractHandler } from '../../TestContractHandler'
|
||||||
import { BalancerContractHandler } from '../../BalancerContractHandler'
|
import { BalancerContractHandler } from '../../BalancerContractHandler'
|
||||||
import { DataTokens } from '../../../src/datatokens/Datatokens'
|
import { DataTokens } from '../../../src/datatokens/Datatokens'
|
||||||
import { OceanPool } from '../../../src/balancer/OceanPool'
|
import { OceanPool } from '../../../src/balancer/OceanPool'
|
||||||
|
|
||||||
const Web3 = require('web3')
|
import Web3 from 'web3'
|
||||||
const web3 = new Web3('http://127.0.0.1:8545')
|
import factory from '@oceanprotocol/contracts/artifacts/DTFactory.json'
|
||||||
const factory = require('@oceanprotocol/contracts/artifacts/DTFactory.json')
|
import datatokensTemplate from '@oceanprotocol/contracts/artifacts/DataTokenTemplate.json'
|
||||||
const datatokensTemplate = require('@oceanprotocol/contracts/artifacts/DataTokenTemplate.json')
|
|
||||||
|
|
||||||
// this will be replaced by our SFactory/SPool
|
// this will be replaced by our SFactory/SPool
|
||||||
const OceanPoolFactory = require('@oceanprotocol/contracts/artifacts/SFactory.json')
|
import OceanPoolFactory from '@oceanprotocol/contracts/artifacts/SFactory.json'
|
||||||
const OceanSPool = require('@oceanprotocol/contracts/artifacts/SPool.json')
|
import OceanSPool from '@oceanprotocol/contracts/artifacts/SPool.json'
|
||||||
|
const web3 = new Web3('http://127.0.0.1:8545')
|
||||||
|
|
||||||
describe('Balancer flow', () => {
|
describe('Balancer flow', () => {
|
||||||
let oceanTokenAddress
|
let oceanTokenAddress
|
||||||
@ -35,9 +36,9 @@ describe('Balancer flow', () => {
|
|||||||
before(async () => {
|
before(async () => {
|
||||||
// deploy SFactory
|
// deploy SFactory
|
||||||
const SContracts = new BalancerContractHandler(
|
const SContracts = new BalancerContractHandler(
|
||||||
OceanPoolFactory.abi,
|
OceanPoolFactory.abi as AbiItem[],
|
||||||
OceanPoolFactory.bytecode,
|
OceanPoolFactory.bytecode,
|
||||||
OceanSPool.abi,
|
OceanSPool.abi as AbiItem[],
|
||||||
OceanSPool.bytecode,
|
OceanSPool.bytecode,
|
||||||
web3
|
web3
|
||||||
)
|
)
|
||||||
@ -50,8 +51,8 @@ describe('Balancer flow', () => {
|
|||||||
|
|
||||||
// deploy DT Factory
|
// deploy DT Factory
|
||||||
contracts = new TestContractHandler(
|
contracts = new TestContractHandler(
|
||||||
factory.abi,
|
factory.abi as AbiItem[],
|
||||||
datatokensTemplate.abi,
|
datatokensTemplate.abi as AbiItem[],
|
||||||
datatokensTemplate.bytecode,
|
datatokensTemplate.bytecode,
|
||||||
factory.bytecode,
|
factory.bytecode,
|
||||||
web3
|
web3
|
||||||
@ -65,8 +66,8 @@ describe('Balancer flow', () => {
|
|||||||
// initialize DataTokens
|
// initialize DataTokens
|
||||||
datatoken = new DataTokens(
|
datatoken = new DataTokens(
|
||||||
contracts.factoryAddress,
|
contracts.factoryAddress,
|
||||||
factory.abi,
|
factory.abi as AbiItem[],
|
||||||
datatokensTemplate.abi,
|
datatokensTemplate.abi as AbiItem[],
|
||||||
web3
|
web3
|
||||||
)
|
)
|
||||||
assert(datatoken !== null)
|
assert(datatoken !== null)
|
||||||
@ -80,8 +81,8 @@ describe('Balancer flow', () => {
|
|||||||
// Alice creates a Datatoken
|
// Alice creates a Datatoken
|
||||||
oceandatatoken = new DataTokens(
|
oceandatatoken = new DataTokens(
|
||||||
contracts.factoryAddress,
|
contracts.factoryAddress,
|
||||||
factory.abi,
|
factory.abi as AbiItem[],
|
||||||
datatokensTemplate.abi,
|
datatokensTemplate.abi as AbiItem[],
|
||||||
web3
|
web3
|
||||||
)
|
)
|
||||||
oceanTokenAddress = await oceandatatoken.create(blob, alice)
|
oceanTokenAddress = await oceandatatoken.create(blob, alice)
|
||||||
@ -89,8 +90,8 @@ describe('Balancer flow', () => {
|
|||||||
it('should initialize OceanPool class', async () => {
|
it('should initialize OceanPool class', async () => {
|
||||||
Pool = new OceanPool(
|
Pool = new OceanPool(
|
||||||
web3,
|
web3,
|
||||||
OceanPoolFactory.abi,
|
OceanPoolFactory.abi as AbiItem[],
|
||||||
OceanSPool.abi,
|
OceanSPool.abi as AbiItem[],
|
||||||
OceanPoolFactoryAddress,
|
OceanPoolFactoryAddress,
|
||||||
oceanTokenAddress
|
oceanTokenAddress
|
||||||
)
|
)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user