@openzeppelin/ui-builder-adapter-evm 1.2.0 → 1.3.0
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/index.cjs +106 -31
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +114 -35
- package/dist/index.js.map +1 -1
- package/package.json +5 -5
- package/src/wallet/components/account/AccountDisplay.tsx +30 -11
- package/src/wallet/components/connect/ConnectButton.tsx +29 -12
- package/src/wallet/components/network/NetworkSwitcher.tsx +41 -9
- package/src/wallet/rainbowkit/components.tsx +7 -5
package/dist/index.cjs
CHANGED
|
@@ -2081,27 +2081,44 @@ var ConnectorDialogContent = ({ open, onOpenChange }) => {
|
|
|
2081
2081
|
var import_jsx_runtime3 = require("react/jsx-runtime");
|
|
2082
2082
|
var CustomConnectButton = ({
|
|
2083
2083
|
className,
|
|
2084
|
+
size,
|
|
2085
|
+
variant,
|
|
2086
|
+
fullWidth,
|
|
2084
2087
|
hideWhenConnected = true
|
|
2085
2088
|
}) => {
|
|
2086
2089
|
const [dialogOpen, setDialogOpen] = (0, import_react7.useState)(false);
|
|
2087
|
-
const
|
|
2088
|
-
|
|
2089
|
-
|
|
2090
|
-
|
|
2090
|
+
const sizeProps = (0, import_ui_utils9.getWalletButtonSizeProps)(size);
|
|
2091
|
+
const unavailableButton = /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { className: (0, import_ui_utils9.cn)("flex items-center", fullWidth && "w-full", className), children: /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(
|
|
2092
|
+
import_ui_components2.Button,
|
|
2093
|
+
{
|
|
2094
|
+
disabled: true,
|
|
2095
|
+
variant: variant || "outline",
|
|
2096
|
+
size: sizeProps.size,
|
|
2097
|
+
className: (0, import_ui_utils9.cn)(sizeProps.className, fullWidth && "w-full"),
|
|
2098
|
+
children: [
|
|
2099
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_lucide_react.Wallet, { className: (0, import_ui_utils9.cn)(sizeProps.iconSize, "mr-1") }),
|
|
2100
|
+
"Wallet Unavailable"
|
|
2101
|
+
]
|
|
2102
|
+
}
|
|
2103
|
+
) });
|
|
2091
2104
|
return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(SafeWagmiComponent, { fallback: unavailableButton, children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
2092
2105
|
ConnectButtonContent,
|
|
2093
2106
|
{
|
|
2094
2107
|
className,
|
|
2108
|
+
size,
|
|
2109
|
+
variant,
|
|
2110
|
+
fullWidth,
|
|
2095
2111
|
dialogOpen,
|
|
2096
2112
|
setDialogOpen,
|
|
2097
2113
|
hideWhenConnected
|
|
2098
2114
|
}
|
|
2099
2115
|
) });
|
|
2100
2116
|
};
|
|
2101
|
-
var ConnectButtonContent = ({ className, dialogOpen, setDialogOpen, hideWhenConnected }) => {
|
|
2117
|
+
var ConnectButtonContent = ({ className, size, variant, fullWidth, dialogOpen, setDialogOpen, hideWhenConnected }) => {
|
|
2102
2118
|
const { isConnected } = (0, import_ui_react2.useDerivedAccountStatus)();
|
|
2103
2119
|
const { isConnecting: isHookConnecting, error: connectError } = (0, import_ui_react2.useDerivedConnectStatus)();
|
|
2104
2120
|
const [isManuallyInitiated, setIsManuallyInitiated] = (0, import_react7.useState)(false);
|
|
2121
|
+
const sizeProps = (0, import_ui_utils9.getWalletButtonSizeProps)(size);
|
|
2105
2122
|
(0, import_react7.useEffect)(() => {
|
|
2106
2123
|
if (isConnected && hideWhenConnected) {
|
|
2107
2124
|
setDialogOpen(false);
|
|
@@ -2128,18 +2145,18 @@ var ConnectButtonContent = ({ className, dialogOpen, setDialogOpen, hideWhenConn
|
|
|
2128
2145
|
return null;
|
|
2129
2146
|
}
|
|
2130
2147
|
const showButtonLoading = isHookConnecting || isManuallyInitiated;
|
|
2131
|
-
return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { className: (0, import_ui_utils9.cn)("flex items-center", className), children: [
|
|
2148
|
+
return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { className: (0, import_ui_utils9.cn)("flex items-center", fullWidth && "w-full", className), children: [
|
|
2132
2149
|
/* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(
|
|
2133
2150
|
import_ui_components2.Button,
|
|
2134
2151
|
{
|
|
2135
2152
|
onClick: handleConnectClick,
|
|
2136
2153
|
disabled: showButtonLoading || isConnected,
|
|
2137
|
-
variant: "outline",
|
|
2138
|
-
size:
|
|
2139
|
-
className:
|
|
2154
|
+
variant: variant || "outline",
|
|
2155
|
+
size: sizeProps.size,
|
|
2156
|
+
className: (0, import_ui_utils9.cn)(sizeProps.className, fullWidth && "w-full"),
|
|
2140
2157
|
title: isConnected ? "Connected" : connectError?.message || "Connect Wallet",
|
|
2141
2158
|
children: [
|
|
2142
|
-
showButtonLoading ? /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_lucide_react.Loader2, { className:
|
|
2159
|
+
showButtonLoading ? /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_lucide_react.Loader2, { className: (0, import_ui_utils9.cn)(sizeProps.iconSize, "animate-spin mr-1") }) : /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_lucide_react.Wallet, { className: (0, import_ui_utils9.cn)(sizeProps.iconSize, "mr-1") }),
|
|
2143
2160
|
showButtonLoading ? "Connecting..." : "Connect Wallet"
|
|
2144
2161
|
]
|
|
2145
2162
|
}
|
|
@@ -2165,29 +2182,48 @@ var import_ui_components3 = require("@openzeppelin/ui-components");
|
|
|
2165
2182
|
var import_ui_react3 = require("@openzeppelin/ui-react");
|
|
2166
2183
|
var import_ui_utils10 = require("@openzeppelin/ui-utils");
|
|
2167
2184
|
var import_jsx_runtime4 = require("react/jsx-runtime");
|
|
2168
|
-
var CustomAccountDisplay = ({
|
|
2169
|
-
|
|
2185
|
+
var CustomAccountDisplay = ({
|
|
2186
|
+
className,
|
|
2187
|
+
size,
|
|
2188
|
+
variant,
|
|
2189
|
+
fullWidth
|
|
2190
|
+
}) => {
|
|
2191
|
+
return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(SafeWagmiComponent, { fallback: null, children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
2192
|
+
AccountDisplayContent,
|
|
2193
|
+
{
|
|
2194
|
+
className,
|
|
2195
|
+
size,
|
|
2196
|
+
variant,
|
|
2197
|
+
fullWidth
|
|
2198
|
+
}
|
|
2199
|
+
) });
|
|
2170
2200
|
};
|
|
2171
|
-
var AccountDisplayContent = ({
|
|
2201
|
+
var AccountDisplayContent = ({
|
|
2202
|
+
className,
|
|
2203
|
+
size,
|
|
2204
|
+
variant,
|
|
2205
|
+
fullWidth
|
|
2206
|
+
}) => {
|
|
2172
2207
|
const { isConnected, address, chainId } = (0, import_ui_react3.useDerivedAccountStatus)();
|
|
2173
2208
|
const { disconnect: disconnect2 } = (0, import_ui_react3.useDerivedDisconnect)();
|
|
2209
|
+
const sizeProps = (0, import_ui_utils10.getWalletAccountDisplaySizeProps)(size);
|
|
2174
2210
|
if (!isConnected || !address || !disconnect2) {
|
|
2175
2211
|
return null;
|
|
2176
2212
|
}
|
|
2177
|
-
return /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { className: (0, import_ui_utils10.cn)("flex items-center gap-2", className), children: [
|
|
2178
|
-
/* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { className: "flex flex-col", children: [
|
|
2179
|
-
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)("span", { className: "
|
|
2180
|
-
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)("span", { className: "text-
|
|
2213
|
+
return /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { className: (0, import_ui_utils10.cn)("flex items-center gap-2", fullWidth && "w-full", className), children: [
|
|
2214
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { className: (0, import_ui_utils10.cn)("flex flex-col", fullWidth && "flex-1"), children: [
|
|
2215
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)("span", { className: (0, import_ui_utils10.cn)(sizeProps.textSize, "font-medium"), children: (0, import_ui_utils10.truncateMiddle)(address, 4, 4) }),
|
|
2216
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)("span", { className: (0, import_ui_utils10.cn)(sizeProps.subTextSize, "text-muted-foreground -mt-0.5"), children: chainId ? `Chain ID: ${chainId}` : "Chain ID: N/A" })
|
|
2181
2217
|
] }),
|
|
2182
2218
|
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
2183
2219
|
import_ui_components3.Button,
|
|
2184
2220
|
{
|
|
2185
2221
|
onClick: () => disconnect2(),
|
|
2186
|
-
variant: "ghost",
|
|
2222
|
+
variant: variant || "ghost",
|
|
2187
2223
|
size: "icon",
|
|
2188
|
-
className: "
|
|
2224
|
+
className: (0, import_ui_utils10.cn)(sizeProps.iconButtonSize, "p-0"),
|
|
2189
2225
|
title: "Disconnect wallet",
|
|
2190
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_lucide_react2.LogOut, { className:
|
|
2226
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_lucide_react2.LogOut, { className: sizeProps.iconSize })
|
|
2191
2227
|
}
|
|
2192
2228
|
)
|
|
2193
2229
|
] });
|
|
@@ -2199,13 +2235,33 @@ var import_ui_components4 = require("@openzeppelin/ui-components");
|
|
|
2199
2235
|
var import_ui_react4 = require("@openzeppelin/ui-react");
|
|
2200
2236
|
var import_ui_utils11 = require("@openzeppelin/ui-utils");
|
|
2201
2237
|
var import_jsx_runtime5 = require("react/jsx-runtime");
|
|
2202
|
-
var CustomNetworkSwitcher = ({
|
|
2203
|
-
|
|
2238
|
+
var CustomNetworkSwitcher = ({
|
|
2239
|
+
className,
|
|
2240
|
+
size,
|
|
2241
|
+
variant,
|
|
2242
|
+
fullWidth
|
|
2243
|
+
}) => {
|
|
2244
|
+
return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(SafeWagmiComponent, { fallback: null, children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
2245
|
+
NetworkSwitcherContent,
|
|
2246
|
+
{
|
|
2247
|
+
className,
|
|
2248
|
+
size,
|
|
2249
|
+
variant,
|
|
2250
|
+
fullWidth
|
|
2251
|
+
}
|
|
2252
|
+
) });
|
|
2204
2253
|
};
|
|
2205
|
-
var NetworkSwitcherContent = ({
|
|
2254
|
+
var NetworkSwitcherContent = ({
|
|
2255
|
+
className,
|
|
2256
|
+
size,
|
|
2257
|
+
variant,
|
|
2258
|
+
fullWidth
|
|
2259
|
+
}) => {
|
|
2206
2260
|
const { isConnected } = (0, import_ui_react4.useDerivedAccountStatus)();
|
|
2207
2261
|
const { currentChainId, availableChains: unknownChains } = (0, import_ui_react4.useDerivedChainInfo)();
|
|
2208
2262
|
const { switchChain: switchChain2, isSwitching: isPending, error } = (0, import_ui_react4.useDerivedSwitchChainStatus)();
|
|
2263
|
+
const sizeProps = (0, import_ui_utils11.getWalletNetworkSwitcherSizeProps)(size);
|
|
2264
|
+
const variantClassName = (0, import_ui_utils11.getWalletNetworkSwitcherVariantClassName)(variant);
|
|
2209
2265
|
const typedAvailableChains = unknownChains;
|
|
2210
2266
|
if (!isConnected || !switchChain2 || typedAvailableChains.length === 0) {
|
|
2211
2267
|
return null;
|
|
@@ -2217,7 +2273,7 @@ var NetworkSwitcherContent = ({ className }) => {
|
|
|
2217
2273
|
};
|
|
2218
2274
|
const currentChain = typedAvailableChains.find((chain) => chain.id === currentChainId);
|
|
2219
2275
|
const currentChainName = currentChain?.name || "Network";
|
|
2220
|
-
return /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: (0, import_ui_utils11.cn)("flex items-center", className), children: [
|
|
2276
|
+
return /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: (0, import_ui_utils11.cn)("flex items-center", fullWidth && "w-full", className), children: [
|
|
2221
2277
|
/* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(
|
|
2222
2278
|
import_ui_components4.Select,
|
|
2223
2279
|
{
|
|
@@ -2225,7 +2281,17 @@ var NetworkSwitcherContent = ({ className }) => {
|
|
|
2225
2281
|
onValueChange: (value) => handleNetworkChange(Number(value)),
|
|
2226
2282
|
disabled: isPending || typedAvailableChains.length === 0,
|
|
2227
2283
|
children: [
|
|
2228
|
-
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
2284
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
2285
|
+
import_ui_components4.SelectTrigger,
|
|
2286
|
+
{
|
|
2287
|
+
className: (0, import_ui_utils11.cn)(
|
|
2288
|
+
sizeProps.triggerClassName,
|
|
2289
|
+
variantClassName,
|
|
2290
|
+
fullWidth && "w-full max-w-none"
|
|
2291
|
+
),
|
|
2292
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_ui_components4.SelectValue, { placeholder: "Network", children: currentChainName })
|
|
2293
|
+
}
|
|
2294
|
+
),
|
|
2229
2295
|
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
2230
2296
|
import_ui_components4.SelectContent,
|
|
2231
2297
|
{
|
|
@@ -2233,13 +2299,21 @@ var NetworkSwitcherContent = ({ className }) => {
|
|
|
2233
2299
|
sideOffset: 5,
|
|
2234
2300
|
align: "start",
|
|
2235
2301
|
className: "w-auto min-w-[160px] max-h-[300px]",
|
|
2236
|
-
children: typedAvailableChains.map((chain) => /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
2302
|
+
children: typedAvailableChains.map((chain) => /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
2303
|
+
import_ui_components4.SelectItem,
|
|
2304
|
+
{
|
|
2305
|
+
value: chain.id.toString(),
|
|
2306
|
+
className: sizeProps.itemClassName,
|
|
2307
|
+
children: chain.name
|
|
2308
|
+
},
|
|
2309
|
+
chain.id
|
|
2310
|
+
))
|
|
2237
2311
|
}
|
|
2238
2312
|
)
|
|
2239
2313
|
]
|
|
2240
2314
|
}
|
|
2241
2315
|
),
|
|
2242
|
-
isPending && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("span", { className: "text-
|
|
2316
|
+
isPending && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("span", { className: "text-muted-foreground ml-2", children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_lucide_react3.Loader2, { className: (0, import_ui_utils11.cn)(sizeProps.loaderSize, "animate-spin") }) }),
|
|
2243
2317
|
error && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("span", { className: "text-xs text-red-500 ml-2", children: "!" })
|
|
2244
2318
|
] });
|
|
2245
2319
|
};
|
|
@@ -2309,15 +2383,16 @@ var RainbowKitConnectButton = (props) => {
|
|
|
2309
2383
|
}
|
|
2310
2384
|
};
|
|
2311
2385
|
}, []);
|
|
2386
|
+
const sizeProps = (0, import_ui_utils12.getWalletButtonSizeProps)(props.size);
|
|
2312
2387
|
const renderLoadingPlaceholder = (message) => /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(
|
|
2313
2388
|
import_ui_components5.Button,
|
|
2314
2389
|
{
|
|
2315
2390
|
disabled: true,
|
|
2316
|
-
variant: "outline",
|
|
2317
|
-
size:
|
|
2318
|
-
className: (0, import_ui_utils12.cn)(
|
|
2391
|
+
variant: props.variant || "outline",
|
|
2392
|
+
size: sizeProps.size,
|
|
2393
|
+
className: (0, import_ui_utils12.cn)(sizeProps.className, props.fullWidth && "w-full", props.className),
|
|
2319
2394
|
children: [
|
|
2320
|
-
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_lucide_react4.Loader2, { className:
|
|
2395
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_lucide_react4.Loader2, { className: (0, import_ui_utils12.cn)(sizeProps.iconSize, "animate-spin mr-1.5") }),
|
|
2321
2396
|
message
|
|
2322
2397
|
]
|
|
2323
2398
|
}
|