Skip to content

Commit

Permalink
Embed hw wallet name in crypto provider info
Browse files Browse the repository at this point in the history
  • Loading branch information
refi93 committed Nov 22, 2021
1 parent 4e64446 commit 745bf2b
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 16 deletions.
2 changes: 1 addition & 1 deletion app/frontend/actions/common.ts
Expand Up @@ -24,7 +24,7 @@ export default (store: Store) => {
sendTransactionSummary: {
// TODO: we should reset this to null
type: TxType.SEND_ADA,
address: null,
address: null as any, // TODO avoid casting to any
coins: 0 as Lovelace,
token: null,
minimalLovelaceAmount: 0 as Lovelace,
Expand Down
Expand Up @@ -10,7 +10,6 @@ import tooltip from '../../common/tooltip'
import Alert from '../../common/alert'
import {
AssetFamily,
AuthMethodType,
DelegateTransactionSummary,
DeregisterStakingKeyTransactionSummary,
Lovelace,
Expand Down
2 changes: 1 addition & 1 deletion app/frontend/state.ts
Expand Up @@ -197,7 +197,7 @@ const initialState: State = {
sendTransactionSummary: {
// this should be called only transactionSummary
type: TxType.SEND_ADA,
address: null,
address: null as any,
coins: 0 as Lovelace,
token: null,
minimalLovelaceAmount: 0 as Lovelace,
Expand Down
2 changes: 1 addition & 1 deletion app/frontend/types.ts
Expand Up @@ -379,7 +379,7 @@ export type SendTransactionSummary = {
type: TxType.SEND_ADA | TxType.CONVERT_LEGACY
coins: Lovelace
token: Token | null
address: Address | null
address: Address
minimalLovelaceAmount: Lovelace
}

Expand Down
30 changes: 18 additions & 12 deletions app/frontend/wallet/shelley-wallet.ts
Expand Up @@ -36,29 +36,36 @@ const ShelleyWallet = ({config, cryptoProvider}: WalletParams) => {
return cryptoProvider.isHwWallet()
}

function getWalletName() {
// TODO remove
return cryptoProvider.getWalletName()
}

function getCryptoProviderInfo(): CryptoProviderInfo {
const supportedFeatures: CryptoProviderFeature[] = []
for (const feature of Object.values(CryptoProviderFeature)) {
if (cryptoProvider.isFeatureSupported(feature)) {
supportedFeatures.push(feature)
}
}

return {
cryptoProviderType: cryptoProvider.getType(),
isHwWallet: cryptoProvider.isHwWallet(),
supportedFeatures,
const isHwWallet = cryptoProvider.isHwWallet()

// TODO this passing of deviceBrandName a bit sketchy, think of a less hacky solution
// that would ensure code dealing with the wallet brand name is type-safe
if (isHwWallet) {
return {
cryptoProviderType: cryptoProvider.getType(),
isHwWallet,
supportedFeatures,
deviceBrandName: cryptoProvider.getWalletName(),
}
} else {
return {
cryptoProviderType: cryptoProvider.getType(),
isHwWallet: false,
supportedFeatures,
}
}
}

function submitTx(signedTx, txType: TxType): Promise<any> {
const params = {
walletType: getWalletName(),
walletType: cryptoProvider.getWalletName(),
walletVersion: cryptoProvider.getVersion(),
walletDerivationScheme: cryptoProvider.getDerivationScheme().type,
txType,
Expand Down Expand Up @@ -127,7 +134,6 @@ const ShelleyWallet = ({config, cryptoProvider}: WalletParams) => {

return {
isHwWallet,
getWalletName,
submitTx,
getWalletSecretDef,
fetchTxInfo,
Expand Down

0 comments on commit 745bf2b

Please sign in to comment.