Changeset View
Changeset View
Standalone View
Standalone View
cashtab/src/helpers/index.ts
| // Copyright (c) 2024 The Bitcoin developers | // Copyright (c) 2024 The Bitcoin developers | ||||
| // Distributed under the MIT software license, see the accompanying | // Distributed under the MIT software license, see the accompanying | ||||
| // file COPYING or http://www.opensource.org/licenses/mit-license.php. | // file COPYING or http://www.opensource.org/licenses/mit-license.php. | ||||
| import { | import { | ||||
| ScriptUtxo, | ScriptUtxo, | ||||
| Token, | Token, | ||||
| Tx, | Tx, | ||||
| TxInput, | TxInput, | ||||
| TxOutput, | TxOutput, | ||||
| TokenEntry, | TokenEntry, | ||||
| } from 'chronik-client'; | } from 'chronik-client'; | ||||
| import { Script } from 'ecash-lib'; | import { Script } from 'ecash-lib'; | ||||
| import appConfig from 'config/app'; | import appConfig from 'config/app'; | ||||
| import CashtabCache, { CashtabCachedTokenInfo } from 'config/CashtabCache'; | import CashtabCache, { CashtabCachedTokenInfo } from 'config/CashtabCache'; | ||||
| import { applyDisplayOverridesToTokenCache } from 'constants/tokenDisplayOverrides'; | |||||
| import { toSatoshis } from 'wallet'; | import { toSatoshis } from 'wallet'; | ||||
| import { | import { | ||||
| StoredCashtabState_Pre_3_42_0, | StoredCashtabState_Pre_3_42_0, | ||||
| CashtabPathInfo, | CashtabPathInfo, | ||||
| StoredCashtabPathInfo, | StoredCashtabPathInfo, | ||||
| LegacyCashtabWallet, | LegacyCashtabWallet, | ||||
| LegacyPathInfo, | LegacyPathInfo, | ||||
| CashtabTxJson, | CashtabTxJson, | ||||
| ▲ Show 20 Lines • Show All 94 Lines • ▼ Show 20 Lines | |||||
| * For now, this means converting the one key 'tokens' from a keyvalue array to a Map | * For now, this means converting the one key 'tokens' from a keyvalue array to a Map | ||||
| * @param storedCashtabCache | * @param storedCashtabCache | ||||
| */ | */ | ||||
| export const storedCashtabCacheToMap = ( | export const storedCashtabCacheToMap = ( | ||||
| storedCashtabCache: CashtabCacheJson, | storedCashtabCache: CashtabCacheJson, | ||||
| ): CashtabCache => { | ): CashtabCache => { | ||||
| return { | return { | ||||
| ...storedCashtabCache, | ...storedCashtabCache, | ||||
| tokens: new Map(storedCashtabCache.tokens), | tokens: applyDisplayOverridesToTokenCache( | ||||
| new Map(storedCashtabCache.tokens), | |||||
| ), | |||||
| }; | }; | ||||
| }; | }; | ||||
| export interface LegacyStoredCashtabWallet { | export interface LegacyStoredCashtabWallet { | ||||
| name: string; | name: string; | ||||
| mnemonic: string; | mnemonic: string; | ||||
| paths: [number, StoredCashtabPathInfo][]; | paths: [number, StoredCashtabPathInfo][]; | ||||
| state: StoredCashtabState_Pre_3_42_0; | state: StoredCashtabState_Pre_3_42_0; | ||||
| ▲ Show 20 Lines • Show All 480 Lines • Show Last 20 Lines | |||||