diff --git a/.env b/.env index 6d31fec5..69702ce4 100644 --- a/.env +++ b/.env @@ -34,5 +34,15 @@ NEXT_PUBLIC_WC_PROJECT_ID= # If the API key is not set, Magic support will not be enabled. NEXT_PUBLIC_MAGIC_API_KEY= -# Feature flags +##### Feature flags ##### + +# Language switcher NEXT_PUBLIC_FEAT_LANG_SWITCHER=true + +# Mnemonic wallet - Entering a mnemonic instead of using a wallet +NEXT_PUBLIC_FEAT_MNEMONIC_WALLET=false +# Persist mnemonic wallet to local storage. If not "true", the user will be asked repeatedly for the +# mnemonic every time they need to connect to a wallet or sign a transaction. If "true", the user is +# asked for the mnemonic once because the mnemonic is dangerously stored in local storage in plain +# text. This is ignored if NEXT_PUBLIC_FEAT_MNEMONIC_WALLET is not "true". +NEXT_PUBLIC_FEAT_MNEMONIC_WALLET_PERSIST=false diff --git a/.env.development b/.env.development index 9cd578ed..e4e024db 100644 --- a/.env.development +++ b/.env.development @@ -34,5 +34,15 @@ NEXT_PUBLIC_WC_PROJECT_ID= # If the API key is not set, Magic support will not be enabled. NEXT_PUBLIC_MAGIC_API_KEY= -# Feature flags +##### Feature flags ##### + +# Language switcher NEXT_PUBLIC_FEAT_LANG_SWITCHER=true + +# Mnemonic wallet - Entering a mnemonic instead of using a wallet +NEXT_PUBLIC_FEAT_MNEMONIC_WALLET=true +# Persist mnemonic wallet to local storage. If not "true", the user will be asked repeatedly for the +# mnemonic every time they need to connect to a wallet or sign a transaction. If "true", the user is +# asked for the mnemonic once because the mnemonic is dangerously stored in local storage in plain +# text. This is ignored if NEXT_PUBLIC_FEAT_MNEMONIC_WALLET is not "true". +NEXT_PUBLIC_FEAT_MNEMONIC_WALLET_PERSIST=true diff --git a/.env.local.example b/.env.local.example index c7ecb3ec..4c496942 100644 --- a/.env.local.example +++ b/.env.local.example @@ -35,5 +35,15 @@ NEXT_PUBLIC_WC_PROJECT_ID= # If the API key is not set, Magic support will not be enabled. NEXT_PUBLIC_MAGIC_API_KEY= -# Feature flags +##### Feature flags ##### + +# Language switcher NEXT_PUBLIC_FEAT_LANG_SWITCHER=true + +# Mnemonic wallet - Entering a mnemonic instead of using a wallet +NEXT_PUBLIC_FEAT_MNEMONIC_WALLET=false +# Persist mnemonic wallet to local storage. If not "true", the user will be asked repeatedly for the +# mnemonic every time they need to connect to a wallet or sign a transaction. If "true", the user is +# asked for the mnemonic once because the mnemonic is dangerously stored in local storage in plain +# text. This is ignored if NEXT_PUBLIC_FEAT_MNEMONIC_WALLET is not "true". +NEXT_PUBLIC_FEAT_MNEMONIC_WALLET_PERSIST=false diff --git a/.env.production b/.env.production index 46bc7fbf..f2b1be11 100644 --- a/.env.production +++ b/.env.production @@ -35,5 +35,15 @@ NEXT_PUBLIC_WC_PROJECT_ID= # If the API key is not set, Magic support will not be enabled. NEXT_PUBLIC_MAGIC_API_KEY= -# Feature flags +##### Feature flags ##### + +# Language switcher NEXT_PUBLIC_FEAT_LANG_SWITCHER=true + +# Mnemonic wallet - Entering a mnemonic instead of using a wallet +NEXT_PUBLIC_FEAT_MNEMONIC_WALLET=false +# Persist mnemonic wallet to local storage. If not "true", the user will be asked repeatedly for the +# mnemonic every time they need to connect to a wallet or sign a transaction. If "true", the user is +# asked for the mnemonic once because the mnemonic is dangerously stored in local storage in plain +# text. This is ignored if NEXT_PUBLIC_FEAT_MNEMONIC_WALLET is not "true". +NEXT_PUBLIC_FEAT_MNEMONIC_WALLET_PERSIST=false diff --git a/.env.test b/.env.test index 259861a3..1668fba7 100644 --- a/.env.test +++ b/.env.test @@ -34,5 +34,15 @@ NEXT_PUBLIC_WC_PROJECT_ID= # If the API key is not set, Magic support will not be enabled. NEXT_PUBLIC_MAGIC_API_KEY= -# Feature flags +##### Feature flags ##### + +# Language switcher NEXT_PUBLIC_FEAT_LANG_SWITCHER=true + +# Mnemonic wallet - Entering a mnemonic instead of using a wallet +NEXT_PUBLIC_FEAT_MNEMONIC_WALLET=true +# Persist mnemonic wallet to local storage. If not "true", the user will be asked repeatedly for the +# mnemonic every time they need to connect to a wallet or sign a transaction. If "true", the user is +# asked for the mnemonic once because the mnemonic is dangerously stored in local storage in plain +# text. This is ignored if NEXT_PUBLIC_FEAT_MNEMONIC_WALLET is not "true". +NEXT_PUBLIC_FEAT_MNEMONIC_WALLET_PERSIST=true diff --git a/src/app/[lang]/components/wallet/WalletProvider.tsx b/src/app/[lang]/components/wallet/WalletProvider.tsx index ed3496f4..2e41192e 100644 --- a/src/app/[lang]/components/wallet/WalletProvider.tsx +++ b/src/app/[lang]/components/wallet/WalletProvider.tsx @@ -7,7 +7,7 @@ import { type SupportedWallets, } from '@txnlab/use-wallet-react'; import { useAtomValue } from 'jotai'; -import { nodeConfigAtom } from '@/app/lib/node-config'; +import { MAINNET, nodeConfigAtom } from '@/app/lib/node-config'; /** Wrapper for initializing the use-wallet library. Also serves as a provider to convert the * use-wallet wallet provider to a client component so it can be used in server components with @@ -58,7 +58,24 @@ export default function WalletProvider({ sitename, children }: { }); /* * Wallets list is now: - * Pera, Defly, Lute, WalletConnect, Kibisis, Magic, Exodus, KMD + * Pera, Defly, Lute, WalletConnect?, Kibisis, Magic, Exodus, KMD + */ + } + + // TODO: Disable for Voi MainNet too + // Add mnemonic as a supported wallet if it is enabled in the environment variables + // AND the network is not MainNet + if (process.env.NEXT_PUBLIC_FEAT_MNEMONIC_WALLET === 'true' + && nodeConfig.network !== MAINNET + ) { + // Insert mnemonic wallet at the end of the list of supported wallets + supportedWallets.push({ + id: WalletId.MNEMONIC, + options: { persistToStorage: process.env.NEXT_PUBLIC_FEAT_MNEMONIC_WALLET_PERSIST === 'true'} + }); + /* + * Wallets list is now: + * Pera, Defly, Lute, WalletConnect?, Kibisis, Magic?, Exodus, KMD, Mnemonic */ } @@ -69,7 +86,6 @@ export default function WalletProvider({ sitename, children }: { baseServer: nodeConfig.nodeServer, port: nodeConfig.nodePort, headers: nodeConfig.nodeHeaders, - }, options: { // Setting `debug` to `true` same as setting `logLevel` to `LogLevel.DEBUG` diff --git a/src/app/i18n/locales/en/app.yml b/src/app/i18n/locales/en/app.yml index f84c739a..bf3479bf 100644 --- a/src/app/i18n/locales/en/app.yml +++ b/src/app/i18n/locales/en/app.yml @@ -72,6 +72,7 @@ wallet: kibisis: Kibisis walletconnect: WalletConnect magic: Magic + mnemonic: Mnemonic type: mobile: Mobile wallet mobile_web: Mobile & web wallet @@ -80,6 +81,7 @@ wallet: cli_sandbox: CLI wallet for Sandbox protocol: Wallet connection protocol waas: Wallet-as-a-service + mnemonic: Dangerously enter the mnemonic magic_prompt: fail: Failed to authenticate using Magic. heading: Magic diff --git a/src/app/i18n/locales/es/app.yml b/src/app/i18n/locales/es/app.yml index f346588b..9eb36d2b 100644 --- a/src/app/i18n/locales/es/app.yml +++ b/src/app/i18n/locales/es/app.yml @@ -77,6 +77,7 @@ wallet: kibisis: Kibisis walletconnect: WalletConnect magic: Magic + mnemonic: Mnemonic type: mobile: Billetera móvil mobile_web: Billetera móvil y web @@ -85,6 +86,7 @@ wallet: cli_sandbox: Billetera CLI para Sandbox protocol: Protocolo para conectarse a una billetera waas: Billetera como servicio + mnemonic: Peligrosamente entrar la mnemotecnia magic_prompt: fail: Error al autenticar usando Magic. heading: Magic diff --git a/src/app/lib/wallet-utils.ts b/src/app/lib/wallet-utils.ts index bcb8d432..0e5c72a7 100644 --- a/src/app/lib/wallet-utils.ts +++ b/src/app/lib/wallet-utils.ts @@ -17,6 +17,7 @@ export const walletTypes: {[id: string]: string} = { [WalletId.KIBISIS]: 'browser_extension', [WalletId.WALLETCONNECT]: 'protocol', [WalletId.MAGIC]: 'waas', + [WalletId.MNEMONIC]: 'mnemonic', }; /** Validation atom that contains the Magic email address */