Skip to content

Commit

Permalink
Fix in page provider injection (#794)
Browse files Browse the repository at this point in the history
* changes (#792)

* Fix in page provider injection

---------

Co-authored-by: Terence Ng <[email protected]>
  • Loading branch information
victorkirov and Terence Ng authored Feb 7, 2024
1 parent 23474bd commit 286ac33
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 17 deletions.
8 changes: 4 additions & 4 deletions src/app/screens/nftDashboard/rareSatsTabGridItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,8 @@ function RareSatsTabGridItem({ bundle, maxItems }: { bundle: Bundle; maxItems: n

return icons.map((sats, index) => (
<Range key={`${bundle.satRanges[index].block}-${bundle.satRanges[index].offset}`}>
{sats.map((sattribute, indexSatributes) => {
if (sattribute === 'ellipsis') {
{sats.map((satribute, indexSatributes) => {
if (satribute === 'ellipsis') {
return (
<DotsThree
key={`${totalTilesDisplayed}-ellipsis`}
Expand All @@ -96,7 +96,7 @@ function RareSatsTabGridItem({ bundle, maxItems }: { bundle: Bundle; maxItems: n
);
}

if (sattribute === '+X') {
if (satribute === '+X') {
return (
<TileText key={`${totalTilesDisplayed}-+X`} typography="body_m">
+{totalTiles - totalTilesDisplayed}
Expand All @@ -105,7 +105,7 @@ function RareSatsTabGridItem({ bundle, maxItems }: { bundle: Bundle; maxItems: n
}
return (
// eslint-disable-next-line react/no-array-index-key
<RareSatIcon key={`${sattribute}-${indexSatributes}`} type={sattribute} size={24} />
<RareSatIcon key={`${satribute}-${indexSatributes}`} type={satribute} size={24} />
);
})}
</Range>
Expand Down
2 changes: 1 addition & 1 deletion src/app/screens/ordinalDetail/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -607,7 +607,7 @@ function OrdinalDetailScreen() {
const stributesBadges = showSatributes && (
<SatributesBadgeContainer isGallery={isGalleryOpen}>
<StyledP typography="body_medium_m" color="white_400">
{commonT('SATTRIBUTES')}
{commonT('SATRIBUTES')}
</StyledP>
<SatributesBadges isGallery={isGalleryOpen}>
{ordinalSatributes.map((satribute, index) => {
Expand Down
30 changes: 19 additions & 11 deletions src/inpage/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
2 changes: 1 addition & 1 deletion src/locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"SEND": "Send",
"COMBO": "Combo",
"SATS": "Sats",
"SATTRIBUTES": "Sattributes",
"SATRIBUTES": "Satributes",
"INPUT": "Input",
"SIZE": "Size",
"BUNDLE": "Bundle"
Expand Down

0 comments on commit 286ac33

Please sign in to comment.