Skip to content

Commit

Permalink
adjusted wallet names when linking accounts in settings
Browse files Browse the repository at this point in the history
  • Loading branch information
piggydoughnut committed Mar 11, 2024
1 parent fdad263 commit 2b259f5
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 5 deletions.
9 changes: 8 additions & 1 deletion src/modules/users/client/components/MySettings.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,14 @@ import { getWallets } from '#client/components/auth/helper'
export const MySettings: React.FC = () => {
useDocumentTitle('Settings')
// @todo move to some config?
const allowedWallets = ['polkadot-js', 'talisman']
const allowedWallets = [
'polkadot-js',
'talisman',
'subwallet-js',
'subwallet',
'novawallet',
'walletconnect',
]
const me = useStore(stores.me)
const [showModal, setShowModal] = useState(false)
const [wallets, setWallets] = useState<any>([])
Expand Down
11 changes: 7 additions & 4 deletions src/modules/users/server/router.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import { AuthAccount } from '#shared/types'
import * as fp from '#shared/utils/fp'
import { Permissions } from '../permissions'
import {
AuthExtension,
AuthProvider,
GeoData,
ImportedTag,
Expand Down Expand Up @@ -492,9 +493,11 @@ const userRouter: FastifyPluginCallback = async function (fastify, opts) {
}>,
reply
) => {
const extensionName = req.body.extensionName
const source: AuthExtension = req.body.extensionName
.replaceAll(' ', '')
.toLowerCase()
const providerAuthIds = req.user.authIds[AuthProvider.Polkadot] ?? []
const extensionIds = providerAuthIds[extensionName] ?? []
const extensionIds = providerAuthIds[source] ?? []

if (!!Object.keys(providerAuthIds).length && extensionIds) {
const alreadyLinked = extensionIds.find(
Expand All @@ -515,15 +518,15 @@ const userRouter: FastifyPluginCallback = async function (fastify, opts) {

if (!!otherUsers.length) {
fastify.log.error(
`The address ${req.body.address} from provider ${PROVIDER_NAME}, extension: ${extensionName} has already been linked with user ${otherUsers[0].id}`
`The address ${req.body.address} from provider ${PROVIDER_NAME}, extension: ${source} has already been linked with user ${otherUsers[0].id}`
)
return reply.throw.badParams(
'This address has already been connected to another account.'
)
}

await req.user
.addAuthId(AuthProvider.Polkadot, extensionName, {
.addAuthId(AuthProvider.Polkadot, source, {
name: req.body.name,
address: req.body.address,
})
Expand Down
4 changes: 4 additions & 0 deletions src/modules/users/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,10 @@ export enum AuthProvider {
export enum AuthExtension {
PolkadotJs = 'polkadot-js',
Talisman = 'talisman',
Nova = 'novawallet',
Subwallet = 'subwallet',
SubwalletJs = 'subwallet-js',
WalletConnect = 'walletConnect',
}

export type AuthIds = Record<
Expand Down

0 comments on commit 2b259f5

Please sign in to comment.