[WIP] [NO-MERGE] Adds WalletConnect adapter pkg
Adds a new package to wrap WalletConnect and expose SignClient and utils
This adapter/wrapper allows us to pin WalletConnect to a version for use with FCL.
It exposes initWcAdapter and additional utils to consumers.
Passing a projectId and optional metadata will initialize and return a SignClient for use in connecting to a Flow enabled WalletConnect wallet. This Adapter will be updated to support WalletConnect api and utils as needed.
EXPECT BREAKING CHANGES
This adapter can be passed to FCL config and used by the application and FCL to connect, authenticate, authorize, and sign messages.
Init adapter/client and add to config
import * as fcl from '@onflow/fcl'
import * as fclWC from '@onflow/fcl-wc'
import { initWcAdapter, getSdkError, QRCodeModal } from '@onflow/fcl-wc'
const wcAdapter = fclWC.initWcAdapter({
projectId: WC_PROJECT_ID,
metadata: {
name: 'FCL WalletConnect',
description: 'FCL DApp for WalletConnect',
url: 'https://flow.com/',
icons: ['https://avatars.githubusercontent.com/u/62387156?s=280&v=4']
}
})
fcl
.config()
.put('wc.adapter', wcAdapter)
Get client from fcl.config
const { client, QRCodeModal } = await fcl.config.get('wc.adapter')
client.on('session_update', ({ topic, params }) => {
const session = client.session.get(topic)
console.log('EVENT', 'session_update', { topic, params, session })
})
await client.disconnect({
topic: session.topic,
reason: getSdkError('USER_DISCONNECTED')
})
🦋 Changeset detected
Latest commit: 52a683541ff3b6b257bd37a763a05efae2d8fd08
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 | Minor |
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
Working on updates to include a Service Strategy plugin for FCL
Waiting on the first publishing.
Updated with ServicePlugin and initial serviceStrategy. Initialization will now create services for any existing pairings.