Skip to content

Commit

Permalink
🙈 Add address formating on wallet log in
Browse files Browse the repository at this point in the history
  • Loading branch information
WRadoslaw committed Dec 29, 2023
1 parent a301531 commit 965e6f5
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
3 changes: 3 additions & 0 deletions packages/atlas/src/providers/wallet/wallet.helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ export const getWalletsList = () => {
return [...supportedWallets, ...unknownWallets]
}

// eslint-disable-next-line @typescript-eslint/no-explicit-any
export const filterUnsupportedAccounts = (account: any) => account.type === 'sr25519'

export class UnknownWallet extends BaseDotsamaWallet {
extensionName: string
title: string
Expand Down
9 changes: 5 additions & 4 deletions packages/atlas/src/providers/wallet/wallet.provider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { formatJoystreamAddress } from '@/utils/address'
import { SentryLogger } from '@/utils/logs'
import { retryWalletPromise } from '@/utils/misc'

import { getWalletsList } from './wallet.helpers'
import { filterUnsupportedAccounts, getWalletsList } from './wallet.helpers'

const WalletContext = createContext<undefined | WalletContextValue>(undefined)
WalletContext.displayName = 'WalletContext'
Expand All @@ -29,8 +29,7 @@ export const WalletProvider: FC<PropsWithChildren> = ({ children }) => {

const setWalletAccounts = useCallback(
async (accounts: WalletAccount[]) => {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
const polkadotAccounts = accounts.filter((account: any) => account.type === 'sr25519')
const polkadotAccounts = accounts.filter(filterUnsupportedAccounts)

const mappedAccounts = polkadotAccounts.map((account) => {
return {
Expand Down Expand Up @@ -59,12 +58,14 @@ export const WalletProvider: FC<PropsWithChildren> = ({ children }) => {
// taken from https://github.com/TalismanSociety/talisman-connect/blob/47cfefee9f1333326c0605c159d6ee8ebfba3e84/libs/wallets/src/lib/base-dotsama-wallet/index.ts#L98-L107
// should be part of future talisman-connect release
const accounts = await selectedWallet.extension.accounts.get()

const accountsWithWallet = accounts
.filter(filterUnsupportedAccounts)
// eslint-disable-next-line @typescript-eslint/no-explicit-any
.map((account: any) => {
return {
...account,
address: account.address,
address: formatJoystreamAddress(account.address),
source: selectedWallet.extension?.name as string,
wallet: selectedWallet,
signer: selectedWallet.extension?.signer,
Expand Down

0 comments on commit 965e6f5

Please sign in to comment.