Skip to content
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

Merged
merged 3 commits into from
Jun 23, 2023
Merged

MobileRelay #903

merged 3 commits into from
Jun 23, 2023

Conversation

bangtoven
Copy link
Contributor

Summary

separate relay for mobile connection.
currently it subclasses existing relay, but will be updated later.

How did you test your changes?

Comment on lines +128 to +130
this._relay = isMobileWeb()
? new MobileRelay(relayOption)
: new WalletLinkRelay(relayOption);
Copy link
Contributor Author

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

// override
public requestEthereumAccounts(): CancelablePromise<RequestEthereumAccountsResponse> {
if (this._useMobileWalletLink) {
return super.requestEthereumAccounts();
Copy link
Contributor Author

Choose a reason for hiding this comment

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

TODO: deeplink navigation

Comment on lines +22 to +37
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,
)}`;
}),
Copy link
Contributor Author

Choose a reason for hiding this comment

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

migrated from WalletLinkRelay/requestEthereumAccounts

image

import { RequestEthereumAccountsResponse } from "./Web3Response";

export class MobileRelay extends WalletLinkRelay {
private _useMobileWalletLink: boolean;
Copy link
Contributor

Choose a reason for hiding this comment

The 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;

Copy link
Contributor Author

Choose a reason for hiding this comment

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

thanks for flagging that.
will address that during overall refactor.

@bangtoven bangtoven merged commit ecf4a46 into master Jun 23, 2023
12 checks passed
@bangtoven bangtoven deleted the jungho/mobile branch June 23, 2023 21:53
bangtoven added a commit that referenced this pull request Feb 29, 2024
* rename to clarify how the relay connects

* introduce MobileRelay

* comment
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants