From bb7db60afe77cde71c98e28b731257c11227c258 Mon Sep 17 00:00:00 2001 From: MuckT Date: Wed, 1 Nov 2023 17:53:08 -0700 Subject: [PATCH 1/3] feat: populate multiple chains in big query tokenInfo table --- scripts/update-bq.ts | 28 ++++++++++++++++++++-------- 1 file changed, 20 insertions(+), 8 deletions(-) diff --git a/scripts/update-bq.ts b/scripts/update-bq.ts index 3bdc7b12..24cbd0b9 100644 --- a/scripts/update-bq.ts +++ b/scripts/update-bq.ts @@ -1,20 +1,32 @@ /* eslint-disable no-console */ import { BigQuery } from '@google-cloud/bigquery' -import jsonData from '../src/data/mainnet/celo-tokens-info.json' +import { NetworkId } from '../src/types' +import { getTokensInfoByNetworkIds } from '../src/tokens-info' const bigquery = new BigQuery() const projectId = 'celo-mobile-mainnet' // we don't index testnet data const datasetId = 'address_metadata' const tableId = 'tokens_info' -const fieldsToKeep = ['address', 'decimals', 'name', 'symbol'] as const - -const rows = jsonData.map((entry) => { - const row: Record = {} - fieldsToKeep.forEach((field) => { - row[field] = entry[field] - }) +const fieldsToKeep = [ + 'address', + 'decimals', + 'name', + 'symbol', + 'isNative', + 'tokenId', + 'networkId', +] as const + +const tokensInfo = getTokensInfoByNetworkIds([ + NetworkId['celo-mainnet'], + NetworkId['ethereum-mainnet'], +]) + +const rows = Object.entries(tokensInfo).map(([_, tokenInfo]) => { + const row: Record = {} + fieldsToKeep.forEach((field) => (row[field] = tokenInfo[field] || null)) return row }) From 2a20ab32a341c1783f8a4f98678de1fec13090f5 Mon Sep 17 00:00:00 2001 From: MuckT Date: Mon, 6 Nov 2023 16:43:44 -0800 Subject: [PATCH 2/3] chore: remove unused isNative field --- scripts/update-bq.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/scripts/update-bq.ts b/scripts/update-bq.ts index 24cbd0b9..088ff3a6 100644 --- a/scripts/update-bq.ts +++ b/scripts/update-bq.ts @@ -14,7 +14,6 @@ const fieldsToKeep = [ 'decimals', 'name', 'symbol', - 'isNative', 'tokenId', 'networkId', ] as const From 73e26202a3337f76813ffdb433378050c5912616 Mon Sep 17 00:00:00 2001 From: Tom McGuire Date: Tue, 7 Nov 2023 14:54:51 -0800 Subject: [PATCH 3/3] Update scripts/update-bq.ts Co-authored-by: Charlie Andrews-Jubelt --- scripts/update-bq.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/update-bq.ts b/scripts/update-bq.ts index 088ff3a6..f8754cd5 100644 --- a/scripts/update-bq.ts +++ b/scripts/update-bq.ts @@ -25,7 +25,7 @@ const tokensInfo = getTokensInfoByNetworkIds([ const rows = Object.entries(tokensInfo).map(([_, tokenInfo]) => { const row: Record = {} - fieldsToKeep.forEach((field) => (row[field] = tokenInfo[field] || null)) + fieldsToKeep.forEach((field) => (row[field] = tokenInfo[field] ?? null)) return row })