From c3a7eabd8fab4f635520462ad41fa0f1bdb5cbbd Mon Sep 17 00:00:00 2001 From: Fuyao Zhao Date: Tue, 13 Sep 2022 11:47:45 -0700 Subject: [PATCH] chore(sdk): export more token info types (#92) --- sdk/src/processor-runner.ts | 3 --- sdk/src/utils/erc20.ts | 10 ++++++++-- sdk/src/utils/index.ts | 2 +- 3 files changed, 9 insertions(+), 6 deletions(-) diff --git a/sdk/src/processor-runner.ts b/sdk/src/processor-runner.ts index 9b59eadb7..bc0aaab44 100644 --- a/sdk/src/processor-runner.ts +++ b/sdk/src/processor-runner.ts @@ -38,9 +38,6 @@ setProvider(chainsConfig, options.concurrency, options['use-chainserver']) console.log('Start Server', options) -console.log(global.PROCESSOR_STATE.processors.length, ' processors loaded') -console.log(global.PROCESSOR_STATE.solanaProcessors.length, ' solana processors loaded') - const server = createServer() const service = new ProcessorServiceImpl(() => load(options.target), server.shutdown) diff --git a/sdk/src/utils/erc20.ts b/sdk/src/utils/erc20.ts index f056cd23c..2f09dc06f 100644 --- a/sdk/src/utils/erc20.ts +++ b/sdk/src/utils/erc20.ts @@ -7,12 +7,18 @@ import { BigDecimal } from '@sentio/sdk' import { toBigDecimal } from './convert' import { utils } from 'ethers' -export interface TokenInfo { +export class TokenInfo { symbol: string name: string decimal: number } +export const NATIVE_ETH = { + symbol: 'ETH', + decimal: 18, + name: 'Native ETH', +} + const TOKEN_INFOS = new Map() export async function getERC20TokenInfo(tokenAddress: string, chainId = 1): Promise { @@ -41,7 +47,7 @@ export async function getERC20TokenInfo(tokenAddress: string, chainId = 1): Prom } const decimal = await contract.decimals() - const info = { name, symbol, decimal } + const info: TokenInfo = { name, symbol, decimal } TOKEN_INFOS.set(key, info) return info } catch (e) { diff --git a/sdk/src/utils/index.ts b/sdk/src/utils/index.ts index 3574ebe42..7ac0ae1cd 100644 --- a/sdk/src/utils/index.ts +++ b/sdk/src/utils/index.ts @@ -1,3 +1,3 @@ export { getChainName } from './chainmap' export { toBigDecimal, metricValueToNumberish } from './convert' -export { getERC20TokenInfo, getER20NormalizedAmount } from './erc20' +export { getERC20TokenInfo, getER20NormalizedAmount, TokenInfo, NATIVE_ETH } from './erc20'