From cf3f366431e8d2857ea574a129b28ef9d053ca76 Mon Sep 17 00:00:00 2001 From: Victor Kirov Date: Thu, 1 Feb 2024 16:23:44 +0200 Subject: [PATCH 1/8] Option to select xverse as default browser wallet in settings (#774) * Add new setting for prioritising Xverse * default to false priority on storage failure * Use chrome storage util * Fix chrome storage types * fix storage default value --- src/app/hooks/useChromeLocalStorage.ts | 23 +++++++++++++++++++++++ src/app/hooks/useSeedVault.ts | 4 ++-- src/app/screens/settings/index.tsx | 22 ++++++++++++++++++++-- src/app/utils/chromeLocalStorage.ts | 13 +++++++++++++ src/app/utils/chromeStorage.ts | 12 ++++++------ src/content-scripts/content-script.ts | 22 +++++++++++++++++----- src/inpage/index.ts | 11 +++++++++-- src/locales/en.json | 4 +++- 8 files changed, 93 insertions(+), 18 deletions(-) create mode 100644 src/app/hooks/useChromeLocalStorage.ts create mode 100644 src/app/utils/chromeLocalStorage.ts diff --git a/src/app/hooks/useChromeLocalStorage.ts b/src/app/hooks/useChromeLocalStorage.ts new file mode 100644 index 000000000..b507a0cba --- /dev/null +++ b/src/app/hooks/useChromeLocalStorage.ts @@ -0,0 +1,23 @@ +import { chromeLocalStorage } from '@utils/chromeStorage'; +import { useEffect, useState } from 'react'; + +export const useChromeLocalStorage = (key: string, defaultValue?: T) => { + const [value, setValueState] = useState(undefined); + + useEffect(() => { + setValueState(undefined); + chromeLocalStorage.getItem(key).then((result) => { + const newValue = result === undefined ? defaultValue : result; + setValueState(newValue); + }); + }, [key]); + + const setValue = (newValue: T) => { + chromeLocalStorage.setItem(key, newValue); + setValueState(newValue); + }; + + return [value, setValue] as const; +}; + +export default useChromeLocalStorage; diff --git a/src/app/hooks/useSeedVault.ts b/src/app/hooks/useSeedVault.ts index cdc58e8d3..299f1c5ba 100644 --- a/src/app/hooks/useSeedVault.ts +++ b/src/app/hooks/useSeedVault.ts @@ -20,13 +20,13 @@ const cryptoUtilsAdapter: CryptoUtilsAdapter = { }; const secureStorageAdapter: StorageAdapter = { - get: async (key: string) => chromeSessionStorage.getItem(key), + get: async (key: string) => chromeSessionStorage.getItem(key, null), set: async (key: string, value: string) => chromeSessionStorage.setItem(key, value), remove: async (key: string) => chromeSessionStorage.removeItem(key), }; const commonStorageAdapter: StorageAdapter = { - get: async (key: string) => chromeLocalStorage.getItem(key), + get: async (key: string) => chromeLocalStorage.getItem(key, null), set: async (key: string, value: string) => chromeLocalStorage.setItem(key, value), remove: async (key: string) => chromeLocalStorage.removeItem(key), }; diff --git a/src/app/screens/settings/index.tsx b/src/app/screens/settings/index.tsx index cdf5b42f8..0d0e02e39 100644 --- a/src/app/screens/settings/index.tsx +++ b/src/app/screens/settings/index.tsx @@ -3,6 +3,7 @@ import ArrowIcon from '@assets/img/settings/arrow.svg'; import XverseLogo from '@assets/img/settings/logo.svg'; import PasswordInput from '@components/passwordInput'; import BottomBar from '@components/tabBar'; +import useChromeLocalStorage from '@hooks/useChromeLocalStorage'; import useSeedVault from '@hooks/useSeedVault'; import useWalletReducer from '@hooks/useWalletReducer'; import useWalletSelector from '@hooks/useWalletSelector'; @@ -11,6 +12,7 @@ import { ChangeActivateRareSatsAction, ChangeActivateRBFAction, } from '@stores/wallet/actions/actionCreators'; +import { chromeLocalStorageKeys } from '@utils/chromeLocalStorage'; import { PRIVACY_POLICY_LINK, SUPPORT_LINK, TERMS_LINK } from '@utils/constants'; import { isInOptions, isLedgerAccount } from '@utils/helper'; import { useState } from 'react'; @@ -67,6 +69,10 @@ function Setting() { hasActivatedRBFKey, selectedAccount, } = useWalletSelector(); + const [isPriorityWallet, setIsPriorityWallet] = useChromeLocalStorage( + chromeLocalStorageKeys.isPriorityWallet, + true, + ); const navigate = useNavigate(); const dispatch = useDispatch(); const { resetWallet } = useWalletReducer(); @@ -100,6 +106,10 @@ function Setting() { navigate('/backup-wallet'); }; + const switchIsPriorityWallet = () => { + setIsPriorityWallet(!isPriorityWallet); + }; + const switchActivateOrdinalState = () => { dispatch(ChangeActivateOrdinalsAction(!hasActivatedOrdinalsKey)); // disable rare sats if ordinal is disabled @@ -202,6 +212,7 @@ function Setting() { onClick={openChangeNetworkScreen} textDetail={network.type} /> + + - - + { + const isPriorityWallet = await chromeLocalStorage.getItem( + chromeLocalStorageKeys.isPriorityWallet, + ); + + return isPriorityWallet ?? true; +} diff --git a/src/app/utils/chromeStorage.ts b/src/app/utils/chromeStorage.ts index 44d4527a0..9b1d8958a 100644 --- a/src/app/utils/chromeStorage.ts +++ b/src/app/utils/chromeStorage.ts @@ -19,35 +19,35 @@ class ChromeStorage { return runtimeMap.get(this).lastError; } - setItem(key: string, item: any): Promise { + setItem(key: string, item: any): Promise { return new Promise((resolve, reject) => { this.getDriver().set({ [key]: item }, () => { if (this.hasError()) { return reject(this.getError()); } - return resolve(true); + return resolve(); }); }); } - getItem(key: string): Promise { + getItem(key: string, defaultValue?: D): Promise { return new Promise((resolve, reject) => { this.getDriver().get(key, (response: any) => { if (this.hasError()) { return reject(this.getError()); } - return resolve(response[key]); + return resolve(response[key] ?? defaultValue); }); }); } - removeItem(key: string): Promise { + removeItem(key: string): Promise { return new Promise((resolve, reject) => { this.getDriver().remove(key, () => { if (this.hasError()) { return reject(this.getError()); } - return resolve(true); + return resolve(); }); }); } diff --git a/src/content-scripts/content-script.ts b/src/content-scripts/content-script.ts index 005fde8d3..50e3081eb 100644 --- a/src/content-scripts/content-script.ts +++ b/src/content-scripts/content-script.ts @@ -22,6 +22,7 @@ import { } from '@common/types/message-types'; import getEventSourceWindow from '@common/utils/get-event-source-window'; import RequestsRoutes from '@common/utils/route-urls'; +import { getIsPriorityWallet } from '@utils/chromeLocalStorage'; // Legacy messaging to work with older versions of Connect window.addEventListener('message', (event) => { @@ -203,8 +204,19 @@ document.addEventListener(DomEventName.createRepeatInscriptionsRequest, (( }); }) as EventListener); -// Inject inpage script (Stacks Provider) -const inpage = document.createElement('script'); -inpage.src = chrome.runtime.getURL('inpage.js'); -inpage.id = 'xverse-wallet-provider'; -document.body.appendChild(inpage); +// Inject in-page script (Stacks and Bitcoin Providers) +const injectInPageScript = (isPriority) => { + const inpage = document.createElement('script'); + inpage.src = chrome.runtime.getURL('inpage.js'); + inpage.id = 'xverse-wallet-provider'; + inpage.setAttribute('data-is-priority', isPriority ? 'true' : ''); + document.body.appendChild(inpage); +}; + +getIsPriorityWallet() + .then((isPriorityWallet) => { + injectInPageScript(isPriorityWallet); + }) + .catch(() => { + injectInPageScript(false); + }); diff --git a/src/inpage/index.ts b/src/inpage/index.ts index b2cf92e96..e96afeba3 100644 --- a/src/inpage/index.ts +++ b/src/inpage/index.ts @@ -10,8 +10,15 @@ declare global { } } // we inject these in case implementors call the default providers -window.StacksProvider = StacksMethodsProvider as StacksProvider; -window.BitcoinProvider = SatsMethodsProvider as BitcoinProvider; +if (document.currentScript?.dataset.isPriority) { + Object.defineProperties(window, { + StacksProvider: { get: () => StacksMethodsProvider, set: () => {} }, + BitcoinProvider: { get: () => SatsMethodsProvider, set: () => {} }, + }); +} else { + window.StacksProvider = StacksMethodsProvider as StacksProvider; + window.BitcoinProvider = SatsMethodsProvider; +} // We also inject the providers in an Xverse object in order to have them exclusively available for Xverse wallet // and not clash with providers from other wallets diff --git a/src/locales/en.json b/src/locales/en.json index 5e63081bf..bc0315cef 100644 --- a/src/locales/en.json +++ b/src/locales/en.json @@ -761,7 +761,9 @@ "ENABLE_RARE_SATS_DETAIL": "Automatically scan and display rare sats in your Ordinals wallet.", "ENABLE_SPEED_UP_TRANSACTIONS": "Enable speed up transactions", "ENABLE_SPEED_UP_TRANSACTIONS_DETAIL": "Allows you to speed up unconfirmed transactions by paying a higher fee.", - "ADVANCED": "Advanced" + "ADVANCED": "Advanced", + "XVERSE_DEFAULT": "Use Xverse as default wallet", + "XVERSE_DEFAULT_DESCRIPTION": "Allow apps to prioritize Xverse when looking for a wallet with which to connect." }, "OPTIONS_DIALOG": { "SWITCH_ACCOUNT": "Switch Account", From 96792e970b594c5ed41a475190da40e7f6d9fe89 Mon Sep 17 00:00:00 2001 From: Victor Kirov Date: Fri, 2 Feb 2024 12:41:37 +0200 Subject: [PATCH 2/8] Ensure translations are not applied to seed phrases (#785) * Ensure translations are not applied to seed phrases * Ensure the word button in confirm words onboarding steps aren't translated --- src/app/components/seedPhraseView/index.tsx | 1 - src/app/components/seedPhraseView/word.tsx | 4 +++- src/app/screens/backupWalletSteps/verifySeed.tsx | 2 +- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/app/components/seedPhraseView/index.tsx b/src/app/components/seedPhraseView/index.tsx index 814ca4073..d1bd21420 100644 --- a/src/app/components/seedPhraseView/index.tsx +++ b/src/app/components/seedPhraseView/index.tsx @@ -1,5 +1,4 @@ import Eye from '@assets/img/createPassword/Eye.svg'; -import { useMemo } from 'react'; import styled from 'styled-components'; import SeedPhraseWord from './word'; diff --git a/src/app/components/seedPhraseView/word.tsx b/src/app/components/seedPhraseView/word.tsx index 7c100c3da..8024485ca 100644 --- a/src/app/components/seedPhraseView/word.tsx +++ b/src/app/components/seedPhraseView/word.tsx @@ -27,7 +27,9 @@ function SeedPhraseWord({ index, word }: Props) { return ( {index + 1}. - {word} + + {word} + ); } diff --git a/src/app/screens/backupWalletSteps/verifySeed.tsx b/src/app/screens/backupWalletSteps/verifySeed.tsx index 1f0ee0be2..e06eb8cd1 100644 --- a/src/app/screens/backupWalletSteps/verifySeed.tsx +++ b/src/app/screens/backupWalletSteps/verifySeed.tsx @@ -143,7 +143,7 @@ export default function VerifySeed({ {quiz.words.map((word) => ( - + {word} ))} From 42171ab5128fb4d9d1e0d9ca49d47de897f2d6ff Mon Sep 17 00:00:00 2001 From: Mahmoud Aboelenein Date: Fri, 2 Feb 2024 15:35:34 +0200 Subject: [PATCH 3/8] replace deprecated util with core (#786) --- package-lock.json | 14 +++--- package.json | 2 +- .../connect/btcSelectAddressScreen/helper.ts | 48 ------------------- .../connect/btcSelectAddressScreen/index.tsx | 2 +- 4 files changed, 9 insertions(+), 57 deletions(-) delete mode 100644 src/app/screens/connect/btcSelectAddressScreen/helper.ts diff --git a/package-lock.json b/package-lock.json index 08c07d996..9168ab03e 100644 --- a/package-lock.json +++ b/package-lock.json @@ -12,7 +12,7 @@ "@phosphor-icons/react": "^2.0.10", "@react-spring/web": "^9.6.1", "@scure/btc-signer": "1.2.1", - "@secretkeylabs/xverse-core": "9.1.2", + "@secretkeylabs/xverse-core": "9.2.0", "@stacks/connect": "7.4.1", "@stacks/stacks-blockchain-api-types": "6.1.1", "@stacks/transactions": "6.9.0", @@ -1735,9 +1735,9 @@ } }, "node_modules/@secretkeylabs/xverse-core": { - "version": "9.1.2", - "resolved": "https://npm.pkg.github.com/download/@secretkeylabs/xverse-core/9.1.2/fdd0d4e6f7a2fed163453b17f5e402f7673e323b", - "integrity": "sha512-PtkrO22QQvbt96YCmxJwQqrNtNT9z4oHQam2TqLpFK+dyWL+mB8TI93NWbBxDNxf8vdEjNPtM6NdFU2WwCYe7A==", + "version": "9.2.0", + "resolved": "https://npm.pkg.github.com/download/@secretkeylabs/xverse-core/9.2.0/f2254d462c467747c31d65f38b80059870bd475e", + "integrity": "sha512-wr8LXWE34AOC6PFmcDf/GmqPeej90GlkUuLJBBhQ6A2aFShDkR53A76hT6Uw3fwSeeZRMTa7LRcfhVi6qWEjmg==", "license": "ISC", "dependencies": { "@bitcoinerlab/secp256k1": "^1.0.2", @@ -15448,9 +15448,9 @@ } }, "@secretkeylabs/xverse-core": { - "version": "9.1.2", - "resolved": "https://npm.pkg.github.com/download/@secretkeylabs/xverse-core/9.1.2/fdd0d4e6f7a2fed163453b17f5e402f7673e323b", - "integrity": "sha512-PtkrO22QQvbt96YCmxJwQqrNtNT9z4oHQam2TqLpFK+dyWL+mB8TI93NWbBxDNxf8vdEjNPtM6NdFU2WwCYe7A==", + "version": "9.2.0", + "resolved": "https://npm.pkg.github.com/download/@secretkeylabs/xverse-core/9.2.0/f2254d462c467747c31d65f38b80059870bd475e", + "integrity": "sha512-wr8LXWE34AOC6PFmcDf/GmqPeej90GlkUuLJBBhQ6A2aFShDkR53A76hT6Uw3fwSeeZRMTa7LRcfhVi6qWEjmg==", "requires": { "@bitcoinerlab/secp256k1": "^1.0.2", "@noble/curves": "^1.2.0", diff --git a/package.json b/package.json index 26b908ac1..97e5a736c 100644 --- a/package.json +++ b/package.json @@ -11,7 +11,7 @@ "@phosphor-icons/react": "^2.0.10", "@react-spring/web": "^9.6.1", "@scure/btc-signer": "1.2.1", - "@secretkeylabs/xverse-core": "9.1.2", + "@secretkeylabs/xverse-core": "9.2.0", "@stacks/connect": "7.4.1", "@stacks/stacks-blockchain-api-types": "6.1.1", "@stacks/transactions": "6.9.0", diff --git a/src/app/screens/connect/btcSelectAddressScreen/helper.ts b/src/app/screens/connect/btcSelectAddressScreen/helper.ts deleted file mode 100644 index 1bf47cc69..000000000 --- a/src/app/screens/connect/btcSelectAddressScreen/helper.ts +++ /dev/null @@ -1,48 +0,0 @@ -export interface WebManifest { - icons?: { src: string; sizes?: string }[]; -} - -export async function getAppIconFromWebManifest(url: string): Promise { - try { - // Validate URL format - if (!/^https?:\/\/.*/.test(url)) { - throw new Error('Invalid URL format'); - } - - // Fetch the web manifest - const response = await fetch(`${url}/manifest.json`); - - // Check for successful response - if (!response.ok) { - throw new Error(`Failed to fetch web manifest. Status: ${response.status}`); - } - - const manifest: WebManifest = await response.json(); - // Ensure the manifest contains the 'icons' property - if (!manifest.icons || !Array.isArray(manifest.icons)) { - throw new Error('Web manifest is missing the icons property'); - } - - // Extract the app icons' URLs - const icons = manifest.icons.filter((icon) => icon.sizes === '48x48'); - - return `${url}${icons[0].src}`; - } catch (error: any) { - if (error.message.includes('Failed to fetch web manifest')) { - const response = await fetch(`${url}/manifest.webmanifest`); - if (!response.ok) { - return ''; - } - const manifest: WebManifest = await response.json(); - // Ensure the manifest contains the 'icons' property - if (!manifest.icons || !Array.isArray(manifest.icons)) { - throw new Error('Web manifest is missing the icons property'); - } - - // Extract the app icons' URLs - const icons = manifest.icons.filter((icon) => icon.sizes === '48x48'); - return `${url}/${icons[0].src}`; - } - return ''; - } -} diff --git a/src/app/screens/connect/btcSelectAddressScreen/index.tsx b/src/app/screens/connect/btcSelectAddressScreen/index.tsx index 39858e68a..7280819f0 100644 --- a/src/app/screens/connect/btcSelectAddressScreen/index.tsx +++ b/src/app/screens/connect/btcSelectAddressScreen/index.tsx @@ -6,6 +6,7 @@ import useBtcAddressRequest from '@hooks/useBtcAddressRequest'; import useWalletSelector from '@hooks/useWalletSelector'; import { animated, useTransition } from '@react-spring/web'; import SelectAccount from '@screens/connect/selectAccount'; +import { getAppIconFromWebManifest } from '@secretkeylabs/xverse-core'; import { StickyHorizontalSplitButtonContainer } from '@ui-library/common.styled'; import { useCallback, useEffect, useMemo, useState } from 'react'; import { useTranslation } from 'react-i18next'; @@ -15,7 +16,6 @@ import { AddressPurpose } from 'sats-connect'; import styled from 'styled-components'; import AddressPurposeBox from '../addressPurposeBox'; import PermissionsList from '../permissionsList'; -import { getAppIconFromWebManifest } from './helper'; const OuterContainer = styled.div((props) => ({ display: 'flex', From aa3a37261030e481ce871e777116e3bb3df1a42a Mon Sep 17 00:00:00 2001 From: Victor Kirov Date: Fri, 2 Feb 2024 15:37:37 +0200 Subject: [PATCH 4/8] Remove fee subtraction from the You Will Transfer total (#787) --- src/app/components/confirmBtcTransaction/transactionSummary.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/app/components/confirmBtcTransaction/transactionSummary.tsx b/src/app/components/confirmBtcTransaction/transactionSummary.tsx index 013071812..ccb5d6014 100644 --- a/src/app/components/confirmBtcTransaction/transactionSummary.tsx +++ b/src/app/components/confirmBtcTransaction/transactionSummary.tsx @@ -116,7 +116,7 @@ function TransactionSummary({ inputs={inputs} isPartialTransaction={isPartialTransaction} onShowInscription={setInscriptionToShow} - netAmount={(netAmount + (feeOutput?.amount ?? 0)) * -1} + netAmount={-netAmount} /> Date: Fri, 2 Feb 2024 15:45:13 +0200 Subject: [PATCH 5/8] update ledger message signing util (#784) * update ledger message signing util * update core version --- package-lock.json | 14 +++++++------- package.json | 2 +- src/app/screens/signatureRequest/index.tsx | 1 + src/app/utils/ledger.ts | 3 +++ 4 files changed, 12 insertions(+), 8 deletions(-) diff --git a/package-lock.json b/package-lock.json index 9168ab03e..816ab1258 100644 --- a/package-lock.json +++ b/package-lock.json @@ -12,7 +12,7 @@ "@phosphor-icons/react": "^2.0.10", "@react-spring/web": "^9.6.1", "@scure/btc-signer": "1.2.1", - "@secretkeylabs/xverse-core": "9.2.0", + "@secretkeylabs/xverse-core": "10.0.0", "@stacks/connect": "7.4.1", "@stacks/stacks-blockchain-api-types": "6.1.1", "@stacks/transactions": "6.9.0", @@ -1735,9 +1735,9 @@ } }, "node_modules/@secretkeylabs/xverse-core": { - "version": "9.2.0", - "resolved": "https://npm.pkg.github.com/download/@secretkeylabs/xverse-core/9.2.0/f2254d462c467747c31d65f38b80059870bd475e", - "integrity": "sha512-wr8LXWE34AOC6PFmcDf/GmqPeej90GlkUuLJBBhQ6A2aFShDkR53A76hT6Uw3fwSeeZRMTa7LRcfhVi6qWEjmg==", + "version": "10.0.0", + "resolved": "https://npm.pkg.github.com/download/@secretkeylabs/xverse-core/10.0.0/6daaebbed79ce92bd3435f5006f67021dffec8d7", + "integrity": "sha512-KrWWd+iQ/KhouA1VEVMBkM5E2D64I5ZztUsFag9lJZXAJVV39b+jbJYIm1leb9kHgl0hlFED7SHB/wSh7Yj6Kw==", "license": "ISC", "dependencies": { "@bitcoinerlab/secp256k1": "^1.0.2", @@ -15448,9 +15448,9 @@ } }, "@secretkeylabs/xverse-core": { - "version": "9.2.0", - "resolved": "https://npm.pkg.github.com/download/@secretkeylabs/xverse-core/9.2.0/f2254d462c467747c31d65f38b80059870bd475e", - "integrity": "sha512-wr8LXWE34AOC6PFmcDf/GmqPeej90GlkUuLJBBhQ6A2aFShDkR53A76hT6Uw3fwSeeZRMTa7LRcfhVi6qWEjmg==", + "version": "10.0.0", + "resolved": "https://npm.pkg.github.com/download/@secretkeylabs/xverse-core/10.0.0/6daaebbed79ce92bd3435f5006f67021dffec8d7", + "integrity": "sha512-KrWWd+iQ/KhouA1VEVMBkM5E2D64I5ZztUsFag9lJZXAJVV39b+jbJYIm1leb9kHgl0hlFED7SHB/wSh7Yj6Kw==", "requires": { "@bitcoinerlab/secp256k1": "^1.0.2", "@noble/curves": "^1.2.0", diff --git a/package.json b/package.json index 97e5a736c..1ae93d969 100644 --- a/package.json +++ b/package.json @@ -11,7 +11,7 @@ "@phosphor-icons/react": "^2.0.10", "@react-spring/web": "^9.6.1", "@scure/btc-signer": "1.2.1", - "@secretkeylabs/xverse-core": "9.2.0", + "@secretkeylabs/xverse-core": "10.0.0", "@stacks/connect": "7.4.1", "@stacks/stacks-blockchain-api-types": "6.1.1", "@stacks/transactions": "6.9.0", diff --git a/src/app/screens/signatureRequest/index.tsx b/src/app/screens/signatureRequest/index.tsx index 9f21b1b6e..455d04e95 100644 --- a/src/app/screens/signatureRequest/index.tsx +++ b/src/app/screens/signatureRequest/index.tsx @@ -271,6 +271,7 @@ function SignatureRequest(): JSX.Element { const signature = await handleBip322LedgerMessageSigning({ transport, addressIndex: selectedAccount.deviceAccountIndex, + address: payload.address, networkType: network.type, message: payload.message, }); diff --git a/src/app/utils/ledger.ts b/src/app/utils/ledger.ts index 3454b6f7d..89b0f43c3 100644 --- a/src/app/utils/ledger.ts +++ b/src/app/utils/ledger.ts @@ -3,11 +3,13 @@ import { NetworkType, signSimpleBip322Message, Transport } from '@secretkeylabs/ export const handleBip322LedgerMessageSigning = async ({ transport, addressIndex, + address, networkType, message, }: { transport: Transport; addressIndex?: number; + address: string; networkType: NetworkType; message: string; }) => { @@ -19,6 +21,7 @@ export const handleBip322LedgerMessageSigning = async ({ transport, networkType, addressIndex, + address, message, }); From 845ea6da313e807d55ad2bd86e0d15591de7d47f Mon Sep 17 00:00:00 2001 From: GitHub Actions Bot <> Date: Fri, 2 Feb 2024 13:45:59 +0000 Subject: [PATCH 6/8] release: v0.29.1 --- package-lock.json | 4 ++-- package.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/package-lock.json b/package-lock.json index 816ab1258..5b0185240 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "xverse-web-extension", - "version": "0.29.0", + "version": "0.29.1", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "xverse-web-extension", - "version": "0.29.0", + "version": "0.29.1", "dependencies": { "@ledgerhq/hw-transport-webusb": "^6.27.13", "@phosphor-icons/react": "^2.0.10", diff --git a/package.json b/package.json index 1ae93d969..113637260 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "xverse-web-extension", "description": "A Bitcoin wallet for Web3", - "version": "0.29.0", + "version": "0.29.1", "private": true, "engines": { "node": "^18.18.2" From 23474bd9c1874dcf6dbaab2047e3c087848db0a1 Mon Sep 17 00:00:00 2001 From: Mahmoud Aboelenein Date: Fri, 2 Feb 2024 16:24:10 +0200 Subject: [PATCH 7/8] default to empty string on icon fetching failure (#790) --- .../connect/btcSelectAddressScreen/index.tsx | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/app/screens/connect/btcSelectAddressScreen/index.tsx b/src/app/screens/connect/btcSelectAddressScreen/index.tsx index 7280819f0..baa32b9c6 100644 --- a/src/app/screens/connect/btcSelectAddressScreen/index.tsx +++ b/src/app/screens/connect/btcSelectAddressScreen/index.tsx @@ -144,10 +144,15 @@ function BtcSelectAddressScreen() { (async () => { if (origin !== '') { setIsLoadingIcon(true); - getAppIconFromWebManifest(origin).then((appIcons) => { - setAppIcon(appIcons); - setIsLoadingIcon(false); - }); + getAppIconFromWebManifest(origin) + .then((appIcons) => { + setAppIcon(appIcons); + setIsLoadingIcon(false); + }) + .catch(() => { + setIsLoadingIcon(false); + setAppIcon(''); + }); } })(); From 286ac3340227220d5c9cd7181106c62a9bf899ed Mon Sep 17 00:00:00 2001 From: Victor Kirov Date: Wed, 7 Feb 2024 13:39:01 +0200 Subject: [PATCH 8/8] Fix in page provider injection (#794) * changes (#792) * Fix in page provider injection --------- Co-authored-by: Terence Ng --- .../nftDashboard/rareSatsTabGridItem.tsx | 8 ++--- src/app/screens/ordinalDetail/index.tsx | 2 +- src/inpage/index.ts | 30 ++++++++++++------- src/locales/en.json | 2 +- 4 files changed, 25 insertions(+), 17 deletions(-) diff --git a/src/app/screens/nftDashboard/rareSatsTabGridItem.tsx b/src/app/screens/nftDashboard/rareSatsTabGridItem.tsx index e33b36bba..8fdb667a7 100644 --- a/src/app/screens/nftDashboard/rareSatsTabGridItem.tsx +++ b/src/app/screens/nftDashboard/rareSatsTabGridItem.tsx @@ -85,8 +85,8 @@ function RareSatsTabGridItem({ bundle, maxItems }: { bundle: Bundle; maxItems: n return icons.map((sats, index) => ( - {sats.map((sattribute, indexSatributes) => { - if (sattribute === 'ellipsis') { + {sats.map((satribute, indexSatributes) => { + if (satribute === 'ellipsis') { return ( +{totalTiles - totalTilesDisplayed} @@ -105,7 +105,7 @@ function RareSatsTabGridItem({ bundle, maxItems }: { bundle: Bundle; maxItems: n } return ( // eslint-disable-next-line react/no-array-index-key - + ); })} diff --git a/src/app/screens/ordinalDetail/index.tsx b/src/app/screens/ordinalDetail/index.tsx index ac8e6aca8..0003b0b71 100644 --- a/src/app/screens/ordinalDetail/index.tsx +++ b/src/app/screens/ordinalDetail/index.tsx @@ -607,7 +607,7 @@ function OrdinalDetailScreen() { const stributesBadges = showSatributes && ( - {commonT('SATTRIBUTES')} + {commonT('SATRIBUTES')} {ordinalSatributes.map((satribute, index) => { diff --git a/src/inpage/index.ts b/src/inpage/index.ts index e96afeba3..3e4fe91ba 100644 --- a/src/inpage/index.ts +++ b/src/inpage/index.ts @@ -9,21 +9,29 @@ declare global { StacksProvider: StacksProvider; } } -// we inject these in case implementors call the default providers -if (document.currentScript?.dataset.isPriority) { - Object.defineProperties(window, { - StacksProvider: { get: () => StacksMethodsProvider, set: () => {} }, - BitcoinProvider: { get: () => SatsMethodsProvider, set: () => {} }, - }); -} else { - window.StacksProvider = StacksMethodsProvider as StacksProvider; - window.BitcoinProvider = SatsMethodsProvider; -} -// We also inject the providers in an Xverse object in order to have them exclusively available for Xverse wallet +// We inject the providers in an Xverse object in order to have them exclusively available for Xverse wallet // and not clash with providers from other wallets window.XverseProviders = { // @ts-ignore StacksProvider: StacksMethodsProvider as StacksProvider, BitcoinProvider: SatsMethodsProvider as BitcoinProvider, }; + +// we inject these in case implementors call the default providers +try { + if (document.currentScript?.dataset.isPriority) { + Object.defineProperties(window, { + StacksProvider: { get: () => StacksMethodsProvider, set: () => {} }, + BitcoinProvider: { get: () => SatsMethodsProvider, set: () => {} }, + }); + } else { + window.StacksProvider = StacksMethodsProvider as StacksProvider; + window.BitcoinProvider = SatsMethodsProvider; + } +} catch (e) { + console.log( + 'Failed setting Xverse default providers. Another wallet may have already set them in an immutable way.', + ); + console.error(e); +} diff --git a/src/locales/en.json b/src/locales/en.json index bc0315cef..4a2ab382d 100644 --- a/src/locales/en.json +++ b/src/locales/en.json @@ -4,7 +4,7 @@ "SEND": "Send", "COMBO": "Combo", "SATS": "Sats", - "SATTRIBUTES": "Sattributes", + "SATRIBUTES": "Satributes", "INPUT": "Input", "SIZE": "Size", "BUNDLE": "Bundle"