Microservice used to create NEAR accounts
- Install latest Node.js LTS release
- Install HTTPie
yarn
Make sure you have PostgreSQL installed and running. On macOS, you can use Postgres.app.
Create accounts_development Postgres DB with helper user/password. You can do this from within psql using:
create user helper with superuser password 'helper';
create database accounts_development with owner=helper;
After that:
yarn migrate
You can also modify DB config in config/config.js to use different connection settings, etc.
Follow existing migrations as examples. To generate a migration file use the following:
npx sequelize-cli migration:generate --name migration-skeleton
Create a .env file, copy in the default values from .env.sample. Read this file for information about how to change configuration settings to suit your needs.
By default, it assumes that you're running a local node and local network. To do this:
- clone nearcore
- in your nearcore directory, get a local network running (at the time of writing, the command was
./scripts/start_localnet.py)
Note that you need to add an ACCOUNT_CREATOR_KEY to your .env. Running nearcore locally created a ~/.near/[network]/validator_key.json file for you. Copy the contents of this file and paste them as a single line, with NO whitespace, for the *_KEY value in your .env.
e.g. ACCOUNT_CREATOR_KEY={"account_id":"...","...":"...",...}
yarn start
http post http://localhost:3000/account newAccountId=nosuchuseryet newAccountPublicKey=22skMptHjFWNyuEWY22ftn2AbLPSYpmYwGJRGwpNHbTV
Follow the instructions above for creating the development database and helper user. Then create an accounts_test database using psql:
create database accounts_test with owner=helper;
Ensure nearcore is running
As mentioned in the "Environment Variables" section above, make sure you are running a local blockchain
This will run the tests using jest
Tests should be run sequentially, i.e.
jest test --runInBand