-
Notifications
You must be signed in to change notification settings - Fork 520
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
MobileRelay #903
MobileRelay #903
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
import { isInIFrame } from "../util"; | ||
import { WalletLinkRelay, WalletLinkRelayOptions } from "./WalletLinkRelay"; | ||
import { CancelablePromise } from "./WalletSDKRelayAbstract"; | ||
import { RequestEthereumAccountsResponse } from "./Web3Response"; | ||
|
||
export class MobileRelay extends WalletLinkRelay { | ||
private _useMobileWalletLink: boolean; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Instead of typescript privates we can start using javascript private methods https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Classes/Private_class_fields #useMobileWalletLink: boolean; There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. thanks for flagging that. |
||
|
||
constructor(options: Readonly<WalletLinkRelayOptions>) { | ||
super(options); | ||
this._useMobileWalletLink = options.useMobileWalletLink ?? false; | ||
} | ||
|
||
// override | ||
public requestEthereumAccounts(): CancelablePromise<RequestEthereumAccountsResponse> { | ||
if (this._useMobileWalletLink) { | ||
return super.requestEthereumAccounts(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. TODO: deeplink navigation |
||
} | ||
|
||
// TODO: Implement & present in-page wallet picker instead of navigating to www.coinbase.com/connect-dapp | ||
return { | ||
promise: new Promise(() => { | ||
let location: Location; | ||
try { | ||
if (isInIFrame() && window.top) { | ||
location = window.top.location; | ||
} else { | ||
location = window.location; | ||
} | ||
} catch (e) { | ||
location = window.location; | ||
} | ||
|
||
location.href = `https://www.coinbase.com/connect-dapp?uri=${encodeURIComponent( | ||
location.href, | ||
)}`; | ||
}), | ||
Comment on lines
+22
to
+37
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
cancel: () => {}, | ||
}; | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
branching here for dedicated relay logic