Blockchain.com's open source, non-custodial Wallet
Blockchain.com Wallet
Be Your Own Bank at login.blockchain.com. Please contact support if you have any issues using the wallet.
About
This repo contains the three codebases/packages listed below.
Packages
- blockchain-info-components The shared UI components library.
- blockchain-wallet-v4 The functional library for handling wallets.
- blockchain-wallet-v4-frontend The frontend application built with React/Redux.
Local Development
- Ensure Node version >= 14.16 is installed. Using NVM is recommended.
- From the project root, run the following command to install dependencies:
./setup.sh. - Start the application in development mode:
yarn start - The frontend application will now be accessible via browser at
localhost:8080
DISABLESSL env param to true with any start command. (e.g. DISABLESSL=true yarn start:staging)
Windows Support
To ensure proper support for Windows, please take the following actions before running the above setup instructions.
- Open a Powershell window with rights elevated to an Administrator.
- Run
npm install -g windows-build-tools. This will install Python 2.7 and Visual C++ Build Tools which are required to compile some native Node modules. - Ensure Python has been added to your environment variables by opening a cmd prompt and typing
python. If you get aCommandNotFoundExceptionmessage, add the folder%USERPROFILE%\.windows-build-tools\python27to your environment variables.
Tips & Useful Commands
- To completely remove all dependencies and artifacts run
yarn clean - To add/remove an NPM package run
yarn addoryarn removein the package folder. After installing or uninstalling a NPM package, runyarnin the root folder to re-init the project - All development specific dependencies should be installed as a
dev-dependencyin the top levelpackage.jsonviayarn i --save-dev [package-name] - All application specific dependencies should be installed in the specific packages
package.jsonviayarn i --save [package-name]
Running Environments Locally
The frontend application can be ran locally with different build configurations found in config/env. The following commands are available:
yarn startRuns the application with thedevelopment.jsconfiguration fileyarn start:devRuns the application with thedevelopment.jsconfiguration fileyarn start:stagingRuns the application with thestaging.jsconfiguration fileyarn start:prodRuns the application with theproduction.jsconfiguration fileyarn run:prodRuns the application mimicking the production environment entirely (i.e. code is bundled and minified, HMR is disabled,
./server.js) and the production.js configuration file is loaded)
Notes:
- Developers will need to manually create the
development.jsandstaging.jsfiles - Custom application runtimes are possible by modifying the corresponding environment files found in the
config/envfolder
Useful Chrome Extensions
- React Developer Tools Inspect the React component tree
- Redux DevTools View/debug Redux state changes
Release Process
Prerequisites
To be able to create a release follow these steps starting with "Obtain a personal access token...": https://github.com/release-it/release-it#github-releases
GITHUBTOKEN should be saved as RELEASEITTOKEN instead in your bashprofile or wherever you keep env variables
You'll need git changelog to generate the history since the last release:
Release Steps
- From the tip of the
developmentbranch, runyarn release - Answer the questions prompted via CLI, accepting the defaults for each
- Once completed, this will create a new tag which will trigger a builds
- Once builds have finished, deploy the images to desired environments
- Test and verify the latest changes in desired environments
- Create PR to merge the HEAD of
developmentintomaster - Merge PR to
masterso thatmasteralways reflects what is currently in production
Code Quality
yarn vetRuns Prettier, lint JS, lint CSS and finally all unit tests
Linting
We follow the rules outlined by the Javascript Standard Style as well as a few React specific rules.
Code linting is handled by ESLint. The following commands are available:
yarn lintLints all packagesyarn lint:componentsLints only blockchain-info-componentsyarn lint:coreLints only blockchain-wallet-v4yarn lint:frontendLints only blockchain-wallet-v4-frontendyarn lint:fixAutomatically resolves fixable issues via ESLint
Prettier
We follow all standard rules that are provided by Prettier. The following commands are available:
yarn prettierRuns Prettier against all packagesyarn prettier:componentsRuns Prettier against only blockchain-info-componentsyarn prettier:coreRuns Prettier against only blockchain-wallet-v4yarn prettier:frontendRuns Prettier against only blockchain-wallet-v4-frontend
Unit Tests
Testing is done via Jest and Enzyme.
Running Tests
yarn testRuns unit tests for all packagesyarn test:componentsRuns unit tests for only blockchain-info-componentsyarn test:coreRuns unit tests for only blockchain-wallet-v4yarn test:frontendRuns unit tests for only blockchain-wallet-v4-frontend
yarn test before testing specific packages (eg, yarn test:frontend)
Running Tests via Watch
yarn test:watchWatches and then runs desired testsyarn test:components:watchWatches and then runs desired tests for only blockchain-info-componentsyarn test:core:watchWatches and then runs desired tests for only blockchain-wallet-v4yarn test:frontend:watchWatches and then runs desired tests for only blockchain-wallet-v4-frontend
Debugging Tests
To enable debugging for unit tests via the Chrome browser, run the following commands:
yarn test:components:debugDebugs unit tests for only blockchain-info-componentsyarn test:core:debugDebugs unit tests for only blockchain-wallet-v4yarn test:frontend:debugDebugs unit tests for only blockchain-wallet-v4-frontend
chrome://inspect and click on "Open Dedicated DevTools for Node",
which will give you a list of available node instances you can connect to. Click on the address displayed in the terminal
(usually localhost:9229) and you will be able to debug tests using Chrome's DevTools.
Updating Snapshot Tests
We are snapshot testing UI some components. Here are the commands to update them when necessary:
yarn test:components:updateUpdates component snapshots for only blockchain-info-componentsyarn test:frontend:updateUpdates component snapshots for only blockchain-wallet-v4-frontend
Code Coverage
To generate code coverage reports via Istanbul, the following commands are available:
yarn coverageGenerates a coverage report for all packagesyarn coverage:componentsGenerates coverage report for only blockchain-info-componentsyarn coverage:coreGenerates coverage report for only blockchain-wallet-v4yarn coverage:frontendGenerates coverage report for only blockchain-wallet-v4-frontend
coverage/index.htmlcoverage/blockchain-info-components/index.htmlcoverage/blockchain-wallet-v4/index.htmlcoverage/blockchain-wallet-v4-frontend/index.html
index.html file in your browser to view.
TypeScript
TypeScript is supported and should be used when adding new code. It's also recommended to replace legacy JS with TS when time allows.
TS Coverage
We are using Codechecks and Typecov for coverage reporting. Coverage is automatically analyzed for PRs and the following command is available.
yarn codechecks
Code Bundle Analysis/Reports
To visualize and interact with the tree of the production code bundles files:
yarn analyze
Storybook
Storybook is used by the blockchain-info-components and blockchain-wallet-v4-frontend packages to interactively view, develop and test components. The following commands are available:
storybook:build-wallet: Builds the static storybook assets for wallet specific components (if base components is running locally, storybook will put wallet and base components into the same storybook UI)storybook:build-base: Builds the static storybook assets for base shared componentsstorybook:serve-walletBuilds storybook assets and then serves them locally atlocalhost:6006storybook:serve-baseBuilds storybook assets and then serves them locally atlocalhost:6007storybook:deploy-walletBuilds storybook assets and then serves them to github pages. You will probably need to runcd ./packages/blockchain-info-components && git remote add origin git@github.com:blockchain/blockchain-wallet-v4-frontend.gitfirst.storybook:deploy-baseBuilds storybook assets and then serves them to github pages. You will probably need to runcd ./packages/blockchain-info-components && git remote add origin git@github.com:blockchain/blockchain-wallet-v4-frontend.gitfirst.
Contribute
Please review to the Wiki
Security
Security issues can be reported to us in the following venues:
- Email: security@blockchain.info
- Bug Bounty: https://hackerone.com/blockchain