Skip to content

Commit

Permalink
clarified unsupported wallet errors
Browse files Browse the repository at this point in the history
  • Loading branch information
NoahSaso committed Oct 2, 2024
1 parent 65cfb5e commit d365ebd
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 9 deletions.
3 changes: 2 additions & 1 deletion packages/i18n/locales/en/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -560,11 +560,12 @@
"unknownDenom": "Unknown denomination {{denom}}.",
"unknownError": "An unknown error occurred.",
"unknownInboxType": "Unknown inbox item type.",
"unsupportedAminoWallet": "{{name}} does not support amino signing, which is needed in order to perform this action. Please try a different wallet.",
"unsupportedApprovalFailedRender": "Failed to render approval proposal. Unsupported module.",
"unsupportedChains_one": "Unsupported chain: {{chains}}.",
"unsupportedChains_other": "Unsupported chains: {{chains}}.",
"unsupportedValenceChain": "Valence accounts are not supported on this chain.",
"unsupportedWallet": "Unsupported wallet. Please use a different wallet."
"unsupportedWallet": "{{name}} does not support this action. Please try a different wallet."
},
"form": {
"acceptSubDaoAddressInputLabel": "SubDAO to accept",
Expand Down
3 changes: 1 addition & 2 deletions packages/i18n/locales/es/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -577,8 +577,7 @@
"unsupportedApprovalFailedRender": "Error al renderizar la propuesta de aprobación. Módulo no soportado.",
"unsupportedChains_one": "Cadena no soportada: {{chains}}.",
"unsupportedChains_other": "Cadenas no soportadas: {{chains}}.",
"unsupportedValenceChain": "Las cuentas de Valence no son compatibles con esta cadena.",
"unsupportedWallet": "Billetera no soportada. Por favor, use una billetera diferente."
"unsupportedValenceChain": "Las cuentas de Valence no son compatibles con esta cadena."
},
"form": {
"acceptSubDaoAddressInputLabel": "SubDAO a aceptar",
Expand Down
22 changes: 17 additions & 5 deletions packages/stateful/hooks/useCfWorkerAuthPostRequest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ export const useCfWorkerAuthPostRequest = (

// If hex public key not loaded, load it from the wallet.
if (!thisChainWallet) {
throw new Error(t('error.loadingData'))
throw new Error(t('error.logInToContinue'))
}

// Attempt to connect if needed.
Expand All @@ -70,7 +70,11 @@ export const useCfWorkerAuthPostRequest = (
await thisChainWallet.client.getAccount?.(thisChainWallet.chainId)
)?.pubkey
if (!publicKey) {
throw new Error(t('error.unsupportedWallet'))
throw new Error(
t('error.unsupportedWallet', {
name: thisChainWallet.walletPrettyName,
})
)
}

return toHex(publicKey)
Expand Down Expand Up @@ -127,12 +131,20 @@ export const useCfWorkerAuthPostRequest = (
)
: chainWallet

if (!thisChainWallet?.address) {
throw new Error(t('error.logInToContinue'))
}

const offlineSignerAmino =
await thisChainWallet?.client.getOfflineSignerAmino?.bind(
await thisChainWallet.client.getOfflineSignerAmino?.bind(
thisChainWallet.client
)?.(thisChainWallet.chainId)
if (!thisChainWallet?.address || !offlineSignerAmino) {
throw new Error(t('error.unsupportedWallet'))
if (!offlineSignerAmino) {
throw new Error(
t('error.unsupportedAminoWallet', {
name: thisChainWallet.walletPrettyName,
})
)
}

// Fetch nonce.
Expand Down
6 changes: 5 additions & 1 deletion packages/stateful/hooks/useManageProfile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -312,7 +312,11 @@ export const useManageProfile = ({
// If no amino signer, error that wallet is unsupported. This should
// only happen if there's no amino signer getter defined.
if (!offlineSignerAmino) {
throw new Error(t('error.unsupportedWallet'))
throw new Error(
t('error.unsupportedAminoWallet', {
name: chainWallet.walletPrettyName,
})
)
}

const hexPublicKey = toHex(pubkeyData)
Expand Down

0 comments on commit d365ebd

Please sign in to comment.