Skip to content

Commit

Permalink
setAppInfo
Browse files Browse the repository at this point in the history
  • Loading branch information
fan-zhang-sv committed Oct 23, 2024
1 parent 7ba8572 commit 0b37ac0
Showing 1 changed file with 4 additions and 14 deletions.
18 changes: 4 additions & 14 deletions packages/wallet-sdk/src/util/provider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ export interface CBWindow {
export interface CBInjectedProvider extends ProviderInterface {
isCoinbaseBrowser?: boolean;
setAppInfo?: (...args: unknown[]) => unknown;
setAppParams?: (params: Record<string, unknown>) => void;
}

function getCoinbaseInjectedLegacyProvider(): CBInjectedProvider | undefined {
Expand All @@ -53,32 +52,23 @@ function getInjectedEthereum(): CBInjectedProvider | undefined {
}
}

function flattenParams({
metadata,
preference,
}: Readonly<ConstructorOptions>): Record<string, unknown> {
return {
...metadata,
...preference,
};
}

export function getCoinbaseInjectedProvider({
metadata,
preference,
}: Readonly<ConstructorOptions>): ProviderInterface | undefined {
const { appName, appLogoUrl, appChainIds } = metadata;

if (preference.options !== 'smartWalletOnly') {
const extension = getCoinbaseInjectedLegacyProvider();
if (extension) {
const { appName, appLogoUrl, appChainIds } = metadata;
extension.setAppInfo?.(appName, appLogoUrl, appChainIds);
extension.setAppInfo?.(appName, appLogoUrl, appChainIds, preference);
return extension;
}
}

const ethereum = getInjectedEthereum();
if (ethereum?.isCoinbaseBrowser) {
ethereum.setAppParams?.(flattenParams({ metadata, preference }));
ethereum.setAppInfo?.(appName, appLogoUrl, appChainIds, preference);
return ethereum;
}

Expand Down

0 comments on commit 0b37ac0

Please sign in to comment.