@berachain/wagmi 0.4.0-beta.2 → 0.4.0-beta.4

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.
@@ -1,4 +1,5 @@
1
1
  import { PropsWithChildren } from 'react';
2
+ import { Profile, WalletConnectionOption } from 'thirdweb/wallets';
2
3
  import { Address, Chain } from 'viem';
3
4
  import { UseWalletClientReturnType } from 'wagmi';
4
5
  import { getConfig, ThirdwebConfig } from './config/index.cjs';
@@ -8,7 +9,7 @@ interface BeraWagmiApi {
8
9
  /**
9
10
  * @deprecated used for prototyping only.
10
11
  */
11
- DebugConnectButton: () => React.ReactNode;
12
+ DebugConnectButton(): React.ReactNode;
12
13
  /**
13
14
  * Account connected to berachain dapp. It might include some additional data once embedded wallets are enabled.
14
15
  */
@@ -23,6 +24,7 @@ interface BeraWagmiApi {
23
24
  isEmbeddedWallet: boolean;
24
25
  connectorName: string | null;
25
26
  connectionId: string;
27
+ profiles: Profile[] | undefined;
26
28
  /**
27
29
  * Wallet to display.
28
30
  *
@@ -56,22 +58,18 @@ interface BeraWagmiApi {
56
58
  disable5792Upgrade: boolean;
57
59
  };
58
60
  walletClient: UseWalletClientReturnType["data"];
59
- openConnectModal: () => Promise<void> | void;
61
+ openConnectModal(): Promise<void> | void;
60
62
  /**
61
63
  * Connects a wallet using a specific strategy.
62
- *
63
- * @param strategy - The strategy to use to connect the wallet.
64
64
  */
65
- connect: ({ strategy, }: {
66
- strategy: "google" | "apple";
67
- }) => Promise<void> | void;
65
+ connect(args: Omit<WalletConnectionOption<"inApp">, "client">): Promise<void> | void;
68
66
  disconnect(): void;
69
67
  /**
70
68
  * A callback that is called when a smart account upgrade is rejected.
71
69
  *
72
70
  * This is used to disable EIP-5792 temporarily.
73
71
  */
74
- onSmartAccountRejection: () => void;
72
+ onSmartAccountRejection(): void;
75
73
  /**
76
74
  * List of external chains that are whitelisted for that app.
77
75
  */
@@ -1,4 +1,5 @@
1
1
  import { PropsWithChildren } from 'react';
2
+ import { Profile, WalletConnectionOption } from 'thirdweb/wallets';
2
3
  import { Address, Chain } from 'viem';
3
4
  import { UseWalletClientReturnType } from 'wagmi';
4
5
  import { getConfig, ThirdwebConfig } from './config/index.js';
@@ -8,7 +9,7 @@ interface BeraWagmiApi {
8
9
  /**
9
10
  * @deprecated used for prototyping only.
10
11
  */
11
- DebugConnectButton: () => React.ReactNode;
12
+ DebugConnectButton(): React.ReactNode;
12
13
  /**
13
14
  * Account connected to berachain dapp. It might include some additional data once embedded wallets are enabled.
14
15
  */
@@ -23,6 +24,7 @@ interface BeraWagmiApi {
23
24
  isEmbeddedWallet: boolean;
24
25
  connectorName: string | null;
25
26
  connectionId: string;
27
+ profiles: Profile[] | undefined;
26
28
  /**
27
29
  * Wallet to display.
28
30
  *
@@ -56,22 +58,18 @@ interface BeraWagmiApi {
56
58
  disable5792Upgrade: boolean;
57
59
  };
58
60
  walletClient: UseWalletClientReturnType["data"];
59
- openConnectModal: () => Promise<void> | void;
61
+ openConnectModal(): Promise<void> | void;
60
62
  /**
61
63
  * Connects a wallet using a specific strategy.
62
- *
63
- * @param strategy - The strategy to use to connect the wallet.
64
64
  */
65
- connect: ({ strategy, }: {
66
- strategy: "google" | "apple";
67
- }) => Promise<void> | void;
65
+ connect(args: Omit<WalletConnectionOption<"inApp">, "client">): Promise<void> | void;
68
66
  disconnect(): void;
69
67
  /**
70
68
  * A callback that is called when a smart account upgrade is rejected.
71
69
  *
72
70
  * This is used to disable EIP-5792 temporarily.
73
71
  */
74
- onSmartAccountRejection: () => void;
72
+ onSmartAccountRejection(): void;
75
73
  /**
76
74
  * List of external chains that are whitelisted for that app.
77
75
  */
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }var _wagmi = require('wagmi');var _react = require('react');var _jsxruntime = require('react/jsx-runtime');var I=_react.createContext.call(void 0, void 0);function M({children:e,address:n,defaultChainId:o}){return _jsxruntime.jsx.call(void 0, I.Provider,{value:{address:n,defaultChainId:o},children:e})}function E(){let e=_react.useContext.call(void 0, I);if(!e)throw new Error("LightweightAccountContext not found");let{address:n,defaultChainId:o}=e;return{isConnected:!!n,address:n,defaultChainId:o}}var _immutable = require('swr/immutable'); var _immutable2 = _interopRequireDefault(_immutable);var _ens = require('viem/ens');var _thirdweb = require('thirdweb');var _react3 = require('thirdweb/react');function L({config:e,theme:n,chains:o,chain:t,publicJsonRpcUrl:l=t.rpcUrls.default.http[0]}){let{connectors:b,connect:w}=_wagmi.useConnect.call(void 0, ),a=_react3.useActiveWallet.call(void 0, ),s=_react3.useActiveAccount.call(void 0, ),{disconnect:A}=_react3.useDisconnect.call(void 0, ),{data:C}=_react3.useWalletInfo.call(void 0, _optionalChain([a, 'optionalAccess', _2 => _2.id])),{data:m}=_react3.useProfiles.call(void 0, {client:e.client}),g=_react.useMemo.call(void 0, ()=>_thirdweb.defineChain.call(void 0, {id:t.id,blockExplorers:t.blockExplorers,blockTime:t.blockTime,ensTlds:t.ensTlds,testnet:t.testnet,contracts:t.contracts,nativeCurrency:t.nativeCurrency,name:t.name,rpcUrls:{default:{http:[l]}}}),[l,t]),u={client:e.client,chain:g,wallets:e.wallets};async function p(r){let i=b.find(c=>c.id==="in-app-wallet");if(i){let c={withCapabilities:!0,wallet:r};w({connector:i,chainId:t.id,...c})}else console.error("no tw connector found")}let{isLoading:W}=_react3.useAutoConnect.call(void 0, {...u,onConnect:p}),v=_react.useMemo.call(void 0, ()=>crypto.randomUUID(),[_optionalChain([a, 'optionalAccess', _3 => _3.id]),_optionalChain([s, 'optionalAccess', _4 => _4.address])]),{connect:P}=_react3.useConnectModal.call(void 0, );return{async connect({strategy:r}){if(!e.hasEmbeddedWallets){console.error("useBeraWagmi.connect: this function is not available if embedded wallets are disabled");return}let i=e.wallets.find(c=>c.id==="inApp");if(!i){console.error("useBeraWagmi.connect: no inApp wallet found");return}await i.connect({...u,strategy:r}),await p(i)},async openConnectModal(){let r=await P({...u,wallets:e.wallets,theme:n==="auto"?void 0:n,size:"compact",chains:[g,...o.map(i=>_thirdweb.defineChain.call(void 0, {id:i.id}))]});await p(r)},disconnect(){a&&A(a)},isConnecting:W,connectionId:v,connectorName:_nullishCoalesce(_optionalChain([C, 'optionalAccess', _5 => _5.name]), () => (null)),isEmbeddedWallet:_optionalChain([C, 'optionalAccess', _6 => _6.id])==="inApp",wallet:s,profiles:m,DebugConnectButton(){return _jsxruntime.jsx.call(void 0, _react3.ConnectButton,{...u,connectModal:{size:"compact"},onConnect:r=>p(r)})}}}function f(){let e=_react.useContext.call(void 0, O);if(!e)throw new Error("BeraWagmiContext not found");return e}var O=_react.createContext.call(void 0, void 0);function Se({children:e,config:n,flags:{disableEip5792:o,disable5792Upgrade:t,accountOverride:l}={},theme:b,onSmartAccountRejection:w,chains:a,defaultChain:s,thirdweb:A,publicJsonRpcUrl:C}){let{wallet:m,openConnectModal:g,connect:u,DebugConnectButton:p,connectionId:W,disconnect:v,connectorName:P,isEmbeddedWallet:r,profiles:i,isConnecting:c}=L({config:n,theme:b,chains:a,chain:s,publicJsonRpcUrl:C}),{address:y,chainId:B}=_wagmi.useAccount.call(void 0, ),{disconnect:S}=_wagmi.useDisconnect.call(void 0, ),_=_wagmi.usePublicClient.call(void 0, ),d=_react.useMemo.call(void 0, ()=>{if(!(!y||!m))return _nullishCoalesce(l, () => (y))},[l,y,m]),{data:h}=_wagmi.useEnsName.call(void 0, {config:n.wagmi,chainId:s.id,address:d}),{data:x}=_immutable2.default.call(void 0, d?["BeraWagmiProvider_code",d,B]:null,([F,G,we])=>_optionalChain([_, 'optionalAccess', _7 => _7.getCode, 'call', _8 => _8({address:G})]),{refreshInterval:6e4}),[q,J]=_react.useMemo.call(void 0, ()=>x?x.startsWith("0xef01")?[!1,!0]:[!0,!1]:[!1,!1],[x]),{data:U}=_wagmi.useWalletClient.call(void 0, ),K=_react.useMemo.call(void 0, ()=>{try{return h?_ens.normalize.call(void 0, h):void 0}catch (e2){}},[h]),j=_wagmi.useEnsAvatar.call(void 0, {name:K});return _jsxruntime.jsx.call(void 0, O.Provider,{value:{flags:{disableEip5792:!!o,disable5792Upgrade:!!t},walletClient:U,onSmartAccountRejection:()=>{_optionalChain([w, 'optionalCall', _9 => _9()])},isEmbeddedWalletsEnabled:_nullishCoalesce(A.embeddedWallets, () => (!0)),isConnecting:c,isConnected:!!d&&!!U,DebugConnectButton:p,account:m&&B&&d?{connectionId:W,chainId:B,connectorName:P,isEmbeddedWallet:r,profiles:i,wallet:{address:d,ensName:_nullishCoalesce(_optionalChain([h, 'optionalAccess', _10 => _10.replace, 'call', _11 => _11(".bera",".\u{1F43B}\u26D3\uFE0F")]), () => (null)),ensAvatar:_nullishCoalesce(j.data, () => (null)),has7702Authorization:J,isContract:q}}:void 0,connect:u,openConnectModal:async()=>{console.log("openConnectModal.called"),await g()},disconnect:()=>{S(),v()},chains:a,defaultChainId:s.id},children:_jsxruntime.jsx.call(void 0, M,{address:d,defaultChainId:s.id,children:e})})}function fe(){let{account:e,isConnected:n}=f();return{...e,isConnected:n}}function he({chainId:e}){let{flags:n,account:o}=f(),{data:t}=_wagmi.useCapabilities.call(void 0, {account:_optionalChain([o, 'optionalAccess', _12 => _12.wallet, 'optionalAccess', _13 => _13.address]),scopeKey:_optionalChain([o, 'optionalAccess', _14 => _14.connectionId]),query:{retry:3},chainId:e});return{supportsAtomic:_react.useMemo.call(void 0, ()=>n.disableEip5792||!t?!1:_optionalChain([t, 'optionalAccess', _15 => _15.atomic, 'optionalAccess', _16 => _16.status])==="supported"||!n.disable5792Upgrade&&_optionalChain([t, 'optionalAccess', _17 => _17.atomic, 'optionalAccess', _18 => _18.status])==="ready",[t,n.disableEip5792,n.disable5792Upgrade,e]),capabilities:t}}function Xe(e){let{defaultChainId:n}=E(),{chainId:o,...t}=_nullishCoalesce(e, () => ({}));return _wagmi.usePublicClient.call(void 0, {chainId:_nullishCoalesce(o, () => (n)),...t})}exports.a = E; exports.b = fe; exports.c = he; exports.d = Xe; exports.e = _wagmi.useBlockNumber; exports.f = _wagmi.useChains; exports.g = _wagmi.useConfig; exports.h = _wagmi.useEnsAvatar; exports.i = _wagmi.useEnsName; exports.j = _wagmi.useSwitchChain; exports.k = _wagmi.useTransactionReceipt; exports.l = f; exports.m = Se;
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }var _wagmiadapter = require('@thirdweb-dev/wagmi-adapter');var _thirdweb = require('thirdweb');var _wallets = require('thirdweb/wallets');var _wagmi = require('wagmi');function A({thirdweb:e,transports:i={},defaultChain:n,chains:r=[]}){let o=_thirdweb.createThirdwebClient.call(void 0, {clientId:e.clientId}),s=!!_optionalChain([n, 'access', _ => _.contracts, 'optionalAccess', _2 => _2.multicall3]),a={mode:"EIP7702",sponsorGas:e.sponsorGas},d=_wallets.inAppWallet.call(void 0, {executionMode:a,auth:{options:["google","apple"],mode:"popup"}}),l=[..._wallets.getInstalledWallets.call(void 0, ),_wallets.createWallet.call(void 0, "io.rabby"),_wallets.createWallet.call(void 0, "io.metamask"),_wallets.createWallet.call(void 0, "com.coinbase.wallet"),_wallets.createWallet.call(void 0, "walletConnect")].filter((p,c,m)=>m.findIndex(f=>f.id===p.id)===c);return{hasEmbeddedWallets:e.embeddedWallets,wallets:e.embeddedWallets?[d,...l]:l,executionMode:a,client:o,wagmi:_wagmi.createConfig.call(void 0, {chains:[n,...r],ssr:!0,connectors:[_wagmiadapter.inAppWalletConnector.call(void 0, {client:o,executionMode:a})],storage:_wagmi.createStorage.call(void 0, {key:"wagmi-berachain-thirdweb",storage:typeof window<"u"?localStorage:void 0}),batch:{multicall:s?{wait:15}:void 0},transports:i})}}exports.a = A;
@@ -0,0 +1 @@
1
+ import{usePublicClient as be}from"wagmi";import{useContext as V}from"react";import{createContext as H}from"react";import{jsx as Q}from"react/jsx-runtime";var I=H(void 0);function M({children:e,address:n,defaultChainId:o}){return Q(I.Provider,{value:{address:n,defaultChainId:o},children:e})}function E(){let e=V(I);if(!e)throw new Error("LightweightAccountContext not found");let{address:n,defaultChainId:o}=e;return{isConnected:!!n,address:n,defaultChainId:o}}import{useBlockNumber as $e,useChains as et,useConfig as tt,useEnsAvatar as z,useEnsName as D,useSwitchChain as nt,useTransactionReceipt as ot}from"wagmi";import{createContext as ae,useContext as se,useMemo as T}from"react";import ce from"swr/immutable";import{normalize as de}from"viem/ens";import{useAccount as le,useDisconnect as ue,usePublicClient as pe,useWalletClient as me}from"wagmi";import{useMemo as N}from"react";import{defineChain as R}from"thirdweb";import{ConnectButton as X,useActiveAccount as Y,useActiveWallet as Z,useAutoConnect as $,useProfiles as ee,useConnectModal as te,useDisconnect as ne,useWalletInfo as oe}from"thirdweb/react";import{useConnect as ie}from"wagmi";import{jsx as re}from"react/jsx-runtime";function L({config:e,theme:n,chains:o,chain:t,publicJsonRpcUrl:l=t.rpcUrls.default.http[0]}){let{connectors:b,connect:w}=ie(),a=Z(),s=Y(),{disconnect:A}=ne(),{data:C}=oe(a?.id),{data:m}=ee({client:e.client}),g=N(()=>R({id:t.id,blockExplorers:t.blockExplorers,blockTime:t.blockTime,ensTlds:t.ensTlds,testnet:t.testnet,contracts:t.contracts,nativeCurrency:t.nativeCurrency,name:t.name,rpcUrls:{default:{http:[l]}}}),[l,t]),u={client:e.client,chain:g,wallets:e.wallets};async function p(r){let i=b.find(c=>c.id==="in-app-wallet");if(i){let c={withCapabilities:!0,wallet:r};w({connector:i,chainId:t.id,...c})}else console.error("no tw connector found")}let{isLoading:W}=$({...u,onConnect:p}),v=N(()=>crypto.randomUUID(),[a?.id,s?.address]),{connect:P}=te();return{async connect({strategy:r}){if(!e.hasEmbeddedWallets){console.error("useBeraWagmi.connect: this function is not available if embedded wallets are disabled");return}let i=e.wallets.find(c=>c.id==="inApp");if(!i){console.error("useBeraWagmi.connect: no inApp wallet found");return}await i.connect({...u,strategy:r}),await p(i)},async openConnectModal(){let r=await P({...u,wallets:e.wallets,theme:n==="auto"?void 0:n,size:"compact",chains:[g,...o.map(i=>R({id:i.id}))]});await p(r)},disconnect(){a&&A(a)},isConnecting:W,connectionId:v,connectorName:C?.name??null,isEmbeddedWallet:C?.id==="inApp",wallet:s,profiles:m,DebugConnectButton(){return re(X,{...u,connectModal:{size:"compact"},onConnect:r=>p(r)})}}}import{jsx as k}from"react/jsx-runtime";function f(){let e=se(O);if(!e)throw new Error("BeraWagmiContext not found");return e}var O=ae(void 0);function Se({children:e,config:n,flags:{disableEip5792:o,disable5792Upgrade:t,accountOverride:l}={},theme:b,onSmartAccountRejection:w,chains:a,defaultChain:s,thirdweb:A,publicJsonRpcUrl:C}){let{wallet:m,openConnectModal:g,connect:u,DebugConnectButton:p,connectionId:W,disconnect:v,connectorName:P,isEmbeddedWallet:r,profiles:i,isConnecting:c}=L({config:n,theme:b,chains:a,chain:s,publicJsonRpcUrl:C}),{address:y,chainId:B}=le(),{disconnect:S}=ue(),_=pe(),d=T(()=>{if(!(!y||!m))return l??y},[l,y,m]),{data:h}=D({config:n.wagmi,chainId:s.id,address:d}),{data:x}=ce(d?["BeraWagmiProvider_code",d,B]:null,([F,G,we])=>_?.getCode({address:G}),{refreshInterval:6e4}),[q,J]=T(()=>x?x.startsWith("0xef01")?[!1,!0]:[!0,!1]:[!1,!1],[x]),{data:U}=me(),K=T(()=>{try{return h?de(h):void 0}catch{}},[h]),j=z({name:K});return k(O.Provider,{value:{flags:{disableEip5792:!!o,disable5792Upgrade:!!t},walletClient:U,onSmartAccountRejection:()=>{w?.()},isEmbeddedWalletsEnabled:A.embeddedWallets??!0,isConnecting:c,isConnected:!!d&&!!U,DebugConnectButton:p,account:m&&B&&d?{connectionId:W,chainId:B,connectorName:P,isEmbeddedWallet:r,profiles:i,wallet:{address:d,ensName:h?.replace(".bera",".\u{1F43B}\u26D3\uFE0F")??null,ensAvatar:j.data??null,has7702Authorization:J,isContract:q}}:void 0,connect:u,openConnectModal:async()=>{console.log("openConnectModal.called"),await g()},disconnect:()=>{S(),v()},chains:a,defaultChainId:s.id},children:k(M,{address:d,defaultChainId:s.id,children:e})})}function fe(){let{account:e,isConnected:n}=f();return{...e,isConnected:n}}import{useMemo as Ce}from"react";import{useCapabilities as ge}from"wagmi";function he({chainId:e}){let{flags:n,account:o}=f(),{data:t}=ge({account:o?.wallet?.address,scopeKey:o?.connectionId,query:{retry:3},chainId:e});return{supportsAtomic:Ce(()=>n.disableEip5792||!t?!1:t?.atomic?.status==="supported"||!n.disable5792Upgrade&&t?.atomic?.status==="ready",[t,n.disableEip5792,n.disable5792Upgrade,e]),capabilities:t}}function Xe(e){let{defaultChainId:n}=E(),{chainId:o,...t}=e??{};return be({chainId:o??n,...t})}export{E as a,fe as b,he as c,Xe as d,$e as e,et as f,tt as g,z as h,D as i,nt as j,ot as k,f as l,Se as m};
@@ -0,0 +1 @@
1
+ import{inAppWalletConnector as g}from"@thirdweb-dev/wagmi-adapter";import{createThirdwebClient as C}from"thirdweb";import{createWallet as t,getInstalledWallets as u,inAppWallet as W}from"thirdweb/wallets";import{createConfig as b,createStorage as h}from"wagmi";function A({thirdweb:e,transports:i={},defaultChain:n,chains:r=[]}){let o=C({clientId:e.clientId}),s=!!n.contracts?.multicall3,a={mode:"EIP7702",sponsorGas:e.sponsorGas},d=W({executionMode:a,auth:{options:["google","apple"],mode:"popup"}}),l=[...u(),t("io.rabby"),t("io.metamask"),t("com.coinbase.wallet"),t("walletConnect")].filter((p,c,m)=>m.findIndex(f=>f.id===p.id)===c);return{hasEmbeddedWallets:e.embeddedWallets,wallets:e.embeddedWallets?[d,...l]:l,executionMode:a,client:o,wagmi:b({chains:[n,...r],ssr:!0,connectors:[g({client:o,executionMode:a})],storage:h({key:"wagmi-berachain-thirdweb",storage:typeof window<"u"?localStorage:void 0}),batch:{multicall:s?{wait:15}:void 0},transports:i})}}export{A as a};
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkSMQG24G3cjs = require('../chunk-SMQG24G3.cjs');exports.getConfig = _chunkSMQG24G3cjs.a;
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkHDH4V7DJcjs = require('../chunk-HDH4V7DJ.cjs');exports.getConfig = _chunkHDH4V7DJcjs.a;
@@ -1,5 +1,5 @@
1
1
  import * as thirdweb from 'thirdweb';
2
- import * as thirdweb_wallets from 'thirdweb/wallets';
2
+ import { Wallet } from 'thirdweb/wallets';
3
3
  import { Transport, Chain } from 'viem';
4
4
  import { Config } from 'wagmi';
5
5
 
@@ -16,7 +16,7 @@ interface BeraWagmiConfig {
16
16
  }
17
17
  declare function getConfig({ thirdweb, transports, defaultChain: chain, chains, }: BeraWagmiConfig): {
18
18
  hasEmbeddedWallets: boolean | undefined;
19
- wallets: thirdweb_wallets.Wallet[];
19
+ wallets: Wallet[];
20
20
  executionMode: {
21
21
  readonly mode: "EIP7702";
22
22
  readonly sponsorGas: boolean | undefined;
@@ -1,5 +1,5 @@
1
1
  import * as thirdweb from 'thirdweb';
2
- import * as thirdweb_wallets from 'thirdweb/wallets';
2
+ import { Wallet } from 'thirdweb/wallets';
3
3
  import { Transport, Chain } from 'viem';
4
4
  import { Config } from 'wagmi';
5
5
 
@@ -16,7 +16,7 @@ interface BeraWagmiConfig {
16
16
  }
17
17
  declare function getConfig({ thirdweb, transports, defaultChain: chain, chains, }: BeraWagmiConfig): {
18
18
  hasEmbeddedWallets: boolean | undefined;
19
- wallets: thirdweb_wallets.Wallet[];
19
+ wallets: Wallet[];
20
20
  executionMode: {
21
21
  readonly mode: "EIP7702";
22
22
  readonly sponsorGas: boolean | undefined;
@@ -1 +1 @@
1
- import{a as o}from"../chunk-CO26JY24.mjs";export{o as getConfig};
1
+ import{a as o}from"../chunk-YD5OWUSZ.mjs";export{o as getConfig};
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true});"use client";var _chunkSMQG24G3cjs = require('../chunk-SMQG24G3.cjs');var _chunkMAZOXXPJcjs = require('../chunk-MAZOXXPJ.cjs');var _react = require('react');var _reactquery = require('@tanstack/react-query');var _react3 = require('thirdweb/react');var _wagmi = require('wagmi');var _jsxruntime = require('react/jsx-runtime');var u=new _reactquery.QueryClient;function h({transports:n,defaultChain:e,chains:i,thirdweb:o,...f}){let t=_react.useMemo.call(void 0, ()=>_chunkSMQG24G3cjs.a.call(void 0, {thirdweb:o,transports:n,defaultChain:e,chains:i}),[e,o,n,i]);return _jsxruntime.jsx.call(void 0, _react3.ThirdwebProvider,{children:_jsxruntime.jsx.call(void 0, _wagmi.WagmiProvider,{config:t.wagmi,reconnectOnMount:!1,children:_jsxruntime.jsx.call(void 0, _reactquery.QueryClientProvider,{client:u,children:_jsxruntime.jsx.call(void 0, _chunkMAZOXXPJcjs.m,{...f,thirdweb:o,chains:i,defaultChain:e,config:t})})})})}exports.WagmiProvider = h;
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});"use client";var _chunkHDH4V7DJcjs = require('../chunk-HDH4V7DJ.cjs');var _chunk63VDHYYBcjs = require('../chunk-63VDHYYB.cjs');var _react = require('react');var _reactquery = require('@tanstack/react-query');var _react3 = require('thirdweb/react');var _wagmi = require('wagmi');var _jsxruntime = require('react/jsx-runtime');var u=new _reactquery.QueryClient;function h({transports:n,defaultChain:e,chains:i,thirdweb:o,...f}){let t=_react.useMemo.call(void 0, ()=>_chunkHDH4V7DJcjs.a.call(void 0, {thirdweb:o,transports:n,defaultChain:e,chains:i}),[e,o,n,i]);return _jsxruntime.jsx.call(void 0, _react3.ThirdwebProvider,{children:_jsxruntime.jsx.call(void 0, _wagmi.WagmiProvider,{config:t.wagmi,reconnectOnMount:!1,children:_jsxruntime.jsx.call(void 0, _reactquery.QueryClientProvider,{client:u,children:_jsxruntime.jsx.call(void 0, _chunk63VDHYYBcjs.m,{...f,thirdweb:o,chains:i,defaultChain:e,config:t})})})})}exports.WagmiProvider = h;
@@ -1,11 +1,11 @@
1
1
  import * as react_jsx_runtime from 'react/jsx-runtime';
2
2
  import { Transport, Chain } from 'viem';
3
- import { I as IBeraWagmiProviderProps } from '../BeraWagmi-CGaPo4Jy.cjs';
3
+ import { I as IBeraWagmiProviderProps } from '../BeraWagmi-LchnqEU8.cjs';
4
4
  import 'react';
5
+ import 'thirdweb/wallets';
5
6
  import 'wagmi';
6
7
  import '../config/index.cjs';
7
8
  import 'thirdweb';
8
- import 'thirdweb/wallets';
9
9
 
10
10
  type WagmiProviderProps = Omit<IBeraWagmiProviderProps, "config" | "defaultChain"> & {
11
11
  transports?: Record<number, Transport>;
@@ -1,11 +1,11 @@
1
1
  import * as react_jsx_runtime from 'react/jsx-runtime';
2
2
  import { Transport, Chain } from 'viem';
3
- import { I as IBeraWagmiProviderProps } from '../BeraWagmi-DygXBvcd.js';
3
+ import { I as IBeraWagmiProviderProps } from '../BeraWagmi-hVislkpK.js';
4
4
  import 'react';
5
+ import 'thirdweb/wallets';
5
6
  import 'wagmi';
6
7
  import '../config/index.js';
7
8
  import 'thirdweb';
8
- import 'thirdweb/wallets';
9
9
 
10
10
  type WagmiProviderProps = Omit<IBeraWagmiProviderProps, "config" | "defaultChain"> & {
11
11
  transports?: Record<number, Transport>;
@@ -1 +1 @@
1
- "use client";import{a as m}from"../chunk-CO26JY24.mjs";import{m as a}from"../chunk-FTYFPKMT.mjs";import{useMemo as p}from"react";import{QueryClient as d,QueryClientProvider as g}from"@tanstack/react-query";import{ThirdwebProvider as s}from"thirdweb/react";import{WagmiProvider as P}from"wagmi";import{jsx as r}from"react/jsx-runtime";var u=new d;function h({transports:n,defaultChain:e,chains:i,thirdweb:o,...f}){let t=p(()=>m({thirdweb:o,transports:n,defaultChain:e,chains:i}),[e,o,n,i]);return r(s,{children:r(P,{config:t.wagmi,reconnectOnMount:!1,children:r(g,{client:u,children:r(a,{...f,thirdweb:o,chains:i,defaultChain:e,config:t})})})})}export{h as WagmiProvider};
1
+ "use client";import{a as m}from"../chunk-YD5OWUSZ.mjs";import{m as a}from"../chunk-LNXUPM6A.mjs";import{useMemo as p}from"react";import{QueryClient as d,QueryClientProvider as g}from"@tanstack/react-query";import{ThirdwebProvider as s}from"thirdweb/react";import{WagmiProvider as P}from"wagmi";import{jsx as r}from"react/jsx-runtime";var u=new d;function h({transports:n,defaultChain:e,chains:i,thirdweb:o,...f}){let t=p(()=>m({thirdweb:o,transports:n,defaultChain:e,chains:i}),[e,o,n,i]);return r(s,{children:r(P,{config:t.wagmi,reconnectOnMount:!1,children:r(g,{client:u,children:r(a,{...f,thirdweb:o,chains:i,defaultChain:e,config:t})})})})}export{h as WagmiProvider};
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkMAZOXXPJcjs = require('../chunk-MAZOXXPJ.cjs');exports.useBeraAccount = _chunkMAZOXXPJcjs.b; exports.useBeraWagmi = _chunkMAZOXXPJcjs.l; exports.useBeraWallet = _chunkMAZOXXPJcjs.a; exports.useBlockNumber = _chunkMAZOXXPJcjs.e; exports.useCapabilities = _chunkMAZOXXPJcjs.c; exports.useChains = _chunkMAZOXXPJcjs.f; exports.useConfig = _chunkMAZOXXPJcjs.g; exports.useEnsAvatar = _chunkMAZOXXPJcjs.h; exports.useEnsName = _chunkMAZOXXPJcjs.i; exports.usePublicClient = _chunkMAZOXXPJcjs.d; exports.useSwitchChain = _chunkMAZOXXPJcjs.j; exports.useTransactionReceipt = _chunkMAZOXXPJcjs.k;
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunk63VDHYYBcjs = require('../chunk-63VDHYYB.cjs');exports.useBeraAccount = _chunk63VDHYYBcjs.b; exports.useBeraWagmi = _chunk63VDHYYBcjs.l; exports.useBeraWallet = _chunk63VDHYYBcjs.a; exports.useBlockNumber = _chunk63VDHYYBcjs.e; exports.useCapabilities = _chunk63VDHYYBcjs.c; exports.useChains = _chunk63VDHYYBcjs.f; exports.useConfig = _chunk63VDHYYBcjs.g; exports.useEnsAvatar = _chunk63VDHYYBcjs.h; exports.useEnsName = _chunk63VDHYYBcjs.i; exports.usePublicClient = _chunk63VDHYYBcjs.d; exports.useSwitchChain = _chunk63VDHYYBcjs.j; exports.useTransactionReceipt = _chunk63VDHYYBcjs.k;
@@ -1,12 +1,12 @@
1
1
  import { UsePublicClientParameters, UsePublicClientReturnType } from 'wagmi';
2
2
  export { useBlockNumber, useChains, useConfig, useEnsAvatar, useEnsName, useSwitchChain, useTransactionReceipt } from 'wagmi';
3
- import { B as BeraWagmiApi, C as ChainId } from '../BeraWagmi-CGaPo4Jy.cjs';
4
- export { u as useBeraWagmi } from '../BeraWagmi-CGaPo4Jy.cjs';
3
+ import { B as BeraWagmiApi, C as ChainId } from '../BeraWagmi-LchnqEU8.cjs';
4
+ export { u as useBeraWagmi } from '../BeraWagmi-LchnqEU8.cjs';
5
5
  import 'react';
6
+ import 'thirdweb/wallets';
6
7
  import 'viem';
7
8
  import '../config/index.cjs';
8
9
  import 'thirdweb';
9
- import 'thirdweb/wallets';
10
10
 
11
11
  declare function useBeraAccount(): Partial<NonNullable<BeraWagmiApi["account"]>> & {
12
12
  isConnected: boolean;
@@ -1,12 +1,12 @@
1
1
  import { UsePublicClientParameters, UsePublicClientReturnType } from 'wagmi';
2
2
  export { useBlockNumber, useChains, useConfig, useEnsAvatar, useEnsName, useSwitchChain, useTransactionReceipt } from 'wagmi';
3
- import { B as BeraWagmiApi, C as ChainId } from '../BeraWagmi-DygXBvcd.js';
4
- export { u as useBeraWagmi } from '../BeraWagmi-DygXBvcd.js';
3
+ import { B as BeraWagmiApi, C as ChainId } from '../BeraWagmi-hVislkpK.js';
4
+ export { u as useBeraWagmi } from '../BeraWagmi-hVislkpK.js';
5
5
  import 'react';
6
+ import 'thirdweb/wallets';
6
7
  import 'viem';
7
8
  import '../config/index.js';
8
9
  import 'thirdweb';
9
- import 'thirdweb/wallets';
10
10
 
11
11
  declare function useBeraAccount(): Partial<NonNullable<BeraWagmiApi["account"]>> & {
12
12
  isConnected: boolean;
@@ -1 +1 @@
1
- import{a,b,c,d,e,f,g,h,i,j,k,l}from"../chunk-FTYFPKMT.mjs";export{b as useBeraAccount,l as useBeraWagmi,a as useBeraWallet,e as useBlockNumber,c as useCapabilities,f as useChains,g as useConfig,h as useEnsAvatar,i as useEnsName,d as usePublicClient,j as useSwitchChain,k as useTransactionReceipt};
1
+ import{a,b,c,d,e,f,g,h,i,j,k,l}from"../chunk-LNXUPM6A.mjs";export{b as useBeraAccount,l as useBeraWagmi,a as useBeraWallet,e as useBlockNumber,c as useCapabilities,f as useChains,g as useConfig,h as useEnsAvatar,i as useEnsName,d as usePublicClient,j as useSwitchChain,k as useTransactionReceipt};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@berachain/wagmi",
3
- "version": "0.4.0-beta.2",
3
+ "version": "0.4.0-beta.4",
4
4
  "type": "module",
5
5
  "files": [
6
6
  "dist",
@@ -5,6 +5,7 @@ import {
5
5
  getInstalledWallets,
6
6
  type InAppWalletCreationOptions,
7
7
  inAppWallet,
8
+ type Wallet,
8
9
  } from "thirdweb/wallets";
9
10
  import type { Chain, Transport } from "viem";
10
11
  import { type Config, createConfig, createStorage } from "wagmi";
@@ -41,10 +42,14 @@ export function getConfig({
41
42
 
42
43
  const thirdwebWallet: ReturnType<typeof inAppWallet> = inAppWallet({
43
44
  executionMode,
45
+ auth: {
46
+ options: ["google", "apple"],
47
+ mode: "popup",
48
+ },
44
49
  });
45
50
 
46
51
  const installedWallets = getInstalledWallets();
47
- const wallets = [
52
+ const wallets: Wallet[] = [
48
53
  ...installedWallets,
49
54
  createWallet("io.rabby"),
50
55
  createWallet("io.metamask"),
@@ -5,6 +5,7 @@ import {
5
5
  useMemo,
6
6
  } from "react";
7
7
  import useSWRImmutable from "swr/immutable";
8
+ import type { Profile, WalletConnectionOption } from "thirdweb/wallets";
8
9
  import type { Address, Chain } from "viem";
9
10
  import { normalize } from "viem/ens";
10
11
  import {
@@ -31,7 +32,7 @@ export interface BeraWagmiApi {
31
32
  /**
32
33
  * @deprecated used for prototyping only.
33
34
  */
34
- DebugConnectButton: () => React.ReactNode;
35
+ DebugConnectButton(): React.ReactNode;
35
36
  /**
36
37
  * Account connected to berachain dapp. It might include some additional data once embedded wallets are enabled.
37
38
  */
@@ -47,6 +48,7 @@ export interface BeraWagmiApi {
47
48
  isEmbeddedWallet: boolean;
48
49
  connectorName: string | null;
49
50
  connectionId: string;
51
+ profiles: Profile[] | undefined;
50
52
  /**
51
53
  * Wallet to display.
52
54
  *
@@ -63,7 +65,6 @@ export interface BeraWagmiApi {
63
65
  * ENS avatar of the wallet.
64
66
  */
65
67
  ensAvatar: string | null;
66
-
67
68
  /**
68
69
  * Whether the wallet has 7702 authorization.
69
70
  */
@@ -84,24 +85,20 @@ export interface BeraWagmiApi {
84
85
  disable5792Upgrade: boolean;
85
86
  };
86
87
  walletClient: UseWalletClientReturnType["data"];
87
- openConnectModal: () => Promise<void> | void;
88
+ openConnectModal(): Promise<void> | void;
88
89
  /**
89
90
  * Connects a wallet using a specific strategy.
90
- *
91
- * @param strategy - The strategy to use to connect the wallet.
92
91
  */
93
- connect: ({
94
- strategy,
95
- }: {
96
- strategy: "google" | "apple";
97
- }) => Promise<void> | void;
92
+ connect(
93
+ args: Omit<WalletConnectionOption<"inApp">, "client">,
94
+ ): Promise<void> | void;
98
95
  disconnect(): void;
99
96
  /**
100
97
  * A callback that is called when a smart account upgrade is rejected.
101
98
  *
102
99
  * This is used to disable EIP-5792 temporarily.
103
100
  */
104
- onSmartAccountRejection: () => void;
101
+ onSmartAccountRejection(): void;
105
102
  /**
106
103
  * List of external chains that are whitelisted for that app.
107
104
  */
@@ -166,6 +163,7 @@ export function BeraWagmiProvider({
166
163
  disconnect: disconnectProvider,
167
164
  connectorName,
168
165
  isEmbeddedWallet,
166
+ profiles,
169
167
  isConnecting,
170
168
  } = useThirdweb({
171
169
  config,
@@ -262,6 +260,7 @@ export function BeraWagmiProvider({
262
260
  chainId,
263
261
  connectorName,
264
262
  isEmbeddedWallet,
263
+ profiles,
265
264
  wallet: {
266
265
  address,
267
266
  ensName: ens?.replace(".bera", ".🐻⛓️") ?? null,
@@ -6,15 +6,22 @@ import {
6
6
  useActiveAccount,
7
7
  useActiveWallet,
8
8
  useAutoConnect,
9
+ useProfiles,
9
10
  useConnectModal as useTwConnectModal,
10
11
  useDisconnect as useTwDisconnect,
11
12
  useWalletInfo,
12
13
  } from "thirdweb/react";
13
- import type { AutoConnectProps, Wallet } from "thirdweb/wallets";
14
+ import type {
15
+ Account,
16
+ AutoConnectProps,
17
+ Profile,
18
+ Wallet,
19
+ } from "thirdweb/wallets";
14
20
  import type { Chain } from "viem";
15
21
  import { useConnect } from "wagmi";
16
22
 
17
23
  import type { getConfig } from "~/config";
24
+ import type { BeraWagmiApi } from "./BeraWagmi";
18
25
 
19
26
  export function useThirdweb({
20
27
  config,
@@ -28,7 +35,20 @@ export function useThirdweb({
28
35
  chains: Chain[];
29
36
  publicJsonRpcUrl?: string;
30
37
  chain: Chain;
31
- }) {
38
+ }): Pick<
39
+ BeraWagmiApi,
40
+ | "connect"
41
+ | "openConnectModal"
42
+ | "disconnect"
43
+ | "isConnecting"
44
+ | "DebugConnectButton"
45
+ > & {
46
+ connectionId: string;
47
+ connectorName: string | null;
48
+ isEmbeddedWallet: boolean;
49
+ wallet: Account | undefined;
50
+ profiles: Profile[] | undefined;
51
+ } {
32
52
  const { connectors, connect: wagmiConnect } = useConnect();
33
53
 
34
54
  const activeWallet = useActiveWallet();
@@ -36,6 +56,8 @@ export function useThirdweb({
36
56
  const { disconnect: disconnectThirdweb } = useTwDisconnect();
37
57
  const { data: walletInfo } = useWalletInfo(activeWallet?.id);
38
58
 
59
+ const { data: profiles } = useProfiles({ client: config.client });
60
+
39
61
  const thirdwebChain = useMemo(
40
62
  () =>
41
63
  defineChain({
@@ -97,7 +119,7 @@ export function useThirdweb({
97
119
  const { connect: twConnectModal } = useTwConnectModal();
98
120
 
99
121
  return {
100
- async connect({ strategy }: { strategy: "google" | "apple" }) {
122
+ async connect({ strategy }) {
101
123
  if (!config.hasEmbeddedWallets) {
102
124
  console.error(
103
125
  "useBeraWagmi.connect: this function is not available if embedded wallets are disabled",
@@ -113,9 +135,8 @@ export function useThirdweb({
113
135
  }
114
136
 
115
137
  await wallet.connect({
138
+ ...connectOptions,
116
139
  strategy,
117
- client: config.client,
118
- chain: thirdwebChain,
119
140
  });
120
141
  await syncConnectedWallet(wallet);
121
142
  },
@@ -147,6 +168,7 @@ export function useThirdweb({
147
168
  connectorName: walletInfo?.name ?? null,
148
169
  isEmbeddedWallet: walletInfo?.id === "inApp",
149
170
  wallet: activeAccount,
171
+ profiles,
150
172
  DebugConnectButton() {
151
173
  return (
152
174
  <ConnectButton
@@ -1 +0,0 @@
1
- import{inAppWalletConnector as g}from"@thirdweb-dev/wagmi-adapter";import{createThirdwebClient as C}from"thirdweb";import{createWallet as t,getInstalledWallets as b,inAppWallet as u}from"thirdweb/wallets";import{createConfig as W,createStorage as h}from"wagmi";function A({thirdweb:e,transports:l={},defaultChain:a,chains:r=[]}){let o=C({clientId:e.clientId}),s=!!a.contracts?.multicall3,n={mode:"EIP7702",sponsorGas:e.sponsorGas},d=u({executionMode:n}),i=[...b(),t("io.rabby"),t("io.metamask"),t("com.coinbase.wallet"),t("walletConnect")].filter((c,p,f)=>f.findIndex(m=>m.id===c.id)===p);return{hasEmbeddedWallets:e.embeddedWallets,wallets:e.embeddedWallets?[d,...i]:i,executionMode:n,client:o,wagmi:W({chains:[a,...r],ssr:!0,connectors:[g({client:o,executionMode:n})],storage:h({key:"wagmi-berachain-thirdweb",storage:typeof window<"u"?localStorage:void 0}),batch:{multicall:s?{wait:15}:void 0},transports:l})}}export{A as a};
@@ -1 +0,0 @@
1
- import{usePublicClient as ge}from"wagmi";import{useContext as Q}from"react";import{createContext as G}from"react";import{jsx as H}from"react/jsx-runtime";var B=G(void 0);function U({children:e,address:n,defaultChainId:o}){return H(B.Provider,{value:{address:n,defaultChainId:o},children:e})}function I(){let e=Q(B);if(!e)throw new Error("LightweightAccountContext not found");let{address:n,defaultChainId:o}=e;return{isConnected:!!n,address:n,defaultChainId:o}}import{useBlockNumber as Ye,useChains as Ze,useConfig as $e,useEnsAvatar as z,useEnsName as k,useSwitchChain as et,useTransactionReceipt as tt}from"wagmi";import{createContext as ie,useContext as ae,useMemo as E}from"react";import re from"swr/immutable";import{normalize as se}from"viem/ens";import{useAccount as ce,useDisconnect as de,usePublicClient as le,useWalletClient as ue}from"wagmi";import{useMemo as R}from"react";import{defineChain as M}from"thirdweb";import{ConnectButton as V,useActiveAccount as X,useActiveWallet as Y,useAutoConnect as Z,useConnectModal as $,useDisconnect as ee,useWalletInfo as te}from"thirdweb/react";import{useConnect as ne}from"wagmi";import{jsx as oe}from"react/jsx-runtime";function N({config:e,theme:n,chains:o,chain:t,publicJsonRpcUrl:u=t.rpcUrls.default.http[0]}){let{connectors:h,connect:b}=ne(),r=Y(),s=X(),{disconnect:w}=ee(),{data:C}=te(r?.id),c=R(()=>M({id:t.id,blockExplorers:t.blockExplorers,blockTime:t.blockTime,ensTlds:t.ensTlds,testnet:t.testnet,contracts:t.contracts,nativeCurrency:t.nativeCurrency,name:t.name,rpcUrls:{default:{http:[u]}}}),[u,t]),m={client:e.client,chain:c,wallets:e.wallets};async function p(a){let i=h.find(d=>d.id==="in-app-wallet");if(i){let d={withCapabilities:!0,wallet:a};b({connector:i,chainId:t.id,...d})}else console.error("no tw connector found")}let{isLoading:A}=Z({...m,onConnect:p}),W=R(()=>crypto.randomUUID(),[r?.id,s?.address]),{connect:v}=$();return{async connect({strategy:a}){if(!e.hasEmbeddedWallets){console.error("useBeraWagmi.connect: this function is not available if embedded wallets are disabled");return}let i=e.wallets.find(d=>d.id==="inApp");if(!i){console.error("useBeraWagmi.connect: no inApp wallet found");return}await i.connect({strategy:a,client:e.client,chain:c}),await p(i)},async openConnectModal(){let a=await v({...m,wallets:e.wallets,theme:n==="auto"?void 0:n,size:"compact",chains:[c,...o.map(i=>M({id:i.id}))]});await p(a)},disconnect(){r&&w(r)},isConnecting:A,connectionId:W,connectorName:C?.name??null,isEmbeddedWallet:C?.id==="inApp",wallet:s,DebugConnectButton(){return oe(V,{...m,connectModal:{size:"compact"},onConnect:a=>p(a)})}}}import{jsx as L}from"react/jsx-runtime";function f(){let e=ae(D);if(!e)throw new Error("BeraWagmiContext not found");return e}var D=ie(void 0);function De({children:e,config:n,flags:{disableEip5792:o,disable5792Upgrade:t,accountOverride:u}={},theme:h,onSmartAccountRejection:b,chains:r,defaultChain:s,thirdweb:w,publicJsonRpcUrl:C}){let{wallet:c,openConnectModal:m,connect:p,DebugConnectButton:A,connectionId:W,disconnect:v,connectorName:a,isEmbeddedWallet:i,isConnecting:d}=N({config:n,theme:h,chains:r,chain:s,publicJsonRpcUrl:C}),{address:y,chainId:P}=ce(),{disconnect:S}=de(),O=le(),l=E(()=>{if(!(!y||!c))return u??y},[u,y,c]),{data:g}=k({config:n.wagmi,chainId:s.id,address:l}),{data:x}=re(l?["BeraWagmiProvider_code",l,P]:null,([j,F,he])=>O?.getCode({address:F}),{refreshInterval:6e4}),[_,q]=E(()=>x?x.startsWith("0xef01")?[!1,!0]:[!0,!1]:[!1,!1],[x]),{data:T}=ue(),J=E(()=>{try{return g?se(g):void 0}catch{}},[g]),K=z({name:J});return L(D.Provider,{value:{flags:{disableEip5792:!!o,disable5792Upgrade:!!t},walletClient:T,onSmartAccountRejection:()=>{b?.()},isEmbeddedWalletsEnabled:w.embeddedWallets??!0,isConnecting:d,isConnected:!!l&&!!T,DebugConnectButton:A,account:c&&P&&l?{connectionId:W,chainId:P,connectorName:a,isEmbeddedWallet:i,wallet:{address:l,ensName:g?.replace(".bera",".\u{1F43B}\u26D3\uFE0F")??null,ensAvatar:K.data??null,has7702Authorization:q,isContract:_}}:void 0,connect:p,openConnectModal:async()=>{console.log("openConnectModal.called"),await m()},disconnect:()=>{S(),v()},chains:r,defaultChainId:s.id},children:L(U,{address:l,defaultChainId:s.id,children:e})})}function pe(){let{account:e,isConnected:n}=f();return{...e,isConnected:n}}import{useMemo as me}from"react";import{useCapabilities as fe}from"wagmi";function Ce({chainId:e}){let{flags:n,account:o}=f(),{data:t}=fe({account:o?.wallet?.address,scopeKey:o?.connectionId,query:{retry:3},chainId:e});return{supportsAtomic:me(()=>n.disableEip5792||!t?!1:t?.atomic?.status==="supported"||!n.disable5792Upgrade&&t?.atomic?.status==="ready",[t,n.disableEip5792,n.disable5792Upgrade,e]),capabilities:t}}function Qe(e){let{defaultChainId:n}=I(),{chainId:o,...t}=e??{};return ge({chainId:o??n,...t})}export{I as a,pe as b,Ce as c,Qe as d,Ye as e,Ze as f,$e as g,z as h,k as i,et as j,tt as k,f as l,De as m};
@@ -1 +0,0 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }var _wagmi = require('wagmi');var _react = require('react');var _jsxruntime = require('react/jsx-runtime');var B=_react.createContext.call(void 0, void 0);function U({children:e,address:n,defaultChainId:o}){return _jsxruntime.jsx.call(void 0, B.Provider,{value:{address:n,defaultChainId:o},children:e})}function I(){let e=_react.useContext.call(void 0, B);if(!e)throw new Error("LightweightAccountContext not found");let{address:n,defaultChainId:o}=e;return{isConnected:!!n,address:n,defaultChainId:o}}var _immutable = require('swr/immutable'); var _immutable2 = _interopRequireDefault(_immutable);var _ens = require('viem/ens');var _thirdweb = require('thirdweb');var _react3 = require('thirdweb/react');function N({config:e,theme:n,chains:o,chain:t,publicJsonRpcUrl:u=t.rpcUrls.default.http[0]}){let{connectors:h,connect:b}=_wagmi.useConnect.call(void 0, ),r=_react3.useActiveWallet.call(void 0, ),s=_react3.useActiveAccount.call(void 0, ),{disconnect:w}=_react3.useDisconnect.call(void 0, ),{data:C}=_react3.useWalletInfo.call(void 0, _optionalChain([r, 'optionalAccess', _2 => _2.id])),c=_react.useMemo.call(void 0, ()=>_thirdweb.defineChain.call(void 0, {id:t.id,blockExplorers:t.blockExplorers,blockTime:t.blockTime,ensTlds:t.ensTlds,testnet:t.testnet,contracts:t.contracts,nativeCurrency:t.nativeCurrency,name:t.name,rpcUrls:{default:{http:[u]}}}),[u,t]),m={client:e.client,chain:c,wallets:e.wallets};async function p(a){let i=h.find(d=>d.id==="in-app-wallet");if(i){let d={withCapabilities:!0,wallet:a};b({connector:i,chainId:t.id,...d})}else console.error("no tw connector found")}let{isLoading:A}=_react3.useAutoConnect.call(void 0, {...m,onConnect:p}),W=_react.useMemo.call(void 0, ()=>crypto.randomUUID(),[_optionalChain([r, 'optionalAccess', _3 => _3.id]),_optionalChain([s, 'optionalAccess', _4 => _4.address])]),{connect:v}=_react3.useConnectModal.call(void 0, );return{async connect({strategy:a}){if(!e.hasEmbeddedWallets){console.error("useBeraWagmi.connect: this function is not available if embedded wallets are disabled");return}let i=e.wallets.find(d=>d.id==="inApp");if(!i){console.error("useBeraWagmi.connect: no inApp wallet found");return}await i.connect({strategy:a,client:e.client,chain:c}),await p(i)},async openConnectModal(){let a=await v({...m,wallets:e.wallets,theme:n==="auto"?void 0:n,size:"compact",chains:[c,...o.map(i=>_thirdweb.defineChain.call(void 0, {id:i.id}))]});await p(a)},disconnect(){r&&w(r)},isConnecting:A,connectionId:W,connectorName:_nullishCoalesce(_optionalChain([C, 'optionalAccess', _5 => _5.name]), () => (null)),isEmbeddedWallet:_optionalChain([C, 'optionalAccess', _6 => _6.id])==="inApp",wallet:s,DebugConnectButton(){return _jsxruntime.jsx.call(void 0, _react3.ConnectButton,{...m,connectModal:{size:"compact"},onConnect:a=>p(a)})}}}function f(){let e=_react.useContext.call(void 0, D);if(!e)throw new Error("BeraWagmiContext not found");return e}var D=_react.createContext.call(void 0, void 0);function De({children:e,config:n,flags:{disableEip5792:o,disable5792Upgrade:t,accountOverride:u}={},theme:h,onSmartAccountRejection:b,chains:r,defaultChain:s,thirdweb:w,publicJsonRpcUrl:C}){let{wallet:c,openConnectModal:m,connect:p,DebugConnectButton:A,connectionId:W,disconnect:v,connectorName:a,isEmbeddedWallet:i,isConnecting:d}=N({config:n,theme:h,chains:r,chain:s,publicJsonRpcUrl:C}),{address:y,chainId:P}=_wagmi.useAccount.call(void 0, ),{disconnect:S}=_wagmi.useDisconnect.call(void 0, ),O=_wagmi.usePublicClient.call(void 0, ),l=_react.useMemo.call(void 0, ()=>{if(!(!y||!c))return _nullishCoalesce(u, () => (y))},[u,y,c]),{data:g}=_wagmi.useEnsName.call(void 0, {config:n.wagmi,chainId:s.id,address:l}),{data:x}=_immutable2.default.call(void 0, l?["BeraWagmiProvider_code",l,P]:null,([j,F,he])=>_optionalChain([O, 'optionalAccess', _7 => _7.getCode, 'call', _8 => _8({address:F})]),{refreshInterval:6e4}),[_,q]=_react.useMemo.call(void 0, ()=>x?x.startsWith("0xef01")?[!1,!0]:[!0,!1]:[!1,!1],[x]),{data:T}=_wagmi.useWalletClient.call(void 0, ),J=_react.useMemo.call(void 0, ()=>{try{return g?_ens.normalize.call(void 0, g):void 0}catch (e2){}},[g]),K=_wagmi.useEnsAvatar.call(void 0, {name:J});return _jsxruntime.jsx.call(void 0, D.Provider,{value:{flags:{disableEip5792:!!o,disable5792Upgrade:!!t},walletClient:T,onSmartAccountRejection:()=>{_optionalChain([b, 'optionalCall', _9 => _9()])},isEmbeddedWalletsEnabled:_nullishCoalesce(w.embeddedWallets, () => (!0)),isConnecting:d,isConnected:!!l&&!!T,DebugConnectButton:A,account:c&&P&&l?{connectionId:W,chainId:P,connectorName:a,isEmbeddedWallet:i,wallet:{address:l,ensName:_nullishCoalesce(_optionalChain([g, 'optionalAccess', _10 => _10.replace, 'call', _11 => _11(".bera",".\u{1F43B}\u26D3\uFE0F")]), () => (null)),ensAvatar:_nullishCoalesce(K.data, () => (null)),has7702Authorization:q,isContract:_}}:void 0,connect:p,openConnectModal:async()=>{console.log("openConnectModal.called"),await m()},disconnect:()=>{S(),v()},chains:r,defaultChainId:s.id},children:_jsxruntime.jsx.call(void 0, U,{address:l,defaultChainId:s.id,children:e})})}function pe(){let{account:e,isConnected:n}=f();return{...e,isConnected:n}}function Ce({chainId:e}){let{flags:n,account:o}=f(),{data:t}=_wagmi.useCapabilities.call(void 0, {account:_optionalChain([o, 'optionalAccess', _12 => _12.wallet, 'optionalAccess', _13 => _13.address]),scopeKey:_optionalChain([o, 'optionalAccess', _14 => _14.connectionId]),query:{retry:3},chainId:e});return{supportsAtomic:_react.useMemo.call(void 0, ()=>n.disableEip5792||!t?!1:_optionalChain([t, 'optionalAccess', _15 => _15.atomic, 'optionalAccess', _16 => _16.status])==="supported"||!n.disable5792Upgrade&&_optionalChain([t, 'optionalAccess', _17 => _17.atomic, 'optionalAccess', _18 => _18.status])==="ready",[t,n.disableEip5792,n.disable5792Upgrade,e]),capabilities:t}}function Qe(e){let{defaultChainId:n}=I(),{chainId:o,...t}=_nullishCoalesce(e, () => ({}));return _wagmi.usePublicClient.call(void 0, {chainId:_nullishCoalesce(o, () => (n)),...t})}exports.a = I; exports.b = pe; exports.c = Ce; exports.d = Qe; exports.e = _wagmi.useBlockNumber; exports.f = _wagmi.useChains; exports.g = _wagmi.useConfig; exports.h = _wagmi.useEnsAvatar; exports.i = _wagmi.useEnsName; exports.j = _wagmi.useSwitchChain; exports.k = _wagmi.useTransactionReceipt; exports.l = f; exports.m = De;
@@ -1 +0,0 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }var _wagmiadapter = require('@thirdweb-dev/wagmi-adapter');var _thirdweb = require('thirdweb');var _wallets = require('thirdweb/wallets');var _wagmi = require('wagmi');function A({thirdweb:e,transports:l={},defaultChain:a,chains:r=[]}){let o=_thirdweb.createThirdwebClient.call(void 0, {clientId:e.clientId}),s=!!_optionalChain([a, 'access', _ => _.contracts, 'optionalAccess', _2 => _2.multicall3]),n={mode:"EIP7702",sponsorGas:e.sponsorGas},d=_wallets.inAppWallet.call(void 0, {executionMode:n}),i=[..._wallets.getInstalledWallets.call(void 0, ),_wallets.createWallet.call(void 0, "io.rabby"),_wallets.createWallet.call(void 0, "io.metamask"),_wallets.createWallet.call(void 0, "com.coinbase.wallet"),_wallets.createWallet.call(void 0, "walletConnect")].filter((c,p,f)=>f.findIndex(m=>m.id===c.id)===p);return{hasEmbeddedWallets:e.embeddedWallets,wallets:e.embeddedWallets?[d,...i]:i,executionMode:n,client:o,wagmi:_wagmi.createConfig.call(void 0, {chains:[a,...r],ssr:!0,connectors:[_wagmiadapter.inAppWalletConnector.call(void 0, {client:o,executionMode:n})],storage:_wagmi.createStorage.call(void 0, {key:"wagmi-berachain-thirdweb",storage:typeof window<"u"?localStorage:void 0}),batch:{multicall:s?{wait:15}:void 0},transports:l})}}exports.a = A;