-
Notifications
You must be signed in to change notification settings - Fork 116
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[fcl-wc] add pairing modal override and sessionRequestHook (#1411)
* 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
- Loading branch information
Greg Santos
authored
Sep 15, 2022
1 parent
15d7722
commit 3c7a1bd
Showing
5 changed files
with
187 additions
and
88 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
--- | ||
"@onflow/fcl-wc": patch | ||
--- | ||
|
||
Adds additional options to `init` for `pairingModalOverride` and `wcRequestHook` | ||
|
||
```js | ||
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) | ||
|
||
``` | ||
```ts | ||
|
||
interface WcRequestData { | ||
type: string // 'session_request' | 'pairing_request' | ||
session: SessionTypes.Struct | undefined // https://www.npmjs.com/package/@walletconnect/types | ||
pairing: PairingTypes.Struct | undefined // https://www.npmjs.com/package/@walletconnect/types | ||
method: string // "flow_authn" | "flow_authz" | "flow_user_sign" | ||
uri: string | undefined | ||
} | ||
|
||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
export const FLOW_METHODS = { | ||
FLOW_AUTHN: "flow_authn", | ||
FLOW_AUTHZ: "flow_authz", | ||
FLOW_USER_SIGN: "flow_user_sign", | ||
} | ||
|
||
export const REQUEST_TYPES = { | ||
SESSION: "session_request", | ||
PAIRING: "pairing_request", | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.