This repository contains utilities and automation for updating static data (supported ERC20 tokens, etc) in Firebase's RTDB.
Note: filing an issue does not guarantee addition to the supported token list. We do not review token addition requests in any particular order, and we do not guarantee that we will review your request to add the token to the supported list.
To add a new ERC20 token you need to follow these steps:
- Open
src/data/mainnet/tokens-info.json
and/orsrc/data/alfajores/tokens-info.json
. You will see that it's an array of token info. Add a new object. The fields are described below. - Add the logo to assets/tokens
- After doing this you should open a PR and ask someone on the Valora team to review it so it can be merged. Once it's merged, the new ERC20 token will be visible in the Valora Wallet for users holding it.
Property | Description |
---|---|
address |
The lower-case address of the ERC20 token contract. |
decimals |
The number of decimals used by the ERC20 token. |
imageUrl |
The logo to display for the ERC20 token. It must be a 256 x 256 PNG. Add the image to the assets/tokens folder and use the following format: https://raw.githubusercontent.com/valora-inc/address-metadata/main/assets/tokens/{image}.png |
name |
The name to display for the ERC20 token. |
symbol |
The short symbol to display for the ERC20 token. |
When adding a new node of data to this repository, first write a Joi
schema for the data in src/schemas
.
Then, add the raw data as a JSON blob to e.g., src/data/mainnet/{some-rtdb-node}.json
or src/data/alfajores/{some-rtdb-node}.json
. Finally, import the appropriate files and fill in the required metadata
in src/data/mainnet/index.ts
or src/data/alfajores/index.ts
. The rtdbLocation
field in the metadata list
should be the path where this data is located within RTDB.
Once these steps are done, any changes you make to the raw JSON files will be committed to the correct RTDB
environments during CICD, on a merge to main
.
This repository also contains some nifty utilities. Running yarn validate
will validate all the JSON blobs against
their corresponding schemas, and will fail if any of the JSON blobs are poorly formed.
yarn diff --project={mainnet|alfajores} --database-url={URL to Firebase RTDB location}
will display a
diff between the local JSON contents and the state within RTDB, much like git diff
.
yarn update --project={mainnet|alfajores} --database-url={URL to Firebase RTDB location}
will actually perform
RTDB updates based off the local state. If some local JSON blob fails to validate, it will not be updated.
Similarly, if the local state is already consistent with that in RTDB, we will not perform any write.
yarn
yarn validate
yarn diff --project={mainnet|alfajores} --database-url={URL to Firebase RTDB location}
When updating nodes without overrides, there is no check to avoid sending the update request even if there is no update (i.e. info in firebase is already ok).
This is done automatically during CICD; you should not need to run this locally.
yarn update --project={mainnet|alfajores} --database-url={URL to Firebase RTDB location}