Skip to content

Commit

Permalink
chore(sdk): export more token info types (stephenh#92)
Browse files Browse the repository at this point in the history
  • Loading branch information
zfy0701 authored Sep 13, 2022
1 parent 2a4044b commit c3a7eab
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 6 deletions.
3 changes: 0 additions & 3 deletions sdk/src/processor-runner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
10 changes: 8 additions & 2 deletions sdk/src/utils/erc20.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<string, TokenInfo>()

export async function getERC20TokenInfo(tokenAddress: string, chainId = 1): Promise<TokenInfo> {
Expand Down Expand Up @@ -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) {
Expand Down
2 changes: 1 addition & 1 deletion sdk/src/utils/index.ts
Original file line number Diff line number Diff line change
@@ -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'

0 comments on commit c3a7eab

Please sign in to comment.