Skip to content

Commit b348854

Browse files
committed
align ifram w parent
1 parent 0279873 commit b348854

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

packages/wallet-sdk/src/util/provider.ts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@ export interface CBWindow {
3131
top: CBWindow;
3232
ethereum?: CBInjectedProvider;
3333
coinbaseWalletExtension?: CBInjectedProvider;
34+
ReactNativeWebView?: unknown;
35+
__CIPHER_BRIDGE__?: unknown;
3436
}
3537

3638
export interface CBInjectedProvider extends ProviderInterface {
@@ -43,6 +45,18 @@ function getCoinbaseInjectedLegacyProvider(): CBInjectedProvider | undefined {
4345
return window.coinbaseWalletExtension;
4446
}
4547

48+
function alignIframeWithParentIfNeeded() {
49+
const window = globalThis as CBWindow;
50+
if (window !== window.top && window.top.ethereum?.isCoinbaseBrowser) {
51+
if (window.top?.ReactNativeWebView) {
52+
window.ReactNativeWebView = window.top.ReactNativeWebView;
53+
}
54+
if (window.top?.__CIPHER_BRIDGE__) {
55+
window.__CIPHER_BRIDGE__ = window.top.__CIPHER_BRIDGE__;
56+
}
57+
}
58+
}
59+
4660
function getInjectedEthereum(): CBInjectedProvider | undefined {
4761
try {
4862
const window = globalThis as CBWindow;
@@ -68,6 +82,7 @@ export function getCoinbaseInjectedProvider({
6882

6983
const ethereum = getInjectedEthereum();
7084
if (ethereum?.isCoinbaseBrowser) {
85+
alignIframeWithParentIfNeeded();
7186
ethereum.setAppInfo?.(appName, appLogoUrl, appChainIds, preference);
7287
return ethereum;
7388
}

0 commit comments

Comments
 (0)