@farcaster/frame-wagmi-connector 0.0.13 → 0.0.15

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@farcaster/frame-wagmi-connector",
3
- "version": "0.0.13",
3
+ "version": "0.0.15",
4
4
  "type": "module",
5
5
  "main": "dist/index.js",
6
6
  "files": [
@@ -11,14 +11,14 @@
11
11
  "@wagmi/core": "^2.16.3",
12
12
  "typescript": "^5.7.2",
13
13
  "viem": "^2.21.57",
14
- "@farcaster/frame-sdk": "0.0.26",
14
+ "@farcaster/frame-sdk": "0.0.27",
15
15
  "@farcaster/tsconfig": "0.0.2"
16
16
  },
17
17
  "publishConfig": {
18
18
  "access": "public"
19
19
  },
20
20
  "peerDependencies": {
21
- "@farcaster/frame-sdk": "^0.0.26",
21
+ "@farcaster/frame-sdk": "^0.0.27",
22
22
  "@wagmi/core": "^2.14.1",
23
23
  "viem": "^2.21.55"
24
24
  },
package/src/connector.ts CHANGED
@@ -13,8 +13,6 @@ let chainChanged: Connector['onChainChanged'] | undefined
13
13
  let disconnect: Connector['onDisconnect'] | undefined
14
14
 
15
15
  export function farcasterFrame() {
16
- let connected = false
17
-
18
16
  return createConnector<typeof FrameSDK.wallet.ethProvider>((config) => ({
19
17
  id: 'farcaster',
20
18
  name: 'Farcaster Frame',
@@ -48,8 +46,6 @@ export function farcasterFrame() {
48
46
  currentChainId = chain.id
49
47
  }
50
48
 
51
- connected = true
52
-
53
49
  return {
54
50
  accounts: accounts.map((x) => getAddress(x)),
55
51
  chainId: currentChainId,
@@ -73,16 +69,11 @@ export function farcasterFrame() {
73
69
  provider.removeListener('disconnect', disconnect)
74
70
  disconnect = undefined
75
71
  }
76
-
77
- connected = false
78
72
  },
79
73
  async getAccounts() {
80
- if (!connected) {
81
- throw new Error('Not connected')
82
- }
83
74
  const provider = await this.getProvider()
84
75
  const accounts = await provider.request({
85
- method: 'eth_requestAccounts',
76
+ method: 'eth_accounts',
86
77
  })
87
78
  return accounts.map((x) => getAddress(x))
88
79
  },
@@ -92,12 +83,12 @@ export function farcasterFrame() {
92
83
  return fromHex(hexChainId, 'number')
93
84
  },
94
85
  async isAuthorized() {
95
- if (!connected) {
86
+ try {
87
+ const accounts = await this.getAccounts()
88
+ return !!accounts.length
89
+ } catch {
96
90
  return false
97
91
  }
98
-
99
- const accounts = await this.getAccounts()
100
- return !!accounts.length
101
92
  },
102
93
  async switchChain({ chainId }) {
103
94
  const provider = await this.getProvider()
@@ -134,7 +125,6 @@ export function farcasterFrame() {
134
125
  },
135
126
  async onDisconnect() {
136
127
  config.emitter.emit('disconnect')
137
- connected = false
138
128
  },
139
129
  async getProvider() {
140
130
  return FrameSDK.wallet.ethProvider