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

Remove Polkadot JS Option In Iframe #448

Merged
merged 6 commits into from
Nov 6, 2023
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions integration/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,12 @@ function createUrl(
}

// to make the autocomplete still appears, but enables any string to be passed in
type KnownEvents = 'ready' | 'unread' | 'totalMessage' | (string & {})
type KnownEvents =
| 'ready'
| 'unread'
| 'totalMessage'
| 'isUpdatingConfig'
| (string & {})
export type GrillEventListener = (eventName: KnownEvents, value: string) => void
const grill = {
instances: {} as Record<
Expand Down Expand Up @@ -267,10 +272,10 @@ const grill = {
sendSetConfigMessage()
},

addUnreadCountListener(listener: GrillEventListener) {
addMessageListener(listener: GrillEventListener) {
this.eventListeners.push(listener)
},
removeUnreadCountListener(listener: GrillEventListener) {
removeMessageListener(listener: GrillEventListener) {
this.eventListeners = this.eventListeners.filter((l) => l !== listener)
},
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { useSendEvent } from '@/stores/analytics'
import { useMyAccount } from '@/stores/my-account'
import { cx } from '@/utils/class-names'
import { getCurrentUrlOrigin } from '@/utils/links'
import { isInMobileOrTablet } from '@/utils/window'
import { getIsInIframe, isInMobileOrTablet } from '@/utils/window'
import { getWallets, Wallet } from '@talismn/connect-wallets'
import Image from 'next/image'
import { FiDownload } from 'react-icons/fi'
Expand All @@ -20,12 +20,26 @@ export default function PolkadotConnectWalletContent({
const setPreferredWallet = useMyAccount((state) => state.setPreferredWallet)
const supportedWallets: Wallet[] = getWallets()

supportedWallets.sort((a, b) => {
return !a.installed && b.installed ? 1 : -1
const installedWallets: Wallet[] = []
const otherWallets: Wallet[] = []
supportedWallets.forEach((wallet) => {
// polkadot js doesn't inject its web3 object inside iframe
// issue link: https://github.com/polkadot-js/extension/issues/1274
const isPolkadotJsNotInstalledAndInIframe =
wallet.title.toLowerCase() === 'polkadot.js' &&
!wallet.installed &&
getIsInIframe()
if (isPolkadotJsNotInstalledAndInIframe) return

if (wallet.installed) installedWallets.push(wallet)
else otherWallets.push(wallet)
})
let hasInstalledWallet = false
let menus: MenuListProps['menus'] = supportedWallets.map((wallet: Wallet) => {
if (wallet.installed) hasInstalledWallet = true
let hasInstalledWallet = installedWallets.length

let menus: MenuListProps['menus'] = [
...installedWallets,
...otherWallets,
].map((wallet: Wallet) => {
return {
text: (
<div className='flex w-full items-center justify-between gap-4'>
Expand Down