diff --git a/packages/bitcoin-wallet-snap/CHANGELOG.md b/packages/bitcoin-wallet-snap/CHANGELOG.md
index a7d346814..2262ce498 100644
--- a/packages/bitcoin-wallet-snap/CHANGELOG.md
+++ b/packages/bitcoin-wallet-snap/CHANGELOG.md
@@ -9,6 +9,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Changed
+- Never display an opaque request origin: the PSBT-signing and send confirmations now show a hostname (or `MetaMask`) and hide the row otherwise, instead of printing the raw origin, which for remote transports is a connection id
+- Stop labelling the literal `wallet-connect` origin as "WalletConnect"; the clients now pass a per-session channel id instead
- **BREAKING** Bump `@metamask/keyring-api` from `^23.7.0` to `^24.1.0` ([#214](https://github.com/MetaMask/internal-snaps/pull/214))
- **BREAKING** Bump `@metamask/keyring-snap-sdk` from `^9.2.1` to `^10.0.0` ([#214](https://github.com/MetaMask/internal-snaps/pull/214))
- **BREAKING** Bump `@metamask/snaps-sdk` from `^11.2.0` to `^12.0.1` ([#214](https://github.com/MetaMask/internal-snaps/pull/214))
diff --git a/packages/bitcoin-wallet-snap/src/infra/jsx/confirmations/SignPsbtConfirmationView.tsx b/packages/bitcoin-wallet-snap/src/infra/jsx/confirmations/SignPsbtConfirmationView.tsx
index 31d59ec5d..c2025ff6e 100644
--- a/packages/bitcoin-wallet-snap/src/infra/jsx/confirmations/SignPsbtConfirmationView.tsx
+++ b/packages/bitcoin-wallet-snap/src/infra/jsx/confirmations/SignPsbtConfirmationView.tsx
@@ -18,6 +18,7 @@ import {
displayCaip10,
displayExchangeAmount,
displayNetwork,
+ displayOrigin,
translate,
} from '../format';
@@ -144,7 +145,7 @@ export const SignPsbtConfirmationView: SnapComponent<
{t('confirmation.requestOrigin')}
- {origin ?? 'MetaMask'}
+ {displayOrigin(origin ?? 'metamask')}
{null}
diff --git a/packages/bitcoin-wallet-snap/src/infra/jsx/format.test.ts b/packages/bitcoin-wallet-snap/src/infra/jsx/format.test.ts
index 6a8c225c2..39e7b170f 100644
--- a/packages/bitcoin-wallet-snap/src/infra/jsx/format.test.ts
+++ b/packages/bitcoin-wallet-snap/src/infra/jsx/format.test.ts
@@ -12,13 +12,12 @@ describe('displayOrigin', () => {
expect(displayOrigin('metamask')).toBe('MetaMask');
});
- it('returns the known label for the "wallet-connect" origin', () => {
- expect(displayOrigin('wallet-connect')).toBe('WalletConnect');
+ it('matches the internal origin case-insensitively', () => {
+ expect(displayOrigin('MetaMask')).toBe('MetaMask');
});
- it('matches known origins case-insensitively', () => {
- expect(displayOrigin('MetaMask')).toBe('MetaMask');
- expect(displayOrigin('Wallet-Connect')).toBe('WalletConnect');
+ it('returns an empty string for the legacy "wallet-connect" origin', () => {
+ expect(displayOrigin('wallet-connect')).toBe('');
});
it('returns the hostname for a valid https URL', () => {
diff --git a/packages/bitcoin-wallet-snap/src/infra/jsx/format.ts b/packages/bitcoin-wallet-snap/src/infra/jsx/format.ts
index 8e54922fb..263d7208a 100644
--- a/packages/bitcoin-wallet-snap/src/infra/jsx/format.ts
+++ b/packages/bitcoin-wallet-snap/src/infra/jsx/format.ts
@@ -1,5 +1,6 @@
import type { Network } from '@metamask/bitcoindevkit';
import { Amount, BdkErrorCode } from '@metamask/bitcoindevkit';
+import { resolveOrigin } from '@metamask/snap-networks-utils';
import type { CaipAccountId } from '@metamask/snaps-sdk';
import type { CurrencyRate, CurrencyUnit, Messages } from '../../entities';
@@ -69,30 +70,23 @@ export const errorCodeToLabel = (code: number): string => {
};
/**
- * Known origins mapped to their human-readable labels. Keys are lowercased so
- * lookups can be performed case-insensitively against the raw origin.
+ * Formats a request origin for display.
+ *
+ * Returns an empty string when the origin is not displayable: remote
+ * transports (WalletConnect, SDK) pass an opaque connection id, which is
+ * meaningless to the user, so the caller hides the origin row instead of
+ * showing it.
+ *
+ * ponytail: the self-reported URL that rides along such requests in
+ * `originMetadata` is not plumbed into the confirmations yet (Bitcoin has no
+ * remote-transport support to exercise it). Pass it to `resolveOrigin` and
+ * render its `isSelfReported` flag when that support lands.
+ *
+ * @param origin - The origin of the request, as received by the snap.
+ * @returns The hostname, a label for known origins, or an empty string.
*/
-const KNOWN_ORIGIN_LABELS: Record = {
- metamask: 'MetaMask',
- 'wallet-connect': 'WalletConnect',
-};
-
-export const displayOrigin = (origin: string): string => {
- const knownLabel = KNOWN_ORIGIN_LABELS[origin.toLowerCase()];
- if (knownLabel) {
- return knownLabel;
- }
-
- try {
- const url = new URL(origin);
- return url.protocol === 'http:' || url.protocol === 'https:'
- ? url.hostname
- : '';
- } catch {
- console.log('[format] - displayOrigin - failed to parse origin', origin);
- return '';
- }
-};
+export const displayOrigin = (origin: string): string =>
+ resolveOrigin(origin).displayOrigin ?? '';
export const displayCaip10 = (
network: Network,
diff --git a/packages/bitcoin-wallet-snap/src/infra/jsx/unified-send-flow/UnifiedSendFormView.tsx b/packages/bitcoin-wallet-snap/src/infra/jsx/unified-send-flow/UnifiedSendFormView.tsx
index 774cd1451..d6b2bf102 100644
--- a/packages/bitcoin-wallet-snap/src/infra/jsx/unified-send-flow/UnifiedSendFormView.tsx
+++ b/packages/bitcoin-wallet-snap/src/infra/jsx/unified-send-flow/UnifiedSendFormView.tsx
@@ -22,6 +22,7 @@ import {
displayExchangeAmount,
displayExplorerUrl,
displayNetwork,
+ displayOrigin,
isValidSnapLinkProtocol,
translate,
} from '../format';
@@ -103,7 +104,7 @@ export const UnifiedSendFormView: SnapComponent = ({
{t('confirmation.requestOrigin')}
- {origin ?? 'MetaMask'}
+ {displayOrigin(origin ?? 'metamask')}
{null}