dawsbot / eth-labels

📃 A public dataset of crypto addresses labeled
https://eth-labels-production.up.railway.app/swagger
MIT License
190 stars 29 forks source link

Implement `loadAllTokensFromFileSystem()` #82

Closed dawsbot closed 3 months ago

dawsbot commented 3 months ago

This is nearly the exact same as https://github.com/dawsbot/evm-labels/issues/81 <- do that first

We want a function which is callable synchronously (no await needed). that loads up ALL tokens from data/*/*/tokens.json.

The data type we are trying to load up can be called Array<TokenDBRow>.

An TokenDBRow is like the type TokenRow which is already in the db, but with a few extra keys. You can define the the like this:

type TokenDBRow = {
  chainId: number;
  address: string;
  label: string;
  name: string;
  symbol: string;
  nameTag?: string;
}

Steps

  1. Traverse the filesystem to generate this array. 1.1 Use globby to get all account filepaths: https://github.com/sindresorhus/globby 1.2 Use fs.readFileSync to load all of those files into memory & generate that TokenDBRow type

Expected outcome

const allTokens = loadAllTokensFromFilesystem();