mirror of
https://github.com/oceanprotocol-archive/squid-js.git
synced 2024-02-02 15:31:51 +01:00
typescript updates
This commit is contained in:
parent
c6bc0438de
commit
9d95f149d5
@ -2,7 +2,7 @@ dist: xenial
|
||||
sudo: required
|
||||
language: node_js
|
||||
node_js:
|
||||
- '12'
|
||||
- '11'
|
||||
|
||||
services:
|
||||
- docker
|
||||
|
@ -1,4 +1,4 @@
|
||||
import * as HDWalletProvider from 'truffle-hdwallet-provider'
|
||||
import HDWalletProvider from '@truffle/hdwallet-provider'
|
||||
import { Config } from '../src'
|
||||
|
||||
const configJson: Config = {
|
||||
|
@ -2,6 +2,7 @@
|
||||
"compilerOptions": {
|
||||
"resolveJsonModule": true,
|
||||
"lib": ["es6", "es7", "dom"],
|
||||
"noUnusedLocals": true
|
||||
"noUnusedLocals": true,
|
||||
"esModuleInterop": true
|
||||
}
|
||||
}
|
||||
|
3370
package-lock.json
generated
3370
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@ -64,6 +64,7 @@
|
||||
},
|
||||
"devDependencies": {
|
||||
"@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",
|
||||
@ -86,7 +87,6 @@
|
||||
"ora": "^4.0.2",
|
||||
"prettier": "^1.18.2",
|
||||
"source-map-support": "^0.5.16",
|
||||
"truffle-hdwallet-provider": "^1.0.17",
|
||||
"ts-node": "^8.4.1",
|
||||
"typedoc": "^0.15.0",
|
||||
"typescript": "^3.6.4",
|
||||
|
@ -1,4 +1,3 @@
|
||||
import Web3 from 'web3'
|
||||
import Web3Provider from '../keeper/Web3Provider'
|
||||
import LoggerInstance from '../utils/Logger'
|
||||
import { Ocean } from '../ocean/Ocean'
|
||||
@ -165,7 +164,7 @@ export class DDO {
|
||||
* @return {Promise<Proof>} Proof object.
|
||||
*/
|
||||
public async addProof(
|
||||
web3: Web3,
|
||||
web3: any,
|
||||
publicKey: string,
|
||||
password?: string
|
||||
): Promise<void> {
|
||||
|
@ -1,16 +1,18 @@
|
||||
import Web3 from 'web3'
|
||||
import Config from '../models/Config'
|
||||
import Web3Types from 'web3'
|
||||
const Web3 = require('web3')
|
||||
|
||||
export default class Web3Provider {
|
||||
/**
|
||||
* Returns Web3 instance.
|
||||
* @return {Web3}
|
||||
*/
|
||||
public static getWeb3(config: Partial<Config> = {}): Web3 {
|
||||
return new Web3(
|
||||
public static getWeb3(config: Partial<Config> = {}): Web3Types {
|
||||
const provider =
|
||||
config.web3Provider ||
|
||||
Web3.givenProvider ||
|
||||
new Web3.providers.HttpProvider(config.nodeUri)
|
||||
)
|
||||
|
||||
return new Web3(provider)
|
||||
}
|
||||
}
|
||||
|
@ -1,4 +1,5 @@
|
||||
import { LogLevel } from '../utils/Logger'
|
||||
import Web3 from 'web3'
|
||||
export { LogLevel } from '../utils/Logger'
|
||||
|
||||
export class Config {
|
||||
|
@ -78,7 +78,7 @@ export class ServiceAgreement extends Instantiable {
|
||||
timelocks: number[],
|
||||
timeouts: number[]
|
||||
): string {
|
||||
const args = [
|
||||
const args: any = [
|
||||
{ type: 'address', value: zeroX(serviceAgreementTemplateId) },
|
||||
{ type: 'bytes32[]', value: valueHashes.map(zeroX) },
|
||||
{ type: 'uint256[]', value: timelocks },
|
||||
@ -86,7 +86,9 @@ export class ServiceAgreement extends Instantiable {
|
||||
{ type: 'bytes32', value: zeroX(serviceAgreementId) }
|
||||
]
|
||||
|
||||
return this.web3.utils.soliditySha3(...args).toString('hex')
|
||||
// return this.web3.utils.soliditySha3(...args).toString('hex')
|
||||
const sha3 = this.web3.utils.soliditySha3(...args)
|
||||
return this.web3.utils.toHex(sha3)
|
||||
}
|
||||
|
||||
private getTimeValuesFromService(
|
||||
|
@ -14,7 +14,7 @@ export class SignatureUtils extends Instantiable {
|
||||
const isMetaMask =
|
||||
this.web3 &&
|
||||
this.web3.currentProvider &&
|
||||
this.web3.currentProvider.isMetaMask
|
||||
(this.web3 as any).currentProvider.isMetaMask
|
||||
try {
|
||||
return await this.web3.eth.personal.sign(text, publicKey, password)
|
||||
} catch (e) {
|
||||
@ -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'
|
||||
|
@ -1,5 +1,5 @@
|
||||
import { assert, expect, spy, use } from 'chai'
|
||||
import * as spies from 'chai-spies'
|
||||
import spies from 'chai-spies'
|
||||
import Web3 from 'web3'
|
||||
|
||||
import { DDO } from '../../src/ddo/DDO'
|
||||
@ -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(() => {
|
||||
|
@ -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 Contract from 'web3-eth-contract'
|
||||
import { Contract } from 'web3-eth-contract'
|
||||
import ContractHandler from '../../src/keeper/ContractHandler'
|
||||
import Web3Provider from '../../src/keeper/Web3Provider'
|
||||
import Logger from '../../src/utils/Logger'
|
||||
@ -134,13 +134,13 @@ export default class TestContractHandler extends ContractHandler {
|
||||
from: string,
|
||||
args: any[] = [],
|
||||
tokens: { [name: string]: string } = {}
|
||||
): Promise<Contract & { $initialized: boolean }> {
|
||||
): Promise<any & { $initialized: boolean }> {
|
||||
const where = this.networkId
|
||||
|
||||
// dont redeploy if there is already something loaded
|
||||
if (TestContractHandler.hasContract(name, where)) {
|
||||
const contract = await ContractHandler.getContract(name, where)
|
||||
if (contract.testContract) {
|
||||
if ((contract as any).testContract) {
|
||||
return { ...contract, $initialized: true }
|
||||
}
|
||||
}
|
||||
@ -153,7 +153,7 @@ export default class TestContractHandler extends ContractHandler {
|
||||
const sendConfig = {
|
||||
from,
|
||||
gas: 3000000,
|
||||
gasPrice: 10000000000
|
||||
gasPrice: String(10000000000)
|
||||
}
|
||||
const artifact = require(`@oceanprotocol/keeper-contracts/artifacts/${name}.development.json`)
|
||||
const tempContract = new web3.eth.Contract(
|
||||
@ -188,7 +188,7 @@ export default class TestContractHandler extends ContractHandler {
|
||||
.initialize(...args)
|
||||
.send(sendConfig)
|
||||
}
|
||||
contractInstance.testContract = true
|
||||
;(contractInstance as any).testContract = true
|
||||
ContractHandler.setContract(name, where, contractInstance)
|
||||
// Logger.log("Deployed", name, "at", contractInstance.options.address);
|
||||
} catch (err) {
|
||||
|
@ -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'
|
||||
|
@ -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…
Reference in New Issue
Block a user