From e38f6ab36e8e0c333571adeefbac3c57b00b7c8c Mon Sep 17 00:00:00 2001 From: kyranjamie Date: Fri, 5 Jul 2024 14:07:10 +0200 Subject: [PATCH] feat: add Leather to WBIP004 array, closes #5615 --- .../legacy-gaia-config-lookup.ts | 2 +- src/inpage/add-leather-to-providers.ts | 38 +++++++++++++++++++ src/inpage/inpage.ts | 4 ++ 3 files changed, 43 insertions(+), 1 deletion(-) create mode 100644 src/inpage/add-leather-to-providers.ts diff --git a/src/app/common/account-restoration/legacy-gaia-config-lookup.ts b/src/app/common/account-restoration/legacy-gaia-config-lookup.ts index cd905ce1730..5a88b21e5e9 100644 --- a/src/app/common/account-restoration/legacy-gaia-config-lookup.ts +++ b/src/app/common/account-restoration/legacy-gaia-config-lookup.ts @@ -7,7 +7,7 @@ import { import { gaiaUrl as gaiaHubUrl } from '@shared/constants'; -// This function repliactes behaviour wrapped in the `restoreWalletAccounts` +// This function replicates behaviour wrapped in the `restoreWalletAccounts` // method of wallet-sdk. It checks for BNS names on Gaia-persisted accounts, // resulting in a huge number of requests when called by a wallet with many // accounts. Here, we only care to find the number of accounts a user has diff --git a/src/inpage/add-leather-to-providers.ts b/src/inpage/add-leather-to-providers.ts new file mode 100644 index 00000000000..dfbaa5086fd --- /dev/null +++ b/src/inpage/add-leather-to-providers.ts @@ -0,0 +1,38 @@ +interface WalletProvider { + id: string; + name: string; + icon: string; + webUrl?: string; + chromeWebStoreUrl?: string; + mozillaAddOnsUrl?: string; + googlePlayStoreUrl?: string; + iOSAppStoreUrl?: string; + methods?: string[]; +} + +// https://wbips.netlify.app/wbips/WBIP004 +export function addLeatherToProviders() { + const win = window as unknown as Window & { btc_providers?: WalletProvider[] }; + + if (!win.btc_providers) win.btc_providers = []; + + win.btc_providers.push({ + id: 'LeatherProvider', + name: 'Leather', + icon: 'data:image/svg;base64,PHN2ZyB3aWR0aD0iMTI4IiBoZWlnaHQ9IjEyOCIgdmlld0JveD0iMCAwIDEyOCAxMjgiIGZpbGw9Im5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OCA2Mi44MjIgNTIuNzExNEM2Ny41OTAzIDM1LjczNzIgNzcuODI0NiAyMi41MDkgOTEuNDMxNiAyMi41MDlDOTkuMTA3NCAyMi41MDkgMTA1LjE1NSAyNy41NDI4IDEwNS4xNTUgMzYuNjczN0MxMDUuMTU1IDUxLjMwNjYgODYuMDgxOSA2My4yNDcxIDcxLjY2MDcgNjQuNDE3N0w2NS43Mjk1IDg1LjM3MjFDNzIuNDc0OCA5My4yMTUzIDkxLjE5OSAxMDAuODI0IDkxLjE5OSA3OS4yODQ4SDEwMi44MjlaIiBmaWxsPSIjRjdGNUYzIi8+Cjwvc3ZnPgo=', + + webUrl: 'https://leather.io', + + chromeWebStoreUrl: + 'https://chromewebstore.google.com/detail/leather/ldinpeekobnhjjdofggfgjlcehhmanlj', + + methods: [ + 'getAddresses', + 'signMessage', + 'sentTransfer', + 'signPsbt', + 'stx_signMessage', + 'stx_signTransaction', + ], + }); +} diff --git a/src/inpage/inpage.ts b/src/inpage/inpage.ts index 395155e586a..161504d40f2 100644 --- a/src/inpage/inpage.ts +++ b/src/inpage/inpage.ts @@ -22,8 +22,12 @@ import { } from '@shared/message-types'; import type { WalletMethodMap, WalletMethodNames, WalletResponses } from '@shared/rpc/rpc-methods'; +import { addLeatherToProviders } from './add-leather-to-providers'; + type CallableMethods = keyof typeof ExternalMethods; +addLeatherToProviders(); + interface ExtensionResponse { source: 'blockstack-extension'; method: CallableMethods;