Skip to content
Merged
Show file tree
Hide file tree
Changes from 4 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
10 changes: 9 additions & 1 deletion app/components/Views/AccountConnect/AccountConnect.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -286,6 +286,14 @@

const dappUrl = sdkConnection?.originatorInfo?.url ?? '';

// Should be the self reported dapp url if SDK or WC connection, null if no self reported dapp url.
// If not SDK or WC connection, i.e. a regular external connection, it should be the hostname.
const referrer = isOriginMMSDKRemoteConn
? dappUrl
: isOriginWalletConnect
? wc2Metadata?.url
: channelIdOrHostname;

Check warning on line 295 in app/components/Views/AccountConnect/AccountConnect.tsx

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Extract this nested ternary operation into an independent statement.

See more on https://sonarcloud.io/project/issues?id=metamask-mobile&issues=AZ1AIXfDip1ffNXdFk0F&open=AZ1AIXfDip1ffNXdFk0F&pullRequest=28111
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks like dappUrl will default to '' not null? not sure about wc2Metadata?.url

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah good point. The comment is wrong. I really just want the value to be falsey here (i.e. not the channelId) when the connection is SDK or WC and the self reported dapp url is not available.


// If it is undefined, it will enter the regular eth account creation flow.
const [multichainAccountOptions, setMultichainAccountOptions] = useState<
| {
Expand Down Expand Up @@ -511,7 +519,7 @@
account_type: getAddressAccountType(activeAddress),
source: eventSource,
chain_id_list: selectedChainIds,
referrer: request.metadata.origin,
referrer,
...getApiAnalyticsProperties(isMultichainRequest),
})
.build(),
Expand All @@ -535,7 +543,7 @@
} finally {
setIsLoading(false);
}
}, [

Check failure on line 546 in app/components/Views/AccountConnect/AccountConnect.tsx

View workflow job for this annotation

GitHub Actions / Run `lint`

React Hook useCallback has a missing dependency: 'referrer'. Either include it or remove the dependency array
eventSource,
selectedAddresses,
hostInfo,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -480,6 +480,14 @@
sdkV2Connection?.originatorInfo?.url ??
'';

// Should be the self reported dapp url if SDK or WC connection, null if no self reported dapp url.
// If not SDK or WC connection, i.e. a regular external connection, it should be the hostname.
const referrer = isOriginMMSDKRemoteConn
? dappUrl
: isOriginWalletConnect
? wc2Metadata?.url
: channelIdOrHostname;

Check warning on line 489 in app/components/Views/MultichainAccounts/MultichainAccountConnect/MultichainAccountConnect.tsx

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Extract this nested ternary operation into an independent statement.

See more on https://sonarcloud.io/project/issues?id=metamask-mobile&issues=AZ1AIXqQip1ffNXdFk0G&open=AZ1AIXqQip1ffNXdFk0G&pullRequest=28111
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

V2 SDK connections not handled in referrer computation

Medium Severity

The referrer computation only checks isOriginMMSDKRemoteConn (v1 SDK connections) but this component also supports v2 SDK connections via isOriginMMSDKV2RemoteConn. For v2 SDK connections, isOriginMMSDKRemoteConn is false, so referrer falls through to channelIdOrHostname instead of using the self-reported dapp URL from dappUrl (which already includes sdkV2Connection?.originatorInfo?.url at lines 478–481). This defeats the PR's purpose of reporting the self-reported dapp URL for SDK connections.

Fix in Cursor Fix in Web


const { domainTitle, hostname } = useMemo(() => {
let title = strings('sdk.unknown');
let dappHostname = dappUrl || channelIdOrHostname;
Expand Down Expand Up @@ -694,7 +702,7 @@
account_type: 'multichain',
source: eventSource,
chain_id_list: selectedChainIds,
referrer: request.metadata.origin,
referrer,
...getApiAnalyticsProperties(isMultichainRequest),
})
.build(),
Expand All @@ -718,7 +726,7 @@
} finally {
setIsLoading(false);
}
}, [

Check failure on line 729 in app/components/Views/MultichainAccounts/MultichainAccountConnect/MultichainAccountConnect.tsx

View workflow job for this annotation

GitHub Actions / Run `lint`

React Hook useCallback has a missing dependency: 'referrer'. Either include it or remove the dependency array
hostInfo,
channelIdOrHostname,
requestedRequestWithExistingPermissions,
Expand Down
Loading