mirror of
https://github.com/oceanprotocol-archive/squid-js.git
synced 2024-02-02 15:31:51 +01:00
commit
f3e044ecdd
13
.travis.yml
13
.travis.yml
@ -2,7 +2,7 @@ dist: xenial
|
||||
sudo: required
|
||||
language: node_js
|
||||
node_js:
|
||||
- '10'
|
||||
- '11'
|
||||
|
||||
services:
|
||||
- docker
|
||||
@ -22,20 +22,21 @@ before_script:
|
||||
- git clone https://github.com/oceanprotocol/barge
|
||||
- cd barge
|
||||
- export AQUARIUS_VERSION=v0.3.8
|
||||
- export BRIZO_VERSION=v0.4.4
|
||||
- export KEEPER_VERSION=v0.11.1
|
||||
- export BRIZO_VERSION=v0.4.5
|
||||
- export KEEPER_VERSION=v0.12.7
|
||||
- export EVENTS_HANDLER_VERSION=v0.1.2
|
||||
- export KEEPER_OWNER_ROLE_ADDRESS="0xe2DD09d719Da89e5a3D0F2549c7E24566e947260"
|
||||
- bash -x start_ocean.sh --no-commons --local-spree-node 2>&1 > start_ocean.log &
|
||||
- rm -rf "${HOME}/.ocean/keeper-contracts/artifacts"
|
||||
- bash -x start_ocean.sh --no-commons --no-dashboard 2>&1 > start_ocean.log &
|
||||
- cd ..
|
||||
|
||||
script:
|
||||
- npm run lint
|
||||
- ./scripts/keeper.sh
|
||||
- export ETH_PORT=18545; npm run test:cover
|
||||
- npm run build
|
||||
- npm run doc
|
||||
- export SEED_WORDS="taxi music thumb unique chat sand crew more leg another off lamp"; npm run integration:cover
|
||||
- ./scripts/keeper.sh
|
||||
- npm run integration:cover
|
||||
- npm run report-coverage
|
||||
|
||||
after_script:
|
||||
|
@ -102,11 +102,12 @@ npm start
|
||||
|
||||
### Unit Tests
|
||||
|
||||
For unit tests, running [`ganache-cli`](https://github.com/trufflesuite/ganache-cli) is required before starting the tests:
|
||||
For unit tests, running [`ganache-cli`](https://github.com/trufflesuite/ganache-cli) is required before starting the tests. It's best to start it on a different port so it doesn't clash with anything running in Barge:
|
||||
|
||||
```bash
|
||||
npm i -g ganache-cli
|
||||
ganache-cli
|
||||
ganache-cli --port 18545
|
||||
export ETH_PORT=18545
|
||||
```
|
||||
|
||||
To start unit tests, run:
|
||||
|
@ -1,4 +1,4 @@
|
||||
import * as HDWalletProvider from 'truffle-hdwallet-provider'
|
||||
import HDWalletProvider from '@truffle/hdwallet-provider'
|
||||
import { Config } from '../src'
|
||||
|
||||
const configJson: Config = {
|
||||
|
@ -1,9 +1,6 @@
|
||||
import { assert } from 'chai'
|
||||
|
||||
import { config } from '../config'
|
||||
|
||||
import { getMetadata } from '../utils'
|
||||
|
||||
import { Ocean, Account } from '../../src' // @oceanprotocol/squid
|
||||
|
||||
describe('Asset Owners', () => {
|
||||
@ -25,15 +22,14 @@ describe('Asset Owners', () => {
|
||||
}
|
||||
})
|
||||
|
||||
it('should be set correctly the owner of an asset', async () => {
|
||||
it('should set the owner of an asset', async () => {
|
||||
const ddo = await ocean.assets.create(metadata as any, account1)
|
||||
|
||||
const owner = await ocean.assets.owner(ddo.id)
|
||||
|
||||
assert.equal(owner, account1.getId())
|
||||
})
|
||||
|
||||
it('should be set correctly the provider of an asset', async () => {
|
||||
it('should set the provider of an asset', async () => {
|
||||
const ddo = await ocean.assets.create(metadata as any, account1)
|
||||
|
||||
const isProvider = await ocean.keeper.didRegistry.isDIDProvider(
|
||||
@ -61,7 +57,7 @@ describe('Asset Owners', () => {
|
||||
assert.equal(finalLength - initialLength, 1)
|
||||
})
|
||||
|
||||
it('should get the assets that can be consumer by a user', async () => {
|
||||
it('should get the assets that can be consumed by a user', async () => {
|
||||
const { length: initialLength } = await ocean.assets.consumerAssets(
|
||||
account2.getId()
|
||||
)
|
||||
|
@ -17,7 +17,7 @@ describe('Signature', () => {
|
||||
;[consumer] = await ocean.accounts.list()
|
||||
})
|
||||
|
||||
it('should generate the correct signature', async () => {
|
||||
it('hashServiceAgreement should generate the correct signature', () => {
|
||||
const templateId = `0x${'f'.repeat(40)}`
|
||||
const agreementId = `0x${'e'.repeat(64)}`
|
||||
|
||||
@ -25,7 +25,7 @@ describe('Signature', () => {
|
||||
const lockId = `0x${'b'.repeat(64)}`
|
||||
const escrowId = `0x${'c'.repeat(64)}`
|
||||
|
||||
const hash = await ocean.utils.agreements.hashServiceAgreement(
|
||||
const hash = ocean.utils.agreements.hashServiceAgreement(
|
||||
templateId,
|
||||
agreementId,
|
||||
[accessId, lockId, escrowId],
|
||||
@ -36,11 +36,11 @@ describe('Signature', () => {
|
||||
assert.equal(
|
||||
hash,
|
||||
'0x67901517c18a3d23e05806fff7f04235cc8ae3b1f82345b8bfb3e4b02b5800c7',
|
||||
'The signatuere is not correct.'
|
||||
'The signature is not correct.'
|
||||
)
|
||||
})
|
||||
|
||||
it('should generate the correct signature', async () => {
|
||||
it('signServiceAgreement should generate the correct signature', async () => {
|
||||
const { templates } = ocean.keeper
|
||||
|
||||
const did = `did:op:${'c'.repeat(64)}`
|
||||
@ -86,8 +86,8 @@ describe('Signature', () => {
|
||||
|
||||
assert.equal(
|
||||
signature,
|
||||
'0x3aa8a1c48b8e582d694bbd4ba3a29fde573b78da9720dc48baeb831b2163e1fa6e10e983882ebf8a00f4124de2505136354fd146934053f0d58bba4eced5f8d000',
|
||||
'The signatuere is not correct.'
|
||||
'0x3aa8a1c48b8e582d694bbd4ba3a29fde573b78da9720dc48baeb831b2163e1fa6e10e983882ebf8a00f4124de2505136354fd146934053f0d58bba4eced5f8d01b',
|
||||
'The signature is not correct.'
|
||||
)
|
||||
})
|
||||
})
|
||||
|
@ -2,6 +2,7 @@
|
||||
"compilerOptions": {
|
||||
"resolveJsonModule": true,
|
||||
"lib": ["es6", "es7", "dom"],
|
||||
"noUnusedLocals": true
|
||||
"noUnusedLocals": true,
|
||||
"esModuleInterop": true
|
||||
}
|
||||
}
|
||||
|
@ -7,11 +7,11 @@
|
||||
"dependencies": [
|
||||
{
|
||||
"name": "keeper-contracts",
|
||||
"version": "~0.11.1"
|
||||
"version": "~0.12.7"
|
||||
},
|
||||
{
|
||||
"name": "brizo",
|
||||
"version": "~0.4.2"
|
||||
"version": "~0.4.5"
|
||||
},
|
||||
{
|
||||
"name": "aquarius",
|
||||
|
4312
package-lock.json
generated
4312
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
47
package.json
47
package.json
@ -52,47 +52,47 @@
|
||||
"web3": "^1.2.0"
|
||||
},
|
||||
"dependencies": {
|
||||
"@oceanprotocol/keeper-contracts": "^0.12.4",
|
||||
"@oceanprotocol/secret-store-client": "0.0.15",
|
||||
"@oceanprotocol/keeper-contracts": "^0.12.7",
|
||||
"@oceanprotocol/secret-store-client": "^0.0.15",
|
||||
"bignumber.js": "^9.0.0",
|
||||
"deprecated-decorator": "^0.1.6",
|
||||
"node-fetch": "^2.6.0",
|
||||
"save-file": "^2.3.1",
|
||||
"uuid": "^3.3.3",
|
||||
"web3": "1.2.1",
|
||||
"whatwg-url": "^7.0.0"
|
||||
"whatwg-url": "^7.1.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@release-it/bumper": "^1.0.3",
|
||||
"@types/chai": "^4.2.2",
|
||||
"@release-it/bumper": "^1.0.5",
|
||||
"@truffle/hdwallet-provider": "^1.0.23",
|
||||
"@types/chai": "^4.2.4",
|
||||
"@types/chai-spies": "^1.0.1",
|
||||
"@types/mocha": "^5.2.7",
|
||||
"@types/node": "^12.7.5",
|
||||
"@types/node-fetch": "^2.5.0",
|
||||
"@typescript-eslint/eslint-plugin": "^2.2.0",
|
||||
"@typescript-eslint/parser": "^2.2.0",
|
||||
"auto-changelog": "^1.16.1",
|
||||
"@types/node": "^12.12.5",
|
||||
"@types/node-fetch": "^2.5.3",
|
||||
"@typescript-eslint/eslint-plugin": "^2.6.0",
|
||||
"@typescript-eslint/parser": "^2.6.0",
|
||||
"auto-changelog": "^1.16.2",
|
||||
"chai": "^4.2.0",
|
||||
"chai-spies": "^1.0.0",
|
||||
"cross-env": "^6.0.0",
|
||||
"eslint": "^6.3.0",
|
||||
"cross-env": "^6.0.3",
|
||||
"eslint": "^6.6.0",
|
||||
"eslint-config-oceanprotocol": "^1.5.0",
|
||||
"eslint-config-prettier": "^6.3.0",
|
||||
"eslint-plugin-prettier": "^3.1.0",
|
||||
"eslint-config-prettier": "^6.5.0",
|
||||
"eslint-plugin-prettier": "^3.1.1",
|
||||
"lcov-result-merger": "^3.1.0",
|
||||
"mocha": "^6.2.0",
|
||||
"mocha": "^6.2.2",
|
||||
"mock-local-storage": "^1.1.8",
|
||||
"nyc": "^14.1.1",
|
||||
"ora": "^4.0.0",
|
||||
"ora": "^4.0.2",
|
||||
"prettier": "^1.18.2",
|
||||
"source-map-support": "^0.5.13",
|
||||
"truffle-hdwallet-provider": "^1.0.17",
|
||||
"ts-node": "^8.3.0",
|
||||
"source-map-support": "^0.5.16",
|
||||
"ts-node": "^8.4.1",
|
||||
"typedoc": "^0.15.0",
|
||||
"typescript": "^3.6.3",
|
||||
"typescript": "^3.6.4",
|
||||
"uglifyjs-webpack-plugin": "^2.2.0",
|
||||
"webpack": "^4.40.1",
|
||||
"webpack-cli": "^3.3.8",
|
||||
"webpack": "^4.41.2",
|
||||
"webpack-cli": "^3.3.10",
|
||||
"webpack-merge": "^4.2.2"
|
||||
},
|
||||
"nyc": {
|
||||
@ -122,7 +122,8 @@
|
||||
"@release-it/bumper": {
|
||||
"out": [
|
||||
"package.json",
|
||||
"package-lock.json"
|
||||
"package-lock.json",
|
||||
"dist/squid-js.json"
|
||||
]
|
||||
}
|
||||
},
|
||||
|
@ -1,4 +1,4 @@
|
||||
import * as Web3 from 'web3'
|
||||
import Web3 from 'web3'
|
||||
import Config from './models/Config'
|
||||
import { Logger, LoggerInstance, LogLevel } from './utils'
|
||||
import Web3Provider from './keeper/Web3Provider'
|
||||
|
@ -1,4 +1,4 @@
|
||||
import * as Web3 from 'web3'
|
||||
import Web3 from 'web3'
|
||||
import Web3Provider from '../keeper/Web3Provider'
|
||||
import LoggerInstance from '../utils/Logger'
|
||||
import { Ocean } from '../ocean/Ocean'
|
||||
|
@ -20,7 +20,7 @@ export class ContractEvent {
|
||||
public subscribe(
|
||||
callback: (events: any[]) => void
|
||||
): ContractEventSubscription {
|
||||
const onEvent = async blockNumber => {
|
||||
const onEvent = async (blockNumber: number) => {
|
||||
const events = await this.contract.getEventData(this.eventName, {
|
||||
filter: this.filter,
|
||||
fromBlock: blockNumber,
|
||||
|
@ -1,4 +1,4 @@
|
||||
import * as Web3 from 'web3'
|
||||
import Web3 from 'web3'
|
||||
import Config from '../models/Config'
|
||||
|
||||
export default class Web3Provider {
|
||||
|
@ -24,7 +24,7 @@ export class SignatureUtils extends Instantiable {
|
||||
this.logger.warn('Error on personal sign.')
|
||||
this.logger.warn(e)
|
||||
try {
|
||||
return await this.web3.eth.sign(text, publicKey, password)
|
||||
return await this.web3.eth.sign(text, publicKey)
|
||||
} catch (e2) {
|
||||
this.logger.error('Error on sign.')
|
||||
this.logger.error(e2)
|
||||
|
@ -1,4 +1,4 @@
|
||||
import * as assert from 'assert'
|
||||
import assert from 'assert'
|
||||
import * as squid from '../src/squid'
|
||||
|
||||
describe('Squid', () => {
|
||||
|
@ -1,6 +1,5 @@
|
||||
import { assert, spy, use } from 'chai'
|
||||
import * as spies from 'chai-spies'
|
||||
|
||||
import spies from 'chai-spies'
|
||||
import { Ocean } from '../../src/ocean/Ocean'
|
||||
import { Aquarius, SearchQuery } from '../../src/aquarius/Aquarius'
|
||||
import { DDO } from '../../src/ddo/DDO'
|
||||
|
@ -5,7 +5,7 @@ LoggerInstance.setLevel(LogLevel.Error)
|
||||
|
||||
export default {
|
||||
aquariusUri: 'http://localhost:5000',
|
||||
brizoUri: 'http://localhost:3000',
|
||||
brizoUri: 'http://localhost:8030',
|
||||
nodeUri: `http://localhost:${process.env.ETH_PORT || 8545}`,
|
||||
parityUri: 'http://localhost:9545',
|
||||
secretStoreUri: 'http://localhost:12001',
|
||||
|
@ -1,6 +1,6 @@
|
||||
import { assert, expect, spy, use } from 'chai'
|
||||
import * as spies from 'chai-spies'
|
||||
import * as Web3 from 'web3'
|
||||
import spies from 'chai-spies'
|
||||
import Web3 from 'web3'
|
||||
|
||||
import { DDO } from '../../src/ddo/DDO'
|
||||
import { Service } from '../../src/ddo/Service'
|
||||
@ -177,7 +177,7 @@ describe('DDO', () => {
|
||||
beforeEach(async () => {
|
||||
await TestContractHandler.prepareContracts()
|
||||
ocean = await Ocean.getInstance(config)
|
||||
web3 = (ocean as any).web3
|
||||
;({ web3 } = ocean as any)
|
||||
})
|
||||
|
||||
afterEach(() => {
|
||||
|
@ -22,7 +22,7 @@ describe('ContractEvent', () => {
|
||||
})
|
||||
|
||||
describe('#subscribe()', () => {
|
||||
it('should listen the events', async () => {
|
||||
it('should be able to listen to events', async () => {
|
||||
const event = eventHandler.getEvent(
|
||||
ocean.keeper.token,
|
||||
'Transfer',
|
||||
@ -55,7 +55,7 @@ describe('ContractEvent', () => {
|
||||
})
|
||||
|
||||
describe('#once()', () => {
|
||||
it('should listen only once', async () => {
|
||||
it('should listen to event only once', async () => {
|
||||
const to = account
|
||||
const event = eventHandler.getEvent(
|
||||
ocean.keeper.token,
|
||||
@ -65,7 +65,7 @@ describe('ContractEvent', () => {
|
||||
let canBeRejected = false
|
||||
|
||||
const waitUntilEvent = new Promise((resolve, reject) => {
|
||||
event.once(events => {
|
||||
event.once(() => {
|
||||
if (canBeRejected) {
|
||||
reject(new Error(''))
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
import { assert, expect, spy, use } from 'chai'
|
||||
import * as spies from 'chai-spies'
|
||||
import spies from 'chai-spies'
|
||||
import { EventHandler } from '../../src/keeper/EventHandler'
|
||||
import { Ocean } from '../../src/ocean/Ocean'
|
||||
import config from '../config'
|
||||
|
@ -1,4 +1,4 @@
|
||||
import * as assert from 'assert'
|
||||
import assert from 'assert'
|
||||
import DID from '../../src/ocean/DID'
|
||||
|
||||
describe('DID', () => {
|
||||
|
@ -1,5 +1,5 @@
|
||||
import { assert, spy, use } from 'chai'
|
||||
import * as spies from 'chai-spies'
|
||||
import spies from 'chai-spies'
|
||||
|
||||
import { SearchQuery } from '../../src/aquarius/Aquarius'
|
||||
import Account from '../../src/ocean/Account'
|
||||
@ -25,7 +25,7 @@ describe('Ocean', () => {
|
||||
})
|
||||
|
||||
describe('#getInstance()', () => {
|
||||
it('should get an instance of cean', async () => {
|
||||
it('should get an instance of Ocean', async () => {
|
||||
const oceanInstance: Ocean = await Ocean.getInstance(config)
|
||||
|
||||
assert(oceanInstance)
|
||||
|
@ -1,5 +1,5 @@
|
||||
import { assert, spy, use } from 'chai'
|
||||
import * as spies from 'chai-spies'
|
||||
import spies from 'chai-spies'
|
||||
|
||||
import config from '../config'
|
||||
import Account from '../../src/ocean/Account'
|
||||
|
@ -1,5 +1,5 @@
|
||||
import { assert, expect, spy, use } from 'chai'
|
||||
import * as spies from 'chai-spies'
|
||||
import spies from 'chai-spies'
|
||||
|
||||
import config from '../config'
|
||||
import Account from '../../src/ocean/Account'
|
||||
|
@ -1,5 +1,5 @@
|
||||
import { assert, expect, spy, use } from 'chai'
|
||||
import * as spies from 'chai-spies'
|
||||
import spies from 'chai-spies'
|
||||
|
||||
import Account from '../../src/ocean/Account'
|
||||
import { Ocean } from '../../src/ocean/Ocean'
|
||||
|
@ -1,5 +1,5 @@
|
||||
import { assert, expect, spy, use } from 'chai'
|
||||
import * as spies from 'chai-spies'
|
||||
import spies from 'chai-spies'
|
||||
|
||||
import config from '../../config'
|
||||
|
||||
|
@ -1,10 +1,8 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"resolveJsonModule": true,
|
||||
"lib": [
|
||||
"es6",
|
||||
"es7"
|
||||
],
|
||||
"noUnusedLocals": true
|
||||
"lib": ["es6", "es7"],
|
||||
"noUnusedLocals": true,
|
||||
"esModuleInterop": true
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
import { assert, expect, spy, use } from 'chai'
|
||||
import * as spies from 'chai-spies'
|
||||
import spies from 'chai-spies'
|
||||
|
||||
import { SubscribableObserver } from '../../src/utils/SubscribableObserver'
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
import { assert, expect, spy, use } from 'chai'
|
||||
import * as spies from 'chai-spies'
|
||||
import spies from 'chai-spies'
|
||||
|
||||
import { SubscribablePromise } from '../../src/utils/SubscribablePromise'
|
||||
|
||||
|
@ -6,6 +6,7 @@
|
||||
"declaration": true,
|
||||
"module": "commonjs",
|
||||
"target": "es5",
|
||||
"esModuleInterop": true,
|
||||
"noImplicitAny": false,
|
||||
"removeComments": true,
|
||||
"experimentalDecorators": true,
|
||||
|
Loading…
x
Reference in New Issue
Block a user