diff --git a/packages/cli/README.md b/packages/cli/README.md index 8b6ec8ddf40..8b9a842ae53 100644 --- a/packages/cli/README.md +++ b/packages/cli/README.md @@ -4,10 +4,42 @@ Tool for interacting with the Celo Protocol. ## Development +### Build + Use `yarn build:sdk ` to build the sdk for the target environment (CLI dependency). Use `yarn build` to compile the CLI. +### Generate docs + Use `yarn docs` to populate `packages/docs` with generated documentation. Generated files should be checked in, and CI will fail if CLI modifications cause changes in the docs which were not checked in. _See [@celo/dev-cli](https://github.com/celo-org/dev-cli) for how we customize doc generation._ + +### Known build issues on Linux + +> I'm getting the follow error: `Cannot find module '@celo/contractkit'`. + +A possible solution is to build the monorepo manually. +Go to the `celo-monorepo` root directory and + +```bash +> yarn build +``` + +If all works well, navigate to `packages/cli`. + +> I've got the cli built successfully but the running the `cli` yields: `Error: Returned values aren't valid, did it run Out of Gas?`. + +When running the `cli` against a full node, this can mean that the contract artifacts are out of date. +Solution: switch to the `alfajores` branch and build the `celo-monorepo`. + +Go to the `celo-monorepo` root directory and + +```bash +> git checkout alfajores +> yarn +> yarn build +> cd packages/cli +> ./bin/run account:balance $CELO_ACCOUNT_ADDRESS +``` diff --git a/packages/protocol/.solcover.js b/packages/protocol/.solcover.js deleted file mode 100644 index 254f66f6135..00000000000 --- a/packages/protocol/.solcover.js +++ /dev/null @@ -1,44 +0,0 @@ -const mnemonic = require('./truffle.js').networks.development.mnemonic -const datadir = '.datadir' - -module.exports = { - datadir, - copyPackages: ['openzeppelin-solidity'], - testrpcOptions: '-d -m "' + mnemonic + '" -g 0 --db ' + datadir, - port: 8545, - skipFiles: [ - // Need custom precompiles - 'common/GoldToken.sol', - 'identity/Attestations.sol', - - // Proxies - 'common/GasCurrencyWhitelistProxy.sol', - 'common/GoldTokenProxy.sol', - 'common/MultiSigProxy.sol', - 'common/RegistryProxy.sol', - 'common/ValidatorsProxy.sol', - 'governance/LockedGoldProxy.sol', - 'identity/AttestationsProxy.sol', - 'identity/EscrowProxy.sol', - 'stability/ExchangeProxy.sol', - 'stability/MedianatorProxy.sol', - 'stability/OracleProxy.sol', - 'stability/ReserveProxy.sol', - 'stability/StableTokenProxy.sol', - - // Test contracts - 'common/test/GetSetV0.sol', - 'common/test/GetSetV1.sol', - 'common/test/HasInitializer.sol', - 'common/test/MsgSenderCheck.sol', - 'governance/test/MockLockedGold.sol', - 'governance/test/MockElection.sol', - 'governance/test/MockGovernance.sol', - 'governance/test/SortedListTest.sol', - 'stability/test/FractionUtilTest.sol', - 'stability/test/MockGoldToken.sol', - 'stability/test/MockReserve.sol', - 'stability/test/MockStableToken.sol', - 'stability/test/SortedFractionMedianListTest.sol', - ], -} diff --git a/packages/protocol/README.md b/packages/protocol/README.md index 637799f0b2b..c42ddb02e47 100644 --- a/packages/protocol/README.md +++ b/packages/protocol/README.md @@ -16,7 +16,7 @@ Then, to deploy contracts to a network run: yarn run init-network -n NETWORK ``` -This will deploy the contracts to the network specified in `truffle.js` and save the artifacts to `build/NETWORK`. +This will deploy the contracts to the network specified in `truffle-config.js` and save the artifacts to `build/NETWORK`. If your network was deployed with `helm`, you will probably set `NETWORK` the same as your `NAME` (which sets `NAMESPACE_NAME` and `RELEASE_NAME`). For more clarity on these names, also see the [testnet helm chart README](../helm-charts/testnet/README.md) ### Migrations diff --git a/packages/protocol/migrations/07_reserve.ts b/packages/protocol/migrations/07_reserve.ts index b97f02978da..45ab18b2c59 100644 --- a/packages/protocol/migrations/07_reserve.ts +++ b/packages/protocol/migrations/07_reserve.ts @@ -8,7 +8,7 @@ import { } from '@celo/protocol/lib/web3-utils' import { config } from '@celo/protocol/migrationsConfig' import { RegistryInstance, ReserveInstance } from 'types' -const truffle = require('@celo/protocol/truffle.js') +const truffle = require('@celo/protocol/truffle-config.js') const initializeArgs = async (): Promise<[string, number]> => { const registry: RegistryInstance = await getDeployedProxiedContract( diff --git a/packages/protocol/migrations/08_stabletoken.ts b/packages/protocol/migrations/08_stabletoken.ts index 920b438ae13..5bc02ece37d 100644 --- a/packages/protocol/migrations/08_stabletoken.ts +++ b/packages/protocol/migrations/08_stabletoken.ts @@ -16,7 +16,7 @@ import { StableTokenInstance, } from 'types' -const truffle = require('@celo/protocol/truffle.js') +const truffle = require('@celo/protocol/truffle-config.js') const NULL_ADDRESS = '0x0000000000000000000000000000000000000000' const initializeArgs = async (): Promise => { diff --git a/packages/protocol/migrations/15_governance.ts b/packages/protocol/migrations/15_governance.ts index 5b55ec636d9..eec28590310 100644 --- a/packages/protocol/migrations/15_governance.ts +++ b/packages/protocol/migrations/15_governance.ts @@ -13,7 +13,7 @@ import { config } from '@celo/protocol/migrationsConfig' import { toFixed } from '@celo/utils/lib/fixidity' const initializeArgs = async (networkName: string): Promise => { - const approver = require('@celo/protocol/truffle.js').networks[networkName].from + const approver = require('@celo/protocol/truffle-config.js').networks[networkName].from return [ config.registry.predeployedProxyAddress, diff --git a/packages/protocol/runTests.js b/packages/protocol/runTests.js index 4e92630311d..2704b7c37a1 100644 --- a/packages/protocol/runTests.js +++ b/packages/protocol/runTests.js @@ -4,7 +4,7 @@ const glob = require('glob-fs')({ }) const { exec } = require('./lib/test-utils') const minimist = require('minimist') -const network = require('./truffle.js').networks.development +const network = require('./truffle-config.js').networks.development const sleep = (seconds) => new Promise((resolve) => setTimeout(resolve, 1000 * seconds)) diff --git a/packages/protocol/scripts/bash/set_exchange_rate.sh b/packages/protocol/scripts/bash/set_exchange_rate.sh index eb97a853d73..ec54f5aac2a 100755 --- a/packages/protocol/scripts/bash/set_exchange_rate.sh +++ b/packages/protocol/scripts/bash/set_exchange_rate.sh @@ -7,7 +7,7 @@ set -euo pipefail # # Flags: # -f: Filepath to csv of (timestamp, stableValue, goldValue) tuples -# -n: name of the network defined in truffle.js to set the exchange rate on +# -n: name of the network defined in truffle-config.js to set the exchange rate on # -s: StableToken component of exchange rate # -g: GoldToken component of exchange rate # -c: Override for truffle config diff --git a/packages/protocol/scripts/truffle/get_balances.ts b/packages/protocol/scripts/truffle/get_balances.ts index 44475f2ddb3..c65c266d211 100644 --- a/packages/protocol/scripts/truffle/get_balances.ts +++ b/packages/protocol/scripts/truffle/get_balances.ts @@ -5,7 +5,7 @@ import { GoldTokenInstance, StableTokenInstance } from 'types' * A simple script to check token balances on a testnet. * * Expects the following flags: - * network: name of the network defined in truffle.js to deploy to + * network: name of the network defined in truffle-config.js to deploy to * account: address of the account to transfer tokens to * * Run using truffle exec, e.g.: diff --git a/packages/protocol/scripts/truffle/invite.ts b/packages/protocol/scripts/truffle/invite.ts index b33b3e7b2ed..1f655906d42 100644 --- a/packages/protocol/scripts/truffle/invite.ts +++ b/packages/protocol/scripts/truffle/invite.ts @@ -17,7 +17,7 @@ const twilioConfig = require('@celo/protocol/twilio-config') * A simple script to send a payment and invite a user. * * Expects the following flags: - * network: name of the network defined in truffle.js to deploy to + * network: name of the network defined in truffle-config.js to deploy to * stableValue: amount of stable token to transfer * goldValue: amount of gold transfer * phone: phone number of user to invite diff --git a/packages/protocol/scripts/truffle/network_check.ts b/packages/protocol/scripts/truffle/network_check.ts index 05b8db47186..4f81207c363 100644 --- a/packages/protocol/scripts/truffle/network_check.ts +++ b/packages/protocol/scripts/truffle/network_check.ts @@ -25,7 +25,7 @@ const contractMapping: any = {} * A simple script to check contract state invariants. * * Expects the following flags: - * network: name of the network defined in truffle.js to test + * network: name of the network defined in truffle-config.js to test * build_directory: location of the appropriate build artifacts * * Run using truffle exec, e.g.: diff --git a/packages/protocol/scripts/truffle/revoke.ts b/packages/protocol/scripts/truffle/revoke.ts index 33a79992886..bca24d91d29 100644 --- a/packages/protocol/scripts/truffle/revoke.ts +++ b/packages/protocol/scripts/truffle/revoke.ts @@ -8,7 +8,7 @@ import { AttestationsInstance } from 'types' * * Expects the following flags: * phone: the phone number to revoke in E164 format - * network: name of the network defined in truffle.js + * network: name of the network defined in truffle-config.js * * Run using truffle exec, e.g.: * truffle exec identity/scripts/revoke.js --network testnet --phone +18005882300 diff --git a/packages/protocol/scripts/truffle/set_exchange_rate.ts b/packages/protocol/scripts/truffle/set_exchange_rate.ts index b35f10b7e18..699383cce2d 100644 --- a/packages/protocol/scripts/truffle/set_exchange_rate.ts +++ b/packages/protocol/scripts/truffle/set_exchange_rate.ts @@ -67,7 +67,7 @@ const getLesserAndGreater = ( * * Expects the following flags: * csv: Filepath to csv of (timestamp, stableValue, goldValue) tuples - * network: name of the network defined in truffle.js to set the exchange rate on + * network: name of the network defined in truffle-config.js to set the exchange rate on * stableValue: StableToken component of exchange rate * goldValue: GoldToken component of exchange rate * diff --git a/packages/protocol/scripts/truffle/transfer.ts b/packages/protocol/scripts/truffle/transfer.ts index 64d0d2312ee..9f7e9f9c8f5 100644 --- a/packages/protocol/scripts/truffle/transfer.ts +++ b/packages/protocol/scripts/truffle/transfer.ts @@ -9,7 +9,7 @@ import { GoldTokenInstance, StableTokenInstance } from 'types' * A simple script to transfer token balances on a testnet. * * Expects the following flags: - * network: name of the network defined in truffle.js to deploy to + * network: name of the network defined in truffle-config.js to deploy to * to: address of the account to transfer tokens to * stableValue: amount of stable token to transfer * goldValue: amount of gold transfer diff --git a/packages/protocol/truffle.js b/packages/protocol/truffle-config.js similarity index 100% rename from packages/protocol/truffle.js rename to packages/protocol/truffle-config.js