@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 CHANGED
@@ -17,6 +17,17 @@ export function farcasterFrame() {
17
17
  const accounts = await provider.request({
18
18
  method: 'eth_requestAccounts',
19
19
  });
20
+ let targetChainId = chainId;
21
+ if (!targetChainId) {
22
+ const state = (await config.storage?.getItem('state')) ?? {};
23
+ const isChainSupported = config.chains.some((x) => x.id === state.chainId);
24
+ if (isChainSupported)
25
+ targetChainId = state.chainId;
26
+ else
27
+ targetChainId = config.chains[0]?.id;
28
+ }
29
+ if (!targetChainId)
30
+ throw new Error('No chains found on connector.');
20
31
  if (!accountsChanged) {
21
32
  accountsChanged = this.onAccountsChanged.bind(this);
22
33
  // @ts-expect-error - provider type is stricter
@@ -31,8 +42,8 @@ export function farcasterFrame() {
31
42
  provider.on('disconnect', disconnect);
32
43
  }
33
44
  let currentChainId = await this.getChainId();
34
- if (chainId && currentChainId !== chainId) {
35
- const chain = await this.switchChain({ chainId });
45
+ if (targetChainId && currentChainId !== targetChainId) {
46
+ const chain = await this.switchChain({ chainId: targetChainId });
36
47
  currentChainId = chain.id;
37
48
  }
38
49
  return {
package/dist/index.d.ts CHANGED
@@ -1,3 +1,3 @@
1
- import { farcasterFrame } from './connector';
2
- export * from './connector';
1
+ import { farcasterFrame } from './connector.js';
2
+ export * from './connector.js';
3
3
  export default farcasterFrame;
package/dist/index.js CHANGED
@@ -1,3 +1,3 @@
1
- import { farcasterFrame } from './connector';
2
- export * from './connector';
1
+ import { farcasterFrame } from './connector.js';
2
+ export * from './connector.js';
3
3
  export default farcasterFrame;