From 4d630b3af8e7aea78d216621600880c65950ca26 Mon Sep 17 00:00:00 2001 From: Federico Date: Tue, 25 Sep 2018 15:23:24 +0200 Subject: [PATCH 1/8] =?UTF-8?q?initial=20commit=20=F0=9F=8C=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/api/src/contracts/contract.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/api/src/contracts/contract.ts b/packages/api/src/contracts/contract.ts index 023207d25..7bfd3286c 100644 --- a/packages/api/src/contracts/contract.ts +++ b/packages/api/src/contracts/contract.ts @@ -3,6 +3,7 @@ import { ContractExtension } from './contract-extension' import { ContractModels } from './' import { TypeChainContract } from './models/typechain-runtime' +// abi-gen support class Contract extends ContractModels { async init(web3: Web3, contractsMap: Contract.ContractsMap) { const contractNames: string[] = Object.keys(contractsMap) From ebb38d4024ac9a99b625c35bb09b23651ae6dfff Mon Sep 17 00:00:00 2001 From: Federico Obialero Date: Tue, 25 Sep 2018 16:15:17 +0200 Subject: [PATCH 2/8] Initial Template (#450) * initial commit * added abi-gen script * wip * first tests * working constant methods * first contract tests * template cleanup * minor fix to tests * removed abis folder * removed typechain contracts * commented non working circleci steps * removed useless files * rollback RigoToken test * eslint ignoring generated files * minor rollback * fixes to package.json --- .circleci/config.yml | 50 ++--- packages/api/.gitignore | 2 +- packages/api/abi-gen.ts | 7 + packages/api/package.json | 27 ++- .../api/partials/constantFunction.handlebars | 6 + packages/api/partials/event.handlebars | 5 + packages/api/partials/params.handlebars | 3 + packages/api/partials/return_type.handlebars | 10 + packages/api/partials/txFunction.handlebars | 3 + packages/api/partials/typed_params.handlebars | 3 + packages/api/src/baseContract.ts | 6 + packages/api/template.handlebars | 57 ++++++ packages/api/test/contracts.test.ts | 92 +++++++++ packages/api/test/setupTests.ts | 16 ++ packages/exchange-connector/package.json | 1 - yarn.lock | 185 +++++++++++++++--- 16 files changed, 420 insertions(+), 53 deletions(-) create mode 100644 packages/api/abi-gen.ts create mode 100644 packages/api/partials/constantFunction.handlebars create mode 100644 packages/api/partials/event.handlebars create mode 100644 packages/api/partials/params.handlebars create mode 100644 packages/api/partials/return_type.handlebars create mode 100644 packages/api/partials/txFunction.handlebars create mode 100644 packages/api/partials/typed_params.handlebars create mode 100644 packages/api/src/baseContract.ts create mode 100644 packages/api/template.handlebars create mode 100644 packages/api/test/contracts.test.ts create mode 100644 packages/api/test/setupTests.ts diff --git a/.circleci/config.yml b/.circleci/config.yml index c3f48843a..122d1c22f 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -389,28 +389,28 @@ workflows: - test-contracts: requires: - build-contracts - - build-api: - requires: - - build-contracts - - build-dapp: - requires: - - build-api - - test-feature-dapp: - requires: - - build-dapp - - deploy-dapp-staging: - requires: - - test-unit-dapp - - build-dapp - - test-feature-dapp - filters: - branches: - only: master - - deploy-storybook-staging: - requires: - - test-unit-dapp - - build-dapp - - test-feature-dapp - filters: - branches: - only: master + # - build-api: + # requires: + # - build-contracts + # - build-dapp: + # requires: + # - build-api + # - test-feature-dapp: + # requires: + # - build-dapp + # - deploy-dapp-staging: + # requires: + # - test-unit-dapp + # - build-dapp + # - test-feature-dapp + # filters: + # branches: + # only: master + # - deploy-storybook-staging: + # requires: + # - test-unit-dapp + # - build-dapp + # - test-feature-dapp + # filters: + # branches: + # only: master diff --git a/packages/api/.gitignore b/packages/api/.gitignore index 7f31e16d5..1ab3d818d 100644 --- a/packages/api/.gitignore +++ b/packages/api/.gitignore @@ -1,6 +1,6 @@ coverage .tmp -src/contracts/models +src/generated dist lib node_modules diff --git a/packages/api/abi-gen.ts b/packages/api/abi-gen.ts new file mode 100644 index 000000000..22827e595 --- /dev/null +++ b/packages/api/abi-gen.ts @@ -0,0 +1,7 @@ +const Handlebars = require('handlebars') + +Handlebars.registerHelper('getAbi', (ctor, events, methods) => + JSON.stringify([ctor, ...events, ...methods], null, 2) +) + +const abiGen = require('@0xproject/abi-gen') diff --git a/packages/api/package.json b/packages/api/package.json index 204083278..2f96c0e12 100644 --- a/packages/api/package.json +++ b/packages/api/package.json @@ -10,16 +10,22 @@ "scripts": { "build": "npm run typechain && npm run tsc", "tsc": "rm -rf dist/* && tsc --outDir './dist'", + "test": "jest", "tsc:watch": "rm -rf dist; tsc -w --outDir './dist'", "lint": "eslint src --ext ts --ignore-path .gitignore --fix", - "typechain": "rm -rf .tmp && node src/abi-extractor.js && typechain --force --outDir src/contracts/models '.tmp/*.json'" + "abi-gen": "node src/abi-extractor.js && rm -rf src/generated && ts-node abi-gen.ts --abis './.tmp/*.json' -o src/generated --template './template.handlebars' --partials './partials/*.handlebars'" }, "files": [ "dist" ], "devDependencies": { + "@0xproject/abi-gen": "^1.0.9", + "@types/jest": "^23.3.2", + "bignumber.js": "^7.2.1", "chalk": "^2.4.1", "eslint-plugin-typescript": "^0.12.0", + "jest": "^23.6.0", + "ts-jest": "^23.10.1", "typescript": "^3.0.1", "typescript-eslint-parser": "^18.0.0" }, @@ -30,8 +36,25 @@ "@rigoblock/contracts": "^0.3.2", "@types/node": "^9.6.6", "bignumber.js": "^5.0.0", + "handlebars": "^4.0.12", "typechain": "^0.2.2", - "web3": "0.20.6", + "web3": "1.0.0-beta.36", "web3-provider-engine": "^14.0.5" + }, + "jest": { + "setupTestFrameworkScriptFile": "/test/setupTests.ts", + "roots": [ + "/test" + ], + "transform": { + "^.+\\.ts?$": "ts-jest" + }, + "testRegex": "(/__tests__/.*|(\\.|/)(test|spec))\\.tsx?$", + "moduleFileExtensions": [ + "ts", + "js", + "json", + "node" + ] } } diff --git a/packages/api/partials/constantFunction.handlebars b/packages/api/partials/constantFunction.handlebars new file mode 100644 index 000000000..af9bb105d --- /dev/null +++ b/packages/api/partials/constantFunction.handlebars @@ -0,0 +1,6 @@ +public async {{this.tsName}}( +{{> typed_params inputs=inputs}} +): Promise<{{> return_type outputs=outputs}}> { + const transactionObject = await this.rawWeb3Contract.methods.{{this.tsName}}({{> params inputs=inputs}}) + return transactionObject.call() +} diff --git a/packages/api/partials/event.handlebars b/packages/api/partials/event.handlebars new file mode 100644 index 000000000..61d523ca2 --- /dev/null +++ b/packages/api/partials/event.handlebars @@ -0,0 +1,5 @@ +export interface {{@root.contractName}}{{name}}EventArgs extends DecodedLogArgs { + {{#each inputs}} + {{name}}: {{#returnType type components}}{{/returnType}}; + {{/each}} +} diff --git a/packages/api/partials/params.handlebars b/packages/api/partials/params.handlebars new file mode 100644 index 000000000..6e5cb6b98 --- /dev/null +++ b/packages/api/partials/params.handlebars @@ -0,0 +1,3 @@ +{{#each inputs}} +{{name}}.toString(){{#if @last}}{{else}},{{/if}} +{{/each}} diff --git a/packages/api/partials/return_type.handlebars b/packages/api/partials/return_type.handlebars new file mode 100644 index 000000000..77d96e8c4 --- /dev/null +++ b/packages/api/partials/return_type.handlebars @@ -0,0 +1,10 @@ +{{#if outputs.length}} +{{#singleReturnValue}} +{{#returnType outputs.0.type outputs.0.components}}{{/returnType}} +{{/singleReturnValue}} +{{^singleReturnValue}} +[{{#each outputs}}{{#returnType type components}}{{/returnType}}{{#unless @last}}, {{/unless}}{{/each}}] +{{/singleReturnValue}} +{{else}} +void +{{/if}} diff --git a/packages/api/partials/txFunction.handlebars b/packages/api/partials/txFunction.handlebars new file mode 100644 index 000000000..514a7e1d2 --- /dev/null +++ b/packages/api/partials/txFunction.handlebars @@ -0,0 +1,3 @@ +public async {{this.tsName}}({{> typed_params inputs=inputs}}): Promise<{{> return_type outputs=outputs}}> { + return this.rawWeb3Contract.methods.{{this.tsName}}({{> params inputs=inputs}}) +} diff --git a/packages/api/partials/typed_params.handlebars b/packages/api/partials/typed_params.handlebars new file mode 100644 index 000000000..c100e58f7 --- /dev/null +++ b/packages/api/partials/typed_params.handlebars @@ -0,0 +1,3 @@ +{{#each inputs}} + {{name}}: {{#parameterType type components}}{{/parameterType}}, +{{/each}} diff --git a/packages/api/src/baseContract.ts b/packages/api/src/baseContract.ts new file mode 100644 index 000000000..adb71bee3 --- /dev/null +++ b/packages/api/src/baseContract.ts @@ -0,0 +1,6 @@ +export default class BaseContract { + public readonly rawWeb3Contract: any + constructor(web3: any, address: string, abi: any) { + this.rawWeb3Contract = new web3.eth.Contract(abi, address) + } +} diff --git a/packages/api/template.handlebars b/packages/api/template.handlebars new file mode 100644 index 000000000..8819e6511 --- /dev/null +++ b/packages/api/template.handlebars @@ -0,0 +1,57 @@ +/* eslint-disable */ +import { BigNumber } from 'bignumber.js' +import BaseContract from '../baseContract' + +{{!-- TODO: add events --}} +{{!-- {{#if events}} +export type {{contractName}}EventArgs = +{{#each events}} + | {{@root.contractName}}{{name}}EventArgs{{#if @last}};{{/if}} +{{/each}} + +export enum {{contractName}}Events { + {{#each events}} + {{name}} = '{{name}}', + {{/each}} +} + +{{#each events}} +{{> event}} + +{{/each}} +{{/if}} --}} +export class {{contractName}} extends BaseContract { + public constructor(web3: any, address: string) { + const abi = {{{getAbi ctor events methods}}} + super(web3, address, abi); + } + + static async createAndValidate( + web3: any, + address: string + ): Promise<{{contractName}}> { + const contract = new {{contractName}}(web3, address) + const code = await web3.eth.getCode(address) + + // in case of missing smartcontract, code can be equal to "0x0" or "0x" depending on exact web3 implementation + // to cover all these cases we just check against the source code length — there won't be any meaningful EVM program in less then 3 chars + if (code.length < 4) { + throw new Error(`Contract at ${address} doesn't exist!`); + } + return contract; + } + + public static address: string + {{#each methods}} + {{#this.constant}} + {{> constantFunction contractName=../contractName}} + {{/this.constant}} + {{^this.constant}} + {{> txFunction contractName=../contractName}} + {{/this.constant}} + {{/each}} + + static isDeployed() { + return !!this.address + } +} diff --git a/packages/api/test/contracts.test.ts b/packages/api/test/contracts.test.ts new file mode 100644 index 000000000..cc360159e --- /dev/null +++ b/packages/api/test/contracts.test.ts @@ -0,0 +1,92 @@ +import Web3 = require('web3') +import { Vault } from '../src/generated/vault' +import { VaultFactory } from '../src/generated/vault_factory' + +describe('generated contract', () => { + let web3 + let extendedExpect + let accounts + let txOptions + beforeAll(async () => { + web3 = new Web3(new Web3.providers.HttpProvider('http://localhost:8545')) + accounts = await web3.eth.getAccounts() + extendedExpect = expect as any + }) + describe('createAndValidate', () => { + it('istantiates a smart contract', async () => { + const vaultFactory = await VaultFactory.createAndValidate( + web3, + '0x7ce6e371085cb611fb46d5065397223ef2f952ff' + ) + expect(vaultFactory).toBeInstanceOf(VaultFactory) + }) + }) + describe('contract methods', () => { + let vaultFactory + beforeAll(async () => { + txOptions = { + from: accounts[0] + } + vaultFactory = await VaultFactory.createAndValidate( + web3, + '0x7ce6e371085cb611fb46d5065397223ef2f952ff' + ) + }) + it('constant method', async () => { + const registry = '0xf7cBB0849d4a8ec5aB4650030FA776c00Eb52dA7' + const res = await vaultFactory.getRegistry() + expect(res).toEqual(registry) + }) + it('createVault', async () => { + const vaultName = Math.random() + .toString(36) + .substring(2, 7) + const vaultOptions = [vaultName, 'ASD'] + const gasPrice = await web3.eth.getGasPrice() + const gasEstimate = await vaultFactory // 2538415 + .createVault(...vaultOptions) + .then(obj => obj.estimateGas(txOptions)) + const receipt = await vaultFactory + .createVault(...vaultOptions) + .then(obj => + // adding value to gas estimate as it is not always correct + obj.send({ ...txOptions, gasPrice, gas: gasEstimate + 5000 }) + ) + + extendedExpect(receipt.transactionHash).toBeHash() + }) + describe('payable methods', async () => { + let vaultInstance + beforeAll(async () => { + const vaultName = Math.random() + .toString(36) + .substring(2, 7) + const vaultOptions = [vaultName, 'VLT'] + const gasPrice = await web3.eth.getGasPrice() + const gasEstimate = await vaultFactory + .createVault(...vaultOptions) + .then(obj => obj.estimateGas(txOptions)) + const receipt = await vaultFactory + .createVault(...vaultOptions) + .then(obj => + // adding value to gas estimate as it is not always correct + obj.send({ ...txOptions, gasPrice, gas: gasEstimate + 5000 }) + ) + const vaultAddress = receipt.events.VaultCreated.returnValues.vault + vaultInstance = await Vault.createAndValidate(web3, vaultAddress) + }) + it('buyVault', async () => { + const options = { ...txOptions, value: web3.utils.toWei('1') } + const gasPrice = await web3.eth.getGasPrice() + const gasEstimate = await vaultInstance + .buyVault() + .then(obj => obj.estimateGas(options)) + await vaultInstance + .buyVault() + .then(obj => + obj.send({ ...options, gasPrice, gas: gasEstimate + 5000 }) + ) + }) + }) + }) +}) diff --git a/packages/api/test/setupTests.ts b/packages/api/test/setupTests.ts new file mode 100644 index 000000000..2b4a77f0e --- /dev/null +++ b/packages/api/test/setupTests.ts @@ -0,0 +1,16 @@ +expect.extend({ + toBeHash(received) { + try { + if (received.substring(0, 2) === '0x' && received.length === 66) { + return { + message: () => `expected ${received} to be a valid Hash`, + pass: true + } + } + } catch (err) {} + return { + message: () => `expected ${received} to be a valid Hash`, + pass: false + } + } +}) diff --git a/packages/exchange-connector/package.json b/packages/exchange-connector/package.json index d7b7f64c1..ef7181442 100644 --- a/packages/exchange-connector/package.json +++ b/packages/exchange-connector/package.json @@ -54,7 +54,6 @@ ] }, "jest": { - "verbose": true, "testURL": "http://localhost/", "roots": [ "/src" diff --git a/yarn.lock b/yarn.lock index 02ae5c81c..f82297381 100644 --- a/yarn.lock +++ b/yarn.lock @@ -19,6 +19,23 @@ ethers "3.0.22" lodash "4.17.10" +"@0xproject/abi-gen@^1.0.9": + version "1.0.9" + resolved "https://registry.yarnpkg.com/@0xproject/abi-gen/-/abi-gen-1.0.9.tgz#bc9b1c7c6ab8961340541b8bfe66fb6e512597c6" + dependencies: + "@0xproject/typescript-typings" "^2.0.1" + "@0xproject/utils" "^1.0.9" + chalk "^2.3.0" + ethereum-types "^1.0.7" + glob "^7.1.2" + handlebars "^4.0.11" + lodash "^4.17.5" + mkdirp "^0.5.1" + sleep "^5.1.1" + tmp "^0.0.33" + to-snake-case "^1.0.0" + yargs "^10.0.3" + "@0xproject/assert@^0.2.14": version "0.2.14" resolved "https://registry.yarnpkg.com/@0xproject/assert/-/assert-0.2.14.tgz#7d5a373fedc8eb482716b730f4dddf3ef33bfa29" @@ -217,6 +234,14 @@ "@types/node" "9.6.0" bignumber.js "~4.1.0" +"@0xproject/types@^1.0.2": + version "1.0.2" + resolved "https://registry.yarnpkg.com/@0xproject/types/-/types-1.0.2.tgz#76a7106f6c19b0ed9cde7dc1218dcc4252d3b397" + dependencies: + "@types/node" "*" + bignumber.js "~4.1.0" + ethereum-types "^1.0.7" + "@0xproject/typescript-typings@^0.0.3": version "0.0.3" resolved "http://registry.npmjs.org/@0xproject/typescript-typings/-/typescript-typings-0.0.3.tgz#3272080bde00ade0a970b0d236686b483b08a1d0" @@ -246,6 +271,16 @@ bignumber.js "~4.1.0" ethereum-types "^0.0.2" +"@0xproject/typescript-typings@^2.0.1": + version "2.0.1" + resolved "https://registry.yarnpkg.com/@0xproject/typescript-typings/-/typescript-typings-2.0.1.tgz#328e80d650092a2e1a7b156796a401811b066df6" + dependencies: + "@types/bn.js" "^4.11.0" + "@types/react" "*" + bignumber.js "~4.1.0" + ethereum-types "^1.0.7" + popper.js "1.14.3" + "@0xproject/utils@^0.5.2": version "0.5.2" resolved "https://registry.yarnpkg.com/@0xproject/utils/-/utils-0.5.2.tgz#02ce0a920437db0a15d059e8c6c70fa33e9c3860" @@ -286,6 +321,23 @@ lodash "4.17.10" web3 "0.20.6" +"@0xproject/utils@^1.0.9": + version "1.0.9" + resolved "https://registry.yarnpkg.com/@0xproject/utils/-/utils-1.0.9.tgz#6154f69d5618f4675e9429879b59e6162ee5d985" + dependencies: + "@0xproject/types" "^1.0.2" + "@0xproject/typescript-typings" "^2.0.1" + "@types/node" "*" + abortcontroller-polyfill "^1.1.9" + bignumber.js "~4.1.0" + detect-node "2.0.3" + ethereum-types "^1.0.7" + ethereumjs-util "^5.1.1" + ethers "3.0.22" + isomorphic-fetch "^2.2.1" + js-sha3 "^0.7.0" + lodash "^4.17.5" + "@0xproject/web3-wrapper@^0.6.1": version "0.6.4" resolved "https://registry.yarnpkg.com/@0xproject/web3-wrapper/-/web3-wrapper-0.6.4.tgz#fb15b71cdf4e5001c2b2e0d316b0de485a2be5f8" @@ -1251,6 +1303,12 @@ dependencies: "@types/node" "*" +"@types/bn.js@^4.11.0": + version "4.11.2" + resolved "https://registry.yarnpkg.com/@types/bn.js/-/bn.js-4.11.2.tgz#3179b977b9d18aa81f256cae7556282ee99fd1cc" + dependencies: + "@types/node" "*" + "@types/bull@^3.3.19": version "3.3.20" resolved "https://registry.yarnpkg.com/@types/bull/-/bull-3.3.20.tgz#c61a597def297252419cf16ac4effdfb4d82d9c9" @@ -1268,7 +1326,7 @@ dependencies: "@types/node" "*" -"@types/jest@^23.3.1": +"@types/jest@^23.3.1", "@types/jest@^23.3.2": version "23.3.2" resolved "https://registry.yarnpkg.com/@types/jest/-/jest-23.3.2.tgz#07b90f6adf75d42c34230c026a2529e56c249dbb" @@ -1305,6 +1363,19 @@ version "7.1.30" resolved "https://registry.yarnpkg.com/@types/promise/-/promise-7.1.30.tgz#1b6714b321fdfc54d1527e7a17116a0e1f2ab810" +"@types/prop-types@*": + version "15.5.5" + resolved "https://registry.yarnpkg.com/@types/prop-types/-/prop-types-15.5.5.tgz#17038dd322c2325f5da650a94d5f9974943625e3" + dependencies: + "@types/react" "*" + +"@types/react@*": + version "16.4.14" + resolved "https://registry.yarnpkg.com/@types/react/-/react-16.4.14.tgz#47c604c8e46ed674bbdf4aabf82b34b9041c6a04" + dependencies: + "@types/prop-types" "*" + csstype "^2.2.0" + "@types/require-from-string@^1.2.0": version "1.2.0" resolved "https://registry.yarnpkg.com/@types/require-from-string/-/require-from-string-1.2.0.tgz#c18cfc8a2c1a0259e5841d1fef2b5e9d01c64242" @@ -1620,6 +1691,10 @@ abbrev@1: version "1.1.1" resolved "https://registry.yarnpkg.com/abbrev/-/abbrev-1.1.1.tgz#f8f2c887ad10bf67f634f005b6987fed3179aac8" +abortcontroller-polyfill@^1.1.9: + version "1.1.9" + resolved "https://registry.yarnpkg.com/abortcontroller-polyfill/-/abortcontroller-polyfill-1.1.9.tgz#9fefe359fda2e9e0932dc85e6106453ac393b2da" + abstract-leveldown@0.12.3: version "0.12.3" resolved "https://registry.yarnpkg.com/abstract-leveldown/-/abstract-leveldown-0.12.3.tgz#116b1ec5c7710ef7a2d5706768bbdb4440be1070" @@ -3677,6 +3752,12 @@ browserslist@^4.1.0: electron-to-chromium "^1.3.62" node-releases "^1.0.0-alpha.11" +bs-logger@0.x: + version "0.2.5" + resolved "https://registry.yarnpkg.com/bs-logger/-/bs-logger-0.2.5.tgz#1d82f0cf88864e1341cd9262237f8d0748a49b22" + dependencies: + fast-json-stable-stringify "^2.0.0" + bs58@^2.0.1: version "2.0.1" resolved "https://registry.yarnpkg.com/bs58/-/bs58-2.0.1.tgz#55908d58f1982aba2008fa1bed8f91998a29bf8d" @@ -3719,14 +3800,14 @@ buffer-fill@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/buffer-fill/-/buffer-fill-1.0.0.tgz#f8f78b76789888ef39f205cd637f68e702122b2c" +buffer-from@1.x, buffer-from@^1.0.0, buffer-from@^1.1.0: + version "1.1.1" + resolved "https://registry.yarnpkg.com/buffer-from/-/buffer-from-1.1.1.tgz#32713bc028f75c02fdb710d7c7bcec1f2c6070ef" + buffer-from@^0.1.1: version "0.1.2" resolved "https://registry.yarnpkg.com/buffer-from/-/buffer-from-0.1.2.tgz#15f4b9bcef012044df31142c14333caf6e0260d0" -buffer-from@^1.0.0, buffer-from@^1.1.0: - version "1.1.1" - resolved "https://registry.yarnpkg.com/buffer-from/-/buffer-from-1.1.1.tgz#32713bc028f75c02fdb710d7c7bcec1f2c6070ef" - buffer-indexof@^1.0.0: version "1.1.1" resolved "https://registry.yarnpkg.com/buffer-indexof/-/buffer-indexof-1.1.1.tgz#52fabcc6a606d1a00302802648ef68f639da268c" @@ -5355,6 +5436,10 @@ detect-newline@^2.1.0: version "2.1.0" resolved "https://registry.yarnpkg.com/detect-newline/-/detect-newline-2.1.0.tgz#f41f1c10be4b00e87b5f13da680759f2c5bfd3e2" +detect-node@2.0.3: + version "2.0.3" + resolved "http://registry.npmjs.org/detect-node/-/detect-node-2.0.3.tgz#a2033c09cc8e158d37748fbde7507832bd6ce127" + detect-node@^2.0.3: version "2.0.4" resolved "https://registry.yarnpkg.com/detect-node/-/detect-node-2.0.4.tgz#014ee8f8f669c5c58023da64b8179c083a28c46c" @@ -6307,6 +6392,13 @@ ethereum-types@^0.0.2: "@types/node" "^8.0.53" bignumber.js "~4.1.0" +ethereum-types@^1.0.7: + version "1.0.7" + resolved "https://registry.yarnpkg.com/ethereum-types/-/ethereum-types-1.0.7.tgz#880833ee3dbbf37e9b00cc5c7a635ed91d063992" + dependencies: + "@types/node" "*" + bignumber.js "~4.1.0" + ethereumjs-abi@0.6.5, "ethereumjs-abi@git+https://github.com/ethereumjs/ethereumjs-abi.git": version "0.6.5" resolved "git+https://github.com/ethereumjs/ethereumjs-abi.git#00ba8463a7f7a67fcad737ff9c2ebd95643427f7" @@ -6865,7 +6957,7 @@ fast-json-parse@^1.0.3: version "1.0.3" resolved "https://registry.yarnpkg.com/fast-json-parse/-/fast-json-parse-1.0.3.tgz#43e5c61ee4efa9265633046b770fb682a7577c4d" -fast-json-stable-stringify@^2.0.0: +fast-json-stable-stringify@2.x, fast-json-stable-stringify@^2.0.0: version "2.0.0" resolved "https://registry.yarnpkg.com/fast-json-stable-stringify/-/fast-json-stable-stringify-2.0.0.tgz#d5142c0caee6b1189f87d3a76111064f86c8bbf2" @@ -7774,7 +7866,7 @@ handlebars@4.0.11: optionalDependencies: uglify-js "^2.6" -handlebars@^4.0.2, handlebars@^4.0.3: +handlebars@^4.0.11, handlebars@^4.0.12, handlebars@^4.0.2, handlebars@^4.0.3: version "4.0.12" resolved "https://registry.yarnpkg.com/handlebars/-/handlebars-4.0.12.tgz#2c15c8a96d46da5e266700518ba8cb8d919d5bc5" dependencies: @@ -9522,7 +9614,7 @@ jest@23.4.1: import-local "^1.0.0" jest-cli "^23.4.1" -jest@^23.4.2, jest@^23.5.0: +jest@^23.4.2, jest@^23.5.0, jest@^23.6.0: version "23.6.0" resolved "https://registry.yarnpkg.com/jest/-/jest-23.6.0.tgz#ad5835e923ebf6e19e7a1d7529a432edfee7813d" dependencies: @@ -9731,6 +9823,12 @@ json3@3.3.2, json3@^3.3.2: version "3.3.2" resolved "https://registry.yarnpkg.com/json3/-/json3-3.3.2.tgz#3c0434743df93e2f5c42aee7b19bcb483575f4e1" +json5@2.x: + version "2.0.1" + resolved "https://registry.yarnpkg.com/json5/-/json5-2.0.1.tgz#3d6d0d1066039eb50984e66a7840e4f4b7a2c660" + dependencies: + minimist "^1.2.0" + json5@^0.5.0, json5@^0.5.1: version "0.5.1" resolved "https://registry.yarnpkg.com/json5/-/json5-0.5.1.tgz#1eade7acc012034ad84e2396767ead9fa5495821" @@ -10452,7 +10550,7 @@ make-dir@^1.0.0, make-dir@^1.1.0: dependencies: pify "^3.0.0" -make-error@^1.1.1, make-error@^1.3.4: +make-error@1.x, make-error@^1.1.1, make-error@^1.3.4: version "1.3.5" resolved "https://registry.yarnpkg.com/make-error/-/make-error-1.3.5.tgz#efe4e81f6db28cadd605c70f29c831b58ef776c8" @@ -10900,7 +10998,7 @@ mkdirp-promise@^5.0.1: dependencies: mkdirp "*" -mkdirp@*, mkdirp@0.5.1, mkdirp@0.5.x, "mkdirp@>=0.5 0", mkdirp@^0.5.0, mkdirp@^0.5.1, mkdirp@~0.5.0, mkdirp@~0.5.1: +mkdirp@*, mkdirp@0.5.1, mkdirp@0.5.x, mkdirp@0.x, "mkdirp@>=0.5 0", mkdirp@^0.5.0, mkdirp@^0.5.1, mkdirp@~0.5.0, mkdirp@~0.5.1: version "0.5.1" resolved "http://registry.npmjs.org/mkdirp/-/mkdirp-0.5.1.tgz#30057438eac6cf7f8c4767f38648d6697d75c903" dependencies: @@ -11018,7 +11116,7 @@ nan@2.10.0: version "2.10.0" resolved "https://registry.yarnpkg.com/nan/-/nan-2.10.0.tgz#96d0cd610ebd58d4b4de9cc0c6828cda99c7548f" -nan@^2.0.8, nan@^2.10.0, nan@^2.2.1, nan@^2.3.3, nan@^2.9.2: +nan@>=2.5.1, nan@^2.0.8, nan@^2.10.0, nan@^2.2.1, nan@^2.3.3, nan@^2.9.2: version "2.11.0" resolved "https://registry.yarnpkg.com/nan/-/nan-2.11.0.tgz#574e360e4d954ab16966ec102c0c049fd961a099" @@ -12035,6 +12133,10 @@ pn@^1.1.0: version "1.1.0" resolved "https://registry.yarnpkg.com/pn/-/pn-1.1.0.tgz#e2f4cef0e219f463c179ab37463e4e1ecdccbafb" +popper.js@1.14.3: + version "1.14.3" + resolved "https://registry.yarnpkg.com/popper.js/-/popper.js-1.14.3.tgz#1438f98d046acf7b4d78cd502bf418ac64d4f095" + portfinder@^1.0.9: version "1.0.17" resolved "https://registry.yarnpkg.com/portfinder/-/portfinder-1.0.17.tgz#a8a1691143e46c4735edefcf4fbcccedad26456a" @@ -14158,7 +14260,7 @@ semver-diff@^2.0.0: dependencies: semver "^5.0.3" -"semver@2 || 3 || 4 || 5", semver@^5.0.1, semver@^5.0.3, semver@^5.1.0, semver@^5.3.0, semver@^5.4.1, semver@^5.5.0, semver@^5.5.1: +"semver@2 || 3 || 4 || 5", semver@5.x, semver@^5.0.1, semver@^5.0.3, semver@^5.1.0, semver@^5.3.0, semver@^5.4.1, semver@^5.5.0, semver@^5.5.1: version "5.5.1" resolved "https://registry.yarnpkg.com/semver/-/semver-5.5.1.tgz#7dfdd8814bdb7cabc7be0fb1d734cfb66c940477" @@ -14400,6 +14502,12 @@ slash@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/slash/-/slash-1.0.0.tgz#c41f2f6c39fc16d1cd17ad4b5d896114ae470d55" +sleep@^5.1.1: + version "5.2.3" + resolved "https://registry.yarnpkg.com/sleep/-/sleep-5.2.3.tgz#be8852dd8cf91c8f206d21d681c64754cbceb33c" + dependencies: + nan ">=2.5.1" + slice-ansi@0.0.4: version "0.0.4" resolved "https://registry.yarnpkg.com/slice-ansi/-/slice-ansi-0.0.4.tgz#edbf8903f66f7ce2f8eafd6ceed65e264c831b35" @@ -15459,6 +15567,10 @@ to-fast-properties@^2.0.0: version "2.0.0" resolved "https://registry.yarnpkg.com/to-fast-properties/-/to-fast-properties-2.0.0.tgz#dc5e698cbd079265bc73e0377681a4e4e83f616e" +to-no-case@^1.0.0: + version "1.0.2" + resolved "https://registry.yarnpkg.com/to-no-case/-/to-no-case-1.0.2.tgz#c722907164ef6b178132c8e69930212d1b4aa16a" + to-object-path@^0.3.0: version "0.3.0" resolved "https://registry.yarnpkg.com/to-object-path/-/to-object-path-0.3.0.tgz#297588b7b0e7e0ac08e04e672f85c1f4999e17af" @@ -15481,6 +15593,18 @@ to-regex@^3.0.1, to-regex@^3.0.2: regex-not "^1.0.2" safe-regex "^1.1.0" +to-snake-case@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/to-snake-case/-/to-snake-case-1.0.0.tgz#ce746913897946019a87e62edfaeaea4c608ab8c" + dependencies: + to-space-case "^1.0.0" + +to-space-case@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/to-space-case/-/to-space-case-1.0.0.tgz#b052daafb1b2b29dc770cea0163e5ec0ebc9fc17" + dependencies: + to-no-case "^1.0.0" + toposort@^1.0.0: version "1.0.7" resolved "https://registry.yarnpkg.com/toposort/-/toposort-1.0.7.tgz#2e68442d9f64ec720b8cc89e6443ac6caa950029" @@ -15555,6 +15679,19 @@ ts-jest@^23.1.3, ts-jest@^23.1.4: json5 "^0.5.0" lodash "^4.17.10" +ts-jest@^23.10.1: + version "23.10.1" + resolved "https://registry.yarnpkg.com/ts-jest/-/ts-jest-23.10.1.tgz#ad0196f7b81f08888897004d9ed870c1a901511a" + dependencies: + bs-logger "0.x" + buffer-from "1.x" + fast-json-stable-stringify "2.x" + json5 "2.x" + make-error "1.x" + mkdirp "0.x" + semver "5.x" + yargs-parser "10.x" + ts-loader@^4.5.0: version "4.5.0" resolved "https://registry.yarnpkg.com/ts-loader/-/ts-loader-4.5.0.tgz#a1ce70b2dc799941fb2197605f0d67874097859b" @@ -16867,17 +17004,7 @@ web3@1.0.0-beta.35: web3-shh "1.0.0-beta.35" web3-utils "1.0.0-beta.35" -web3@^0.20.0: - version "0.20.7" - resolved "https://registry.yarnpkg.com/web3/-/web3-0.20.7.tgz#1605e6d81399ed6f85a471a4f3da0c8be57df2f7" - dependencies: - bignumber.js "git+https://github.com/frozeman/bignumber.js-nolookahead.git" - crypto-js "^3.1.4" - utf8 "^2.1.1" - xhr2-cookies "^1.1.0" - xmlhttprequest "*" - -web3@^1.0.0-beta.33, web3@^1.0.0-beta.34: +web3@1.0.0-beta.36, web3@^1.0.0-beta.33, web3@^1.0.0-beta.34: version "1.0.0-beta.36" resolved "https://registry.yarnpkg.com/web3/-/web3-1.0.0-beta.36.tgz#2954da9e431124c88396025510d840ba731c8373" dependencies: @@ -16889,6 +17016,16 @@ web3@^1.0.0-beta.33, web3@^1.0.0-beta.34: web3-shh "1.0.0-beta.36" web3-utils "1.0.0-beta.36" +web3@^0.20.0: + version "0.20.7" + resolved "https://registry.yarnpkg.com/web3/-/web3-0.20.7.tgz#1605e6d81399ed6f85a471a4f3da0c8be57df2f7" + dependencies: + bignumber.js "git+https://github.com/frozeman/bignumber.js-nolookahead.git" + crypto-js "^3.1.4" + utf8 "^2.1.1" + xhr2-cookies "^1.1.0" + xmlhttprequest "*" + webidl-conversions@^4.0.2: version "4.0.2" resolved "https://registry.yarnpkg.com/webidl-conversions/-/webidl-conversions-4.0.2.tgz#a855980b1f0b6b359ba1d5d9fb39ae941faa63ad" @@ -17425,7 +17562,7 @@ yallist@^3.0.0, yallist@^3.0.2: version "3.0.2" resolved "https://registry.yarnpkg.com/yallist/-/yallist-3.0.2.tgz#8452b4bb7e83c7c188d8041c1a837c773d6d8bb9" -yargs-parser@^10.0.0, yargs-parser@^10.1.0: +yargs-parser@10.x, yargs-parser@^10.0.0, yargs-parser@^10.1.0: version "10.1.0" resolved "https://registry.yarnpkg.com/yargs-parser/-/yargs-parser-10.1.0.tgz#7202265b89f7e9e9f2e5765e0fe735a905edbaa8" dependencies: From 9aedbc70436e2fa4085f9e9dd7fbae0027305d22 Mon Sep 17 00:00:00 2001 From: Federico Obialero Date: Thu, 27 Sep 2018 12:51:58 +0200 Subject: [PATCH 3/8] Events Support (#451) * added getPastEvents method * added allEvents function * added once, missing test * modified event partial * fixed event partial * now only contracts with events extend the baseContract * fixed unit tests * fixed return types of txFunctions * removed test file, minor refactor --- packages/api/.gitignore | 2 +- packages/api/package.json | 8 +- packages/api/partials/event.handlebars | 9 +- packages/api/partials/txFunction.handlebars | 2 +- packages/api/partials/typed_params.handlebars | 2 +- packages/api/src/baseContract.ts | 46 ++++- packages/api/template.handlebars | 37 ++-- packages/api/test/contracts.test.ts | 191 +++++++++++++----- packages/api/tsconfig.json | 3 +- yarn.lock | 16 +- 10 files changed, 234 insertions(+), 82 deletions(-) diff --git a/packages/api/.gitignore b/packages/api/.gitignore index 1ab3d818d..7f31e16d5 100644 --- a/packages/api/.gitignore +++ b/packages/api/.gitignore @@ -1,6 +1,6 @@ coverage .tmp -src/generated +src/contracts/models dist lib node_modules diff --git a/packages/api/package.json b/packages/api/package.json index 2f96c0e12..55e36d388 100644 --- a/packages/api/package.json +++ b/packages/api/package.json @@ -12,8 +12,12 @@ "tsc": "rm -rf dist/* && tsc --outDir './dist'", "test": "jest", "tsc:watch": "rm -rf dist; tsc -w --outDir './dist'", + "ganache": "npx ganache-cli -p 8545 -i 5777 -m \"${npm_package_config_mnemonic}\"", "lint": "eslint src --ext ts --ignore-path .gitignore --fix", - "abi-gen": "node src/abi-extractor.js && rm -rf src/generated && ts-node abi-gen.ts --abis './.tmp/*.json' -o src/generated --template './template.handlebars' --partials './partials/*.handlebars'" + "abi-gen": "rm -rf src/contracts/models && ts-node abi-gen.ts --abis './.tmp/*.json' -o src/contracts/models --template './template.handlebars' --partials './partials/*.handlebars'" + }, + "config": { + "mnemonic": "lemon scrub wasp bracket town boat property sadness layer taxi butter audit" }, "files": [ "dist" @@ -21,6 +25,7 @@ "devDependencies": { "@0xproject/abi-gen": "^1.0.9", "@types/jest": "^23.3.2", + "@types/web3": "^1.0.6", "bignumber.js": "^7.2.1", "chalk": "^2.4.1", "eslint-plugin-typescript": "^0.12.0", @@ -36,6 +41,7 @@ "@rigoblock/contracts": "^0.3.2", "@types/node": "^9.6.6", "bignumber.js": "^5.0.0", + "ganache-cli": "7.0.0-beta.0", "handlebars": "^4.0.12", "typechain": "^0.2.2", "web3": "1.0.0-beta.36", diff --git a/packages/api/partials/event.handlebars b/packages/api/partials/event.handlebars index 61d523ca2..4d89e4ebb 100644 --- a/packages/api/partials/event.handlebars +++ b/packages/api/partials/event.handlebars @@ -1,5 +1,6 @@ -export interface {{@root.contractName}}{{name}}EventArgs extends DecodedLogArgs { - {{#each inputs}} - {{name}}: {{#returnType type components}}{{/returnType}}; - {{/each}} +public {{this.name}}Event( + options?: EventOptions, + cb?: Function +) { + return this.rawWeb3Contract.events.{{this.name}}(options || {}, cb) } diff --git a/packages/api/partials/txFunction.handlebars b/packages/api/partials/txFunction.handlebars index 514a7e1d2..cbc68026e 100644 --- a/packages/api/partials/txFunction.handlebars +++ b/packages/api/partials/txFunction.handlebars @@ -1,3 +1,3 @@ -public async {{this.tsName}}({{> typed_params inputs=inputs}}): Promise<{{> return_type outputs=outputs}}> { +public async {{this.tsName}}({{> typed_params inputs=inputs}}): Promise return_type outputs=outputs}}>> { return this.rawWeb3Contract.methods.{{this.tsName}}({{> params inputs=inputs}}) } diff --git a/packages/api/partials/typed_params.handlebars b/packages/api/partials/typed_params.handlebars index c100e58f7..e4423c5f9 100644 --- a/packages/api/partials/typed_params.handlebars +++ b/packages/api/partials/typed_params.handlebars @@ -1,3 +1,3 @@ {{#each inputs}} - {{name}}: {{#parameterType type components}}{{/parameterType}}, +{{name}}: {{#parameterType type components}}{{/parameterType}}{{#if @last}}{{else}},{{/if}} {{/each}} diff --git a/packages/api/src/baseContract.ts b/packages/api/src/baseContract.ts index adb71bee3..cbdbbd7d6 100644 --- a/packages/api/src/baseContract.ts +++ b/packages/api/src/baseContract.ts @@ -1,6 +1,44 @@ -export default class BaseContract { - public readonly rawWeb3Contract: any - constructor(web3: any, address: string, abi: any) { - this.rawWeb3Contract = new web3.eth.Contract(abi, address) +import { EventEmitter, EventLog } from 'web3/types' + +export interface TransactionObject { + call + send + encodeABI + estimateGas +} +export interface EventFilter { + [key: string]: string +} + +export interface EventOptions { + filter?: EventFilter + fromBlock?: number + toBlock?: number | 'latest' + topics?: string[] +} + +export default class BaseContract { + public rawWeb3Contract: any + + public getPastEvents( + eventName: Events, + options?: EventOptions + ): Promise { + return this.rawWeb3Contract.getPastEvents(eventName, options || {}) + } + + public allEvents( + options?: EventOptions, + cb?: Function + ): Promise { + return this.rawWeb3Contract.events.allEvents(options || {}, cb) + } + + public once( + eventName: Events, + options?: EventOptions, + cb?: Function + ): Promise { + return this.rawWeb3Contract.once(eventName, options || {}, cb) } } diff --git a/packages/api/template.handlebars b/packages/api/template.handlebars index 8819e6511..0366ca550 100644 --- a/packages/api/template.handlebars +++ b/packages/api/template.handlebars @@ -1,29 +1,28 @@ /* eslint-disable */ import { BigNumber } from 'bignumber.js' -import BaseContract from '../baseContract' - -{{!-- TODO: add events --}} -{{!-- {{#if events}} -export type {{contractName}}EventArgs = -{{#each events}} - | {{@root.contractName}}{{name}}EventArgs{{#if @last}};{{/if}} -{{/each}} +import BaseContract, { EventOptions } from '../../baseContract' +import { TransactionObject } from 'web3/eth/types' +{{#if events}} export enum {{contractName}}Events { {{#each events}} {{name}} = '{{name}}', {{/each}} } +{{/if}} + +{{#if events}} +export class {{contractName}} extends BaseContract<{{contractName}}Events> { + public constructor(web3: any, address: string) { + super() +{{else}} +export class {{contractName}} { + public rawWeb3Contract: any + public constructor(web3: any, address: string) { +{{/if}} -{{#each events}} -{{> event}} - -{{/each}} -{{/if}} --}} -export class {{contractName}} extends BaseContract { - public constructor(web3: any, address: string) { const abi = {{{getAbi ctor events methods}}} - super(web3, address, abi); + this.rawWeb3Contract = new web3.eth.Contract(abi, address) } static async createAndValidate( @@ -42,6 +41,7 @@ export class {{contractName}} extends BaseContract { } public static address: string + {{#each methods}} {{#this.constant}} {{> constantFunction contractName=../contractName}} @@ -50,6 +50,11 @@ export class {{contractName}} extends BaseContract { {{> txFunction contractName=../contractName}} {{/this.constant}} {{/each}} + {{#if events}} + {{#each events}} + {{> event contractName=../contractName}} + {{/each}} + {{/if}} static isDeployed() { return !!this.address diff --git a/packages/api/test/contracts.test.ts b/packages/api/test/contracts.test.ts index cc360159e..169f70e23 100644 --- a/packages/api/test/contracts.test.ts +++ b/packages/api/test/contracts.test.ts @@ -1,6 +1,9 @@ import Web3 = require('web3') -import { Vault } from '../src/generated/vault' -import { VaultFactory } from '../src/generated/vault_factory' +import { Vault } from '../src/contracts/models/vault' +import { + VaultFactory, + VaultFactoryEvents +} from '../src/contracts/models/vault_factory' describe('generated contract', () => { let web3 @@ -8,7 +11,7 @@ describe('generated contract', () => { let accounts let txOptions beforeAll(async () => { - web3 = new Web3(new Web3.providers.HttpProvider('http://localhost:8545')) + web3 = new Web3(new Web3.providers.WebsocketProvider('ws://localhost:8545')) accounts = await web3.eth.getAccounts() extendedExpect = expect as any }) @@ -32,60 +35,146 @@ describe('generated contract', () => { '0x7ce6e371085cb611fb46d5065397223ef2f952ff' ) }) - it('constant method', async () => { - const registry = '0xf7cBB0849d4a8ec5aB4650030FA776c00Eb52dA7' - const res = await vaultFactory.getRegistry() - expect(res).toEqual(registry) + describe('constant methods', () => { + it('reads a constant property of the contract from the blockChain ', async () => { + const registry = '0xf7cBB0849d4a8ec5aB4650030FA776c00Eb52dA7' + const res = await vaultFactory.getRegistry() + expect(res).toEqual(registry) + }) }) - it('createVault', async () => { - const vaultName = Math.random() - .toString(36) - .substring(2, 7) - const vaultOptions = [vaultName, 'ASD'] - const gasPrice = await web3.eth.getGasPrice() - const gasEstimate = await vaultFactory // 2538415 - .createVault(...vaultOptions) - .then(obj => obj.estimateGas(txOptions)) - const receipt = await vaultFactory - .createVault(...vaultOptions) - .then(obj => - // adding value to gas estimate as it is not always correct - obj.send({ ...txOptions, gasPrice, gas: gasEstimate + 5000 }) - ) - extendedExpect(receipt.transactionHash).toBeHash() + describe('non constant methods', () => { + describe('non payable methods', () => { + it("writes to the blockChain, but doesn't accept ether", async () => { + const vaultName = Math.random() + .toString(36) + .substring(2, 7) + const vaultOptions = [vaultName, 'ASD'] + const gasPrice = await web3.eth.getGasPrice() + const gasEstimate = await vaultFactory // 2538415 + .createVault(...vaultOptions) + .then(obj => { + return obj.estimateGas(txOptions) + }) + const receipt = await vaultFactory + .createVault(...vaultOptions) + .then(obj => + // adding value to gas estimate as it is not always correct + obj.send({ ...txOptions, gasPrice, gas: gasEstimate + 5000 }) + ) + + extendedExpect(receipt.transactionHash).toBeHash() + }) + }) + describe('payable methods', async () => { + let vaultInstance + beforeAll(async () => { + const vaultName = Math.random() + .toString(36) + .substring(2, 7) + const vaultOptions = [vaultName, 'VLT'] + const gasPrice = await web3.eth.getGasPrice() + const gasEstimate = await vaultFactory + .createVault(...vaultOptions) + .then(obj => obj.estimateGas(txOptions)) + const receipt = await vaultFactory + .createVault(...vaultOptions) + .then(obj => + // adding value to gas estimate as it is not always correct + obj.send({ ...txOptions, gasPrice, gas: gasEstimate + 5000 }) + ) + const vaultAddress = receipt.events.VaultCreated.returnValues.vault + vaultInstance = await Vault.createAndValidate(web3, vaultAddress) + }) + it('accepts an ether value', async () => { + const options = { ...txOptions, value: web3.utils.toWei('1') } + const gasPrice = await web3.eth.getGasPrice() + const gasEstimate = await vaultInstance + .buyVault() + .then(obj => obj.estimateGas(options)) + await vaultInstance + .buyVault() + .then(obj => + obj.send({ ...options, gasPrice, gas: gasEstimate + 5000 }) + ) + }) + }) + }) + }) + describe('contract events', () => { + describe('getPastEvents', () => { + it('returns past logs for the specified event', async () => { + const vaultFactory = await VaultFactory.createAndValidate( + web3, + '0x7ce6e371085cb611fb46d5065397223ef2f952ff' + ) + const eventLog = await vaultFactory.getPastEvents( + VaultFactoryEvents.VaultCreated, + { fromBlock: 0, toBlock: 'latest' } + ) + expect(Array.isArray(eventLog)).toBe(true) + }) }) - describe('payable methods', async () => { - let vaultInstance - beforeAll(async () => { - const vaultName = Math.random() - .toString(36) - .substring(2, 7) - const vaultOptions = [vaultName, 'VLT'] - const gasPrice = await web3.eth.getGasPrice() - const gasEstimate = await vaultFactory - .createVault(...vaultOptions) - .then(obj => obj.estimateGas(txOptions)) - const receipt = await vaultFactory - .createVault(...vaultOptions) - .then(obj => - // adding value to gas estimate as it is not always correct - obj.send({ ...txOptions, gasPrice, gas: gasEstimate + 5000 }) + describe('websocket events', () => { + const allEventsSpy = jest.fn() + const onceSpy = jest.fn() + const VaultCreatedSpy = jest.fn() + const filterOptions = { + fromBlock: 0, + toBlock: 'latest' + } + const filterCallback = (err, event) => + err ? console.error(err) : console.log(event) + + class ContractMock { + public once(...args) { + return onceSpy(...args) + } + public events = { + allEvents: allEventsSpy, + VaultCreated: VaultCreatedSpy + } + } + const Web3Mock = { + eth: { + getCode: () => Promise.resolve('0x12345'), + Contract: ContractMock + } + } + let mockedVaultFactory + beforeEach(async () => { + const VaultFactory = require('../src/contracts/models/vault_factory') + .VaultFactory + + mockedVaultFactory = await VaultFactory.createAndValidate( + Web3Mock, + '0x7ce6e371085cb611fb46d5065397223ef2f952ff' + ) + }) + describe('allEvents', () => { + it('calls the web3 allEvents method with the specified options', async () => { + await mockedVaultFactory.allEvents(filterOptions, filterCallback) + expect(allEventsSpy).toHaveBeenCalledWith( + filterOptions, + filterCallback ) - const vaultAddress = receipt.events.VaultCreated.returnValues.vault - vaultInstance = await Vault.createAndValidate(web3, vaultAddress) + }) + }) + describe('once', () => { + it('calls the web3 once function with specified options', async () => { + const options = ['VaultCreated', filterOptions, filterCallback] + await mockedVaultFactory.once(...options) + expect(onceSpy).toHaveBeenCalledWith(...options) + }) }) - it('buyVault', async () => { - const options = { ...txOptions, value: web3.utils.toWei('1') } - const gasPrice = await web3.eth.getGasPrice() - const gasEstimate = await vaultInstance - .buyVault() - .then(obj => obj.estimateGas(options)) - await vaultInstance - .buyVault() - .then(obj => - obj.send({ ...options, gasPrice, gas: gasEstimate + 5000 }) + describe('contract event', () => { + it('calls the web3 event function to subscribe to a specific event', async () => { + await mockedVaultFactory.VaultCreatedEvent(filterOptions) + expect(VaultCreatedSpy).toHaveBeenCalledWith( + filterOptions, + undefined // callback is optional ) + }) }) }) }) diff --git a/packages/api/tsconfig.json b/packages/api/tsconfig.json index 77cc0ce8b..9023efc9d 100644 --- a/packages/api/tsconfig.json +++ b/packages/api/tsconfig.json @@ -9,7 +9,6 @@ "noImplicitReturns": true, "declaration": true, "sourceMap": true, - "pretty": true, - "typeRoots": ["node_modules/@0xproject/typescript-typings/types", "node_modules/@types"], + "pretty": true } } diff --git a/yarn.lock b/yarn.lock index f82297381..c9ef1ebb6 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1395,6 +1395,13 @@ "@types/bn.js" "*" "@types/underscore" "*" +"@types/web3@^1.0.6": + version "1.0.6" + resolved "https://registry.yarnpkg.com/@types/web3/-/web3-1.0.6.tgz#ea6bd4591a59efa73c3399b2bf172a268630edbf" + dependencies: + "@types/bn.js" "*" + "@types/underscore" "*" + "@types/yargs@10.0.2": version "10.0.2" resolved "https://registry.yarnpkg.com/@types/yargs/-/yargs-10.0.2.tgz#cc4ea921877874d1261e2c44b89807bc836e1b12" @@ -7400,6 +7407,13 @@ fuse.js@^3.0.1, fuse.js@^3.2.0: version "3.2.1" resolved "https://registry.yarnpkg.com/fuse.js/-/fuse.js-3.2.1.tgz#6320cb94ce56ec9755c89ade775bcdbb0358d425" +ganache-cli@7.0.0-beta.0: + version "7.0.0-beta.0" + resolved "https://registry.yarnpkg.com/ganache-cli/-/ganache-cli-7.0.0-beta.0.tgz#9454567d731bd8f0b582e40473f2f44a16f109b3" + dependencies: + source-map-support "^0.5.0" + webpack "^3.10.0" + ganache-cli@^6.1.0: version "6.1.8" resolved "https://registry.yarnpkg.com/ganache-cli/-/ganache-cli-6.1.8.tgz#49a8a331683a9652183f82ef1378d17e1814fcd3" @@ -17200,7 +17214,7 @@ webpack@4.16.1: watchpack "^1.5.0" webpack-sources "^1.0.1" -webpack@^3.11.0: +webpack@^3.10.0, webpack@^3.11.0: version "3.12.0" resolved "https://registry.yarnpkg.com/webpack/-/webpack-3.12.0.tgz#3f9e34360370602fcf639e97939db486f4ec0d74" dependencies: From f145f698a3e25590f11275a188d7275d4ea33485 Mon Sep 17 00:00:00 2001 From: Federico Obialero Date: Thu, 27 Sep 2018 18:58:01 +0200 Subject: [PATCH 4/8] Fix API build process (#453) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * initial commit 🌅 * minor fixes * removed unused dependencies * restored build-api circleci step * fix to package.json * minor fixes * removed extra web3 instance * fixed build script --- .circleci/config.yml | 6 +- packages/api/.eslintrc | 5 + packages/api/package.json | 19 +- packages/api/src/api.ts | 34 +- .../api/src/contracts/contract-extension.ts | 7 - packages/api/src/contracts/contract.ts | 19 +- packages/api/src/contracts/index.ts | 80 ++-- yarn.lock | 386 ++++++++++++------ 8 files changed, 340 insertions(+), 216 deletions(-) delete mode 100644 packages/api/src/contracts/contract-extension.ts diff --git a/.circleci/config.yml b/.circleci/config.yml index 122d1c22f..9ac9aa287 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -389,9 +389,9 @@ workflows: - test-contracts: requires: - build-contracts - # - build-api: - # requires: - # - build-contracts + - build-api: + requires: + - build-contracts # - build-dapp: # requires: # - build-api diff --git a/packages/api/.eslintrc b/packages/api/.eslintrc index ba62f5ea0..0919aa61d 100644 --- a/packages/api/.eslintrc +++ b/packages/api/.eslintrc @@ -13,5 +13,10 @@ "parser": "typescript" } ] + }, + "parserOptions": { + "ecmaFeatures": { + "jsx": false + } } } diff --git a/packages/api/package.json b/packages/api/package.json index 55e36d388..9d99015b4 100644 --- a/packages/api/package.json +++ b/packages/api/package.json @@ -8,13 +8,14 @@ "node": ">=6.4" }, "scripts": { - "build": "npm run typechain && npm run tsc", + "build": "npm run abi-gen && npm run tsc", "tsc": "rm -rf dist/* && tsc --outDir './dist'", + "tsc:watch" : "rm -rf dist; tsc -w --outDir './dist'", "test": "jest", - "tsc:watch": "rm -rf dist; tsc -w --outDir './dist'", "ganache": "npx ganache-cli -p 8545 -i 5777 -m \"${npm_package_config_mnemonic}\"", "lint": "eslint src --ext ts --ignore-path .gitignore --fix", - "abi-gen": "rm -rf src/contracts/models && ts-node abi-gen.ts --abis './.tmp/*.json' -o src/contracts/models --template './template.handlebars' --partials './partials/*.handlebars'" + "abi-gen": "npm run abi-extract && rm -rf src/contracts/models && ts-node abi-gen.ts --abis './.tmp/*.json' -o src/contracts/models --template './template.handlebars' --partials './partials/*.handlebars'", + "abi-extract": "rm -rf .tmp && node src/abi-extractor.js" }, "config": { "mnemonic": "lemon scrub wasp bracket town boat property sadness layer taxi butter audit" @@ -30,22 +31,20 @@ "chalk": "^2.4.1", "eslint-plugin-typescript": "^0.12.0", "jest": "^23.6.0", + "to-snake-case": "^1.0.0", "ts-jest": "^23.10.1", "typescript": "^3.0.1", "typescript-eslint-parser": "^18.0.0" }, "dependencies": { - "@0xproject/subproviders": "^0.10.4", - "@0xproject/typescript-typings": "^0.4.1", - "@0xproject/web3-wrapper": "^0.7.1", + "@0xproject/subproviders": "^2.0.5", "@rigoblock/contracts": "^0.3.2", - "@types/node": "^9.6.6", - "bignumber.js": "^5.0.0", + "@types/node": "^10.11.0", + "bignumber.js": "^7.2.1", "ganache-cli": "7.0.0-beta.0", "handlebars": "^4.0.12", - "typechain": "^0.2.2", "web3": "1.0.0-beta.36", - "web3-provider-engine": "^14.0.5" + "web3-provider-engine": "^14.0.6" }, "jest": { "setupTestFrameworkScriptFile": "/test/setupTests.ts", diff --git a/packages/api/src/api.ts b/packages/api/src/api.ts index 018d4d700..a39482655 100644 --- a/packages/api/src/api.ts +++ b/packages/api/src/api.ts @@ -1,10 +1,9 @@ +import Web3 = require('web3') import ProviderEngine = require('web3-provider-engine') import * as Contract from './contracts/contract' import * as RpcSubprovider from 'web3-provider-engine/subproviders/rpc.js' -import * as Web3 from 'web3' import { ContractModels } from './contracts' -import { InjectedWeb3Subprovider } from '@0xproject/subproviders' -import { Web3Wrapper } from '@0xproject/web3-wrapper' +import { SignerSubprovider } from '@0xproject/subproviders' import fetchContracts from '@rigoblock/contracts' interface Web3Window extends Window { @@ -13,14 +12,10 @@ interface Web3Window extends Window { declare let window: Web3Window -// Fix until 0x types are in sync with provider engine -export interface ProviderEngineFix extends ProviderEngine { - start(cb?: Function): void -} class Api { public contract: ContractModels - public web3: Web3Wrapper - public engine: ProviderEngineFix + public web3: Web3 + public engine: ProviderEngine async startEngine() { return new Promise((resolve, reject) => { @@ -28,29 +23,22 @@ class Api { }) } - async init(web3: Web3 = window.web3) { + async init(web3: Web3 = window.web3, rpcUrl = 'http://localhost:8545') { this.engine = new ProviderEngine() - this.engine.addProvider(new InjectedWeb3Subprovider(web3.currentProvider)) + this.engine.addProvider(new SignerSubprovider(web3.currentProvider)) this.engine.addProvider( new RpcSubprovider({ - rpcUrl: 'http://localhost:8545' + rpcUrl }) ) - - this.web3 = new Web3Wrapper(this.engine) - - const networkId = await new Promise((resolve, reject) => - web3.version.getNetwork( - (err, networkId) => (err ? reject(err) : resolve(networkId)) - ) - ) - + this.web3 = new Web3(this.engine) + const networkId = await this.web3.eth.net.getId() const contractsMap: Contract.ContractsMap = await fetchContracts(networkId) const contracts = new Contract() - await contracts.init(web3, contractsMap) + await contracts.init(contractsMap) this.contract = contracts - await this.startEngine() + await this.startEngine().catch(err => console.error(err)) return this } diff --git a/packages/api/src/contracts/contract-extension.ts b/packages/api/src/contracts/contract-extension.ts deleted file mode 100644 index 3a5ca52d1..000000000 --- a/packages/api/src/contracts/contract-extension.ts +++ /dev/null @@ -1,7 +0,0 @@ -export abstract class ContractExtension { - public static address: string - - static isDeployed() { - return !!this.address - } -} diff --git a/packages/api/src/contracts/contract.ts b/packages/api/src/contracts/contract.ts index 7bfd3286c..c2073b053 100644 --- a/packages/api/src/contracts/contract.ts +++ b/packages/api/src/contracts/contract.ts @@ -1,21 +1,16 @@ -import * as Web3 from 'web3' -import { ContractExtension } from './contract-extension' +import toSnakeCase = require('to-snake-case') import { ContractModels } from './' -import { TypeChainContract } from './models/typechain-runtime' +import Web3Contract from 'web3/eth/contract' -// abi-gen support class Contract extends ContractModels { - async init(web3: Web3, contractsMap: Contract.ContractsMap) { + async init(contractsMap: Contract.ContractsMap) { const contractNames: string[] = Object.keys(contractsMap) const contractsPromises: Promise< - [string, TypeChainContract][] + [string, Web3Contract][] >[] = contractNames.map(async contractName => { - const contract: TypeChainContract = await import(`./models/${contractName}`) - Object.assign(contract[contractName], ContractExtension) - Object.assign( - contract[contractName].prototype, - ContractExtension.prototype - ) + const contract: Web3Contract = await import(`./models/${toSnakeCase( + contractName + )}`) if (contractsMap[contractName].address) { contract[contractName].address = contractsMap[contractName].address } diff --git a/packages/api/src/contracts/index.ts b/packages/api/src/contracts/index.ts index cf8401668..7b96a1451 100644 --- a/packages/api/src/contracts/index.ts +++ b/packages/api/src/contracts/index.ts @@ -1,51 +1,41 @@ -import { Authority } from './models/Authority' -import { Distribution } from './models/Distribution' -import { Drago } from './models/Drago' -import { DragoEventful } from './models/DragoEventful' -import { DragoFactory } from './models/DragoFactory' -import { DragoRegistry } from './models/DragoRegistry' -import { ERC20 } from './models/ERC20' -import { Inflation } from './models/Inflation' -import { Migrations } from './models/Migrations' -import { Owned } from './models/Owned' -import { OwnedUninitialized } from './models/OwnedUninitialized' -import { ProofOfPerformance } from './models/ProofOfPerformance' -import { RigoToken } from './models/RigoToken' -import { UnlimitedAllowanceToken } from './models/UnlimitedAllowanceToken' -import { Vault } from './models/Vault' -import { VaultEventful } from './models/VaultEventful' -import { VaultFactory } from './models/VaultFactory' - -// Custom extension -import { ContractExtension } from './contract-extension' - -export type EnhancedContract = T & typeof ContractExtension +import { Authority } from './models/authority' +import { Distribution } from './models/distribution' +import { Drago } from './models/drago' +import { DragoEventful } from './models/drago_eventful' +import { DragoFactory } from './models/drago_factory' +import { DragoRegistry } from './models/drago_registry' +import { ERC20 } from './models/erc20' +import { Inflation } from './models/inflation' +import { Migrations } from './models/migrations' +import { Owned } from './models/owned' +import { OwnedUninitialized } from './models/owned_uninitialized' +import { ProofOfPerformance } from './models/proof_of_performance' +import { RigoToken } from './models/rigo_token' +import { UnlimitedAllowanceToken } from './models/unlimited_allowance_token' +import { Vault } from './models/vault' +import { VaultEventful } from './models/vault_eventful' +import { VaultFactory } from './models/vault_factory' // typeof Authority & Authority = needed to expose all static methods and // instance methods of the Authority contract export abstract class ContractModels { - Authority: EnhancedContract - ERC20: EnhancedContract - RigoToken: EnhancedContract - Distribution: EnhancedContract - Inflation: EnhancedContract - UnlimitedAllowanceToken: EnhancedContract< - typeof UnlimitedAllowanceToken & UnlimitedAllowanceToken - > - Drago: EnhancedContract - Migrations: EnhancedContract - Vault: EnhancedContract - DragoEventful: EnhancedContract - Owned: EnhancedContract - VaultEventful: EnhancedContract - DragoFactory: EnhancedContract - OwnedUninitialized: EnhancedContract< - typeof OwnedUninitialized & OwnedUninitialized - > - VaultFactory: EnhancedContract - DragoRegistry: EnhancedContract - ProofOfPerformance: EnhancedContract< - typeof ProofOfPerformance & ProofOfPerformance - > + Authority: typeof Authority & Authority + ERC20: typeof ERC20 & ERC20 + RigoToken: typeof RigoToken & RigoToken + Distribution: typeof Distribution & Distribution + Inflation: typeof Inflation & Inflation + UnlimitedAllowanceToken: typeof UnlimitedAllowanceToken & + UnlimitedAllowanceToken + Drago: typeof Drago & Drago + Migrations: typeof Migrations & Migrations + Vault: typeof Vault & Vault + DragoEventful: typeof DragoEventful & DragoEventful + Owned: typeof Owned & Owned + VaultEventful: typeof VaultEventful & VaultEventful + DragoFactory: typeof DragoFactory & DragoFactory + OwnedUninitialized: typeof OwnedUninitialized & OwnedUninitialized + VaultFactory: typeof VaultFactory & VaultFactory + DragoRegistry: typeof DragoRegistry & DragoRegistry + ProofOfPerformance: typeof ProofOfPerformance & ProofOfPerformance } diff --git a/yarn.lock b/yarn.lock index c9ef1ebb6..0973fa072 100644 --- a/yarn.lock +++ b/yarn.lock @@ -46,6 +46,16 @@ lodash "4.17.10" valid-url "1.0.9" +"@0xproject/assert@^1.0.11": + version "1.0.11" + resolved "https://registry.yarnpkg.com/@0xproject/assert/-/assert-1.0.11.tgz#11d218e96baefa2d41d2412ee3aa9848a5674dcd" + dependencies: + "@0xproject/json-schemas" "^1.0.4" + "@0xproject/typescript-typings" "^2.0.2" + "@0xproject/utils" "^1.0.11" + lodash "^4.17.5" + valid-url "^1.0.9" + "@0xproject/base-contract@^0.3.6": version "0.3.6" resolved "https://registry.yarnpkg.com/@0xproject/base-contract/-/base-contract-0.3.6.tgz#c6d742ce2904bdd9e77524d99ba2438d3aae8a40" @@ -109,6 +119,15 @@ jsonschema "1.2.2" lodash.values "4.3.0" +"@0xproject/json-schemas@^1.0.4": + version "1.0.4" + resolved "https://registry.yarnpkg.com/@0xproject/json-schemas/-/json-schemas-1.0.4.tgz#d8865e138553d46e373783877b9c621b83762ef6" + dependencies: + "@0xproject/typescript-typings" "^2.0.2" + "@types/node" "*" + jsonschema "^1.2.0" + lodash.values "^4.3.0" + "@0xproject/order-utils@^0.0.9": version "0.0.9" resolved "https://registry.yarnpkg.com/@0xproject/order-utils/-/order-utils-0.0.9.tgz#75225dfbd87335d18810abf995d8e077b9a84868" @@ -184,28 +203,34 @@ "@0xproject/typescript-typings" "^0.0.3" lodash "4.17.10" -"@0xproject/subproviders@^0.10.4": - version "0.10.6" - resolved "https://registry.yarnpkg.com/@0xproject/subproviders/-/subproviders-0.10.6.tgz#383a9bb96c661148b6f4541fb553c79c787983e1" - dependencies: - "@0xproject/assert" "^0.2.14" - "@0xproject/types" "^0.8.2" - "@0xproject/typescript-typings" "^0.4.3" - "@0xproject/utils" "^0.7.3" - "@ledgerhq/hw-app-eth" "4.7.3" - "@ledgerhq/hw-transport-u2f" "4.7.3" - bip39 "2.5.0" - bn.js "4.11.7" - ethereumjs-tx "1.3.4" - ethereumjs-util "5.1.5" - ganache-core "0xProject/ganache-core" - hdkey "0.7.1" - lodash "4.17.10" - semaphore-async-await "1.5.1" - web3 "0.20.6" +"@0xproject/subproviders@^2.0.5": + version "2.0.5" + resolved "https://registry.yarnpkg.com/@0xproject/subproviders/-/subproviders-2.0.5.tgz#79c6b77cfbc735c3dd76c97652b47a0272257a9e" + dependencies: + "@0xproject/assert" "^1.0.11" + "@0xproject/types" "^1.1.1" + "@0xproject/typescript-typings" "^2.0.2" + "@0xproject/utils" "^1.0.11" + "@0xproject/web3-wrapper" "^3.0.1" + "@ledgerhq/hw-app-eth" "^4.3.0" + "@ledgerhq/hw-transport-u2f" "^4.3.0" + "@types/eth-lightwallet" "^3.0.0" + "@types/ganache-core" "^2.1.0" + "@types/hdkey" "^0.7.0" + bip39 "^2.5.0" + bn.js "^4.11.8" + eth-lightwallet "^3.0.1" + ethereum-types "^1.0.8" + ethereumjs-tx "^1.3.5" + ethereumjs-util "^5.1.1" + ganache-core "0xProject/ganache-core#monorepo-dep" + hdkey "^0.7.1" + json-rpc-error "2.0.0" + lodash "^4.17.5" + semaphore-async-await "^1.5.1" web3-provider-engine "14.0.6" optionalDependencies: - "@ledgerhq/hw-transport-node-hid" "4.7.3" + "@ledgerhq/hw-transport-node-hid" "^4.3.0" "@0xproject/types@^0.5.0": version "0.5.0" @@ -242,6 +267,14 @@ bignumber.js "~4.1.0" ethereum-types "^1.0.7" +"@0xproject/types@^1.1.1": + version "1.1.1" + resolved "https://registry.yarnpkg.com/@0xproject/types/-/types-1.1.1.tgz#c5c0b19ce387ee5732b002bfae734b8bd7cbb2c8" + dependencies: + "@types/node" "*" + bignumber.js "~4.1.0" + ethereum-types "^1.0.8" + "@0xproject/typescript-typings@^0.0.3": version "0.0.3" resolved "http://registry.npmjs.org/@0xproject/typescript-typings/-/typescript-typings-0.0.3.tgz#3272080bde00ade0a970b0d236686b483b08a1d0" @@ -263,7 +296,7 @@ "@0xproject/types" "^0.7.0" bignumber.js "~4.1.0" -"@0xproject/typescript-typings@^0.4.1", "@0xproject/typescript-typings@^0.4.3": +"@0xproject/typescript-typings@^0.4.3": version "0.4.3" resolved "https://registry.yarnpkg.com/@0xproject/typescript-typings/-/typescript-typings-0.4.3.tgz#f99f939a43f2764ad7182fcd78a71212a1d76d96" dependencies: @@ -281,6 +314,16 @@ ethereum-types "^1.0.7" popper.js "1.14.3" +"@0xproject/typescript-typings@^2.0.2": + version "2.0.2" + resolved "https://registry.yarnpkg.com/@0xproject/typescript-typings/-/typescript-typings-2.0.2.tgz#1812f64e341f1d24c09b8b5a951cbde0e5fff9c2" + dependencies: + "@types/bn.js" "^4.11.0" + "@types/react" "*" + bignumber.js "~4.1.0" + ethereum-types "^1.0.8" + popper.js "1.14.3" + "@0xproject/utils@^0.5.2": version "0.5.2" resolved "https://registry.yarnpkg.com/@0xproject/utils/-/utils-0.5.2.tgz#02ce0a920437db0a15d059e8c6c70fa33e9c3860" @@ -321,6 +364,23 @@ lodash "4.17.10" web3 "0.20.6" +"@0xproject/utils@^1.0.11": + version "1.0.11" + resolved "https://registry.yarnpkg.com/@0xproject/utils/-/utils-1.0.11.tgz#5b53e7d9d4dbe68e219049218c9db04e97c37429" + dependencies: + "@0xproject/types" "^1.1.1" + "@0xproject/typescript-typings" "^2.0.2" + "@types/node" "*" + abortcontroller-polyfill "^1.1.9" + bignumber.js "~4.1.0" + detect-node "2.0.3" + ethereum-types "^1.0.8" + ethereumjs-util "^5.1.1" + ethers "3.0.22" + isomorphic-fetch "^2.2.1" + js-sha3 "^0.7.0" + lodash "^4.17.5" + "@0xproject/utils@^1.0.9": version "1.0.9" resolved "https://registry.yarnpkg.com/@0xproject/utils/-/utils-1.0.9.tgz#6154f69d5618f4675e9429879b59e6162ee5d985" @@ -349,7 +409,7 @@ lodash "^4.17.4" web3 "^0.20.0" -"@0xproject/web3-wrapper@^0.7.1", "@0xproject/web3-wrapper@^0.7.3": +"@0xproject/web3-wrapper@^0.7.3": version "0.7.3" resolved "https://registry.yarnpkg.com/@0xproject/web3-wrapper/-/web3-wrapper-0.7.3.tgz#9bd50b034b92fd505b6766b6e225f014b6d08b08" dependencies: @@ -360,6 +420,19 @@ lodash "4.17.10" web3 "0.20.6" +"@0xproject/web3-wrapper@^3.0.1": + version "3.0.1" + resolved "https://registry.yarnpkg.com/@0xproject/web3-wrapper/-/web3-wrapper-3.0.1.tgz#7285dbc263b85a77e5bc2b5afbe73dd980c72ba5" + dependencies: + "@0xproject/assert" "^1.0.11" + "@0xproject/json-schemas" "^1.0.4" + "@0xproject/typescript-typings" "^2.0.2" + "@0xproject/utils" "^1.0.11" + ethereum-types "^1.0.8" + ethereumjs-util "^5.1.1" + ethers "3.0.22" + lodash "^4.17.5" + "@babel/code-frame@7.0.0-beta.44": version "7.0.0-beta.44" resolved "http://registry.npmjs.org/@babel/code-frame/-/code-frame-7.0.0-beta.44.tgz#2a02643368de80916162be70865c97774f3adbd9" @@ -998,27 +1071,29 @@ lodash "^4.17.10" to-fast-properties "^2.0.0" -"@ledgerhq/hw-app-eth@4.7.3": - version "4.7.3" - resolved "https://registry.yarnpkg.com/@ledgerhq/hw-app-eth/-/hw-app-eth-4.7.3.tgz#d352e19658ae296532e522c53c8ec2a1a77b64e5" +"@ledgerhq/hw-app-eth@^4.3.0": + version "4.21.0" + resolved "https://registry.yarnpkg.com/@ledgerhq/hw-app-eth/-/hw-app-eth-4.21.0.tgz#2d8bfbe5f09b92e8d6951ae685036d9d5aea96ff" dependencies: - "@ledgerhq/hw-transport" "^4.7.3" + "@ledgerhq/hw-transport" "^4.21.0" -"@ledgerhq/hw-transport-node-hid@4.7.3": - version "4.7.3" - resolved "https://registry.yarnpkg.com/@ledgerhq/hw-transport-node-hid/-/hw-transport-node-hid-4.7.3.tgz#e7634d53161cdffed4f602cddca6a7bc34e7b79b" +"@ledgerhq/hw-transport-node-hid@^4.3.0": + version "4.22.0" + resolved "https://registry.yarnpkg.com/@ledgerhq/hw-transport-node-hid/-/hw-transport-node-hid-4.22.0.tgz#1ee00dcccd852cb6fb152cd68c781c9689cf9f24" dependencies: - "@ledgerhq/hw-transport" "^4.7.3" + "@ledgerhq/hw-transport" "^4.21.0" + lodash "^4.17.10" node-hid "^0.7.2" + usb "^1.3.2" -"@ledgerhq/hw-transport-u2f@4.7.3": - version "4.7.3" - resolved "https://registry.yarnpkg.com/@ledgerhq/hw-transport-u2f/-/hw-transport-u2f-4.7.3.tgz#32be84bd2829f0ad0745604355f73a169dceb5e5" +"@ledgerhq/hw-transport-u2f@^4.3.0": + version "4.21.0" + resolved "https://registry.yarnpkg.com/@ledgerhq/hw-transport-u2f/-/hw-transport-u2f-4.21.0.tgz#85695d7e853a5c21af7e7dcb0ce3919f2b65cdd9" dependencies: - "@ledgerhq/hw-transport" "^4.7.3" + "@ledgerhq/hw-transport" "^4.21.0" u2f-api "0.2.7" -"@ledgerhq/hw-transport@^4.7.3": +"@ledgerhq/hw-transport@^4.21.0": version "4.21.0" resolved "https://registry.yarnpkg.com/@ledgerhq/hw-transport/-/hw-transport-4.21.0.tgz#50f85cfe115ba3f9d5bf94755c701e927175794f" dependencies: @@ -1035,6 +1110,10 @@ version "1.1.2" resolved "https://registry.yarnpkg.com/@nodelib/fs.stat/-/fs.stat-1.1.2.tgz#54c5a964462be3d4d78af631363c18d6fa91ac26" +"@rigoblock/contracts@^0.3.3": + version "0.3.3" + resolved "https://registry.yarnpkg.com/@rigoblock/contracts/-/contracts-0.3.3.tgz#a483b3ef73287e8893b375f1cb71a2096aa8cf5a" + "@samverschueren/stream-to-observable@^0.3.0": version "0.3.0" resolved "https://registry.yarnpkg.com/@samverschueren/stream-to-observable/-/stream-to-observable-0.3.0.tgz#ecdf48d532c58ea477acfcab80348424f8d0662f" @@ -1316,10 +1395,34 @@ "@types/bluebird" "*" "@types/ioredis" "*" +"@types/eth-lightwallet@^3.0.0": + version "3.0.0" + resolved "https://registry.yarnpkg.com/@types/eth-lightwallet/-/eth-lightwallet-3.0.0.tgz#9be5b59dc6fb3fcdb01e65c2c2a79cd601f72dd4" + dependencies: + "@types/node" "*" + +"@types/ethereum-protocol@*": + version "1.0.0" + resolved "https://registry.yarnpkg.com/@types/ethereum-protocol/-/ethereum-protocol-1.0.0.tgz#416e3827d5fdfa4658b0045b35a008747871b271" + dependencies: + bignumber.js "7.2.1" + "@types/events@*": version "1.2.0" resolved "https://registry.yarnpkg.com/@types/events/-/events-1.2.0.tgz#81a6731ce4df43619e5c8c945383b3e62a89ea86" +"@types/ganache-core@^2.1.0": + version "2.1.0" + resolved "https://registry.yarnpkg.com/@types/ganache-core/-/ganache-core-2.1.0.tgz#b6702857a239d483b79f008f3205bbbc17f080e0" + dependencies: + "@types/ethereum-protocol" "*" + +"@types/hdkey@^0.7.0": + version "0.7.0" + resolved "https://registry.yarnpkg.com/@types/hdkey/-/hdkey-0.7.0.tgz#6734d138e3c597f241be8fae2e60c2949bc3af87" + dependencies: + "@types/node" "*" + "@types/ioredis@*": version "4.0.1" resolved "https://registry.yarnpkg.com/@types/ioredis/-/ioredis-4.0.1.tgz#dfe9de0d5dce54193975c1909f0d082e5574e2f2" @@ -1344,14 +1447,14 @@ version "9.6.0" resolved "http://registry.npmjs.org/@types/node/-/node-9.6.0.tgz#d3480ee666df9784b1001a1872a2f6ccefb6c2d7" +"@types/node@^10.11.0": + version "10.11.0" + resolved "https://registry.yarnpkg.com/@types/node/-/node-10.11.0.tgz#ddd0d67a3b6c3810dd1a59e36675fa82de5e19ae" + "@types/node@^8.0.53": version "8.10.29" resolved "https://registry.yarnpkg.com/@types/node/-/node-8.10.29.tgz#b3a13b58dd7b0682bf1b42022bef4a5a9718f687" -"@types/node@^9.6.6": - version "9.6.31" - resolved "https://registry.yarnpkg.com/@types/node/-/node-9.6.31.tgz#4d1722987f8d808b4c194dceb8c213bd92f028e5" - "@types/pino@^4.16.1": version "4.16.1" resolved "https://registry.yarnpkg.com/@types/pino/-/pino-4.16.1.tgz#3b4b36e707cb364dcf0903503a7f44df67294b1c" @@ -1995,18 +2098,6 @@ arr-union@^3.1.0: version "3.1.0" resolved "https://registry.yarnpkg.com/arr-union/-/arr-union-3.1.0.tgz#e39b09aea9def866a8f206e288af63919bae39c4" -array-back@^1.0.3, array-back@^1.0.4: - version "1.0.4" - resolved "https://registry.yarnpkg.com/array-back/-/array-back-1.0.4.tgz#644ba7f095f7ffcf7c43b5f0dc39d3c1f03c063b" - dependencies: - typical "^2.6.0" - -array-back@^2.0.0: - version "2.0.0" - resolved "https://registry.yarnpkg.com/array-back/-/array-back-2.0.0.tgz#6877471d51ecc9c9bfa6136fb6c7d5fe69748022" - dependencies: - typical "^2.6.1" - array-differ@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/array-differ/-/array-differ-1.0.0.tgz#eff52e3758249d33be402b8bb8e564bb2b5d4031" @@ -3395,6 +3486,12 @@ base-x@^1.1.0: version "1.1.0" resolved "https://registry.yarnpkg.com/base-x/-/base-x-1.1.0.tgz#42d3d717474f9ea02207f6d1aa1f426913eeb7ac" +base-x@^3.0.2: + version "3.0.4" + resolved "https://registry.yarnpkg.com/base-x/-/base-x-3.0.4.tgz#94c1788736da065edb1d68808869e357c977fa77" + dependencies: + safe-buffer "^5.0.1" + base64-arraybuffer@0.1.5: version "0.1.5" resolved "https://registry.yarnpkg.com/base64-arraybuffer/-/base64-arraybuffer-0.1.5.tgz#73926771923b5a19747ad666aa5cd4bf9c6e9ce8" @@ -3449,11 +3546,7 @@ big.js@^3.1.3: version "3.2.0" resolved "https://registry.yarnpkg.com/big.js/-/big.js-3.2.0.tgz#a5fc298b81b9e0dca2e458824784b65c52ba588e" -bignumber.js@^5.0.0: - version "5.0.0" - resolved "https://registry.yarnpkg.com/bignumber.js/-/bignumber.js-5.0.0.tgz#fbce63f09776b3000a83185badcde525daf34833" - -bignumber.js@^7.2.1: +bignumber.js@7.2.1, bignumber.js@^7.2.1: version "7.2.1" resolved "https://registry.yarnpkg.com/bignumber.js/-/bignumber.js-7.2.1.tgz#80c048759d826800807c4bfd521e50edbba57a5f" @@ -3481,7 +3574,7 @@ bintrees@1.0.2: version "1.0.2" resolved "https://registry.yarnpkg.com/bintrees/-/bintrees-1.0.2.tgz#49f896d6e858a4a499df85c38fb399b9aff840f8" -bip39@2.5.0: +bip39@^2.5.0: version "2.5.0" resolved "https://registry.yarnpkg.com/bip39/-/bip39-2.5.0.tgz#51cbd5179460504a63ea3c000db3f787ca051235" dependencies: @@ -3507,6 +3600,24 @@ bip66@^1.1.3: dependencies: safe-buffer "^5.0.1" +bitcore-lib@^0.15.0: + version "0.15.0" + resolved "https://registry.yarnpkg.com/bitcore-lib/-/bitcore-lib-0.15.0.tgz#f924be13869f2aab7e04aeec5642ad3359b6cec2" + dependencies: + bn.js "=4.11.8" + bs58 "=4.0.1" + buffer-compare "=1.1.1" + elliptic "=6.4.0" + inherits "=2.0.1" + lodash "=4.17.4" + +bitcore-mnemonic@^1.5.0: + version "1.5.0" + resolved "https://registry.yarnpkg.com/bitcore-mnemonic/-/bitcore-mnemonic-1.5.0.tgz#c7e785beb6bf0616ed4992785dc3658670425a39" + dependencies: + bitcore-lib "^0.15.0" + unorm "^1.3.3" + bl@^1.0.0: version "1.2.2" resolved "https://registry.yarnpkg.com/bl/-/bl-1.2.2.tgz#a160911717103c07410cef63ef51b397c025af9c" @@ -3550,10 +3661,14 @@ bn.js@4.11.7: version "4.11.7" resolved "https://registry.yarnpkg.com/bn.js/-/bn.js-4.11.7.tgz#ddb048e50d9482790094c13eb3fcfc833ce7ab46" -bn.js@^4.0.0, bn.js@^4.1.0, bn.js@^4.1.1, bn.js@^4.10.0, bn.js@^4.11.0, bn.js@^4.11.3, bn.js@^4.11.6, bn.js@^4.11.8, bn.js@^4.4.0, bn.js@^4.8.0: +bn.js@=4.11.8, bn.js@^4.0.0, bn.js@^4.1.0, bn.js@^4.1.1, bn.js@^4.10.0, bn.js@^4.11.0, bn.js@^4.11.3, bn.js@^4.11.6, bn.js@^4.11.8, bn.js@^4.4.0, bn.js@^4.8.0: version "4.11.8" resolved "https://registry.yarnpkg.com/bn.js/-/bn.js-4.11.8.tgz#2cde09eb5ee341f484746bb0309b3253b1b1442f" +bn.js@^2.0.3: + version "2.2.0" + resolved "https://registry.yarnpkg.com/bn.js/-/bn.js-2.2.0.tgz#12162bc2ae71fc40a5626c33438f3a875cd37625" + bo-selector@0.0.10: version "0.0.10" resolved "https://registry.yarnpkg.com/bo-selector/-/bo-selector-0.0.10.tgz#9816dcb00adf374ea87941a863b2acfc026afa3e" @@ -3765,6 +3880,12 @@ bs-logger@0.x: dependencies: fast-json-stable-stringify "^2.0.0" +bs58@=4.0.1: + version "4.0.1" + resolved "https://registry.yarnpkg.com/bs58/-/bs58-4.0.1.tgz#be161e76c354f6f788ae4071f63f34e8c4f0a42a" + dependencies: + base-x "^3.0.2" + bs58@^2.0.1: version "2.0.1" resolved "https://registry.yarnpkg.com/bs58/-/bs58-2.0.1.tgz#55908d58f1982aba2008fa1bed8f91998a29bf8d" @@ -3799,6 +3920,10 @@ buffer-alloc@^1.1.0, buffer-alloc@^1.2.0: buffer-alloc-unsafe "^1.1.0" buffer-fill "^1.0.0" +buffer-compare@=1.1.1: + version "1.1.1" + resolved "https://registry.yarnpkg.com/buffer-compare/-/buffer-compare-1.1.1.tgz#5be7be853af89198d1f4ddc090d1d66a48aef596" + buffer-crc32@~0.2.3: version "0.2.13" resolved "https://registry.yarnpkg.com/buffer-crc32/-/buffer-crc32-0.2.13.tgz#0d333e3f00eac50aa1454abd30ef8c2a5d9a7242" @@ -3835,7 +3960,7 @@ buffer@^3.0.1: ieee754 "^1.1.4" isarray "^1.0.0" -buffer@^4.3.0: +buffer@^4.3.0, buffer@^4.9.0: version "4.9.1" resolved "http://registry.npmjs.org/buffer/-/buffer-4.9.1.tgz#6d1bb601b07a4efced97094132093027c95bc298" dependencies: @@ -4494,14 +4619,6 @@ command-join@^2.0.0: version "2.0.0" resolved "https://registry.yarnpkg.com/command-join/-/command-join-2.0.0.tgz#52e8b984f4872d952ff1bdc8b98397d27c7144cf" -command-line-args@^4.0.7: - version "4.0.7" - resolved "https://registry.yarnpkg.com/command-line-args/-/command-line-args-4.0.7.tgz#f8d1916ecb90e9e121eda6428e41300bfb64cc46" - dependencies: - array-back "^2.0.0" - find-replace "^1.0.3" - typical "^2.6.1" - commander@2.11.0: version "2.11.0" resolved "https://registry.yarnpkg.com/commander/-/commander-2.11.0.tgz#157152fd1e7a6c8d98a5b715cf376df928004563" @@ -4970,7 +5087,7 @@ crypto-browserify@3.12.0, crypto-browserify@^3.11.0: randombytes "^2.0.0" randomfill "^1.0.3" -crypto-js@^3.1.4: +crypto-js@^3.1.4, crypto-js@^3.1.5: version "3.1.8" resolved "https://registry.yarnpkg.com/crypto-js/-/crypto-js-3.1.8.tgz#715f070bf6014f2ae992a98b3929258b713f08d5" @@ -5197,7 +5314,7 @@ debug@3.1.0: dependencies: ms "2.0.0" -debug@^3.0.0, debug@^3.0.1, debug@^3.1.0: +debug@^3.0.0, debug@^3.1.0: version "3.2.4" resolved "https://registry.yarnpkg.com/debug/-/debug-3.2.4.tgz#82123737c51afbe9609a2b5dfe9664e7487171f0" dependencies: @@ -5694,6 +5811,27 @@ elliptic@6.3.3: hash.js "^1.0.0" inherits "^2.0.1" +elliptic@=6.4.0: + version "6.4.0" + resolved "https://registry.yarnpkg.com/elliptic/-/elliptic-6.4.0.tgz#cac9af8762c85836187003c8dfe193e5e2eae5df" + dependencies: + bn.js "^4.4.0" + brorand "^1.0.1" + hash.js "^1.0.0" + hmac-drbg "^1.0.0" + inherits "^2.0.1" + minimalistic-assert "^1.0.0" + minimalistic-crypto-utils "^1.0.0" + +elliptic@^3.1.0: + version "3.1.0" + resolved "https://registry.yarnpkg.com/elliptic/-/elliptic-3.1.0.tgz#c21682ef762769b56a74201609105da11d5f60cc" + dependencies: + bn.js "^2.0.3" + brorand "^1.0.1" + hash.js "^1.0.0" + inherits "^2.0.1" + elliptic@^6.0.0, elliptic@^6.2.3, elliptic@^6.4.0: version "6.4.1" resolved "https://registry.yarnpkg.com/elliptic/-/elliptic-6.4.1.tgz#c2d0b7776911b86722c632c3c06c60f2f819939a" @@ -6348,6 +6486,22 @@ eth-lib@0.2.7: elliptic "^6.4.0" xhr-request-promise "^0.1.2" +eth-lightwallet@^3.0.1: + version "3.0.1" + resolved "https://registry.yarnpkg.com/eth-lightwallet/-/eth-lightwallet-3.0.1.tgz#297022932aa568f4e4eb0873bff257f5e5b78709" + dependencies: + bitcore-lib "^0.15.0" + bitcore-mnemonic "^1.5.0" + buffer "^4.9.0" + crypto-js "^3.1.5" + elliptic "^3.1.0" + ethereumjs-tx "^1.3.3" + ethereumjs-util "^5.1.1" + rlp "^2.0.0" + scrypt-async "^1.2.0" + tweetnacl "0.13.2" + web3 "0.20.2" + eth-query@^2.0.2, eth-query@^2.1.0, eth-query@^2.1.2: version "2.1.2" resolved "https://registry.yarnpkg.com/eth-query/-/eth-query-2.1.2.tgz#d6741d9000106b51510c72db92d6365456a6da5e" @@ -6406,6 +6560,13 @@ ethereum-types@^1.0.7: "@types/node" "*" bignumber.js "~4.1.0" +ethereum-types@^1.0.8: + version "1.0.8" + resolved "https://registry.yarnpkg.com/ethereum-types/-/ethereum-types-1.0.8.tgz#3db12242c11f94366fdfcc5072b4ff4c8e40f6b6" + dependencies: + "@types/node" "*" + bignumber.js "~4.1.0" + ethereumjs-abi@0.6.5, "ethereumjs-abi@git+https://github.com/ethereumjs/ethereumjs-abi.git": version "0.6.5" resolved "git+https://github.com/ethereumjs/ethereumjs-abi.git#00ba8463a7f7a67fcad737ff9c2ebd95643427f7" @@ -6460,14 +6621,7 @@ ethereumjs-tx@0xProject/ethereumjs-tx#fake-tx-include-signature-by-default: ethereum-common "^0.0.18" ethereumjs-util "^5.0.0" -ethereumjs-tx@1.3.4: - version "1.3.4" - resolved "https://registry.yarnpkg.com/ethereumjs-tx/-/ethereumjs-tx-1.3.4.tgz#c2304912f6c07af03237ad8675ac036e290dad48" - dependencies: - ethereum-common "^0.0.18" - ethereumjs-util "^5.0.0" - -ethereumjs-tx@^1.0.0, ethereumjs-tx@^1.1.1, ethereumjs-tx@^1.2.0, ethereumjs-tx@^1.2.2, ethereumjs-tx@^1.3.3: +ethereumjs-tx@^1.0.0, ethereumjs-tx@^1.1.1, ethereumjs-tx@^1.2.0, ethereumjs-tx@^1.2.2, ethereumjs-tx@^1.3.3, ethereumjs-tx@^1.3.5: version "1.3.7" resolved "https://registry.yarnpkg.com/ethereumjs-tx/-/ethereumjs-tx-1.3.7.tgz#88323a2d875b10549b8347e09f4862b546f3d89a" dependencies: @@ -7149,13 +7303,6 @@ find-parent-dir@^0.3.0: version "0.3.0" resolved "https://registry.yarnpkg.com/find-parent-dir/-/find-parent-dir-0.3.0.tgz#33c44b429ab2b2f0646299c5f9f718f376ff8d54" -find-replace@^1.0.3: - version "1.0.3" - resolved "https://registry.yarnpkg.com/find-replace/-/find-replace-1.0.3.tgz#b88e7364d2d9c959559f388c66670d6130441fa0" - dependencies: - array-back "^1.0.4" - test-value "^2.1.0" - find-up@^1.0.0: version "1.1.2" resolved "https://registry.yarnpkg.com/find-up/-/find-up-1.1.2.tgz#6b2e9822b1a2ce0a60ab64d610eccad53cb24d0f" @@ -7327,7 +7474,7 @@ fs-extra@^2.0.0, fs-extra@^2.1.2: graceful-fs "^4.1.2" jsonfile "^2.1.0" -fs-extra@^4.0.1, fs-extra@^4.0.2: +fs-extra@^4.0.1: version "4.0.3" resolved "https://registry.yarnpkg.com/fs-extra/-/fs-extra-4.0.3.tgz#0d852122e5bc5beb453fb028e9c0c9bf36340c94" dependencies: @@ -7420,7 +7567,7 @@ ganache-cli@^6.1.0: dependencies: source-map-support "^0.5.3" -ganache-core@0xProject/ganache-core: +ganache-core@0xProject/ganache-core#monorepo-dep: version "2.1.2" resolved "https://codeload.github.com/0xProject/ganache-core/tar.gz/9f86ca3d114ee4395e2d16362f95a8c57ec69bb4" dependencies: @@ -8016,7 +8163,7 @@ hash.js@^1.0.0, hash.js@^1.0.3: inherits "^2.0.3" minimalistic-assert "^1.0.1" -hdkey@0.7.1, hdkey@^0.7.0: +hdkey@^0.7.0, hdkey@^0.7.1: version "0.7.1" resolved "https://registry.yarnpkg.com/hdkey/-/hdkey-0.7.1.tgz#caee4be81aa77921e909b8d228dd0f29acaee632" dependencies: @@ -8398,7 +8545,7 @@ inherits@2, inherits@2.0.3, inherits@^2.0.1, inherits@^2.0.3, inherits@~2.0.0, i version "2.0.3" resolved "https://registry.yarnpkg.com/inherits/-/inherits-2.0.3.tgz#633c2c83e3da42a502f52466022480f4208261de" -inherits@2.0.1: +inherits@2.0.1, inherits@=2.0.1: version "2.0.1" resolved "https://registry.yarnpkg.com/inherits/-/inherits-2.0.1.tgz#b17d08d326b4423e568eff719f91b0b1cbdf69f1" @@ -9797,7 +9944,7 @@ json-rpc-engine@^3.4.0, json-rpc-engine@^3.6.0: json-rpc-error "^2.0.0" promise-to-callback "^1.0.0" -json-rpc-error@^2.0.0: +json-rpc-error@2.0.0, json-rpc-error@^2.0.0: version "2.0.0" resolved "https://registry.yarnpkg.com/json-rpc-error/-/json-rpc-error-2.0.0.tgz#a7af9c202838b5e905c7250e547f1aff77258a02" dependencies: @@ -10450,6 +10597,10 @@ lodash@4.17.10, "lodash@>=3.5 <5", lodash@^4.0.0, lodash@^4.0.1, lodash@^4.13.1, version "4.17.10" resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.10.tgz#1b7793cf7259ea38fb3661d4d38b3260af8ae4e7" +lodash@=4.17.4: + version "4.17.4" + resolved "http://registry.npmjs.org/lodash/-/lodash-4.17.4.tgz#78203a4d1c328ae1d86dca6460e369b57f4055ae" + lodash@^3.3.1: version "3.10.1" resolved "http://registry.npmjs.org/lodash/-/lodash-3.10.1.tgz#5bf45e8e49ba4189e17d482789dfd15bd140b7b6" @@ -11130,7 +11281,7 @@ nan@2.10.0: version "2.10.0" resolved "https://registry.yarnpkg.com/nan/-/nan-2.10.0.tgz#96d0cd610ebd58d4b4de9cc0c6828cda99c7548f" -nan@>=2.5.1, nan@^2.0.8, nan@^2.10.0, nan@^2.2.1, nan@^2.3.3, nan@^2.9.2: +nan@>=2.5.1, nan@^2.0.8, nan@^2.10.0, nan@^2.2.1, nan@^2.3.3, nan@^2.8.0, nan@^2.9.2: version "2.11.0" resolved "https://registry.yarnpkg.com/nan/-/nan-2.11.0.tgz#574e360e4d954ab16966ec102c0c049fd961a099" @@ -12609,7 +12760,7 @@ preserve@^0.2.0: version "0.2.0" resolved "https://registry.yarnpkg.com/preserve/-/preserve-0.2.0.tgz#815ed1f6ebc65926f865b310c0713bcb3315ce4b" -prettier@^1.11.1, prettier@^1.12.1, prettier@^1.9.1: +prettier@^1.11.1, prettier@^1.12.1: version "1.14.2" resolved "https://registry.yarnpkg.com/prettier/-/prettier-1.14.2.tgz#0ac1c6e1a90baa22a62925f41963c841983282f9" @@ -14193,6 +14344,10 @@ scoped-regex@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/scoped-regex/-/scoped-regex-1.0.0.tgz#a346bb1acd4207ae70bd7c0c7ca9e566b6baddb8" +scrypt-async@^1.2.0: + version "1.3.1" + resolved "https://registry.yarnpkg.com/scrypt-async/-/scrypt-async-1.3.1.tgz#a11fd6fac981b4b823ee01dee0221169500ddae9" + scrypt-js@2.0.3: version "2.0.3" resolved "https://registry.yarnpkg.com/scrypt-js/-/scrypt-js-2.0.3.tgz#bb0040be03043da9a012a2cea9fc9f852cfc87d4" @@ -14256,7 +14411,7 @@ selfsigned@^1.9.1: dependencies: node-forge "0.7.5" -semaphore-async-await@1.5.1: +semaphore-async-await@^1.5.1: version "1.5.1" resolved "https://registry.yarnpkg.com/semaphore-async-await/-/semaphore-async-await-1.5.1.tgz#857bef5e3644601ca4b9570b87e9df5ca12974fa" @@ -15473,13 +15628,6 @@ test-exclude@^4.2.1: read-pkg-up "^1.0.1" require-main-filename "^1.0.1" -test-value@^2.1.0: - version "2.1.0" - resolved "https://registry.yarnpkg.com/test-value/-/test-value-2.1.0.tgz#11da6ff670f3471a73b625ca4f3fdcf7bb748291" - dependencies: - array-back "^1.0.3" - typical "^2.6.0" - text-extensions@^1.0.0: version "1.8.0" resolved "https://registry.yarnpkg.com/text-extensions/-/text-extensions-1.8.0.tgz#6f343c62268843019b21a616a003557bdb952d2b" @@ -15743,6 +15891,10 @@ tunnel-agent@^0.6.0: dependencies: safe-buffer "^5.0.1" +tweetnacl@0.13.2: + version "0.13.2" + resolved "https://registry.yarnpkg.com/tweetnacl/-/tweetnacl-0.13.2.tgz#453161770469d45cd266c36404e2bc99a8fa9944" + tweetnacl@^0.14.3, tweetnacl@~0.14.0: version "0.14.5" resolved "https://registry.yarnpkg.com/tweetnacl/-/tweetnacl-0.14.5.tgz#5ae68177f192d4456269d108afa93ff8743f4f64" @@ -15772,17 +15924,6 @@ type-is@~1.6.15, type-is@~1.6.16: media-typer "0.3.0" mime-types "~2.1.18" -typechain@^0.2.2: - version "0.2.7" - resolved "https://registry.yarnpkg.com/typechain/-/typechain-0.2.7.tgz#46a52f25176d8cecf08cd509a768aacf92d3f4a3" - dependencies: - chalk "^2.3.0" - command-line-args "^4.0.7" - debug "^3.0.1" - fs-extra "^4.0.2" - glob "^7.1.2" - prettier "^1.9.1" - typedarray-to-buffer@^3.1.2: version "3.1.5" resolved "https://registry.yarnpkg.com/typedarray-to-buffer/-/typedarray-to-buffer-3.1.5.tgz#a97ee7a9ff42691b9f783ff1bc5112fe3fca9080" @@ -15835,10 +15976,6 @@ typewiselite@~1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/typewiselite/-/typewiselite-1.0.0.tgz#c8882fa1bb1092c06005a97f34ef5c8508e3664e" -typical@^2.6.0, typical@^2.6.1: - version "2.6.1" - resolved "https://registry.yarnpkg.com/typical/-/typical-2.6.1.tgz#5c080e5d661cbbe38259d2e70a3c7253e873881d" - u2f-api@0.2.7: version "0.2.7" resolved "https://registry.yarnpkg.com/u2f-api/-/u2f-api-0.2.7.tgz#17bf196b242f6bf72353d9858e6a7566cc192720" @@ -16149,6 +16286,13 @@ url@^0.11.0: punycode "1.3.2" querystring "0.2.0" +usb@^1.3.2: + version "1.3.3" + resolved "https://registry.yarnpkg.com/usb/-/usb-1.3.3.tgz#4e8a4b44ab8833fa1c4fb99778ebae1d2d626970" + dependencies: + nan "^2.8.0" + node-pre-gyp "^0.10.0" + use@^3.1.0: version "3.1.1" resolved "https://registry.yarnpkg.com/use/-/use-3.1.1.tgz#d50c8cac79a19fbc20f2911f56eb973f4e10070f" @@ -16216,7 +16360,7 @@ v8-compile-cache@^2.0.0: version "2.0.2" resolved "https://registry.yarnpkg.com/v8-compile-cache/-/v8-compile-cache-2.0.2.tgz#a428b28bb26790734c4fc8bc9fa106fccebf6a6c" -valid-url@1.0.9: +valid-url@1.0.9, valid-url@^1.0.9: version "1.0.9" resolved "https://registry.yarnpkg.com/valid-url/-/valid-url-1.0.9.tgz#1c14479b40f1397a75782f115e4086447433a200" @@ -16796,7 +16940,7 @@ web3-net@1.0.0-beta.36: web3-core-method "1.0.0-beta.36" web3-utils "1.0.0-beta.36" -web3-provider-engine@14.0.6, web3-provider-engine@^14.0.5, web3-provider-engine@^14.0.6: +web3-provider-engine@14.0.6, web3-provider-engine@^14.0.6: version "14.0.6" resolved "https://registry.yarnpkg.com/web3-provider-engine/-/web3-provider-engine-14.0.6.tgz#cbdd66fe20c0136a3a495cbe40d18b6c4160d5f0" dependencies: @@ -16984,6 +17128,16 @@ web3-utils@1.0.0-beta.36: underscore "1.8.3" utf8 "2.1.1" +web3@0.20.2: + version "0.20.2" + resolved "https://registry.yarnpkg.com/web3/-/web3-0.20.2.tgz#c54dac5fc0e377399c04c1a6ecbb12e4513278d6" + dependencies: + bignumber.js "git+https://github.com/frozeman/bignumber.js-nolookahead.git" + crypto-js "^3.1.4" + utf8 "^2.1.1" + xhr2 "*" + xmlhttprequest "*" + web3@0.20.6: version "0.20.6" resolved "http://registry.npmjs.org/web3/-/web3-0.20.6.tgz#3e97306ae024fb24e10a3d75c884302562215120" From 6a8ee4de25557973ab15bf265f535cb227582be3 Mon Sep 17 00:00:00 2001 From: Federico Obialero Date: Mon, 1 Oct 2018 16:37:37 +0200 Subject: [PATCH 5/8] Update DApp with new API (#454) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * initial commit 🌅 * wip * wip * seems to be working * removed ganache-cli dependency from api * added contractFactory function * refactoring and fixed errors * restored build-dapp step in circleci config * fixed stuck getId on API file * refactor --- .circleci/config.yml | 14 ++--- packages/api/package.json | 4 +- packages/api/src/api.ts | 20 +++++-- .../AccountSummary/AccountSummary.jsx | 6 +- .../CreateVaultForm/CreateVaultForm.jsx | 7 +-- packages/dapp/src/contractFactory.js | 23 ++++++++ .../src/epics/blockChain/BlockChainService.js | 59 +++++++------------ .../src/epics/blockChain/getAccountBalance.js | 4 +- .../src/epics/routing/selectFirstVault.js | 16 +++-- .../dapp/src/epics/routing/vaultInvalid.js | 2 +- packages/dapp/src/epics/vaults/createVault.js | 41 ++++++------- .../dapp/src/epics/vaults/getVaultFees.js | 10 ++-- .../dapp/src/epics/vaults/getVaultSupply.js | 20 +++---- .../src/epics/vaults/getVaultTransactions.js | 17 +++--- .../dapp/src/epics/vaults/registerVaults.js | 31 +++++----- yarn.lock | 13 +--- 16 files changed, 142 insertions(+), 145 deletions(-) create mode 100644 packages/dapp/src/contractFactory.js diff --git a/.circleci/config.yml b/.circleci/config.yml index 9ac9aa287..e5cf3925c 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -380,21 +380,21 @@ workflows: - test-exchange-connector: requires: - build-exchange-connector - - test-unit-dapp: - requires: - - setup + # - test-unit-dapp: + # requires: + # - setup - build-contracts: requires: - - test-unit-dapp + - setup - test-contracts: requires: - build-contracts - build-api: requires: - build-contracts - # - build-dapp: - # requires: - # - build-api + - build-dapp: + requires: + - build-api # - test-feature-dapp: # requires: # - build-dapp diff --git a/packages/api/package.json b/packages/api/package.json index 9d99015b4..b1bc111de 100644 --- a/packages/api/package.json +++ b/packages/api/package.json @@ -10,9 +10,8 @@ "scripts": { "build": "npm run abi-gen && npm run tsc", "tsc": "rm -rf dist/* && tsc --outDir './dist'", - "tsc:watch" : "rm -rf dist; tsc -w --outDir './dist'", + "tsc:watch": "rm -rf dist; tsc -w --outDir './dist'", "test": "jest", - "ganache": "npx ganache-cli -p 8545 -i 5777 -m \"${npm_package_config_mnemonic}\"", "lint": "eslint src --ext ts --ignore-path .gitignore --fix", "abi-gen": "npm run abi-extract && rm -rf src/contracts/models && ts-node abi-gen.ts --abis './.tmp/*.json' -o src/contracts/models --template './template.handlebars' --partials './partials/*.handlebars'", "abi-extract": "rm -rf .tmp && node src/abi-extractor.js" @@ -41,7 +40,6 @@ "@rigoblock/contracts": "^0.3.2", "@types/node": "^10.11.0", "bignumber.js": "^7.2.1", - "ganache-cli": "7.0.0-beta.0", "handlebars": "^4.0.12", "web3": "1.0.0-beta.36", "web3-provider-engine": "^14.0.6" diff --git a/packages/api/src/api.ts b/packages/api/src/api.ts index a39482655..1adf7da84 100644 --- a/packages/api/src/api.ts +++ b/packages/api/src/api.ts @@ -1,7 +1,9 @@ import Web3 = require('web3') import ProviderEngine = require('web3-provider-engine') import * as Contract from './contracts/contract' -import * as RpcSubprovider from 'web3-provider-engine/subproviders/rpc.js' +import * as FilterSubprovider from 'web3-provider-engine/subproviders/filters' +import * as SubscriptionSubProvider from 'web3-provider-engine/subproviders/subscriptions' +import * as WebSocketSubProvider from 'web3-provider-engine/subproviders/websocket' import { ContractModels } from './contracts' import { SignerSubprovider } from '@0xproject/subproviders' import fetchContracts from '@rigoblock/contracts' @@ -26,20 +28,28 @@ class Api { async init(web3: Web3 = window.web3, rpcUrl = 'http://localhost:8545') { this.engine = new ProviderEngine() this.engine.addProvider(new SignerSubprovider(web3.currentProvider)) + this.engine.addProvider(new FilterSubprovider()) + const subscriptionSubprovider = new SubscriptionSubProvider() + this.engine.addProvider(subscriptionSubprovider) + subscriptionSubprovider.on('data', (err, notification) => { + return this.engine.emit('data', err, notification) + }) this.engine.addProvider( - new RpcSubprovider({ - rpcUrl + new WebSocketSubProvider({ + rpcUrl: 'ws://localhost:8545' }) ) + this.web3 = new Web3(this.engine) + + await this.startEngine().catch(err => console.error(err)) + const networkId = await this.web3.eth.net.getId() const contractsMap: Contract.ContractsMap = await fetchContracts(networkId) const contracts = new Contract() await contracts.init(contractsMap) this.contract = contracts - await this.startEngine().catch(err => console.error(err)) - return this } } diff --git a/packages/dapp/src/components/organisms/AccountSummary/AccountSummary.jsx b/packages/dapp/src/components/organisms/AccountSummary/AccountSummary.jsx index d3ec06c9d..9e028635d 100644 --- a/packages/dapp/src/components/organisms/AccountSummary/AccountSummary.jsx +++ b/packages/dapp/src/components/organisms/AccountSummary/AccountSummary.jsx @@ -7,7 +7,7 @@ import PropTypes from 'prop-types' import React from 'react' const AccountSummary = ({ provider, number, balance, tokenBalance }) => { - const ethBalance = balance.div(ETH_TO_WEI) + const ethBalance = new BigNumber(balance).div(ETH_TO_WEI) return (
{ AccountSummary.propTypes = { provider: PropTypes.string.isRequired, - balance: PropTypes.object, + balance: PropTypes.string, tokenBalance: PropTypes.object, number: PropTypes.string.isRequired } AccountSummary.defaultProps = { - balance: new BigNumber('0'), + balance: '0', tokenBalance: new BigNumber('0') } diff --git a/packages/dapp/src/components/organisms/CreateVaultForm/CreateVaultForm.jsx b/packages/dapp/src/components/organisms/CreateVaultForm/CreateVaultForm.jsx index 238482b84..c0ce37a83 100644 --- a/packages/dapp/src/components/organisms/CreateVaultForm/CreateVaultForm.jsx +++ b/packages/dapp/src/components/organisms/CreateVaultForm/CreateVaultForm.jsx @@ -9,7 +9,7 @@ import PropTypes from 'prop-types' import React from 'react' import SelectFieldWithTitle from '../../molecules/SelectFieldWithTitle' import TextFieldWithTitle from '../../molecules/TextFieldWithTitle' -import api from '../../../api' +import contractFactory from '../../../contractFactory' import get from 'lodash/get' import globalActions from '../../../actions/global-actions' import vaultActions from '../../../actions/vault-actions' @@ -49,10 +49,7 @@ const validate = values => { const asyncValidate = async values => { const parsedValues = parseFormValues(values) const vaultExistError = { vaultName: 'Vault already exists.' } - const registry = await api.contract.DragoRegistry.createAndValidate( - api.web3._web3, - api.contract.DragoRegistry.address - ) + const registry = await contractFactory.getInstance('DragoRegistry') try { const res = await registry.fromName(parsedValues.vaultName.toLowerCase()) if (res) { diff --git a/packages/dapp/src/contractFactory.js b/packages/dapp/src/contractFactory.js new file mode 100644 index 000000000..73f398c5b --- /dev/null +++ b/packages/dapp/src/contractFactory.js @@ -0,0 +1,23 @@ +import api from './api' + +class ContractFactory { + constructor() { + this.contractInstances = {} + } + + getInstance(name, address = api.contract[name].address) { + return this.contractInstances[name] && this.contractInstances[name][address] + ? Promise.resolve(this.contractInstances[name][address]) + : this.createInstance(name, address) + } + + async createInstance(name, address = api.contract[name].address) { + this.contractInstances[name] = this.contractInstances[name] || {} + this.contractInstances[name][address] = api.contract[ + name + ].createAndValidate(api.web3, address) + return this.contractInstances[name][address] + } +} + +export default new ContractFactory() diff --git a/packages/dapp/src/epics/blockChain/BlockChainService.js b/packages/dapp/src/epics/blockChain/BlockChainService.js index c94553282..c6ec5d8b2 100644 --- a/packages/dapp/src/epics/blockChain/BlockChainService.js +++ b/packages/dapp/src/epics/blockChain/BlockChainService.js @@ -15,6 +15,7 @@ import { of } from 'rxjs/observable/of' import { timer } from 'rxjs/observable/timer' import { zip } from 'rxjs/observable/zip' import blockChainActions from '../../actions/blockchain-actions' +import contractFactory from '../../contractFactory' class BlockChainService { constructor(api, action$, subject$, ts = Scheduler.async) { @@ -43,11 +44,8 @@ class BlockChainService { return timer(0, 1000, this.scheduler) .exhaustMap(() => zip( - fromPromise(this.api.web3.getNodeVersionAsync(), this.scheduler), - fromPromise( - this.api.web3.getAvailableAddressesAsync(), - this.scheduler - ) + fromPromise(this.api.web3.eth.getNodeInfo(), this.scheduler), + fromPromise(this.api.web3.eth.getAccounts(), this.scheduler) ) ) .map(([nodeVersion, accounts]) => { @@ -91,30 +89,17 @@ class BlockChainService { fetchVaultEvents(fromBlock, toBlock = 'latest') { fromBlock = fromBlock || 0 - const VaultEventful = this.api.contract.VaultEventful const allVaultEvents = fromPromise( - VaultEventful.createAndValidate( - this.api.web3._web3, - VaultEventful.address - ), + contractFactory.getInstance('VaultEventful'), this.scheduler ) .mergeMap(vaultEventful => - Observable.create(observer => { - const events = vaultEventful.rawWeb3Contract.allEvents({ + fromPromise( + vaultEventful.getPastEvents('allEvents', { fromBlock, toBlock }) - events.get((err, events) => { - if (err) { - return observer.error(err) - } - observer.next(events) - return observer.complete() - }) - // we are passing an empty callback so that the function uses web3's sendAsync method - return () => events.stopWatching(() => {}) - }) + ) ) .mergeMap(events => from(events)) const filteredBlocks = this._filterBlocksByAccounts(VAULT, allVaultEvents) @@ -126,21 +111,18 @@ class BlockChainService { watchVaultEvents(fromBlock, toBlock = 'latest') { fromBlock = fromBlock || 0 const allVaultEvents = fromPromise( - this.api.contract.VaultEventful.createAndValidate( - this.api.web3._web3, - this.api.contract.VaultEventful.address - ), + contractFactory.getInstance('VaultEventful'), this.scheduler ).mergeMap(vaultEventful => { return Observable.create(observer => { - const events = vaultEventful.rawWeb3Contract.allEvents({ - fromBlock, - toBlock - }) - events.watch((err, events) => { - return err ? observer.error(err) : observer.next(events) - }) - return () => events.stopWatching(() => {}) + const events = vaultEventful.allEvents( + { + fromBlock, + toBlock + }, + (err, events) => (err ? observer.error(err) : observer.next(events)) + ) + return () => events.unsubscribe() }) }) return this.wrapError(this._filterBlocksByAccounts(VAULT, allVaultEvents)) @@ -149,7 +131,7 @@ class BlockChainService { _filterBlocksByAccounts(label, obs) { return obs .map(block => { - const account = Object.values(block.args).reduce( + const account = Object.values(block.returnValues).reduce( (accountInvolved, blockAcc) => this.accounts.has(blockAcc) ? blockAcc : accountInvolved, null @@ -159,9 +141,12 @@ class BlockChainService { .filter(block => !!block) .mergeMap(block => { return fromPromise( - this.api.web3.getBlockTimestampAsync(block.blockNumber), + this.api.web3.eth.getBlock(block.blockNumber), this.scheduler - ).map(timestamp => ({ ...block, timestamp: timestamp * 1000 })) + ).map(retrievedBlock => ({ + ...block, + timestamp: retrievedBlock.timestamp * 1000 + })) }) .map(decoratedBlock => { const { account, ...block } = decoratedBlock diff --git a/packages/dapp/src/epics/blockChain/getAccountBalance.js b/packages/dapp/src/epics/blockChain/getAccountBalance.js index 101b8b908..ab9e17abd 100644 --- a/packages/dapp/src/epics/blockChain/getAccountBalance.js +++ b/packages/dapp/src/epics/blockChain/getAccountBalance.js @@ -24,8 +24,8 @@ export const getAccountBalanceEpic = (action$, store, ts = Scheduler.async) => { ) return merge(action$1, action$2).mergeMap(({ payload: { account } }) => { - return fromPromise(api.web3.getBalanceInWeiAsync(account), ts).map( - balance => blockChainActions.updateAccountBalance({ account, balance }) + return fromPromise(api.web3.eth.getBalance(account), ts).map(balance => + blockChainActions.updateAccountBalance({ account, balance }) ) }) } diff --git a/packages/dapp/src/epics/routing/selectFirstVault.js b/packages/dapp/src/epics/routing/selectFirstVault.js index 861a6385e..ffd3dd13a 100644 --- a/packages/dapp/src/epics/routing/selectFirstVault.js +++ b/packages/dapp/src/epics/routing/selectFirstVault.js @@ -37,15 +37,13 @@ const selectFirstVaultEpic = (action$, store, ts = Scheduler.async) => { Object.keys(getVaultsInState(store, currentAccount)).length ) .mergeMap(() => - fromPromise(api.web3.getAvailableAddressesAsync(), ts).map( - ([account]) => { - const vaults = getVaultsInState(store, account) - const firstVaultId = Object.values(vaults) - .map(vault => vault.id) - .shift() - return routerActions.navigateToVault(firstVaultId) - } - ) + fromPromise(api.web3.eth.getAccounts(), ts).map(([account]) => { + const vaults = getVaultsInState(store, account) + const firstVaultId = Object.values(vaults) + .map(vault => vault.id) + .shift() + return routerActions.navigateToVault(firstVaultId) + }) ) } diff --git a/packages/dapp/src/epics/routing/vaultInvalid.js b/packages/dapp/src/epics/routing/vaultInvalid.js index 2e51cf69a..c35cd5b96 100644 --- a/packages/dapp/src/epics/routing/vaultInvalid.js +++ b/packages/dapp/src/epics/routing/vaultInvalid.js @@ -17,7 +17,7 @@ const vaultInvalidEpic = (action$, store, ts = Scheduler.async) => type === LOCATION_CHANGE && VAULT_ID_REGEXP.test(payload.pathname) ) .mergeMap(({ payload }) => - fromPromise(api.web3.getAvailableAddressesAsync(), ts) + fromPromise(api.web3.eth.getAccounts(), ts) .map(([account]) => { const vaultId = payload.pathname.match(VAULT_ID_REGEXP).pop() const vaults = get( diff --git a/packages/dapp/src/epics/vaults/createVault.js b/packages/dapp/src/epics/vaults/createVault.js index 97ef1cd4c..40eaaace1 100644 --- a/packages/dapp/src/epics/vaults/createVault.js +++ b/packages/dapp/src/epics/vaults/createVault.js @@ -8,8 +8,8 @@ import { Scheduler } from 'rxjs/Scheduler' import { fromPromise } from 'rxjs/observable/fromPromise' import { merge } from 'rxjs/observable/merge' import { of } from 'rxjs/observable/of' -import api from '../../api' import blockChainActions from '../../actions/blockchain-actions' +import contractFactory from '../../contractFactory' import vaultActions from '../../actions/vault-actions' const createVaultEpic = (action$, store, ts = Scheduler.async) => { @@ -22,28 +22,25 @@ const createVaultEpic = (action$, store, ts = Scheduler.async) => { const action$2 = source.mergeMap( ({ payload: { accountNumber, vaultName, vaultSymbol } }) => - fromPromise( - api.contract.VaultFactory.createAndValidate( - api.web3._web3, - api.contract.VaultFactory.address - ), - ts - ).switchMap(vaultFactory => - of(vaultFactory) - .mergeMap(() => - fromPromise( - vaultFactory - .createVaultTx(vaultName.toLowerCase(), vaultSymbol) - .send({ from: accountNumber, gasPrice: 1, gas: 6654755 }), - ts - ).map(txHash => - blockChainActions.transactionCompleted({ - type: CREATE_VAULT, - txHash - }) + fromPromise(contractFactory.getInstance('VaultFactory'), ts).switchMap( + vaultFactory => + of(vaultFactory) + .mergeMap(() => + fromPromise( + vaultFactory + .createVault(vaultName.toLowerCase(), vaultSymbol) + .then(obj => + obj.send({ from: accountNumber, gasPrice: 1, gas: 6654755 }) + ), + ts + ).map(txHash => + blockChainActions.transactionCompleted({ + type: CREATE_VAULT, + txHash + }) + ) ) - ) - .catch(e => of(blockChainActions.transactionFailed(e.toString()))) + .catch(e => of(blockChainActions.transactionFailed(e.toString()))) ) ) diff --git a/packages/dapp/src/epics/vaults/getVaultFees.js b/packages/dapp/src/epics/vaults/getVaultFees.js index 995878a3d..f8ca6f032 100644 --- a/packages/dapp/src/epics/vaults/getVaultFees.js +++ b/packages/dapp/src/epics/vaults/getVaultFees.js @@ -2,9 +2,10 @@ import 'rxjs/add/operator/do' import 'rxjs/add/operator/filter' import 'rxjs/add/operator/map' import 'rxjs/add/operator/mergeMap' +import { BigNumber } from 'bignumber.js' import { Scheduler } from 'rxjs/Scheduler' import { fromPromise } from 'rxjs/observable/fromPromise' -import api from '../../api' +import contractFactory from '../../contractFactory' import vaultActions from '../../actions/vault-actions' const getVaultFees = (action$, store, ts = Scheduler.async) => @@ -12,13 +13,10 @@ const getVaultFees = (action$, store, ts = Scheduler.async) => .filter(action => action.type === vaultActions.registerVault.getType()) .mergeMap(({ payload: { account, vaultData } }) => { const address = Object.keys(vaultData).pop() - return fromPromise( - api.contract.Vault.createAndValidate(api.web3._web3, address), - ts - ) + return fromPromise(contractFactory.getInstance('Vault', address), ts) .mergeMap(vault => fromPromise(vault.getAdminData(), ts)) .map(vaultData => { - const transactionFee = vaultData[4] + const transactionFee = new BigNumber(vaultData.transactionFee) return vaultActions.updateVaultData({ account, vaultData: { diff --git a/packages/dapp/src/epics/vaults/getVaultSupply.js b/packages/dapp/src/epics/vaults/getVaultSupply.js index 824023ad9..11a28dad7 100644 --- a/packages/dapp/src/epics/vaults/getVaultSupply.js +++ b/packages/dapp/src/epics/vaults/getVaultSupply.js @@ -1,10 +1,11 @@ import 'rxjs/add/operator/filter' import 'rxjs/add/operator/map' import 'rxjs/add/operator/mergeMap' +import { BigNumber } from 'bignumber.js' import { MICRO_TO_WEI } from '../../constants/utils' import { Scheduler } from 'rxjs/Scheduler' import { fromPromise } from 'rxjs/observable/fromPromise' -import api from '../../api' +import contractFactory from '../../contractFactory' import vaultActions from '../../actions/vault-actions' const getVaultSupplyEpic = (action$, store, ts = Scheduler.async) => @@ -12,20 +13,19 @@ const getVaultSupplyEpic = (action$, store, ts = Scheduler.async) => .filter(action => action.type === vaultActions.registerVault.getType()) .mergeMap(({ payload: { account, vaultData } }) => { const address = Object.keys(vaultData).pop() - return fromPromise( - api.contract.Vault.createAndValidate(api.web3._web3, address), - ts - ) - .mergeMap(vault => fromPromise(vault.totalSupply, ts)) - .map(totalSupply => - vaultActions.updateVaultData({ + return fromPromise(contractFactory.getInstance('Vault', address), ts) + .mergeMap(vault => fromPromise(vault.totalSupply(), ts)) + .map(totalSupply => { + return vaultActions.updateVaultData({ account, vaultData: { address, - data: { totalSupply: totalSupply.times(MICRO_TO_WEI) } + data: { + totalSupply: new BigNumber(totalSupply).times(MICRO_TO_WEI) + } } }) - ) + }) }) export default getVaultSupplyEpic diff --git a/packages/dapp/src/epics/vaults/getVaultTransactions.js b/packages/dapp/src/epics/vaults/getVaultTransactions.js index 425ea0638..d56fdd09a 100644 --- a/packages/dapp/src/epics/vaults/getVaultTransactions.js +++ b/packages/dapp/src/epics/vaults/getVaultTransactions.js @@ -1,6 +1,7 @@ import 'rxjs/add/operator/filter' import 'rxjs/add/operator/map' import { BUY_VAULT, SELL_VAULT } from '../../constants/blockchain' +import { BigNumber } from 'bignumber.js' import { DEPOSIT, ETH, WITHDRAW } from '../../constants/blockchain' import { merge } from 'rxjs/observable/merge' import vaultActions from '../../actions/vault-actions' @@ -15,14 +16,14 @@ const getVaultTransactions = action$ => { .map(({ payload: { account, block } }) => { const transaction = { hash: block.transactionHash, - vault: block.args.vault, + vault: block.returnValues.vault, data: { date: block.timestamp, type: DEPOSIT, symbol: ETH, - value: block.args.amount, - units: block.args.revenue, - account: block.args.from + value: new BigNumber(block.returnValues.amount), + units: block.returnValues.revenue, + account: block.returnValues.from } } return vaultActions.registerTransaction({ account, transaction }) @@ -37,14 +38,14 @@ const getVaultTransactions = action$ => { .map(({ payload: { account, block } }) => { const transaction = { hash: block.transactionHash, - vault: block.args.vault, + vault: block.returnValues.vault, data: { date: block.timestamp, type: WITHDRAW, symbol: ETH, - value: block.args.revenue, - units: block.args.amount, - account: block.args.from + value: new BigNumber(block.returnValues.revenue), + units: block.returnValues.amount, + account: block.returnValues.from } } return vaultActions.registerTransaction({ account, transaction }) diff --git a/packages/dapp/src/epics/vaults/registerVaults.js b/packages/dapp/src/epics/vaults/registerVaults.js index a0a53357f..2b9e90101 100644 --- a/packages/dapp/src/epics/vaults/registerVaults.js +++ b/packages/dapp/src/epics/vaults/registerVaults.js @@ -5,8 +5,8 @@ import { Scheduler } from 'rxjs/Scheduler' import { VAULT } from '../../constants/blockchain' import { fromPromise } from 'rxjs/observable/fromPromise' import { merge } from 'rxjs/observable/merge' -import api from '../../api' import blockChainActions from '../../actions/blockchain-actions' +import contractFactory from '../../contractFactory' import vaultActions from '../../actions/vault-actions' const registerVaultsEpic = (action$, store, ts = Scheduler.async) => { @@ -23,25 +23,26 @@ const registerVaultsEpic = (action$, store, ts = Scheduler.async) => { ) const action$2 = vaultBlock$ - .mergeMap(action => { - const registry = api.contract.DragoRegistry - return fromPromise( - registry.createAndValidate(api.web3._web3, registry.address) - ).mergeMap(registry => { - const address = action.payload.block.args.vault - const account = action.payload.account - return fromPromise(registry.fromAddress(address), ts).map( - vaultData => ({ account, address, vaultData }) - ) - }) - }) + .mergeMap(action => + fromPromise(contractFactory.getInstance('DragoRegistry')).mergeMap( + registry => { + const address = action.payload.block.returnValues.vault + const account = action.payload.account + return fromPromise(registry.fromAddress(address), ts).map( + vaultData => { + return { account, address, vaultData } + } + ) + } + ) + ) .map( - ({ account, address, vaultData: [id, name, symbol, , owner, group] }) => + ({ account, address, vaultData: { id, name, symbol, owner, group } }) => vaultActions.registerVault({ account, vaultData: { [address]: { - id: id.toNumber(), + id: parseInt(id), name, symbol, owner, diff --git a/yarn.lock b/yarn.lock index 0973fa072..26df19270 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1110,10 +1110,6 @@ version "1.1.2" resolved "https://registry.yarnpkg.com/@nodelib/fs.stat/-/fs.stat-1.1.2.tgz#54c5a964462be3d4d78af631363c18d6fa91ac26" -"@rigoblock/contracts@^0.3.3": - version "0.3.3" - resolved "https://registry.yarnpkg.com/@rigoblock/contracts/-/contracts-0.3.3.tgz#a483b3ef73287e8893b375f1cb71a2096aa8cf5a" - "@samverschueren/stream-to-observable@^0.3.0": version "0.3.0" resolved "https://registry.yarnpkg.com/@samverschueren/stream-to-observable/-/stream-to-observable-0.3.0.tgz#ecdf48d532c58ea477acfcab80348424f8d0662f" @@ -7554,13 +7550,6 @@ fuse.js@^3.0.1, fuse.js@^3.2.0: version "3.2.1" resolved "https://registry.yarnpkg.com/fuse.js/-/fuse.js-3.2.1.tgz#6320cb94ce56ec9755c89ade775bcdbb0358d425" -ganache-cli@7.0.0-beta.0: - version "7.0.0-beta.0" - resolved "https://registry.yarnpkg.com/ganache-cli/-/ganache-cli-7.0.0-beta.0.tgz#9454567d731bd8f0b582e40473f2f44a16f109b3" - dependencies: - source-map-support "^0.5.0" - webpack "^3.10.0" - ganache-cli@^6.1.0: version "6.1.8" resolved "https://registry.yarnpkg.com/ganache-cli/-/ganache-cli-6.1.8.tgz#49a8a331683a9652183f82ef1378d17e1814fcd3" @@ -17368,7 +17357,7 @@ webpack@4.16.1: watchpack "^1.5.0" webpack-sources "^1.0.1" -webpack@^3.10.0, webpack@^3.11.0: +webpack@^3.11.0: version "3.12.0" resolved "https://registry.yarnpkg.com/webpack/-/webpack-3.12.0.tgz#3f9e34360370602fcf639e97939db486f4ec0d74" dependencies: From a0c756bb905e4a91fa06a578849da14df43d6a59 Mon Sep 17 00:00:00 2001 From: Federico Obialero Date: Wed, 3 Oct 2018 10:55:19 +0200 Subject: [PATCH 6/8] Fixed DApp unit tests (#462) * updated babel and dependencies * fixed blockchainservice tests * fixed getVaultFees and getVaultSupply * fixed getVaultTransactions * fixed selectFirstVault and createVault epic * updated snapshots temporarily * fixed remaining unit tests * removed babel-preset-react-app * removed unused dependency. fixed babel dependency versions to avoid issues in the future * fixed circleCI steps * fix to babel-core version * refactored code to avoid bugs * fixed unit and feature tests * using rawgit url with cdn * fix to vaults feature test --- .circleci/config.yml | 46 +- packages/dapp/helpers/web3Puppeteer.js | 7 +- packages/dapp/package.json | 31 +- .../SelectFieldWithTitle.test.js.snap | 13 - .../AccountSummary/AccountSummary.jsx | 6 +- .../CreateVaultForm/CreateVaultForm.jsx | 6 +- .../CreateVaultForm.test.js.snap | 357 +++++++- .../CreateVaultModal.test.js.snap | 357 +++++++- .../PreferencesForm.test.js.snap | 53 +- .../__snapshots__/VaultFees.test.js.snap | 14 - .../__snapshots__/VaultPanel.test.js.snap | 28 - .../__snapshots__/VaultSelect.test.js.snap | 60 +- .../__snapshots__/VaultTitle.test.js.snap | 28 - packages/dapp/src/contractFactory.js | 4 +- .../src/epics/blockChain/BlockChainService.js | 11 +- .../blockChain/BlockChainService.test.js | 118 +-- .../src/epics/blockChain/getAccountBalance.js | 6 +- .../blockChain/getAccountBalance.test.js | 25 +- .../epics/routing/selectFirstVault.test.js | 4 +- .../src/epics/routing/vaultInvalid.test.js | 4 +- packages/dapp/src/epics/vaults/createVault.js | 42 +- .../dapp/src/epics/vaults/createVault.test.js | 14 +- .../src/epics/vaults/getVaultFees.test.js | 12 +- .../src/epics/vaults/getVaultSupply.test.js | 18 +- .../epics/vaults/getVaultTransactions.test.js | 9 +- .../dapp/src/epics/vaults/registerVaults.js | 24 +- .../src/epics/vaults/registerVaults.test.js | 27 +- packages/dapp/test/features/vaults.test.js | 5 +- yarn.lock | 847 +++++++++--------- 29 files changed, 1287 insertions(+), 889 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index e5cf3925c..c3f48843a 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -380,12 +380,12 @@ workflows: - test-exchange-connector: requires: - build-exchange-connector - # - test-unit-dapp: - # requires: - # - setup - - build-contracts: + - test-unit-dapp: requires: - setup + - build-contracts: + requires: + - test-unit-dapp - test-contracts: requires: - build-contracts @@ -395,22 +395,22 @@ workflows: - build-dapp: requires: - build-api - # - test-feature-dapp: - # requires: - # - build-dapp - # - deploy-dapp-staging: - # requires: - # - test-unit-dapp - # - build-dapp - # - test-feature-dapp - # filters: - # branches: - # only: master - # - deploy-storybook-staging: - # requires: - # - test-unit-dapp - # - build-dapp - # - test-feature-dapp - # filters: - # branches: - # only: master + - test-feature-dapp: + requires: + - build-dapp + - deploy-dapp-staging: + requires: + - test-unit-dapp + - build-dapp + - test-feature-dapp + filters: + branches: + only: master + - deploy-storybook-staging: + requires: + - test-unit-dapp + - build-dapp + - test-feature-dapp + filters: + branches: + only: master diff --git a/packages/dapp/helpers/web3Puppeteer.js b/packages/dapp/helpers/web3Puppeteer.js index a03eaa746..f596a03b7 100644 --- a/packages/dapp/helpers/web3Puppeteer.js +++ b/packages/dapp/helpers/web3Puppeteer.js @@ -3,6 +3,7 @@ const fs = require('fs-extra') const ganache = require('ganache-cli') const mnemonic = require('../package.json').config.mnemonic const pushAction = require('react-router-redux').CALL_HISTORY_METHOD +const fetch = require('node-fetch') class Web3Puppeteer extends Helper { constructor() { @@ -47,12 +48,14 @@ class Web3Puppeteer extends Helper { } async inject() { - const web3Raw = fs.readFileSync('../../node_modules/web3/dist/web3.min.js') + const web3Raw = await fetch( + 'https://cdn.rawgit.com/ethereum/web3.js/v1.0.0-beta.36/dist/web3.min.js' + ).then(res => res.text()) const page = this.helpers['Puppeteer'].page await page.evaluate(web3Raw => { eval(web3Raw) window.web3 = new window.Web3( - new window.Web3.providers.HttpProvider('http://localhost:8545/node') + new Web3.providers.HttpProvider('http://localhost:8545') ) this.store = window.init() }, web3Raw) diff --git a/packages/dapp/package.json b/packages/dapp/package.json index 75f42e2b7..7e304350d 100644 --- a/packages/dapp/package.json +++ b/packages/dapp/package.json @@ -24,6 +24,11 @@ "mnemonic": "lemon scrub wasp bracket town boat property sadness layer taxi butter audit" }, "devDependencies": { + "@babel/core": "7.1.2", + "@babel/plugin-proposal-class-properties": "7.1.0", + "@babel/plugin-syntax-jsx": "7.0.0", + "@babel/plugin-transform-react-display-name": "7.0.0", + "@babel/plugin-transform-react-jsx": "7.0.0", "@rigoblock/api": "^0.2.7", "@rigoblock/ganache-bootstrap": "^0.1.14", "@storybook/addon-info": "^3.4.8", @@ -33,15 +38,13 @@ "@storybook/addons": "^3.4.8", "@storybook/react": "^3.4.8", "autoprefixer": "7.1.6", - "babel-core": "6.26.0", - "babel-jest": "20.0.3", + "babel-core": "7.0.0-bridge.0", + "babel-jest": "^23.6.0", "babel-loader": "7.1.4", - "babel-preset-react-app": "^3.1.1", - "babel-runtime": "6.26.0", "case-sensitive-paths-webpack-plugin": "2.1.2", "chalk": "1.1.3", "classnames": "^2.2.5", - "codeceptjs": "^1.3.0", + "codeceptjs": "^1.4.2", "codeceptjs-puppeteer": "^1.3.0", "core-js": "3.0.0-beta.3", "css-loader": "0.28.11", @@ -54,14 +57,15 @@ "eslint-loader": "1.9.0", "file-loader": "1.1.11", "fs-extra": "3.0.1", - "ganache-cli": "^6.1.0", + "ganache-cli": "^6.1.8", "html-webpack-plugin": "3.0.7", - "jest": "22.4.3", + "jest": "23.6.0", "keymirror": "^0.1.1", "localforage": "^1.6.0", "lodash-es": "^4.17.10", "mini-css-extract-plugin": "^0.4.1", "moment-timezone": "^0.5.17", + "node-fetch": "^2.2.0", "node-sass": "^4.7.2", "object-assign": "4.1.1", "postcss-flexbugs-fixes": "3.3.0", @@ -69,7 +73,7 @@ "prettier": "^1.11.1", "promise": "8.0.1", "prop-types": "^15.6.1", - "puppeteer": "^1.2.0", + "puppeteer": "^1.8.0-next.1538070839127", "raf": "3.4.0", "react": "^16.2.0", "react-dev-utils": "^5.0.0", @@ -94,7 +98,7 @@ "sw-precache-webpack-plugin": "0.11.5", "updeep": "^1.0.0", "url-loader": "0.6.2", - "web3": "^1.0.0-beta.34", + "web3": "^1.0.0-beta.36", "webpack": "4.16.1", "webpack-cli": "^2.0.12", "webpack-dev-server": "3.1.1", @@ -145,10 +149,17 @@ }, "babel": { "presets": [ - "react-app" + "@babel/preset-env" + ], + "plugins": [ + "@babel/plugin-syntax-jsx", + "@babel/plugin-transform-react-jsx", + "@babel/plugin-transform-react-display-name", + "@babel/plugin-proposal-class-properties" ] }, "dependencies": { + "@babel/preset-env": "^7.1.0", "@rigoblock/contracts": "^0.3.2", "core-js": "3.0.0-beta.3" } diff --git a/packages/dapp/src/components/molecules/SelectFieldWithTitle/__snapshots__/SelectFieldWithTitle.test.js.snap b/packages/dapp/src/components/molecules/SelectFieldWithTitle/__snapshots__/SelectFieldWithTitle.test.js.snap index 36b831c29..c1701d1b3 100644 --- a/packages/dapp/src/components/molecules/SelectFieldWithTitle/__snapshots__/SelectFieldWithTitle.test.js.snap +++ b/packages/dapp/src/components/molecules/SelectFieldWithTitle/__snapshots__/SelectFieldWithTitle.test.js.snap @@ -644,7 +644,6 @@ exports[`SelectFieldWithTitle component renders correctly 1`] = ` active={false} activeLabel="" below={true} - className={undefined} dropdownIcon={ } error={false} - errorText={undefined} id="1" lineDirection="left" onBlur={[Function]} @@ -661,7 +659,6 @@ exports[`SelectFieldWithTitle component renders correctly 1`] = ` onClick={[Function]} onFocus={[Function]} placeholder={null} - style={undefined} transitionName="md-drop" transitionTime={300} value="" @@ -710,7 +707,6 @@ exports[`SelectFieldWithTitle component renders correctly 1`] = ` active={false} activeLabel="" below={true} - className={undefined} dropdownIcon={ } error={false} - errorText={undefined} id="1" lineDirection="left" onBlur={[Function]} @@ -727,7 +722,6 @@ exports[`SelectFieldWithTitle component renders correctly 1`] = ` onClick={[Function]} onFocus={[Function]} placeholder={null} - style={undefined} transitionName="md-drop" transitionTime={300} value="" @@ -871,16 +865,9 @@ exports[`SelectFieldWithTitle component renders correctly 1`] = ` id="1-toggle" ink={ } listenToEnter={true} diff --git a/packages/dapp/src/components/organisms/AccountSummary/AccountSummary.jsx b/packages/dapp/src/components/organisms/AccountSummary/AccountSummary.jsx index 9e028635d..d3ec06c9d 100644 --- a/packages/dapp/src/components/organisms/AccountSummary/AccountSummary.jsx +++ b/packages/dapp/src/components/organisms/AccountSummary/AccountSummary.jsx @@ -7,7 +7,7 @@ import PropTypes from 'prop-types' import React from 'react' const AccountSummary = ({ provider, number, balance, tokenBalance }) => { - const ethBalance = new BigNumber(balance).div(ETH_TO_WEI) + const ethBalance = balance.div(ETH_TO_WEI) return (
{ AccountSummary.propTypes = { provider: PropTypes.string.isRequired, - balance: PropTypes.string, + balance: PropTypes.object, tokenBalance: PropTypes.object, number: PropTypes.string.isRequired } AccountSummary.defaultProps = { - balance: '0', + balance: new BigNumber('0'), tokenBalance: new BigNumber('0') } diff --git a/packages/dapp/src/components/organisms/CreateVaultForm/CreateVaultForm.jsx b/packages/dapp/src/components/organisms/CreateVaultForm/CreateVaultForm.jsx index c0ce37a83..2dd1c41d3 100644 --- a/packages/dapp/src/components/organisms/CreateVaultForm/CreateVaultForm.jsx +++ b/packages/dapp/src/components/organisms/CreateVaultForm/CreateVaultForm.jsx @@ -9,6 +9,7 @@ import PropTypes from 'prop-types' import React from 'react' import SelectFieldWithTitle from '../../molecules/SelectFieldWithTitle' import TextFieldWithTitle from '../../molecules/TextFieldWithTitle' +import api from '../../../api' import contractFactory from '../../../contractFactory' import get from 'lodash/get' import globalActions from '../../../actions/global-actions' @@ -49,7 +50,10 @@ const validate = values => { const asyncValidate = async values => { const parsedValues = parseFormValues(values) const vaultExistError = { vaultName: 'Vault already exists.' } - const registry = await contractFactory.getInstance('DragoRegistry') + const registry = await contractFactory.getInstance( + 'DragoRegistry', + api.contract.DragoRegistry.address + ) try { const res = await registry.fromName(parsedValues.vaultName.toLowerCase()) if (res) { diff --git a/packages/dapp/src/components/organisms/CreateVaultForm/__snapshots__/CreateVaultForm.test.js.snap b/packages/dapp/src/components/organisms/CreateVaultForm/__snapshots__/CreateVaultForm.test.js.snap index 5f33e16cb..331dd3be6 100644 --- a/packages/dapp/src/components/organisms/CreateVaultForm/__snapshots__/CreateVaultForm.test.js.snap +++ b/packages/dapp/src/components/organisms/CreateVaultForm/__snapshots__/CreateVaultForm.test.js.snap @@ -57,6 +57,24 @@ exports[`CreateVaultForm component renders correctly 1`] = ` }, ], ], + "results": Array [ + Object { + "isThrow": false, + "value": undefined, + }, + Object { + "isThrow": false, + "value": undefined, + }, + Object { + "isThrow": false, + "value": undefined, + }, + Object { + "isThrow": false, + "value": undefined, + }, + ], }, "getState": [Function], "subscribe": [MockFunction] { @@ -68,6 +86,16 @@ exports[`CreateVaultForm component renders correctly 1`] = ` [Function], ], ], + "results": Array [ + Object { + "isThrow": false, + "value": undefined, + }, + Object { + "isThrow": false, + "value": undefined, + }, + ], }, } } @@ -184,6 +212,24 @@ exports[`CreateVaultForm component renders correctly 1`] = ` }, ], ], + "results": Array [ + Object { + "isThrow": false, + "value": undefined, + }, + Object { + "isThrow": false, + "value": undefined, + }, + Object { + "isThrow": false, + "value": undefined, + }, + Object { + "isThrow": false, + "value": undefined, + }, + ], } } formObject={ @@ -321,6 +367,24 @@ exports[`CreateVaultForm component renders correctly 1`] = ` }, ], ], + "results": Array [ + Object { + "isThrow": false, + "value": undefined, + }, + Object { + "isThrow": false, + "value": undefined, + }, + Object { + "isThrow": false, + "value": undefined, + }, + Object { + "isThrow": false, + "value": undefined, + }, + ], } } enableReinitialize={true} @@ -508,6 +572,24 @@ exports[`CreateVaultForm component renders correctly 1`] = ` }, ], ], + "results": Array [ + Object { + "isThrow": false, + "value": undefined, + }, + Object { + "isThrow": false, + "value": undefined, + }, + Object { + "isThrow": false, + "value": undefined, + }, + Object { + "isThrow": false, + "value": undefined, + }, + ], } } enableReinitialize={true} @@ -718,6 +800,24 @@ exports[`CreateVaultForm component renders correctly 1`] = ` }, ], ], + "results": Array [ + Object { + "isThrow": false, + "value": undefined, + }, + Object { + "isThrow": false, + "value": undefined, + }, + Object { + "isThrow": false, + "value": undefined, + }, + Object { + "isThrow": false, + "value": undefined, + }, + ], } } form="createVault" @@ -1005,6 +1105,24 @@ exports[`CreateVaultForm component renders correctly 1`] = ` }, ], ], + "results": Array [ + Object { + "isThrow": false, + "value": undefined, + }, + Object { + "isThrow": false, + "value": undefined, + }, + Object { + "isThrow": false, + "value": undefined, + }, + Object { + "isThrow": false, + "value": undefined, + }, + ], }, "enableReinitialize": true, "error": undefined, @@ -1248,6 +1366,24 @@ exports[`CreateVaultForm component renders correctly 1`] = ` }, ], ], + "results": Array [ + Object { + "isThrow": false, + "value": undefined, + }, + Object { + "isThrow": false, + "value": undefined, + }, + Object { + "isThrow": false, + "value": undefined, + }, + Object { + "isThrow": false, + "value": undefined, + }, + ], }, "enableReinitialize": true, "error": undefined, @@ -1381,6 +1517,24 @@ exports[`CreateVaultForm component renders correctly 1`] = ` }, ], ], + "results": Array [ + Object { + "isThrow": false, + "value": undefined, + }, + Object { + "isThrow": false, + "value": undefined, + }, + Object { + "isThrow": false, + "value": undefined, + }, + Object { + "isThrow": false, + "value": undefined, + }, + ], } } id="0" @@ -1495,6 +1649,24 @@ exports[`CreateVaultForm component renders correctly 1`] = ` }, ], ], + "results": Array [ + Object { + "isThrow": false, + "value": undefined, + }, + Object { + "isThrow": false, + "value": undefined, + }, + Object { + "isThrow": false, + "value": undefined, + }, + Object { + "isThrow": false, + "value": undefined, + }, + ], }, "error": undefined, "form": "createVault", @@ -1602,7 +1774,6 @@ exports[`CreateVaultForm component renders correctly 1`] = ` active={false} activeLabel="MetaMask **** 9196" below={true} - className={undefined} dropdownIcon={ } error={false} - errorText={undefined} id="0" lineDirection="left" onBlur={[Function]} @@ -1619,7 +1789,6 @@ exports[`CreateVaultForm component renders correctly 1`] = ` onClick={[Function]} onFocus={[Function]} placeholder={null} - style={undefined} transitionName="md-drop" transitionTime={300} value="0x242B2Dd21e7E1a2b2516d0A3a06b58e2D9BF9196" @@ -1668,7 +1837,6 @@ exports[`CreateVaultForm component renders correctly 1`] = ` active={false} activeLabel="MetaMask **** 9196" below={true} - className={undefined} dropdownIcon={ } error={false} - errorText={undefined} id="0" lineDirection="left" onBlur={[Function]} @@ -1685,7 +1852,6 @@ exports[`CreateVaultForm component renders correctly 1`] = ` onClick={[Function]} onFocus={[Function]} placeholder={null} - style={undefined} transitionName="md-drop" transitionTime={300} value="0x242B2Dd21e7E1a2b2516d0A3a06b58e2D9BF9196" @@ -1829,16 +1995,9 @@ exports[`CreateVaultForm component renders correctly 1`] = ` id="0-toggle" ink={ } listenToEnter={true} @@ -2128,6 +2287,24 @@ exports[`CreateVaultForm component renders correctly 1`] = ` }, ], ], + "results": Array [ + Object { + "isThrow": false, + "value": undefined, + }, + Object { + "isThrow": false, + "value": undefined, + }, + Object { + "isThrow": false, + "value": undefined, + }, + Object { + "isThrow": false, + "value": undefined, + }, + ], }, "enableReinitialize": true, "error": undefined, @@ -2355,6 +2532,24 @@ exports[`CreateVaultForm component renders correctly 1`] = ` }, ], ], + "results": Array [ + Object { + "isThrow": false, + "value": undefined, + }, + Object { + "isThrow": false, + "value": undefined, + }, + Object { + "isThrow": false, + "value": undefined, + }, + Object { + "isThrow": false, + "value": undefined, + }, + ], }, "enableReinitialize": true, "error": undefined, @@ -2488,6 +2683,24 @@ exports[`CreateVaultForm component renders correctly 1`] = ` }, ], ], + "results": Array [ + Object { + "isThrow": false, + "value": undefined, + }, + Object { + "isThrow": false, + "value": undefined, + }, + Object { + "isThrow": false, + "value": undefined, + }, + Object { + "isThrow": false, + "value": undefined, + }, + ], } } id="1" @@ -2570,6 +2783,24 @@ exports[`CreateVaultForm component renders correctly 1`] = ` }, ], ], + "results": Array [ + Object { + "isThrow": false, + "value": undefined, + }, + Object { + "isThrow": false, + "value": undefined, + }, + Object { + "isThrow": false, + "value": undefined, + }, + Object { + "isThrow": false, + "value": undefined, + }, + ], }, "error": undefined, "form": "createVault", @@ -2870,6 +3101,24 @@ exports[`CreateVaultForm component renders correctly 1`] = ` }, ], ], + "results": Array [ + Object { + "isThrow": false, + "value": undefined, + }, + Object { + "isThrow": false, + "value": undefined, + }, + Object { + "isThrow": false, + "value": undefined, + }, + Object { + "isThrow": false, + "value": undefined, + }, + ], }, "enableReinitialize": true, "error": undefined, @@ -3100,6 +3349,24 @@ exports[`CreateVaultForm component renders correctly 1`] = ` }, ], ], + "results": Array [ + Object { + "isThrow": false, + "value": undefined, + }, + Object { + "isThrow": false, + "value": undefined, + }, + Object { + "isThrow": false, + "value": undefined, + }, + Object { + "isThrow": false, + "value": undefined, + }, + ], }, "enableReinitialize": true, "error": undefined, @@ -3233,6 +3500,24 @@ exports[`CreateVaultForm component renders correctly 1`] = ` }, ], ], + "results": Array [ + Object { + "isThrow": false, + "value": undefined, + }, + Object { + "isThrow": false, + "value": undefined, + }, + Object { + "isThrow": false, + "value": undefined, + }, + Object { + "isThrow": false, + "value": undefined, + }, + ], } } fullWidth={false} @@ -3318,6 +3603,24 @@ exports[`CreateVaultForm component renders correctly 1`] = ` }, ], ], + "results": Array [ + Object { + "isThrow": false, + "value": undefined, + }, + Object { + "isThrow": false, + "value": undefined, + }, + Object { + "isThrow": false, + "value": undefined, + }, + Object { + "isThrow": false, + "value": undefined, + }, + ], }, "error": undefined, "form": "createVault", @@ -3459,16 +3762,9 @@ exports[`CreateVaultForm component renders correctly 1`] = ` flat={true} ink={ } onClick={[Function]} @@ -3483,16 +3779,9 @@ exports[`CreateVaultForm component renders correctly 1`] = ` iconBefore={true} ink={ } onClick={[Function]} @@ -3556,16 +3845,9 @@ exports[`CreateVaultForm component renders correctly 1`] = ` flat={true} ink={ } onClick={[Function]} @@ -3580,16 +3862,9 @@ exports[`CreateVaultForm component renders correctly 1`] = ` iconBefore={true} ink={ } onClick={[Function]} diff --git a/packages/dapp/src/components/organisms/CreateVaultModal/__snapshots__/CreateVaultModal.test.js.snap b/packages/dapp/src/components/organisms/CreateVaultModal/__snapshots__/CreateVaultModal.test.js.snap index 0afff9ebd..7f453f3e4 100644 --- a/packages/dapp/src/components/organisms/CreateVaultModal/__snapshots__/CreateVaultModal.test.js.snap +++ b/packages/dapp/src/components/organisms/CreateVaultModal/__snapshots__/CreateVaultModal.test.js.snap @@ -57,6 +57,24 @@ exports[`CreateVaultModal component renders correctly 1`] = ` }, ], ], + "results": Array [ + Object { + "isThrow": false, + "value": undefined, + }, + Object { + "isThrow": false, + "value": undefined, + }, + Object { + "isThrow": false, + "value": undefined, + }, + Object { + "isThrow": false, + "value": undefined, + }, + ], }, "getState": [Function], "subscribe": [MockFunction] { @@ -68,6 +86,16 @@ exports[`CreateVaultModal component renders correctly 1`] = ` [Function], ], ], + "results": Array [ + Object { + "isThrow": false, + "value": undefined, + }, + Object { + "isThrow": false, + "value": undefined, + }, + ], }, } } @@ -226,6 +254,24 @@ exports[`CreateVaultModal component renders correctly 1`] = ` }, ], ], + "results": Array [ + Object { + "isThrow": false, + "value": undefined, + }, + Object { + "isThrow": false, + "value": undefined, + }, + Object { + "isThrow": false, + "value": undefined, + }, + Object { + "isThrow": false, + "value": undefined, + }, + ], } } formObject={ @@ -363,6 +409,24 @@ exports[`CreateVaultModal component renders correctly 1`] = ` }, ], ], + "results": Array [ + Object { + "isThrow": false, + "value": undefined, + }, + Object { + "isThrow": false, + "value": undefined, + }, + Object { + "isThrow": false, + "value": undefined, + }, + Object { + "isThrow": false, + "value": undefined, + }, + ], } } enableReinitialize={true} @@ -550,6 +614,24 @@ exports[`CreateVaultModal component renders correctly 1`] = ` }, ], ], + "results": Array [ + Object { + "isThrow": false, + "value": undefined, + }, + Object { + "isThrow": false, + "value": undefined, + }, + Object { + "isThrow": false, + "value": undefined, + }, + Object { + "isThrow": false, + "value": undefined, + }, + ], } } enableReinitialize={true} @@ -760,6 +842,24 @@ exports[`CreateVaultModal component renders correctly 1`] = ` }, ], ], + "results": Array [ + Object { + "isThrow": false, + "value": undefined, + }, + Object { + "isThrow": false, + "value": undefined, + }, + Object { + "isThrow": false, + "value": undefined, + }, + Object { + "isThrow": false, + "value": undefined, + }, + ], } } form="createVault" @@ -1047,6 +1147,24 @@ exports[`CreateVaultModal component renders correctly 1`] = ` }, ], ], + "results": Array [ + Object { + "isThrow": false, + "value": undefined, + }, + Object { + "isThrow": false, + "value": undefined, + }, + Object { + "isThrow": false, + "value": undefined, + }, + Object { + "isThrow": false, + "value": undefined, + }, + ], }, "enableReinitialize": true, "error": undefined, @@ -1290,6 +1408,24 @@ exports[`CreateVaultModal component renders correctly 1`] = ` }, ], ], + "results": Array [ + Object { + "isThrow": false, + "value": undefined, + }, + Object { + "isThrow": false, + "value": undefined, + }, + Object { + "isThrow": false, + "value": undefined, + }, + Object { + "isThrow": false, + "value": undefined, + }, + ], }, "enableReinitialize": true, "error": undefined, @@ -1423,6 +1559,24 @@ exports[`CreateVaultModal component renders correctly 1`] = ` }, ], ], + "results": Array [ + Object { + "isThrow": false, + "value": undefined, + }, + Object { + "isThrow": false, + "value": undefined, + }, + Object { + "isThrow": false, + "value": undefined, + }, + Object { + "isThrow": false, + "value": undefined, + }, + ], } } id="0" @@ -1537,6 +1691,24 @@ exports[`CreateVaultModal component renders correctly 1`] = ` }, ], ], + "results": Array [ + Object { + "isThrow": false, + "value": undefined, + }, + Object { + "isThrow": false, + "value": undefined, + }, + Object { + "isThrow": false, + "value": undefined, + }, + Object { + "isThrow": false, + "value": undefined, + }, + ], }, "error": undefined, "form": "createVault", @@ -1644,7 +1816,6 @@ exports[`CreateVaultModal component renders correctly 1`] = ` active={false} activeLabel="MetaMask **** 9196" below={true} - className={undefined} dropdownIcon={ } error={false} - errorText={undefined} id="0" lineDirection="left" onBlur={[Function]} @@ -1661,7 +1831,6 @@ exports[`CreateVaultModal component renders correctly 1`] = ` onClick={[Function]} onFocus={[Function]} placeholder={null} - style={undefined} transitionName="md-drop" transitionTime={300} value="0x242B2Dd21e7E1a2b2516d0A3a06b58e2D9BF9196" @@ -1710,7 +1879,6 @@ exports[`CreateVaultModal component renders correctly 1`] = ` active={false} activeLabel="MetaMask **** 9196" below={true} - className={undefined} dropdownIcon={ } error={false} - errorText={undefined} id="0" lineDirection="left" onBlur={[Function]} @@ -1727,7 +1894,6 @@ exports[`CreateVaultModal component renders correctly 1`] = ` onClick={[Function]} onFocus={[Function]} placeholder={null} - style={undefined} transitionName="md-drop" transitionTime={300} value="0x242B2Dd21e7E1a2b2516d0A3a06b58e2D9BF9196" @@ -1871,16 +2037,9 @@ exports[`CreateVaultModal component renders correctly 1`] = ` id="0-toggle" ink={ } listenToEnter={true} @@ -2170,6 +2329,24 @@ exports[`CreateVaultModal component renders correctly 1`] = ` }, ], ], + "results": Array [ + Object { + "isThrow": false, + "value": undefined, + }, + Object { + "isThrow": false, + "value": undefined, + }, + Object { + "isThrow": false, + "value": undefined, + }, + Object { + "isThrow": false, + "value": undefined, + }, + ], }, "enableReinitialize": true, "error": undefined, @@ -2397,6 +2574,24 @@ exports[`CreateVaultModal component renders correctly 1`] = ` }, ], ], + "results": Array [ + Object { + "isThrow": false, + "value": undefined, + }, + Object { + "isThrow": false, + "value": undefined, + }, + Object { + "isThrow": false, + "value": undefined, + }, + Object { + "isThrow": false, + "value": undefined, + }, + ], }, "enableReinitialize": true, "error": undefined, @@ -2530,6 +2725,24 @@ exports[`CreateVaultModal component renders correctly 1`] = ` }, ], ], + "results": Array [ + Object { + "isThrow": false, + "value": undefined, + }, + Object { + "isThrow": false, + "value": undefined, + }, + Object { + "isThrow": false, + "value": undefined, + }, + Object { + "isThrow": false, + "value": undefined, + }, + ], } } id="1" @@ -2612,6 +2825,24 @@ exports[`CreateVaultModal component renders correctly 1`] = ` }, ], ], + "results": Array [ + Object { + "isThrow": false, + "value": undefined, + }, + Object { + "isThrow": false, + "value": undefined, + }, + Object { + "isThrow": false, + "value": undefined, + }, + Object { + "isThrow": false, + "value": undefined, + }, + ], }, "error": undefined, "form": "createVault", @@ -2912,6 +3143,24 @@ exports[`CreateVaultModal component renders correctly 1`] = ` }, ], ], + "results": Array [ + Object { + "isThrow": false, + "value": undefined, + }, + Object { + "isThrow": false, + "value": undefined, + }, + Object { + "isThrow": false, + "value": undefined, + }, + Object { + "isThrow": false, + "value": undefined, + }, + ], }, "enableReinitialize": true, "error": undefined, @@ -3142,6 +3391,24 @@ exports[`CreateVaultModal component renders correctly 1`] = ` }, ], ], + "results": Array [ + Object { + "isThrow": false, + "value": undefined, + }, + Object { + "isThrow": false, + "value": undefined, + }, + Object { + "isThrow": false, + "value": undefined, + }, + Object { + "isThrow": false, + "value": undefined, + }, + ], }, "enableReinitialize": true, "error": undefined, @@ -3275,6 +3542,24 @@ exports[`CreateVaultModal component renders correctly 1`] = ` }, ], ], + "results": Array [ + Object { + "isThrow": false, + "value": undefined, + }, + Object { + "isThrow": false, + "value": undefined, + }, + Object { + "isThrow": false, + "value": undefined, + }, + Object { + "isThrow": false, + "value": undefined, + }, + ], } } fullWidth={false} @@ -3360,6 +3645,24 @@ exports[`CreateVaultModal component renders correctly 1`] = ` }, ], ], + "results": Array [ + Object { + "isThrow": false, + "value": undefined, + }, + Object { + "isThrow": false, + "value": undefined, + }, + Object { + "isThrow": false, + "value": undefined, + }, + Object { + "isThrow": false, + "value": undefined, + }, + ], }, "error": undefined, "form": "createVault", @@ -3501,16 +3804,9 @@ exports[`CreateVaultModal component renders correctly 1`] = ` flat={true} ink={ } onClick={[Function]} @@ -3525,16 +3821,9 @@ exports[`CreateVaultModal component renders correctly 1`] = ` iconBefore={true} ink={ } onClick={[Function]} @@ -3598,16 +3887,9 @@ exports[`CreateVaultModal component renders correctly 1`] = ` flat={true} ink={ } onClick={[Function]} @@ -3622,16 +3904,9 @@ exports[`CreateVaultModal component renders correctly 1`] = ` iconBefore={true} ink={ } onClick={[Function]} diff --git a/packages/dapp/src/components/organisms/PreferencesForm/__snapshots__/PreferencesForm.test.js.snap b/packages/dapp/src/components/organisms/PreferencesForm/__snapshots__/PreferencesForm.test.js.snap index 6da7cf8e8..f5ac7d988 100644 --- a/packages/dapp/src/components/organisms/PreferencesForm/__snapshots__/PreferencesForm.test.js.snap +++ b/packages/dapp/src/components/organisms/PreferencesForm/__snapshots__/PreferencesForm.test.js.snap @@ -287,8 +287,8 @@ exports[`PreferencesForm component renders correctly 1`] = ` "GMT +10:30", "GMT +11:00", "GMT +12:00", - "GMT +12:45", "GMT +13:00", + "GMT +13:45", "GMT +14:00", ], } @@ -353,8 +353,8 @@ exports[`PreferencesForm component renders correctly 1`] = ` "GMT +10:30", "GMT +11:00", "GMT +12:00", - "GMT +12:45", "GMT +13:00", + "GMT +13:45", "GMT +14:00", ] } @@ -510,8 +510,8 @@ exports[`PreferencesForm component renders correctly 1`] = ` "GMT +10:30", "GMT +11:00", "GMT +12:00", - "GMT +12:45", "GMT +13:00", + "GMT +13:45", "GMT +14:00", ] } @@ -672,8 +672,8 @@ exports[`PreferencesForm component renders correctly 1`] = ` "GMT +10:30", "GMT +11:00", "GMT +12:00", - "GMT +12:45", "GMT +13:00", + "GMT +13:45", "GMT +14:00", ] } @@ -733,8 +733,8 @@ exports[`PreferencesForm component renders correctly 1`] = ` "GMT +10:30", "GMT +11:00", "GMT +12:00", - "GMT +12:45", "GMT +13:00", + "GMT +13:45", "GMT +14:00", ] } @@ -822,8 +822,8 @@ exports[`PreferencesForm component renders correctly 1`] = ` "GMT +10:30", "GMT +11:00", "GMT +12:00", - "GMT +12:45", "GMT +13:00", + "GMT +13:45", "GMT +14:00", ] } @@ -877,7 +877,6 @@ exports[`PreferencesForm component renders correctly 1`] = ` active={false} activeLabel="" below={true} - className={undefined} dropdownIcon={ } error={false} - errorText={undefined} id="1" lineDirection="left" onBlur={[Function]} @@ -894,7 +892,6 @@ exports[`PreferencesForm component renders correctly 1`] = ` onClick={[Function]} onFocus={[Function]} placeholder={null} - style={undefined} transitionName="md-drop" transitionTime={300} value="+02:00" @@ -943,7 +940,6 @@ exports[`PreferencesForm component renders correctly 1`] = ` active={false} activeLabel="" below={true} - className={undefined} dropdownIcon={ } error={false} - errorText={undefined} id="1" lineDirection="left" onBlur={[Function]} @@ -960,7 +955,6 @@ exports[`PreferencesForm component renders correctly 1`] = ` onClick={[Function]} onFocus={[Function]} placeholder={null} - style={undefined} transitionName="md-drop" transitionTime={300} value="+02:00" @@ -1104,16 +1098,9 @@ exports[`PreferencesForm component renders correctly 1`] = ` id="1-toggle" ink={ } listenToEnter={true} @@ -1248,16 +1235,9 @@ exports[`PreferencesForm component renders correctly 1`] = ` flat={true} ink={ } onClick={[Function]} @@ -1272,16 +1252,9 @@ exports[`PreferencesForm component renders correctly 1`] = ` iconBefore={true} ink={ } onClick={[Function]} @@ -1345,16 +1318,9 @@ exports[`PreferencesForm component renders correctly 1`] = ` flat={true} ink={ } onClick={[Function]} @@ -1369,16 +1335,9 @@ exports[`PreferencesForm component renders correctly 1`] = ` iconBefore={true} ink={ } onClick={[Function]} diff --git a/packages/dapp/src/components/organisms/VaultFees/__snapshots__/VaultFees.test.js.snap b/packages/dapp/src/components/organisms/VaultFees/__snapshots__/VaultFees.test.js.snap index e1a539564..d55fda931 100644 --- a/packages/dapp/src/components/organisms/VaultFees/__snapshots__/VaultFees.test.js.snap +++ b/packages/dapp/src/components/organisms/VaultFees/__snapshots__/VaultFees.test.js.snap @@ -141,16 +141,9 @@ exports[`VaultFees component renders correctly as manager 1`] = ` flat={true} ink={ } onClick={[Function]} @@ -165,16 +158,9 @@ exports[`VaultFees component renders correctly as manager 1`] = ` iconBefore={true} ink={ } onClick={[Function]} diff --git a/packages/dapp/src/components/organisms/VaultPanel/__snapshots__/VaultPanel.test.js.snap b/packages/dapp/src/components/organisms/VaultPanel/__snapshots__/VaultPanel.test.js.snap index 37ab8cbd7..ce855d0e4 100644 --- a/packages/dapp/src/components/organisms/VaultPanel/__snapshots__/VaultPanel.test.js.snap +++ b/packages/dapp/src/components/organisms/VaultPanel/__snapshots__/VaultPanel.test.js.snap @@ -273,16 +273,9 @@ exports[`VaultPanel component renders correctly if vaults and transactions are p flat={true} ink={ } onClick={[Function]} @@ -297,16 +290,9 @@ exports[`VaultPanel component renders correctly if vaults and transactions are p iconBefore={true} ink={ } onClick={[Function]} @@ -4466,16 +4452,9 @@ exports[`VaultPanel component renders correctly if vaults are present but no tra flat={true} ink={ } onClick={[Function]} @@ -4490,16 +4469,9 @@ exports[`VaultPanel component renders correctly if vaults are present but no tra iconBefore={true} ink={ } onClick={[Function]} diff --git a/packages/dapp/src/components/organisms/VaultSelect/__snapshots__/VaultSelect.test.js.snap b/packages/dapp/src/components/organisms/VaultSelect/__snapshots__/VaultSelect.test.js.snap index 8f452cdfd..26192f0ff 100644 --- a/packages/dapp/src/components/organisms/VaultSelect/__snapshots__/VaultSelect.test.js.snap +++ b/packages/dapp/src/components/organisms/VaultSelect/__snapshots__/VaultSelect.test.js.snap @@ -12,6 +12,12 @@ exports[`VaultSelect component redirects if no vaults are present but we try to [Function], ], ], + "results": Array [ + Object { + "isThrow": false, + "value": undefined, + }, + ], }, } } @@ -79,16 +85,9 @@ exports[`VaultSelect component redirects if no vaults are present but we try to flat={true} ink={ } onClick={[Function]} @@ -103,16 +102,9 @@ exports[`VaultSelect component redirects if no vaults are present but we try to iconBefore={true} ink={ } onClick={[Function]} @@ -174,6 +166,12 @@ exports[`VaultSelect component renders correctly 1`] = ` [Function], ], ], + "results": Array [ + Object { + "isThrow": false, + "value": undefined, + }, + ], }, } } @@ -230,16 +228,9 @@ exports[`VaultSelect component renders correctly 1`] = ` flat={true} ink={ } onClick={[Function]} @@ -254,16 +245,9 @@ exports[`VaultSelect component renders correctly 1`] = ` iconBefore={true} ink={ } onClick={[Function]} @@ -464,6 +448,12 @@ exports[`VaultSelect component renders correctly if there are no vaults on state [Function], ], ], + "results": Array [ + Object { + "isThrow": false, + "value": undefined, + }, + ], }, } } @@ -496,16 +486,9 @@ exports[`VaultSelect component renders correctly if there are no vaults on state flat={true} ink={ } onClick={[Function]} @@ -520,16 +503,9 @@ exports[`VaultSelect component renders correctly if there are no vaults on state iconBefore={true} ink={ } onClick={[Function]} diff --git a/packages/dapp/src/components/organisms/VaultTitle/__snapshots__/VaultTitle.test.js.snap b/packages/dapp/src/components/organisms/VaultTitle/__snapshots__/VaultTitle.test.js.snap index 46bf3097e..4f037b201 100644 --- a/packages/dapp/src/components/organisms/VaultTitle/__snapshots__/VaultTitle.test.js.snap +++ b/packages/dapp/src/components/organisms/VaultTitle/__snapshots__/VaultTitle.test.js.snap @@ -56,16 +56,9 @@ exports[`VaultTitle component renders correctly as investor 1`] = ` flat={true} ink={ } onClick={[Function]} @@ -80,16 +73,9 @@ exports[`VaultTitle component renders correctly as investor 1`] = ` iconBefore={true} ink={ } onClick={[Function]} @@ -153,16 +139,9 @@ exports[`VaultTitle component renders correctly as investor 1`] = ` flat={true} ink={ } onClick={[Function]} @@ -177,16 +156,9 @@ exports[`VaultTitle component renders correctly as investor 1`] = ` iconBefore={true} ink={ } onClick={[Function]} diff --git a/packages/dapp/src/contractFactory.js b/packages/dapp/src/contractFactory.js index 73f398c5b..80f021c0d 100644 --- a/packages/dapp/src/contractFactory.js +++ b/packages/dapp/src/contractFactory.js @@ -5,13 +5,13 @@ class ContractFactory { this.contractInstances = {} } - getInstance(name, address = api.contract[name].address) { + getInstance(name, address) { return this.contractInstances[name] && this.contractInstances[name][address] ? Promise.resolve(this.contractInstances[name][address]) : this.createInstance(name, address) } - async createInstance(name, address = api.contract[name].address) { + async createInstance(name, address) { this.contractInstances[name] = this.contractInstances[name] || {} this.contractInstances[name][address] = api.contract[ name diff --git a/packages/dapp/src/epics/blockChain/BlockChainService.js b/packages/dapp/src/epics/blockChain/BlockChainService.js index c6ec5d8b2..17fbc20af 100644 --- a/packages/dapp/src/epics/blockChain/BlockChainService.js +++ b/packages/dapp/src/epics/blockChain/BlockChainService.js @@ -14,6 +14,7 @@ import { fromPromise } from 'rxjs/observable/fromPromise' import { of } from 'rxjs/observable/of' import { timer } from 'rxjs/observable/timer' import { zip } from 'rxjs/observable/zip' +import api from '../../api' import blockChainActions from '../../actions/blockchain-actions' import contractFactory from '../../contractFactory' @@ -90,7 +91,10 @@ class BlockChainService { fetchVaultEvents(fromBlock, toBlock = 'latest') { fromBlock = fromBlock || 0 const allVaultEvents = fromPromise( - contractFactory.getInstance('VaultEventful'), + contractFactory.getInstance( + 'VaultEventful', + api.contract.VaultEventful.address + ), this.scheduler ) .mergeMap(vaultEventful => @@ -111,7 +115,10 @@ class BlockChainService { watchVaultEvents(fromBlock, toBlock = 'latest') { fromBlock = fromBlock || 0 const allVaultEvents = fromPromise( - contractFactory.getInstance('VaultEventful'), + contractFactory.getInstance( + 'VaultEventful', + api.contract.VaultEventful.address + ), this.scheduler ).mergeMap(vaultEventful => { return Observable.create(observer => { diff --git a/packages/dapp/src/epics/blockChain/BlockChainService.test.js b/packages/dapp/src/epics/blockChain/BlockChainService.test.js index e0a21e6d9..73f6d09ac 100644 --- a/packages/dapp/src/epics/blockChain/BlockChainService.test.js +++ b/packages/dapp/src/epics/blockChain/BlockChainService.test.js @@ -9,11 +9,12 @@ describe('blockChain services function', () => { let BlockChainService let fromPromiseSpy let apiMock + let contractFactoryMock const owner = '0x242B2Dd21e7E1a2b2516d0A3a06b58e2D9BF9196' const blocks = [ { address: '0x001', - args: { + returnValues: { vault: '0x123', from: owner, to: '0x005', @@ -23,8 +24,8 @@ describe('blockChain services function', () => { event: 'BuyVault' }, { - address: '0x001', - args: { + address: '0x002', + returnValues: { vault: '0x123', from: '0x242b2dd21e7e1a2b2516d0a3a06b58e2d9bf9192', to: '0x005', @@ -34,13 +35,11 @@ describe('blockChain services function', () => { event: 'SellVault' } ] - const stopWatchingMock = jest.fn() beforeEach(() => { fromPromiseSpy = jest.fn() - jest.resetModules() - jest.doMock('rxjs/observable/fromPromise', () => ({ - fromPromise: fromPromiseSpy - })) + contractFactoryMock = { + getInstance: jest.fn() + } apiMock = { init: () => Promise.resolve(), engine: { @@ -48,17 +47,24 @@ describe('blockChain services function', () => { removeListener: () => {} }, web3: { - getAvailableAddressesAsync: jest.fn(() => Promise.resolve([])), - getNodeVersionAsync: jest.fn(() => Promise.resolve('')), - getBlockTimestampAsync: jest.fn(() => Promise.resolve('1528811195')) + eth: { + getNodeInfo: jest.fn(() => Promise.resolve('')), + getAccounts: jest.fn(() => Promise.resolve([])), + getBlock: jest.fn(() => Promise.resolve({ timestamp: '1528811195' })) + } }, contract: { VaultEventful: { - createAndValidate: jest.fn() + address: '0x0' } } } - + jest.resetModules() + jest.doMock('rxjs/observable/fromPromise', () => ({ + fromPromise: fromPromiseSpy + })) + jest.doMock('../../contractFactory', () => contractFactoryMock) + jest.doMock('../../api', () => apiMock) BlockChainService = require('./BlockChainService').default }) describe('main observable flow', () => { @@ -241,19 +247,22 @@ describe('blockChain services function', () => { }) }) describe('utility functions', () => { + const unsubscribeMock = jest.fn() + const vaultEventful = { + getPastEvents: () => blocks, + allEvents: (opt, cb) => { + cb(null, blocks[0]) + return { + unsubscribe: unsubscribeMock + } + } + } describe('fetch vault events', () => { it('fetches blocks, filters them by account and saves them to state with a timestamp', () => { const blockWithTimestamp = { ...blocks[0], timestamp: 1528811195000 } - const vaultEventful = { - rawWeb3Contract: { - allEvents: () => ({ - get: cb => cb(null, blocks), - stopWatching: stopWatchingMock - }) - } - } fromPromiseSpy.mockReturnValueOnce(of(vaultEventful)) - fromPromiseSpy.mockReturnValueOnce(of('1528811195')) + fromPromiseSpy.mockReturnValueOnce(of(blocks)) + fromPromiseSpy.mockReturnValueOnce(of({ timestamp: '1528811195' })) const expectedValues = { a: blockChainActions.registerBlock({ account: owner, @@ -278,54 +287,13 @@ describe('blockChain services function', () => { ts.expectObservable(outputAction).toBe(expectedMarble, expectedValues) ts.flush() - expect(stopWatchingMock).toHaveBeenCalled() - }) - it('emits blockChainError if there is an error during fetch', () => { - const fetchError = new Error('error during fetch') - const vaultEventful = { - rawWeb3Contract: { - allEvents: () => ({ - get: cb => cb(fetchError, null), - stopWatching: stopWatchingMock - }) - } - } - fromPromiseSpy.mockReturnValueOnce(of(vaultEventful)) - const expectedValues = { - a: blockChainActions.blockChainError(fetchError.stack) - } - - const expectedMarble = '(a|)' - - const ts = new TestScheduler((actual, expected) => { - expect(actual).toEqual(expected) - }) - - const blockChainService = new BlockChainService(apiMock, null, null, ts) - - blockChainService.account = owner - blockChainService.accounts.add(owner) - - const outputAction = blockChainService.fetchVaultEvents() - - ts.expectObservable(outputAction).toBe(expectedMarble, expectedValues) - ts.flush() - expect(stopWatchingMock).toHaveBeenCalled() }) }) describe('watch vault events', () => { it('watches for new blocks, filters them by account and saves them to state with a timestamp', () => { const blockWithTimestamp = { ...blocks[0], timestamp: 1528811195000 } - const vaultEventful = { - rawWeb3Contract: { - allEvents: () => ({ - watch: cb => cb(null, blocks[0]), - stopWatching: stopWatchingMock - }) - } - } fromPromiseSpy.mockReturnValueOnce(of(vaultEventful)) - fromPromiseSpy.mockReturnValueOnce(of('1528811195')) + fromPromiseSpy.mockReturnValueOnce(of({ timestamp: '1528811195' })) const expectedValues = { a: blockChainActions.registerBlock({ account: owner, @@ -352,19 +320,20 @@ describe('blockChain services function', () => { const subscription = outputAction.subscribe() subscription.unsubscribe() - expect(stopWatchingMock).toHaveBeenCalled() + expect(unsubscribeMock).toHaveBeenCalled() }) it('emits blockChainError if there is an error during watch', () => { const fetchError = new Error('error during watch') - const vaultEventful = { - rawWeb3Contract: { - allEvents: () => ({ - watch: cb => cb(fetchError, null), - stopWatching: stopWatchingMock - }) + const errorVaultEventful = { + ...vaultEventful, + allEvents: (opt, cb) => { + cb(fetchError, null) + return { + unsubscribe: unsubscribeMock + } } } - fromPromiseSpy.mockReturnValueOnce(of(vaultEventful)) + fromPromiseSpy.mockReturnValueOnce(of(errorVaultEventful)) const expectedValues = { a: blockChainActions.blockChainError(fetchError.stack) } @@ -377,14 +346,11 @@ describe('blockChain services function', () => { const blockChainService = new BlockChainService(apiMock, null, null, ts) - blockChainService.account = owner - blockChainService.accounts.add(owner) - const outputAction = blockChainService.watchVaultEvents() ts.expectObservable(outputAction).toBe(expectedMarble, expectedValues) ts.flush() - expect(stopWatchingMock).toHaveBeenCalled() + expect(unsubscribeMock).toHaveBeenCalled() }) }) describe('createInstance/getInstance functions', () => { diff --git a/packages/dapp/src/epics/blockChain/getAccountBalance.js b/packages/dapp/src/epics/blockChain/getAccountBalance.js index ab9e17abd..467d92e67 100644 --- a/packages/dapp/src/epics/blockChain/getAccountBalance.js +++ b/packages/dapp/src/epics/blockChain/getAccountBalance.js @@ -3,6 +3,7 @@ import 'rxjs/add/operator/filter' import 'rxjs/add/operator/groupBy' import 'rxjs/add/operator/merge' import 'rxjs/add/operator/mergeMap' +import { BigNumber } from 'bignumber.js' import { Scheduler } from 'rxjs/Scheduler' import { fromPromise } from 'rxjs/observable/fromPromise' import { merge } from 'rxjs/observable/merge' @@ -25,7 +26,10 @@ export const getAccountBalanceEpic = (action$, store, ts = Scheduler.async) => { return merge(action$1, action$2).mergeMap(({ payload: { account } }) => { return fromPromise(api.web3.eth.getBalance(account), ts).map(balance => - blockChainActions.updateAccountBalance({ account, balance }) + blockChainActions.updateAccountBalance({ + account, + balance: new BigNumber(balance) + }) ) }) } diff --git a/packages/dapp/src/epics/blockChain/getAccountBalance.test.js b/packages/dapp/src/epics/blockChain/getAccountBalance.test.js index 03422efec..5e0cda228 100644 --- a/packages/dapp/src/epics/blockChain/getAccountBalance.test.js +++ b/packages/dapp/src/epics/blockChain/getAccountBalance.test.js @@ -1,5 +1,5 @@ import { ActionsObservable } from 'redux-observable' -import { ETH_TO_WEI } from '../../constants/utils' +import { BigNumber } from 'bignumber.js' import { TestScheduler } from 'rxjs' import { VAULT } from '../../constants/blockchain' import { of } from 'rxjs/observable/of' @@ -11,10 +11,9 @@ describe('getAccountBalanceEpic', () => { const getBalanceSpy = jest.fn() const apiMock = { web3: { - _web3: { - fromWei: val => val / ETH_TO_WEI - }, - getBalanceInWeiAsync: getBalanceSpy + eth: { + getBalance: getBalanceSpy + } } } const vaultEvent = { @@ -53,7 +52,7 @@ describe('getAccountBalanceEpic', () => { const expectedValues = { b: blockChainActions.updateAccountBalance({ account: owner, - balance: '25999999999952600000' + balance: new BigNumber('25999999999952600000') }) } @@ -87,7 +86,7 @@ describe('getAccountBalanceEpic', () => { const expectedValues = { b: blockChainActions.updateAccountBalance({ account: owner, - balance: '10000000000000000000' + balance: new BigNumber('10000000000000000000') }) } @@ -126,11 +125,11 @@ describe('getAccountBalanceEpic', () => { const expectedValues = { a: blockChainActions.updateAccountBalance({ account: owner, - balance: '10000000000000000000' + balance: new BigNumber('10000000000000000000') }), b: blockChainActions.updateAccountBalance({ account: owner, - balance: '20000000000000000000' + balance: new BigNumber('20000000000000000000') }) } @@ -178,19 +177,19 @@ describe('getAccountBalanceEpic', () => { const expectedValues = { a: blockChainActions.updateAccountBalance({ account: owner, - balance: '10000000000000000000' + balance: new BigNumber('10000000000000000000') }), b: blockChainActions.updateAccountBalance({ account: owner, - balance: '20000000000000000000' + balance: new BigNumber('20000000000000000000') }), c: blockChainActions.updateAccountBalance({ account: otherAccount, - balance: '15000000000000000000' + balance: new BigNumber('15000000000000000000') }), d: blockChainActions.updateAccountBalance({ account: otherAccount, - balance: '25000000000000000000' + balance: new BigNumber('25000000000000000000') }) } diff --git a/packages/dapp/src/epics/routing/selectFirstVault.test.js b/packages/dapp/src/epics/routing/selectFirstVault.test.js index 4cf4d5476..11c26a271 100644 --- a/packages/dapp/src/epics/routing/selectFirstVault.test.js +++ b/packages/dapp/src/epics/routing/selectFirstVault.test.js @@ -16,7 +16,9 @@ describe('selectFirstVault Epic', () => { const apiMock = { web3: { - getAvailableAddressesAsync: () => {} + eth: { + getAccounts: () => {} + } } } let fromPromiseSpy diff --git a/packages/dapp/src/epics/routing/vaultInvalid.test.js b/packages/dapp/src/epics/routing/vaultInvalid.test.js index 55a990c6a..f03e7acaf 100644 --- a/packages/dapp/src/epics/routing/vaultInvalid.test.js +++ b/packages/dapp/src/epics/routing/vaultInvalid.test.js @@ -15,7 +15,9 @@ describe('vaultInvalid Epic', () => { const apiMock = { web3: { - getAvailableAddressesAsync: () => {} + eth: { + getAccounts: () => {} + } } } let fromPromiseSpy diff --git a/packages/dapp/src/epics/vaults/createVault.js b/packages/dapp/src/epics/vaults/createVault.js index 40eaaace1..9d51a7ff7 100644 --- a/packages/dapp/src/epics/vaults/createVault.js +++ b/packages/dapp/src/epics/vaults/createVault.js @@ -8,6 +8,7 @@ import { Scheduler } from 'rxjs/Scheduler' import { fromPromise } from 'rxjs/observable/fromPromise' import { merge } from 'rxjs/observable/merge' import { of } from 'rxjs/observable/of' +import api from '../../api' import blockChainActions from '../../actions/blockchain-actions' import contractFactory from '../../contractFactory' import vaultActions from '../../actions/vault-actions' @@ -22,25 +23,30 @@ const createVaultEpic = (action$, store, ts = Scheduler.async) => { const action$2 = source.mergeMap( ({ payload: { accountNumber, vaultName, vaultSymbol } }) => - fromPromise(contractFactory.getInstance('VaultFactory'), ts).switchMap( - vaultFactory => - of(vaultFactory) - .mergeMap(() => - fromPromise( - vaultFactory - .createVault(vaultName.toLowerCase(), vaultSymbol) - .then(obj => - obj.send({ from: accountNumber, gasPrice: 1, gas: 6654755 }) - ), - ts - ).map(txHash => - blockChainActions.transactionCompleted({ - type: CREATE_VAULT, - txHash - }) - ) + fromPromise( + contractFactory.getInstance( + 'VaultFactory', + api.contract.VaultFactory.address + ), + ts + ).switchMap(vaultFactory => + of(vaultFactory) + .mergeMap(() => + fromPromise( + vaultFactory + .createVault(vaultName.toLowerCase(), vaultSymbol) + .then(obj => + obj.send({ from: accountNumber, gasPrice: 1, gas: 6654755 }) + ), + ts + ).map(txHash => + blockChainActions.transactionCompleted({ + type: CREATE_VAULT, + txHash + }) ) - .catch(e => of(blockChainActions.transactionFailed(e.toString()))) + ) + .catch(e => of(blockChainActions.transactionFailed(e.toString()))) ) ) diff --git a/packages/dapp/src/epics/vaults/createVault.test.js b/packages/dapp/src/epics/vaults/createVault.test.js index c1756ceab..3b3238844 100644 --- a/packages/dapp/src/epics/vaults/createVault.test.js +++ b/packages/dapp/src/epics/vaults/createVault.test.js @@ -18,12 +18,11 @@ describe('createVault Epic', () => { const mockStore = { getState: getStateMock } + let contractFactoryMock class VaultFactoryMock { - createVaultTx() { - return { - send: jest.fn() - } + createVault() { + return Promise.resolve({ send: () => {} }) } } @@ -33,8 +32,7 @@ describe('createVault Epic', () => { }, contract: { VaultFactory: { - address: '0x123123123', - createAndValidate: () => {} + address: '0x0' } } } @@ -45,9 +43,13 @@ describe('createVault Epic', () => { beforeEach(() => { jest.resetModules() fromPromiseSpy = jest.fn() + contractFactoryMock = { + getInstance: jest.fn() + } jest.doMock('rxjs/observable/fromPromise', () => ({ fromPromise: fromPromiseSpy })) + jest.doMock('../../contractFactory', () => contractFactoryMock) jest.doMock('../../api', () => apiMock) createVaultEpic = require('./createVault').default }) diff --git a/packages/dapp/src/epics/vaults/getVaultFees.test.js b/packages/dapp/src/epics/vaults/getVaultFees.test.js index 01c87c922..5cba83ce4 100644 --- a/packages/dapp/src/epics/vaults/getVaultFees.test.js +++ b/packages/dapp/src/epics/vaults/getVaultFees.test.js @@ -7,8 +7,14 @@ import vaultActions from '../../actions/vault-actions' describe('getVaultFees epics', () => { const owner = '0x242B2Dd21e7E1a2b2516d0A3a06b58e2D9BF9196' const vaultAddress = '0x86a1ba4d485ce346bded508e2426798f825558be' - const transactionFee = new BigNumber('1') - const vaultData = ['0x123', '0x123', '0x123', '1', transactionFee] + const transactionFee = '1' + const vaultData = { + feeCollector: '0x7328eF1d7Ab7583Eb9968B2f4a9c900f8a2e2d6d', + minPeriod: '0', + ratio: '80', + transactionFee, + vaultDao: '0x7ce6e371085cb611fb46d5065397223ef2F952Ff' + } let fromPromiseSpy let getVaultFees @@ -58,7 +64,7 @@ describe('getVaultFees epics', () => { account: owner, vaultData: { address: vaultAddress, - data: { transactionFee } + data: { transactionFee: new BigNumber(transactionFee) } } }) } diff --git a/packages/dapp/src/epics/vaults/getVaultSupply.test.js b/packages/dapp/src/epics/vaults/getVaultSupply.test.js index 0db8f752e..4b5f2cc6b 100644 --- a/packages/dapp/src/epics/vaults/getVaultSupply.test.js +++ b/packages/dapp/src/epics/vaults/getVaultSupply.test.js @@ -8,9 +8,10 @@ import vaultActions from '../../actions/vault-actions' describe('getVaultSupply epics', () => { const owner = '0x242B2Dd21e7E1a2b2516d0A3a06b58e2D9BF9196' const vaultAddress = '0x86a1ba4d485ce346bded508e2426798f825558be' - const supply = new BigNumber('14000000') + const supply = '14000000' let fromPromiseSpy let getVaultSupply + let contractFactoryMock const vault = { [vaultAddress]: { @@ -23,25 +24,26 @@ describe('getVaultSupply epics', () => { } class VaultMock { - totalSupply + totalSupply() { + return supply + } } const apiMock = { web3: { _web3: {} - }, - contract: { - Vault: { - createAndValidate: () => VaultMock - } } } beforeEach(() => { + contractFactoryMock = { + getInstance: jest.fn() + } fromPromiseSpy = jest.fn() jest.resetModules() jest.doMock('rxjs/observable/fromPromise', () => ({ fromPromise: fromPromiseSpy })) + jest.doMock('../../contractFactory', () => contractFactoryMock) jest.doMock('../../api', () => apiMock) getVaultSupply = require('./getVaultSupply').default }) @@ -57,7 +59,7 @@ describe('getVaultSupply epics', () => { account: owner, vaultData: { address: vaultAddress, - data: { totalSupply: supply.times(MICRO_TO_WEI) } + data: { totalSupply: new BigNumber(supply).times(MICRO_TO_WEI) } } }) } diff --git a/packages/dapp/src/epics/vaults/getVaultTransactions.test.js b/packages/dapp/src/epics/vaults/getVaultTransactions.test.js index 24b3a5b16..6c90664f1 100644 --- a/packages/dapp/src/epics/vaults/getVaultTransactions.test.js +++ b/packages/dapp/src/epics/vaults/getVaultTransactions.test.js @@ -1,4 +1,5 @@ import { ActionsObservable } from 'redux-observable' +import { BigNumber } from 'bignumber.js' import { DEPOSIT, ETH, WITHDRAW } from '../../constants/blockchain' import { TestScheduler } from 'rxjs' import getVaultTransactions from './getVaultTransactions' @@ -17,7 +18,7 @@ describe('getVaultTransactions epic', () => { address: '0x6dddcaede2071883c85c6e5781524985608d2460', type: 'mined', event: 'BuyVault', - args: { + returnValues: { vault: '0x03910164aa522fb1a68bebea515e54610e4a9b94', from: '0x8bb7481495d45ccd5cffae1c3a84155fea85a323', to: '0x03910164aa522fb1a68bebea515e54610e4a9b94', @@ -32,7 +33,7 @@ describe('getVaultTransactions epic', () => { const sellVaultEvent = { ...buyVaultEvent, event: 'SellVault', - args: { + returnValues: { vault: '0x03910164aa522fb1a68bebea515e54610e4a9b94', from: '0x8bb7481495d45ccd5cffae1c3a84155fea85a323', to: '0x03910164aa522fb1a68bebea515e54610e4a9b94', @@ -50,7 +51,7 @@ describe('getVaultTransactions epic', () => { date: 1530698497000, type: DEPOSIT, symbol: ETH, - value: '3000000000000000000', + value: new BigNumber('3000000000000000000'), units: '3000000', account: '0x8bb7481495d45ccd5cffae1c3a84155fea85a323' } @@ -62,7 +63,7 @@ describe('getVaultTransactions epic', () => { date: 1530698497000, type: WITHDRAW, symbol: ETH, - value: '3000000000000000000', + value: new BigNumber('3000000000000000000'), units: '3000000', account: '0x8bb7481495d45ccd5cffae1c3a84155fea85a323' } diff --git a/packages/dapp/src/epics/vaults/registerVaults.js b/packages/dapp/src/epics/vaults/registerVaults.js index 2b9e90101..df0531a4d 100644 --- a/packages/dapp/src/epics/vaults/registerVaults.js +++ b/packages/dapp/src/epics/vaults/registerVaults.js @@ -5,6 +5,7 @@ import { Scheduler } from 'rxjs/Scheduler' import { VAULT } from '../../constants/blockchain' import { fromPromise } from 'rxjs/observable/fromPromise' import { merge } from 'rxjs/observable/merge' +import api from '../../api' import blockChainActions from '../../actions/blockchain-actions' import contractFactory from '../../contractFactory' import vaultActions from '../../actions/vault-actions' @@ -24,17 +25,18 @@ const registerVaultsEpic = (action$, store, ts = Scheduler.async) => { const action$2 = vaultBlock$ .mergeMap(action => - fromPromise(contractFactory.getInstance('DragoRegistry')).mergeMap( - registry => { - const address = action.payload.block.returnValues.vault - const account = action.payload.account - return fromPromise(registry.fromAddress(address), ts).map( - vaultData => { - return { account, address, vaultData } - } - ) - } - ) + fromPromise( + contractFactory.getInstance( + 'DragoRegistry', + api.contract.DragoRegistry.address + ) + ).mergeMap(registry => { + const address = action.payload.block.returnValues.vault + const account = action.payload.account + return fromPromise(registry.fromAddress(address), ts).map( + vaultData => ({ account, address, vaultData }) + ) + }) ) .map( ({ account, address, vaultData: { id, name, symbol, owner, group } }) => diff --git a/packages/dapp/src/epics/vaults/registerVaults.test.js b/packages/dapp/src/epics/vaults/registerVaults.test.js index 40aa233df..387f31628 100644 --- a/packages/dapp/src/epics/vaults/registerVaults.test.js +++ b/packages/dapp/src/epics/vaults/registerVaults.test.js @@ -1,5 +1,4 @@ import { ActionsObservable } from 'redux-observable' -import { BigNumber } from 'bignumber.js' import { TestScheduler } from 'rxjs' import { VAULT } from '../../constants/blockchain' import { of } from 'rxjs/observable/of' @@ -10,7 +9,7 @@ describe('registerVaults epic', () => { const owner = '0x242B2Dd21e7E1a2b2516d0A3a06b58e2D9BF9196' const vaultEvent = { address: '0x001', - args: { + returnValues: { vault: '0xc1Eba7b6F9f06E4491a499E653878464e40AB70e', from: owner, to: '0x005', @@ -19,14 +18,14 @@ describe('registerVaults epic', () => { }, event: 'BuyVault' } - const vaultData = [ - new BigNumber('0'), - 'Rocksolid Vault', - 'VLT', + const vaultData = { + dragoId: '0', + group: '0x7ce6e371085cb611fb46d5065397223ef2F952Ff', + id: '0', + name: 'Rocksolid Vault', owner, - owner, - null - ] + symbol: 'VLT' + } class RegistryMock { fromAddress() { @@ -39,21 +38,23 @@ describe('registerVaults epic', () => { address: '0xf7cbb0849d4a8ec5ab4650030fa776c00eb52la4', createAndValidate: jest.fn() } - }, - web3: { - '._web3': {} } } let fromPromiseSpy let registerVaults + let contractFactoryMock beforeEach(() => { jest.resetModules() fromPromiseSpy = jest.fn() + contractFactoryMock = { + getInstance: jest.fn() + } jest.doMock('../../api', () => apiMock) jest.doMock('rxjs/observable/fromPromise', () => ({ fromPromise: fromPromiseSpy })) + jest.doMock('../../contractFactory', () => contractFactoryMock) registerVaults = require('./registerVaults').default }) @@ -80,7 +81,7 @@ describe('registerVaults epic', () => { vaultData: { ['0xc1Eba7b6F9f06E4491a499E653878464e40AB70e']: { id: 0, - group: null, + group: '0x7ce6e371085cb611fb46d5065397223ef2F952Ff', name: 'Rocksolid Vault', symbol: 'VLT', owner diff --git a/packages/dapp/test/features/vaults.test.js b/packages/dapp/test/features/vaults.test.js index 01f6b5f10..0e94954f3 100644 --- a/packages/dapp/test/features/vaults.test.js +++ b/packages/dapp/test/features/vaults.test.js @@ -1,7 +1,6 @@ -Feature('Vaults') -// .retry(3) +Feature('Vaults').retry(3) -const account = '0x242b2dd21e7e1a2b2516d0a3a06b58e2d9bf9196' +const account = '0x242B2Dd21e7E1a2b2516d0A3a06b58e2D9BF9196' Scenario('test correct vaults render', vaults => { vaults.navigateTo() diff --git a/yarn.lock b/yarn.lock index 26df19270..db0fc5d2a 100644 --- a/yarn.lock +++ b/yarn.lock @@ -445,6 +445,25 @@ dependencies: "@babel/highlight" "^7.0.0" +"@babel/core@7.1.2": + version "7.1.2" + resolved "https://registry.yarnpkg.com/@babel/core/-/core-7.1.2.tgz#f8d2a9ceb6832887329a7b60f9d035791400ba4e" + dependencies: + "@babel/code-frame" "^7.0.0" + "@babel/generator" "^7.1.2" + "@babel/helpers" "^7.1.2" + "@babel/parser" "^7.1.2" + "@babel/template" "^7.1.2" + "@babel/traverse" "^7.1.0" + "@babel/types" "^7.1.2" + convert-source-map "^1.1.0" + debug "^3.1.0" + json5 "^0.5.0" + lodash "^4.17.10" + resolve "^1.3.2" + semver "^5.4.1" + source-map "^0.5.0" + "@babel/core@^7.0.0-beta.54", "@babel/core@^7.0.0-beta.55", "@babel/core@^7.0.0-rc.1": version "7.0.0" resolved "https://registry.yarnpkg.com/@babel/core/-/core-7.0.0.tgz#0cb0c0fd2e78a0a2bec97698f549ae9ce0b99515" @@ -484,6 +503,16 @@ source-map "^0.5.0" trim-right "^1.0.1" +"@babel/generator@^7.1.2": + version "7.1.2" + resolved "https://registry.yarnpkg.com/@babel/generator/-/generator-7.1.2.tgz#fde75c072575ce7abbd97322e8fef5bae67e4630" + dependencies: + "@babel/types" "^7.1.2" + jsesc "^2.5.1" + lodash "^4.17.10" + source-map "^0.5.0" + trim-right "^1.0.1" + "@babel/helper-annotate-as-pure@^7.0.0": version "7.0.0" resolved "https://registry.yarnpkg.com/@babel/helper-annotate-as-pure/-/helper-annotate-as-pure-7.0.0.tgz#323d39dd0b50e10c7c06ca7d7638e6864d8c5c32" @@ -497,6 +526,20 @@ "@babel/helper-explode-assignable-expression" "^7.0.0" "@babel/types" "^7.0.0" +"@babel/helper-builder-binary-assignment-operator-visitor@^7.1.0": + version "7.1.0" + resolved "https://registry.yarnpkg.com/@babel/helper-builder-binary-assignment-operator-visitor/-/helper-builder-binary-assignment-operator-visitor-7.1.0.tgz#6b69628dfe4087798e0c4ed98e3d4a6b2fbd2f5f" + dependencies: + "@babel/helper-explode-assignable-expression" "^7.1.0" + "@babel/types" "^7.0.0" + +"@babel/helper-builder-react-jsx@^7.0.0": + version "7.0.0" + resolved "https://registry.yarnpkg.com/@babel/helper-builder-react-jsx/-/helper-builder-react-jsx-7.0.0.tgz#fa154cb53eb918cf2a9a7ce928e29eb649c5acdb" + dependencies: + "@babel/types" "^7.0.0" + esutils "^2.0.0" + "@babel/helper-call-delegate@^7.0.0": version "7.0.0" resolved "https://registry.yarnpkg.com/@babel/helper-call-delegate/-/helper-call-delegate-7.0.0.tgz#e036956bb33d76e59c07a04a1fff144e9f62ab78" @@ -505,6 +548,14 @@ "@babel/traverse" "^7.0.0" "@babel/types" "^7.0.0" +"@babel/helper-call-delegate@^7.1.0": + version "7.1.0" + resolved "https://registry.yarnpkg.com/@babel/helper-call-delegate/-/helper-call-delegate-7.1.0.tgz#6a957f105f37755e8645343d3038a22e1449cc4a" + dependencies: + "@babel/helper-hoist-variables" "^7.0.0" + "@babel/traverse" "^7.1.0" + "@babel/types" "^7.0.0" + "@babel/helper-define-map@^7.0.0": version "7.0.0" resolved "https://registry.yarnpkg.com/@babel/helper-define-map/-/helper-define-map-7.0.0.tgz#a5684dd2adf30f0137cf9b0bde436f8c2db17225" @@ -513,6 +564,14 @@ "@babel/types" "^7.0.0" lodash "^4.17.10" +"@babel/helper-define-map@^7.1.0": + version "7.1.0" + resolved "https://registry.yarnpkg.com/@babel/helper-define-map/-/helper-define-map-7.1.0.tgz#3b74caec329b3c80c116290887c0dd9ae468c20c" + dependencies: + "@babel/helper-function-name" "^7.1.0" + "@babel/types" "^7.0.0" + lodash "^4.17.10" + "@babel/helper-explode-assignable-expression@^7.0.0": version "7.0.0" resolved "https://registry.yarnpkg.com/@babel/helper-explode-assignable-expression/-/helper-explode-assignable-expression-7.0.0.tgz#fdfa4c88603ae3e954d0fc3244d5ca82fb468497" @@ -520,6 +579,13 @@ "@babel/traverse" "^7.0.0" "@babel/types" "^7.0.0" +"@babel/helper-explode-assignable-expression@^7.1.0": + version "7.1.0" + resolved "https://registry.yarnpkg.com/@babel/helper-explode-assignable-expression/-/helper-explode-assignable-expression-7.1.0.tgz#537fa13f6f1674df745b0c00ec8fe4e99681c8f6" + dependencies: + "@babel/traverse" "^7.1.0" + "@babel/types" "^7.0.0" + "@babel/helper-function-name@7.0.0-beta.44": version "7.0.0-beta.44" resolved "http://registry.npmjs.org/@babel/helper-function-name/-/helper-function-name-7.0.0-beta.44.tgz#e18552aaae2231100a6e485e03854bc3532d44dd" @@ -536,6 +602,14 @@ "@babel/template" "^7.0.0" "@babel/types" "^7.0.0" +"@babel/helper-function-name@^7.1.0": + version "7.1.0" + resolved "https://registry.yarnpkg.com/@babel/helper-function-name/-/helper-function-name-7.1.0.tgz#a0ceb01685f73355d4360c1247f582bfafc8ff53" + dependencies: + "@babel/helper-get-function-arity" "^7.0.0" + "@babel/template" "^7.1.0" + "@babel/types" "^7.0.0" + "@babel/helper-get-function-arity@7.0.0-beta.44": version "7.0.0-beta.44" resolved "http://registry.npmjs.org/@babel/helper-get-function-arity/-/helper-get-function-arity-7.0.0-beta.44.tgz#d03ca6dd2b9f7b0b1e6b32c56c72836140db3a15" @@ -577,6 +651,17 @@ "@babel/types" "^7.0.0" lodash "^4.17.10" +"@babel/helper-module-transforms@^7.1.0": + version "7.1.0" + resolved "https://registry.yarnpkg.com/@babel/helper-module-transforms/-/helper-module-transforms-7.1.0.tgz#470d4f9676d9fad50b324cdcce5fbabbc3da5787" + dependencies: + "@babel/helper-module-imports" "^7.0.0" + "@babel/helper-simple-access" "^7.1.0" + "@babel/helper-split-export-declaration" "^7.0.0" + "@babel/template" "^7.1.0" + "@babel/types" "^7.0.0" + lodash "^4.17.10" + "@babel/helper-optimise-call-expression@^7.0.0": version "7.0.0" resolved "https://registry.yarnpkg.com/@babel/helper-optimise-call-expression/-/helper-optimise-call-expression-7.0.0.tgz#a2920c5702b073c15de51106200aa8cad20497d5" @@ -603,6 +688,16 @@ "@babel/traverse" "^7.0.0" "@babel/types" "^7.0.0" +"@babel/helper-remap-async-to-generator@^7.1.0": + version "7.1.0" + resolved "https://registry.yarnpkg.com/@babel/helper-remap-async-to-generator/-/helper-remap-async-to-generator-7.1.0.tgz#361d80821b6f38da75bd3f0785ece20a88c5fe7f" + dependencies: + "@babel/helper-annotate-as-pure" "^7.0.0" + "@babel/helper-wrap-function" "^7.1.0" + "@babel/template" "^7.1.0" + "@babel/traverse" "^7.1.0" + "@babel/types" "^7.0.0" + "@babel/helper-replace-supers@^7.0.0": version "7.0.0" resolved "https://registry.yarnpkg.com/@babel/helper-replace-supers/-/helper-replace-supers-7.0.0.tgz#b6f21237280e0be54f591f63a464b66627ced707" @@ -612,6 +707,15 @@ "@babel/traverse" "^7.0.0" "@babel/types" "^7.0.0" +"@babel/helper-replace-supers@^7.1.0": + version "7.1.0" + resolved "https://registry.yarnpkg.com/@babel/helper-replace-supers/-/helper-replace-supers-7.1.0.tgz#5fc31de522ec0ef0899dc9b3e7cf6a5dd655f362" + dependencies: + "@babel/helper-member-expression-to-functions" "^7.0.0" + "@babel/helper-optimise-call-expression" "^7.0.0" + "@babel/traverse" "^7.1.0" + "@babel/types" "^7.0.0" + "@babel/helper-simple-access@^7.0.0": version "7.0.0" resolved "https://registry.yarnpkg.com/@babel/helper-simple-access/-/helper-simple-access-7.0.0.tgz#ff36a27983ae4c27122da2f7f294dced80ecbd08" @@ -619,6 +723,13 @@ "@babel/template" "^7.0.0" "@babel/types" "^7.0.0" +"@babel/helper-simple-access@^7.1.0": + version "7.1.0" + resolved "https://registry.yarnpkg.com/@babel/helper-simple-access/-/helper-simple-access-7.1.0.tgz#65eeb954c8c245beaa4e859da6188f39d71e585c" + dependencies: + "@babel/template" "^7.1.0" + "@babel/types" "^7.0.0" + "@babel/helper-split-export-declaration@7.0.0-beta.44": version "7.0.0-beta.44" resolved "http://registry.npmjs.org/@babel/helper-split-export-declaration/-/helper-split-export-declaration-7.0.0-beta.44.tgz#c0b351735e0fbcb3822c8ad8db4e583b05ebd9dc" @@ -640,6 +751,15 @@ "@babel/traverse" "^7.0.0" "@babel/types" "^7.0.0" +"@babel/helper-wrap-function@^7.1.0": + version "7.1.0" + resolved "https://registry.yarnpkg.com/@babel/helper-wrap-function/-/helper-wrap-function-7.1.0.tgz#8cf54e9190706067f016af8f75cb3df829cc8c66" + dependencies: + "@babel/helper-function-name" "^7.1.0" + "@babel/template" "^7.1.0" + "@babel/traverse" "^7.1.0" + "@babel/types" "^7.0.0" + "@babel/helpers@^7.0.0": version "7.0.0" resolved "https://registry.yarnpkg.com/@babel/helpers/-/helpers-7.0.0.tgz#7213388341eeb07417f44710fd7e1d00acfa6ac0" @@ -648,6 +768,14 @@ "@babel/traverse" "^7.0.0" "@babel/types" "^7.0.0" +"@babel/helpers@^7.1.2": + version "7.1.2" + resolved "https://registry.yarnpkg.com/@babel/helpers/-/helpers-7.1.2.tgz#ab752e8c35ef7d39987df4e8586c63b8846234b5" + dependencies: + "@babel/template" "^7.1.2" + "@babel/traverse" "^7.1.0" + "@babel/types" "^7.1.2" + "@babel/highlight@7.0.0-beta.44": version "7.0.0-beta.44" resolved "http://registry.npmjs.org/@babel/highlight/-/highlight-7.0.0-beta.44.tgz#18c94ce543916a80553edcdcf681890b200747d5" @@ -672,6 +800,10 @@ version "7.0.0" resolved "https://registry.yarnpkg.com/@babel/parser/-/parser-7.0.0.tgz#697655183394facffb063437ddf52c0277698775" +"@babel/parser@^7.1.0", "@babel/parser@^7.1.2": + version "7.1.2" + resolved "https://registry.yarnpkg.com/@babel/parser/-/parser-7.1.2.tgz#85c5c47af6d244fab77bce6b9bd830e38c978409" + "@babel/plugin-proposal-async-generator-functions@^7.0.0": version "7.0.0" resolved "https://registry.yarnpkg.com/@babel/plugin-proposal-async-generator-functions/-/plugin-proposal-async-generator-functions-7.0.0.tgz#5d1eb6b44fd388b97f964350007ab9da090b1d70" @@ -680,6 +812,25 @@ "@babel/helper-remap-async-to-generator" "^7.0.0" "@babel/plugin-syntax-async-generators" "^7.0.0" +"@babel/plugin-proposal-async-generator-functions@^7.1.0": + version "7.1.0" + resolved "https://registry.yarnpkg.com/@babel/plugin-proposal-async-generator-functions/-/plugin-proposal-async-generator-functions-7.1.0.tgz#41c1a702e10081456e23a7b74d891922dd1bb6ce" + dependencies: + "@babel/helper-plugin-utils" "^7.0.0" + "@babel/helper-remap-async-to-generator" "^7.1.0" + "@babel/plugin-syntax-async-generators" "^7.0.0" + +"@babel/plugin-proposal-class-properties@7.1.0": + version "7.1.0" + resolved "https://registry.yarnpkg.com/@babel/plugin-proposal-class-properties/-/plugin-proposal-class-properties-7.1.0.tgz#9af01856b1241db60ec8838d84691aa0bd1e8df4" + dependencies: + "@babel/helper-function-name" "^7.1.0" + "@babel/helper-member-expression-to-functions" "^7.0.0" + "@babel/helper-optimise-call-expression" "^7.0.0" + "@babel/helper-plugin-utils" "^7.0.0" + "@babel/helper-replace-supers" "^7.1.0" + "@babel/plugin-syntax-class-properties" "^7.0.0" + "@babel/plugin-proposal-class-properties@^7.0.0-beta.55", "@babel/plugin-proposal-class-properties@^7.0.0-rc.1": version "7.0.0" resolved "https://registry.yarnpkg.com/@babel/plugin-proposal-class-properties/-/plugin-proposal-class-properties-7.0.0.tgz#a16b5c076ba6c3d87df64d2480a380e979543731" @@ -744,6 +895,12 @@ dependencies: "@babel/helper-plugin-utils" "^7.0.0" +"@babel/plugin-syntax-jsx@7.0.0", "@babel/plugin-syntax-jsx@^7.0.0": + version "7.0.0" + resolved "https://registry.yarnpkg.com/@babel/plugin-syntax-jsx/-/plugin-syntax-jsx-7.0.0.tgz#034d5e2b4e14ccaea2e4c137af7e4afb39375ffd" + dependencies: + "@babel/helper-plugin-utils" "^7.0.0" + "@babel/plugin-syntax-object-rest-spread@^7.0.0": version "7.0.0" resolved "https://registry.yarnpkg.com/@babel/plugin-syntax-object-rest-spread/-/plugin-syntax-object-rest-spread-7.0.0.tgz#37d8fbcaf216bd658ea1aebbeb8b75e88ebc549b" @@ -770,6 +927,14 @@ "@babel/helper-plugin-utils" "^7.0.0" "@babel/helper-remap-async-to-generator" "^7.0.0" +"@babel/plugin-transform-async-to-generator@^7.1.0": + version "7.1.0" + resolved "https://registry.yarnpkg.com/@babel/plugin-transform-async-to-generator/-/plugin-transform-async-to-generator-7.1.0.tgz#109e036496c51dd65857e16acab3bafdf3c57811" + dependencies: + "@babel/helper-module-imports" "^7.0.0" + "@babel/helper-plugin-utils" "^7.0.0" + "@babel/helper-remap-async-to-generator" "^7.1.0" + "@babel/plugin-transform-block-scoped-functions@^7.0.0": version "7.0.0" resolved "https://registry.yarnpkg.com/@babel/plugin-transform-block-scoped-functions/-/plugin-transform-block-scoped-functions-7.0.0.tgz#482b3f75103927e37288b3b67b65f848e2aa0d07" @@ -796,6 +961,19 @@ "@babel/helper-split-export-declaration" "^7.0.0" globals "^11.1.0" +"@babel/plugin-transform-classes@^7.1.0": + version "7.1.0" + resolved "https://registry.yarnpkg.com/@babel/plugin-transform-classes/-/plugin-transform-classes-7.1.0.tgz#ab3f8a564361800cbc8ab1ca6f21108038432249" + dependencies: + "@babel/helper-annotate-as-pure" "^7.0.0" + "@babel/helper-define-map" "^7.1.0" + "@babel/helper-function-name" "^7.1.0" + "@babel/helper-optimise-call-expression" "^7.0.0" + "@babel/helper-plugin-utils" "^7.0.0" + "@babel/helper-replace-supers" "^7.1.0" + "@babel/helper-split-export-declaration" "^7.0.0" + globals "^11.1.0" + "@babel/plugin-transform-computed-properties@^7.0.0": version "7.0.0" resolved "https://registry.yarnpkg.com/@babel/plugin-transform-computed-properties/-/plugin-transform-computed-properties-7.0.0.tgz#2fbb8900cd3e8258f2a2ede909b90e7556185e31" @@ -829,6 +1007,13 @@ "@babel/helper-builder-binary-assignment-operator-visitor" "^7.0.0" "@babel/helper-plugin-utils" "^7.0.0" +"@babel/plugin-transform-exponentiation-operator@^7.1.0": + version "7.1.0" + resolved "https://registry.yarnpkg.com/@babel/plugin-transform-exponentiation-operator/-/plugin-transform-exponentiation-operator-7.1.0.tgz#9c34c2ee7fd77e02779cfa37e403a2e1003ccc73" + dependencies: + "@babel/helper-builder-binary-assignment-operator-visitor" "^7.1.0" + "@babel/helper-plugin-utils" "^7.0.0" + "@babel/plugin-transform-for-of@^7.0.0": version "7.0.0" resolved "https://registry.yarnpkg.com/@babel/plugin-transform-for-of/-/plugin-transform-for-of-7.0.0.tgz#f2ba4eadb83bd17dc3c7e9b30f4707365e1c3e39" @@ -842,6 +1027,13 @@ "@babel/helper-function-name" "^7.0.0" "@babel/helper-plugin-utils" "^7.0.0" +"@babel/plugin-transform-function-name@^7.1.0": + version "7.1.0" + resolved "https://registry.yarnpkg.com/@babel/plugin-transform-function-name/-/plugin-transform-function-name-7.1.0.tgz#29c5550d5c46208e7f730516d41eeddd4affadbb" + dependencies: + "@babel/helper-function-name" "^7.1.0" + "@babel/helper-plugin-utils" "^7.0.0" + "@babel/plugin-transform-literals@^7.0.0": version "7.0.0" resolved "https://registry.yarnpkg.com/@babel/plugin-transform-literals/-/plugin-transform-literals-7.0.0.tgz#2aec1d29cdd24c407359c930cdd89e914ee8ff86" @@ -855,6 +1047,13 @@ "@babel/helper-module-transforms" "^7.0.0" "@babel/helper-plugin-utils" "^7.0.0" +"@babel/plugin-transform-modules-amd@^7.1.0": + version "7.1.0" + resolved "https://registry.yarnpkg.com/@babel/plugin-transform-modules-amd/-/plugin-transform-modules-amd-7.1.0.tgz#f9e0a7072c12e296079b5a59f408ff5b97bf86a8" + dependencies: + "@babel/helper-module-transforms" "^7.1.0" + "@babel/helper-plugin-utils" "^7.0.0" + "@babel/plugin-transform-modules-commonjs@^7.0.0": version "7.0.0" resolved "https://registry.yarnpkg.com/@babel/plugin-transform-modules-commonjs/-/plugin-transform-modules-commonjs-7.0.0.tgz#20b906e5ab130dd8e456b694a94d9575da0fd41f" @@ -863,6 +1062,14 @@ "@babel/helper-plugin-utils" "^7.0.0" "@babel/helper-simple-access" "^7.0.0" +"@babel/plugin-transform-modules-commonjs@^7.1.0": + version "7.1.0" + resolved "https://registry.yarnpkg.com/@babel/plugin-transform-modules-commonjs/-/plugin-transform-modules-commonjs-7.1.0.tgz#0a9d86451cbbfb29bd15186306897c67f6f9a05c" + dependencies: + "@babel/helper-module-transforms" "^7.1.0" + "@babel/helper-plugin-utils" "^7.0.0" + "@babel/helper-simple-access" "^7.1.0" + "@babel/plugin-transform-modules-systemjs@^7.0.0": version "7.0.0" resolved "https://registry.yarnpkg.com/@babel/plugin-transform-modules-systemjs/-/plugin-transform-modules-systemjs-7.0.0.tgz#8873d876d4fee23209decc4d1feab8f198cf2df4" @@ -877,6 +1084,13 @@ "@babel/helper-module-transforms" "^7.0.0" "@babel/helper-plugin-utils" "^7.0.0" +"@babel/plugin-transform-modules-umd@^7.1.0": + version "7.1.0" + resolved "https://registry.yarnpkg.com/@babel/plugin-transform-modules-umd/-/plugin-transform-modules-umd-7.1.0.tgz#a29a7d85d6f28c3561c33964442257cc6a21f2a8" + dependencies: + "@babel/helper-module-transforms" "^7.1.0" + "@babel/helper-plugin-utils" "^7.0.0" + "@babel/plugin-transform-new-target@^7.0.0": version "7.0.0" resolved "https://registry.yarnpkg.com/@babel/plugin-transform-new-target/-/plugin-transform-new-target-7.0.0.tgz#ae8fbd89517fa7892d20e6564e641e8770c3aa4a" @@ -890,6 +1104,13 @@ "@babel/helper-plugin-utils" "^7.0.0" "@babel/helper-replace-supers" "^7.0.0" +"@babel/plugin-transform-object-super@^7.1.0": + version "7.1.0" + resolved "https://registry.yarnpkg.com/@babel/plugin-transform-object-super/-/plugin-transform-object-super-7.1.0.tgz#b1ae194a054b826d8d4ba7ca91486d4ada0f91bb" + dependencies: + "@babel/helper-plugin-utils" "^7.0.0" + "@babel/helper-replace-supers" "^7.1.0" + "@babel/plugin-transform-parameters@^7.0.0": version "7.0.0" resolved "https://registry.yarnpkg.com/@babel/plugin-transform-parameters/-/plugin-transform-parameters-7.0.0.tgz#da864efa111816a6df161d492f33de10e74b1949" @@ -898,6 +1119,28 @@ "@babel/helper-get-function-arity" "^7.0.0" "@babel/helper-plugin-utils" "^7.0.0" +"@babel/plugin-transform-parameters@^7.1.0": + version "7.1.0" + resolved "https://registry.yarnpkg.com/@babel/plugin-transform-parameters/-/plugin-transform-parameters-7.1.0.tgz#44f492f9d618c9124026e62301c296bf606a7aed" + dependencies: + "@babel/helper-call-delegate" "^7.1.0" + "@babel/helper-get-function-arity" "^7.0.0" + "@babel/helper-plugin-utils" "^7.0.0" + +"@babel/plugin-transform-react-display-name@7.0.0": + version "7.0.0" + resolved "https://registry.yarnpkg.com/@babel/plugin-transform-react-display-name/-/plugin-transform-react-display-name-7.0.0.tgz#93759e6c023782e52c2da3b75eca60d4f10533ee" + dependencies: + "@babel/helper-plugin-utils" "^7.0.0" + +"@babel/plugin-transform-react-jsx@7.0.0": + version "7.0.0" + resolved "https://registry.yarnpkg.com/@babel/plugin-transform-react-jsx/-/plugin-transform-react-jsx-7.0.0.tgz#524379e4eca5363cd10c4446ba163f093da75f3e" + dependencies: + "@babel/helper-builder-react-jsx" "^7.0.0" + "@babel/helper-plugin-utils" "^7.0.0" + "@babel/plugin-syntax-jsx" "^7.0.0" + "@babel/plugin-transform-regenerator@^7.0.0": version "7.0.0" resolved "https://registry.yarnpkg.com/@babel/plugin-transform-regenerator/-/plugin-transform-regenerator-7.0.0.tgz#5b41686b4ed40bef874d7ed6a84bdd849c13e0c1" @@ -997,6 +1240,52 @@ js-levenshtein "^1.1.3" semver "^5.3.0" +"@babel/preset-env@^7.1.0": + version "7.1.0" + resolved "https://registry.yarnpkg.com/@babel/preset-env/-/preset-env-7.1.0.tgz#e67ea5b0441cfeab1d6f41e9b5c79798800e8d11" + dependencies: + "@babel/helper-module-imports" "^7.0.0" + "@babel/helper-plugin-utils" "^7.0.0" + "@babel/plugin-proposal-async-generator-functions" "^7.1.0" + "@babel/plugin-proposal-json-strings" "^7.0.0" + "@babel/plugin-proposal-object-rest-spread" "^7.0.0" + "@babel/plugin-proposal-optional-catch-binding" "^7.0.0" + "@babel/plugin-proposal-unicode-property-regex" "^7.0.0" + "@babel/plugin-syntax-async-generators" "^7.0.0" + "@babel/plugin-syntax-object-rest-spread" "^7.0.0" + "@babel/plugin-syntax-optional-catch-binding" "^7.0.0" + "@babel/plugin-transform-arrow-functions" "^7.0.0" + "@babel/plugin-transform-async-to-generator" "^7.1.0" + "@babel/plugin-transform-block-scoped-functions" "^7.0.0" + "@babel/plugin-transform-block-scoping" "^7.0.0" + "@babel/plugin-transform-classes" "^7.1.0" + "@babel/plugin-transform-computed-properties" "^7.0.0" + "@babel/plugin-transform-destructuring" "^7.0.0" + "@babel/plugin-transform-dotall-regex" "^7.0.0" + "@babel/plugin-transform-duplicate-keys" "^7.0.0" + "@babel/plugin-transform-exponentiation-operator" "^7.1.0" + "@babel/plugin-transform-for-of" "^7.0.0" + "@babel/plugin-transform-function-name" "^7.1.0" + "@babel/plugin-transform-literals" "^7.0.0" + "@babel/plugin-transform-modules-amd" "^7.1.0" + "@babel/plugin-transform-modules-commonjs" "^7.1.0" + "@babel/plugin-transform-modules-systemjs" "^7.0.0" + "@babel/plugin-transform-modules-umd" "^7.1.0" + "@babel/plugin-transform-new-target" "^7.0.0" + "@babel/plugin-transform-object-super" "^7.1.0" + "@babel/plugin-transform-parameters" "^7.1.0" + "@babel/plugin-transform-regenerator" "^7.0.0" + "@babel/plugin-transform-shorthand-properties" "^7.0.0" + "@babel/plugin-transform-spread" "^7.0.0" + "@babel/plugin-transform-sticky-regex" "^7.0.0" + "@babel/plugin-transform-template-literals" "^7.0.0" + "@babel/plugin-transform-typeof-symbol" "^7.0.0" + "@babel/plugin-transform-unicode-regex" "^7.0.0" + browserslist "^4.1.0" + invariant "^2.2.2" + js-levenshtein "^1.1.3" + semver "^5.3.0" + "@babel/runtime@7.0.0": version "7.0.0" resolved "https://registry.yarnpkg.com/@babel/runtime/-/runtime-7.0.0.tgz#adeb78fedfc855aa05bc041640f3f6f98e85424c" @@ -1026,6 +1315,14 @@ "@babel/parser" "^7.0.0" "@babel/types" "^7.0.0" +"@babel/template@^7.1.0", "@babel/template@^7.1.2": + version "7.1.2" + resolved "https://registry.yarnpkg.com/@babel/template/-/template-7.1.2.tgz#090484a574fef5a2d2d7726a674eceda5c5b5644" + dependencies: + "@babel/code-frame" "^7.0.0" + "@babel/parser" "^7.1.2" + "@babel/types" "^7.1.2" + "@babel/traverse@7.0.0-beta.44": version "7.0.0-beta.44" resolved "http://registry.npmjs.org/@babel/traverse/-/traverse-7.0.0-beta.44.tgz#a970a2c45477ad18017e2e465a0606feee0d2966" @@ -1055,6 +1352,20 @@ globals "^11.1.0" lodash "^4.17.10" +"@babel/traverse@^7.1.0": + version "7.1.0" + resolved "https://registry.yarnpkg.com/@babel/traverse/-/traverse-7.1.0.tgz#503ec6669387efd182c3888c4eec07bcc45d91b2" + dependencies: + "@babel/code-frame" "^7.0.0" + "@babel/generator" "^7.0.0" + "@babel/helper-function-name" "^7.1.0" + "@babel/helper-split-export-declaration" "^7.0.0" + "@babel/parser" "^7.1.0" + "@babel/types" "^7.0.0" + debug "^3.1.0" + globals "^11.1.0" + lodash "^4.17.10" + "@babel/types@7.0.0-beta.44": version "7.0.0-beta.44" resolved "http://registry.npmjs.org/@babel/types/-/types-7.0.0-beta.44.tgz#6b1b164591f77dec0a0342aca995f2d046b3a757" @@ -1071,6 +1382,14 @@ lodash "^4.17.10" to-fast-properties "^2.0.0" +"@babel/types@^7.1.2": + version "7.1.2" + resolved "https://registry.yarnpkg.com/@babel/types/-/types-7.1.2.tgz#183e7952cf6691628afdc2e2b90d03240bac80c0" + dependencies: + esutils "^2.0.2" + lodash "^4.17.10" + to-fast-properties "^2.0.0" + "@ledgerhq/hw-app-eth@^4.3.0": version "4.21.0" resolved "https://registry.yarnpkg.com/@ledgerhq/hw-app-eth/-/hw-app-eth-4.21.0.tgz#2d8bfbe5f09b92e8d6951ae685036d9d5aea96ff" @@ -1965,6 +2284,17 @@ align-text@^0.1.1, align-text@^0.1.3: longest "^1.0.1" repeat-string "^1.5.2" +allure-js-commons@^1.3.2: + version "1.3.2" + resolved "https://registry.yarnpkg.com/allure-js-commons/-/allure-js-commons-1.3.2.tgz#e1cf0466e36695bb3ced1228f6570eac6c2e9eda" + dependencies: + file-type "^7.7.1" + fs-extra "^6.0.1" + js2xmlparser "^3.0.0" + mime "^2.3.1" + object-assign "^4.1.1" + uuid "^3.0.0" + alphanum-sort@^1.0.1, alphanum-sort@^1.0.2: version "1.0.2" resolved "https://registry.yarnpkg.com/alphanum-sort/-/alphanum-sort-1.0.2.tgz#97a1119649b211ad33691d9f9f486a8ec9fbe0a3" @@ -2349,29 +2679,9 @@ babel-code-frame@6.26.0, babel-code-frame@^6.22.0, babel-code-frame@^6.26.0: esutils "^2.0.2" js-tokens "^3.0.2" -babel-core@6.26.0: - version "6.26.0" - resolved "https://registry.yarnpkg.com/babel-core/-/babel-core-6.26.0.tgz#af32f78b31a6fcef119c87b0fd8d9753f03a0bb8" - dependencies: - babel-code-frame "^6.26.0" - babel-generator "^6.26.0" - babel-helpers "^6.24.1" - babel-messages "^6.23.0" - babel-register "^6.26.0" - babel-runtime "^6.26.0" - babel-template "^6.26.0" - babel-traverse "^6.26.0" - babel-types "^6.26.0" - babylon "^6.18.0" - convert-source-map "^1.5.0" - debug "^2.6.8" - json5 "^0.5.1" - lodash "^4.17.4" - minimatch "^3.0.4" - path-is-absolute "^1.0.1" - private "^0.1.7" - slash "^1.0.0" - source-map "^0.5.6" +babel-core@7.0.0-bridge.0, babel-core@^7.0.0-bridge.0: + version "7.0.0-bridge.0" + resolved "https://registry.yarnpkg.com/babel-core/-/babel-core-7.0.0-bridge.0.tgz#95a492ddd90f9b4e9a4a1da14eb335b87b634ece" babel-core@^6.0.0, babel-core@^6.0.14, babel-core@^6.26.0: version "6.26.3" @@ -2397,10 +2707,6 @@ babel-core@^6.0.0, babel-core@^6.0.14, babel-core@^6.26.0: slash "^1.0.0" source-map "^0.5.7" -babel-core@^7.0.0-bridge.0: - version "7.0.0-bridge.0" - resolved "https://registry.yarnpkg.com/babel-core/-/babel-core-7.0.0-bridge.0.tgz#95a492ddd90f9b4e9a4a1da14eb335b87b634ece" - babel-eslint@^8.2.6: version "8.2.6" resolved "https://registry.yarnpkg.com/babel-eslint/-/babel-eslint-8.2.6.tgz#6270d0c73205628067c0f7ae1693a9e797acefd9" @@ -2579,14 +2885,6 @@ babel-helpers@^6.24.1: babel-runtime "^6.22.0" babel-template "^6.24.1" -babel-jest@20.0.3: - version "20.0.3" - resolved "https://registry.yarnpkg.com/babel-jest/-/babel-jest-20.0.3.tgz#e4a03b13dc10389e140fc645d09ffc4ced301671" - dependencies: - babel-core "^6.0.0" - babel-plugin-istanbul "^4.0.0" - babel-preset-jest "^20.0.3" - babel-jest@23.4.2: version "23.4.2" resolved "https://registry.yarnpkg.com/babel-jest/-/babel-jest-23.4.2.tgz#f276de67798a5d68f2d6e87ff518c2f6e1609877" @@ -2594,13 +2892,6 @@ babel-jest@23.4.2: babel-plugin-istanbul "^4.1.6" babel-preset-jest "^23.2.0" -babel-jest@^22.4.4: - version "22.4.4" - resolved "https://registry.yarnpkg.com/babel-jest/-/babel-jest-22.4.4.tgz#977259240420e227444ebe49e226a61e49ea659d" - dependencies: - babel-plugin-istanbul "^4.1.5" - babel-preset-jest "^22.4.4" - babel-jest@^23.4.2, babel-jest@^23.6.0: version "23.6.0" resolved "https://registry.yarnpkg.com/babel-jest/-/babel-jest-23.6.0.tgz#a644232366557a2240a0c083da6b25786185a2f1" @@ -2645,15 +2936,7 @@ babel-plugin-check-es2015-constants@^6.22.0: dependencies: babel-runtime "^6.22.0" -babel-plugin-dynamic-import-node@1.1.0: - version "1.1.0" - resolved "https://registry.yarnpkg.com/babel-plugin-dynamic-import-node/-/babel-plugin-dynamic-import-node-1.1.0.tgz#bd1d88ac7aaf98df4917c384373b04d971a2b37a" - dependencies: - babel-plugin-syntax-dynamic-import "^6.18.0" - babel-template "^6.26.0" - babel-types "^6.26.0" - -babel-plugin-istanbul@^4.0.0, babel-plugin-istanbul@^4.1.5, babel-plugin-istanbul@^4.1.6: +babel-plugin-istanbul@^4.1.6: version "4.1.6" resolved "http://registry.npmjs.org/babel-plugin-istanbul/-/babel-plugin-istanbul-4.1.6.tgz#36c59b2192efce81c5b378321b74175add1c9a45" dependencies: @@ -2662,14 +2945,6 @@ babel-plugin-istanbul@^4.0.0, babel-plugin-istanbul@^4.1.5, babel-plugin-istanbu istanbul-lib-instrument "^1.10.1" test-exclude "^4.2.1" -babel-plugin-jest-hoist@^20.0.3: - version "20.0.3" - resolved "https://registry.yarnpkg.com/babel-plugin-jest-hoist/-/babel-plugin-jest-hoist-20.0.3.tgz#afedc853bd3f8dc3548ea671fbe69d03cc2c1767" - -babel-plugin-jest-hoist@^22.4.4: - version "22.4.4" - resolved "https://registry.yarnpkg.com/babel-plugin-jest-hoist/-/babel-plugin-jest-hoist-22.4.4.tgz#b9851906eab34c7bf6f8c895a2b08bea1a844c0b" - babel-plugin-jest-hoist@^23.2.0: version "23.2.0" resolved "https://registry.yarnpkg.com/babel-plugin-jest-hoist/-/babel-plugin-jest-hoist-23.2.0.tgz#e61fae05a1ca8801aadee57a6d66b8cefaf44167" @@ -2777,7 +3052,7 @@ babel-plugin-syntax-do-expressions@^6.8.0: version "6.13.0" resolved "http://registry.npmjs.org/babel-plugin-syntax-do-expressions/-/babel-plugin-syntax-do-expressions-6.13.0.tgz#5747756139aa26d390d09410b03744ba07e4796d" -babel-plugin-syntax-dynamic-import@6.18.0, babel-plugin-syntax-dynamic-import@^6.18.0: +babel-plugin-syntax-dynamic-import@^6.18.0: version "6.18.0" resolved "http://registry.npmjs.org/babel-plugin-syntax-dynamic-import/-/babel-plugin-syntax-dynamic-import-6.18.0.tgz#8d6a26229c83745a9982a441051572caa179b1da" @@ -2833,7 +3108,7 @@ babel-plugin-transform-class-constructor-call@^6.24.1: babel-runtime "^6.22.0" babel-template "^6.24.1" -babel-plugin-transform-class-properties@6.24.1, babel-plugin-transform-class-properties@^6.24.1: +babel-plugin-transform-class-properties@^6.24.1: version "6.24.1" resolved "https://registry.yarnpkg.com/babel-plugin-transform-class-properties/-/babel-plugin-transform-class-properties-6.24.1.tgz#6a79763ea61d33d36f37b611aa9def81a81b46ac" dependencies: @@ -2902,7 +3177,7 @@ babel-plugin-transform-es2015-computed-properties@^6.22.0, babel-plugin-transfor babel-runtime "^6.22.0" babel-template "^6.24.1" -babel-plugin-transform-es2015-destructuring@6.23.0, babel-plugin-transform-es2015-destructuring@^6.22.0, babel-plugin-transform-es2015-destructuring@^6.23.0: +babel-plugin-transform-es2015-destructuring@^6.22.0, babel-plugin-transform-es2015-destructuring@^6.23.0: version "6.23.0" resolved "https://registry.yarnpkg.com/babel-plugin-transform-es2015-destructuring/-/babel-plugin-transform-es2015-destructuring-6.23.0.tgz#997bb1f1ab967f682d2b0876fe358d60e765c56d" dependencies: @@ -3072,7 +3347,7 @@ babel-plugin-transform-minify-booleans@^6.9.0: version "6.9.4" resolved "https://registry.yarnpkg.com/babel-plugin-transform-minify-booleans/-/babel-plugin-transform-minify-booleans-6.9.4.tgz#acbb3e56a3555dd23928e4b582d285162dd2b198" -babel-plugin-transform-object-rest-spread@6.26.0, babel-plugin-transform-object-rest-spread@^6.22.0: +babel-plugin-transform-object-rest-spread@^6.22.0: version "6.26.0" resolved "https://registry.yarnpkg.com/babel-plugin-transform-object-rest-spread/-/babel-plugin-transform-object-rest-spread-6.26.0.tgz#0f36692d50fef6b7e2d4b3ac1478137a963b7b06" dependencies: @@ -3085,33 +3360,27 @@ babel-plugin-transform-property-literals@^6.9.0: dependencies: esutils "^2.0.2" -babel-plugin-transform-react-constant-elements@6.23.0: - version "6.23.0" - resolved "https://registry.yarnpkg.com/babel-plugin-transform-react-constant-elements/-/babel-plugin-transform-react-constant-elements-6.23.0.tgz#2f119bf4d2cdd45eb9baaae574053c604f6147dd" - dependencies: - babel-runtime "^6.22.0" - babel-plugin-transform-react-display-name@^6.23.0: version "6.25.0" resolved "https://registry.yarnpkg.com/babel-plugin-transform-react-display-name/-/babel-plugin-transform-react-display-name-6.25.0.tgz#67e2bf1f1e9c93ab08db96792e05392bf2cc28d1" dependencies: babel-runtime "^6.22.0" -babel-plugin-transform-react-jsx-self@6.22.0, babel-plugin-transform-react-jsx-self@^6.22.0: +babel-plugin-transform-react-jsx-self@^6.22.0: version "6.22.0" resolved "https://registry.yarnpkg.com/babel-plugin-transform-react-jsx-self/-/babel-plugin-transform-react-jsx-self-6.22.0.tgz#df6d80a9da2612a121e6ddd7558bcbecf06e636e" dependencies: babel-plugin-syntax-jsx "^6.8.0" babel-runtime "^6.22.0" -babel-plugin-transform-react-jsx-source@6.22.0, babel-plugin-transform-react-jsx-source@^6.22.0: +babel-plugin-transform-react-jsx-source@^6.22.0: version "6.22.0" resolved "https://registry.yarnpkg.com/babel-plugin-transform-react-jsx-source/-/babel-plugin-transform-react-jsx-source-6.22.0.tgz#66ac12153f5cd2d17b3c19268f4bf0197f44ecd6" dependencies: babel-plugin-syntax-jsx "^6.8.0" babel-runtime "^6.22.0" -babel-plugin-transform-react-jsx@6.24.1, babel-plugin-transform-react-jsx@^6.24.1: +babel-plugin-transform-react-jsx@^6.24.1: version "6.24.1" resolved "https://registry.yarnpkg.com/babel-plugin-transform-react-jsx/-/babel-plugin-transform-react-jsx-6.24.1.tgz#840a028e7df460dfc3a2d29f0c0d91f6376e66a3" dependencies: @@ -3119,7 +3388,7 @@ babel-plugin-transform-react-jsx@6.24.1, babel-plugin-transform-react-jsx@^6.24. babel-plugin-syntax-jsx "^6.8.0" babel-runtime "^6.22.0" -babel-plugin-transform-regenerator@6.26.0, babel-plugin-transform-regenerator@^6.22.0, babel-plugin-transform-regenerator@^6.24.1, babel-plugin-transform-regenerator@^6.26.0: +babel-plugin-transform-regenerator@^6.22.0, babel-plugin-transform-regenerator@^6.24.1, babel-plugin-transform-regenerator@^6.26.0: version "6.26.0" resolved "https://registry.yarnpkg.com/babel-plugin-transform-regenerator/-/babel-plugin-transform-regenerator-6.26.0.tgz#e0703696fbde27f0a3efcacf8b4dca2f7b3a8f2f" dependencies: @@ -3143,7 +3412,7 @@ babel-plugin-transform-remove-undefined@^0.3.0: dependencies: babel-helper-evaluate-path "^0.3.0" -babel-plugin-transform-runtime@6.23.0, babel-plugin-transform-runtime@^6.23.0: +babel-plugin-transform-runtime@^6.23.0: version "6.23.0" resolved "https://registry.yarnpkg.com/babel-plugin-transform-runtime/-/babel-plugin-transform-runtime-6.23.0.tgz#88490d446502ea9b8e7efb0fe09ec4d99479b1ee" dependencies: @@ -3164,41 +3433,6 @@ babel-plugin-transform-undefined-to-void@^6.9.0: version "6.9.4" resolved "https://registry.yarnpkg.com/babel-plugin-transform-undefined-to-void/-/babel-plugin-transform-undefined-to-void-6.9.4.tgz#be241ca81404030678b748717322b89d0c8fe280" -babel-preset-env@1.6.1: - version "1.6.1" - resolved "https://registry.yarnpkg.com/babel-preset-env/-/babel-preset-env-1.6.1.tgz#a18b564cc9b9afdf4aae57ae3c1b0d99188e6f48" - dependencies: - babel-plugin-check-es2015-constants "^6.22.0" - babel-plugin-syntax-trailing-function-commas "^6.22.0" - babel-plugin-transform-async-to-generator "^6.22.0" - babel-plugin-transform-es2015-arrow-functions "^6.22.0" - babel-plugin-transform-es2015-block-scoped-functions "^6.22.0" - babel-plugin-transform-es2015-block-scoping "^6.23.0" - babel-plugin-transform-es2015-classes "^6.23.0" - babel-plugin-transform-es2015-computed-properties "^6.22.0" - babel-plugin-transform-es2015-destructuring "^6.23.0" - babel-plugin-transform-es2015-duplicate-keys "^6.22.0" - babel-plugin-transform-es2015-for-of "^6.23.0" - babel-plugin-transform-es2015-function-name "^6.22.0" - babel-plugin-transform-es2015-literals "^6.22.0" - babel-plugin-transform-es2015-modules-amd "^6.22.0" - babel-plugin-transform-es2015-modules-commonjs "^6.23.0" - babel-plugin-transform-es2015-modules-systemjs "^6.23.0" - babel-plugin-transform-es2015-modules-umd "^6.23.0" - babel-plugin-transform-es2015-object-super "^6.22.0" - babel-plugin-transform-es2015-parameters "^6.23.0" - babel-plugin-transform-es2015-shorthand-properties "^6.22.0" - babel-plugin-transform-es2015-spread "^6.22.0" - babel-plugin-transform-es2015-sticky-regex "^6.22.0" - babel-plugin-transform-es2015-template-literals "^6.22.0" - babel-plugin-transform-es2015-typeof-symbol "^6.23.0" - babel-plugin-transform-es2015-unicode-regex "^6.22.0" - babel-plugin-transform-exponentiation-operator "^6.22.0" - babel-plugin-transform-regenerator "^6.22.0" - browserslist "^2.1.2" - invariant "^2.2.2" - semver "^5.3.0" - babel-preset-env@^1.3.2, babel-preset-env@^1.6.1: version "1.7.0" resolved "https://registry.yarnpkg.com/babel-preset-env/-/babel-preset-env-1.7.0.tgz#dea79fa4ebeb883cd35dab07e260c1c9c04df77a" @@ -3269,19 +3503,6 @@ babel-preset-flow@^6.23.0: dependencies: babel-plugin-transform-flow-strip-types "^6.22.0" -babel-preset-jest@^20.0.3: - version "20.0.3" - resolved "https://registry.yarnpkg.com/babel-preset-jest/-/babel-preset-jest-20.0.3.tgz#cbacaadecb5d689ca1e1de1360ebfc66862c178a" - dependencies: - babel-plugin-jest-hoist "^20.0.3" - -babel-preset-jest@^22.4.4: - version "22.4.4" - resolved "https://registry.yarnpkg.com/babel-preset-jest/-/babel-preset-jest-22.4.4.tgz#ec9fbd8bcd7dfd24b8b5320e0e688013235b7c39" - dependencies: - babel-plugin-jest-hoist "^22.4.4" - babel-plugin-syntax-object-rest-spread "^6.13.0" - babel-preset-jest@^23.2.0: version "23.2.0" resolved "https://registry.yarnpkg.com/babel-preset-jest/-/babel-preset-jest-23.2.0.tgz#8ec7a03a138f001a1a8fb1e8113652bf1a55da46" @@ -3317,25 +3538,7 @@ babel-preset-minify@^0.3.0: babel-plugin-transform-undefined-to-void "^6.9.0" lodash.isplainobject "^4.0.6" -babel-preset-react-app@^3.1.1: - version "3.1.2" - resolved "https://registry.yarnpkg.com/babel-preset-react-app/-/babel-preset-react-app-3.1.2.tgz#49ba3681b917c4e5c73a5249d3ef4c48fae064e2" - dependencies: - babel-plugin-dynamic-import-node "1.1.0" - babel-plugin-syntax-dynamic-import "6.18.0" - babel-plugin-transform-class-properties "6.24.1" - babel-plugin-transform-es2015-destructuring "6.23.0" - babel-plugin-transform-object-rest-spread "6.26.0" - babel-plugin-transform-react-constant-elements "6.23.0" - babel-plugin-transform-react-jsx "6.24.1" - babel-plugin-transform-react-jsx-self "6.22.0" - babel-plugin-transform-react-jsx-source "6.22.0" - babel-plugin-transform-regenerator "6.26.0" - babel-plugin-transform-runtime "6.23.0" - babel-preset-env "1.6.1" - babel-preset-react "6.24.1" - -babel-preset-react@6.24.1, babel-preset-react@^6.24.1: +babel-preset-react@^6.24.1: version "6.24.1" resolved "https://registry.yarnpkg.com/babel-preset-react/-/babel-preset-react-6.24.1.tgz#ba69dfaea45fc3ec639b6a4ecea6e17702c91380" dependencies: @@ -3393,7 +3596,7 @@ babel-register@^6.26.0, babel-register@^6.9.0: mkdirp "^0.5.1" source-map-support "^0.4.15" -babel-runtime@6.26.0, babel-runtime@6.x.x, babel-runtime@^6.11.6, babel-runtime@^6.18.0, babel-runtime@^6.22.0, babel-runtime@^6.23.0, babel-runtime@^6.26.0, babel-runtime@^6.5.0, babel-runtime@^6.9.2: +babel-runtime@6.x.x, babel-runtime@^6.11.6, babel-runtime@^6.18.0, babel-runtime@^6.22.0, babel-runtime@^6.23.0, babel-runtime@^6.26.0, babel-runtime@^6.5.0, babel-runtime@^6.9.2: version "6.26.0" resolved "https://registry.yarnpkg.com/babel-runtime/-/babel-runtime-6.26.0.tgz#965c7058668e82b55d7bfe04ff2337bc8b5647fe" dependencies: @@ -3772,7 +3975,7 @@ browser-process-hrtime@^0.1.2: version "0.1.2" resolved "https://registry.yarnpkg.com/browser-process-hrtime/-/browser-process-hrtime-0.1.2.tgz#425d68a58d3447f02a04aa894187fce8af8b7b8e" -browser-resolve@^1.11.2, browser-resolve@^1.11.3: +browser-resolve@^1.11.3: version "1.11.3" resolved "https://registry.yarnpkg.com/browser-resolve/-/browser-resolve-1.11.3.tgz#9b7cbb3d0f510e4cb86bdbd796124d28b5890af6" dependencies: @@ -3848,7 +4051,7 @@ browserslist@^1.3.6, browserslist@^1.5.2, browserslist@^1.7.6: caniuse-db "^1.0.30000639" electron-to-chromium "^1.2.7" -browserslist@^2.1.2, browserslist@^2.11.3, browserslist@^2.5.1: +browserslist@^2.11.3, browserslist@^2.5.1: version "2.11.3" resolved "https://registry.yarnpkg.com/browserslist/-/browserslist-2.11.3.tgz#fe36167aed1bbcde4827ebfe71347a2cc70b99b2" dependencies: @@ -4532,6 +4735,28 @@ codeceptjs@^1.3.0: requireg "^0.1.8" sprintf-js "^1.1.1" +codeceptjs@^1.4.2: + version "1.4.2" + resolved "https://registry.yarnpkg.com/codeceptjs/-/codeceptjs-1.4.2.tgz#b26272d259c867dcf11044534660815e9dcd2443" + dependencies: + allure-js-commons "^1.3.2" + chalk "^1.1.3" + commander "^2.18.0" + css-to-xpath "^0.1.0" + cucumber-expressions "^6.0.1" + escape-string-regexp "^1.0.3" + figures "^2.0.0" + fn-args "^3.0.0" + gherkin "^5.1.0" + glob "^6.0.1" + inquirer "^0.11.0" + mkdirp "^0.5.1" + mocha "^4.1.0" + parse-function "^5.2.10" + promise-retry "^1.1.1" + requireg "^0.1.8" + sprintf-js "^1.1.1" + coinstring@^2.0.0: version "2.3.0" resolved "https://registry.yarnpkg.com/coinstring/-/coinstring-2.3.0.tgz#cdb63363a961502404a25afb82c2e26d5ff627a4" @@ -4623,7 +4848,7 @@ commander@2.17.x, commander@~2.17.1: version "2.17.1" resolved "https://registry.yarnpkg.com/commander/-/commander-2.17.1.tgz#bd77ab7de6de94205ceacc72f1716d29f20a77bf" -commander@^2.14.1, commander@^2.15.0, commander@^2.16.0, commander@^2.8.1, commander@^2.9.0: +commander@^2.14.1, commander@^2.15.0, commander@^2.16.0, commander@^2.18.0, commander@^2.8.1, commander@^2.9.0: version "2.18.0" resolved "https://registry.yarnpkg.com/commander/-/commander-2.18.0.tgz#2bf063ddee7c7891176981a2cc798e5754bc6970" @@ -4890,7 +5115,7 @@ conventional-recommended-bump@^1.2.1: meow "^3.3.0" object-assign "^4.0.1" -convert-source-map@^1.1.0, convert-source-map@^1.4.0, convert-source-map@^1.5.0, convert-source-map@^1.5.1: +convert-source-map@^1.1.0, convert-source-map@^1.4.0, convert-source-map@^1.5.1: version "1.6.0" resolved "https://registry.yarnpkg.com/convert-source-map/-/convert-source-map-1.6.0.tgz#51b537a8c43e0f04dec1993bffcdd504e758ac20" dependencies: @@ -6394,7 +6619,7 @@ estraverse@^4.0.0, estraverse@^4.1.0, estraverse@^4.1.1, estraverse@^4.2.0: version "4.2.0" resolved "https://registry.yarnpkg.com/estraverse/-/estraverse-4.2.0.tgz#0dee3fed31fcd469618ce7342099fc1afa0bdb13" -esutils@^2.0.2: +esutils@^2.0.0, esutils@^2.0.2: version "2.0.2" resolved "https://registry.yarnpkg.com/esutils/-/esutils-2.0.2.tgz#0abf4f1caa5bcb1f7a9d8acc6dea4faaa04bac9b" @@ -6955,17 +7180,6 @@ expand-tilde@^2.0.0, expand-tilde@^2.0.2: dependencies: homedir-polyfill "^1.0.1" -expect@^22.4.0: - version "22.4.3" - resolved "http://registry.npmjs.org/expect/-/expect-22.4.3.tgz#d5a29d0a0e1fb2153557caef2674d4547e914674" - dependencies: - ansi-styles "^3.2.0" - jest-diff "^22.4.3" - jest-get-type "^22.4.3" - jest-matcher-utils "^22.4.3" - jest-message-util "^22.4.3" - jest-regex-util "^22.4.3" - expect@^23.6.0: version "23.6.0" resolved "https://registry.yarnpkg.com/expect/-/expect-23.6.0.tgz#1e0c8d3ba9a581c87bd71fb9bc8862d443425f98" @@ -7229,6 +7443,10 @@ file-type@^6.1.0: version "6.2.0" resolved "https://registry.yarnpkg.com/file-type/-/file-type-6.2.0.tgz#e50cd75d356ffed4e306dc4f5bcf52a79903a919" +file-type@^7.7.1: + version "7.7.1" + resolved "https://registry.yarnpkg.com/file-type/-/file-type-7.7.1.tgz#91c2f5edb8ce70688b9b68a90d931bbb6cb21f65" + filename-regex@^2.0.0: version "2.0.1" resolved "https://registry.yarnpkg.com/filename-regex/-/filename-regex-2.0.1.tgz#c1c4b9bee3e09725ddb106b75c1e301fe2f18b26" @@ -7445,7 +7663,7 @@ fs-extra@3.0.1: jsonfile "^3.0.0" universalify "^0.1.0" -fs-extra@6.0.1: +fs-extra@6.0.1, fs-extra@^6.0.1: version "6.0.1" resolved "https://registry.yarnpkg.com/fs-extra/-/fs-extra-6.0.1.tgz#8abc128f7946e310135ddc93b98bddb410e7a34b" dependencies: @@ -7550,7 +7768,7 @@ fuse.js@^3.0.1, fuse.js@^3.2.0: version "3.2.1" resolved "https://registry.yarnpkg.com/fuse.js/-/fuse.js-3.2.1.tgz#6320cb94ce56ec9755c89ade775bcdbb0358d425" -ganache-cli@^6.1.0: +ganache-cli@^6.1.0, ganache-cli@^6.1.8: version "6.1.8" resolved "https://registry.yarnpkg.com/ganache-cli/-/ganache-cli-6.1.8.tgz#49a8a331683a9652183f82ef1378d17e1814fcd3" dependencies: @@ -9137,7 +9355,7 @@ isstream@~0.1.2: version "0.1.2" resolved "https://registry.yarnpkg.com/isstream/-/isstream-0.1.2.tgz#47e63f7af55afa6f92e1500e690eb8b8529c099a" -istanbul-api@^1.1.14, istanbul-api@^1.3.1: +istanbul-api@^1.3.1: version "1.3.7" resolved "https://registry.yarnpkg.com/istanbul-api/-/istanbul-api-1.3.7.tgz#a86c770d2b03e11e3f778cd7aedd82d2722092aa" dependencies: @@ -9153,7 +9371,7 @@ istanbul-api@^1.1.14, istanbul-api@^1.3.1: mkdirp "^0.5.1" once "^1.4.0" -istanbul-lib-coverage@^1.1.1, istanbul-lib-coverage@^1.2.0, istanbul-lib-coverage@^1.2.1: +istanbul-lib-coverage@^1.2.0, istanbul-lib-coverage@^1.2.1: version "1.2.1" resolved "https://registry.yarnpkg.com/istanbul-lib-coverage/-/istanbul-lib-coverage-1.2.1.tgz#ccf7edcd0a0bb9b8f729feeb0930470f9af664f0" @@ -9163,7 +9381,7 @@ istanbul-lib-hook@^1.2.2: dependencies: append-transform "^0.4.0" -istanbul-lib-instrument@^1.10.1, istanbul-lib-instrument@^1.10.2, istanbul-lib-instrument@^1.8.0: +istanbul-lib-instrument@^1.10.1, istanbul-lib-instrument@^1.10.2: version "1.10.2" resolved "https://registry.yarnpkg.com/istanbul-lib-instrument/-/istanbul-lib-instrument-1.10.2.tgz#1f55ed10ac3c47f2bdddd5307935126754d0a9ca" dependencies: @@ -9184,7 +9402,7 @@ istanbul-lib-report@^1.1.5: path-parse "^1.0.5" supports-color "^3.1.2" -istanbul-lib-source-maps@^1.2.1, istanbul-lib-source-maps@^1.2.4, istanbul-lib-source-maps@^1.2.6: +istanbul-lib-source-maps@^1.2.4, istanbul-lib-source-maps@^1.2.6: version "1.2.6" resolved "https://registry.yarnpkg.com/istanbul-lib-source-maps/-/istanbul-lib-source-maps-1.2.6.tgz#37b9ff661580f8fca11232752ee42e08c6675d8f" dependencies: @@ -9215,57 +9433,12 @@ isurl@^1.0.0-alpha5: has-to-string-tag-x "^1.2.0" is-object "^1.0.1" -jest-changed-files@^22.2.0: - version "22.4.3" - resolved "https://registry.yarnpkg.com/jest-changed-files/-/jest-changed-files-22.4.3.tgz#8882181e022c38bd46a2e4d18d44d19d90a90fb2" - dependencies: - throat "^4.0.0" - jest-changed-files@^23.4.2: version "23.4.2" resolved "https://registry.yarnpkg.com/jest-changed-files/-/jest-changed-files-23.4.2.tgz#1eed688370cd5eebafe4ae93d34bb3b64968fe83" dependencies: throat "^4.0.0" -jest-cli@^22.4.3: - version "22.4.4" - resolved "https://registry.yarnpkg.com/jest-cli/-/jest-cli-22.4.4.tgz#68cd2a2aae983adb1e6638248ca21082fd6d9e90" - dependencies: - ansi-escapes "^3.0.0" - chalk "^2.0.1" - exit "^0.1.2" - glob "^7.1.2" - graceful-fs "^4.1.11" - import-local "^1.0.0" - is-ci "^1.0.10" - istanbul-api "^1.1.14" - istanbul-lib-coverage "^1.1.1" - istanbul-lib-instrument "^1.8.0" - istanbul-lib-source-maps "^1.2.1" - jest-changed-files "^22.2.0" - jest-config "^22.4.4" - jest-environment-jsdom "^22.4.1" - jest-get-type "^22.1.0" - jest-haste-map "^22.4.2" - jest-message-util "^22.4.0" - jest-regex-util "^22.1.0" - jest-resolve-dependencies "^22.1.0" - jest-runner "^22.4.4" - jest-runtime "^22.4.4" - jest-snapshot "^22.4.0" - jest-util "^22.4.1" - jest-validate "^22.4.4" - jest-worker "^22.2.2" - micromatch "^2.3.11" - node-notifier "^5.2.1" - realpath-native "^1.0.0" - rimraf "^2.5.4" - slash "^1.0.0" - string-length "^2.0.0" - strip-ansi "^4.0.0" - which "^1.2.12" - yargs "^10.0.3" - jest-cli@^23.4.1, jest-cli@^23.6.0: version "23.6.0" resolved "https://registry.yarnpkg.com/jest-cli/-/jest-cli-23.6.0.tgz#61ab917744338f443ef2baa282ddffdd658a5da4" @@ -9307,22 +9480,6 @@ jest-cli@^23.4.1, jest-cli@^23.6.0: which "^1.2.12" yargs "^11.0.0" -jest-config@^22.4.4: - version "22.4.4" - resolved "https://registry.yarnpkg.com/jest-config/-/jest-config-22.4.4.tgz#72a521188720597169cd8b4ff86934ef5752d86a" - dependencies: - chalk "^2.0.1" - glob "^7.1.1" - jest-environment-jsdom "^22.4.1" - jest-environment-node "^22.4.1" - jest-get-type "^22.1.0" - jest-jasmine2 "^22.4.4" - jest-regex-util "^22.1.0" - jest-resolve "^22.4.2" - jest-util "^22.4.1" - jest-validate "^22.4.4" - pretty-format "^22.4.0" - jest-config@^23.6.0: version "23.6.0" resolved "https://registry.yarnpkg.com/jest-config/-/jest-config-23.6.0.tgz#f82546a90ade2d8c7026fbf6ac5207fc22f8eb1d" @@ -9342,15 +9499,6 @@ jest-config@^23.6.0: micromatch "^2.3.11" pretty-format "^23.6.0" -jest-diff@^22.4.0, jest-diff@^22.4.3: - version "22.4.3" - resolved "http://registry.npmjs.org/jest-diff/-/jest-diff-22.4.3.tgz#e18cc3feff0aeef159d02310f2686d4065378030" - dependencies: - chalk "^2.0.1" - diff "^3.2.0" - jest-get-type "^22.4.3" - pretty-format "^22.4.3" - jest-diff@^23.6.0: version "23.6.0" resolved "https://registry.yarnpkg.com/jest-diff/-/jest-diff-23.6.0.tgz#1500f3f16e850bb3d71233408089be099f610c7d" @@ -9364,12 +9512,6 @@ jest-docblock@^21.0.0: version "21.2.0" resolved "https://registry.yarnpkg.com/jest-docblock/-/jest-docblock-21.2.0.tgz#51529c3b30d5fd159da60c27ceedc195faf8d414" -jest-docblock@^22.4.0, jest-docblock@^22.4.3: - version "22.4.3" - resolved "https://registry.yarnpkg.com/jest-docblock/-/jest-docblock-22.4.3.tgz#50886f132b42b280c903c592373bb6e93bb68b19" - dependencies: - detect-newline "^2.1.0" - jest-docblock@^23.2.0: version "23.2.0" resolved "https://registry.yarnpkg.com/jest-docblock/-/jest-docblock-23.2.0.tgz#f085e1f18548d99fdd69b20207e6fd55d91383a7" @@ -9383,14 +9525,6 @@ jest-each@^23.6.0: chalk "^2.0.1" pretty-format "^23.6.0" -jest-environment-jsdom@^22.4.1: - version "22.4.3" - resolved "https://registry.yarnpkg.com/jest-environment-jsdom/-/jest-environment-jsdom-22.4.3.tgz#d67daa4155e33516aecdd35afd82d4abf0fa8a1e" - dependencies: - jest-mock "^22.4.3" - jest-util "^22.4.3" - jsdom "^11.5.1" - jest-environment-jsdom@^23.4.0: version "23.4.0" resolved "https://registry.yarnpkg.com/jest-environment-jsdom/-/jest-environment-jsdom-23.4.0.tgz#056a7952b3fea513ac62a140a2c368c79d9e6023" @@ -9399,13 +9533,6 @@ jest-environment-jsdom@^23.4.0: jest-util "^23.4.0" jsdom "^11.5.1" -jest-environment-node@^22.4.1: - version "22.4.3" - resolved "https://registry.yarnpkg.com/jest-environment-node/-/jest-environment-node-22.4.3.tgz#54c4eaa374c83dd52a9da8759be14ebe1d0b9129" - dependencies: - jest-mock "^22.4.3" - jest-util "^22.4.3" - jest-environment-node@^23.4.0: version "23.4.0" resolved "https://registry.yarnpkg.com/jest-environment-node/-/jest-environment-node-23.4.0.tgz#57e80ed0841dea303167cce8cd79521debafde10" @@ -9413,22 +9540,10 @@ jest-environment-node@^23.4.0: jest-mock "^23.2.0" jest-util "^23.4.0" -jest-get-type@^22.1.0, jest-get-type@^22.4.3: +jest-get-type@^22.1.0: version "22.4.3" resolved "https://registry.yarnpkg.com/jest-get-type/-/jest-get-type-22.4.3.tgz#e3a8504d8479342dd4420236b322869f18900ce4" -jest-haste-map@^22.4.2: - version "22.4.3" - resolved "http://registry.npmjs.org/jest-haste-map/-/jest-haste-map-22.4.3.tgz#25842fa2ba350200767ac27f658d58b9d5c2e20b" - dependencies: - fb-watchman "^2.0.0" - graceful-fs "^4.1.11" - jest-docblock "^22.4.3" - jest-serializer "^22.4.3" - jest-worker "^22.4.3" - micromatch "^2.3.11" - sane "^2.0.0" - jest-haste-map@^23.6.0: version "23.6.0" resolved "https://registry.yarnpkg.com/jest-haste-map/-/jest-haste-map-23.6.0.tgz#2e3eb997814ca696d62afdb3f2529f5bbc935e16" @@ -9442,22 +9557,6 @@ jest-haste-map@^23.6.0: micromatch "^2.3.11" sane "^2.0.0" -jest-jasmine2@^22.4.4: - version "22.4.4" - resolved "https://registry.yarnpkg.com/jest-jasmine2/-/jest-jasmine2-22.4.4.tgz#c55f92c961a141f693f869f5f081a79a10d24e23" - dependencies: - chalk "^2.0.1" - co "^4.6.0" - expect "^22.4.0" - graceful-fs "^4.1.11" - is-generator-fn "^1.0.0" - jest-diff "^22.4.0" - jest-matcher-utils "^22.4.0" - jest-message-util "^22.4.0" - jest-snapshot "^22.4.0" - jest-util "^22.4.1" - source-map-support "^0.5.0" - jest-jasmine2@^23.6.0: version "23.6.0" resolved "https://registry.yarnpkg.com/jest-jasmine2/-/jest-jasmine2-23.6.0.tgz#840e937f848a6c8638df24360ab869cc718592e0" @@ -9475,26 +9574,12 @@ jest-jasmine2@^23.6.0: jest-util "^23.4.0" pretty-format "^23.6.0" -jest-leak-detector@^22.4.0: - version "22.4.3" - resolved "http://registry.npmjs.org/jest-leak-detector/-/jest-leak-detector-22.4.3.tgz#2b7b263103afae8c52b6b91241a2de40117e5b35" - dependencies: - pretty-format "^22.4.3" - jest-leak-detector@^23.6.0: version "23.6.0" resolved "https://registry.yarnpkg.com/jest-leak-detector/-/jest-leak-detector-23.6.0.tgz#e4230fd42cf381a1a1971237ad56897de7e171de" dependencies: pretty-format "^23.6.0" -jest-matcher-utils@^22.4.0, jest-matcher-utils@^22.4.3: - version "22.4.3" - resolved "http://registry.npmjs.org/jest-matcher-utils/-/jest-matcher-utils-22.4.3.tgz#4632fe428ebc73ebc194d3c7b65d37b161f710ff" - dependencies: - chalk "^2.0.1" - jest-get-type "^22.4.3" - pretty-format "^22.4.3" - jest-matcher-utils@^23.6.0: version "23.6.0" resolved "https://registry.yarnpkg.com/jest-matcher-utils/-/jest-matcher-utils-23.6.0.tgz#726bcea0c5294261a7417afb6da3186b4b8cac80" @@ -9503,16 +9588,6 @@ jest-matcher-utils@^23.6.0: jest-get-type "^22.1.0" pretty-format "^23.6.0" -jest-message-util@^22.4.0, jest-message-util@^22.4.3: - version "22.4.3" - resolved "https://registry.yarnpkg.com/jest-message-util/-/jest-message-util-22.4.3.tgz#cf3d38aafe4befddbfc455e57d65d5239e399eb7" - dependencies: - "@babel/code-frame" "^7.0.0-beta.35" - chalk "^2.0.1" - micromatch "^2.3.11" - slash "^1.0.0" - stack-utils "^1.0.1" - jest-message-util@^23.4.0: version "23.4.0" resolved "https://registry.yarnpkg.com/jest-message-util/-/jest-message-util-23.4.0.tgz#17610c50942349508d01a3d1e0bda2c079086a9f" @@ -9523,28 +9598,14 @@ jest-message-util@^23.4.0: slash "^1.0.0" stack-utils "^1.0.1" -jest-mock@^22.4.3: - version "22.4.3" - resolved "https://registry.yarnpkg.com/jest-mock/-/jest-mock-22.4.3.tgz#f63ba2f07a1511772cdc7979733397df770aabc7" - jest-mock@^23.2.0: version "23.2.0" resolved "https://registry.yarnpkg.com/jest-mock/-/jest-mock-23.2.0.tgz#ad1c60f29e8719d47c26e1138098b6d18b261134" -jest-regex-util@^22.1.0, jest-regex-util@^22.4.3: - version "22.4.3" - resolved "https://registry.yarnpkg.com/jest-regex-util/-/jest-regex-util-22.4.3.tgz#a826eb191cdf22502198c5401a1fc04de9cef5af" - jest-regex-util@^23.3.0: version "23.3.0" resolved "https://registry.yarnpkg.com/jest-regex-util/-/jest-regex-util-23.3.0.tgz#5f86729547c2785c4002ceaa8f849fe8ca471bc5" -jest-resolve-dependencies@^22.1.0: - version "22.4.3" - resolved "http://registry.npmjs.org/jest-resolve-dependencies/-/jest-resolve-dependencies-22.4.3.tgz#e2256a5a846732dc3969cb72f3c9ad7725a8195e" - dependencies: - jest-regex-util "^22.4.3" - jest-resolve-dependencies@^23.6.0: version "23.6.0" resolved "https://registry.yarnpkg.com/jest-resolve-dependencies/-/jest-resolve-dependencies-23.6.0.tgz#b4526af24c8540d9a3fab102c15081cf509b723d" @@ -9552,13 +9613,6 @@ jest-resolve-dependencies@^23.6.0: jest-regex-util "^23.3.0" jest-snapshot "^23.6.0" -jest-resolve@^22.4.2: - version "22.4.3" - resolved "http://registry.npmjs.org/jest-resolve/-/jest-resolve-22.4.3.tgz#0ce9d438c8438229aa9b916968ec6b05c1abb4ea" - dependencies: - browser-resolve "^1.11.2" - chalk "^2.0.1" - jest-resolve@^23.6.0: version "23.6.0" resolved "https://registry.yarnpkg.com/jest-resolve/-/jest-resolve-23.6.0.tgz#cf1d1a24ce7ee7b23d661c33ba2150f3aebfa0ae" @@ -9567,22 +9621,6 @@ jest-resolve@^23.6.0: chalk "^2.0.1" realpath-native "^1.0.0" -jest-runner@^22.4.4: - version "22.4.4" - resolved "https://registry.yarnpkg.com/jest-runner/-/jest-runner-22.4.4.tgz#dfca7b7553e0fa617e7b1291aeb7ce83e540a907" - dependencies: - exit "^0.1.2" - jest-config "^22.4.4" - jest-docblock "^22.4.0" - jest-haste-map "^22.4.2" - jest-jasmine2 "^22.4.4" - jest-leak-detector "^22.4.0" - jest-message-util "^22.4.0" - jest-runtime "^22.4.4" - jest-util "^22.4.1" - jest-worker "^22.2.2" - throat "^4.0.0" - jest-runner@^23.6.0: version "23.6.0" resolved "https://registry.yarnpkg.com/jest-runner/-/jest-runner-23.6.0.tgz#3894bd219ffc3f3cb94dc48a4170a2e6f23a5a38" @@ -9601,31 +9639,6 @@ jest-runner@^23.6.0: source-map-support "^0.5.6" throat "^4.0.0" -jest-runtime@^22.4.4: - version "22.4.4" - resolved "https://registry.yarnpkg.com/jest-runtime/-/jest-runtime-22.4.4.tgz#9ba7792fc75582a5be0f79af6f8fe8adea314048" - dependencies: - babel-core "^6.0.0" - babel-jest "^22.4.4" - babel-plugin-istanbul "^4.1.5" - chalk "^2.0.1" - convert-source-map "^1.4.0" - exit "^0.1.2" - graceful-fs "^4.1.11" - jest-config "^22.4.4" - jest-haste-map "^22.4.2" - jest-regex-util "^22.1.0" - jest-resolve "^22.4.2" - jest-util "^22.4.1" - jest-validate "^22.4.4" - json-stable-stringify "^1.0.1" - micromatch "^2.3.11" - realpath-native "^1.0.0" - slash "^1.0.0" - strip-bom "3.0.0" - write-file-atomic "^2.1.0" - yargs "^10.0.3" - jest-runtime@^23.6.0: version "23.6.0" resolved "https://registry.yarnpkg.com/jest-runtime/-/jest-runtime-23.6.0.tgz#059e58c8ab445917cd0e0d84ac2ba68de8f23082" @@ -9652,25 +9665,10 @@ jest-runtime@^23.6.0: write-file-atomic "^2.1.0" yargs "^11.0.0" -jest-serializer@^22.4.3: - version "22.4.3" - resolved "https://registry.yarnpkg.com/jest-serializer/-/jest-serializer-22.4.3.tgz#a679b81a7f111e4766235f4f0c46d230ee0f7436" - jest-serializer@^23.0.1: version "23.0.1" resolved "https://registry.yarnpkg.com/jest-serializer/-/jest-serializer-23.0.1.tgz#a3776aeb311e90fe83fab9e533e85102bd164165" -jest-snapshot@^22.4.0: - version "22.4.3" - resolved "http://registry.npmjs.org/jest-snapshot/-/jest-snapshot-22.4.3.tgz#b5c9b42846ffb9faccb76b841315ba67887362d2" - dependencies: - chalk "^2.0.1" - jest-diff "^22.4.3" - jest-matcher-utils "^22.4.3" - mkdirp "^0.5.1" - natural-compare "^1.4.0" - pretty-format "^22.4.3" - jest-snapshot@^23.6.0: version "23.6.0" resolved "https://registry.yarnpkg.com/jest-snapshot/-/jest-snapshot-23.6.0.tgz#f9c2625d1b18acda01ec2d2b826c0ce58a5aa17a" @@ -9686,18 +9684,6 @@ jest-snapshot@^23.6.0: pretty-format "^23.6.0" semver "^5.5.0" -jest-util@^22.4.1, jest-util@^22.4.3: - version "22.4.3" - resolved "https://registry.yarnpkg.com/jest-util/-/jest-util-22.4.3.tgz#c70fec8eec487c37b10b0809dc064a7ecf6aafac" - dependencies: - callsites "^2.0.0" - chalk "^2.0.1" - graceful-fs "^4.1.11" - is-ci "^1.0.10" - jest-message-util "^22.4.3" - mkdirp "^0.5.1" - source-map "^0.6.0" - jest-util@^23.4.0: version "23.4.0" resolved "https://registry.yarnpkg.com/jest-util/-/jest-util-23.4.0.tgz#4d063cb927baf0a23831ff61bec2cbbf49793561" @@ -9711,16 +9697,6 @@ jest-util@^23.4.0: slash "^1.0.0" source-map "^0.6.0" -jest-validate@^22.4.4: - version "22.4.4" - resolved "https://registry.yarnpkg.com/jest-validate/-/jest-validate-22.4.4.tgz#1dd0b616ef46c995de61810d85f57119dbbcec4d" - dependencies: - chalk "^2.0.1" - jest-config "^22.4.4" - jest-get-type "^22.1.0" - leven "^2.1.0" - pretty-format "^22.4.0" - jest-validate@^23.5.0, jest-validate@^23.6.0: version "23.6.0" resolved "https://registry.yarnpkg.com/jest-validate/-/jest-validate-23.6.0.tgz#36761f99d1ed33fcd425b4e4c5595d62b6597474" @@ -9738,25 +9714,12 @@ jest-watcher@^23.4.0: chalk "^2.0.1" string-length "^2.0.0" -jest-worker@^22.2.2, jest-worker@^22.4.3: - version "22.4.3" - resolved "https://registry.yarnpkg.com/jest-worker/-/jest-worker-22.4.3.tgz#5c421417cba1c0abf64bf56bd5fb7968d79dd40b" - dependencies: - merge-stream "^1.0.1" - jest-worker@^23.2.0: version "23.2.0" resolved "https://registry.yarnpkg.com/jest-worker/-/jest-worker-23.2.0.tgz#faf706a8da36fae60eb26957257fa7b5d8ea02b9" dependencies: merge-stream "^1.0.1" -jest@22.4.3: - version "22.4.3" - resolved "http://registry.npmjs.org/jest/-/jest-22.4.3.tgz#2261f4b117dc46d9a4a1a673d2150958dee92f16" - dependencies: - import-local "^1.0.0" - jest-cli "^22.4.3" - jest@23.4.1: version "23.4.1" resolved "https://registry.yarnpkg.com/jest/-/jest-23.4.1.tgz#39550c72f3237f63ae1b434d8d122cdf6fa007b6" @@ -9764,7 +9727,7 @@ jest@23.4.1: import-local "^1.0.0" jest-cli "^23.4.1" -jest@^23.4.2, jest@^23.5.0, jest@^23.6.0: +jest@23.6.0, jest@^23.4.2, jest@^23.5.0, jest@^23.6.0: version "23.6.0" resolved "https://registry.yarnpkg.com/jest/-/jest-23.6.0.tgz#ad5835e923ebf6e19e7a1d7529a432edfee7813d" dependencies: @@ -9823,6 +9786,12 @@ js-yaml@~3.7.0: argparse "^1.0.7" esprima "^2.6.0" +js2xmlparser@^3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/js2xmlparser/-/js2xmlparser-3.0.0.tgz#3fb60eaa089c5440f9319f51760ccd07e2499733" + dependencies: + xmlcreate "^1.0.1" + jsbn@~0.1.0: version "0.1.1" resolved "https://registry.yarnpkg.com/jsbn/-/jsbn-0.1.1.tgz#a5e654c2e5a2deb5f201d96cefbca80c0ef2f513" @@ -11031,7 +11000,7 @@ mime@^1.4.1, mime@^1.5.0: version "1.6.0" resolved "https://registry.yarnpkg.com/mime/-/mime-1.6.0.tgz#32cd9e5c64553bd58d19a568af452acff04981b1" -mime@^2.0.3, mime@^2.1.0: +mime@^2.0.3, mime@^2.1.0, mime@^2.3.1: version "2.3.1" resolved "https://registry.yarnpkg.com/mime/-/mime-2.3.1.tgz#b1621c54d63b97c47d3cfe7f7215f7d64517c369" @@ -12764,13 +12733,6 @@ pretty-error@^2.0.2: renderkid "^2.0.1" utila "~0.4" -pretty-format@^22.4.0, pretty-format@^22.4.3: - version "22.4.3" - resolved "http://registry.npmjs.org/pretty-format/-/pretty-format-22.4.3.tgz#f873d780839a9c02e9664c8a082e9ee79eaac16f" - dependencies: - ansi-regex "^3.0.0" - ansi-styles "^3.2.0" - pretty-format@^23.6.0: version "23.6.0" resolved "https://registry.yarnpkg.com/pretty-format/-/pretty-format-23.6.0.tgz#5eaac8eeb6b33b987b7fe6097ea6a8a146ab5760" @@ -12778,7 +12740,7 @@ pretty-format@^23.6.0: ansi-regex "^3.0.0" ansi-styles "^3.2.0" -private@^0.1.6, private@^0.1.7, private@^0.1.8, private@~0.1.5: +private@^0.1.6, private@^0.1.8, private@~0.1.5: version "0.1.8" resolved "https://registry.yarnpkg.com/private/-/private-0.1.8.tgz#2381edb3689f7a53d653190060fcf822d2f368ff" @@ -12995,7 +12957,7 @@ pupa@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/pupa/-/pupa-1.0.0.tgz#9a9568a5af7e657b8462a6e9d5328743560ceff6" -puppeteer@^1.2.0, puppeteer@^1.5.0: +puppeteer@^1.5.0: version "1.8.0" resolved "https://registry.yarnpkg.com/puppeteer/-/puppeteer-1.8.0.tgz#9e8bbd2f5448cc19cac220efc0512837104877ad" dependencies: @@ -13008,6 +12970,19 @@ puppeteer@^1.2.0, puppeteer@^1.5.0: rimraf "^2.6.1" ws "^5.1.1" +puppeteer@^1.8.0-next.1538070839127: + version "1.8.0-next.1538070839127" + resolved "https://registry.yarnpkg.com/puppeteer/-/puppeteer-1.8.0-next.1538070839127.tgz#cef826c679494f30466c7184a730fb3733479b44" + dependencies: + debug "^3.1.0" + extract-zip "^1.6.6" + https-proxy-agent "^2.2.1" + mime "^2.0.3" + progress "^2.0.0" + proxy-from-env "^1.0.0" + rimraf "^2.6.1" + ws "^5.1.1" + q@^1.1.2, q@^1.4.1, q@^1.5.1: version "1.5.1" resolved "https://registry.yarnpkg.com/q/-/q-1.5.1.tgz#7e32f75b41381291d04611f1bf14109ac00651d7" @@ -14846,7 +14821,7 @@ source-map-support@^0.4.15: dependencies: source-map "^0.5.6" -source-map-support@^0.5.0, source-map-support@^0.5.3, source-map-support@^0.5.6: +source-map-support@^0.5.3, source-map-support@^0.5.6: version "0.5.9" resolved "https://registry.yarnpkg.com/source-map-support/-/source-map-support-0.5.9.tgz#41bc953b2534267ea2d605bccfa7bfa3111ced5f" dependencies: @@ -16341,7 +16316,7 @@ uuid@^2.0.1: version "2.0.3" resolved "https://registry.yarnpkg.com/uuid/-/uuid-2.0.3.tgz#67e2e863797215530dff318e5bf9dcebfd47b21a" -uuid@^3.0.1, uuid@^3.1.0, uuid@^3.2.1, uuid@^3.3.2: +uuid@^3.0.0, uuid@^3.0.1, uuid@^3.1.0, uuid@^3.2.1, uuid@^3.3.2: version "3.3.2" resolved "https://registry.yarnpkg.com/uuid/-/uuid-3.3.2.tgz#1b4af4955eb3077c501c23872fc6513811587131" @@ -17161,7 +17136,7 @@ web3@1.0.0-beta.35: web3-shh "1.0.0-beta.35" web3-utils "1.0.0-beta.35" -web3@1.0.0-beta.36, web3@^1.0.0-beta.33, web3@^1.0.0-beta.34: +web3@1.0.0-beta.36, web3@^1.0.0-beta.33, web3@^1.0.0-beta.34, web3@^1.0.0-beta.36: version "1.0.0-beta.36" resolved "https://registry.yarnpkg.com/web3/-/web3-1.0.0-beta.36.tgz#2954da9e431124c88396025510d840ba731c8373" dependencies: @@ -17669,6 +17644,10 @@ xmlbuilder@^4.1.0: dependencies: lodash "^4.0.0" +xmlcreate@^1.0.1: + version "1.0.2" + resolved "https://registry.yarnpkg.com/xmlcreate/-/xmlcreate-1.0.2.tgz#fa6bf762a60a413fb3dd8f4b03c5b269238d308f" + xmlhttprequest-ssl@1.5.3: version "1.5.3" resolved "https://registry.yarnpkg.com/xmlhttprequest-ssl/-/xmlhttprequest-ssl-1.5.3.tgz#185a888c04eca46c3e4070d99f7b49de3528992d" From 5dd7212bdf6e9e8451ede3378d53bb691edff210 Mon Sep 17 00:00:00 2001 From: Federico Obialero Date: Wed, 3 Oct 2018 17:21:42 +0200 Subject: [PATCH 7/8] code refactor (#466) --- packages/api/src/api.ts | 4 +- .../CreateVaultForm/CreateVaultForm.test.js | 3 -- .../CreateVaultModal/CreateVaultModal.test.js | 3 -- .../organisms/VaultSelect/VaultSelect.test.js | 3 -- .../src/epics/blockChain/BlockChainService.js | 4 +- .../blockChain/BlockChainService.test.js | 49 ++++++++++--------- .../blockChain/getAccountBalance.test.js | 36 ++++++++------ .../dapp/src/epics/vaults/createVault.test.js | 14 ++---- .../src/epics/vaults/fetchVaultEvents.test.js | 1 - .../src/epics/vaults/getVaultFees.test.js | 16 +++--- .../src/epics/vaults/getVaultSupply.test.js | 4 +- .../src/epics/vaults/registerVaults.test.js | 8 ++- .../src/epics/vaults/watchVaultEvents.test.js | 1 - packages/dapp/src/pages/Vaults/Vaults.jsx | 2 - packages/dapp/src/pages/Vaults/Vaults.test.js | 4 +- 15 files changed, 68 insertions(+), 84 deletions(-) diff --git a/packages/api/src/api.ts b/packages/api/src/api.ts index 1adf7da84..b017dba67 100644 --- a/packages/api/src/api.ts +++ b/packages/api/src/api.ts @@ -25,7 +25,7 @@ class Api { }) } - async init(web3: Web3 = window.web3, rpcUrl = 'http://localhost:8545') { + async init(web3: Web3 = window.web3, rpcUrl = 'ws://localhost:8545') { this.engine = new ProviderEngine() this.engine.addProvider(new SignerSubprovider(web3.currentProvider)) this.engine.addProvider(new FilterSubprovider()) @@ -36,7 +36,7 @@ class Api { }) this.engine.addProvider( new WebSocketSubProvider({ - rpcUrl: 'ws://localhost:8545' + rpcUrl }) ) diff --git a/packages/dapp/src/components/organisms/CreateVaultForm/CreateVaultForm.test.js b/packages/dapp/src/components/organisms/CreateVaultForm/CreateVaultForm.test.js index 0e27c9f14..53aeba4c4 100644 --- a/packages/dapp/src/components/organisms/CreateVaultForm/CreateVaultForm.test.js +++ b/packages/dapp/src/components/organisms/CreateVaultForm/CreateVaultForm.test.js @@ -13,9 +13,6 @@ describe('CreateVaultForm component', () => { address: '0xf7cbb0849d4a8ec5ab4650030fa776c00eb52la4', createAndValidate: jest.fn() } - }, - web3: { - '._web3': {} } } diff --git a/packages/dapp/src/components/organisms/CreateVaultModal/CreateVaultModal.test.js b/packages/dapp/src/components/organisms/CreateVaultModal/CreateVaultModal.test.js index a15c82fe5..a334295fa 100644 --- a/packages/dapp/src/components/organisms/CreateVaultModal/CreateVaultModal.test.js +++ b/packages/dapp/src/components/organisms/CreateVaultModal/CreateVaultModal.test.js @@ -11,9 +11,6 @@ describe('CreateVaultModal component', () => { address: '0xf7cbb0849d4a8ec5ab4650030fa776c00eb52la4', createAndValidate: jest.fn() } - }, - web3: { - '._web3': {} } } diff --git a/packages/dapp/src/components/organisms/VaultSelect/VaultSelect.test.js b/packages/dapp/src/components/organisms/VaultSelect/VaultSelect.test.js index f210d0eac..14722fb85 100644 --- a/packages/dapp/src/components/organisms/VaultSelect/VaultSelect.test.js +++ b/packages/dapp/src/components/organisms/VaultSelect/VaultSelect.test.js @@ -16,9 +16,6 @@ describe('VaultSelect component', () => { address: '0xf7cbb0849d4a8ec5ab4650030fa776c00eb52la4', createAndValidate: jest.fn() } - }, - web3: { - '._web3': {} } } diff --git a/packages/dapp/src/epics/blockChain/BlockChainService.js b/packages/dapp/src/epics/blockChain/BlockChainService.js index 17fbc20af..68b348968 100644 --- a/packages/dapp/src/epics/blockChain/BlockChainService.js +++ b/packages/dapp/src/epics/blockChain/BlockChainService.js @@ -150,9 +150,9 @@ class BlockChainService { return fromPromise( this.api.web3.eth.getBlock(block.blockNumber), this.scheduler - ).map(retrievedBlock => ({ + ).map(({ timestamp }) => ({ ...block, - timestamp: retrievedBlock.timestamp * 1000 + timestamp: timestamp * 1000 })) }) .map(decoratedBlock => { diff --git a/packages/dapp/src/epics/blockChain/BlockChainService.test.js b/packages/dapp/src/epics/blockChain/BlockChainService.test.js index 73f6d09ac..93556c2e5 100644 --- a/packages/dapp/src/epics/blockChain/BlockChainService.test.js +++ b/packages/dapp/src/epics/blockChain/BlockChainService.test.js @@ -6,14 +6,10 @@ import blockChainActions from '../../actions/blockchain-actions' describe('blockChain services function', () => { const testError = new Error('test error') - let BlockChainService - let fromPromiseSpy - let apiMock - let contractFactoryMock + const nodeVersion = 'MetaMask/v4.6.1' const owner = '0x242B2Dd21e7E1a2b2516d0A3a06b58e2D9BF9196' const blocks = [ { - address: '0x001', returnValues: { vault: '0x123', from: owner, @@ -24,7 +20,6 @@ describe('blockChain services function', () => { event: 'BuyVault' }, { - address: '0x002', returnValues: { vault: '0x123', from: '0x242b2dd21e7e1a2b2516d0a3a06b58e2d9bf9192', @@ -35,7 +30,14 @@ describe('blockChain services function', () => { event: 'SellVault' } ] + + let BlockChainService + let fromPromiseSpy + let apiMock + let contractFactoryMock + beforeEach(() => { + jest.resetModules() fromPromiseSpy = jest.fn() contractFactoryMock = { getInstance: jest.fn() @@ -48,9 +50,9 @@ describe('blockChain services function', () => { }, web3: { eth: { - getNodeInfo: jest.fn(() => Promise.resolve('')), - getAccounts: jest.fn(() => Promise.resolve([])), - getBlock: jest.fn(() => Promise.resolve({ timestamp: '1528811195' })) + getNodeInfo: jest.fn(), + getAccounts: jest.fn(), + getBlock: jest.fn() } }, contract: { @@ -59,7 +61,6 @@ describe('blockChain services function', () => { } } } - jest.resetModules() jest.doMock('rxjs/observable/fromPromise', () => ({ fromPromise: fromPromiseSpy })) @@ -75,7 +76,7 @@ describe('blockChain services function', () => { }) it('returns a blockchain init action', () => { fromPromiseSpy - .mockReturnValueOnce(of('MetaMask/v4.6.1')) + .mockReturnValueOnce(of(nodeVersion)) .mockReturnValueOnce(of([])) const expectedValues = { @@ -100,11 +101,11 @@ describe('blockChain services function', () => { const address2 = 'address2' fromPromiseSpy - .mockReturnValueOnce(of('MetaMask/v4.6.1')) + .mockReturnValueOnce(of(nodeVersion)) .mockReturnValueOnce(of([address1])) - .mockReturnValueOnce(of('MetaMask/v4.6.1')) + .mockReturnValueOnce(of(nodeVersion)) .mockReturnValueOnce(of([address2])) - .mockReturnValueOnce(of('MetaMask/v4.6.1')) + .mockReturnValueOnce(of(nodeVersion)) .mockReturnValueOnce(of([address1])) const expectedValues = { @@ -138,7 +139,7 @@ describe('blockChain services function', () => { it('sends blockChainError action if web3 getAvailableAddressesAsync fails', () => { fromPromiseSpy - .mockReturnValueOnce(of('MetaMask/v4.6.1')) + .mockReturnValueOnce(of(nodeVersion)) .mockReturnValueOnce(_throw(testError)) const expectedValues = { @@ -161,16 +162,15 @@ describe('blockChain services function', () => { }) it('sends blockChainLogin action if web3 retrieves accounts list', () => { - const address = owner fromPromiseSpy - .mockReturnValueOnce(of('MetaMask/v4.6.1')) - .mockReturnValueOnce(of([address])) + .mockReturnValueOnce(of(nodeVersion)) + .mockReturnValueOnce(of([owner])) const expectedValues = { a: blockChainActions.blockChainInit(), b: blockChainActions.blockChainLogIn({ provider: 'metamask', - account: address + account: owner }) } @@ -190,7 +190,7 @@ describe('blockChain services function', () => { it("sends blockChainLogout action if web3 doesn't retrieve accounts list", () => { fromPromiseSpy - .mockReturnValueOnce(of('MetaMask/v4.6.1')) + .mockReturnValueOnce(of(nodeVersion)) .mockReturnValueOnce(of([])) const expectedValues = { @@ -220,7 +220,7 @@ describe('blockChain services function', () => { it('listens for connectivity issues', () => { fromPromiseSpy.mockReturnValueOnce(of('')).mockReturnValueOnce(of([])) - const mockApi = { + const apiWithError = { ...apiMock, engine: { on: (_, cb) => cb(testError), @@ -239,7 +239,12 @@ describe('blockChain services function', () => { expect(actual).toEqual(expected) }) - const blockChainService = new BlockChainService(mockApi, null, null, ts) + const blockChainService = new BlockChainService( + apiWithError, + null, + null, + ts + ) const outputAction = blockChainService.init() ts.expectObservable(outputAction).toBe(expectedMarble, expectedValues) ts.flush() diff --git a/packages/dapp/src/epics/blockChain/getAccountBalance.test.js b/packages/dapp/src/epics/blockChain/getAccountBalance.test.js index 5e0cda228..63071fef0 100644 --- a/packages/dapp/src/epics/blockChain/getAccountBalance.test.js +++ b/packages/dapp/src/epics/blockChain/getAccountBalance.test.js @@ -8,6 +8,10 @@ import blockChainActions from '../../actions/blockchain-actions' describe('getAccountBalanceEpic', () => { const owner = '0x242B2Dd21e7E1a2b2516d0A3a06b58e2D9BF9196' const otherAccount = '0x8BB7481495D45CCD5CFFAE1C3A84155FEA85A323' + const firstBalance = '10000000000000000000' + const secondBalance = '20000000000000000000' + const thirdBalance = '15000000000000000000' + const fourthBalance = '25000000000000000000' const getBalanceSpy = jest.fn() const apiMock = { web3: { @@ -42,7 +46,7 @@ describe('getAccountBalanceEpic', () => { }) it('dispatches an updateAccountBalance action upon user login', () => { - fromPromiseSpy.mockReturnValueOnce(of('25999999999952600000')) + fromPromiseSpy.mockReturnValueOnce(of(firstBalance)) const inputValues = { a: blockChainActions.blockChainLogIn({ provider: 'metamask', @@ -52,7 +56,7 @@ describe('getAccountBalanceEpic', () => { const expectedValues = { b: blockChainActions.updateAccountBalance({ account: owner, - balance: new BigNumber('25999999999952600000') + balance: new BigNumber(firstBalance) }) } @@ -73,7 +77,7 @@ describe('getAccountBalanceEpic', () => { }) it('dispatches an updateAccountBalance action if we register a block which interests the current account', () => { - fromPromiseSpy.mockReturnValueOnce(of('10000000000000000000')) + fromPromiseSpy.mockReturnValueOnce(of(firstBalance)) const inputAction = blockChainActions.registerBlock({ account: owner, label: VAULT, @@ -86,7 +90,7 @@ describe('getAccountBalanceEpic', () => { const expectedValues = { b: blockChainActions.updateAccountBalance({ account: owner, - balance: new BigNumber('10000000000000000000') + balance: new BigNumber(firstBalance) }) } @@ -111,8 +115,8 @@ describe('getAccountBalanceEpic', () => { it('dispatches the action after emissions stopped for 500ms, only taking last received value', () => { fromPromiseSpy - .mockReturnValueOnce(of('10000000000000000000')) - .mockReturnValueOnce(of('20000000000000000000')) + .mockReturnValueOnce(of(firstBalance)) + .mockReturnValueOnce(of(secondBalance)) const inputAction = blockChainActions.registerBlock({ account: owner, @@ -125,11 +129,11 @@ describe('getAccountBalanceEpic', () => { const expectedValues = { a: blockChainActions.updateAccountBalance({ account: owner, - balance: new BigNumber('10000000000000000000') + balance: new BigNumber(firstBalance) }), b: blockChainActions.updateAccountBalance({ account: owner, - balance: new BigNumber('20000000000000000000') + balance: new BigNumber(secondBalance) }) } @@ -155,10 +159,10 @@ describe('getAccountBalanceEpic', () => { it('dispatches multiple actions if we receive multiple registration for different accounts', () => { fromPromiseSpy - .mockReturnValueOnce(of('10000000000000000000')) - .mockReturnValueOnce(of('15000000000000000000')) - .mockReturnValueOnce(of('20000000000000000000')) - .mockReturnValueOnce(of('25000000000000000000')) + .mockReturnValueOnce(of(firstBalance)) + .mockReturnValueOnce(of(thirdBalance)) + .mockReturnValueOnce(of(secondBalance)) + .mockReturnValueOnce(of(fourthBalance)) const inputAction1 = blockChainActions.registerBlock({ account: owner, @@ -177,19 +181,19 @@ describe('getAccountBalanceEpic', () => { const expectedValues = { a: blockChainActions.updateAccountBalance({ account: owner, - balance: new BigNumber('10000000000000000000') + balance: new BigNumber(firstBalance) }), b: blockChainActions.updateAccountBalance({ account: owner, - balance: new BigNumber('20000000000000000000') + balance: new BigNumber(secondBalance) }), c: blockChainActions.updateAccountBalance({ account: otherAccount, - balance: new BigNumber('15000000000000000000') + balance: new BigNumber(thirdBalance) }), d: blockChainActions.updateAccountBalance({ account: otherAccount, - balance: new BigNumber('25000000000000000000') + balance: new BigNumber(fourthBalance) }) } diff --git a/packages/dapp/src/epics/vaults/createVault.test.js b/packages/dapp/src/epics/vaults/createVault.test.js index 3b3238844..fd12ac655 100644 --- a/packages/dapp/src/epics/vaults/createVault.test.js +++ b/packages/dapp/src/epics/vaults/createVault.test.js @@ -18,34 +18,28 @@ describe('createVault Epic', () => { const mockStore = { getState: getStateMock } - let contractFactoryMock - + const contractFactoryMock = { + getInstance: jest.fn() + } class VaultFactoryMock { createVault() { return Promise.resolve({ send: () => {} }) } } - const apiMock = { - web3: { - _web3: {} - }, + web3: {}, contract: { VaultFactory: { address: '0x0' } } } - let createVaultEpic let fromPromiseSpy beforeEach(() => { jest.resetModules() fromPromiseSpy = jest.fn() - contractFactoryMock = { - getInstance: jest.fn() - } jest.doMock('rxjs/observable/fromPromise', () => ({ fromPromise: fromPromiseSpy })) diff --git a/packages/dapp/src/epics/vaults/fetchVaultEvents.test.js b/packages/dapp/src/epics/vaults/fetchVaultEvents.test.js index b2a0d6aa7..b3613c729 100644 --- a/packages/dapp/src/epics/vaults/fetchVaultEvents.test.js +++ b/packages/dapp/src/epics/vaults/fetchVaultEvents.test.js @@ -27,7 +27,6 @@ describe('fetchVaultEventsEpic', () => { } const getStateSpy = jest.fn() const fetchVaultEventsSpy = jest.fn() - const mockStore = { getState: getStateSpy } diff --git a/packages/dapp/src/epics/vaults/getVaultFees.test.js b/packages/dapp/src/epics/vaults/getVaultFees.test.js index 5cba83ce4..015fdc561 100644 --- a/packages/dapp/src/epics/vaults/getVaultFees.test.js +++ b/packages/dapp/src/epics/vaults/getVaultFees.test.js @@ -15,9 +15,6 @@ describe('getVaultFees epics', () => { transactionFee, vaultDao: '0x7ce6e371085cb611fb46d5065397223ef2F952Ff' } - let fromPromiseSpy - let getVaultFees - const vault = { [vaultAddress]: { id: new BigNumber('0'), @@ -27,28 +24,31 @@ describe('getVaultFees epics', () => { group: '0x7ce6e371085cb611fb46d5065397223ef2f952ff' } } - + const contractFactoryMock = { + getInstance: jest.fn() + } class VaultMock { getAdminData = () => transactionFee } const apiMock = { - web3: { - _web3: {} - }, + web3: {}, contract: { Vault: { createAndValidate: () => new VaultMock() } } } + let fromPromiseSpy + let getVaultFees beforeEach(() => { - fromPromiseSpy = jest.fn() jest.resetModules() + fromPromiseSpy = jest.fn() jest.doMock('rxjs/observable/fromPromise', () => ({ fromPromise: fromPromiseSpy })) jest.doMock('../../api', () => apiMock) + jest.doMock('../../contractFactory', () => contractFactoryMock) getVaultFees = require('./getVaultFees').default }) diff --git a/packages/dapp/src/epics/vaults/getVaultSupply.test.js b/packages/dapp/src/epics/vaults/getVaultSupply.test.js index 4b5f2cc6b..0744ab361 100644 --- a/packages/dapp/src/epics/vaults/getVaultSupply.test.js +++ b/packages/dapp/src/epics/vaults/getVaultSupply.test.js @@ -29,9 +29,7 @@ describe('getVaultSupply epics', () => { } } const apiMock = { - web3: { - _web3: {} - } + web3: {} } beforeEach(() => { diff --git a/packages/dapp/src/epics/vaults/registerVaults.test.js b/packages/dapp/src/epics/vaults/registerVaults.test.js index 387f31628..25ed1265a 100644 --- a/packages/dapp/src/epics/vaults/registerVaults.test.js +++ b/packages/dapp/src/epics/vaults/registerVaults.test.js @@ -42,20 +42,18 @@ describe('registerVaults epic', () => { } let fromPromiseSpy let registerVaults - let contractFactoryMock + const contractFactoryMock = { + getInstance: jest.fn() + } beforeEach(() => { jest.resetModules() fromPromiseSpy = jest.fn() - contractFactoryMock = { - getInstance: jest.fn() - } jest.doMock('../../api', () => apiMock) jest.doMock('rxjs/observable/fromPromise', () => ({ fromPromise: fromPromiseSpy })) jest.doMock('../../contractFactory', () => contractFactoryMock) - registerVaults = require('./registerVaults').default }) diff --git a/packages/dapp/src/epics/vaults/watchVaultEvents.test.js b/packages/dapp/src/epics/vaults/watchVaultEvents.test.js index ca9a614cb..f491ce305 100644 --- a/packages/dapp/src/epics/vaults/watchVaultEvents.test.js +++ b/packages/dapp/src/epics/vaults/watchVaultEvents.test.js @@ -28,7 +28,6 @@ describe('watchVaultEvents', () => { } const getStateSpy = jest.fn() const watchVaultEventsSpy = jest.fn() - const mockStore = { getState: getStateSpy } diff --git a/packages/dapp/src/pages/Vaults/Vaults.jsx b/packages/dapp/src/pages/Vaults/Vaults.jsx index 35e38d6c6..ad3e5fff3 100644 --- a/packages/dapp/src/pages/Vaults/Vaults.jsx +++ b/packages/dapp/src/pages/Vaults/Vaults.jsx @@ -6,8 +6,6 @@ import VaultSelect from '../../components/organisms/VaultSelect' class Vaults extends Component { render() { - // TODO: use the match prop to render the correct Vault - // depending on url return ( diff --git a/packages/dapp/src/pages/Vaults/Vaults.test.js b/packages/dapp/src/pages/Vaults/Vaults.test.js index 5971544f8..d724f524f 100644 --- a/packages/dapp/src/pages/Vaults/Vaults.test.js +++ b/packages/dapp/src/pages/Vaults/Vaults.test.js @@ -10,9 +10,7 @@ describe('Vaults page', () => { createAndValidate: jest.fn() } }, - web3: { - '._web3': {} - } + web3: {} } let Vaults From 3839b5fb8892b0c6d39f4ac99f6e2022bac612de Mon Sep 17 00:00:00 2001 From: Federico Date: Wed, 3 Oct 2018 18:24:02 +0200 Subject: [PATCH 8/8] updated createVault to estimate the gas amount rather than using hardcoded one --- packages/dapp/src/epics/vaults/createVault.js | 45 ++++++++++++------- .../dapp/src/epics/vaults/createVault.test.js | 29 +++++++++--- 2 files changed, 54 insertions(+), 20 deletions(-) diff --git a/packages/dapp/src/epics/vaults/createVault.js b/packages/dapp/src/epics/vaults/createVault.js index 9d51a7ff7..bfc8269ce 100644 --- a/packages/dapp/src/epics/vaults/createVault.js +++ b/packages/dapp/src/epics/vaults/createVault.js @@ -3,11 +3,13 @@ import 'rxjs/add/operator/filter' import 'rxjs/add/operator/map' import 'rxjs/add/operator/mergeMap' import 'rxjs/add/operator/switchMap' +import { BigNumber } from 'bignumber.js' import { CREATE_VAULT } from '../../constants/transaction-types' import { Scheduler } from 'rxjs/Scheduler' import { fromPromise } from 'rxjs/observable/fromPromise' import { merge } from 'rxjs/observable/merge' import { of } from 'rxjs/observable/of' +import { zip } from 'rxjs/observable/zip' import api from '../../api' import blockChainActions from '../../actions/blockchain-actions' import contractFactory from '../../contractFactory' @@ -29,25 +31,38 @@ const createVaultEpic = (action$, store, ts = Scheduler.async) => { api.contract.VaultFactory.address ), ts - ).switchMap(vaultFactory => - of(vaultFactory) - .mergeMap(() => + ) + .switchMap(vaultFactory => { + return zip( + fromPromise(api.web3.eth.getGasPrice(), ts), fromPromise( - vaultFactory - .createVault(vaultName.toLowerCase(), vaultSymbol) - .then(obj => - obj.send({ from: accountNumber, gasPrice: 1, gas: 6654755 }) - ), + vaultFactory.createVault(vaultName.toLowerCase(), vaultSymbol), ts - ).map(txHash => - blockChainActions.transactionCompleted({ - type: CREATE_VAULT, - txHash - }) ) ) - .catch(e => of(blockChainActions.transactionFailed(e.toString()))) - ) + }) + .mergeMap(([gasPrice, txObj]) => { + const txOptions = { from: accountNumber } + return fromPromise( + txObj.estimateGas(txOptions).then(gas => { + return txObj.send({ + ...txOptions, + gasPrice, + // adding 20% to the gas limit as the estimate isn't + // always accurate + gas: new BigNumber(gas).times(1.2).toFixed(0) + }) + }), + ts + ) + }) + .map(({ transactionHash }) => + blockChainActions.transactionCompleted({ + type: CREATE_VAULT, + txHash: transactionHash + }) + ) + .catch(e => of(blockChainActions.transactionFailed(e.toString()))) ) return merge(action$1, action$2) diff --git a/packages/dapp/src/epics/vaults/createVault.test.js b/packages/dapp/src/epics/vaults/createVault.test.js index fd12ac655..c84f6f473 100644 --- a/packages/dapp/src/epics/vaults/createVault.test.js +++ b/packages/dapp/src/epics/vaults/createVault.test.js @@ -9,11 +9,15 @@ import vaultActions from '../../actions/vault-actions' describe('createVault Epic', () => { const owner = '0x242B2Dd21e7E1a2b2516d0A3a06b58e2D9BF9196' - const txHash = - '0x5d5d3dd42388e0f7fffb8f526117a01202015ced105caf216ede7f560b0e1082' + const transaction = { + transactionHash: + '0x5d5d3dd42388e0f7fffb8f526117a01202015ced105caf216ede7f560b0e1082' + } const txError = new Error( 'MetaMask Tx Signature: User denied transaction signature.' ) + const gasPrice = '20000000000' + const gasEstimate = '2455473' const getStateMock = jest.fn() const mockStore = { getState: getStateMock @@ -27,13 +31,21 @@ describe('createVault Epic', () => { } } const apiMock = { - web3: {}, + web3: { + eth: { + getGasPrice: jest.fn() + } + }, contract: { VaultFactory: { address: '0x0' } } } + const txObject = { + estimateGas: jest.fn(() => Promise.resolve(gasEstimate)), + send: jest.fn() + } let createVaultEpic let fromPromiseSpy @@ -51,7 +63,9 @@ describe('createVault Epic', () => { it('emits transactionInProgress action when createVault is fired, and a transactionCompleted when the transaction resolves', () => { fromPromiseSpy .mockReturnValueOnce(of(new VaultFactoryMock())) - .mockReturnValueOnce(of(txHash)) + .mockReturnValueOnce(of(gasPrice)) + .mockReturnValueOnce(of(txObject)) + .mockReturnValueOnce(of(transaction)) const inputValues = { a: vaultActions.createVault({ @@ -62,7 +76,10 @@ describe('createVault Epic', () => { } const expectedValues = { b: blockChainActions.transactionInProgress('Create Vault'), - c: blockchainActions.transactionCompleted({ type: CREATE_VAULT, txHash }) + c: blockchainActions.transactionCompleted({ + type: CREATE_VAULT, + txHash: transaction.transactionHash + }) } const inputMarble = 'a' @@ -84,6 +101,8 @@ describe('createVault Epic', () => { it('emits a transactionFailed action if there was an error during the transaction', () => { fromPromiseSpy .mockReturnValueOnce(of(new VaultFactoryMock())) + .mockReturnValueOnce(of(gasPrice)) + .mockReturnValueOnce(of(txObject)) .mockReturnValueOnce(ErrorObservable.create(txError)) const inputValues = {