Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor private key connector #577

Merged
merged 1 commit into from Mar 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
16 changes: 13 additions & 3 deletions src/constants/rainbow.ts
Expand Up @@ -23,6 +23,7 @@ import {
zora,
} from 'wagmi/chains'
import { publicProvider } from 'wagmi/providers/public'
import i18n from '~i18n'

export const { chains, publicClient } = configureChains(
[
Expand Down Expand Up @@ -63,7 +64,6 @@ const featuredConnectors = () => {
rainbowWallet({ projectId, chains }),
coinbaseWallet({ chains, appName }),
walletConnectWallet({ chains, projectId }),
privateKeyWallet({ chains }),
],
}

Expand Down Expand Up @@ -100,11 +100,21 @@ const featuredConnectors = () => {
oAuthServiceProvider: 'facebook',
},
}),
privateKeyWallet({ chains }),
],
}

const connectors: { [key: string]: WalletGroup } = { web2, web3 }
const recovery: WalletGroup = {
groupName: i18n.t('rainbow.group.recovery'),
wallets: [
privateKeyWallet({
name: i18n.t('rainbow.recovery'),
iconUrl: 'https://www.svgrepo.com/show/525392/key-minimalistic-square-3.svg',
chains,
}),
],
}

const connectors: { [key: string]: WalletGroup } = { web2, web3, recovery }
const wallets: WalletList = []
for (const connector of import.meta.env.features.login) {
wallets.push(connectors[connector])
Expand Down
6 changes: 6 additions & 0 deletions src/i18n/locales/ca.json
Expand Up @@ -520,6 +520,12 @@
"accuracy": "Precisió dels Saldos de Cens Anònims: "
}
},
"rainbow": {
"group": {
"recovery": "Recuperació"
},
"recovery": "Recuperar compte"
},
"retry": "Reintenta",
"roadmap": {
"census_description": "Crear un cens descentralitzat fora de la cadena i compatible amb zk a partir d'una instantània de blocs d'Ethereum, amb verificació a la cadena.",
Expand Down
6 changes: 6 additions & 0 deletions src/i18n/locales/en.json
Expand Up @@ -511,6 +511,12 @@
"accuracy": "Anonymous Census Balance Accuracy: "
}
},
"rainbow": {
"group": {
"recovery": "Recovery"
},
"recovery": "Account recovery"
},
"retry": "Retry",
"roadmap": {
"census_description": "Create a trust-less off-chain zk-friendly census from an Ethereum block snapshot, with on-chain verification.",
Expand Down
6 changes: 6 additions & 0 deletions src/i18n/locales/es.json
Expand Up @@ -520,6 +520,12 @@
"accuracy": "Precisión de los Saldos de Censo Anónimo: "
}
},
"rainbow": {
"group": {
"recovery": "Recuperación"
},
"recovery": "Recuperar cuenta"
},
"retry": "Reintentar",
"roadmap": {
"census_description": "Crear un censo descentralizado fuera de la cadena y compatible con zk a partir de una instantánea de bloques de Ethereum, con verificación en cadena.",
Expand Down
7 changes: 7 additions & 0 deletions vite/features.ts
Expand Up @@ -23,6 +23,13 @@ const features = () => {
if (!features.languages.length) {
features.languages = ['en']
}
// verify login options are valid
const validLogins = ['web2', 'web3', 'recovery']
features.login.forEach((login) => {
if (!validLogins.includes(login)) {
throw new Error(`Invalid login option: ${login}`)
}
})
// We need pure booleans in order to ensure rollup tree-shakes non enabled features.
// Using functions like `.includes()` would prevent such tree-shaking, resulting in a bigger bundle.
features._census = {
Expand Down