diff --git a/src/algorand/AlgorandEngine.ts b/src/algorand/AlgorandEngine.ts index 498bd61bf..fa00adfdc 100644 --- a/src/algorand/AlgorandEngine.ts +++ b/src/algorand/AlgorandEngine.ts @@ -708,17 +708,6 @@ export class AlgorandEngine extends CurrencyEngine< return edgeTransaction } - getDisplayPrivateSeed(privateKeys: JsonObject): string { - const algorandPrivateKeys = asAlgorandPrivateKeys( - this.currencyInfo.pluginId - )(privateKeys) - return algorandPrivateKeys.mnemonic - } - - getDisplayPublicSeed(): string { - return this.walletInfo.keys.publicKey ?? '' - } - engineGetActivationAssets = async ( options: EdgeEngineGetActivationAssetsOptions ): Promise => { diff --git a/src/algorand/AlgorandTools.ts b/src/algorand/AlgorandTools.ts index d0485f26d..34fe7951b 100644 --- a/src/algorand/AlgorandTools.ts +++ b/src/algorand/AlgorandTools.ts @@ -20,7 +20,8 @@ import { getDenomInfo } from '../common/utils' import { AlgorandNetworkInfo, asAlgorandPrivateKeys, - asMaybeContractAddressLocation + asMaybeContractAddressLocation, + asSafeAlgorandWalletInfo } from './algorandTypes' const { isValidAddress, mnemonicFromSeed } = algosdk @@ -37,6 +38,19 @@ export class AlgorandTools implements EdgeCurrencyTools { this.builtinTokens = builtinTokens } + async getDisplayPrivateKey( + privateWalletInfo: EdgeWalletInfo + ): Promise { + const { pluginId } = this.currencyInfo + const keys = asAlgorandPrivateKeys(pluginId)(privateWalletInfo.keys) + return keys.mnemonic + } + + async getDisplayPublicKey(publicWalletInfo: EdgeWalletInfo): Promise { + const { keys } = asSafeAlgorandWalletInfo(publicWalletInfo) + return keys.publicKey + } + async importPrivateKey(input: string): Promise { const { pluginId } = this.currencyInfo diff --git a/src/binance/BinanceEngine.ts b/src/binance/BinanceEngine.ts index 7a084472b..ed59c505b 100644 --- a/src/binance/BinanceEngine.ts +++ b/src/binance/BinanceEngine.ts @@ -514,16 +514,6 @@ export class BinanceEngine extends CurrencyEngine< throw new Error(`Broadcast failed: ${e.message}`) } } - - getDisplayPrivateSeed(privateKeys: JsonObject): string { - const bnbPrivateKey = asBnbPrivateKey(privateKeys) - return bnbPrivateKey.binanceMnemonic - } - - getDisplayPublicSeed(): string { - const { keys } = this.walletInfo - return keys.publicKey - } } export async function makeCurrencyEngine( diff --git a/src/binance/BinanceTools.ts b/src/binance/BinanceTools.ts index b9e53684a..e680b0da9 100644 --- a/src/binance/BinanceTools.ts +++ b/src/binance/BinanceTools.ts @@ -16,7 +16,11 @@ import { import { PluginEnvironment } from '../common/innerPlugin' import { encodeUriCommon, parseUriCommon } from '../common/uriHelpers' import { getDenomInfo } from '../common/utils' -import { BinanceNetworkInfo } from './binanceTypes' +import { + asBnbPrivateKey, + asSafeBnbWalletInfo, + BinanceNetworkInfo +} from './binanceTypes' const { checkAddress, @@ -39,6 +43,18 @@ export class BinanceTools implements EdgeCurrencyTools { this.networkInfo = networkInfo } + async getDisplayPrivateKey( + privateWalletInfo: EdgeWalletInfo + ): Promise { + const keys = asBnbPrivateKey(privateWalletInfo.keys) + return keys.binanceMnemonic + } + + async getDisplayPublicKey(publicWalletInfo: EdgeWalletInfo): Promise { + const { keys } = asSafeBnbWalletInfo(publicWalletInfo) + return keys.publicKey + } + // will actually use MNEMONIC version of private key async importPrivateKey(mnemonic: string): Promise { const isValid = validateMnemonic(mnemonic) diff --git a/src/common/CurrencyEngine.ts b/src/common/CurrencyEngine.ts index e4351d1f1..860a396f4 100644 --- a/src/common/CurrencyEngine.ts +++ b/src/common/CurrencyEngine.ts @@ -1076,14 +1076,6 @@ export class CurrencyEngine< // Virtual functions to be override by extension: // - getDisplayPrivateSeed(privateKeys: JsonObject): string | null { - throw new Error('not implemented') - } - - getDisplayPublicSeed(): string | null { - throw new Error('not implemented') - } - async resyncBlockchain(): Promise { throw new Error('not implemented') } diff --git a/src/eos/EosEngine.ts b/src/eos/EosEngine.ts index cce17b4b8..0a0a9236c 100644 --- a/src/eos/EosEngine.ts +++ b/src/eos/EosEngine.ts @@ -1150,31 +1150,6 @@ export class EosEngine extends CurrencyEngine { throw err } } - - getDisplayPrivateSeed(privateKeys: JsonObject): string { - const eosPrivateKeys = asEosPrivateKeys(privateKeys) - let out = '' - // usage of eosOwnerKey must be protected by conditional - // checking for its existence - out += 'owner key\n' + String(eosPrivateKeys.eosOwnerKey) + '\n\n' - out += 'active key\n' + String(eosPrivateKeys.eosKey) + '\n\n' - return out - } - - getDisplayPublicSeed(): string { - let out = '' - if (this.walletInfo.keys?.ownerPublicKey != null) { - out += - 'owner publicKey\n' + - String(this.walletInfo.keys.ownerPublicKey) + - '\n\n' - } - if (this.walletInfo.keys?.publicKey != null) { - out += - 'active publicKey\n' + String(this.walletInfo.keys.publicKey) + '\n\n' - } - return out - } } export async function makeCurrencyEngine( diff --git a/src/eos/EosTools.ts b/src/eos/EosTools.ts index 37ee7803b..09684987e 100644 --- a/src/eos/EosTools.ts +++ b/src/eos/EosTools.ts @@ -30,7 +30,11 @@ import { asGetActivationCost, asGetActivationSupportedCurrencies } from './eosSchema' -import { EosNetworkInfo } from './eosTypes' +import { + asEosPrivateKeys, + asSafeEosWalletInfo, + EosNetworkInfo +} from './eosTypes' export function checkAddress(address: string): boolean { return Name.pattern.test(address) @@ -63,6 +67,31 @@ export class EosTools implements EdgeCurrencyTools { this.networkInfo = networkInfo } + async getDisplayPrivateKey( + privateWalletInfo: EdgeWalletInfo + ): Promise { + const keys = asEosPrivateKeys(privateWalletInfo.keys) + let out = '' + // usage of eosOwnerKey must be protected by conditional + // checking for its existence + out += 'owner key\n' + String(keys.eosOwnerKey) + '\n\n' + out += 'active key\n' + String(keys.eosKey) + '\n\n' + return out + } + + async getDisplayPublicKey(publicWalletInfo: EdgeWalletInfo): Promise { + const { keys } = asSafeEosWalletInfo(publicWalletInfo) + + let out = '' + if (keys?.ownerPublicKey != null) { + out += 'owner publicKey\n' + String(keys.ownerPublicKey) + '\n\n' + } + if (keys?.publicKey != null) { + out += 'active publicKey\n' + String(keys.publicKey) + '\n\n' + } + return out + } + async importPrivateKey(privateKey: string): Promise { const strippedPrivateKey = privateKey.replace(/ /g, '') // should be in WIF format if (strippedPrivateKey.length !== 51) { diff --git a/src/ethereum/EthereumEngine.ts b/src/ethereum/EthereumEngine.ts index a4a8c8ea4..882b1aa07 100644 --- a/src/ethereum/EthereumEngine.ts +++ b/src/ethereum/EthereumEngine.ts @@ -1325,17 +1325,6 @@ export class EthereumEngine extends CurrencyEngine< } } - getDisplayPrivateSeed(privateKeys: JsonObject): string { - const ethereumPrivateKeys = asEthereumPrivateKeys( - this.currencyInfo.pluginId - )(privateKeys) - return ethereumPrivateKeys.privateKey - } - - getDisplayPublicSeed(): string | null { - return this.walletInfo.keys.publicKey - } - // Overload saveTx to mutate replaced transactions by RBF // eslint-disable-next-line @typescript-eslint/explicit-function-return-type async saveTx(edgeTransaction: EdgeTransaction) { diff --git a/src/ethereum/EthereumTools.ts b/src/ethereum/EthereumTools.ts index adca8d3ab..edaba09eb 100644 --- a/src/ethereum/EthereumTools.ts +++ b/src/ethereum/EthereumTools.ts @@ -20,7 +20,11 @@ import { asMaybeContractLocation, validateToken } from '../common/tokenHelpers' import { encodeUriCommon, parseUriCommon } from '../common/uriHelpers' import { biggyScience, getDenomInfo } from '../common/utils' import { ethereumPlugins } from './ethereumInfos' -import { EthereumNetworkInfo } from './ethereumTypes' +import { + asEthereumPrivateKeys, + asSafeEthWalletInfo, + EthereumNetworkInfo +} from './ethereumTypes' export class EthereumTools implements EdgeCurrencyTools { builtinTokens: EdgeTokenMap @@ -36,6 +40,19 @@ export class EthereumTools implements EdgeCurrencyTools { this.networkInfo = networkInfo } + async getDisplayPrivateKey( + privateWalletInfo: EdgeWalletInfo + ): Promise { + const { pluginId } = this.currencyInfo + const keys = asEthereumPrivateKeys(pluginId)(privateWalletInfo.keys) + return keys.privateKey + } + + async getDisplayPublicKey(publicWalletInfo: EdgeWalletInfo): Promise { + const { keys } = asSafeEthWalletInfo(publicWalletInfo) + return keys.publicKey + } + async importPrivateKey(userInput: string): Promise { const { pluginId } = this.currencyInfo const { pluginMnemonicKeyName, pluginRegularKeyName } = this.networkInfo diff --git a/src/fio/FioEngine.ts b/src/fio/FioEngine.ts index dfce0c5d1..f6aca5f43 100644 --- a/src/fio/FioEngine.ts +++ b/src/fio/FioEngine.ts @@ -1991,15 +1991,6 @@ export class FioEngine extends CurrencyEngine { async getFreshAddress(options: any): Promise { return { publicAddress: this.walletInfo.keys.publicKey } } - - getDisplayPrivateSeed(privateKeys: JsonObject): string { - const fioPrivateKeys = asFioPrivateKeys(privateKeys) - return fioPrivateKeys.fioKey - } - - getDisplayPublicSeed(): string { - return this.walletInfo.keys.publicKey - } } export async function makeCurrencyEngine( diff --git a/src/fio/FioTools.ts b/src/fio/FioTools.ts index 6550b4a48..cfd86ca31 100644 --- a/src/fio/FioTools.ts +++ b/src/fio/FioTools.ts @@ -26,7 +26,11 @@ import { import { DEFAULT_APR, FIO_REG_API_ENDPOINTS } from './fioConst' import { fioApiErrorCodes, FioError } from './fioError' import { currencyInfo } from './fioInfo' -import { FioNetworkInfo } from './fioTypes' +import { + asFioPrivateKeys, + asSafeFioWalletInfo, + FioNetworkInfo +} from './fioTypes' const FIO_CURRENCY_CODE = 'FIO' const FIO_TYPE = 'fio' @@ -74,6 +78,18 @@ export class FioTools implements EdgeCurrencyTools { } } + async getDisplayPrivateKey( + privateWalletInfo: EdgeWalletInfo + ): Promise { + const keys = asFioPrivateKeys(privateWalletInfo.keys) + return keys.fioKey + } + + async getDisplayPublicKey(publicWalletInfo: EdgeWalletInfo): Promise { + const { keys } = asSafeFioWalletInfo(publicWalletInfo) + return keys.publicKey + } + async importPrivateKey(userInput: string): Promise { const { pluginId } = this.currencyInfo const keys = {} diff --git a/src/hedera/HederaEngine.ts b/src/hedera/HederaEngine.ts index 353e978f5..5509d2371 100644 --- a/src/hedera/HederaEngine.ts +++ b/src/hedera/HederaEngine.ts @@ -544,25 +544,6 @@ export class HederaEngine extends CurrencyEngine< getBlockHeight(): number { return Math.floor(Date.now() / 1000) } - - getDisplayPrivateSeed(privateKeys: JsonObject): string { - const hederaPrivateKeys = asHederaPrivateKeys(this.currencyInfo.pluginId)( - privateKeys - ) - return hederaPrivateKeys.mnemonic ?? hederaPrivateKeys.privateKey - } - - // eslint-disable-next-line @typescript-eslint/explicit-function-return-type - getDisplayPublicSeed() { - if ( - // eslint-disable-next-line @typescript-eslint/prefer-optional-chain - this.walletInfo.keys != null && - this.walletInfo.keys.publicKey != null - ) { - return this.walletInfo.keys.publicKey - } - return '' - } } function hashToTxid(hash: Uint8Array): string { diff --git a/src/hedera/HederaTools.ts b/src/hedera/HederaTools.ts index b9f77eae1..48ae68440 100644 --- a/src/hedera/HederaTools.ts +++ b/src/hedera/HederaTools.ts @@ -16,7 +16,12 @@ import { import { PluginEnvironment } from '../common/innerPlugin' import { encodeUriCommon, parseUriCommon } from '../common/uriHelpers' import { getDenomInfo, getFetchCors } from '../common/utils' -import { asGetActivationCost, HederaNetworkInfo } from './hederaTypes' +import { + asGetActivationCost, + asHederaPrivateKeys, + asSafeHederaWalletInfo, + HederaNetworkInfo +} from './hederaTypes' import { createChecksum, validAddress } from './hederaUtils' // if users want to import their mnemonic phrase in e.g. MyHbarWallet.com @@ -42,6 +47,19 @@ export class HederaTools implements EdgeCurrencyTools { this.networkInfo = networkInfo } + async getDisplayPrivateKey( + privateWalletInfo: EdgeWalletInfo + ): Promise { + const { pluginId } = this.currencyInfo + const keys = asHederaPrivateKeys(pluginId)(privateWalletInfo.keys) + return keys.mnemonic ?? keys.privateKey + } + + async getDisplayPublicKey(publicWalletInfo: EdgeWalletInfo): Promise { + const { keys } = asSafeHederaWalletInfo(publicWalletInfo) + return keys.publicKey + } + async createPrivateKey(walletType: string): Promise { if (walletType !== this.currencyInfo.walletType) { throw new Error('InvalidWalletType') diff --git a/src/polkadot/PolkadotEngine.ts b/src/polkadot/PolkadotEngine.ts index c2dcaef4e..4be21e8bf 100644 --- a/src/polkadot/PolkadotEngine.ts +++ b/src/polkadot/PolkadotEngine.ts @@ -476,17 +476,6 @@ export class PolkadotEngine extends CurrencyEngine< return edgeTransaction } - - getDisplayPrivateSeed(privateKeys: JsonObject): string { - const polkadotPrivateKeys = asPolkapolkadotPrivateKeys( - this.currencyInfo.pluginId - )(privateKeys) - return polkadotPrivateKeys.mnemonic ?? polkadotPrivateKeys.privateKey - } - - getDisplayPublicSeed(): string { - return this.walletInfo.keys.publicKey ?? '' - } } export async function makeCurrencyEngine( diff --git a/src/polkadot/PolkadotTools.ts b/src/polkadot/PolkadotTools.ts index da9bfcff0..73bda6193 100644 --- a/src/polkadot/PolkadotTools.ts +++ b/src/polkadot/PolkadotTools.ts @@ -18,7 +18,11 @@ import { import { PluginEnvironment } from '../common/innerPlugin' import { encodeUriCommon, parseUriCommon } from '../common/uriHelpers' import { getDenomInfo, isHex } from '../common/utils' -import { PolkadotNetworkInfo } from './polkadotTypes' +import { + asPolkapolkadotPrivateKeys, + asSafePolkadotWalletInfo, + PolkadotNetworkInfo +} from './polkadotTypes' const { ed25519PairFromSeed, isAddress, mnemonicToMiniSecret } = utilCrypto @@ -42,6 +46,19 @@ export class PolkadotTools implements EdgeCurrencyTools { this.polkadotApiSubscribers = new Set() } + async getDisplayPrivateKey( + privateWalletInfo: EdgeWalletInfo + ): Promise { + const { pluginId } = this.currencyInfo + const keys = asPolkapolkadotPrivateKeys(pluginId)(privateWalletInfo.keys) + return keys.mnemonic ?? keys.privateKey + } + + async getDisplayPublicKey(publicWalletInfo: EdgeWalletInfo): Promise { + const { keys } = asSafePolkadotWalletInfo(publicWalletInfo) + return keys.publicKey + } + async importPrivateKey(userInput: string): Promise { const { pluginId } = this.currencyInfo if (validateMnemonic(userInput)) { diff --git a/src/ripple/RippleEngine.ts b/src/ripple/RippleEngine.ts index 996aee1f5..59c5ad642 100644 --- a/src/ripple/RippleEngine.ts +++ b/src/ripple/RippleEngine.ts @@ -893,15 +893,6 @@ export class XrpEngine extends CurrencyEngine< return edgeTransaction } - getDisplayPrivateSeed(privateKeys: JsonObject): string { - const ripplePrivateKeys = asRipplePrivateKeys(privateKeys) - return ripplePrivateKeys.rippleKey - } - - getDisplayPublicSeed(): string { - return this.walletInfo.keys?.publicKey ?? '' - } - engineGetActivationAssets = async ( options: EdgeEngineGetActivationAssetsOptions ): Promise => { diff --git a/src/ripple/RippleTools.ts b/src/ripple/RippleTools.ts index 8d3d2fae1..4272a74c7 100644 --- a/src/ripple/RippleTools.ts +++ b/src/ripple/RippleTools.ts @@ -23,7 +23,12 @@ import { PluginEnvironment } from '../common/innerPlugin' import { validateToken } from '../common/tokenHelpers' import { encodeUriCommon, parseUriCommon } from '../common/uriHelpers' import { asyncWaterfall, getDenomInfo, safeErrorMessage } from '../common/utils' -import { asXrpNetworkLocation, XrpNetworkInfo } from './rippleTypes' +import { + asRipplePrivateKeys, + asSafeRippleWalletInfo, + asXrpNetworkLocation, + XrpNetworkInfo +} from './rippleTypes' import { makeTokenId } from './rippleUtils' export class RippleTools implements EdgeCurrencyTools { @@ -45,6 +50,18 @@ export class RippleTools implements EdgeCurrencyTools { this.rippleApiSubscribers = {} } + async getDisplayPrivateKey( + privateWalletInfo: EdgeWalletInfo + ): Promise { + const keys = asRipplePrivateKeys(privateWalletInfo.keys) + return keys.rippleKey + } + + async getDisplayPublicKey(publicWalletInfo: EdgeWalletInfo): Promise { + const { keys } = asSafeRippleWalletInfo(publicWalletInfo) + return keys.publicKey + } + async connectApi(walletId: string): Promise { if (Object.keys(this.rippleApiSubscribers).length === 0) { const funcs = this.networkInfo.rippledServers.map(server => async () => { diff --git a/src/solana/SolanaEngine.ts b/src/solana/SolanaEngine.ts index 02b4e424d..ce571634e 100644 --- a/src/solana/SolanaEngine.ts +++ b/src/solana/SolanaEngine.ts @@ -434,17 +434,6 @@ export class SolanaEngine extends CurrencyEngine< return edgeTransaction } - - getDisplayPrivateSeed(privateKeys: JsonObject): string | null { - const solanaPrivateKeys = asSolanaPrivateKeys(this.currencyInfo.pluginId)( - privateKeys - ) - return solanaPrivateKeys.mnemonic - } - - getDisplayPublicSeed(): string { - return this.walletInfo.keys.publicKey - } } export async function makeCurrencyEngine( diff --git a/src/solana/SolanaTools.ts b/src/solana/SolanaTools.ts index fd038f125..fd63dd884 100644 --- a/src/solana/SolanaTools.ts +++ b/src/solana/SolanaTools.ts @@ -18,7 +18,11 @@ import { import { PluginEnvironment } from '../common/innerPlugin' import { encodeUriCommon, parseUriCommon } from '../common/uriHelpers' import { getDenomInfo } from '../common/utils' -import { SolanaNetworkInfo } from './solanaTypes' +import { + asSafeSolanaWalletInfo, + asSolanaPrivateKeys, + SolanaNetworkInfo +} from './solanaTypes' const { Keypair, PublicKey } = solanaWeb3 @@ -47,6 +51,19 @@ export class SolanaTools implements EdgeCurrencyTools { this.networkInfo = networkInfo } + async getDisplayPrivateKey( + privateWalletInfo: EdgeWalletInfo + ): Promise { + const { pluginId } = this.currencyInfo + const keys = asSolanaPrivateKeys(pluginId)(privateWalletInfo.keys) + return keys.mnemonic + } + + async getDisplayPublicKey(publicWalletInfo: EdgeWalletInfo): Promise { + const { keys } = asSafeSolanaWalletInfo(publicWalletInfo) + return keys.publicKey + } + async importPrivateKey(mnemonic: string): Promise { const { pluginId } = this.currencyInfo const isValid = validateMnemonic(mnemonic) diff --git a/src/stellar/StellarEngine.ts b/src/stellar/StellarEngine.ts index 4a0b77d53..cac5119df 100644 --- a/src/stellar/StellarEngine.ts +++ b/src/stellar/StellarEngine.ts @@ -667,15 +667,6 @@ export class StellarEngine extends CurrencyEngine< } return edgeTransaction } - - getDisplayPrivateSeed(privateKeys: JsonObject): string | null { - const stellarPrivateKeys = asStellarPrivateKeys(privateKeys) - return stellarPrivateKeys.stellarKey - } - - getDisplayPublicSeed(): string | null { - return this.walletInfo.keys.publicKey - } } export async function makeCurrencyEngine( diff --git a/src/stellar/StellarTools.ts b/src/stellar/StellarTools.ts index bb1cbaf02..4de8ecba6 100644 --- a/src/stellar/StellarTools.ts +++ b/src/stellar/StellarTools.ts @@ -15,7 +15,11 @@ import parse from 'url-parse' import { PluginEnvironment } from '../common/innerPlugin' import { parseUriCommon } from '../common/uriHelpers' import { getDenomInfo } from '../common/utils' -import { StellarNetworkInfo } from './stellarTypes' +import { + asSafeStellarWalletInfo, + asStellarPrivateKeys, + StellarNetworkInfo +} from './stellarTypes' const URI_PREFIX = 'web+stellar' @@ -44,6 +48,18 @@ export class StellarTools implements EdgeCurrencyTools { } } + async getDisplayPrivateKey( + privateWalletInfo: EdgeWalletInfo + ): Promise { + const keys = asStellarPrivateKeys(privateWalletInfo.keys) + return keys.stellarKey + } + + async getDisplayPublicKey(publicWalletInfo: EdgeWalletInfo): Promise { + const { keys } = asSafeStellarWalletInfo(publicWalletInfo) + return keys.publicKey + } + checkAddress(address: string): boolean { // TODO: check address try { diff --git a/src/tezos/TezosEngine.ts b/src/tezos/TezosEngine.ts index 44c3f2641..576477c49 100644 --- a/src/tezos/TezosEngine.ts +++ b/src/tezos/TezosEngine.ts @@ -519,15 +519,6 @@ export class TezosEngine extends CurrencyEngine< this.warn(`SUCCESS broadcastTx\n${cleanTxLogs(edgeTransaction)}`) return edgeTransaction } - - getDisplayPrivateSeed(privateKeys: JsonObject): string | null { - const tezosPrivateKeys = asTezosPrivateKeys(privateKeys) - return tezosPrivateKeys.mnemonic - } - - getDisplayPublicSeed(): string | null { - return this.walletInfo.keys.publicKey - } } export async function makeCurrencyEngine( diff --git a/src/tezos/TezosTools.ts b/src/tezos/TezosTools.ts index 6f4865a02..f30ecdc7d 100644 --- a/src/tezos/TezosTools.ts +++ b/src/tezos/TezosTools.ts @@ -11,7 +11,12 @@ import { eztz } from 'eztz.js' import { decodeMainnet, encodeMainnet } from 'tezos-uri' import { PluginEnvironment } from '../common/innerPlugin' -import type { TezosNetworkInfo, UriTransaction } from './tezosTypes' +import { + asSafeTezosWalletInfo, + asTezosPrivateKeys, + TezosNetworkInfo, + UriTransaction +} from './tezosTypes' export class TezosTools implements EdgeCurrencyTools { builtinTokens: EdgeTokenMap @@ -33,6 +38,18 @@ export class TezosTools implements EdgeCurrencyTools { this.tezosApiServers = [...this.networkInfo.tezosApiServers] } + async getDisplayPrivateKey( + privateWalletInfo: EdgeWalletInfo + ): Promise { + const keys = asTezosPrivateKeys(privateWalletInfo.keys) + return keys.mnemonic + } + + async getDisplayPublicKey(publicWalletInfo: EdgeWalletInfo): Promise { + const { keys } = asSafeTezosWalletInfo(publicWalletInfo) + return keys.publicKey + } + checkAddress(address: string): boolean { try { const valid = eztz.crypto.checkAddress(address) diff --git a/src/tron/TronEngine.ts b/src/tron/TronEngine.ts index 4bbec754c..aaf72cc4b 100644 --- a/src/tron/TronEngine.ts +++ b/src/tron/TronEngine.ts @@ -1497,15 +1497,6 @@ export class TronEngine extends CurrencyEngine { edgeTransaction.date = Date.now() / 1000 return edgeTransaction } - - getDisplayPrivateSeed(privateKeys: JsonObject): string { - const tronPrivateKeys = asTronPrivateKeys(privateKeys) - return tronPrivateKeys.tronMnemonic ?? tronPrivateKeys.tronKey - } - - getDisplayPublicSeed(): string { - return this.walletInfo.keys.publicKey - } } export async function makeCurrencyEngine( diff --git a/src/tron/TronTools.ts b/src/tron/TronTools.ts index 8864a348d..4bf984c75 100644 --- a/src/tron/TronTools.ts +++ b/src/tron/TronTools.ts @@ -22,6 +22,7 @@ import { asMaybeContractLocation, validateToken } from '../common/tokenHelpers' import { encodeUriCommon, parseUriCommon } from '../common/uriHelpers' import { getDenomInfo } from '../common/utils' import { + asSafeTronWalletInfo, asTronInitOptions, asTronPrivateKeys, TronInitOptions, @@ -54,6 +55,18 @@ export class TronTools implements EdgeCurrencyTools { this.networkInfo = networkInfo } + async getDisplayPrivateKey( + privateWalletInfo: EdgeWalletInfo + ): Promise { + const keys = asTronPrivateKeys(privateWalletInfo.keys) + return keys.tronMnemonic ?? keys.tronKey + } + + async getDisplayPublicKey(publicWalletInfo: EdgeWalletInfo): Promise { + const { keys } = asSafeTronWalletInfo(publicWalletInfo) + return keys.publicKey + } + async importPrivateKey( userInput: string, opts?: { derivationPath?: string } diff --git a/src/zcash/ZcashEngine.ts b/src/zcash/ZcashEngine.ts index 3651841c7..330806e8c 100644 --- a/src/zcash/ZcashEngine.ts +++ b/src/zcash/ZcashEngine.ts @@ -8,7 +8,6 @@ import { EdgeTransaction, EdgeWalletInfo, InsufficientFundsError, - JsonObject, NoAmountSpecifiedError } from 'edge-core-js/types' @@ -400,15 +399,6 @@ export class ZcashEngine extends CurrencyEngine< return edgeTransaction } - getDisplayPrivateSeed(privateKeys: JsonObject): string { - const zcashPrivateKeys = asZcashPrivateKeys(this.pluginId)(privateKeys) - return zcashPrivateKeys.mnemonic - } - - getDisplayPublicSeed(): string { - return this.walletInfo.keys.unifiedViewingKeys?.extfvk ?? '' - } - async loadEngine( plugin: EdgeCurrencyTools, walletInfo: SafeZcashWalletInfo, diff --git a/src/zcash/ZcashTools.ts b/src/zcash/ZcashTools.ts index eb55177e8..e344d3b92 100644 --- a/src/zcash/ZcashTools.ts +++ b/src/zcash/ZcashTools.ts @@ -22,6 +22,7 @@ import { asIntegerString } from '../common/types' import { encodeUriCommon, parseUriCommon } from '../common/uriHelpers' import { getDenomInfo } from '../common/utils' import { + asSafeZcashWalletInfo, asZcashPrivateKeys, asZecPublicKey, UnifiedViewingKey, @@ -54,6 +55,19 @@ export class ZcashTools implements EdgeCurrencyTools { this.AddressTool = AddressTool } + async getDisplayPrivateKey( + privateWalletInfo: EdgeWalletInfo + ): Promise { + const { pluginId } = this.currencyInfo + const keys = asZcashPrivateKeys(pluginId)(privateWalletInfo.keys) + return keys.mnemonic + } + + async getDisplayPublicKey(publicWalletInfo: EdgeWalletInfo): Promise { + const { keys } = asSafeZcashWalletInfo(publicWalletInfo) + return keys.unifiedViewingKeys?.extfvk + } + async getNewWalletBirthdayBlockheight(): Promise { try { return await this.KeyTool.getBirthdayHeight(