@berachain/wagmi 0.1.0-alpha.0 → 0.1.0-alpha.1

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.
@@ -0,0 +1,100 @@
1
+ import { PropsWithChildren } from 'react';
2
+ import { Address, GetCapabilitiesReturnType, Chain } from 'viem';
3
+ import { UseWalletClientReturnType } from 'wagmi';
4
+ import { EdgeConfigSchema } from '@berachain/config/internal/edge-config';
5
+
6
+ declare function useBeraWagmi(): BeraWagmiApi;
7
+ interface BeraWagmiApi {
8
+ /**
9
+ * @deprecated used for prototyping only.
10
+ */
11
+ DebugConnectButton: () => React.ReactNode;
12
+ /**
13
+ * Account connected to berachain dapp. It might include some additional data once embedded wallets are enabled.
14
+ */
15
+ account: {
16
+ /**
17
+ * Chain ID to which the wallet provider is currently connected to.
18
+ */
19
+ chainId: number;
20
+ /**
21
+ * Whether the wallet is an embedded wallet.
22
+ */
23
+ isEmbeddedWallet: boolean;
24
+ connectorName: string | null;
25
+ flags: {
26
+ supportsAtomic: boolean;
27
+ };
28
+ /**
29
+ * Wallet provider capabilities for the current account.
30
+ *
31
+ * Status can be:
32
+ * - supported: User has enabled the feature.
33
+ * - ready: The wallet provider is ready to use the feature.
34
+ * - unsupported: The wallet provider does not support the feature.
35
+ */
36
+ capabilities: GetCapabilitiesReturnType | undefined;
37
+ /**
38
+ * Wallet to display.
39
+ *
40
+ * This might be manually overridden by the accountOverride prop, thus not being the same as the connected wallet.
41
+ */
42
+ wallet: {
43
+ address: Address;
44
+ /**
45
+ * ENS name of the wallet.
46
+ */
47
+ ensName: string | null;
48
+ /**
49
+ * ENS avatar of the wallet.
50
+ */
51
+ ensAvatar: string | null;
52
+ /**
53
+ * Whether the wallet has 7702 authorization.
54
+ */
55
+ has7702Authorization: boolean;
56
+ /**
57
+ * Whether the wallet is a contract.
58
+ */
59
+ isContract: boolean;
60
+ } | undefined;
61
+ } | undefined;
62
+ isEmbeddedWalletsEnabled: boolean;
63
+ isConnected: boolean;
64
+ isConnecting: boolean;
65
+ walletClient: UseWalletClientReturnType["data"];
66
+ connectWallet: () => Promise<void> | void;
67
+ disconnect(): void;
68
+ /**
69
+ * A callback that is called when a smart account upgrade is rejected.
70
+ *
71
+ * This is used to disable EIP-5792 temporarily.
72
+ */
73
+ onSmartAccountRejection: () => void;
74
+ /**
75
+ * List of external chains that are whitelisted for that app.
76
+ */
77
+ externalChainList: Chain[];
78
+ }
79
+ interface IBeraWagmiProviderProps extends PropsWithChildren {
80
+ theme?: "dark" | "light" | "auto";
81
+ isEmbeddedWalletsEnabled: boolean;
82
+ disableEip5792: boolean;
83
+ /**
84
+ * Whether to disable the 5792 upgrade for users that haven't upgraded yet.
85
+ *
86
+ * `atomic.status === "ready"`
87
+ */
88
+ disable5792Upgrade?: boolean;
89
+ accountOverride?: Address;
90
+ onSmartAccountRejection?: () => void;
91
+ edgeConfigChainList: EdgeConfigSchema["wagmi"]["externalChainList"];
92
+ /**
93
+ * Event triggered when a wallet is connected manually.
94
+ *
95
+ * This is not triggered when a wallet connect automatically after a refresh.
96
+ */
97
+ onConnectedWallet?: () => void;
98
+ }
99
+
100
+ export { type BeraWagmiApi as B, type IBeraWagmiProviderProps as I, 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 _wagmiadapter = require('@thirdweb-dev/wagmi-adapter');var _thirdweb = require('thirdweb');var _wallets = require('thirdweb/wallets');var _chains = require('viem/chains');var _wagmi = require('wagmi');var _internal = require('@berachain/config/internal');var A=_thirdweb.createThirdwebClient.call(void 0, {clientId:_internal.appConfig.apiKeys.public.thirdweb}),b= exports.b ={mode:"EIP7702",sponsorGas:!0},G= exports.c =_wallets.inAppWallet.call(void 0, {executionMode:b}),m= exports.d =_internal.chainId===_chains.berachain.id?_chains.berachain:_chains.berachainBepolia,r= exports.e ={chain:m},U=!!_optionalChain([m, 'access', _ => _.contracts, 'optionalAccess', _2 => _2.multicall3]),u= exports.f =[_chains.mainnet,_chains.polygon,_chains.optimism,_chains.base,_chains.bsc,_chains.arbitrum,_chains.avalanche],K= exports.g =[...u,_chains.berachain,_chains.berachainBepolia].reduce((e,t)=>(e[t.id]=t.name,e),{}),M={[_chains.mainnet.id]:["https://1.rpc.thirdweb.com/","https://ultra-sleek-pond.quiknode.pro/08ab7832de196248b7ba7dcffad268c9b3747f48/"],[_chains.polygon.id]:["https://137.rpc.thirdweb.com/","https://sleek-thrilling-orb.matic.quiknode.pro/592d9950044bf173c232f5ecf79a2725c43f517b/"],[_chains.optimism.id]:["https://10.rpc.thirdweb.com/","https://blue-neat-liquid.optimism.quiknode.pro/26ca3fe255f687652124050450faada988023979/"],[_chains.base.id]:["https://8453.rpc.thirdweb.com/","https://soft-empty-sailboat.base-mainnet.quiknode.pro/bb9300074b062c5e0a1e93e0a8ebd53501c32fe7/"],[_chains.bsc.id]:["https://56.rpc.thirdweb.com/","https://chaotic-floral-brook.bsc.quiknode.pro/6f0e5a9791285c6b59f2a6a907a62ec9d581d7bd/"],[_chains.avalanche.id]:["https://43114.rpc.thirdweb.com/","https://shy-special-mansion.avalanche-mainnet.quiknode.pro/efa880845032c2ef4049637d779d2ae58acf0f65/ext/bc/C/rpc/"],[_chains.arbitrum.id]:["https://42161.rpc.thirdweb.com/","https://fluent-broken-violet.arbitrum-mainnet.quiknode.pro/445b20e9ed10e22fffee6498a40c4f83f83f4ec7/"]},P= exports.h =_wagmi.createConfig.call(void 0, {chains:[r.chain,...u],ssr:!0,connectors:[_wagmiadapter.inAppWalletConnector.call(void 0, {client:A,executionMode:b})],storage:_wagmi.createStorage.call(void 0, {key:"wagmi-berachain-thirdweb",storage:typeof window<"u"?localStorage:void 0}),batch:{multicall:U?{wait:15}:void 0},transports:{[r.chain.id]:_wagmi.fallback.call(void 0, [_internal.privateRcpUrl,_internal.jsonRpcUrl,_internal.alchemyJsonRpcUrl,_internal.publicJsonRpcUrl].filter(e=>e).map(e=>_wagmi.http.call(void 0, e,{batch:{wait:35}}))),...Object.entries(M).reduce((e,[t,C])=>(e[Number(t)]=_wagmi.fallback.call(void 0, [...C,void 0].map(w=>_wagmi.http.call(void 0, w,{batch:{wait:15}}))),e),{})}});exports.a = A; exports.b = b; exports.c = G; exports.d = m; exports.e = r; exports.f = u; exports.g = K; exports.h = P;
@@ -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 _chunk44WGYPR4cjs = require('./chunk-44WGYPR4.cjs');var _wagmi = require('wagmi');var _internal = require('@berachain/config/internal');var _react = require('react');var _immutable = require('swr/immutable'); var _immutable2 = _interopRequireDefault(_immutable);var _chains = require('viem/chains');var _ens = require('viem/ens');var _edgeconfig = require('@berachain/config/internal/edge-config');var _jsxruntime = require('react/jsx-runtime');var B=_react.createContext.call(void 0, void 0);function U({children:e,address:t}){return _jsxruntime.jsx.call(void 0, B.Provider,{value:{address:t},children:e})}var _thirdweb = require('thirdweb');var _react3 = require('thirdweb/react');var _wallets = require('thirdweb/wallets');var de=_wallets.getInstalledWallets.call(void 0, ),ue=[...de,_wallets.createWallet.call(void 0, "io.rabby"),_wallets.createWallet.call(void 0, "io.metamask"),_wallets.createWallet.call(void 0, "com.coinbase.wallet"),_wallets.createWallet.call(void 0, "walletConnect")].filter((e,t,n)=>n.findIndex(i=>i.id===e.id)===t),N=_thirdweb.defineChain.call(void 0, {id:_chunk44WGYPR4cjs.d.id,blockExplorers:_chunk44WGYPR4cjs.d.blockExplorers,blockTime:_chunk44WGYPR4cjs.d.blockTime,ensTlds:_chunk44WGYPR4cjs.d.ensTlds,testnet:_chunk44WGYPR4cjs.d.testnet,contracts:_chunk44WGYPR4cjs.d.contracts,nativeCurrency:_chunk44WGYPR4cjs.d.nativeCurrency,name:_chunk44WGYPR4cjs.d.name,rpcUrls:{default:{http:[_internal.publicJsonRpcUrl]}}});function S({isEmbeddedWalletsEnabled:e,theme:t,extenalChains:n}){let{connectors:i,connect:b}=_wagmi.useConnect.call(void 0, ),a=_react3.useActiveWallet.call(void 0, ),A=_react3.useActiveAccount.call(void 0, ),{disconnect:W}=_react3.useDisconnect.call(void 0, ),{data:u}=_react3.useWalletInfo.call(void 0, _optionalChain([a, 'optionalAccess', _2 => _2.id])),l={client:_chunk44WGYPR4cjs.a,chain:N,wallets:e?void 0:ue};async function r(s){let d=i.find(f=>f.id==="in-app-wallet");d?b({connector:d,chainId:_internal.defaultChainId,...{withCapabilities:!0,wallet:s}}):console.error("no tw connector found")}let{isLoading:w}=_react3.useAutoConnect.call(void 0, {...l,onConnect:r}),v=_react.useMemo.call(void 0, ()=>crypto.randomUUID(),[_optionalChain([a, 'optionalAccess', _3 => _3.id]),_optionalChain([A, 'optionalAccess', _4 => _4.address])]),{connect:x}=_react3.useConnectModal.call(void 0, );return{async connect(){let s=await x({...l,theme:t==="auto"?void 0:t,chains:[N,...n.map(d=>_thirdweb.defineChain.call(void 0, {id:d.id}))]});await r(s)},disconnect(){a&&W(a)},isConnecting:w,connectionId:v,connectorName:_nullishCoalesce(_optionalChain([u, 'optionalAccess', _5 => _5.name]), () => (null)),isEmbeddedWallet:_optionalChain([u, 'optionalAccess', _6 => _6.id])==="inApp",wallet:A,DebugConnectButton(){return _jsxruntime.jsx.call(void 0, _react3.ConnectButton,{...l,onConnect:s=>r(s)})}}}function E(){let e=_react.useContext.call(void 0, _);if(!e)throw new Error("BeraWagmiContext not found");return e}var _=_react.createContext.call(void 0, void 0),Re=[_chains.mainnet,_chains.polygon,_chains.optimism,_chains.base,_chains.bsc,_chains.avalanche,_chains.arbitrum];function Le({externalChainList:e}){return Re.filter(t=>{let n=_optionalChain([e, 'optionalAccess', _7 => _7.find, 'call', _8 => _8(i=>i.chainId===t.id)]);return!n||_edgeconfig.isFlagEnabled.call(void 0, n.enabled)})}function st({children:e,isEmbeddedWalletsEnabled:t,disableEip5792:n,disable5792Upgrade:i,theme:b,accountOverride:a,onConnectedWallet:A,onSmartAccountRejection:W,edgeConfigChainList:u}){let l=_react.useMemo.call(void 0, ()=>Le({externalChainList:u}),[u]),{wallet:r,connect:w,DebugConnectButton:v,connectionId:x,disconnect:s,connectorName:d,isEmbeddedWallet:f,isConnecting:O}=S({isEmbeddedWalletsEnabled:t,theme:b,extenalChains:l}),{address:C,chainId:y}=_wagmi.useAccount.call(void 0, ),{disconnect:G}=_wagmi.useDisconnect.call(void 0, ),q=_wagmi.usePublicClient.call(void 0, ),c=_react.useMemo.call(void 0, ()=>{if(!(!C||!r))return _nullishCoalesce(a, () => (C))},[a,C,r]),{data:m}=_wagmi.useCapabilities.call(void 0, {account:C,scopeKey:x,query:{retry:3}}),F=_react.useMemo.call(void 0, ()=>n||!m?!1:_optionalChain([m, 'optionalAccess', _9 => _9[_internal.defaultChainId], 'optionalAccess', _10 => _10.atomic, 'optionalAccess', _11 => _11.status])==="supported"||!i&&_optionalChain([m, 'optionalAccess', _12 => _12[_internal.defaultChainId], 'optionalAccess', _13 => _13.atomic, 'optionalAccess', _14 => _14.status])==="ready",[m,n,i]),{data:h}=_wagmi.useEnsName.call(void 0, {config:_chunk44WGYPR4cjs.h,chainId:_internal.defaultChainId,address:c}),{data:P}=_immutable2.default.call(void 0, c?["BeraWagmiProvider_code",c,y]:null,([Q,V,ze])=>_optionalChain([q, 'optionalAccess', _15 => _15.getCode, 'call', _16 => _16({address:V})]),{refreshInterval:6e4}),[J,K]=_react.useMemo.call(void 0, ()=>P?P.startsWith("0xef01")?[!1,!0]:[!0,!1]:[!1,!1],[P]),{data:T}=_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]),H=_wagmi.useEnsAvatar.call(void 0, {name:j});return _jsxruntime.jsx.call(void 0, _.Provider,{value:{walletClient:T,onSmartAccountRejection:()=>{_optionalChain([W, 'optionalCall', _17 => _17()])},isEmbeddedWalletsEnabled:t,isConnecting:O,isConnected:!!c&&!!T,DebugConnectButton:v,account:r&&y&&c?{chainId:y,connectorName:d,isEmbeddedWallet:f,capabilities:m,flags:{supportsAtomic:F},wallet:{address:c,ensName:_nullishCoalesce(h, () => (null)),ensAvatar:_nullishCoalesce(H.data, () => (null)),has7702Authorization:K,isContract:J}}:void 0,connectWallet:async()=>{console.log("connectWallet.called"),await w()},disconnect:()=>{G(),s()},externalChainList:l},children:_jsxruntime.jsx.call(void 0, U,{address:c,children:e})})}function Ue(){let{account:e,isConnected:t}=E();return{...e,isConnected:t}}function ke(){let e=_react.useContext.call(void 0, B);if(!e)throw new Error("LightweightAccountContext not found");let{address:t}=e;return{isConnected:!!t,address:t}}function gt(e){let{chainId:t,...n}=_nullishCoalesce(e, () => ({}));return _wagmi.usePublicClient.call(void 0, {chainId:_nullishCoalesce(t, () => (_internal.defaultChainId)),...n})}exports.a = Ue; exports.b = ke; exports.c = gt; exports.d = _wagmi.useBlockNumber; exports.e = _wagmi.useChains; exports.f = _wagmi.useConfig; exports.g = _wagmi.useEnsAvatar; exports.h = _wagmi.useEnsName; exports.i = _wagmi.useSwitchChain; exports.j = _wagmi.useTransactionReceipt; exports.k = E; exports.l = st;
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunk44WGYPR4cjs = require('../chunk-44WGYPR4.cjs');exports.chain = _chunk44WGYPR4cjs.d; exports.chainIdToName = _chunk44WGYPR4cjs.g; exports.defaultBeraNetworkConfig = _chunk44WGYPR4cjs.e; exports.executionMode = _chunk44WGYPR4cjs.b; exports.externalChains = _chunk44WGYPR4cjs.f; exports.thirdwebClient = _chunk44WGYPR4cjs.a; exports.thirdwebWallet = _chunk44WGYPR4cjs.c; exports.wagmiConfig = _chunk44WGYPR4cjs.h;
@@ -0,0 +1,27 @@
1
+ import * as thirdweb from 'thirdweb';
2
+ import { inAppWallet } from 'thirdweb/wallets';
3
+ import { Chain } from 'viem';
4
+ import { Config } from 'wagmi';
5
+
6
+ declare const thirdwebClient: thirdweb.ThirdwebClient;
7
+ declare const executionMode: {
8
+ readonly mode: "EIP7702";
9
+ readonly sponsorGas: true;
10
+ };
11
+ declare const thirdwebWallet: ReturnType<typeof inAppWallet>;
12
+ /**
13
+ * Using default viem chain definition since it also includes ens and other metadata
14
+ */
15
+ declare const chain: Chain;
16
+ declare const defaultBeraNetworkConfig: NetworkConfig;
17
+ interface NetworkConfig {
18
+ chain: Chain;
19
+ }
20
+ /**
21
+ * Exporting this is helpful for the multi-chain zap, to get the list of chains that we want to support.
22
+ */
23
+ declare const externalChains: Chain[];
24
+ declare const chainIdToName: Record<Chain["id"], string>;
25
+ declare const wagmiConfig: Config;
26
+
27
+ export { type NetworkConfig, chain, chainIdToName, defaultBeraNetworkConfig, executionMode, externalChains, thirdwebClient, thirdwebWallet, wagmiConfig };
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});"use client";var _chunkGVIEHLWTcjs = require('../chunk-GVIEHLWT.cjs');var _chunk44WGYPR4cjs = require('../chunk-44WGYPR4.cjs');var _reactquery = require('@tanstack/react-query');var _porto = require('porto');var _react = require('thirdweb/react');var _wagmi = require('wagmi');var _jsxruntime = require('react/jsx-runtime');var P=new _reactquery.QueryClient;_porto.Porto.create();function c({...o}){return _jsxruntime.jsx.call(void 0, _react.ThirdwebProvider,{children:_jsxruntime.jsx.call(void 0, _wagmi.WagmiProvider,{config:_chunk44WGYPR4cjs.h,reconnectOnMount:!1,children:_jsxruntime.jsx.call(void 0, _reactquery.QueryClientProvider,{client:P,children:_jsxruntime.jsx.call(void 0, _chunkGVIEHLWTcjs.l,{...o})})})})}exports.WagmiProvider = c;
@@ -0,0 +1,10 @@
1
+ import * as react_jsx_runtime from 'react/jsx-runtime';
2
+ import { I as IBeraWagmiProviderProps } from '../BeraWagmi-B79qATYX.cjs';
3
+ import 'react';
4
+ import 'viem';
5
+ import 'wagmi';
6
+ import '@berachain/config/internal/edge-config';
7
+
8
+ declare function WagmiProvider({ ...beraWagmiProps }: IBeraWagmiProviderProps): react_jsx_runtime.JSX.Element;
9
+
10
+ export { WagmiProvider };
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});var _core = require('@wagmi/core');exports.getConnectorClient = _core.getConnectorClient; exports.getWalletClient = _core.getWalletClient; exports.switchChain = _core.switchChain;
@@ -0,0 +1 @@
1
+ export { getConnectorClient, getWalletClient, switchChain } from '@wagmi/core';
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkGVIEHLWTcjs = require('../chunk-GVIEHLWT.cjs');require('../chunk-44WGYPR4.cjs');exports.useBeraAccount = _chunkGVIEHLWTcjs.a; exports.useBeraWagmi = _chunkGVIEHLWTcjs.k; exports.useBeraWallet = _chunkGVIEHLWTcjs.b; exports.useBlockNumber = _chunkGVIEHLWTcjs.d; exports.useChains = _chunkGVIEHLWTcjs.e; exports.useConfig = _chunkGVIEHLWTcjs.f; exports.useEnsAvatar = _chunkGVIEHLWTcjs.g; exports.useEnsName = _chunkGVIEHLWTcjs.h; exports.usePublicClient = _chunkGVIEHLWTcjs.c; exports.useSwitchChain = _chunkGVIEHLWTcjs.i; exports.useTransactionReceipt = _chunkGVIEHLWTcjs.j;
@@ -0,0 +1,20 @@
1
+ import { UsePublicClientParameters, UsePublicClientReturnType } from 'wagmi';
2
+ export { useBlockNumber, useChains, useConfig, useEnsAvatar, useEnsName, useSwitchChain, useTransactionReceipt } from 'wagmi';
3
+ import { B as BeraWagmiApi } from '../BeraWagmi-B79qATYX.cjs';
4
+ export { u as useBeraWagmi } from '../BeraWagmi-B79qATYX.cjs';
5
+ import 'react';
6
+ import 'viem';
7
+ import '@berachain/config/internal/edge-config';
8
+
9
+ declare function useBeraAccount(): Partial<NonNullable<BeraWagmiApi["account"]>> & {
10
+ isConnected: boolean;
11
+ };
12
+
13
+ declare function useBeraWallet(): {
14
+ readonly isConnected: boolean;
15
+ readonly address: `0x${string}` | undefined;
16
+ };
17
+
18
+ declare function usePublicClient(args?: UsePublicClientParameters): UsePublicClientReturnType;
19
+
20
+ export { useBeraAccount, useBeraWallet, usePublicClient };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@berachain/wagmi",
3
- "version": "0.1.0-alpha.0",
3
+ "version": "0.1.0-alpha.1",
4
4
  "type": "module",
5
5
  "files": [
6
6
  "dist"