Changeset View
Changeset View
Standalone View
Standalone View
cashtab/src/chronik/index.ts
| Show All 16 Lines | import { | ||||
| undecimalizeTokenAmount, | undecimalizeTokenAmount, | ||||
| TokenUtxo, | TokenUtxo, | ||||
| SlpDecimals, | SlpDecimals, | ||||
| CashtabTx, | CashtabTx, | ||||
| toXec, | toXec, | ||||
| } from 'wallet'; | } from 'wallet'; | ||||
| import { ChronikClient, Tx, TokenTxType, GenesisInfo } from 'chronik-client'; | import { ChronikClient, Tx, TokenTxType, GenesisInfo } from 'chronik-client'; | ||||
| import { CashtabCachedTokenInfo } from 'config/CashtabCache'; | import { CashtabCachedTokenInfo } from 'config/CashtabCache'; | ||||
| import { applyTokenDisplayOverrides } from 'constants/tokenDisplayOverrides'; | |||||
| import appConfig from 'config/app'; | import appConfig from 'config/app'; | ||||
| import { opReturn } from 'config/opreturn'; | import { opReturn } from 'config/opreturn'; | ||||
| import { scriptOps } from 'ecash-agora'; | import { scriptOps } from 'ecash-agora'; | ||||
| import { Script, fromHex, OP_0, decodeInputData, toHex } from 'ecash-lib'; | import { Script, fromHex, OP_0, decodeInputData, toHex } from 'ecash-lib'; | ||||
| import { getRenderedTokenType, RenderedTokenType } from 'token-protocols'; | import { getRenderedTokenType, RenderedTokenType } from 'token-protocols'; | ||||
| import { getEmppAppActions, getEmppAppAction } from 'opreturn'; | import { getEmppAppActions, getEmppAppAction } from 'opreturn'; | ||||
| import { decimalizedTokenQtyToLocaleFormat } from 'formatting'; | import { decimalizedTokenQtyToLocaleFormat } from 'formatting'; | ||||
| ▲ Show 20 Lines • Show All 1,268 Lines • ▼ Show 20 Lines | |||||
| ): Promise<CashtabCachedTokenInfo> => { | ): Promise<CashtabCachedTokenInfo> => { | ||||
| // We can get timeFirstSeen, block, tokenType, and genesisInfo from the token() endpoint | // We can get timeFirstSeen, block, tokenType, and genesisInfo from the token() endpoint | ||||
| // If we call this endpoint before the genesis tx is confirmed, we will not get block | // If we call this endpoint before the genesis tx is confirmed, we will not get block | ||||
| // So, block does not need to be included | // So, block does not need to be included | ||||
| const tokenInfo = await chronik.token(tokenId); | const tokenInfo = await chronik.token(tokenId); | ||||
| const genesisTxInfo = await chronik.tx(tokenId); | const genesisTxInfo = await chronik.tx(tokenId); | ||||
| const { timeFirstSeen, genesisInfo, tokenType } = tokenInfo; | const { timeFirstSeen, tokenType } = tokenInfo; | ||||
| const genesisInfo = applyTokenDisplayOverrides( | |||||
| tokenId, | |||||
| tokenInfo.genesisInfo, | |||||
| ); | |||||
| const decimals = genesisInfo.decimals; | const decimals = genesisInfo.decimals; | ||||
| // Initialize variables for determined quantities we want to cache | // Initialize variables for determined quantities we want to cache | ||||
| /** | /** | ||||
| * genesisSupply {string} | * genesisSupply {string} | ||||
| * Quantity of token created at mint | * Quantity of token created at mint | ||||
| * Note: we may have genesisSupply at different genesisAddresses | * Note: we may have genesisSupply at different genesisAddresses | ||||
| ▲ Show 20 Lines • Show All 216 Lines • Show Last 20 Lines | |||||