@berachain/wagmi 0.4.1 → 0.4.2-beta.2
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/{BeraWagmi-Bod8ckMU.d.ts → BeraWagmi-BYoBR8sq.d.ts} +9 -7
- package/dist/{BeraWagmi-tWJv_bhM.d.cts → BeraWagmi-D_9r9lFE.d.cts} +9 -7
- package/dist/chunk-CGJ4MZ4C.mjs +1 -0
- package/dist/chunk-GZLYCTRI.cjs +1 -0
- package/dist/chunk-HSGI3QYR.cjs +1 -0
- package/dist/chunk-RFS3IIRD.mjs +1 -0
- package/dist/context/index.cjs +1 -1
- package/dist/context/index.d.cts +1 -1
- package/dist/context/index.d.ts +1 -1
- package/dist/context/index.mjs +1 -1
- package/dist/context/thirdweb/index.cjs +1 -0
- package/dist/context/thirdweb/index.d.cts +47 -0
- package/dist/context/thirdweb/index.d.ts +47 -0
- package/dist/context/thirdweb/index.mjs +1 -0
- package/dist/hooks/index.cjs +1 -1
- package/dist/hooks/index.d.cts +2 -2
- package/dist/hooks/index.d.ts +2 -2
- package/dist/hooks/index.mjs +1 -1
- package/package.json +4 -4
- package/src/context/BeraWagmi.tsx +10 -6
- package/src/context/BeraWagmiLightWeight.tsx +314 -0
- package/src/context/WagmiProviderLightWeight.tsx +58 -0
- package/src/context/thirdweb/index.ts +3 -0
- package/src/context/useThirdweb.tsx +37 -26
- package/src/context/useThirdwebLightWeight.tsx +177 -0
- package/dist/chunk-4MF5YCJ5.mjs +0 -1
- package/dist/chunk-PNOS6IM4.cjs +0 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { PropsWithChildren } from 'react';
|
|
2
|
-
import {
|
|
2
|
+
import { SingleStepAuthArgsType, MultiStepAuthArgsType, Profile, Wallet } from 'thirdweb/wallets';
|
|
3
3
|
import { Address, Chain } from 'viem';
|
|
4
4
|
import { UseWalletClientReturnType } from 'wagmi';
|
|
5
5
|
import { getConfig, ThirdwebConfig } from './config/index.js';
|
|
@@ -88,6 +88,12 @@ declare enum ChainId {
|
|
|
88
88
|
MAINNET = 80094,
|
|
89
89
|
BEPOLIA = 80069
|
|
90
90
|
}
|
|
91
|
+
type ConnectEvent = {
|
|
92
|
+
type: "connect";
|
|
93
|
+
data: SingleStepAuthArgsType | MultiStepAuthArgsType;
|
|
94
|
+
} | {
|
|
95
|
+
type: "connect_modal";
|
|
96
|
+
};
|
|
91
97
|
interface IBeraWagmiProviderProps extends PropsWithChildren {
|
|
92
98
|
config: ReturnType<typeof getConfig>;
|
|
93
99
|
theme?: "dark" | "light" | "auto";
|
|
@@ -106,12 +112,8 @@ interface IBeraWagmiProviderProps extends PropsWithChildren {
|
|
|
106
112
|
accountOverride?: Address;
|
|
107
113
|
};
|
|
108
114
|
onSmartAccountRejection?: () => void;
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
*
|
|
112
|
-
* This is not triggered when a wallet connect automatically after a refresh.
|
|
113
|
-
*/
|
|
114
|
-
onConnectedWallet?: () => void;
|
|
115
|
+
onConnect?: (event: ConnectEvent) => void;
|
|
116
|
+
onConnectError?: (error: Error) => void;
|
|
115
117
|
chains?: Chain[];
|
|
116
118
|
defaultChain: Chain;
|
|
117
119
|
thirdweb: ThirdwebConfig;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { PropsWithChildren } from 'react';
|
|
2
|
-
import {
|
|
2
|
+
import { SingleStepAuthArgsType, MultiStepAuthArgsType, Profile, Wallet } from 'thirdweb/wallets';
|
|
3
3
|
import { Address, Chain } from 'viem';
|
|
4
4
|
import { UseWalletClientReturnType } from 'wagmi';
|
|
5
5
|
import { getConfig, ThirdwebConfig } from './config/index.cjs';
|
|
@@ -88,6 +88,12 @@ declare enum ChainId {
|
|
|
88
88
|
MAINNET = 80094,
|
|
89
89
|
BEPOLIA = 80069
|
|
90
90
|
}
|
|
91
|
+
type ConnectEvent = {
|
|
92
|
+
type: "connect";
|
|
93
|
+
data: SingleStepAuthArgsType | MultiStepAuthArgsType;
|
|
94
|
+
} | {
|
|
95
|
+
type: "connect_modal";
|
|
96
|
+
};
|
|
91
97
|
interface IBeraWagmiProviderProps extends PropsWithChildren {
|
|
92
98
|
config: ReturnType<typeof getConfig>;
|
|
93
99
|
theme?: "dark" | "light" | "auto";
|
|
@@ -106,12 +112,8 @@ interface IBeraWagmiProviderProps extends PropsWithChildren {
|
|
|
106
112
|
accountOverride?: Address;
|
|
107
113
|
};
|
|
108
114
|
onSmartAccountRejection?: () => void;
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
*
|
|
112
|
-
* This is not triggered when a wallet connect automatically after a refresh.
|
|
113
|
-
*/
|
|
114
|
-
onConnectedWallet?: () => void;
|
|
115
|
+
onConnect?: (event: ConnectEvent) => void;
|
|
116
|
+
onConnectError?: (error: Error) => void;
|
|
115
117
|
chains?: Chain[];
|
|
116
118
|
defaultChain: Chain;
|
|
117
119
|
thirdweb: ThirdwebConfig;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a as S,b as R}from"./chunk-RFS3IIRD.mjs";import{usePublicClient as ye}from"wagmi";import{useContext as X}from"react";function U(){let e=X(S);if(!e)throw new Error("LightweightAccountContext not found");let{address:n,defaultChainId:r}=e;return{isConnected:!!n,address:n,defaultChainId:r}}import{useBlockNumber as et,useChains as tt,useConfig as nt,useEnsAvatar as _,useEnsName as O,useSwitchChain as ot,useTransactionReceipt as it}from"wagmi";import{createContext as le,useContext as de,useMemo as M}from"react";import ue from"swr/immutable";import{normalize as pe}from"viem/ens";import{useAccount as me,useDisconnect as fe,usePublicClient as Ce,useWalletClient as ge}from"wagmi";import{useMemo as D}from"react";import{defineChain as k}from"thirdweb";import{ConnectButton as Y,useActiveAccount as Z,useActiveWallet as $,useAutoConnect as ee,useProfiles as te,useConnect as ne,useConnectModal as oe,useDisconnect as ie,useWalletInfo as re}from"thirdweb/react";import{preAuthenticate as ae}from"thirdweb/wallets/in-app";import{useConnect as se}from"wagmi";import{jsx as ce}from"react/jsx-runtime";function z({config:e,theme:n,chains:r=[],chain:t,onConnect:c,onConnectError:g,publicJsonRpcUrl:h=t.rpcUrls.default.http[0]}){let{connectors:y,connect:l}=se(),d=$(),b=Z(),{disconnect:W}=ie(),{data:A}=re(d?.id),{connect:m}=ne(),{data:v}=te({client:e.client}),f=D(()=>k({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:[h]}}}),[h,t]),u={client:e.client,chain:f,wallets:e.wallets};async function p(o){let i=y.find(a=>a.id==="in-app-wallet");if(i){let a={withCapabilities:!0,wallet:o};l({connector:i,chainId:t.id,...a})}else console.error("no tw connector found")}let{isLoading:P}=ee({...u,onConnect:p}),E=D(()=>"randomUUID"in crypto?crypto.randomUUID():Math.random().toString(36).substring(2,15),[d?.id,b?.address]),{connect:B}=oe();return{connect(o){if(!e.hasEmbeddedWallets){console.error("useBeraWagmi.connect: this function is not available if embedded wallets are disabled");return}return m(async()=>{let i=e.wallets.find(a=>a.id==="inApp");if(!i)throw console.error("useBeraWagmi.connect: no inApp wallet found"),new Error("no inApp wallet found");return i.connect({...u,...o}).then(async()=>(c?.({type:"connect",data:o}),await p(i),i)).catch(a=>{throw g?.(a),a})})},async openConnectModal(){try{let o=await B({...u,wallets:e.wallets,theme:n==="auto"?void 0:n,size:"compact",chains:[f,...r.filter(i=>i.id!==f.id).map(i=>k({id:i.id}))]});c?.({type:"connect_modal"}),await p(o)}catch(o){throw g?.(o),o}},disconnect(){d&&W(d)},isConnecting:P,connectionId:E,connectorName:A?.name??null,isEmbeddedWallet:A?.id==="inApp",wallet:b,profiles:v,preAuthenticate(o){return ae({...o,client:e.client})},DebugConnectButton(){return ce(Y,{...u,connectModal:{size:"compact"},onConnect:o=>p(o)})}}}import{jsx as L}from"react/jsx-runtime";function C(){let e=de(j);if(!e)throw new Error("BeraWagmiContext not found");return e}var j=le(void 0);function Oe({children:e,config:n,flags:{disableEip5792:r,disable5792Upgrade:t,accountOverride:c}={},theme:g,onSmartAccountRejection:h,chains:y=[],defaultChain:l,thirdweb:d,publicJsonRpcUrl:b,onConnect:W,onConnectError:A}){let{wallet:m,openConnectModal:v,connect:f,DebugConnectButton:u,connectionId:p,disconnect:P,connectorName:E,isEmbeddedWallet:B,profiles:o,preAuthenticate:i,isConnecting:a}=z({config:n,theme:g,chains:y,chain:l,publicJsonRpcUrl:b,onConnect:W,onConnectError:A}),{address:x,chainId:I}=me(),{disconnect:q}=fe(),J=Ce(),s=M(()=>{if(!(!x||!m))return c??x},[c,x,m]),{data:w}=O({config:n.wagmi,chainId:l.id,address:s}),{data:T}=ue(s?["BeraWagmiProvider_code",s,I]:null,([Q,V,We])=>J?.getCode({address:V}),{refreshInterval:6e4}),[K,F]=M(()=>T?T.startsWith("0xef01")?[!1,!0]:[!0,!1]:[!1,!1],[T]),{data:N}=ge(),G=M(()=>{try{return w?pe(w):void 0}catch{}},[w]),H=_({name:G});return L(j.Provider,{value:{preAuthenticate:i,flags:{disableEip5792:!!r,disable5792Upgrade:!!t},walletClient:N,onSmartAccountRejection:()=>{h?.()},isEmbeddedWalletsEnabled:d.embeddedWallets??!0,isConnecting:a,isConnected:!!s&&!!N,DebugConnectButton:u,account:m&&I&&s?{connectionId:p,chainId:I,connectorName:E,isEmbeddedWallet:B,profiles:o,wallet:{address:s,ensName:w?.replace(".bera",".\u{1F43B}\u26D3\uFE0F")??null,ensAvatar:H.data??null,has7702Authorization:F,isContract:K}}:void 0,connect:f,openConnectModal:async()=>{await v()},disconnect:()=>{q(),P()},defaultChainId:l.id},children:L(R,{address:s,defaultChainId:l.id,children:e})})}function he(){let{account:e,isConnected:n}=C();return{...e,isConnected:n}}import{useMemo as be}from"react";import{useCapabilities as Ae}from"wagmi";function we({chainId:e}){let{flags:n,account:r}=C(),{data:t}=Ae({account:r?.wallet?.address,scopeKey:r?.connectionId,query:{retry:3},chainId:e});return{supportsAtomic:be(()=>n.disableEip5792||!t?!1:t?.atomic?.status==="supported"||!n.disable5792Upgrade&&t?.atomic?.status==="ready",[t,n.disableEip5792,n.disable5792Upgrade,e]),capabilities:t}}function Ye(e){let{defaultChainId:n}=U(),{chainId:r,...t}=e??{};return ye({chainId:r??n,...t})}export{U as a,he as b,we as c,Ye as d,et as e,tt as f,nt as g,_ as h,O as i,ot as j,it as k,C as l,Oe as m};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true});var _react = require('react');var _jsxruntime = require('react/jsx-runtime');var r=_react.createContext.call(void 0, void 0);function h({children:e,address:d,defaultChainId:t}){return _jsxruntime.jsx.call(void 0, r.Provider,{value:{address:d,defaultChainId:t},children:e})}exports.a = r; exports.b = h;
|
|
@@ -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 _chunkGZLYCTRIcjs = require('./chunk-GZLYCTRI.cjs');var _wagmi = require('wagmi');var _react = require('react');function U(){let e=_react.useContext.call(void 0, _chunkGZLYCTRIcjs.a);if(!e)throw new Error("LightweightAccountContext not found");let{address:n,defaultChainId:r}=e;return{isConnected:!!n,address:n,defaultChainId:r}}var _immutable = require('swr/immutable'); var _immutable2 = _interopRequireDefault(_immutable);var _ens = require('viem/ens');var _thirdweb = require('thirdweb');var _react3 = require('thirdweb/react');var _inapp = require('thirdweb/wallets/in-app');var _jsxruntime = require('react/jsx-runtime');function z({config:e,theme:n,chains:r=[],chain:t,onConnect:c,onConnectError:g,publicJsonRpcUrl:h=t.rpcUrls.default.http[0]}){let{connectors:y,connect:l}=_wagmi.useConnect.call(void 0, ),d=_react3.useActiveWallet.call(void 0, ),b=_react3.useActiveAccount.call(void 0, ),{disconnect:W}=_react3.useDisconnect.call(void 0, ),{data:A}=_react3.useWalletInfo.call(void 0, _optionalChain([d, 'optionalAccess', _2 => _2.id])),{connect:m}=_react3.useConnect.call(void 0, ),{data:v}=_react3.useProfiles.call(void 0, {client:e.client}),f=_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:[h]}}}),[h,t]),u={client:e.client,chain:f,wallets:e.wallets};async function p(o){let i=y.find(a=>a.id==="in-app-wallet");if(i){let a={withCapabilities:!0,wallet:o};l({connector:i,chainId:t.id,...a})}else console.error("no tw connector found")}let{isLoading:P}=_react3.useAutoConnect.call(void 0, {...u,onConnect:p}),E=_react.useMemo.call(void 0, ()=>"randomUUID"in crypto?crypto.randomUUID():Math.random().toString(36).substring(2,15),[_optionalChain([d, 'optionalAccess', _3 => _3.id]),_optionalChain([b, 'optionalAccess', _4 => _4.address])]),{connect:B}=_react3.useConnectModal.call(void 0, );return{connect(o){if(!e.hasEmbeddedWallets){console.error("useBeraWagmi.connect: this function is not available if embedded wallets are disabled");return}return m(async()=>{let i=e.wallets.find(a=>a.id==="inApp");if(!i)throw console.error("useBeraWagmi.connect: no inApp wallet found"),new Error("no inApp wallet found");return i.connect({...u,...o}).then(async()=>(_optionalChain([c, 'optionalCall', _5 => _5({type:"connect",data:o})]),await p(i),i)).catch(a=>{throw _optionalChain([g, 'optionalCall', _6 => _6(a)]),a})})},async openConnectModal(){try{let o=await B({...u,wallets:e.wallets,theme:n==="auto"?void 0:n,size:"compact",chains:[f,...r.filter(i=>i.id!==f.id).map(i=>_thirdweb.defineChain.call(void 0, {id:i.id}))]});_optionalChain([c, 'optionalCall', _7 => _7({type:"connect_modal"})]),await p(o)}catch(o){throw _optionalChain([g, 'optionalCall', _8 => _8(o)]),o}},disconnect(){d&&W(d)},isConnecting:P,connectionId:E,connectorName:_nullishCoalesce(_optionalChain([A, 'optionalAccess', _9 => _9.name]), () => (null)),isEmbeddedWallet:_optionalChain([A, 'optionalAccess', _10 => _10.id])==="inApp",wallet:b,profiles:v,preAuthenticate(o){return _inapp.preAuthenticate.call(void 0, {...o,client:e.client})},DebugConnectButton(){return _jsxruntime.jsx.call(void 0, _react3.ConnectButton,{...u,connectModal:{size:"compact"},onConnect:o=>p(o)})}}}function C(){let e=_react.useContext.call(void 0, j);if(!e)throw new Error("BeraWagmiContext not found");return e}var j=_react.createContext.call(void 0, void 0);function Oe({children:e,config:n,flags:{disableEip5792:r,disable5792Upgrade:t,accountOverride:c}={},theme:g,onSmartAccountRejection:h,chains:y=[],defaultChain:l,thirdweb:d,publicJsonRpcUrl:b,onConnect:W,onConnectError:A}){let{wallet:m,openConnectModal:v,connect:f,DebugConnectButton:u,connectionId:p,disconnect:P,connectorName:E,isEmbeddedWallet:B,profiles:o,preAuthenticate:i,isConnecting:a}=z({config:n,theme:g,chains:y,chain:l,publicJsonRpcUrl:b,onConnect:W,onConnectError:A}),{address:x,chainId:I}=_wagmi.useAccount.call(void 0, ),{disconnect:q}=_wagmi.useDisconnect.call(void 0, ),J=_wagmi.usePublicClient.call(void 0, ),s=_react.useMemo.call(void 0, ()=>{if(!(!x||!m))return _nullishCoalesce(c, () => (x))},[c,x,m]),{data:w}=_wagmi.useEnsName.call(void 0, {config:n.wagmi,chainId:l.id,address:s}),{data:T}=_immutable2.default.call(void 0, s?["BeraWagmiProvider_code",s,I]:null,([Q,V,We])=>_optionalChain([J, 'optionalAccess', _11 => _11.getCode, 'call', _12 => _12({address:V})]),{refreshInterval:6e4}),[K,F]=_react.useMemo.call(void 0, ()=>T?T.startsWith("0xef01")?[!1,!0]:[!0,!1]:[!1,!1],[T]),{data:N}=_wagmi.useWalletClient.call(void 0, ),G=_react.useMemo.call(void 0, ()=>{try{return w?_ens.normalize.call(void 0, w):void 0}catch (e2){}},[w]),H=_wagmi.useEnsAvatar.call(void 0, {name:G});return _jsxruntime.jsx.call(void 0, j.Provider,{value:{preAuthenticate:i,flags:{disableEip5792:!!r,disable5792Upgrade:!!t},walletClient:N,onSmartAccountRejection:()=>{_optionalChain([h, 'optionalCall', _13 => _13()])},isEmbeddedWalletsEnabled:_nullishCoalesce(d.embeddedWallets, () => (!0)),isConnecting:a,isConnected:!!s&&!!N,DebugConnectButton:u,account:m&&I&&s?{connectionId:p,chainId:I,connectorName:E,isEmbeddedWallet:B,profiles:o,wallet:{address:s,ensName:_nullishCoalesce(_optionalChain([w, 'optionalAccess', _14 => _14.replace, 'call', _15 => _15(".bera",".\u{1F43B}\u26D3\uFE0F")]), () => (null)),ensAvatar:_nullishCoalesce(H.data, () => (null)),has7702Authorization:F,isContract:K}}:void 0,connect:f,openConnectModal:async()=>{await v()},disconnect:()=>{q(),P()},defaultChainId:l.id},children:_jsxruntime.jsx.call(void 0, _chunkGZLYCTRIcjs.b,{address:s,defaultChainId:l.id,children:e})})}function he(){let{account:e,isConnected:n}=C();return{...e,isConnected:n}}function we({chainId:e}){let{flags:n,account:r}=C(),{data:t}=_wagmi.useCapabilities.call(void 0, {account:_optionalChain([r, 'optionalAccess', _16 => _16.wallet, 'optionalAccess', _17 => _17.address]),scopeKey:_optionalChain([r, 'optionalAccess', _18 => _18.connectionId]),query:{retry:3},chainId:e});return{supportsAtomic:_react.useMemo.call(void 0, ()=>n.disableEip5792||!t?!1:_optionalChain([t, 'optionalAccess', _19 => _19.atomic, 'optionalAccess', _20 => _20.status])==="supported"||!n.disable5792Upgrade&&_optionalChain([t, 'optionalAccess', _21 => _21.atomic, 'optionalAccess', _22 => _22.status])==="ready",[t,n.disableEip5792,n.disable5792Upgrade,e]),capabilities:t}}function Ye(e){let{defaultChainId:n}=U(),{chainId:r,...t}=_nullishCoalesce(e, () => ({}));return _wagmi.usePublicClient.call(void 0, {chainId:_nullishCoalesce(r, () => (n)),...t})}exports.a = U; exports.b = he; exports.c = we; exports.d = Ye; 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 = C; exports.m = Oe;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{createContext as i}from"react";import{jsx as n}from"react/jsx-runtime";var r=i(void 0);function h({children:e,address:d,defaultChainId:t}){return n(r.Provider,{value:{address:d,defaultChainId:t},children:e})}export{r as a,h as b};
|
package/dist/context/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true});"use client";var
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true});"use client";var _chunkHSGI3QYRcjs = require('../chunk-HSGI3QYR.cjs');var _chunkPVMPBWIGcjs = require('../chunk-PVMPBWIG.cjs');require('../chunk-GZLYCTRI.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 B({transports:t,defaultChain:e,chains:i,thirdweb:o,...f}){let n=_react.useMemo.call(void 0, ()=>_chunkPVMPBWIGcjs.a.call(void 0, {thirdweb:o,transports:t,defaultChain:e,chains:i}),[e,o,t,i]);return _jsxruntime.jsx.call(void 0, _react3.ThirdwebProvider,{children:_jsxruntime.jsx.call(void 0, _wagmi.WagmiProvider,{config:n.wagmi,reconnectOnMount:!1,children:_jsxruntime.jsx.call(void 0, _reactquery.QueryClientProvider,{client:u,children:_jsxruntime.jsx.call(void 0, _chunkHSGI3QYRcjs.m,{...f,thirdweb:o,chains:i,defaultChain:e,config:n})})})})}exports.WagmiProvider = B;
|
package/dist/context/index.d.cts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
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-
|
|
3
|
+
import { I as IBeraWagmiProviderProps } from '../BeraWagmi-D_9r9lFE.cjs';
|
|
4
4
|
import 'react';
|
|
5
5
|
import 'thirdweb/wallets';
|
|
6
6
|
import 'wagmi';
|
package/dist/context/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
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-
|
|
3
|
+
import { I as IBeraWagmiProviderProps } from '../BeraWagmi-BYoBR8sq.js';
|
|
4
4
|
import 'react';
|
|
5
5
|
import 'thirdweb/wallets';
|
|
6
6
|
import 'wagmi';
|
package/dist/context/index.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";import{
|
|
1
|
+
"use client";import{m as a}from"../chunk-CGJ4MZ4C.mjs";import{a as m}from"../chunk-MZZ62TKM.mjs";import"../chunk-RFS3IIRD.mjs";import{useMemo as p}from"react";import{QueryClient as d,QueryClientProvider as g}from"@tanstack/react-query";import{ThirdwebProvider as P}from"thirdweb/react";import{WagmiProvider as s}from"wagmi";import{jsx as r}from"react/jsx-runtime";var u=new d;function B({transports:t,defaultChain:e,chains:i,thirdweb:o,...f}){let n=p(()=>m({thirdweb:o,transports:t,defaultChain:e,chains:i}),[e,o,t,i]);return r(P,{children:r(s,{config:n.wagmi,reconnectOnMount:!1,children:r(g,{client:u,children:r(a,{...f,thirdweb:o,chains:i,defaultChain:e,config:n})})})})}export{B as WagmiProvider};
|
|
@@ -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; }"use client";var _chunkPVMPBWIGcjs = require('../../chunk-PVMPBWIG.cjs');var _chunkGZLYCTRIcjs = require('../../chunk-GZLYCTRI.cjs');var _react = require('react');var _reactquery = require('@tanstack/react-query');var _react3 = require('thirdweb/react');var _wagmi = require('wagmi');var _immutable = require('swr/immutable'); var _immutable2 = _interopRequireDefault(_immutable);var _ens = require('viem/ens');var _thirdweb = require('thirdweb');var _inapp = require('thirdweb/wallets/in-app');function U({config:n,chain:e,onConnect:i,onConnectError:a,publicJsonRpcUrl:s=e.rpcUrls.default.http[0]}){let{connectors:l,connect:b}=_wagmi.useConnect.call(void 0, ),u=_react3.useActiveWallet.call(void 0, ),c=_react3.useActiveAccount.call(void 0, ),{disconnect:A}=_react3.useDisconnect.call(void 0, ),{data:m}=_react3.useWalletInfo.call(void 0, _optionalChain([u, 'optionalAccess', _2 => _2.id])),{connect:v}=_react3.useConnect.call(void 0, ),{data:w}=_react3.useProfiles.call(void 0, {client:n.client}),p=_react.useMemo.call(void 0, ()=>_thirdweb.defineChain.call(void 0, {id:e.id,blockExplorers:e.blockExplorers,blockTime:e.blockTime,ensTlds:e.ensTlds,testnet:e.testnet,contracts:e.contracts,nativeCurrency:e.nativeCurrency,name:e.name,rpcUrls:{default:{http:[s]}}}),[s,e]),f={client:n.client,chain:p,wallets:n.wallets};async function g(r){let o=l.find(t=>t.id==="in-app-wallet");if(o){let t={withCapabilities:!0,wallet:r};b({connector:o,chainId:e.id,...t})}else console.error("no tw connector found")}let{isLoading:W}=_react3.useAutoConnect.call(void 0, {...f,onConnect:g}),y=_react.useMemo.call(void 0, ()=>"randomUUID"in crypto?crypto.randomUUID():Math.random().toString(36).substring(2,15),[_optionalChain([u, 'optionalAccess', _3 => _3.id]),_optionalChain([c, 'optionalAccess', _4 => _4.address])]);return{connect(r){if(!n.hasEmbeddedWallets){console.error("useBeraWagmi.connect: this function is not available if embedded wallets are disabled");return}return v(async()=>{let o=n.wallets.find(t=>t.id==="inApp");if(!o)throw console.error("useBeraWagmi.connect: no inApp wallet found"),new Error("no inApp wallet found");return o.connect({...f,...r}).then(async()=>(_optionalChain([i, 'optionalCall', _5 => _5({type:"connect",data:r})]),await g(o),o)).catch(t=>{throw _optionalChain([a, 'optionalCall', _6 => _6(t)]),t})})},disconnect(){u&&A(u)},isConnecting:W,connectionId:y,connectorName:_nullishCoalesce(_optionalChain([m, 'optionalAccess', _7 => _7.name]), () => (null)),isEmbeddedWallet:_optionalChain([m, 'optionalAccess', _8 => _8.id])==="inApp",wallet:c,profiles:w,preAuthenticate(r){return _inapp.preAuthenticate.call(void 0, {...r,client:n.client})}}}var _jsxruntime = require('react/jsx-runtime');var de=_react.createContext.call(void 0, void 0);function N({children:n,config:e,flags:{disableEip5792:i,disable5792Upgrade:a,accountOverride:s}={},theme:l,onSmartAccountRejection:b,chains:u=[],defaultChain:c,thirdweb:A,publicJsonRpcUrl:m,onConnect:v,onConnectError:w}){let{wallet:p,connect:f,connectionId:g,disconnect:W,connectorName:y,isEmbeddedWallet:r,profiles:o,preAuthenticate:t,isConnecting:D}=U({config:e,theme:l,chains:u,chain:c,publicJsonRpcUrl:m,onConnect:v,onConnectError:w}),{address:P,chainId:E}=_wagmi.useAccount.call(void 0, ),{disconnect:k}=_wagmi.useDisconnect.call(void 0, ),L=_wagmi.usePublicClient.call(void 0, ),d=_react.useMemo.call(void 0, ()=>{if(!(!P||!p))return _nullishCoalesce(s, () => (P))},[s,P,p]),{data:h}=_wagmi.useEnsName.call(void 0, {config:e.wagmi,chainId:c.id,address:d}),{data:T}=_immutable2.default.call(void 0, d?["BeraWagmiProvider_code",d,E]:null,([j,q,he])=>_optionalChain([L, 'optionalAccess', _9 => _9.getCode, 'call', _10 => _10({address:q})]),{refreshInterval:6e4}),[z,O]=_react.useMemo.call(void 0, ()=>T?T.startsWith("0xef01")?[!1,!0]:[!0,!1]:[!1,!1],[T]),{data:I}=_wagmi.useWalletClient.call(void 0, ),_=_react.useMemo.call(void 0, ()=>{try{return h?_ens.normalize.call(void 0, h):void 0}catch (e2){}},[h]),Q=_wagmi.useEnsAvatar.call(void 0, {name:_});return _jsxruntime.jsx.call(void 0, de.Provider,{value:{preAuthenticate:t,flags:{disableEip5792:!!i,disable5792Upgrade:!!a},walletClient:I,onSmartAccountRejection:()=>{_optionalChain([b, 'optionalCall', _11 => _11()])},isEmbeddedWalletsEnabled:_nullishCoalesce(A.embeddedWallets, () => (!0)),isConnecting:D,isConnected:!!d&&!!I,DebugConnectButton(){return null},account:p&&E&&d?{connectionId:g,chainId:E,connectorName:y,isEmbeddedWallet:r,profiles:o,wallet:{address:d,ensName:_nullishCoalesce(_optionalChain([h, 'optionalAccess', _12 => _12.replace, 'call', _13 => _13(".bera",".\u{1F43B}\u26D3\uFE0F")]), () => (null)),ensAvatar:_nullishCoalesce(Q.data, () => (null)),has7702Authorization:O,isContract:z}}:void 0,connect:f,openConnectModal(){throw new Error("openConnectModal is not available in lightweight mode. Use @berachain/wagmi/context/full instead.")},disconnect:()=>{k(),W()},defaultChainId:c.id},children:_jsxruntime.jsx.call(void 0, _chunkGZLYCTRIcjs.b,{address:d,defaultChainId:c.id,children:n})})}var ge=new _reactquery.QueryClient;function ze({transports:n,defaultChain:e,chains:i,thirdweb:a,...s}){let l=_react.useMemo.call(void 0, ()=>_chunkPVMPBWIGcjs.a.call(void 0, {thirdweb:a,transports:n,defaultChain:e,chains:i}),[e,a,n,i]);return _jsxruntime.jsx.call(void 0, _react3.ThirdwebProvider,{children:_jsxruntime.jsx.call(void 0, _wagmi.WagmiProvider,{config:l.wagmi,reconnectOnMount:!1,children:_jsxruntime.jsx.call(void 0, _reactquery.QueryClientProvider,{client:ge,children:_jsxruntime.jsx.call(void 0, N,{...s,thirdweb:a,chains:i,defaultChain:e,config:l})})})})}exports.WagmiProvider = ze;
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
+
import { Address, Chain, Transport } from 'viem';
|
|
3
|
+
import { PropsWithChildren } from 'react';
|
|
4
|
+
import { SingleStepAuthArgsType, MultiStepAuthArgsType } from 'thirdweb/wallets';
|
|
5
|
+
import { getConfig, ThirdwebConfig } from '../../config/index.cjs';
|
|
6
|
+
import 'thirdweb';
|
|
7
|
+
import 'wagmi';
|
|
8
|
+
|
|
9
|
+
type ConnectEvent = {
|
|
10
|
+
type: "connect";
|
|
11
|
+
data: SingleStepAuthArgsType | MultiStepAuthArgsType;
|
|
12
|
+
} | {
|
|
13
|
+
type: "connect_modal";
|
|
14
|
+
};
|
|
15
|
+
interface IBeraWagmiProviderProps extends PropsWithChildren {
|
|
16
|
+
config: ReturnType<typeof getConfig>;
|
|
17
|
+
theme?: "dark" | "light" | "auto";
|
|
18
|
+
flags?: {
|
|
19
|
+
disableEip5792?: boolean;
|
|
20
|
+
/**
|
|
21
|
+
* Whether to disable the 5792 upgrade for users that haven't upgraded yet.
|
|
22
|
+
*
|
|
23
|
+
* `atomic.status === "ready"`
|
|
24
|
+
*/
|
|
25
|
+
disable5792Upgrade?: boolean;
|
|
26
|
+
/**
|
|
27
|
+
* A value that mocks the connected wallet address, while transactions are still sent from the connected wallet.
|
|
28
|
+
* It can be used for advanced use cases like sending permissionless transactions (like incentive claims).
|
|
29
|
+
*/
|
|
30
|
+
accountOverride?: Address;
|
|
31
|
+
};
|
|
32
|
+
onSmartAccountRejection?: () => void;
|
|
33
|
+
onConnect?: (event: ConnectEvent) => void;
|
|
34
|
+
onConnectError?: (error: Error) => void;
|
|
35
|
+
chains?: Chain[];
|
|
36
|
+
defaultChain: Chain;
|
|
37
|
+
thirdweb: ThirdwebConfig;
|
|
38
|
+
publicJsonRpcUrl?: string;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
type WagmiProviderProps = Omit<IBeraWagmiProviderProps, "config" | "defaultChain"> & {
|
|
42
|
+
transports?: Record<number, Transport>;
|
|
43
|
+
defaultChain: Chain;
|
|
44
|
+
};
|
|
45
|
+
declare function WagmiProvider({ transports, defaultChain, chains, thirdweb, ...beraWagmiProps }: WagmiProviderProps): react_jsx_runtime.JSX.Element;
|
|
46
|
+
|
|
47
|
+
export { WagmiProvider };
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
+
import { Address, Chain, Transport } from 'viem';
|
|
3
|
+
import { PropsWithChildren } from 'react';
|
|
4
|
+
import { SingleStepAuthArgsType, MultiStepAuthArgsType } from 'thirdweb/wallets';
|
|
5
|
+
import { getConfig, ThirdwebConfig } from '../../config/index.js';
|
|
6
|
+
import 'thirdweb';
|
|
7
|
+
import 'wagmi';
|
|
8
|
+
|
|
9
|
+
type ConnectEvent = {
|
|
10
|
+
type: "connect";
|
|
11
|
+
data: SingleStepAuthArgsType | MultiStepAuthArgsType;
|
|
12
|
+
} | {
|
|
13
|
+
type: "connect_modal";
|
|
14
|
+
};
|
|
15
|
+
interface IBeraWagmiProviderProps extends PropsWithChildren {
|
|
16
|
+
config: ReturnType<typeof getConfig>;
|
|
17
|
+
theme?: "dark" | "light" | "auto";
|
|
18
|
+
flags?: {
|
|
19
|
+
disableEip5792?: boolean;
|
|
20
|
+
/**
|
|
21
|
+
* Whether to disable the 5792 upgrade for users that haven't upgraded yet.
|
|
22
|
+
*
|
|
23
|
+
* `atomic.status === "ready"`
|
|
24
|
+
*/
|
|
25
|
+
disable5792Upgrade?: boolean;
|
|
26
|
+
/**
|
|
27
|
+
* A value that mocks the connected wallet address, while transactions are still sent from the connected wallet.
|
|
28
|
+
* It can be used for advanced use cases like sending permissionless transactions (like incentive claims).
|
|
29
|
+
*/
|
|
30
|
+
accountOverride?: Address;
|
|
31
|
+
};
|
|
32
|
+
onSmartAccountRejection?: () => void;
|
|
33
|
+
onConnect?: (event: ConnectEvent) => void;
|
|
34
|
+
onConnectError?: (error: Error) => void;
|
|
35
|
+
chains?: Chain[];
|
|
36
|
+
defaultChain: Chain;
|
|
37
|
+
thirdweb: ThirdwebConfig;
|
|
38
|
+
publicJsonRpcUrl?: string;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
type WagmiProviderProps = Omit<IBeraWagmiProviderProps, "config" | "defaultChain"> & {
|
|
42
|
+
transports?: Record<number, Transport>;
|
|
43
|
+
defaultChain: Chain;
|
|
44
|
+
};
|
|
45
|
+
declare function WagmiProvider({ transports, defaultChain, chains, thirdweb, ...beraWagmiProps }: WagmiProviderProps): react_jsx_runtime.JSX.Element;
|
|
46
|
+
|
|
47
|
+
export { WagmiProvider };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use client";import{a as x}from"../../chunk-MZZ62TKM.mjs";import{b as S}from"../../chunk-RFS3IIRD.mjs";import{useMemo as le}from"react";import{QueryClient as ue,QueryClientProvider as pe}from"@tanstack/react-query";import{ThirdwebProvider as me}from"thirdweb/react";import{WagmiProvider as fe}from"wagmi";import{createContext as ee,useContext as Pe,useMemo as B}from"react";import ne from"swr/immutable";import{normalize as te}from"viem/ens";import{useAccount as oe,useDisconnect as re,useEnsAvatar as ie,useEnsName as ae,usePublicClient as se,useWalletClient as ce}from"wagmi";import{useMemo as M}from"react";import{defineChain as J}from"thirdweb";import{useActiveAccount as F,useActiveWallet as G,useAutoConnect as H,useProfiles as K,useConnect as V,useDisconnect as X,useWalletInfo as Y}from"thirdweb/react";import{preAuthenticate as Z}from"thirdweb/wallets/in-app";import{useConnect as $}from"wagmi";function U({config:n,chain:e,onConnect:i,onConnectError:a,publicJsonRpcUrl:s=e.rpcUrls.default.http[0]}){let{connectors:l,connect:b}=$(),u=G(),c=F(),{disconnect:A}=X(),{data:m}=Y(u?.id),{connect:v}=V(),{data:w}=K({client:n.client}),p=M(()=>J({id:e.id,blockExplorers:e.blockExplorers,blockTime:e.blockTime,ensTlds:e.ensTlds,testnet:e.testnet,contracts:e.contracts,nativeCurrency:e.nativeCurrency,name:e.name,rpcUrls:{default:{http:[s]}}}),[s,e]),f={client:n.client,chain:p,wallets:n.wallets};async function g(r){let o=l.find(t=>t.id==="in-app-wallet");if(o){let t={withCapabilities:!0,wallet:r};b({connector:o,chainId:e.id,...t})}else console.error("no tw connector found")}let{isLoading:W}=H({...f,onConnect:g}),y=M(()=>"randomUUID"in crypto?crypto.randomUUID():Math.random().toString(36).substring(2,15),[u?.id,c?.address]);return{connect(r){if(!n.hasEmbeddedWallets){console.error("useBeraWagmi.connect: this function is not available if embedded wallets are disabled");return}return v(async()=>{let o=n.wallets.find(t=>t.id==="inApp");if(!o)throw console.error("useBeraWagmi.connect: no inApp wallet found"),new Error("no inApp wallet found");return o.connect({...f,...r}).then(async()=>(i?.({type:"connect",data:r}),await g(o),o)).catch(t=>{throw a?.(t),t})})},disconnect(){u&&A(u)},isConnecting:W,connectionId:y,connectorName:m?.name??null,isEmbeddedWallet:m?.id==="inApp",wallet:c,profiles:w,preAuthenticate(r){return Z({...r,client:n.client})}}}import{jsx as R}from"react/jsx-runtime";var de=ee(void 0);function N({children:n,config:e,flags:{disableEip5792:i,disable5792Upgrade:a,accountOverride:s}={},theme:l,onSmartAccountRejection:b,chains:u=[],defaultChain:c,thirdweb:A,publicJsonRpcUrl:m,onConnect:v,onConnectError:w}){let{wallet:p,connect:f,connectionId:g,disconnect:W,connectorName:y,isEmbeddedWallet:r,profiles:o,preAuthenticate:t,isConnecting:D}=U({config:e,theme:l,chains:u,chain:c,publicJsonRpcUrl:m,onConnect:v,onConnectError:w}),{address:P,chainId:E}=oe(),{disconnect:k}=re(),L=se(),d=B(()=>{if(!(!P||!p))return s??P},[s,P,p]),{data:h}=ae({config:e.wagmi,chainId:c.id,address:d}),{data:T}=ne(d?["BeraWagmiProvider_code",d,E]:null,([j,q,he])=>L?.getCode({address:q}),{refreshInterval:6e4}),[z,O]=B(()=>T?T.startsWith("0xef01")?[!1,!0]:[!0,!1]:[!1,!1],[T]),{data:I}=ce(),_=B(()=>{try{return h?te(h):void 0}catch{}},[h]),Q=ie({name:_});return R(de.Provider,{value:{preAuthenticate:t,flags:{disableEip5792:!!i,disable5792Upgrade:!!a},walletClient:I,onSmartAccountRejection:()=>{b?.()},isEmbeddedWalletsEnabled:A.embeddedWallets??!0,isConnecting:D,isConnected:!!d&&!!I,DebugConnectButton(){return null},account:p&&E&&d?{connectionId:g,chainId:E,connectorName:y,isEmbeddedWallet:r,profiles:o,wallet:{address:d,ensName:h?.replace(".bera",".\u{1F43B}\u26D3\uFE0F")??null,ensAvatar:Q.data??null,has7702Authorization:O,isContract:z}}:void 0,connect:f,openConnectModal(){throw new Error("openConnectModal is not available in lightweight mode. Use @berachain/wagmi/context/full instead.")},disconnect:()=>{k(),W()},defaultChainId:c.id},children:R(S,{address:d,defaultChainId:c.id,children:n})})}import{jsx as C}from"react/jsx-runtime";var ge=new ue;function ze({transports:n,defaultChain:e,chains:i,thirdweb:a,...s}){let l=le(()=>x({thirdweb:a,transports:n,defaultChain:e,chains:i}),[e,a,n,i]);return C(me,{children:C(fe,{config:l.wagmi,reconnectOnMount:!1,children:C(pe,{client:ge,children:C(N,{...s,thirdweb:a,chains:i,defaultChain:e,config:l})})})})}export{ze as WagmiProvider};
|
package/dist/hooks/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true});var
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkHSGI3QYRcjs = require('../chunk-HSGI3QYR.cjs');require('../chunk-GZLYCTRI.cjs');exports.useBeraAccount = _chunkHSGI3QYRcjs.b; exports.useBeraWagmi = _chunkHSGI3QYRcjs.l; exports.useBeraWallet = _chunkHSGI3QYRcjs.a; exports.useBlockNumber = _chunkHSGI3QYRcjs.e; exports.useCapabilities = _chunkHSGI3QYRcjs.c; exports.useChains = _chunkHSGI3QYRcjs.f; exports.useConfig = _chunkHSGI3QYRcjs.g; exports.useEnsAvatar = _chunkHSGI3QYRcjs.h; exports.useEnsName = _chunkHSGI3QYRcjs.i; exports.usePublicClient = _chunkHSGI3QYRcjs.d; exports.useSwitchChain = _chunkHSGI3QYRcjs.j; exports.useTransactionReceipt = _chunkHSGI3QYRcjs.k;
|
package/dist/hooks/index.d.cts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
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-
|
|
4
|
-
export { u as useBeraWagmi } from '../BeraWagmi-
|
|
3
|
+
import { B as BeraWagmiApi, C as ChainId } from '../BeraWagmi-D_9r9lFE.cjs';
|
|
4
|
+
export { u as useBeraWagmi } from '../BeraWagmi-D_9r9lFE.cjs';
|
|
5
5
|
import 'react';
|
|
6
6
|
import 'thirdweb/wallets';
|
|
7
7
|
import 'viem';
|
package/dist/hooks/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
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-
|
|
4
|
-
export { u as useBeraWagmi } from '../BeraWagmi-
|
|
3
|
+
import { B as BeraWagmiApi, C as ChainId } from '../BeraWagmi-BYoBR8sq.js';
|
|
4
|
+
export { u as useBeraWagmi } from '../BeraWagmi-BYoBR8sq.js';
|
|
5
5
|
import 'react';
|
|
6
6
|
import 'thirdweb/wallets';
|
|
7
7
|
import 'viem';
|
package/dist/hooks/index.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a,b,c,d,e,f,g,h,i,j,k,l}from"../chunk-
|
|
1
|
+
import{a,b,c,d,e,f,g,h,i,j,k,l}from"../chunk-CGJ4MZ4C.mjs";import"../chunk-RFS3IIRD.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.
|
|
3
|
+
"version": "0.4.2-beta.2",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"files": [
|
|
6
6
|
"dist",
|
|
@@ -47,12 +47,12 @@
|
|
|
47
47
|
"thirdweb": "5.119.0"
|
|
48
48
|
},
|
|
49
49
|
"devDependencies": {
|
|
50
|
+
"@berachain/config": "0.1.8-beta.0",
|
|
50
51
|
"@types/node": "24.1.0",
|
|
51
52
|
"@types/react": "19.1.8",
|
|
52
|
-
"tsup": "8.
|
|
53
|
+
"tsup": "8.5.1",
|
|
53
54
|
"viem": "2.45.0",
|
|
54
|
-
"wagmi": "2.19.5"
|
|
55
|
-
"@berachain/config": "0.1.0"
|
|
55
|
+
"wagmi": "2.19.5"
|
|
56
56
|
},
|
|
57
57
|
"peerDependencies": {
|
|
58
58
|
"react": "^19.1",
|
|
@@ -125,6 +125,10 @@ export enum ChainId {
|
|
|
125
125
|
BEPOLIA = 80069,
|
|
126
126
|
}
|
|
127
127
|
|
|
128
|
+
export type ConnectEvent =
|
|
129
|
+
| { type: "connect"; data: SingleStepAuthArgsType | MultiStepAuthArgsType }
|
|
130
|
+
| { type: "connect_modal" };
|
|
131
|
+
|
|
128
132
|
export interface IBeraWagmiProviderProps extends PropsWithChildren {
|
|
129
133
|
config: ReturnType<typeof getConfig>;
|
|
130
134
|
theme?: "dark" | "light" | "auto";
|
|
@@ -143,12 +147,8 @@ export interface IBeraWagmiProviderProps extends PropsWithChildren {
|
|
|
143
147
|
accountOverride?: Address;
|
|
144
148
|
};
|
|
145
149
|
onSmartAccountRejection?: () => void;
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
*
|
|
149
|
-
* This is not triggered when a wallet connect automatically after a refresh.
|
|
150
|
-
*/
|
|
151
|
-
onConnectedWallet?: () => void;
|
|
150
|
+
onConnect?: (event: ConnectEvent) => void;
|
|
151
|
+
onConnectError?: (error: Error) => void;
|
|
152
152
|
chains?: Chain[];
|
|
153
153
|
defaultChain: Chain;
|
|
154
154
|
thirdweb: ThirdwebConfig;
|
|
@@ -165,6 +165,8 @@ export function BeraWagmiProvider({
|
|
|
165
165
|
defaultChain,
|
|
166
166
|
thirdweb,
|
|
167
167
|
publicJsonRpcUrl,
|
|
168
|
+
onConnect,
|
|
169
|
+
onConnectError,
|
|
168
170
|
}: IBeraWagmiProviderProps) {
|
|
169
171
|
const {
|
|
170
172
|
wallet,
|
|
@@ -184,6 +186,8 @@ export function BeraWagmiProvider({
|
|
|
184
186
|
chains,
|
|
185
187
|
chain: defaultChain,
|
|
186
188
|
publicJsonRpcUrl,
|
|
189
|
+
onConnect,
|
|
190
|
+
onConnectError,
|
|
187
191
|
});
|
|
188
192
|
|
|
189
193
|
const { address: connectedAddress, chainId } = useAccount(); // wagmi
|
|
@@ -0,0 +1,314 @@
|
|
|
1
|
+
import {
|
|
2
|
+
createContext,
|
|
3
|
+
type PropsWithChildren,
|
|
4
|
+
useContext,
|
|
5
|
+
useMemo,
|
|
6
|
+
} from "react";
|
|
7
|
+
import useSWRImmutable from "swr/immutable";
|
|
8
|
+
import type {
|
|
9
|
+
MultiStepAuthArgsType,
|
|
10
|
+
Profile,
|
|
11
|
+
SingleStepAuthArgsType,
|
|
12
|
+
Wallet,
|
|
13
|
+
} from "thirdweb/wallets";
|
|
14
|
+
import type { Address, Chain } from "viem";
|
|
15
|
+
import { normalize } from "viem/ens";
|
|
16
|
+
import {
|
|
17
|
+
type UseWalletClientReturnType,
|
|
18
|
+
useAccount,
|
|
19
|
+
useDisconnect,
|
|
20
|
+
useEnsAvatar,
|
|
21
|
+
useEnsName,
|
|
22
|
+
usePublicClient,
|
|
23
|
+
useWalletClient,
|
|
24
|
+
} from "wagmi";
|
|
25
|
+
|
|
26
|
+
import type { getConfig, ThirdwebConfig } from "../config";
|
|
27
|
+
import { LightweightAccountProvider } from "./LightweightAccountProvider";
|
|
28
|
+
import { useThirdwebLightWeight } from "./useThirdwebLightWeight";
|
|
29
|
+
|
|
30
|
+
export function useBeraWagmi() {
|
|
31
|
+
const context = useContext(BeraWagmiContext);
|
|
32
|
+
if (!context) {
|
|
33
|
+
throw new Error("BeraWagmiContext not found");
|
|
34
|
+
}
|
|
35
|
+
return context;
|
|
36
|
+
}
|
|
37
|
+
export interface BeraWagmiApi {
|
|
38
|
+
/**
|
|
39
|
+
* @deprecated used for prototyping only.
|
|
40
|
+
*/
|
|
41
|
+
DebugConnectButton(): React.ReactNode;
|
|
42
|
+
/**
|
|
43
|
+
* Account connected to berachain dapp. It might include some additional data once embedded wallets are enabled.
|
|
44
|
+
*/
|
|
45
|
+
account:
|
|
46
|
+
| {
|
|
47
|
+
/**
|
|
48
|
+
* Chain ID to which the wallet provider is currently connected to.
|
|
49
|
+
*/
|
|
50
|
+
chainId: number;
|
|
51
|
+
/**
|
|
52
|
+
* Whether the wallet is an embedded wallet.
|
|
53
|
+
*/
|
|
54
|
+
isEmbeddedWallet: boolean;
|
|
55
|
+
connectorName: string | null;
|
|
56
|
+
connectionId: string;
|
|
57
|
+
profiles: Profile[] | undefined;
|
|
58
|
+
/**
|
|
59
|
+
* Wallet to display.
|
|
60
|
+
*
|
|
61
|
+
* This might be manually overridden by the accountOverride prop, thus not being the same as the connected wallet.
|
|
62
|
+
*/
|
|
63
|
+
wallet:
|
|
64
|
+
| {
|
|
65
|
+
address: Address;
|
|
66
|
+
/**
|
|
67
|
+
* ENS name of the wallet.
|
|
68
|
+
*/
|
|
69
|
+
ensName: string | null;
|
|
70
|
+
/**
|
|
71
|
+
* ENS avatar of the wallet.
|
|
72
|
+
*/
|
|
73
|
+
ensAvatar: string | null;
|
|
74
|
+
/**
|
|
75
|
+
* Whether the wallet has 7702 authorization.
|
|
76
|
+
*/
|
|
77
|
+
has7702Authorization: boolean;
|
|
78
|
+
/**
|
|
79
|
+
* Whether the wallet is a contract.
|
|
80
|
+
*/
|
|
81
|
+
isContract: boolean;
|
|
82
|
+
}
|
|
83
|
+
| undefined;
|
|
84
|
+
}
|
|
85
|
+
| undefined;
|
|
86
|
+
isEmbeddedWalletsEnabled: boolean;
|
|
87
|
+
isConnected: boolean;
|
|
88
|
+
isConnecting: boolean;
|
|
89
|
+
flags: {
|
|
90
|
+
disableEip5792: boolean;
|
|
91
|
+
disable5792Upgrade: boolean;
|
|
92
|
+
};
|
|
93
|
+
walletClient: UseWalletClientReturnType["data"];
|
|
94
|
+
openConnectModal(): Promise<void> | void;
|
|
95
|
+
/**
|
|
96
|
+
* Connects a wallet using a specific strategy.
|
|
97
|
+
* For email/phone use MultiStepAuthArgsType (requires preAuthenticate first).
|
|
98
|
+
*/
|
|
99
|
+
connect(
|
|
100
|
+
args: SingleStepAuthArgsType | MultiStepAuthArgsType,
|
|
101
|
+
): Promise<Wallet | null> | undefined;
|
|
102
|
+
/**
|
|
103
|
+
* Sends an OTP to the user's email or phone number.
|
|
104
|
+
* Call this before connect() when using email or phone strategy.
|
|
105
|
+
*/
|
|
106
|
+
preAuthenticate(
|
|
107
|
+
args:
|
|
108
|
+
| { strategy: "email"; email: string }
|
|
109
|
+
| { strategy: "phone"; phoneNumber: string },
|
|
110
|
+
): Promise<void>;
|
|
111
|
+
disconnect(): void;
|
|
112
|
+
/**
|
|
113
|
+
* A callback that is called when a smart account upgrade is rejected.
|
|
114
|
+
*
|
|
115
|
+
* This is used to disable EIP-5792 temporarily.
|
|
116
|
+
*/
|
|
117
|
+
onSmartAccountRejection(): void;
|
|
118
|
+
|
|
119
|
+
defaultChainId: ChainId;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
const BeraWagmiContext = createContext<BeraWagmiApi | undefined>(undefined);
|
|
123
|
+
|
|
124
|
+
export enum ChainId {
|
|
125
|
+
MAINNET = 80094,
|
|
126
|
+
BEPOLIA = 80069,
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
export type ConnectEvent =
|
|
130
|
+
| { type: "connect"; data: SingleStepAuthArgsType | MultiStepAuthArgsType }
|
|
131
|
+
| { type: "connect_modal" };
|
|
132
|
+
|
|
133
|
+
export interface IBeraWagmiProviderProps extends PropsWithChildren {
|
|
134
|
+
config: ReturnType<typeof getConfig>;
|
|
135
|
+
theme?: "dark" | "light" | "auto";
|
|
136
|
+
flags?: {
|
|
137
|
+
disableEip5792?: boolean;
|
|
138
|
+
/**
|
|
139
|
+
* Whether to disable the 5792 upgrade for users that haven't upgraded yet.
|
|
140
|
+
*
|
|
141
|
+
* `atomic.status === "ready"`
|
|
142
|
+
*/
|
|
143
|
+
disable5792Upgrade?: boolean;
|
|
144
|
+
/**
|
|
145
|
+
* A value that mocks the connected wallet address, while transactions are still sent from the connected wallet.
|
|
146
|
+
* It can be used for advanced use cases like sending permissionless transactions (like incentive claims).
|
|
147
|
+
*/
|
|
148
|
+
accountOverride?: Address;
|
|
149
|
+
};
|
|
150
|
+
onSmartAccountRejection?: () => void;
|
|
151
|
+
onConnect?: (event: ConnectEvent) => void;
|
|
152
|
+
onConnectError?: (error: Error) => void;
|
|
153
|
+
chains?: Chain[];
|
|
154
|
+
defaultChain: Chain;
|
|
155
|
+
thirdweb: ThirdwebConfig;
|
|
156
|
+
publicJsonRpcUrl?: string;
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
export function BeraWagmiProvider({
|
|
160
|
+
children,
|
|
161
|
+
config,
|
|
162
|
+
flags: { disableEip5792, disable5792Upgrade, accountOverride } = {},
|
|
163
|
+
theme,
|
|
164
|
+
onSmartAccountRejection,
|
|
165
|
+
chains = [],
|
|
166
|
+
defaultChain,
|
|
167
|
+
thirdweb,
|
|
168
|
+
publicJsonRpcUrl,
|
|
169
|
+
onConnect,
|
|
170
|
+
onConnectError,
|
|
171
|
+
}: IBeraWagmiProviderProps) {
|
|
172
|
+
const {
|
|
173
|
+
wallet,
|
|
174
|
+
connect,
|
|
175
|
+
connectionId,
|
|
176
|
+
disconnect: disconnectProvider,
|
|
177
|
+
connectorName,
|
|
178
|
+
isEmbeddedWallet,
|
|
179
|
+
profiles,
|
|
180
|
+
preAuthenticate,
|
|
181
|
+
isConnecting,
|
|
182
|
+
} = useThirdwebLightWeight({
|
|
183
|
+
config,
|
|
184
|
+
theme,
|
|
185
|
+
chains,
|
|
186
|
+
chain: defaultChain,
|
|
187
|
+
publicJsonRpcUrl,
|
|
188
|
+
onConnect,
|
|
189
|
+
onConnectError,
|
|
190
|
+
});
|
|
191
|
+
|
|
192
|
+
const { address: connectedAddress, chainId } = useAccount(); // wagmi
|
|
193
|
+
|
|
194
|
+
const { disconnect: disconnectWagmi } = useDisconnect();
|
|
195
|
+
const publicClient = usePublicClient();
|
|
196
|
+
|
|
197
|
+
const address = useMemo<Address | undefined>(() => {
|
|
198
|
+
// no address anyway if no connected address
|
|
199
|
+
if (!connectedAddress || !wallet) return undefined;
|
|
200
|
+
|
|
201
|
+
return accountOverride ?? connectedAddress;
|
|
202
|
+
}, [accountOverride, connectedAddress, wallet]);
|
|
203
|
+
|
|
204
|
+
const { data: ens } = useEnsName({
|
|
205
|
+
config: config.wagmi,
|
|
206
|
+
chainId: defaultChain.id,
|
|
207
|
+
address,
|
|
208
|
+
});
|
|
209
|
+
|
|
210
|
+
const { data: code } = useSWRImmutable(
|
|
211
|
+
address ? (["BeraWagmiProvider_code", address, chainId] as const) : null,
|
|
212
|
+
([_, walletAddress, _chainId]) => {
|
|
213
|
+
return publicClient?.getCode({
|
|
214
|
+
address: walletAddress,
|
|
215
|
+
});
|
|
216
|
+
},
|
|
217
|
+
{
|
|
218
|
+
refreshInterval: 60_000,
|
|
219
|
+
},
|
|
220
|
+
);
|
|
221
|
+
const [isContract, has7702Authorization] = useMemo(() => {
|
|
222
|
+
if (!code)
|
|
223
|
+
// if no code, it's not a contract or has 7702 authorization
|
|
224
|
+
return [false, false];
|
|
225
|
+
|
|
226
|
+
const has7702Authorization = code.startsWith("0xef01");
|
|
227
|
+
|
|
228
|
+
if (has7702Authorization) {
|
|
229
|
+
// if has 7702 authorization, it's not a contract
|
|
230
|
+
return [false, true];
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
// if doesn't have 7702 authorization but has code, it's a contract
|
|
234
|
+
return [true, false];
|
|
235
|
+
}, [code]);
|
|
236
|
+
|
|
237
|
+
const { data: walletClient } = useWalletClient();
|
|
238
|
+
|
|
239
|
+
const normalizedEns = useMemo(() => {
|
|
240
|
+
try {
|
|
241
|
+
// some characters might throw an error when normalizing
|
|
242
|
+
// for instance `_` throws an error (e.g. `bera_boy`)
|
|
243
|
+
return ens ? normalize(ens) : undefined;
|
|
244
|
+
} catch {
|
|
245
|
+
// not catching the error here, just returning undefined
|
|
246
|
+
// @see https://berachain-dapps.sentry.io/issues/6949741717/?alert_rule_id=16379160&alert_type=issue¬ification_uuid=b01366a6-78b0-4348-a3c1-5f76ced1d539&project=4509842561630209
|
|
247
|
+
}
|
|
248
|
+
}, [ens]);
|
|
249
|
+
|
|
250
|
+
const avatar = useEnsAvatar({
|
|
251
|
+
name: normalizedEns,
|
|
252
|
+
});
|
|
253
|
+
|
|
254
|
+
return (
|
|
255
|
+
<BeraWagmiContext.Provider
|
|
256
|
+
value={{
|
|
257
|
+
preAuthenticate,
|
|
258
|
+
flags: {
|
|
259
|
+
disableEip5792: !!disableEip5792,
|
|
260
|
+
disable5792Upgrade: !!disable5792Upgrade,
|
|
261
|
+
},
|
|
262
|
+
walletClient,
|
|
263
|
+
onSmartAccountRejection: () => {
|
|
264
|
+
onSmartAccountRejection?.();
|
|
265
|
+
},
|
|
266
|
+
isEmbeddedWalletsEnabled: thirdweb.embeddedWallets ?? true,
|
|
267
|
+
isConnecting,
|
|
268
|
+
isConnected:
|
|
269
|
+
!!address &&
|
|
270
|
+
// this seems obvious but might fix some re-render issues.
|
|
271
|
+
!!walletClient,
|
|
272
|
+
DebugConnectButton() {
|
|
273
|
+
return null;
|
|
274
|
+
},
|
|
275
|
+
account:
|
|
276
|
+
wallet && chainId && address
|
|
277
|
+
? {
|
|
278
|
+
connectionId,
|
|
279
|
+
chainId,
|
|
280
|
+
connectorName,
|
|
281
|
+
isEmbeddedWallet,
|
|
282
|
+
profiles,
|
|
283
|
+
wallet: {
|
|
284
|
+
address,
|
|
285
|
+
ensName: ens?.replace(".bera", ".🐻⛓️") ?? null,
|
|
286
|
+
ensAvatar: avatar.data ?? null,
|
|
287
|
+
has7702Authorization,
|
|
288
|
+
isContract,
|
|
289
|
+
},
|
|
290
|
+
}
|
|
291
|
+
: undefined,
|
|
292
|
+
connect,
|
|
293
|
+
openConnectModal() {
|
|
294
|
+
throw new Error(
|
|
295
|
+
"openConnectModal is not available in lightweight mode. Use @berachain/wagmi/context/full instead.",
|
|
296
|
+
);
|
|
297
|
+
},
|
|
298
|
+
disconnect: () => {
|
|
299
|
+
disconnectWagmi();
|
|
300
|
+
disconnectProvider();
|
|
301
|
+
},
|
|
302
|
+
// chains,
|
|
303
|
+
defaultChainId: defaultChain.id,
|
|
304
|
+
}}
|
|
305
|
+
>
|
|
306
|
+
<LightweightAccountProvider
|
|
307
|
+
address={address}
|
|
308
|
+
defaultChainId={defaultChain.id}
|
|
309
|
+
>
|
|
310
|
+
{children}
|
|
311
|
+
</LightweightAccountProvider>
|
|
312
|
+
</BeraWagmiContext.Provider>
|
|
313
|
+
);
|
|
314
|
+
}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import { useMemo } from "react";
|
|
4
|
+
import { QueryClient, QueryClientProvider } from "@tanstack/react-query";
|
|
5
|
+
import { ThirdwebProvider } from "thirdweb/react";
|
|
6
|
+
import type { Chain, Transport } from "viem";
|
|
7
|
+
import { WagmiProvider as WagmiProviderBase } from "wagmi";
|
|
8
|
+
|
|
9
|
+
import { getConfig } from "../config/defaultWagmiConfig";
|
|
10
|
+
import { BeraWagmiProvider, type IBeraWagmiProviderProps } from "./BeraWagmiLightWeight";
|
|
11
|
+
|
|
12
|
+
type WagmiProviderProps = Omit<
|
|
13
|
+
IBeraWagmiProviderProps,
|
|
14
|
+
"config" | "defaultChain"
|
|
15
|
+
> & {
|
|
16
|
+
transports?: Record<number, Transport>;
|
|
17
|
+
defaultChain: Chain;
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
const queryClient = new QueryClient();
|
|
21
|
+
|
|
22
|
+
export function WagmiProvider({
|
|
23
|
+
transports,
|
|
24
|
+
defaultChain,
|
|
25
|
+
chains,
|
|
26
|
+
thirdweb,
|
|
27
|
+
...beraWagmiProps
|
|
28
|
+
}: WagmiProviderProps) {
|
|
29
|
+
// useMemo to make sure this is initialized only once
|
|
30
|
+
const config = useMemo(() => {
|
|
31
|
+
return getConfig({
|
|
32
|
+
thirdweb,
|
|
33
|
+
transports,
|
|
34
|
+
defaultChain,
|
|
35
|
+
chains,
|
|
36
|
+
});
|
|
37
|
+
}, [defaultChain, thirdweb, transports, chains]);
|
|
38
|
+
|
|
39
|
+
return (
|
|
40
|
+
<ThirdwebProvider>
|
|
41
|
+
<WagmiProviderBase
|
|
42
|
+
config={config.wagmi}
|
|
43
|
+
// must be false if using thirdweb autoconnect
|
|
44
|
+
reconnectOnMount={false}
|
|
45
|
+
>
|
|
46
|
+
<QueryClientProvider client={queryClient}>
|
|
47
|
+
<BeraWagmiProvider
|
|
48
|
+
{...beraWagmiProps}
|
|
49
|
+
thirdweb={thirdweb}
|
|
50
|
+
chains={chains}
|
|
51
|
+
defaultChain={defaultChain}
|
|
52
|
+
config={config}
|
|
53
|
+
/>
|
|
54
|
+
</QueryClientProvider>
|
|
55
|
+
</WagmiProviderBase>
|
|
56
|
+
</ThirdwebProvider>
|
|
57
|
+
);
|
|
58
|
+
}
|
|
@@ -23,17 +23,19 @@ import type { Chain } from "viem";
|
|
|
23
23
|
import { useConnect } from "wagmi";
|
|
24
24
|
|
|
25
25
|
import type { getConfig, InAppWallet } from "../config";
|
|
26
|
-
import type { BeraWagmiApi } from "./BeraWagmi";
|
|
26
|
+
import type { BeraWagmiApi, ConnectEvent } from "./BeraWagmi";
|
|
27
27
|
|
|
28
28
|
export function useThirdweb({
|
|
29
29
|
config,
|
|
30
30
|
theme,
|
|
31
31
|
chains = [],
|
|
32
32
|
chain,
|
|
33
|
-
|
|
33
|
+
onConnect,
|
|
34
|
+
onConnectError,
|
|
34
35
|
publicJsonRpcUrl = chain.rpcUrls.default.http[0],
|
|
35
36
|
}: {
|
|
36
|
-
|
|
37
|
+
onConnect?: (event: ConnectEvent) => void;
|
|
38
|
+
onConnectError?: (error: Error) => void;
|
|
37
39
|
config: ReturnType<typeof getConfig>;
|
|
38
40
|
theme: "light" | "dark" | "auto" | undefined;
|
|
39
41
|
chains?: Chain[];
|
|
@@ -152,34 +154,43 @@ export function useThirdweb({
|
|
|
152
154
|
...connectOptions,
|
|
153
155
|
...args,
|
|
154
156
|
})
|
|
155
|
-
.then(() => {
|
|
156
|
-
|
|
157
|
-
syncConnectedWallet(wallet);
|
|
157
|
+
.then(async () => {
|
|
158
|
+
onConnect?.({ type: "connect", data: args });
|
|
159
|
+
await syncConnectedWallet(wallet);
|
|
158
160
|
return wallet;
|
|
161
|
+
})
|
|
162
|
+
.catch((e) => {
|
|
163
|
+
onConnectError?.(e);
|
|
164
|
+
throw e;
|
|
159
165
|
});
|
|
160
166
|
});
|
|
161
167
|
},
|
|
162
168
|
async openConnectModal() {
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
169
|
+
try {
|
|
170
|
+
const wallet = await twConnectModal({
|
|
171
|
+
...connectOptions,
|
|
172
|
+
wallets: config.wallets,
|
|
173
|
+
theme: theme === "auto" ? undefined : theme,
|
|
174
|
+
size: "compact",
|
|
175
|
+
chains: [
|
|
176
|
+
thirdwebChain,
|
|
177
|
+
...chains
|
|
178
|
+
// avoid duplicates
|
|
179
|
+
.filter((c) => c.id !== thirdwebChain.id)
|
|
180
|
+
.map((c) =>
|
|
181
|
+
defineChain({
|
|
182
|
+
id: c.id,
|
|
183
|
+
}),
|
|
184
|
+
),
|
|
185
|
+
],
|
|
186
|
+
}); // opens the connect modal
|
|
187
|
+
|
|
188
|
+
onConnect?.({ type: "connect_modal" });
|
|
189
|
+
await syncConnectedWallet(wallet);
|
|
190
|
+
} catch (e) {
|
|
191
|
+
onConnectError?.(e as Error);
|
|
192
|
+
throw e;
|
|
193
|
+
}
|
|
183
194
|
},
|
|
184
195
|
disconnect() {
|
|
185
196
|
if (activeWallet) {
|
|
@@ -0,0 +1,177 @@
|
|
|
1
|
+
import { useMemo } from "react";
|
|
2
|
+
import type { ConnectionOptions } from "@thirdweb-dev/wagmi-adapter";
|
|
3
|
+
import { defineChain } from "thirdweb";
|
|
4
|
+
import {
|
|
5
|
+
useActiveAccount,
|
|
6
|
+
useActiveWallet,
|
|
7
|
+
useAutoConnect,
|
|
8
|
+
useProfiles,
|
|
9
|
+
useConnect as useTwConnect,
|
|
10
|
+
useDisconnect as useTwDisconnect,
|
|
11
|
+
useWalletInfo,
|
|
12
|
+
} from "thirdweb/react";
|
|
13
|
+
import type {
|
|
14
|
+
Account,
|
|
15
|
+
AutoConnectProps,
|
|
16
|
+
Profile,
|
|
17
|
+
Wallet,
|
|
18
|
+
} from "thirdweb/wallets";
|
|
19
|
+
import { preAuthenticate } from "thirdweb/wallets/in-app";
|
|
20
|
+
import type { Chain } from "viem";
|
|
21
|
+
import { useConnect } from "wagmi";
|
|
22
|
+
|
|
23
|
+
import type { getConfig, InAppWallet } from "../config";
|
|
24
|
+
import type { BeraWagmiApi, ConnectEvent } from "./BeraWagmiLightWeight";
|
|
25
|
+
|
|
26
|
+
export function useThirdwebLightWeight({
|
|
27
|
+
config,
|
|
28
|
+
chain,
|
|
29
|
+
onConnect,
|
|
30
|
+
onConnectError,
|
|
31
|
+
publicJsonRpcUrl = chain.rpcUrls.default.http[0],
|
|
32
|
+
}: {
|
|
33
|
+
onConnect?: (event: ConnectEvent) => void;
|
|
34
|
+
onConnectError?: (error: Error) => void;
|
|
35
|
+
config: ReturnType<typeof getConfig>;
|
|
36
|
+
theme: "light" | "dark" | "auto" | undefined;
|
|
37
|
+
chains?: Chain[];
|
|
38
|
+
publicJsonRpcUrl?: string;
|
|
39
|
+
chain: Chain;
|
|
40
|
+
}): Pick<
|
|
41
|
+
BeraWagmiApi,
|
|
42
|
+
| "connect"
|
|
43
|
+
| "openConnectModal"
|
|
44
|
+
| "disconnect"
|
|
45
|
+
| "isConnecting"
|
|
46
|
+
| "DebugConnectButton"
|
|
47
|
+
| "preAuthenticate"
|
|
48
|
+
> & {
|
|
49
|
+
connectionId: string;
|
|
50
|
+
connectorName: string | null;
|
|
51
|
+
isEmbeddedWallet: boolean;
|
|
52
|
+
wallet: Account | undefined;
|
|
53
|
+
profiles: Profile[] | undefined;
|
|
54
|
+
} {
|
|
55
|
+
const { connectors, connect: wagmiConnect } = useConnect();
|
|
56
|
+
|
|
57
|
+
const activeWallet = useActiveWallet();
|
|
58
|
+
const activeAccount = useActiveAccount(); // thirdweb
|
|
59
|
+
const { disconnect: disconnectThirdweb } = useTwDisconnect();
|
|
60
|
+
const { data: walletInfo } = useWalletInfo(activeWallet?.id);
|
|
61
|
+
const { connect: twConnect } = useTwConnect();
|
|
62
|
+
|
|
63
|
+
const { data: profiles } = useProfiles({ client: config.client });
|
|
64
|
+
|
|
65
|
+
const thirdwebChain = useMemo(
|
|
66
|
+
() =>
|
|
67
|
+
defineChain({
|
|
68
|
+
id: chain.id,
|
|
69
|
+
blockExplorers: chain.blockExplorers,
|
|
70
|
+
blockTime: chain.blockTime,
|
|
71
|
+
ensTlds: chain.ensTlds,
|
|
72
|
+
testnet: chain.testnet,
|
|
73
|
+
contracts: chain.contracts,
|
|
74
|
+
nativeCurrency: chain.nativeCurrency,
|
|
75
|
+
name: chain.name,
|
|
76
|
+
rpcUrls: {
|
|
77
|
+
default: {
|
|
78
|
+
http: [publicJsonRpcUrl],
|
|
79
|
+
},
|
|
80
|
+
},
|
|
81
|
+
}),
|
|
82
|
+
[publicJsonRpcUrl, chain],
|
|
83
|
+
);
|
|
84
|
+
|
|
85
|
+
const connectOptions = {
|
|
86
|
+
client: config.client,
|
|
87
|
+
chain: thirdwebChain,
|
|
88
|
+
wallets: config.wallets,
|
|
89
|
+
} as const satisfies AutoConnectProps;
|
|
90
|
+
|
|
91
|
+
async function syncConnectedWallet(wallet: Wallet) {
|
|
92
|
+
// console.debug("syncConnectedWallet", wallet);
|
|
93
|
+
// now "connect" the wagmi connector
|
|
94
|
+
const twConnector = connectors.find((c) => c.id === "in-app-wallet");
|
|
95
|
+
|
|
96
|
+
if (twConnector) {
|
|
97
|
+
const options: ConnectionOptions = {
|
|
98
|
+
withCapabilities: true,
|
|
99
|
+
wallet,
|
|
100
|
+
} as const;
|
|
101
|
+
|
|
102
|
+
wagmiConnect({
|
|
103
|
+
connector: twConnector,
|
|
104
|
+
chainId: chain.id,
|
|
105
|
+
...options,
|
|
106
|
+
});
|
|
107
|
+
} else {
|
|
108
|
+
// captureException is not available here since we don't have shared-ui
|
|
109
|
+
// however this happens only if wagmi is misconfigured
|
|
110
|
+
console.error("no tw connector found");
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
const { isLoading: isAutoConnecting } = useAutoConnect({
|
|
115
|
+
...connectOptions,
|
|
116
|
+
onConnect: syncConnectedWallet,
|
|
117
|
+
});
|
|
118
|
+
|
|
119
|
+
const connectionId = useMemo(() => {
|
|
120
|
+
// this might not be available in some environments
|
|
121
|
+
if ("randomUUID" in crypto) {
|
|
122
|
+
return crypto.randomUUID();
|
|
123
|
+
}
|
|
124
|
+
return Math.random().toString(36).substring(2, 15);
|
|
125
|
+
}, [activeWallet?.id, activeAccount?.address]);
|
|
126
|
+
|
|
127
|
+
return {
|
|
128
|
+
connect(args) {
|
|
129
|
+
if (!config.hasEmbeddedWallets) {
|
|
130
|
+
console.error(
|
|
131
|
+
"useBeraWagmi.connect: this function is not available if embedded wallets are disabled",
|
|
132
|
+
);
|
|
133
|
+
return;
|
|
134
|
+
}
|
|
135
|
+
return twConnect(async () => {
|
|
136
|
+
// this must be called inside twConnect or it won't work for social login wallets
|
|
137
|
+
const wallet = config.wallets.find(
|
|
138
|
+
(w) => w.id === "inApp",
|
|
139
|
+
) as InAppWallet;
|
|
140
|
+
|
|
141
|
+
if (!wallet) {
|
|
142
|
+
console.error("useBeraWagmi.connect: no inApp wallet found");
|
|
143
|
+
throw new Error("no inApp wallet found");
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
return wallet
|
|
147
|
+
.connect({
|
|
148
|
+
...connectOptions,
|
|
149
|
+
...args,
|
|
150
|
+
})
|
|
151
|
+
.then(async () => {
|
|
152
|
+
onConnect?.({ type: "connect", data: args });
|
|
153
|
+
await syncConnectedWallet(wallet);
|
|
154
|
+
return wallet;
|
|
155
|
+
})
|
|
156
|
+
.catch((e) => {
|
|
157
|
+
onConnectError?.(e);
|
|
158
|
+
throw e;
|
|
159
|
+
});
|
|
160
|
+
});
|
|
161
|
+
},
|
|
162
|
+
disconnect() {
|
|
163
|
+
if (activeWallet) {
|
|
164
|
+
disconnectThirdweb(activeWallet);
|
|
165
|
+
}
|
|
166
|
+
},
|
|
167
|
+
isConnecting: isAutoConnecting,
|
|
168
|
+
connectionId,
|
|
169
|
+
connectorName: walletInfo?.name ?? null,
|
|
170
|
+
isEmbeddedWallet: walletInfo?.id === "inApp",
|
|
171
|
+
wallet: activeAccount,
|
|
172
|
+
profiles,
|
|
173
|
+
preAuthenticate(args) {
|
|
174
|
+
return preAuthenticate({ ...args, client: config.client });
|
|
175
|
+
}
|
|
176
|
+
};
|
|
177
|
+
}
|
package/dist/chunk-4MF5YCJ5.mjs
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{usePublicClient as We}from"wagmi";import{useContext as X}from"react";import{createContext as Q}from"react";import{jsx as V}from"react/jsx-runtime";var E=Q(void 0);function N({children:e,address:n,defaultChainId:i}){return V(E.Provider,{value:{address:n,defaultChainId:i},children:e})}function T(){let e=X(E);if(!e)throw new Error("LightweightAccountContext not found");let{address:n,defaultChainId:i}=e;return{isConnected:!!n,address:n,defaultChainId:i}}import{useBlockNumber as ot,useChains as it,useConfig as rt,useEnsAvatar as k,useEnsName as z,useSwitchChain as at,useTransactionReceipt as st}from"wagmi";import{createContext as de,useContext as le,useMemo as U}from"react";import ue from"swr/immutable";import{normalize as pe}from"viem/ens";import{useAccount as me,useDisconnect as fe,usePublicClient as Ce,useWalletClient as ge}from"wagmi";import{useMemo as R}from"react";import{defineChain as S}from"thirdweb";import{ConnectButton as Y,useActiveAccount as Z,useActiveWallet as $,useAutoConnect as ee,useProfiles as te,useConnect as ne,useConnectModal as oe,useDisconnect as ie,useWalletInfo as re}from"thirdweb/react";import{preAuthenticate as ae}from"thirdweb/wallets/in-app";import{useConnect as se}from"wagmi";import{jsx as ce}from"react/jsx-runtime";function D({config:e,theme:n,chains:i=[],chain:t,onConnectedWallet:d,publicJsonRpcUrl:C=t.rpcUrls.default.http[0]}){let{connectors:b,connect:A}=se(),a=$(),g=Z(),{disconnect:w}=ie(),{data:l}=re(a?.id),{connect:W}=ne(),{data:y}=te({client:e.client}),m=R(()=>S({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:[C]}}}),[C,t]),u={client:e.client,chain:m,wallets:e.wallets};async function p(r){let o=b.find(s=>s.id==="in-app-wallet");if(o){let s={withCapabilities:!0,wallet:r};A({connector:o,chainId:t.id,...s})}else console.error("no tw connector found")}let{isLoading:P}=ee({...u,onConnect:p}),v=R(()=>"randomUUID"in crypto?crypto.randomUUID():Math.random().toString(36).substring(2,15),[a?.id,g?.address]),{connect:B}=oe();return{connect(r){if(!e.hasEmbeddedWallets){console.error("useBeraWagmi.connect: this function is not available if embedded wallets are disabled");return}return W(async()=>{let o=e.wallets.find(s=>s.id==="inApp");if(!o)throw console.error("useBeraWagmi.connect: no inApp wallet found"),new Error("no inApp wallet found");return o.connect({...u,...r}).then(()=>(d?.(),p(o),o))})},async openConnectModal(){let r=await B({...u,wallets:e.wallets,theme:n==="auto"?void 0:n,size:"compact",chains:[m,...i.filter(o=>o.id!==m.id).map(o=>S({id:o.id}))]});d?.(),await p(r)},disconnect(){a&&w(a)},isConnecting:P,connectionId:v,connectorName:l?.name??null,isEmbeddedWallet:l?.id==="inApp",wallet:g,profiles:y,preAuthenticate(r){return ae({...r,client:e.client})},DebugConnectButton(){return ce(Y,{...u,connectModal:{size:"compact"},onConnect:r=>p(r)})}}}import{jsx as L}from"react/jsx-runtime";function f(){let e=le(O);if(!e)throw new Error("BeraWagmiContext not found");return e}var O=de(void 0);function Ke({children:e,config:n,flags:{disableEip5792:i,disable5792Upgrade:t,accountOverride:d}={},theme:C,onSmartAccountRejection:b,chains:A=[],defaultChain:a,thirdweb:g,publicJsonRpcUrl:w}){let{wallet:l,openConnectModal:W,connect:y,DebugConnectButton:m,connectionId:u,disconnect:p,connectorName:P,isEmbeddedWallet:v,profiles:B,preAuthenticate:r,isConnecting:o}=D({config:n,theme:C,chains:A,chain:a,publicJsonRpcUrl:w}),{address:s,chainId:I}=me(),{disconnect:_}=fe(),q=Ce(),c=U(()=>{if(!(!s||!l))return d??s},[d,s,l]),{data:h}=z({config:n.wagmi,chainId:a.id,address:c}),{data:x}=ue(c?["BeraWagmiProvider_code",c,I]:null,([G,H,ye])=>q?.getCode({address:H}),{refreshInterval:6e4}),[J,K]=U(()=>x?x.startsWith("0xef01")?[!1,!0]:[!0,!1]:[!1,!1],[x]),{data:M}=ge(),j=U(()=>{try{return h?pe(h):void 0}catch{}},[h]),F=k({name:j});return L(O.Provider,{value:{preAuthenticate:r,flags:{disableEip5792:!!i,disable5792Upgrade:!!t},walletClient:M,onSmartAccountRejection:()=>{b?.()},isEmbeddedWalletsEnabled:g.embeddedWallets??!0,isConnecting:o,isConnected:!!c&&!!M,DebugConnectButton:m,account:l&&I&&c?{connectionId:u,chainId:I,connectorName:P,isEmbeddedWallet:v,profiles:B,wallet:{address:c,ensName:h?.replace(".bera",".\u{1F43B}\u26D3\uFE0F")??null,ensAvatar:F.data??null,has7702Authorization:K,isContract:J}}:void 0,connect:y,openConnectModal:async()=>{await W()},disconnect:()=>{_(),p()},defaultChainId:a.id},children:L(N,{address:c,defaultChainId:a.id,children:e})})}function he(){let{account:e,isConnected:n}=f();return{...e,isConnected:n}}import{useMemo as be}from"react";import{useCapabilities as Ae}from"wagmi";function we({chainId:e}){let{flags:n,account:i}=f(),{data:t}=Ae({account:i?.wallet?.address,scopeKey:i?.connectionId,query:{retry:3},chainId:e});return{supportsAtomic:be(()=>n.disableEip5792||!t?!1:t?.atomic?.status==="supported"||!n.disable5792Upgrade&&t?.atomic?.status==="ready",[t,n.disableEip5792,n.disable5792Upgrade,e]),capabilities:t}}function et(e){let{defaultChainId:n}=T(),{chainId:i,...t}=e??{};return We({chainId:i??n,...t})}export{T as a,he as b,we as c,et as d,ot as e,it as f,rt as g,k as h,z as i,at as j,st as k,f as l,Ke as m};
|
package/dist/chunk-PNOS6IM4.cjs
DELETED
|
@@ -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 E=_react.createContext.call(void 0, void 0);function N({children:e,address:n,defaultChainId:i}){return _jsxruntime.jsx.call(void 0, E.Provider,{value:{address:n,defaultChainId:i},children:e})}function T(){let e=_react.useContext.call(void 0, E);if(!e)throw new Error("LightweightAccountContext not found");let{address:n,defaultChainId:i}=e;return{isConnected:!!n,address:n,defaultChainId:i}}var _immutable = require('swr/immutable'); var _immutable2 = _interopRequireDefault(_immutable);var _ens = require('viem/ens');var _thirdweb = require('thirdweb');var _react3 = require('thirdweb/react');var _inapp = require('thirdweb/wallets/in-app');function D({config:e,theme:n,chains:i=[],chain:t,onConnectedWallet:d,publicJsonRpcUrl:C=t.rpcUrls.default.http[0]}){let{connectors:b,connect:A}=_wagmi.useConnect.call(void 0, ),a=_react3.useActiveWallet.call(void 0, ),g=_react3.useActiveAccount.call(void 0, ),{disconnect:w}=_react3.useDisconnect.call(void 0, ),{data:l}=_react3.useWalletInfo.call(void 0, _optionalChain([a, 'optionalAccess', _2 => _2.id])),{connect:W}=_react3.useConnect.call(void 0, ),{data:y}=_react3.useProfiles.call(void 0, {client:e.client}),m=_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:[C]}}}),[C,t]),u={client:e.client,chain:m,wallets:e.wallets};async function p(r){let o=b.find(s=>s.id==="in-app-wallet");if(o){let s={withCapabilities:!0,wallet:r};A({connector:o,chainId:t.id,...s})}else console.error("no tw connector found")}let{isLoading:P}=_react3.useAutoConnect.call(void 0, {...u,onConnect:p}),v=_react.useMemo.call(void 0, ()=>"randomUUID"in crypto?crypto.randomUUID():Math.random().toString(36).substring(2,15),[_optionalChain([a, 'optionalAccess', _3 => _3.id]),_optionalChain([g, 'optionalAccess', _4 => _4.address])]),{connect:B}=_react3.useConnectModal.call(void 0, );return{connect(r){if(!e.hasEmbeddedWallets){console.error("useBeraWagmi.connect: this function is not available if embedded wallets are disabled");return}return W(async()=>{let o=e.wallets.find(s=>s.id==="inApp");if(!o)throw console.error("useBeraWagmi.connect: no inApp wallet found"),new Error("no inApp wallet found");return o.connect({...u,...r}).then(()=>(_optionalChain([d, 'optionalCall', _5 => _5()]),p(o),o))})},async openConnectModal(){let r=await B({...u,wallets:e.wallets,theme:n==="auto"?void 0:n,size:"compact",chains:[m,...i.filter(o=>o.id!==m.id).map(o=>_thirdweb.defineChain.call(void 0, {id:o.id}))]});_optionalChain([d, 'optionalCall', _6 => _6()]),await p(r)},disconnect(){a&&w(a)},isConnecting:P,connectionId:v,connectorName:_nullishCoalesce(_optionalChain([l, 'optionalAccess', _7 => _7.name]), () => (null)),isEmbeddedWallet:_optionalChain([l, 'optionalAccess', _8 => _8.id])==="inApp",wallet:g,profiles:y,preAuthenticate(r){return _inapp.preAuthenticate.call(void 0, {...r,client:e.client})},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 Ke({children:e,config:n,flags:{disableEip5792:i,disable5792Upgrade:t,accountOverride:d}={},theme:C,onSmartAccountRejection:b,chains:A=[],defaultChain:a,thirdweb:g,publicJsonRpcUrl:w}){let{wallet:l,openConnectModal:W,connect:y,DebugConnectButton:m,connectionId:u,disconnect:p,connectorName:P,isEmbeddedWallet:v,profiles:B,preAuthenticate:r,isConnecting:o}=D({config:n,theme:C,chains:A,chain:a,publicJsonRpcUrl:w}),{address:s,chainId:I}=_wagmi.useAccount.call(void 0, ),{disconnect:_}=_wagmi.useDisconnect.call(void 0, ),q=_wagmi.usePublicClient.call(void 0, ),c=_react.useMemo.call(void 0, ()=>{if(!(!s||!l))return _nullishCoalesce(d, () => (s))},[d,s,l]),{data:h}=_wagmi.useEnsName.call(void 0, {config:n.wagmi,chainId:a.id,address:c}),{data:x}=_immutable2.default.call(void 0, c?["BeraWagmiProvider_code",c,I]:null,([G,H,ye])=>_optionalChain([q, 'optionalAccess', _9 => _9.getCode, 'call', _10 => _10({address:H})]),{refreshInterval:6e4}),[J,K]=_react.useMemo.call(void 0, ()=>x?x.startsWith("0xef01")?[!1,!0]:[!0,!1]:[!1,!1],[x]),{data:M}=_wagmi.useWalletClient.call(void 0, ),j=_react.useMemo.call(void 0, ()=>{try{return h?_ens.normalize.call(void 0, h):void 0}catch (e2){}},[h]),F=_wagmi.useEnsAvatar.call(void 0, {name:j});return _jsxruntime.jsx.call(void 0, O.Provider,{value:{preAuthenticate:r,flags:{disableEip5792:!!i,disable5792Upgrade:!!t},walletClient:M,onSmartAccountRejection:()=>{_optionalChain([b, 'optionalCall', _11 => _11()])},isEmbeddedWalletsEnabled:_nullishCoalesce(g.embeddedWallets, () => (!0)),isConnecting:o,isConnected:!!c&&!!M,DebugConnectButton:m,account:l&&I&&c?{connectionId:u,chainId:I,connectorName:P,isEmbeddedWallet:v,profiles:B,wallet:{address:c,ensName:_nullishCoalesce(_optionalChain([h, 'optionalAccess', _12 => _12.replace, 'call', _13 => _13(".bera",".\u{1F43B}\u26D3\uFE0F")]), () => (null)),ensAvatar:_nullishCoalesce(F.data, () => (null)),has7702Authorization:K,isContract:J}}:void 0,connect:y,openConnectModal:async()=>{await W()},disconnect:()=>{_(),p()},defaultChainId:a.id},children:_jsxruntime.jsx.call(void 0, N,{address:c,defaultChainId:a.id,children:e})})}function he(){let{account:e,isConnected:n}=f();return{...e,isConnected:n}}function we({chainId:e}){let{flags:n,account:i}=f(),{data:t}=_wagmi.useCapabilities.call(void 0, {account:_optionalChain([i, 'optionalAccess', _14 => _14.wallet, 'optionalAccess', _15 => _15.address]),scopeKey:_optionalChain([i, 'optionalAccess', _16 => _16.connectionId]),query:{retry:3},chainId:e});return{supportsAtomic:_react.useMemo.call(void 0, ()=>n.disableEip5792||!t?!1:_optionalChain([t, 'optionalAccess', _17 => _17.atomic, 'optionalAccess', _18 => _18.status])==="supported"||!n.disable5792Upgrade&&_optionalChain([t, 'optionalAccess', _19 => _19.atomic, 'optionalAccess', _20 => _20.status])==="ready",[t,n.disableEip5792,n.disable5792Upgrade,e]),capabilities:t}}function et(e){let{defaultChainId:n}=T(),{chainId:i,...t}=_nullishCoalesce(e, () => ({}));return _wagmi.usePublicClient.call(void 0, {chainId:_nullishCoalesce(i, () => (n)),...t})}exports.a = T; exports.b = he; exports.c = we; exports.d = et; 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 = Ke;
|