@farcaster/frame-wagmi-connector 0.0.29 → 0.0.30
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/connector.js +13 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +2 -2
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +3 -3
- package/src/connector.ts +13 -2
- package/src/index.ts +2 -2
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@farcaster/frame-wagmi-connector",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.30",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -17,8 +17,8 @@
|
|
|
17
17
|
"@wagmi/core": "^2.16.3",
|
|
18
18
|
"typescript": "^5.7.2",
|
|
19
19
|
"viem": "^2.21.57",
|
|
20
|
-
"@farcaster/
|
|
21
|
-
"@farcaster/
|
|
20
|
+
"@farcaster/frame-sdk": "0.0.41",
|
|
21
|
+
"@farcaster/tsconfig": "0.0.2"
|
|
22
22
|
},
|
|
23
23
|
"publishConfig": {
|
|
24
24
|
"access": "public"
|
package/src/connector.ts
CHANGED
|
@@ -26,6 +26,17 @@ export function farcasterFrame() {
|
|
|
26
26
|
method: 'eth_requestAccounts',
|
|
27
27
|
})
|
|
28
28
|
|
|
29
|
+
let targetChainId = chainId
|
|
30
|
+
if (!targetChainId) {
|
|
31
|
+
const state = (await config.storage?.getItem('state')) ?? {}
|
|
32
|
+
const isChainSupported = config.chains.some(
|
|
33
|
+
(x) => x.id === state.chainId,
|
|
34
|
+
)
|
|
35
|
+
if (isChainSupported) targetChainId = state.chainId
|
|
36
|
+
else targetChainId = config.chains[0]?.id
|
|
37
|
+
}
|
|
38
|
+
if (!targetChainId) throw new Error('No chains found on connector.')
|
|
39
|
+
|
|
29
40
|
if (!accountsChanged) {
|
|
30
41
|
accountsChanged = this.onAccountsChanged.bind(this)
|
|
31
42
|
// @ts-expect-error - provider type is stricter
|
|
@@ -41,8 +52,8 @@ export function farcasterFrame() {
|
|
|
41
52
|
}
|
|
42
53
|
|
|
43
54
|
let currentChainId = await this.getChainId()
|
|
44
|
-
if (
|
|
45
|
-
const chain = await this.switchChain!({ chainId })
|
|
55
|
+
if (targetChainId && currentChainId !== targetChainId) {
|
|
56
|
+
const chain = await this.switchChain!({ chainId: targetChainId })
|
|
46
57
|
currentChainId = chain.id
|
|
47
58
|
}
|
|
48
59
|
|
package/src/index.ts
CHANGED