diff --git a/packages/app/src/components/protocol/Protocol.react.js b/packages/app/src/components/protocol/Protocol.react.js index b1bce27..f3a11fe 100644 --- a/packages/app/src/components/protocol/Protocol.react.js +++ b/packages/app/src/components/protocol/Protocol.react.js @@ -3,7 +3,7 @@ import Store from '../../store/store' import Network from '../../web3/Network' import ProtocolActions from '../../actions/protocol' import { fromWei } from 'web3-utils' -import { bn } from '@aragon/protocol-backend-shared/helpers/numbers' +import { bn } from '@aragon/protocol-backend-shared/build/helpers/numbers' export default class Protocol extends React.Component { diff --git a/packages/app/src/web3/Network.js b/packages/app/src/web3/Network.js index 57577b0..bb42dfc 100644 --- a/packages/app/src/web3/Network.js +++ b/packages/app/src/web3/Network.js @@ -1,5 +1,5 @@ -import Protocol from '@aragon/protocol-backend-shared/models/Protocol' -import Environment from '@aragon/protocol-backend-shared/models/environments/BrowserEnvironment' +import Protocol from '@aragon/protocol-backend-shared/build/models/Protocol' +import Environment from '@aragon/protocol-backend-shared/build/models/environments/BrowserEnvironment' const FAUCET = { staging: '0x19420Cf68cf6a8d18882730c8e8BAd169eeb1bdC', diff --git a/packages/cli/README.md b/packages/cli/README.md index 6ac8a7a..9eb0a06 100644 --- a/packages/cli/README.md +++ b/packages/cli/README.md @@ -31,8 +31,8 @@ To use the CLI tool locally simply run the following commands to install it loca ```bash git clone https://github.com/aragon/protocol-backend/ cd protocol-backend - npm i - npx lerna bootstrap + yarn install + yarn build:shared cd packages/cli ``` diff --git a/packages/cli/bin/index.js b/packages/cli/bin/index.js index 51f0234..5d781ac 100755 --- a/packages/cli/bin/index.js +++ b/packages/cli/bin/index.js @@ -3,8 +3,8 @@ const fs = require('fs') const path = require('path') const yargs = require('yargs') -const Logger = require('@aragon/protocol-backend-shared/helpers/logger') -const Environment = require('@aragon/protocol-backend-shared/models/environments/TruffleEnvironment') +const { setDefaults } = require('@aragon/protocol-backend-shared/build/helpers/logger') +const Environment = require('@aragon/protocol-backend-shared/build/models/environments/TruffleEnvironment').default const errorHandler = require('../src/helpers/error-handler') const DEFAULT_OPTIONS = { @@ -24,7 +24,7 @@ commands.forEach(commandFilename => { command.handler = argv => { const { from, network, silent, verbose } = argv const environment = new Environment(network, from) - Logger.setDefaults(silent, verbose) + setDefaults(silent, verbose) command.handlerAsync(environment, argv).then(() => process.exit(0)).catch(errorHandler) } diff --git a/packages/cli/bin/setup.js b/packages/cli/bin/setup.js index 71ae764..3d8e249 100644 --- a/packages/cli/bin/setup.js +++ b/packages/cli/bin/setup.js @@ -1,11 +1,11 @@ const yargs = require('yargs') -const { bn } = require('@aragon/protocol-backend-shared/helpers/numbers') +const { bn } = require('@aragon/protocol-backend-shared/build/helpers/numbers') const { execSync } = require('child_process') const errorHandler = require('../src/helpers/error-handler') -const Logger = require('@aragon/protocol-backend-shared/helpers/logger') -const Environment = require('@aragon/protocol-backend-shared/models/environments/TruffleEnvironment') +const { Logger, setDefaults } = require('@aragon/protocol-backend-shared/build/helpers/logger') +const Environment = require('@aragon/protocol-backend-shared/build/models/environments/TruffleEnvironment').default -Logger.setDefaults(false, false) +setDefaults(false, false) const logger = Logger('setup') const { network, guardians: guardiansNumber, disputes } = yargs diff --git a/packages/cli/src/commands/activate.js b/packages/cli/src/commands/activate.js index 332a23b..c1c0d82 100644 --- a/packages/cli/src/commands/activate.js +++ b/packages/cli/src/commands/activate.js @@ -1,4 +1,4 @@ -const logger = require('@aragon/protocol-backend-shared/helpers/logger')('activate') +const logger = require('@aragon/protocol-backend-shared/build/helpers/logger').default('activate') const command = 'activate' const describe = 'Activate tokens to the Protocol' diff --git a/packages/cli/src/commands/appeal.js b/packages/cli/src/commands/appeal.js index 3bee338..8875936 100644 --- a/packages/cli/src/commands/appeal.js +++ b/packages/cli/src/commands/appeal.js @@ -1,4 +1,4 @@ -const logger = require('@aragon/protocol-backend-shared/helpers/logger')('appeal') +const logger = require('@aragon/protocol-backend-shared/build/helpers/logger').default('appeal') const command = 'appeal' const describe = 'Appeal dispute in favour of a certain outcome' diff --git a/packages/cli/src/commands/arbitrable.js b/packages/cli/src/commands/arbitrable.js index 6ca9bf1..2df61cb 100644 --- a/packages/cli/src/commands/arbitrable.js +++ b/packages/cli/src/commands/arbitrable.js @@ -1,4 +1,4 @@ -const logger = require('@aragon/protocol-backend-shared/helpers/logger')('arbitrable') +const logger = require('@aragon/protocol-backend-shared/build/helpers/logger').default('arbitrable') const command = 'arbitrable' const describe = 'Create new Arbitrable instance for the Protocol' diff --git a/packages/cli/src/commands/commit.js b/packages/cli/src/commands/commit.js index 42b3f67..9f945de 100644 --- a/packages/cli/src/commands/commit.js +++ b/packages/cli/src/commands/commit.js @@ -1,4 +1,4 @@ -const logger = require('@aragon/protocol-backend-shared/helpers/logger')('commit') +const logger = require('@aragon/protocol-backend-shared/build/helpers/logger').default('commit') const command = 'commit' const describe = 'Commit vote for a dispute round' diff --git a/packages/cli/src/commands/config.js b/packages/cli/src/commands/config.js index 450637a..dbe58ac 100644 --- a/packages/cli/src/commands/config.js +++ b/packages/cli/src/commands/config.js @@ -1,6 +1,6 @@ const path = require('path') -const logger = require('@aragon/protocol-backend-shared/helpers/logger')('config') -const { bn } = require('@aragon/protocol-backend-shared/helpers/numbers') +const logger = require('@aragon/protocol-backend-shared/build/helpers/logger').default('config') +const { bn } = require('@aragon/protocol-backend-shared/build/helpers/numbers') const command = 'config' const describe = 'Get current protocol config or set a new one' diff --git a/packages/cli/src/commands/confirm-appeal.js b/packages/cli/src/commands/confirm-appeal.js index 38cd57c..ec917a1 100644 --- a/packages/cli/src/commands/confirm-appeal.js +++ b/packages/cli/src/commands/confirm-appeal.js @@ -1,4 +1,4 @@ -const logger = require('@aragon/protocol-backend-shared/helpers/logger')('confirm-appeal') +const logger = require('@aragon/protocol-backend-shared/build/helpers/logger').default('confirm-appeal') const command = 'confirm-appeal' const describe = 'Confirm an existing appeal for a dispute' diff --git a/packages/cli/src/commands/deactivate.js b/packages/cli/src/commands/deactivate.js index add0242..abd9807 100644 --- a/packages/cli/src/commands/deactivate.js +++ b/packages/cli/src/commands/deactivate.js @@ -1,4 +1,4 @@ -const logger = require('@aragon/protocol-backend-shared/helpers/logger')('deactivate') +const logger = require('@aragon/protocol-backend-shared/build/helpers/logger').default('deactivate') const command = 'deactivate' const describe = 'Deactivate tokens to the Protocol' diff --git a/packages/cli/src/commands/dispute.js b/packages/cli/src/commands/dispute.js index eff49d8..f2c69fc 100644 --- a/packages/cli/src/commands/dispute.js +++ b/packages/cli/src/commands/dispute.js @@ -1,4 +1,4 @@ -const logger = require('@aragon/protocol-backend-shared/helpers/logger')('dispute') +const logger = require('@aragon/protocol-backend-shared/build/helpers/logger').default('dispute') const command = 'dispute' const describe = 'Create dispute submitting evidence' diff --git a/packages/cli/src/commands/draft.js b/packages/cli/src/commands/draft.js index 149494a..faea691 100644 --- a/packages/cli/src/commands/draft.js +++ b/packages/cli/src/commands/draft.js @@ -1,4 +1,4 @@ -const logger = require('@aragon/protocol-backend-shared/helpers/logger')('draft') +const logger = require('@aragon/protocol-backend-shared/build/helpers/logger').default('draft') const command = 'draft' const describe = 'Draft dispute and close evidence submission period if necessary' diff --git a/packages/cli/src/commands/execute.js b/packages/cli/src/commands/execute.js index f110e30..60a3951 100644 --- a/packages/cli/src/commands/execute.js +++ b/packages/cli/src/commands/execute.js @@ -1,4 +1,4 @@ -const logger = require('@aragon/protocol-backend-shared/helpers/logger')('execute') +const logger = require('@aragon/protocol-backend-shared/build/helpers/logger').default('execute') const command = 'execute' const describe = 'Execute ruling for a dispute' diff --git a/packages/cli/src/commands/hearbeat.js b/packages/cli/src/commands/hearbeat.js index 4193797..e076c33 100644 --- a/packages/cli/src/commands/hearbeat.js +++ b/packages/cli/src/commands/hearbeat.js @@ -1,4 +1,4 @@ -const logger = require('@aragon/protocol-backend-shared/helpers/logger')('heartbeat') +const logger = require('@aragon/protocol-backend-shared/build/helpers/logger').default('heartbeat') const command = 'heartbeat' const describe = 'Call protocol hearbeat' diff --git a/packages/cli/src/commands/mint.js b/packages/cli/src/commands/mint.js index 0501370..69d652d 100644 --- a/packages/cli/src/commands/mint.js +++ b/packages/cli/src/commands/mint.js @@ -1,5 +1,5 @@ -const logger = require('@aragon/protocol-backend-shared/helpers/logger')('mint') -const { bigExp } = require('@aragon/protocol-backend-shared/helpers/numbers') +const logger = require('@aragon/protocol-backend-shared/build/helpers/logger').default('mint') +const { bigExp } = require('@aragon/protocol-backend-shared/build/helpers/numbers') const command = 'mint' const describe = 'Mint tokens for a certain address' diff --git a/packages/cli/src/commands/payment.js b/packages/cli/src/commands/payment.js index 9ae6770..099911b 100644 --- a/packages/cli/src/commands/payment.js +++ b/packages/cli/src/commands/payment.js @@ -1,4 +1,4 @@ -const logger = require('@aragon/protocol-backend-shared/helpers/logger')('payment') +const logger = require('@aragon/protocol-backend-shared/build/helpers/logger').default('payment') const command = 'payment' const describe = 'Make Aragon Protocol payment' diff --git a/packages/cli/src/commands/reveal.js b/packages/cli/src/commands/reveal.js index c5c7fda..d2df5ce 100644 --- a/packages/cli/src/commands/reveal.js +++ b/packages/cli/src/commands/reveal.js @@ -1,4 +1,4 @@ -const logger = require('@aragon/protocol-backend-shared/helpers/logger')('reveal') +const logger = require('@aragon/protocol-backend-shared/build/helpers/logger').default('reveal') const command = 'reveal' const describe = 'Reveal committed vote' diff --git a/packages/cli/src/commands/settle-juror.js b/packages/cli/src/commands/settle-juror.js index 73c522f..9ed38be 100644 --- a/packages/cli/src/commands/settle-juror.js +++ b/packages/cli/src/commands/settle-juror.js @@ -1,4 +1,4 @@ -const logger = require('@aragon/protocol-backend-shared/helpers/logger')('settle-guardian') +const logger = require('@aragon/protocol-backend-shared/build/helpers/logger').default('settle-guardian') const command = 'settle-guardian' const describe = 'Settle guardian for a dispute' diff --git a/packages/cli/src/commands/settle-round.js b/packages/cli/src/commands/settle-round.js index e935cfc..b82e2e0 100644 --- a/packages/cli/src/commands/settle-round.js +++ b/packages/cli/src/commands/settle-round.js @@ -1,4 +1,4 @@ -const logger = require('@aragon/protocol-backend-shared/helpers/logger')('settle-round') +const logger = require('@aragon/protocol-backend-shared/build/helpers/logger').default('settle-round') const command = 'settle-round' const describe = 'Settle penalties and appeals for a dispute' diff --git a/packages/cli/src/commands/stake.js b/packages/cli/src/commands/stake.js index 8e26e77..826979d 100644 --- a/packages/cli/src/commands/stake.js +++ b/packages/cli/src/commands/stake.js @@ -1,4 +1,4 @@ -const logger = require('@aragon/protocol-backend-shared/helpers/logger')('stake') +const logger = require('@aragon/protocol-backend-shared/build/helpers/logger').default('stake') const command = 'stake' const describe = 'Stake tokens for a guardian' diff --git a/packages/cli/src/commands/unstake.js b/packages/cli/src/commands/unstake.js index 5e3a6b0..4089587 100644 --- a/packages/cli/src/commands/unstake.js +++ b/packages/cli/src/commands/unstake.js @@ -1,4 +1,4 @@ -const logger = require('@aragon/protocol-backend-shared/helpers/logger')('unstake') +const logger = require('@aragon/protocol-backend-shared/build/helpers/logger').default('unstake') const command = 'unstake' const describe = 'Unstake tokens for a guardian' diff --git a/packages/cli/src/helpers/error-handler.js b/packages/cli/src/helpers/error-handler.js index f4b9dec..e28a054 100644 --- a/packages/cli/src/helpers/error-handler.js +++ b/packages/cli/src/helpers/error-handler.js @@ -1,4 +1,4 @@ -const logger = require('@aragon/protocol-backend-shared/helpers/logger')('Error Handler') +const logger = require('@aragon/protocol-backend-shared/build/helpers/logger').default('Error Handler') module.exports = error => { logger.error(`Process finished with error:`) diff --git a/packages/server/src/controllers/RevealsController.js b/packages/server/src/controllers/RevealsController.js index 4c439d7..a793cd8 100644 --- a/packages/server/src/controllers/RevealsController.js +++ b/packages/server/src/controllers/RevealsController.js @@ -1,7 +1,7 @@ import { Reveal } from '@aragon/protocol-backend-shared/build/models/objection' import HttpError from '../errors/http-error' import RevealsValidator from '../validators/RevealsValidator' -import { decodeVoteId } from '@aragon/protocol-backend-shared/helpers/voting' +import { decodeVoteId } from '@aragon/protocol-backend-shared/build/helpers/voting' export default { async show(request, response) { diff --git a/packages/server/src/validators/RevealsValidator.js b/packages/server/src/validators/RevealsValidator.js index 837739a..dbea405 100644 --- a/packages/server/src/validators/RevealsValidator.js +++ b/packages/server/src/validators/RevealsValidator.js @@ -1,7 +1,7 @@ import { Reveal } from '@aragon/protocol-backend-shared/build/models/objection' -import Network from '../web3/Network' +import Network from '@aragon/protocol-backend-shared/build/web3/Network' import BaseValidator from './BaseValidator' -const { hashVote } = require('@aragon/protocol-backend-shared/helpers/voting') +const { hashVote } = require('@aragon/protocol-backend-shared/build/helpers/voting') class RevealsValidator extends BaseValidator { async validateForCreate({ guardian, voteId, outcome, salt }) { diff --git a/packages/services/package.json b/packages/services/package.json index 9539ee9..97b68be 100644 --- a/packages/services/package.json +++ b/packages/services/package.json @@ -18,7 +18,6 @@ "db:setup": "lerna run db:setup --scope '*/*-shared' --stream" }, "dependencies": { - "@aragon/protocol-backend-server": "^0.2.21", "@aragon/protocol-backend-shared": "^0.2.21", "axios": "^0.19.0", "dateformat": "^3.0.3", diff --git a/packages/services/src/bin/main.js b/packages/services/src/bin/main.js index 37cd135..a9e0927 100644 --- a/packages/services/src/bin/main.js +++ b/packages/services/src/bin/main.js @@ -3,7 +3,7 @@ import path from 'path' import { fork } from 'child_process' import { workers } from './config' -import Logger from '@aragon/protocol-backend-shared/helpers/logger' +import Logger from '@aragon/protocol-backend-shared/build/helpers/logger' require('dotenv').config() diff --git a/packages/services/src/helpers/error-handler.js b/packages/services/src/helpers/error-handler.js index b88a8db..8a6ca49 100644 --- a/packages/services/src/helpers/error-handler.js +++ b/packages/services/src/helpers/error-handler.js @@ -1,4 +1,4 @@ -const logger = require('@aragon/protocol-backend-shared/helpers/logger')('Error Handler') +const logger = require('@aragon/protocol-backend-shared/build/helpers/logger').default('Error Handler') export default error => { logger.error(`Process finished with error:`) diff --git a/packages/services/src/helpers/term-id-getter.js b/packages/services/src/helpers/term-id-getter.js index 2868c2c..16fa0d0 100644 --- a/packages/services/src/helpers/term-id-getter.js +++ b/packages/services/src/helpers/term-id-getter.js @@ -1,5 +1,5 @@ -import Network from '@aragon/protocol-backend-server/build/web3/Network' -import { bn } from '@aragon/protocol-backend-shared/helpers/numbers' +import Network from '@aragon/protocol-backend-shared/build/web3/Network' +import { bn } from '@aragon/protocol-backend-shared/build/helpers/numbers' async function draftTermIdFor(state) { const protocol = await Network.getProtocol() diff --git a/packages/services/src/helpers/worker-logger.js b/packages/services/src/helpers/worker-logger.js index 484bf86..1b1d448 100644 --- a/packages/services/src/helpers/worker-logger.js +++ b/packages/services/src/helpers/worker-logger.js @@ -1,4 +1,4 @@ -const Logger = require('@aragon/protocol-backend-shared/helpers/logger') +const { Logger, setDefaults } = require('@aragon/protocol-backend-shared/build/helpers/logger') class WorkerLogger { constructor(worker, logger) { @@ -32,4 +32,4 @@ module.exports = (worker, color) => { return new WorkerLogger(worker, logger) } -module.exports.setDefaults = Logger.setDefaults +module.exports.setDefaults = setDefaults diff --git a/packages/services/src/models/Etherscan.js b/packages/services/src/models/Etherscan.js index c42534a..1d47820 100644 --- a/packages/services/src/models/Etherscan.js +++ b/packages/services/src/models/Etherscan.js @@ -1,5 +1,5 @@ import axios from 'axios' -import { bn } from '@aragon/protocol-backend-shared/helpers/numbers' +import { bn } from '@aragon/protocol-backend-shared/build/helpers/numbers' const BASE_URL = 'https://.etherscan.io/api?' const DEFAULT_API_KEY = process.env.ETHERSCAN_API_KEY diff --git a/packages/services/src/models/notification-scanners/AppealsOpened.js b/packages/services/src/models/notification-scanners/AppealsOpened.js index 53e2976..8050d40 100644 --- a/packages/services/src/models/notification-scanners/AppealsOpened.js +++ b/packages/services/src/models/notification-scanners/AppealsOpened.js @@ -1,5 +1,5 @@ import NotificationScannerBaseModel from './NotificationScannerBaseModel' -import Network from '@aragon/protocol-backend-server/build/web3/Network' +import Network from '@aragon/protocol-backend-shared/build/web3/Network' import { draftTermIdFor } from '../../helpers/term-id-getter' class AppealsOpened extends NotificationScannerBaseModel { diff --git a/packages/services/src/models/notification-scanners/DisputeRuled.js b/packages/services/src/models/notification-scanners/DisputeRuled.js index 89a418e..f179e4b 100644 --- a/packages/services/src/models/notification-scanners/DisputeRuled.js +++ b/packages/services/src/models/notification-scanners/DisputeRuled.js @@ -1,5 +1,5 @@ import NotificationScannerBaseModel from './NotificationScannerBaseModel' -import Network from '@aragon/protocol-backend-server/build/web3/Network' +import Network from '@aragon/protocol-backend-shared/build/web3/Network' const OUTCOMES = { 0: 'Missing', 1: 'Leaked', diff --git a/packages/services/src/models/notification-scanners/DueTasks.js b/packages/services/src/models/notification-scanners/DueTasks.js index aadba67..7c96a90 100644 --- a/packages/services/src/models/notification-scanners/DueTasks.js +++ b/packages/services/src/models/notification-scanners/DueTasks.js @@ -1,5 +1,5 @@ import NotificationScannerBaseModel from './NotificationScannerBaseModel' -import Network from '@aragon/protocol-backend-server/build/web3/Network' +import Network from '@aragon/protocol-backend-shared/build/web3/Network' import { draftTermIdFor, dueDateFor } from '../../helpers/term-id-getter' import dateFormat from 'dateformat' diff --git a/packages/services/src/models/notification-scanners/GuardianDrafted.js b/packages/services/src/models/notification-scanners/GuardianDrafted.js index a1d16d9..901e9f1 100644 --- a/packages/services/src/models/notification-scanners/GuardianDrafted.js +++ b/packages/services/src/models/notification-scanners/GuardianDrafted.js @@ -1,5 +1,5 @@ import NotificationScannerBaseModel from './NotificationScannerBaseModel' -import Network from '@aragon/protocol-backend-server/build/web3/Network' +import Network from '@aragon/protocol-backend-shared/build/web3/Network' class GuardianDrafted extends NotificationScannerBaseModel { async scan() { diff --git a/packages/services/src/models/notification-scanners/MissedReveal.js b/packages/services/src/models/notification-scanners/MissedReveal.js index af04873..dd74d8d 100644 --- a/packages/services/src/models/notification-scanners/MissedReveal.js +++ b/packages/services/src/models/notification-scanners/MissedReveal.js @@ -1,5 +1,5 @@ import NotificationScannerBaseModel from './NotificationScannerBaseModel' -import Network from '@aragon/protocol-backend-server/build/web3/Network' +import Network from '@aragon/protocol-backend-shared/build/web3/Network' import { draftTermIdFor } from '../../helpers/term-id-getter' class MissedReveal extends NotificationScannerBaseModel { diff --git a/packages/services/src/models/notification-scanners/MissedVote.js b/packages/services/src/models/notification-scanners/MissedVote.js index f20ac8c..8abca2c 100644 --- a/packages/services/src/models/notification-scanners/MissedVote.js +++ b/packages/services/src/models/notification-scanners/MissedVote.js @@ -1,5 +1,5 @@ import NotificationScannerBaseModel from './NotificationScannerBaseModel' -import Network from '@aragon/protocol-backend-server/build/web3/Network' +import Network from '@aragon/protocol-backend-shared/build/web3/Network' import { draftTermIdFor } from '../../helpers/term-id-getter' class MissedVote extends NotificationScannerBaseModel { diff --git a/packages/services/src/workers/contract-monitor.js b/packages/services/src/workers/contract-monitor.js index 320b75d..2c09128 100644 --- a/packages/services/src/workers/contract-monitor.js +++ b/packages/services/src/workers/contract-monitor.js @@ -1,6 +1,6 @@ import Etherscan from '../models/Etherscan' import { DAYS } from '@aragon/protocol-backend-shared/build/helpers/times' -import getWalletFromPk from '@aragon/protocol-backend-shared/helpers/get-wallet-from-pk' +import getWalletFromPk from '@aragon/protocol-backend-shared/build/helpers/get-wallet-from-pk' import abi from 'web3-eth-abi' const TRANSACTION_TYPES = [ diff --git a/packages/services/src/workers/heartbeat.js b/packages/services/src/workers/heartbeat.js index 383927a..20cb4d7 100644 --- a/packages/services/src/workers/heartbeat.js +++ b/packages/services/src/workers/heartbeat.js @@ -1,5 +1,5 @@ import sleep from '@aragon/protocol-backend-shared/build/helpers/sleep' -import Network from '@aragon/protocol-backend-server/build/web3/Network' +import Network from '@aragon/protocol-backend-shared/build/web3/Network' const HEARTBEAT_TRIES_PER_JOB = 3 const SECONDS_BETWEEN_INTENTS = 3 diff --git a/packages/services/src/workers/monitor-keeper.js b/packages/services/src/workers/monitor-keeper.js index ecb5364..ef2488f 100644 --- a/packages/services/src/workers/monitor-keeper.js +++ b/packages/services/src/workers/monitor-keeper.js @@ -1,11 +1,11 @@ import emailClient from '@aragon/protocol-backend-shared/build/helpers/email-client' import Etherscan from '../models/Etherscan' -import Network from '@aragon/protocol-backend-server/build/web3/Network' +import Network from '@aragon/protocol-backend-shared/build/web3/Network' import { Admin, KeeperSuspiciousTransaction } from '@aragon/protocol-backend-shared/build/models/objection' import { fromWei } from 'web3-utils' -import { bigExp } from '@aragon/protocol-backend-shared/helpers/numbers' -import getWalletFromPk from '@aragon/protocol-backend-shared/helpers/get-wallet-from-pk' +import { bigExp } from '@aragon/protocol-backend-shared/build/helpers/numbers' +import getWalletFromPk from '@aragon/protocol-backend-shared/build/helpers/get-wallet-from-pk' const FROM = 'noreply@aragon.one' const BALANCE_THRESHOLD = bigExp(1, 17) // 0.1 ETH diff --git a/packages/services/src/workers/reveal.js b/packages/services/src/workers/reveal.js index 5ad7921..8c33b10 100644 --- a/packages/services/src/workers/reveal.js +++ b/packages/services/src/workers/reveal.js @@ -1,5 +1,5 @@ import { Reveal } from '@aragon/protocol-backend-shared/build/models/objection' -import Network from '@aragon/protocol-backend-server/build/web3/Network' +import Network from '@aragon/protocol-backend-shared/build/web3/Network' const REVEAL_TRIES = 3 diff --git a/packages/services/src/workers/settlements.js b/packages/services/src/workers/settlements.js index 384ec73..ba18bab 100644 --- a/packages/services/src/workers/settlements.js +++ b/packages/services/src/workers/settlements.js @@ -1,5 +1,5 @@ import queries from '../helpers/settlement-queries' -import Network from '@aragon/protocol-backend-server/build/web3/Network' +import Network from '@aragon/protocol-backend-shared/build/web3/Network' export default async function (ctx) { const { logger } = ctx diff --git a/packages/services/test/integration/notification-scanners/AppealsOpened.js b/packages/services/test/integration/notification-scanners/AppealsOpened.js index 03c2398..dfd69c3 100644 --- a/packages/services/test/integration/notification-scanners/AppealsOpened.js +++ b/packages/services/test/integration/notification-scanners/AppealsOpened.js @@ -8,7 +8,7 @@ import { userDbCleanup, userNotificationTypeDbCleanup } from '../../helpers/dbCl import userNotificationTypeByModel from '../../helpers/userNotificationTypeByModel' import { tryRunScanner } from '../../../src/workers/notification-scanner' import { User } from '@aragon/protocol-backend-shared/build/models/objection' -import Network from '@aragon/protocol-backend-server/build/web3/Network' +import Network from '@aragon/protocol-backend-shared/build/web3/Network' import * as termIdGetter from '../../../src/helpers/term-id-getter' const { env: { CLIENT_URL } } = process diff --git a/packages/services/test/integration/notification-scanners/DisputeRuled.js b/packages/services/test/integration/notification-scanners/DisputeRuled.js index dda8cae..2d8f699 100644 --- a/packages/services/test/integration/notification-scanners/DisputeRuled.js +++ b/packages/services/test/integration/notification-scanners/DisputeRuled.js @@ -8,7 +8,7 @@ import { userDbCleanup, userNotificationTypeDbCleanup } from '../../helpers/dbCl import userNotificationTypeByModel from '../../helpers/userNotificationTypeByModel' import { tryRunScanner } from '../../../src/workers/notification-scanner' import { User } from '@aragon/protocol-backend-shared/build/models/objection' -import Network from '@aragon/protocol-backend-server/build/web3/Network' +import Network from '@aragon/protocol-backend-shared/build/web3/Network' const { env: { CLIENT_URL } } = process const notificationTypeModel = 'DisputeRuled' diff --git a/packages/services/test/integration/notification-scanners/DueTasks.js b/packages/services/test/integration/notification-scanners/DueTasks.js index bd656fd..dffb5ac 100644 --- a/packages/services/test/integration/notification-scanners/DueTasks.js +++ b/packages/services/test/integration/notification-scanners/DueTasks.js @@ -8,7 +8,7 @@ import { userDbCleanup, userNotificationTypeDbCleanup } from '../../helpers/dbCl import userNotificationTypeByModel from '../../helpers/userNotificationTypeByModel' import { tryRunScanner } from '../../../src/workers/notification-scanner' import { User } from '@aragon/protocol-backend-shared/build/models/objection' -import Network from '@aragon/protocol-backend-server/build/web3/Network' +import Network from '@aragon/protocol-backend-shared/build/web3/Network' import * as termIdGetter from '../../../src/helpers/term-id-getter' const { env: { CLIENT_URL } } = process diff --git a/packages/services/test/integration/notification-scanners/JurorDrafted.js b/packages/services/test/integration/notification-scanners/JurorDrafted.js index 492e9fb..bf8c6a9 100644 --- a/packages/services/test/integration/notification-scanners/JurorDrafted.js +++ b/packages/services/test/integration/notification-scanners/JurorDrafted.js @@ -8,7 +8,7 @@ import { userDbCleanup, userNotificationTypeDbCleanup } from '../../helpers/dbCl import userNotificationTypeByModel from '../../helpers/userNotificationTypeByModel' import { tryRunScanner } from '../../../src/workers/notification-scanner' import { User } from '@aragon/protocol-backend-shared/build/models/objection' -import Network from '@aragon/protocol-backend-server/build/web3/Network' +import Network from '@aragon/protocol-backend-shared/build/web3/Network' const { env: { CLIENT_URL } } = process const notificationTypeModel = 'GuardianDrafted' diff --git a/packages/services/test/integration/notification-scanners/MissedReveal.js b/packages/services/test/integration/notification-scanners/MissedReveal.js index c233692..e807638 100644 --- a/packages/services/test/integration/notification-scanners/MissedReveal.js +++ b/packages/services/test/integration/notification-scanners/MissedReveal.js @@ -8,7 +8,7 @@ import { userDbCleanup, userNotificationTypeDbCleanup } from '../../helpers/dbCl import userNotificationTypeByModel from '../../helpers/userNotificationTypeByModel' import { tryRunScanner } from '../../../src/workers/notification-scanner' import { User } from '@aragon/protocol-backend-shared/build/models/objection' -import Network from '@aragon/protocol-backend-server/build/web3/Network' +import Network from '@aragon/protocol-backend-shared/build/web3/Network' import * as termIdGetter from '../../../src/helpers/term-id-getter' const { env: { CLIENT_URL } } = process diff --git a/packages/services/test/integration/notification-scanners/MissedVote.js b/packages/services/test/integration/notification-scanners/MissedVote.js index 29b847e..a8260b3 100644 --- a/packages/services/test/integration/notification-scanners/MissedVote.js +++ b/packages/services/test/integration/notification-scanners/MissedVote.js @@ -8,7 +8,7 @@ import { userDbCleanup, userNotificationTypeDbCleanup } from '../../helpers/dbCl import userNotificationTypeByModel from '../../helpers/userNotificationTypeByModel' import { tryRunScanner } from '../../../src/workers/notification-scanner' import { User } from '@aragon/protocol-backend-shared/build/models/objection' -import Network from '@aragon/protocol-backend-server/build/web3/Network' +import Network from '@aragon/protocol-backend-shared/build/web3/Network' import * as termIdGetter from '../../../src/helpers/term-id-getter' const { env: { CLIENT_URL } } = process diff --git a/packages/services/test/src/workers/reveal.js b/packages/services/test/src/workers/reveal.js index 3061a97..c7bac4b 100644 --- a/packages/services/test/src/workers/reveal.js +++ b/packages/services/test/src/workers/reveal.js @@ -2,7 +2,7 @@ import chai from 'chai' import sinon from 'sinon' import sinonChai from 'sinon-chai' import revealWorker from '../../../src/workers/reveal' -import Network from '@aragon/protocol-backend-server/build/web3/Network' +import Network from '@aragon/protocol-backend-shared/build/web3/Network' import { Reveal } from '@aragon/protocol-backend-shared/build/models/objection' const { expect } = chai diff --git a/packages/shared/README.md b/packages/shared/README.md index 89f8566..1271473 100644 --- a/packages/shared/README.md +++ b/packages/shared/README.md @@ -9,7 +9,7 @@ It provides a set of JS classes to encapsulate certain web3 behavior shared amon #### Artifacts This JS class is in charge of providing JS wrappers for smart contracts (a.k.a. contract artifacts). -It provides two flavors of artifacts, one [`dynamic`](./models/artifacts/DynamicArtifacts.js) and another one [`static`](./models/artifacts/StaticArtifacts.js), following the same interface. +It provides two flavors of artifacts, one [`dynamic`](./src/models/artifacts/DynamicArtifacts.ts) and another one [`static`](./models/artifacts/StaticArtifacts.ts), following the same interface. The difference is that the dynamic one will load the contract schemas lazily, while the static one will load all of them before hand. #### Protocol @@ -20,7 +20,7 @@ This class is used by all the projects of the Aragon Protocol backoffice to inte #### Environments This JS class is in charge of providing all the web3 commonly used components in a web3 application like: a web3 instance, a web3 provider, an artifacts object, the default sender, and some other particular entities like a protocol instance, a protocol subgraph, among others. -It also provides two different flavors of environments, one for [`browser`](./models/environments/BrowserEnvironment.js) and another one based on [`Truffle configs`](./models/environments/TruffleEnvironment.js). +It also provides two different flavors of environments, one for [`browser`](./src/models/environments/BrowserEnvironment.ts) and another one based on [`Truffle configs`](./src/models/environments/TruffleEnvironment.ts). The first one is only used by the back-office frontend app where all the components mentioned above are built based on a browser web3 provider like `Metamask`, while the second one is used by all the other back-office projects (`cli`, `server`, and `services`) where all these components are derived from a Truffle config file. ### Helpers @@ -28,13 +28,13 @@ The first one is only used by the back-office frontend app where all the compone It provides the following helper functions: - [`email-client`](./src/helpers/email-client.ts): Handles sending emails through Postmark - [`jwt-manager`](./src/helpers/jwt-manager.ts): For creating and validating JWTs in email verification -- [`gas-price-oracle`](./helpers/gas-price-oracle.js): Get gas price oracle object used to know the current gas prices being paid on each network -- [`get-wallet-from-pk`](./helpers/get-wallet-from-pk.js): Decode Ethereum address based on a private key -- [`logger`](./helpers/logger.js): Logger object that provides a friendly interface for fancy logging -- [`numbers`](./helpers/numbers.js): BigNumber-related helper functions +- [`gas-price-oracle`](./src/helpers/gas-price-oracle.ts): Get gas price oracle object used to know the current gas prices being paid on each network +- [`get-wallet-from-pk`](./src/helpers/get-wallet-from-pk.ts): Decode Ethereum address based on a private key +- [`logger`](./src/helpers/logger.ts): Logger object that provides a friendly interface for fancy logging +- [`numbers`](./src/helpers/numbers.ts): BigNumber-related helper functions - [`sleep`](./src/helpers/sleep.ts): Sleep function to wait a number of seconds -- [`times`](./helpers/times.ts): Time constants for using with `Date()` -- [`voting`](./helpers/voting.js): Utils related to the CR Voting module of Aragon Protocol +- [`times`](./src/helpers/times.ts): Time constants for using with `Date()` +- [`voting`](./src/helpers/voting.ts): Utils related to the CR Voting module of Aragon Protocol ## TypeScript compilation diff --git a/packages/shared/helpers/get-wallet-from-pk.js b/packages/shared/helpers/get-wallet-from-pk.js deleted file mode 100644 index a59d906..0000000 --- a/packages/shared/helpers/get-wallet-from-pk.js +++ /dev/null @@ -1,8 +0,0 @@ -const { isValidPrivate } = require('ethereumjs-util') -const { fromPrivateKey } = require('ethereumjs-wallet') - -module.exports = function (key) { - const privateKey = Buffer.from(key.replace('0x', ''), 'hex') - if (!isValidPrivate(privateKey)) throw Error('Given private key is not valid') - return fromPrivateKey(privateKey) -} diff --git a/packages/shared/helpers/numbers.js b/packages/shared/helpers/numbers.js deleted file mode 100644 index cfeb904..0000000 --- a/packages/shared/helpers/numbers.js +++ /dev/null @@ -1,17 +0,0 @@ -const { utils } = require('ethers') -const { fromWei } = require('web3-utils') - -const bn = x => utils.bigNumberify(x) -const bigExp = (x, y = 18) => bn(x).mul(bn(10).pow(bn(y))) -const maxUint = (e) => bn(2).pow(bn(e)).sub(bn(1)) -const tokenToString = (x, { decimals, symbol }) => `${fromWei(bn(x).toString())} ${symbol}` - -const MAX_UINT64 = maxUint(64) - -module.exports = { - bn, - bigExp, - maxUint, - tokenToString, - MAX_UINT64 -} diff --git a/packages/shared/helpers/voting.js b/packages/shared/helpers/voting.js deleted file mode 100644 index 53c9f71..0000000 --- a/packages/shared/helpers/voting.js +++ /dev/null @@ -1,23 +0,0 @@ -const { bn } = require('./numbers') -const { soliditySha3 } = require('web3-utils') - -const hashVote = (outcome, salt = SALT) => { - return soliditySha3({ t: 'uint8', v: outcome }, { t: 'bytes32', v: salt }) -} - -const encodeVoteId = (disputeId, roundId) => { - return bn(2).pow(bn(128)).mul(bn(disputeId)).add(bn(roundId)) -} - -const decodeVoteId = (voteId) => { - const mask = bn(2).pow(bn(128)) - const disputeId = bn(voteId).div(mask) - const roundId = bn(voteId).sub(disputeId.mul(mask)) - return { disputeId, roundId } -} - -module.exports = { - hashVote, - encodeVoteId, - decodeVoteId, -} diff --git a/packages/shared/package.json b/packages/shared/package.json index e62592c..74c4f89 100644 --- a/packages/shared/package.json +++ b/packages/shared/package.json @@ -5,10 +5,10 @@ "author": "Aragon One", "license": "(GPL-3.0-or-later OR AGPL-3.0-or-later)", "scripts": { - "lint": "eslint src/** --ext .ts", + "lint": "eslint src/**/*.ts --ext .ts", "build": "yarn lint && yarn build:types && yarn build:js", "build:types": "tsc", - "build:js": "babel ./src --out-dir ./build --extensions .ts", + "build:js": "babel ./src --out-dir ./build --extensions .js,.ts", "build:clean": "yarn clean && yarn build", "clean": "rm -rf ./build", "db:setup": "babel-node --extensions .ts src/scripts/db-setup" @@ -25,6 +25,8 @@ "axios": "^0.19.0", "chalk": "^2.4.2", "dotenv": "^8.2.0", + "ethereumjs-util": "^7.0.7", + "ethereumjs-wallet": "^1.0.1", "ethers": "^4.0.46", "graphql-request": "^1.8.2", "jsonwebtoken": "^8.5.1", diff --git a/packages/shared/helpers/gas-price-oracle.js b/packages/shared/src/helpers/gas-price-oracle.ts similarity index 80% rename from packages/shared/helpers/gas-price-oracle.js rename to packages/shared/src/helpers/gas-price-oracle.ts index 67e823b..1b891a3 100644 --- a/packages/shared/helpers/gas-price-oracle.js +++ b/packages/shared/src/helpers/gas-price-oracle.ts @@ -1,4 +1,4 @@ -const axios = require('axios') +import axios from 'axios' const GAS_STATION_API_URL = 'https://ethgasstation.info/json/ethgasAPI.json' @@ -7,14 +7,14 @@ const DEFAULT_TESTNET_GAS_PRICE = 10e9 const MAINNET_ID = 1 const TESTNET_IDS = [3, 4, 42] // ropsten, rinkeby and kovan -module.exports = { - async fetch(networkId) { +export default { + async fetch(networkId: number): Promise { if (MAINNET_ID === networkId) return this._fetchMainnetGasPrice() if (TESTNET_IDS.includes(networkId)) return DEFAULT_TESTNET_GAS_PRICE return undefined }, - async _fetchMainnetGasPrice() { + async _fetchMainnetGasPrice(): Promise { try { const { data: responseData } = await axios.get(GAS_STATION_API_URL) return (responseData.fastest / 10) * 1e9 diff --git a/packages/shared/src/helpers/get-wallet-from-pk.ts b/packages/shared/src/helpers/get-wallet-from-pk.ts new file mode 100644 index 0000000..d543a9f --- /dev/null +++ b/packages/shared/src/helpers/get-wallet-from-pk.ts @@ -0,0 +1,8 @@ +import { isValidPrivate } from 'ethereumjs-util' +import Wallet from 'ethereumjs-wallet' + +export default function (key: string): Wallet { + const privateKey = Buffer.from(key.replace('0x', ''), 'hex') + if (!isValidPrivate(privateKey)) throw Error('Given private key is not valid') + return Wallet.fromPrivateKey(privateKey) +} diff --git a/packages/shared/helpers/logger.js b/packages/shared/src/helpers/logger.ts similarity index 59% rename from packages/shared/helpers/logger.js rename to packages/shared/src/helpers/logger.ts index 3c9b658..d48e0a9 100644 --- a/packages/shared/helpers/logger.js +++ b/packages/shared/src/helpers/logger.ts @@ -1,4 +1,4 @@ -const chalk = require('chalk') +import chalk from 'chalk' const DEFAULTS = { verbose: false, @@ -6,29 +6,33 @@ const DEFAULTS = { } class Logger { - constructor(actor, color = 'white') { + + actor: string + color: string + + constructor(actor: string, color = 'white') { this.actor = actor this.color = color } - info(msg) { + info(msg: string): void { if (!DEFAULTS.verbose) return this.log(msg, '️ ', 'white') } - success(msg) { + success(msg: string): void { this.log(msg, '✅', 'green') } - warn(msg) { + warn(msg: string): void { this.log(msg, '⚠️ ', 'yellow') } - error(msg) { + error(msg: string): void { this.log(msg, '🚨', 'red') } - log(msg, emoji, color = 'white') { + log(msg: string, emoji: string, color = 'white'): void { if (DEFAULTS.silent) return let formattedMessage = chalk.keyword(color)(`${emoji} ${this._stringify(msg)}`) if (DEFAULTS.verbose) { @@ -38,16 +42,18 @@ class Logger { console.error(formattedMessage) } - _stringify(obj) { + _stringify(obj: any): string { return (typeof obj === 'object') ? JSON.stringify(obj) : obj.toString() } } -module.exports = (actor, color) => new Logger(actor, color) +const LoggerConstructor = (actor: string, color: string) => new Logger(actor, color) + +export default LoggerConstructor -module.exports.Logger = Logger +export { LoggerConstructor as Logger } -module.exports.setDefaults = (silent, verbose) => { +export const setDefaults = (silent: boolean, verbose: boolean): void => { DEFAULTS.silent = silent DEFAULTS.verbose = verbose } diff --git a/packages/shared/src/helpers/numbers.ts b/packages/shared/src/helpers/numbers.ts new file mode 100644 index 0000000..b2ccfeb --- /dev/null +++ b/packages/shared/src/helpers/numbers.ts @@ -0,0 +1,18 @@ +import { utils } from 'ethers' +import { fromWei } from 'web3-utils' +import { BigNumberish } from 'ethers/utils' + +const bn = (x: BigNumberish) => utils.bigNumberify(x) +const bigExp = (x: BigNumberish, y = 18) => bn(x).mul(bn(10).pow(bn(y))) +const maxUint = (e: BigNumberish) => bn(2).pow(bn(e)).sub(bn(1)) +const tokenToString = (x: BigNumberish, symbol: string) => `${fromWei(bn(x).toString())} ${symbol}` + +const MAX_UINT64 = maxUint(64) + +export { + bn, + bigExp, + maxUint, + tokenToString, + MAX_UINT64 +} diff --git a/packages/shared/src/helpers/voting.ts b/packages/shared/src/helpers/voting.ts new file mode 100644 index 0000000..46a546d --- /dev/null +++ b/packages/shared/src/helpers/voting.ts @@ -0,0 +1,25 @@ +import { bn } from './numbers' +import { soliditySha3 } from 'web3-utils' +import { BigNumber, BigNumberish } from 'ethers/utils' + +const hashVote = (outcome: string, salt: string): string | null => { + return soliditySha3({ t: 'uint8', v: outcome }, { t: 'bytes32', v: salt }) +} + +const encodeVoteId = (disputeId: BigNumberish, roundId: BigNumberish): BigNumber => { + return bn(2).pow(bn(128)).mul(bn(disputeId)).add(bn(roundId)) +} + +interface decodedVoteId { disputeId: BigNumber, roundId: BigNumber } +const decodeVoteId = (voteId: BigNumberish): decodedVoteId => { + const mask = bn(2).pow(bn(128)) + const disputeId = bn(voteId).div(mask) + const roundId = bn(voteId).sub(disputeId.mul(mask)) + return { disputeId, roundId } +} + +export { + hashVote, + encodeVoteId, + decodeVoteId, +} diff --git a/packages/shared/models/Protocol.js b/packages/shared/src/models/Protocol.js similarity index 99% rename from packages/shared/models/Protocol.js rename to packages/shared/src/models/Protocol.js index d1507d2..2c14636 100644 --- a/packages/shared/models/Protocol.js +++ b/packages/shared/src/models/Protocol.js @@ -1,7 +1,7 @@ const { sha3, fromWei, utf8ToHex, soliditySha3 } = require('web3-utils') const { ZERO_ADDRESS, getEventArgument, getEvents } = require('@aragon/contract-helpers-test') -const logger = require('../helpers/logger')('Protocol') +const logger = require('../helpers/logger').default('Protocol') const { bn, bigExp } = require('../helpers/numbers') const { encodeVoteId, hashVote } = require('../helpers/voting') diff --git a/packages/shared/models/artifacts/BaseArtifacts.js b/packages/shared/src/models/artifacts/BaseArtifacts.js similarity index 100% rename from packages/shared/models/artifacts/BaseArtifacts.js rename to packages/shared/src/models/artifacts/BaseArtifacts.js diff --git a/packages/shared/models/artifacts/DynamicArtifacts.js b/packages/shared/src/models/artifacts/DynamicArtifacts.js similarity index 94% rename from packages/shared/models/artifacts/DynamicArtifacts.js rename to packages/shared/src/models/artifacts/DynamicArtifacts.js index 722cc5c..dc72321 100644 --- a/packages/shared/models/artifacts/DynamicArtifacts.js +++ b/packages/shared/src/models/artifacts/DynamicArtifacts.js @@ -25,7 +25,7 @@ class DynamicArtifacts extends BaseArtifacts { } _getNodeModulesPaths(dependency, contractName) { - return BUILD_DIRS.map(dir => path.resolve(__dirname, `../../node_modules/${dependency}/${dir}/${contractName}.json`)) + return BUILD_DIRS.map(dir => path.resolve(__dirname, `../../../node_modules/${dependency}/${dir}/${contractName}.json`)) } } diff --git a/packages/shared/models/artifacts/StaticArtifacts.js b/packages/shared/src/models/artifacts/StaticArtifacts.js similarity index 100% rename from packages/shared/models/artifacts/StaticArtifacts.js rename to packages/shared/src/models/artifacts/StaticArtifacts.js diff --git a/packages/shared/models/environments/BrowserEnvironment.js b/packages/shared/src/models/environments/BrowserEnvironment.js similarity index 95% rename from packages/shared/models/environments/BrowserEnvironment.js rename to packages/shared/src/models/environments/BrowserEnvironment.js index 8f2e55c..06db324 100644 --- a/packages/shared/models/environments/BrowserEnvironment.js +++ b/packages/shared/src/models/environments/BrowserEnvironment.js @@ -1,5 +1,5 @@ const { ethers } = require('ethers') -const sleep = require('../../build/helpers/sleep') +const sleep = require('../../helpers/sleep') const Environment = require('./Environment') const JsonRpcSigner = require('../providers/JsonRpcSigner') const StaticArtifacts = require('../artifacts/StaticArtifacts') diff --git a/packages/shared/models/environments/Environment.js b/packages/shared/src/models/environments/Environment.js similarity index 100% rename from packages/shared/models/environments/Environment.js rename to packages/shared/src/models/environments/Environment.js diff --git a/packages/shared/models/environments/LocalEnvironment.js b/packages/shared/src/models/environments/LocalEnvironment.js similarity index 100% rename from packages/shared/models/environments/LocalEnvironment.js rename to packages/shared/src/models/environments/LocalEnvironment.js diff --git a/packages/shared/models/environments/TruffleEnvironment.js b/packages/shared/src/models/environments/TruffleEnvironment.js similarity index 97% rename from packages/shared/models/environments/TruffleEnvironment.js rename to packages/shared/src/models/environments/TruffleEnvironment.js index 8fa48a6..2cf1fdb 100644 --- a/packages/shared/models/environments/TruffleEnvironment.js +++ b/packages/shared/src/models/environments/TruffleEnvironment.js @@ -44,4 +44,4 @@ class TruffleEnvironment extends Environment { } } -module.exports = TruffleEnvironment +export default TruffleEnvironment diff --git a/packages/shared/models/providers/JsonRpcProvider.js b/packages/shared/src/models/providers/JsonRpcProvider.js similarity index 82% rename from packages/shared/models/providers/JsonRpcProvider.js rename to packages/shared/src/models/providers/JsonRpcProvider.js index 5578f2f..e171aae 100644 --- a/packages/shared/models/providers/JsonRpcProvider.js +++ b/packages/shared/src/models/providers/JsonRpcProvider.js @@ -1,5 +1,5 @@ const ethers = require('ethers') -const logger = require('../../helpers/logger')('Provider') +const logger = require('../../helpers/logger').default('Provider') class JsonRpcProvider extends ethers.providers.JsonRpcProvider { constructor(url, network) { diff --git a/packages/shared/models/providers/JsonRpcSigner.js b/packages/shared/src/models/providers/JsonRpcSigner.js similarity index 100% rename from packages/shared/models/providers/JsonRpcSigner.js rename to packages/shared/src/models/providers/JsonRpcSigner.js diff --git a/packages/shared/models/providers/Wallet.js b/packages/shared/src/models/providers/Wallet.js similarity index 100% rename from packages/shared/models/providers/Wallet.js rename to packages/shared/src/models/providers/Wallet.js diff --git a/packages/server/src/web3/Network.js b/packages/shared/src/web3/Network.js similarity index 71% rename from packages/server/src/web3/Network.js rename to packages/shared/src/web3/Network.js index 10c143b..ce5e343 100644 --- a/packages/server/src/web3/Network.js +++ b/packages/shared/src/web3/Network.js @@ -1,4 +1,4 @@ -import Environment from '@aragon/protocol-backend-shared/models/environments/LocalEnvironment' +import Environment from '../models/environments/LocalEnvironment' const Network = { get environment() { diff --git a/yarn.lock b/yarn.lock index b7a6740..d3a090b 100644 --- a/yarn.lock +++ b/yarn.lock @@ -4456,7 +4456,7 @@ bn.js@^4.0.0, bn.js@^4.1.0, bn.js@^4.11.0, bn.js@^4.11.1, bn.js@^4.11.6, bn.js@^ resolved "https://registry.yarnpkg.com/bn.js/-/bn.js-4.11.9.tgz#26d556829458f9d1e81fc48952493d0ba3507828" integrity sha512-E6QoYqCKZfgatHTdHzs1RRKP7ip4vvm+EyRUeE2RF0NblwVvb0p6jSVeNTOFxPn26QXN2o6SMfNxKp6kU8zQaw== -bn.js@^5.1.1: +bn.js@^5.1.1, bn.js@^5.1.2: version "5.1.3" resolved "https://registry.yarnpkg.com/bn.js/-/bn.js-5.1.3.tgz#beca005408f642ebebea80b042b4d18d2ac0ee6b" integrity sha512-GkTiFpjFtUzU9CbMeJ5iazkCzGL3jrhzerzZIuqLABjbwRaFt33I9tUdSNryIptM+RxDet6OKm2WnLXzW51KsQ== @@ -7452,6 +7452,18 @@ ethereumjs-util@^6.0.0, ethereumjs-util@^6.1.0: ethjs-util "0.1.6" rlp "^2.2.3" +ethereumjs-util@^7.0.2, ethereumjs-util@^7.0.7: + version "7.0.7" + resolved "https://testnet.thegraph.com/npm-registry/ethereumjs-util/-/ethereumjs-util-7.0.7.tgz#484fb9c03b766b2ee64821281070616562fb5a59" + integrity sha512-vU5rtZBlZsgkTw3o6PDKyB8li2EgLavnAbsKcfsH2YhHH1Le+PP8vEiMnAnvgc1B6uMoaM5GDCrVztBw0Q5K9g== + dependencies: + "@types/bn.js" "^4.11.3" + bn.js "^5.1.2" + create-hash "^1.1.2" + ethereum-cryptography "^0.1.3" + ethjs-util "0.1.6" + rlp "^2.2.4" + ethereumjs-vm@^2.3.4, ethereumjs-vm@^2.6.0: version "2.6.0" resolved "https://registry.yarnpkg.com/ethereumjs-vm/-/ethereumjs-vm-2.6.0.tgz#76243ed8de031b408793ac33907fb3407fe400c6" @@ -7484,6 +7496,20 @@ ethereumjs-wallet@^0.6.3: utf8 "^3.0.0" uuid "^3.3.2" +ethereumjs-wallet@^1.0.1: + version "1.0.1" + resolved "https://testnet.thegraph.com/npm-registry/ethereumjs-wallet/-/ethereumjs-wallet-1.0.1.tgz#664a4bcacfc1291ca2703de066df1178938dba1c" + integrity sha512-3Z5g1hG1das0JWU6cQ9HWWTY2nt9nXCcwj7eXVNAHKbo00XAZO8+NHlwdgXDWrL0SXVQMvTWN8Q/82DRH/JhPw== + dependencies: + aes-js "^3.1.1" + bs58check "^2.1.2" + ethereum-cryptography "^0.1.3" + ethereumjs-util "^7.0.2" + randombytes "^2.0.6" + scrypt-js "^3.0.1" + utf8 "^3.0.0" + uuid "^3.3.2" + ethers@4.0.0-beta.3: version "4.0.0-beta.3" resolved "https://registry.yarnpkg.com/ethers/-/ethers-4.0.0-beta.3.tgz#15bef14e57e94ecbeb7f9b39dd0a4bd435bc9066" @@ -15222,7 +15248,7 @@ ripemd160@^2.0.0, ripemd160@^2.0.1: hash-base "^3.0.0" inherits "^2.0.1" -rlp@^2.0.0, rlp@^2.2.3: +rlp@^2.0.0, rlp@^2.2.3, rlp@^2.2.4: version "2.2.6" resolved "https://registry.yarnpkg.com/rlp/-/rlp-2.2.6.tgz#c80ba6266ac7a483ef1e69e8e2f056656de2fb2c" integrity sha512-HAfAmL6SDYNWPUOJNrM500x4Thn4PZsEy5pijPh40U9WfNk0z15hUYzO9xVIMAdIHdFtD8CBDHd75Td1g36Mjg==