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

fix: argent mobile connector based on in app browser #119

Merged
merged 2 commits into from
Aug 8, 2024

Conversation

bluecco
Copy link
Contributor

@bluecco bluecco commented Aug 7, 2024

Issue / feature description

Many dapps don’t support in-app browser properly and add Mobile connector instead which makes for poor experience.

Changes

When the dapp would want to create mobile connector, we could check if it’s in app browser, and return the standard connector instead.

  • ArgentMobileConnector is now renamed as ArgentMobileBaseConnector
  • ArgentMobileConnector now provide a static method to instantiate the right connector
    • argent-x connector if it's inside the in app browser
    • mobile connector for every other case

Checklist

  • Rebased to the last commit of the target branch (or merged)
  • Code self-reviewed
  • Code self-tested
  • Tests updated (if needed)
  • All tests are passing locally

Please keep your pull request as small as possible. If you need to make multiple changes, please create separate pull requests for each change. Create a draft pull request if you need early feedback. This will mark the pull request as a work in progress and prevent it from being reviewed or merged until you are ready.

Please move drafts to the ready for review (regular PR) when you are ready to start the review process and other developers will pick it up from there.

@bluecco bluecco requested review from dmcrodrigues, mluisbrown, Inukares, Cussone, kamilargent and vladutjs and removed request for mluisbrown August 7, 2024 16:18
export class ArgentMobileConnector {
static init(options: ArgentMobileConnectorOptions = {}) {
if (isInArgentMobileAppBrowser()) {
return new InjectedConnector({ options: { id: "argentX" } })

Choose a reason for hiding this comment

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

shouldn't we also configure name and icon in the options here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yeah, will add tomorrow

Copy link
Contributor Author

Choose a reason for hiding this comment

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

updated

Copy link

@kamilargent kamilargent left a comment

Choose a reason for hiding this comment

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

LGTM, simple change, big benefit 👍

@mluisbrown
Copy link

What is the issue that this is fixing?

@@ -1,6 +1,10 @@
import type { StarknetWindowObject } from "@starknet-io/types-js"

export const isInArgentMobileAppBrowser = (): boolean => {
if (typeof window === "undefined") {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

prevent ssr errors

@bluecco
Copy link
Contributor Author

bluecco commented Aug 8, 2024

What is the issue that this is fixing?

@mluisbrown

improved proposal on the technical side. Many dapps don’t support in-app browser properly and add Mobile connector instead which makes for poor experience. Considering uniform interface of connects, when the dapp would want to create mobile connector, we could check if it’s in app browser, and return the standard connector instead.

Copy link

@mluisbrown mluisbrown left a comment

Choose a reason for hiding this comment

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

Nice 👌

@bluecco bluecco merged commit 24ebb92 into develop Aug 8, 2024
1 check passed
@bluecco bluecco deleted the fix/argent-mobile-unified branch August 8, 2024 09:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants