Skip to content

Commit c5191ab

Browse files
authored
Load FCL-WC in createFlowClient (#2614)
1 parent f94ef12 commit c5191ab

File tree

14 files changed

+126
-87
lines changed

14 files changed

+126
-87
lines changed
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@onflow/fcl-wc": minor
3+
---
4+
5+
Add support for manually passing a `network` to `createSessionProposal`

.changeset/spicy-otters-camp.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@onflow/fcl-core": minor
3+
---
4+
5+
Remove unused WalletConnect configuration options from `createFlowClient`

.changeset/wild-taxis-behave.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@onflow/fcl": minor
3+
---
4+
5+
Load FCL-WC in `createFlowClient`

package-lock.json

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/demo/src/components/flow-provider-wrapper.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,10 +62,11 @@ export default function FlowProviderWrapper({
6262
config={{
6363
...flowConfig[flowNetwork],
6464
appDetailTitle: "Demo App",
65+
appDetailUrl: window.location.origin,
6566
appDetailIcon: "https://avatars.githubusercontent.com/u/62387156?v=4",
66-
appDetailUrl: "https://yourapp.com",
6767
appDetailDescription: "Your app description",
6868
computeLimit: 1000,
69+
walletconnectProjectId: "9b70cfa398b2355a5eb9b1cf99f4a981",
6970
}}
7071
flowJson={flowJSON}
7172
colorMode={darkMode ? "dark" : "light"}

packages/demo/vite.config.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,7 @@ import react from "@vitejs/plugin-react"
44
// https://vite.dev/config/
55
export default defineConfig({
66
plugins: [react()],
7+
server: {
8+
allowedHosts: true,
9+
},
710
})

packages/fcl-core/src/client.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,6 @@ export interface FlowClientCoreConfig {
2323
discoveryAuthnEndpoint?: string
2424
discoveryAuthnInclude?: string[]
2525

26-
// WalletConnect configuration
27-
walletconnectProjectId?: string
28-
walletconnectDisableNotifications?: boolean
29-
3026
// Compute limit for transactions
3127
computeLimit: number
3228

packages/fcl-core/src/context/index.ts

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,6 @@ interface FCLConfig {
1616
discoveryAuthnEndpoint?: string
1717
discoveryAuthnInclude?: string[]
1818
flowNetwork?: string
19-
walletconnectProjectId?: string
20-
walletconnectDisableNotifications?: boolean
2119
storage: StorageProvider
2220
discovery?: {
2321
execStrategy?: (...args: any[]) => any
@@ -125,11 +123,6 @@ export function createConfigService(config: FCLConfig): ConfigService {
125123
["discovery.wallet.method", config.discoveryWalletMethod],
126124
["discovery.authn.endpoint", config.discoveryAuthnEndpoint],
127125
["flow.network", config.flowNetwork],
128-
["walletconnectProjectId", config.walletconnectProjectId],
129-
[
130-
"walletconnect.disableNotifications",
131-
config.walletconnectDisableNotifications,
132-
],
133126
["accessNode.api", config.accessNodeUrl],
134127
["fcl.limit", config.computeLimit],
135128
["app.detail.title", config.appDetailTitle],

packages/fcl-wc/src/service.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,7 @@ const makeExec = (
117117
wcRequestHook,
118118
pairingModalOverride,
119119
abortSignal,
120+
network: opts.config.client.network,
120121
}).then(resolve, reject)
121122
})
122123
}
@@ -188,6 +189,7 @@ function connectWc(
188189
wcRequestHook,
189190
pairingModalOverride,
190191
abortSignal,
192+
network,
191193
}: {
192194
service: any
193195
onClose: any
@@ -198,6 +200,7 @@ function connectWc(
198200
wcRequestHook: any
199201
pairingModalOverride: any
200202
abortSignal?: AbortSignal
203+
network: string
201204
}): Promise<SessionTypes.Struct> => {
202205
const projectId = provider.providerOpts.projectId
203206
invariant(
@@ -212,6 +215,7 @@ function connectWc(
212215
const {uri, approval} = await createSessionProposal({
213216
provider,
214217
existingPairing: pairing,
218+
network,
215219
})
216220

217221
if (wcRequestHook && wcRequestHook instanceof Function) {

packages/fcl-wc/src/session.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,13 @@ import {Service} from "@onflow/typedefs"
88
export async function createSessionProposal({
99
provider,
1010
existingPairing,
11+
network,
1112
}: {
1213
provider: InstanceType<typeof UniversalProvider>
1314
existingPairing?: PairingTypes.Struct
15+
network?: string
1416
}) {
15-
const network = await fclCore.getChainId()
17+
const _network = network || (await fclCore.getChainId())
1618

1719
const requiredNamespaces = {
1820
flow: {
@@ -22,7 +24,7 @@ export async function createSessionProposal({
2224
FLOW_METHODS.FLOW_AUTHZ,
2325
FLOW_METHODS.FLOW_USER_SIGN,
2426
],
25-
chains: [`flow:${network}`],
27+
chains: [`flow:${_network}`],
2628
events: ["chainChanged", "accountsChanged"],
2729
},
2830
}

0 commit comments

Comments
 (0)