@berachain/wagmi 0.4.2-beta.2 → 0.4.2-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.
- package/dist/{BeraWagmi-D_9r9lFE.d.cts → BeraWagmi-DPriTsqn.d.cts} +1 -1
- package/dist/{BeraWagmi-BYoBR8sq.d.ts → BeraWagmi-PCCV3r-u.d.ts} +1 -1
- package/dist/chunk-FMEKPQER.cjs +1 -0
- package/dist/chunk-FPJ6HXP4.mjs +1 -0
- package/dist/chunk-HU7OL27P.mjs +1 -0
- package/dist/chunk-OLYL3V2D.cjs +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/lightweight/index.cjs +1 -0
- package/dist/context/lightweight/index.d.cts +27 -0
- package/dist/context/lightweight/index.d.ts +27 -0
- package/dist/context/lightweight/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 +1 -1
- package/src/context/BeraWagmi.tsx +18 -147
- package/src/context/BeraWagmiLightWeight.tsx +37 -174
- package/src/context/WagmiProviderLightWeight.tsx +39 -14
- package/src/context/beraWagmiContext.ts +7 -0
- package/src/context/useThirdweb.tsx +21 -158
- package/src/context/useThirdwebLightWeight.tsx +26 -23
- package/dist/chunk-CGJ4MZ4C.mjs +0 -1
- package/dist/chunk-GZLYCTRI.cjs +0 -1
- package/dist/chunk-HSGI3QYR.cjs +0 -1
- package/dist/chunk-RFS3IIRD.mjs +0 -1
- package/dist/context/thirdweb/index.cjs +0 -1
- package/dist/context/thirdweb/index.d.cts +0 -47
- package/dist/context/thirdweb/index.d.ts +0 -47
- package/dist/context/thirdweb/index.mjs +0 -1
- /package/src/context/{thirdweb → lightweight}/index.ts +0 -0
|
@@ -120,4 +120,4 @@ interface IBeraWagmiProviderProps extends PropsWithChildren {
|
|
|
120
120
|
publicJsonRpcUrl?: string;
|
|
121
121
|
}
|
|
122
122
|
|
|
123
|
-
export { type BeraWagmiApi as B,
|
|
123
|
+
export { type BeraWagmiApi as B, type ConnectEvent as C, type IBeraWagmiProviderProps as I, ChainId as a, useBeraWagmi as u };
|
|
@@ -120,4 +120,4 @@ interface IBeraWagmiProviderProps extends PropsWithChildren {
|
|
|
120
120
|
publicJsonRpcUrl?: string;
|
|
121
121
|
}
|
|
122
122
|
|
|
123
|
-
export { type BeraWagmiApi as B,
|
|
123
|
+
export { type BeraWagmiApi as B, type ConnectEvent as C, type IBeraWagmiProviderProps as I, ChainId as a, useBeraWagmi as u };
|
|
@@ -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 _chunkOLYL3V2Dcjs = require('./chunk-OLYL3V2D.cjs');var _react = require('react');var _thirdweb = require('thirdweb');var _react3 = require('thirdweb/react');var _jsxruntime = require('react/jsx-runtime');function h({config:n,theme:o,chains:d=[],chain:l,onConnect:r,onConnectError:a,publicJsonRpcUrl:c}){let e=_chunkOLYL3V2Dcjs.d.call(void 0, {config:n,chain:l,onConnect:r,onConnectError:a,publicJsonRpcUrl:c}),{connect:s}=_react3.useConnectModal.call(void 0, );return{...e,async openConnectModal(){try{let t=await s({...e.connectOptions,wallets:n.wallets,theme:o==="auto"?void 0:o,size:"compact",chains:[e.thirdwebChain,...d.filter(i=>i.id!==e.thirdwebChain.id).map(i=>_thirdweb.defineChain.call(void 0, {id:i.id}))]});_optionalChain([r, 'optionalCall', _ => _({type:"connect_modal"})]),await e.syncConnectedWallet(t)}catch(t){throw _optionalChain([a, 'optionalCall', _2 => _2(t)]),t}},DebugConnectButton(){return _jsxruntime.jsx.call(void 0, _react3.ConnectButton,{...e.connectOptions,connectModal:{size:"compact"},onConnect:t=>e.syncConnectedWallet(t)})}}}function x(){let n=_react.useContext.call(void 0, _chunkOLYL3V2Dcjs.a);if(!n)throw new Error("BeraWagmiContext not found");return n}function U({children:n,config:o,flags:d,theme:l,onSmartAccountRejection:r,chains:a=[],defaultChain:c,thirdweb:e,publicJsonRpcUrl:s,onConnect:t,onConnectError:i}){let p=h({config:o,theme:l,chains:a,chain:c,publicJsonRpcUrl:s,onConnect:t,onConnectError:i});return _jsxruntime.jsx.call(void 0, _chunkOLYL3V2Dcjs.c,{config:o,flags:d,onSmartAccountRejection:r,defaultChain:c,thirdweb:e,thirdwebResult:p,openConnectModal:async()=>{await p.openConnectModal()},DebugConnectButton:p.DebugConnectButton,children:n})}exports.a = x; exports.b = U;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{createContext as O}from"react";var I=O(void 0);import{createContext as S}from"react";import{jsx as j}from"react/jsx-runtime";var _=S(void 0);function T({children:o,address:e,defaultChainId:c}){return j(_.Provider,{value:{address:e,defaultChainId:c},children:o})}import{useMemo as y}from"react";import q from"swr/immutable";import{normalize as F}from"viem/ens";import{useAccount as G,useDisconnect as H,useEnsAvatar as J,useEnsName as K,usePublicClient as Q,useWalletClient as V}from"wagmi";import{jsx as x}from"react/jsx-runtime";function we({children:o,config:e,flags:{disableEip5792:c,disable5792Upgrade:g,accountOverride:d}={},onSmartAccountRejection:C,defaultChain:l,thirdweb:a,thirdwebResult:{wallet:s,connect:w,connectionId:m,disconnect:A,connectorName:b,isEmbeddedWallet:f,profiles:u,preAuthenticate:p,isConnecting:W},openConnectModal:v,DebugConnectButton:i}){let{address:n,chainId:t}=G(),{disconnect:U}=H(),R=Q(),r=y(()=>{if(!(!n||!s))return d??n},[d,n,s]),{data:h}=K({config:e.wagmi,chainId:l.id,address:r}),{data:B}=q(r?["BeraWagmiProvider_code",r,t]:null,([k,N,ae])=>R?.getCode({address:N}),{refreshInterval:6e4}),[D,L]=y(()=>B?B.startsWith("0xef01")?[!1,!0]:[!0,!1]:[!1,!1],[B]),{data:P}=V(),M=y(()=>{try{return h?F(h):void 0}catch{}},[h]),z=J({name:M});return x(I.Provider,{value:{preAuthenticate:p,flags:{disableEip5792:!!c,disable5792Upgrade:!!g},walletClient:P,onSmartAccountRejection:()=>{C?.()},isEmbeddedWalletsEnabled:a.embeddedWallets??!0,isConnecting:W,isConnected:!!r&&!!P,DebugConnectButton:i??(()=>null),account:s&&t&&r?{connectionId:m,chainId:t,connectorName:b,isEmbeddedWallet:f,profiles:u,wallet:{address:r,ensName:h?.replace(".bera",".\u{1F43B}\u26D3\uFE0F")??null,ensAvatar:z.data??null,has7702Authorization:L,isContract:D}}:void 0,connect:w,openConnectModal:v??(()=>{throw new Error("openConnectModal is not available in lightweight mode. Use @berachain/wagmi/context instead.")}),disconnect:()=>{U(),A()},defaultChainId:l.id},children:x(T,{address:r,defaultChainId:l.id,children:o})})}import{useMemo as E}from"react";import{defineChain as X}from"thirdweb";import{useActiveAccount as Y,useActiveWallet as Z,useAutoConnect as $,useProfiles as ee,useConnect as te,useDisconnect as ne,useWalletInfo as oe}from"thirdweb/react";import{preAuthenticate as ie}from"thirdweb/wallets/in-app";import{useConnect as re}from"wagmi";function Ie({config:o,chain:e,onConnect:c,onConnectError:g,publicJsonRpcUrl:d=e.rpcUrls.default.http[0]}){let{connectors:C,connect:l}=re(),a=Z(),s=Y(),{disconnect:w}=ne(),{data:m}=oe(a?.id),{connect:A}=te(),{data:b}=ee({client:o.client}),f=E(()=>X({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:[d]}}}),[d,e]),u={client:o.client,chain:f,wallets:o.wallets};async function p(i){let n=C.find(t=>t.id==="in-app-wallet");if(n){let t={withCapabilities:!0,wallet:i};l({connector:n,chainId:e.id,...t})}else console.error("no tw connector found")}let{isLoading:W}=$({...u,onConnect:p}),v=E(()=>"randomUUID"in crypto?crypto.randomUUID():Math.random().toString(36).substring(2,15),[a?.id,s?.address]);return{connect(i){if(!o.hasEmbeddedWallets){console.error("useBeraWagmi.connect: this function is not available if embedded wallets are disabled");return}return A(async()=>{let n=o.wallets.find(t=>t.id==="inApp");if(!n)throw console.error("useBeraWagmi.connect: no inApp wallet found"),new Error("no inApp wallet found");return n.connect({...u,...i}).then(async()=>(c?.({type:"connect",data:i}),await p(n),n)).catch(t=>{throw g?.(t),t})})},disconnect(){a&&w(a)},isConnecting:W,connectionId:v,connectorName:m?.name??null,isEmbeddedWallet:m?.id==="inApp",wallet:s,profiles:b,preAuthenticate(i){return ie({...i,client:o.client})},syncConnectedWallet:p,connectOptions:u,thirdwebChain:f}}export{I as a,_ as b,we as c,Ie as d};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a as u,c as m,d as g}from"./chunk-FPJ6HXP4.mjs";import{useContext as w}from"react";import{defineChain as f}from"thirdweb";import{ConnectButton as C,useConnectModal as b}from"thirdweb/react";import{jsx as y}from"react/jsx-runtime";function h({config:n,theme:o,chains:d=[],chain:l,onConnect:r,onConnectError:a,publicJsonRpcUrl:c}){let e=g({config:n,chain:l,onConnect:r,onConnectError:a,publicJsonRpcUrl:c}),{connect:s}=b();return{...e,async openConnectModal(){try{let t=await s({...e.connectOptions,wallets:n.wallets,theme:o==="auto"?void 0:o,size:"compact",chains:[e.thirdwebChain,...d.filter(i=>i.id!==e.thirdwebChain.id).map(i=>f({id:i.id}))]});r?.({type:"connect_modal"}),await e.syncConnectedWallet(t)}catch(t){throw a?.(t),t}},DebugConnectButton(){return y(C,{...e.connectOptions,connectModal:{size:"compact"},onConnect:t=>e.syncConnectedWallet(t)})}}}import{jsx as A}from"react/jsx-runtime";function x(){let n=w(u);if(!n)throw new Error("BeraWagmiContext not found");return n}function U({children:n,config:o,flags:d,theme:l,onSmartAccountRejection:r,chains:a=[],defaultChain:c,thirdweb:e,publicJsonRpcUrl:s,onConnect:t,onConnectError:i}){let p=h({config:o,theme:l,chains:a,chain:c,publicJsonRpcUrl:s,onConnect:t,onConnectError:i});return A(m,{config:o,flags:d,onSmartAccountRejection:r,defaultChain:c,thirdweb:e,thirdwebResult:p,openConnectModal:async()=>{await p.openConnectModal()},DebugConnectButton:p.DebugConnectButton,children:n})}export{x as a,U as b};
|
|
@@ -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 _react = require('react');var I=_react.createContext.call(void 0, void 0);var _jsxruntime = require('react/jsx-runtime');var _=_react.createContext.call(void 0, void 0);function T({children:o,address:e,defaultChainId:c}){return _jsxruntime.jsx.call(void 0, _.Provider,{value:{address:e,defaultChainId:c},children:o})}var _immutable = require('swr/immutable'); var _immutable2 = _interopRequireDefault(_immutable);var _ens = require('viem/ens');var _wagmi = require('wagmi');function we({children:o,config:e,flags:{disableEip5792:c,disable5792Upgrade:g,accountOverride:d}={},onSmartAccountRejection:C,defaultChain:l,thirdweb:a,thirdwebResult:{wallet:s,connect:w,connectionId:m,disconnect:A,connectorName:b,isEmbeddedWallet:f,profiles:u,preAuthenticate:p,isConnecting:W},openConnectModal:v,DebugConnectButton:i}){let{address:n,chainId:t}=_wagmi.useAccount.call(void 0, ),{disconnect:U}=_wagmi.useDisconnect.call(void 0, ),R=_wagmi.usePublicClient.call(void 0, ),r=_react.useMemo.call(void 0, ()=>{if(!(!n||!s))return _nullishCoalesce(d, () => (n))},[d,n,s]),{data:h}=_wagmi.useEnsName.call(void 0, {config:e.wagmi,chainId:l.id,address:r}),{data:B}=_immutable2.default.call(void 0, r?["BeraWagmiProvider_code",r,t]:null,([k,N,ae])=>_optionalChain([R, 'optionalAccess', _2 => _2.getCode, 'call', _3 => _3({address:N})]),{refreshInterval:6e4}),[D,L]=_react.useMemo.call(void 0, ()=>B?B.startsWith("0xef01")?[!1,!0]:[!0,!1]:[!1,!1],[B]),{data:P}=_wagmi.useWalletClient.call(void 0, ),M=_react.useMemo.call(void 0, ()=>{try{return h?_ens.normalize.call(void 0, h):void 0}catch (e2){}},[h]),z=_wagmi.useEnsAvatar.call(void 0, {name:M});return _jsxruntime.jsx.call(void 0, I.Provider,{value:{preAuthenticate:p,flags:{disableEip5792:!!c,disable5792Upgrade:!!g},walletClient:P,onSmartAccountRejection:()=>{_optionalChain([C, 'optionalCall', _4 => _4()])},isEmbeddedWalletsEnabled:_nullishCoalesce(a.embeddedWallets, () => (!0)),isConnecting:W,isConnected:!!r&&!!P,DebugConnectButton:_nullishCoalesce(i, () => ((()=>null))),account:s&&t&&r?{connectionId:m,chainId:t,connectorName:b,isEmbeddedWallet:f,profiles:u,wallet:{address:r,ensName:_nullishCoalesce(_optionalChain([h, 'optionalAccess', _5 => _5.replace, 'call', _6 => _6(".bera",".\u{1F43B}\u26D3\uFE0F")]), () => (null)),ensAvatar:_nullishCoalesce(z.data, () => (null)),has7702Authorization:L,isContract:D}}:void 0,connect:w,openConnectModal:_nullishCoalesce(v, () => ((()=>{throw new Error("openConnectModal is not available in lightweight mode. Use @berachain/wagmi/context instead.")}))),disconnect:()=>{U(),A()},defaultChainId:l.id},children:_jsxruntime.jsx.call(void 0, T,{address:r,defaultChainId:l.id,children:o})})}var _thirdweb = require('thirdweb');var _react3 = require('thirdweb/react');var _inapp = require('thirdweb/wallets/in-app');function Ie({config:o,chain:e,onConnect:c,onConnectError:g,publicJsonRpcUrl:d=e.rpcUrls.default.http[0]}){let{connectors:C,connect:l}=_wagmi.useConnect.call(void 0, ),a=_react3.useActiveWallet.call(void 0, ),s=_react3.useActiveAccount.call(void 0, ),{disconnect:w}=_react3.useDisconnect.call(void 0, ),{data:m}=_react3.useWalletInfo.call(void 0, _optionalChain([a, 'optionalAccess', _7 => _7.id])),{connect:A}=_react3.useConnect.call(void 0, ),{data:b}=_react3.useProfiles.call(void 0, {client:o.client}),f=_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:[d]}}}),[d,e]),u={client:o.client,chain:f,wallets:o.wallets};async function p(i){let n=C.find(t=>t.id==="in-app-wallet");if(n){let t={withCapabilities:!0,wallet:i};l({connector:n,chainId:e.id,...t})}else console.error("no tw connector found")}let{isLoading:W}=_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', _8 => _8.id]),_optionalChain([s, 'optionalAccess', _9 => _9.address])]);return{connect(i){if(!o.hasEmbeddedWallets){console.error("useBeraWagmi.connect: this function is not available if embedded wallets are disabled");return}return A(async()=>{let n=o.wallets.find(t=>t.id==="inApp");if(!n)throw console.error("useBeraWagmi.connect: no inApp wallet found"),new Error("no inApp wallet found");return n.connect({...u,...i}).then(async()=>(_optionalChain([c, 'optionalCall', _10 => _10({type:"connect",data:i})]),await p(n),n)).catch(t=>{throw _optionalChain([g, 'optionalCall', _11 => _11(t)]),t})})},disconnect(){a&&w(a)},isConnecting:W,connectionId:v,connectorName:_nullishCoalesce(_optionalChain([m, 'optionalAccess', _12 => _12.name]), () => (null)),isEmbeddedWallet:_optionalChain([m, 'optionalAccess', _13 => _13.id])==="inApp",wallet:s,profiles:b,preAuthenticate(i){return _inapp.preAuthenticate.call(void 0, {...i,client:o.client})},syncConnectedWallet:p,connectOptions:u,thirdwebChain:f}}exports.a = I; exports.b = _; exports.c = we; exports.d = Ie;
|
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 _chunkFMEKPQERcjs = require('../chunk-FMEKPQER.cjs');var _chunkPVMPBWIGcjs = require('../chunk-PVMPBWIG.cjs');require('../chunk-OLYL3V2D.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, _chunkFMEKPQERcjs.b,{...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-DPriTsqn.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-PCCV3r-u.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{b as a}from"../chunk-HU7OL27P.mjs";import{a as m}from"../chunk-MZZ62TKM.mjs";import"../chunk-FPJ6HXP4.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});"use client";var _chunkPVMPBWIGcjs = require('../../chunk-PVMPBWIG.cjs');var _chunkOLYL3V2Dcjs = require('../../chunk-OLYL3V2D.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 C=new _reactquery.QueryClient;function A({transports:t,defaultChain:r,chains:n,thirdweb:i,children:s,onConnect:c,onConnectError:g,publicJsonRpcUrl:p,...f}){let o=_react.useMemo.call(void 0, ()=>_chunkPVMPBWIGcjs.a.call(void 0, {thirdweb:i,transports:t,defaultChain:r,chains:n}),[r,i,t,n]),h=_chunkOLYL3V2Dcjs.d.call(void 0, {config:o,chain:r,publicJsonRpcUrl:p,onConnect:c,onConnectError:g});return _jsxruntime.jsx.call(void 0, _react3.ThirdwebProvider,{children:_jsxruntime.jsx.call(void 0, _wagmi.WagmiProvider,{config:o.wagmi,reconnectOnMount:!1,children:_jsxruntime.jsx.call(void 0, _reactquery.QueryClientProvider,{client:C,children:_jsxruntime.jsx.call(void 0, _chunkOLYL3V2Dcjs.c,{...f,thirdweb:i,defaultChain:r,config:o,thirdwebResult:h,children:s})})})})}exports.WagmiProvider = A;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
+
import { PropsWithChildren } from 'react';
|
|
3
|
+
import { Transport, Chain, Address } from 'viem';
|
|
4
|
+
import { ThirdwebConfig } from '../../config/index.cjs';
|
|
5
|
+
import { C as ConnectEvent } from '../../BeraWagmi-DPriTsqn.cjs';
|
|
6
|
+
import 'thirdweb';
|
|
7
|
+
import 'thirdweb/wallets';
|
|
8
|
+
import 'wagmi';
|
|
9
|
+
|
|
10
|
+
type WagmiProviderLightWeightProps = PropsWithChildren<{
|
|
11
|
+
transports?: Record<number, Transport>;
|
|
12
|
+
defaultChain: Chain;
|
|
13
|
+
chains?: Chain[];
|
|
14
|
+
thirdweb: ThirdwebConfig;
|
|
15
|
+
flags?: {
|
|
16
|
+
disableEip5792?: boolean;
|
|
17
|
+
disable5792Upgrade?: boolean;
|
|
18
|
+
accountOverride?: Address;
|
|
19
|
+
};
|
|
20
|
+
onSmartAccountRejection?: () => void;
|
|
21
|
+
onConnect?: (event: ConnectEvent) => void;
|
|
22
|
+
onConnectError?: (error: Error) => void;
|
|
23
|
+
publicJsonRpcUrl?: string;
|
|
24
|
+
}>;
|
|
25
|
+
declare function WagmiProvider({ transports, defaultChain, chains, thirdweb, children, onConnect, onConnectError, publicJsonRpcUrl, ...baseProps }: WagmiProviderLightWeightProps): react_jsx_runtime.JSX.Element;
|
|
26
|
+
|
|
27
|
+
export { WagmiProvider };
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
+
import { PropsWithChildren } from 'react';
|
|
3
|
+
import { Transport, Chain, Address } from 'viem';
|
|
4
|
+
import { ThirdwebConfig } from '../../config/index.js';
|
|
5
|
+
import { C as ConnectEvent } from '../../BeraWagmi-PCCV3r-u.js';
|
|
6
|
+
import 'thirdweb';
|
|
7
|
+
import 'thirdweb/wallets';
|
|
8
|
+
import 'wagmi';
|
|
9
|
+
|
|
10
|
+
type WagmiProviderLightWeightProps = PropsWithChildren<{
|
|
11
|
+
transports?: Record<number, Transport>;
|
|
12
|
+
defaultChain: Chain;
|
|
13
|
+
chains?: Chain[];
|
|
14
|
+
thirdweb: ThirdwebConfig;
|
|
15
|
+
flags?: {
|
|
16
|
+
disableEip5792?: boolean;
|
|
17
|
+
disable5792Upgrade?: boolean;
|
|
18
|
+
accountOverride?: Address;
|
|
19
|
+
};
|
|
20
|
+
onSmartAccountRejection?: () => void;
|
|
21
|
+
onConnect?: (event: ConnectEvent) => void;
|
|
22
|
+
onConnectError?: (error: Error) => void;
|
|
23
|
+
publicJsonRpcUrl?: string;
|
|
24
|
+
}>;
|
|
25
|
+
declare function WagmiProvider({ transports, defaultChain, chains, thirdweb, children, onConnect, onConnectError, publicJsonRpcUrl, ...baseProps }: WagmiProviderLightWeightProps): react_jsx_runtime.JSX.Element;
|
|
26
|
+
|
|
27
|
+
export { WagmiProvider };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use client";import{a as m}from"../../chunk-MZZ62TKM.mjs";import{c as a,d}from"../../chunk-FPJ6HXP4.mjs";import{useMemo as v}from"react";import{QueryClient as l,QueryClientProvider as u}from"@tanstack/react-query";import{ThirdwebProvider as P}from"thirdweb/react";import{WagmiProvider as b}from"wagmi";import{jsx as e}from"react/jsx-runtime";var C=new l;function A({transports:t,defaultChain:r,chains:n,thirdweb:i,children:s,onConnect:c,onConnectError:g,publicJsonRpcUrl:p,...f}){let o=v(()=>m({thirdweb:i,transports:t,defaultChain:r,chains:n}),[r,i,t,n]),h=d({config:o,chain:r,publicJsonRpcUrl:p,onConnect:c,onConnectError:g});return e(P,{children:e(b,{config:o.wagmi,reconnectOnMount:!1,children:e(u,{client:C,children:e(a,{...f,thirdweb:i,defaultChain:r,config:o,thirdwebResult:h,children:s})})})})}export{A 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}); 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 _chunkFMEKPQERcjs = require('../chunk-FMEKPQER.cjs');var _chunkOLYL3V2Dcjs = require('../chunk-OLYL3V2D.cjs');var _wagmi = require('wagmi');var _react = require('react');function a(){let t=_react.useContext.call(void 0, _chunkOLYL3V2Dcjs.b);if(!t)throw new Error("LightweightAccountContext not found");let{address:e,defaultChainId:r}=t;return{isConnected:!!e,address:e,defaultChainId:r}}function u(){let{account:t,isConnected:e}=_chunkFMEKPQERcjs.a.call(void 0, );return{...t,isConnected:e}}function p({chainId:t}){let{flags:e,account:r}=_chunkFMEKPQERcjs.a.call(void 0, ),{data:i}=_wagmi.useCapabilities.call(void 0, {account:_optionalChain([r, 'optionalAccess', _ => _.wallet, 'optionalAccess', _2 => _2.address]),scopeKey:_optionalChain([r, 'optionalAccess', _3 => _3.connectionId]),query:{retry:3},chainId:t});return{supportsAtomic:_react.useMemo.call(void 0, ()=>e.disableEip5792||!i?!1:_optionalChain([i, 'optionalAccess', _4 => _4.atomic, 'optionalAccess', _5 => _5.status])==="supported"||!e.disable5792Upgrade&&_optionalChain([i, 'optionalAccess', _6 => _6.atomic, 'optionalAccess', _7 => _7.status])==="ready",[i,e.disableEip5792,e.disable5792Upgrade,t]),capabilities:i}}function w(t){let{defaultChainId:e}=a(),{chainId:r,...i}=_nullishCoalesce(t, () => ({}));return _wagmi.usePublicClient.call(void 0, {chainId:_nullishCoalesce(r, () => (e)),...i})}exports.useBeraAccount = u; exports.useBeraWagmi = _chunkFMEKPQERcjs.a; exports.useBeraWallet = a; exports.useBlockNumber = _wagmi.useBlockNumber; exports.useCapabilities = p; exports.useChains = _wagmi.useChains; exports.useConfig = _wagmi.useConfig; exports.useEnsAvatar = _wagmi.useEnsAvatar; exports.useEnsName = _wagmi.useEnsName; exports.usePublicClient = w; exports.useSwitchChain = _wagmi.useSwitchChain; exports.useTransactionReceipt = _wagmi.useTransactionReceipt;
|
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,
|
|
4
|
-
export { u as useBeraWagmi } from '../BeraWagmi-
|
|
3
|
+
import { B as BeraWagmiApi, a as ChainId } from '../BeraWagmi-DPriTsqn.cjs';
|
|
4
|
+
export { u as useBeraWagmi } from '../BeraWagmi-DPriTsqn.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,
|
|
4
|
-
export { u as useBeraWagmi } from '../BeraWagmi-
|
|
3
|
+
import { B as BeraWagmiApi, a as ChainId } from '../BeraWagmi-PCCV3r-u.js';
|
|
4
|
+
export { u as useBeraWagmi } from '../BeraWagmi-PCCV3r-u.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
|
|
1
|
+
import{a as o}from"../chunk-HU7OL27P.mjs";import{b as s}from"../chunk-FPJ6HXP4.mjs";import{usePublicClient as m}from"wagmi";import{useContext as n}from"react";function a(){let t=n(s);if(!t)throw new Error("LightweightAccountContext not found");let{address:e,defaultChainId:r}=t;return{isConnected:!!e,address:e,defaultChainId:r}}import{useBlockNumber as E,useChains as N,useConfig as R,useEnsAvatar as T,useEnsName as L,useSwitchChain as k,useTransactionReceipt as q}from"wagmi";function u(){let{account:t,isConnected:e}=o();return{...t,isConnected:e}}import{useMemo as c}from"react";import{useCapabilities as l}from"wagmi";function p({chainId:t}){let{flags:e,account:r}=o(),{data:i}=l({account:r?.wallet?.address,scopeKey:r?.connectionId,query:{retry:3},chainId:t});return{supportsAtomic:c(()=>e.disableEip5792||!i?!1:i?.atomic?.status==="supported"||!e.disable5792Upgrade&&i?.atomic?.status==="ready",[i,e.disableEip5792,e.disable5792Upgrade,t]),capabilities:i}}function w(t){let{defaultChainId:e}=a(),{chainId:r,...i}=t??{};return m({chainId:r??e,...i})}export{u as useBeraAccount,o as useBeraWagmi,a as useBeraWallet,E as useBlockNumber,p as useCapabilities,N as useChains,R as useConfig,T as useEnsAvatar,L as useEnsName,w as usePublicClient,k as useSwitchChain,q as useTransactionReceipt};
|
package/package.json
CHANGED
|
@@ -1,10 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
createContext,
|
|
3
|
-
type PropsWithChildren,
|
|
4
|
-
useContext,
|
|
5
|
-
useMemo,
|
|
6
|
-
} from "react";
|
|
7
|
-
import useSWRImmutable from "swr/immutable";
|
|
1
|
+
import { type PropsWithChildren, useContext } from "react";
|
|
8
2
|
import type {
|
|
9
3
|
MultiStepAuthArgsType,
|
|
10
4
|
Profile,
|
|
@@ -12,18 +6,11 @@ import type {
|
|
|
12
6
|
Wallet,
|
|
13
7
|
} from "thirdweb/wallets";
|
|
14
8
|
import type { Address, Chain } from "viem";
|
|
15
|
-
import {
|
|
16
|
-
import {
|
|
17
|
-
type UseWalletClientReturnType,
|
|
18
|
-
useAccount,
|
|
19
|
-
useDisconnect,
|
|
20
|
-
usePublicClient,
|
|
21
|
-
useWalletClient,
|
|
22
|
-
} from "wagmi";
|
|
9
|
+
import type { UseWalletClientReturnType } from "wagmi";
|
|
23
10
|
|
|
24
11
|
import type { getConfig, ThirdwebConfig } from "../config";
|
|
25
|
-
import {
|
|
26
|
-
import {
|
|
12
|
+
import { BeraWagmiProviderBase } from "./BeraWagmiLightWeight";
|
|
13
|
+
import { BeraWagmiContext } from "./beraWagmiContext";
|
|
27
14
|
import { useThirdweb } from "./useThirdweb";
|
|
28
15
|
|
|
29
16
|
export function useBeraWagmi() {
|
|
@@ -118,8 +105,6 @@ export interface BeraWagmiApi {
|
|
|
118
105
|
defaultChainId: ChainId;
|
|
119
106
|
}
|
|
120
107
|
|
|
121
|
-
const BeraWagmiContext = createContext<BeraWagmiApi | undefined>(undefined);
|
|
122
|
-
|
|
123
108
|
export enum ChainId {
|
|
124
109
|
MAINNET = 80094,
|
|
125
110
|
BEPOLIA = 80069,
|
|
@@ -158,7 +143,7 @@ export interface IBeraWagmiProviderProps extends PropsWithChildren {
|
|
|
158
143
|
export function BeraWagmiProvider({
|
|
159
144
|
children,
|
|
160
145
|
config,
|
|
161
|
-
flags
|
|
146
|
+
flags,
|
|
162
147
|
theme,
|
|
163
148
|
onSmartAccountRejection,
|
|
164
149
|
chains = [],
|
|
@@ -168,19 +153,7 @@ export function BeraWagmiProvider({
|
|
|
168
153
|
onConnect,
|
|
169
154
|
onConnectError,
|
|
170
155
|
}: IBeraWagmiProviderProps) {
|
|
171
|
-
const {
|
|
172
|
-
wallet,
|
|
173
|
-
openConnectModal,
|
|
174
|
-
connect,
|
|
175
|
-
DebugConnectButton,
|
|
176
|
-
connectionId,
|
|
177
|
-
disconnect: disconnectProvider,
|
|
178
|
-
connectorName,
|
|
179
|
-
isEmbeddedWallet,
|
|
180
|
-
profiles,
|
|
181
|
-
preAuthenticate,
|
|
182
|
-
isConnecting,
|
|
183
|
-
} = useThirdweb({
|
|
156
|
+
const thirdwebResult = useThirdweb({
|
|
184
157
|
config,
|
|
185
158
|
theme,
|
|
186
159
|
chains,
|
|
@@ -190,122 +163,20 @@ export function BeraWagmiProvider({
|
|
|
190
163
|
onConnectError,
|
|
191
164
|
});
|
|
192
165
|
|
|
193
|
-
const { address: connectedAddress, chainId } = useAccount(); // wagmi
|
|
194
|
-
|
|
195
|
-
const { disconnect: disconnectWagmi } = useDisconnect();
|
|
196
|
-
const publicClient = usePublicClient();
|
|
197
|
-
|
|
198
|
-
const address = useMemo<Address | undefined>(() => {
|
|
199
|
-
// no address anyway if no connected address
|
|
200
|
-
if (!connectedAddress || !wallet) return undefined;
|
|
201
|
-
|
|
202
|
-
return accountOverride ?? connectedAddress;
|
|
203
|
-
}, [accountOverride, connectedAddress, wallet]);
|
|
204
|
-
|
|
205
|
-
const { data: ens } = useEnsName({
|
|
206
|
-
config: config.wagmi,
|
|
207
|
-
chainId: defaultChain.id,
|
|
208
|
-
address,
|
|
209
|
-
});
|
|
210
|
-
|
|
211
|
-
const { data: code } = useSWRImmutable(
|
|
212
|
-
address ? (["BeraWagmiProvider_code", address, chainId] as const) : null,
|
|
213
|
-
([_, walletAddress, _chainId]) => {
|
|
214
|
-
return publicClient?.getCode({
|
|
215
|
-
address: walletAddress,
|
|
216
|
-
});
|
|
217
|
-
},
|
|
218
|
-
{
|
|
219
|
-
refreshInterval: 60_000,
|
|
220
|
-
},
|
|
221
|
-
);
|
|
222
|
-
const [isContract, has7702Authorization] = useMemo(() => {
|
|
223
|
-
if (!code)
|
|
224
|
-
// if no code, it's not a contract or has 7702 authorization
|
|
225
|
-
return [false, false];
|
|
226
|
-
|
|
227
|
-
const has7702Authorization = code.startsWith("0xef01");
|
|
228
|
-
|
|
229
|
-
if (has7702Authorization) {
|
|
230
|
-
// if has 7702 authorization, it's not a contract
|
|
231
|
-
return [false, true];
|
|
232
|
-
}
|
|
233
|
-
|
|
234
|
-
// if doesn't have 7702 authorization but has code, it's a contract
|
|
235
|
-
return [true, false];
|
|
236
|
-
}, [code]);
|
|
237
|
-
|
|
238
|
-
const { data: walletClient } = useWalletClient();
|
|
239
|
-
|
|
240
|
-
const normalizedEns = useMemo(() => {
|
|
241
|
-
try {
|
|
242
|
-
// some characters might throw an error when normalizing
|
|
243
|
-
// for instance `_` throws an error (e.g. `bera_boy`)
|
|
244
|
-
return ens ? normalize(ens) : undefined;
|
|
245
|
-
} catch {
|
|
246
|
-
// not catching the error here, just returning undefined
|
|
247
|
-
// @see https://berachain-dapps.sentry.io/issues/6949741717/?alert_rule_id=16379160&alert_type=issue¬ification_uuid=b01366a6-78b0-4348-a3c1-5f76ced1d539&project=4509842561630209
|
|
248
|
-
}
|
|
249
|
-
}, [ens]);
|
|
250
|
-
|
|
251
|
-
const avatar = useEnsAvatar({
|
|
252
|
-
name: normalizedEns,
|
|
253
|
-
});
|
|
254
|
-
|
|
255
166
|
return (
|
|
256
|
-
<
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
onSmartAccountRejection?.();
|
|
266
|
-
},
|
|
267
|
-
isEmbeddedWalletsEnabled: thirdweb.embeddedWallets ?? true,
|
|
268
|
-
isConnecting,
|
|
269
|
-
isConnected:
|
|
270
|
-
!!address &&
|
|
271
|
-
// this seems obvious but might fix some re-render issues.
|
|
272
|
-
!!walletClient,
|
|
273
|
-
DebugConnectButton,
|
|
274
|
-
account:
|
|
275
|
-
wallet && chainId && address
|
|
276
|
-
? {
|
|
277
|
-
connectionId,
|
|
278
|
-
chainId,
|
|
279
|
-
connectorName,
|
|
280
|
-
isEmbeddedWallet,
|
|
281
|
-
profiles,
|
|
282
|
-
wallet: {
|
|
283
|
-
address,
|
|
284
|
-
ensName: ens?.replace(".bera", ".🐻⛓️") ?? null,
|
|
285
|
-
ensAvatar: avatar.data ?? null,
|
|
286
|
-
has7702Authorization,
|
|
287
|
-
isContract,
|
|
288
|
-
},
|
|
289
|
-
}
|
|
290
|
-
: undefined,
|
|
291
|
-
connect,
|
|
292
|
-
openConnectModal: async () => {
|
|
293
|
-
await openConnectModal();
|
|
294
|
-
},
|
|
295
|
-
disconnect: () => {
|
|
296
|
-
disconnectWagmi();
|
|
297
|
-
disconnectProvider();
|
|
298
|
-
},
|
|
299
|
-
// chains,
|
|
300
|
-
defaultChainId: defaultChain.id,
|
|
167
|
+
<BeraWagmiProviderBase
|
|
168
|
+
config={config}
|
|
169
|
+
flags={flags}
|
|
170
|
+
onSmartAccountRejection={onSmartAccountRejection}
|
|
171
|
+
defaultChain={defaultChain}
|
|
172
|
+
thirdweb={thirdweb}
|
|
173
|
+
thirdwebResult={thirdwebResult}
|
|
174
|
+
openConnectModal={async () => {
|
|
175
|
+
await thirdwebResult.openConnectModal();
|
|
301
176
|
}}
|
|
177
|
+
DebugConnectButton={thirdwebResult.DebugConnectButton}
|
|
302
178
|
>
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
defaultChainId={defaultChain.id}
|
|
306
|
-
>
|
|
307
|
-
{children}
|
|
308
|
-
</LightweightAccountProvider>
|
|
309
|
-
</BeraWagmiContext.Provider>
|
|
179
|
+
{children}
|
|
180
|
+
</BeraWagmiProviderBase>
|
|
310
181
|
);
|
|
311
182
|
}
|