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

[fcl-wc] add pairing modal override and sessionRequestHook #1411

Merged
merged 11 commits into from
Sep 15, 2022

Conversation

gregsantos
Copy link
Contributor

@gregsantos gregsantos commented Sep 14, 2022

  • Improves deeplinking for pairing and requests on mobile and provides wcRequestHook for dApp to alert user of signing request
  • Adds additional options to init for pairing modal override
import * as fcl from '@onflow/fcl'
import { init } from '@onflow/fcl-wc'
// example using pairing data from wcRequestHook and providing a custom pairing modal
const { FclWcServicePlugin, client } = await init({
  projectId: PROJECT_ID,
  metadata: PROJECT_METADATA,
  includeBaseWC: false,
  wallets: [],  
  wcRequestHook: (data: WcRequestData) => {
    const peerMetadata = data?.pairing?.peerMetadata
    setSessionRequestData(peerMetadata)
    setShowRequestModal(true)
  },
  pairingModalOverride: (uri: string = '', rejectPairingRequest: () => void) => {
    openCustomPairingModal(uri)
    // call rejectPairingRequest() to manually reject pairing request from client
  }
})

fcl.pluginRegistry.add(FclWcServicePlugin)

@gregsantos gregsantos requested a review from a team as a code owner September 14, 2022 23:08
@changeset-bot
Copy link

changeset-bot bot commented Sep 14, 2022

🦋 Changeset detected

Latest commit: 333af26

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@onflow/fcl-wc Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@chasefleming
Copy link
Member

@gregsantos should names like includeBaseWC, sessionRequestHook, and pairingModalOveride be more generic so that they can be standards across plugins?

@gregsantos gregsantos merged commit 3c7a1bd into master Sep 15, 2022
@gregsantos gregsantos deleted the gsantos-wc-deeplink branch September 15, 2022 22:06
huyndo pushed a commit that referenced this pull request Sep 24, 2022
* PKG -- [fcl-wc] update fetch wc wallets to use api/v3

* PKG -- [fcl-wc] add function validation to sessionRequest hook

* PKG -- [fcl-wc] open deeplink window before async connect

* PKG -- [fcl-wc] requestHook on mobile for sessions

* PKG -- [fcl-wc] update sessionRequest hool with session/pairing and uri

* PKG -- [fcl-wc] update sclient to singleton, refactor new session

* PKG -- [fcl-wc] add pairing modal overide

* PKG -- [fcl-wc] add method to wcRequestHook, update naming and constants

* PKG -- [fcl-wc] update pairing modal override

* PKG -- [fcl-wc] remove windowRef and use window directly on authn

* PKG -- [fcl-wc] add open deeplink on mobile session request
@github-actions github-actions bot mentioned this pull request Sep 26, 2022
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.

2 participants