@openzeppelin/ui-builder-adapter-evm 1.0.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/README.md +1 -1
- package/dist/index.cjs +473 -375
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +5 -1
- package/dist/index.d.ts +5 -1
- package/dist/index.js +192 -100
- package/dist/index.js.map +1 -1
- package/package.json +6 -6
- package/src/__tests__/adapter-parsing.test.ts +67 -1
- package/src/__tests__/mocks/mock-network-configs.ts +3 -2
- package/src/__tests__/providerSelection.test.ts +1 -1
- package/src/abi/__tests__/etherscan-v2.test.ts +1 -1
- package/src/abi/__tests__/transformer.test.ts +1 -1
- package/src/abi/comparison.ts +1 -1
- package/src/abi/etherscan-v2.ts +2 -2
- package/src/abi/etherscan.ts +2 -2
- package/src/abi/loader.ts +2 -2
- package/src/abi/sourcify.ts +2 -2
- package/src/abi/transformer.ts +2 -6
- package/src/adapter.ts +11 -2
- package/src/config.ts +1 -1
- package/src/configuration/__tests__/explorer.test.ts +1 -1
- package/src/configuration/__tests__/rpc.test.ts +4 -4
- package/src/configuration/execution.ts +2 -2
- package/src/configuration/explorer.ts +2 -6
- package/src/configuration/network-services.ts +3 -3
- package/src/configuration/rpc.ts +2 -2
- package/src/mapping/__tests__/field-generator.test.ts +1 -1
- package/src/mapping/constants.ts +26 -1
- package/src/mapping/field-generator.ts +2 -2
- package/src/mapping/type-mapper.ts +1 -1
- package/src/proxy/detection.ts +1 -1
- package/src/query/handler.ts +2 -2
- package/src/query/view-checker.ts +1 -1
- package/src/transaction/components/AdvancedInfo.tsx +1 -1
- package/src/transaction/components/CustomGasParameters.tsx +2 -2
- package/src/transaction/components/EvmRelayerOptions.tsx +1 -1
- package/src/transaction/components/SpeedSelection.tsx +1 -1
- package/src/transaction/eoa.ts +2 -2
- package/src/transaction/execution-strategy.ts +1 -1
- package/src/transaction/formatter.ts +2 -2
- package/src/transaction/relayer.ts +2 -2
- package/src/transaction/sender.ts +2 -2
- package/src/transform/input-parser.ts +2 -2
- package/src/transform/output-formatter.ts +2 -2
- package/src/types.ts +1 -1
- package/src/validation/eoa.ts +2 -2
- package/src/validation/relayer.ts +1 -1
- package/src/wallet/README.md +4 -4
- package/src/wallet/__tests__/utils.test.ts +2 -2
- package/src/wallet/components/EvmWalletUiRoot.tsx +2 -2
- package/src/wallet/components/account/AccountDisplay.tsx +33 -14
- package/src/wallet/components/connect/ConnectButton.tsx +31 -17
- package/src/wallet/components/connect/ConnectorDialog.tsx +3 -6
- package/src/wallet/components/network/NetworkSwitcher.tsx +48 -16
- package/src/wallet/evmUiKitManager.ts +2 -2
- package/src/wallet/hooks/facade-hooks.ts +1 -1
- package/src/wallet/hooks/useUiKitConfig.ts +2 -2
- package/src/wallet/implementation/wagmi-implementation.ts +3 -3
- package/src/wallet/rainbowkit/__tests__/export-service.test.ts +1 -1
- package/src/wallet/rainbowkit/componentFactory.ts +1 -1
- package/src/wallet/rainbowkit/components.tsx +9 -7
- package/src/wallet/rainbowkit/config-generator.ts +1 -1
- package/src/wallet/rainbowkit/config-service.ts +2 -2
- package/src/wallet/rainbowkit/export-service.ts +1 -1
- package/src/wallet/rainbowkit/rainbowkitAssetManager.ts +1 -1
- package/src/wallet/rainbowkit/utils.ts +2 -2
- package/src/wallet/services/configResolutionService.ts +2 -2
- package/src/wallet/types.ts +1 -1
- package/src/wallet/utils/SafeWagmiComponent.tsx +1 -1
- package/src/wallet/utils/__tests__/uiKitService.test.ts +3 -3
- package/src/wallet/utils/connection.ts +2 -2
- package/src/wallet/utils/filterWalletComponents.ts +3 -3
- package/src/wallet/utils/uiKitService.ts +2 -2
- package/src/wallet/utils/walletImplementationManager.ts +2 -2
- package/src/wallet/utils.ts +2 -2
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { beforeEach, describe, expect, it, vi } from 'vitest';
|
|
2
2
|
|
|
3
|
-
import { logger } from '@openzeppelin/ui-
|
|
3
|
+
import { logger } from '@openzeppelin/ui-utils';
|
|
4
4
|
|
|
5
5
|
import { resolveAndInitializeKitConfig } from '../utils';
|
|
6
6
|
|
|
7
7
|
// Mock the logger to prevent console output during tests and allow spying
|
|
8
|
-
vi.mock('@openzeppelin/ui-
|
|
8
|
+
vi.mock('@openzeppelin/ui-utils', () => ({
|
|
9
9
|
logger: {
|
|
10
10
|
debug: vi.fn(),
|
|
11
11
|
info: vi.fn(),
|
|
@@ -4,8 +4,8 @@ import { mainnet } from 'viem/chains';
|
|
|
4
4
|
import { WagmiProvider } from 'wagmi';
|
|
5
5
|
import React, { useEffect, useMemo, useState } from 'react';
|
|
6
6
|
|
|
7
|
-
import type { EcosystemReactUiProviderProps } from '@openzeppelin/ui-
|
|
8
|
-
import { logger } from '@openzeppelin/ui-
|
|
7
|
+
import type { EcosystemReactUiProviderProps } from '@openzeppelin/ui-types';
|
|
8
|
+
import { logger } from '@openzeppelin/ui-utils';
|
|
9
9
|
|
|
10
10
|
import { WagmiProviderInitializedContext } from '../context/wagmi-context';
|
|
11
11
|
import { evmUiKitManager, type EvmUiKitManagerState } from '../evmUiKitManager';
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { LogOut } from 'lucide-react';
|
|
2
2
|
import React from 'react';
|
|
3
3
|
|
|
4
|
-
import {
|
|
5
|
-
import
|
|
6
|
-
import {
|
|
7
|
-
import { cn, truncateMiddle } from '@openzeppelin/ui-
|
|
4
|
+
import { Button } from '@openzeppelin/ui-components';
|
|
5
|
+
import { useDerivedAccountStatus, useDerivedDisconnect } from '@openzeppelin/ui-react';
|
|
6
|
+
import type { BaseComponentProps } from '@openzeppelin/ui-types';
|
|
7
|
+
import { cn, getWalletAccountDisplaySizeProps, truncateMiddle } from '@openzeppelin/ui-utils';
|
|
8
8
|
|
|
9
9
|
import { SafeWagmiComponent } from '../../utils/SafeWagmiComponent';
|
|
10
10
|
|
|
@@ -12,40 +12,59 @@ import { SafeWagmiComponent } from '../../utils/SafeWagmiComponent';
|
|
|
12
12
|
* A component that displays the connected account address and chain ID.
|
|
13
13
|
* Also includes a disconnect button.
|
|
14
14
|
*/
|
|
15
|
-
export const CustomAccountDisplay: React.FC<BaseComponentProps> = ({
|
|
15
|
+
export const CustomAccountDisplay: React.FC<BaseComponentProps> = ({
|
|
16
|
+
className,
|
|
17
|
+
size,
|
|
18
|
+
variant,
|
|
19
|
+
fullWidth,
|
|
20
|
+
}) => {
|
|
16
21
|
// Use the SafeWagmiComponent with null fallback
|
|
17
22
|
return (
|
|
18
23
|
<SafeWagmiComponent fallback={null}>
|
|
19
|
-
<AccountDisplayContent
|
|
24
|
+
<AccountDisplayContent
|
|
25
|
+
className={className}
|
|
26
|
+
size={size}
|
|
27
|
+
variant={variant}
|
|
28
|
+
fullWidth={fullWidth}
|
|
29
|
+
/>
|
|
20
30
|
</SafeWagmiComponent>
|
|
21
31
|
);
|
|
22
32
|
};
|
|
23
33
|
|
|
24
34
|
// Inner component that uses derived hooks
|
|
25
|
-
const AccountDisplayContent: React.FC<
|
|
35
|
+
const AccountDisplayContent: React.FC<BaseComponentProps> = ({
|
|
36
|
+
className,
|
|
37
|
+
size,
|
|
38
|
+
variant,
|
|
39
|
+
fullWidth,
|
|
40
|
+
}) => {
|
|
26
41
|
const { isConnected, address, chainId } = useDerivedAccountStatus();
|
|
27
42
|
const { disconnect } = useDerivedDisconnect();
|
|
28
43
|
|
|
44
|
+
const sizeProps = getWalletAccountDisplaySizeProps(size);
|
|
45
|
+
|
|
29
46
|
if (!isConnected || !address || !disconnect) {
|
|
30
47
|
return null;
|
|
31
48
|
}
|
|
32
49
|
|
|
33
50
|
return (
|
|
34
|
-
<div className={cn('flex items-center gap-2', className)}>
|
|
35
|
-
<div className=
|
|
36
|
-
<span className=
|
|
37
|
-
|
|
51
|
+
<div className={cn('flex items-center gap-2', fullWidth && 'w-full', className)}>
|
|
52
|
+
<div className={cn('flex flex-col', fullWidth && 'flex-1')}>
|
|
53
|
+
<span className={cn(sizeProps.textSize, 'font-medium')}>
|
|
54
|
+
{truncateMiddle(address, 4, 4)}
|
|
55
|
+
</span>
|
|
56
|
+
<span className={cn(sizeProps.subTextSize, 'text-muted-foreground -mt-0.5')}>
|
|
38
57
|
{chainId ? `Chain ID: ${chainId}` : 'Chain ID: N/A'}
|
|
39
58
|
</span>
|
|
40
59
|
</div>
|
|
41
60
|
<Button
|
|
42
61
|
onClick={() => disconnect()}
|
|
43
|
-
variant=
|
|
62
|
+
variant={variant || 'ghost'}
|
|
44
63
|
size="icon"
|
|
45
|
-
className=
|
|
64
|
+
className={cn(sizeProps.iconButtonSize, 'p-0')}
|
|
46
65
|
title="Disconnect wallet"
|
|
47
66
|
>
|
|
48
|
-
<LogOut className=
|
|
67
|
+
<LogOut className={sizeProps.iconSize} />
|
|
49
68
|
</Button>
|
|
50
69
|
</div>
|
|
51
70
|
);
|
|
@@ -1,13 +1,10 @@
|
|
|
1
1
|
import { Loader2, Wallet } from 'lucide-react';
|
|
2
2
|
import React, { useEffect, useState } from 'react';
|
|
3
3
|
|
|
4
|
-
import {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
} from '@openzeppelin/ui-
|
|
8
|
-
import type { BaseComponentProps } from '@openzeppelin/ui-builder-types';
|
|
9
|
-
import { Button } from '@openzeppelin/ui-builder-ui';
|
|
10
|
-
import { cn } from '@openzeppelin/ui-builder-utils';
|
|
4
|
+
import { Button } from '@openzeppelin/ui-components';
|
|
5
|
+
import { useDerivedAccountStatus, useDerivedConnectStatus } from '@openzeppelin/ui-react';
|
|
6
|
+
import type { BaseComponentProps, WalletComponentSize } from '@openzeppelin/ui-types';
|
|
7
|
+
import { cn, getWalletButtonSizeProps } from '@openzeppelin/ui-utils';
|
|
11
8
|
|
|
12
9
|
import { SafeWagmiComponent } from '../../utils/SafeWagmiComponent';
|
|
13
10
|
import { ConnectorDialog } from './ConnectorDialog';
|
|
@@ -23,14 +20,23 @@ export interface ConnectButtonProps extends BaseComponentProps {
|
|
|
23
20
|
|
|
24
21
|
export const CustomConnectButton: React.FC<ConnectButtonProps> = ({
|
|
25
22
|
className,
|
|
23
|
+
size,
|
|
24
|
+
variant,
|
|
25
|
+
fullWidth,
|
|
26
26
|
hideWhenConnected = true,
|
|
27
27
|
}) => {
|
|
28
28
|
const [dialogOpen, setDialogOpen] = useState(false);
|
|
29
|
+
const sizeProps = getWalletButtonSizeProps(size);
|
|
29
30
|
|
|
30
31
|
const unavailableButton = (
|
|
31
|
-
<div className={cn('flex items-center', className)}>
|
|
32
|
-
<Button
|
|
33
|
-
|
|
32
|
+
<div className={cn('flex items-center', fullWidth && 'w-full', className)}>
|
|
33
|
+
<Button
|
|
34
|
+
disabled={true}
|
|
35
|
+
variant={variant || 'outline'}
|
|
36
|
+
size={sizeProps.size}
|
|
37
|
+
className={cn(sizeProps.className, fullWidth && 'w-full')}
|
|
38
|
+
>
|
|
39
|
+
<Wallet className={cn(sizeProps.iconSize, 'mr-1')} />
|
|
34
40
|
Wallet Unavailable
|
|
35
41
|
</Button>
|
|
36
42
|
</div>
|
|
@@ -40,6 +46,9 @@ export const CustomConnectButton: React.FC<ConnectButtonProps> = ({
|
|
|
40
46
|
<SafeWagmiComponent fallback={unavailableButton}>
|
|
41
47
|
<ConnectButtonContent
|
|
42
48
|
className={className}
|
|
49
|
+
size={size}
|
|
50
|
+
variant={variant}
|
|
51
|
+
fullWidth={fullWidth}
|
|
43
52
|
dialogOpen={dialogOpen}
|
|
44
53
|
setDialogOpen={setDialogOpen}
|
|
45
54
|
hideWhenConnected={hideWhenConnected}
|
|
@@ -50,16 +59,21 @@ export const CustomConnectButton: React.FC<ConnectButtonProps> = ({
|
|
|
50
59
|
|
|
51
60
|
const ConnectButtonContent: React.FC<{
|
|
52
61
|
className?: string;
|
|
62
|
+
size?: WalletComponentSize;
|
|
63
|
+
variant?: BaseComponentProps['variant'];
|
|
64
|
+
fullWidth?: boolean;
|
|
53
65
|
dialogOpen: boolean;
|
|
54
66
|
setDialogOpen: (open: boolean) => void;
|
|
55
67
|
hideWhenConnected: boolean;
|
|
56
|
-
}> = ({ className, dialogOpen, setDialogOpen, hideWhenConnected }) => {
|
|
68
|
+
}> = ({ className, size, variant, fullWidth, dialogOpen, setDialogOpen, hideWhenConnected }) => {
|
|
57
69
|
const { isConnected } = useDerivedAccountStatus();
|
|
58
70
|
const { isConnecting: isHookConnecting, error: connectError } = useDerivedConnectStatus();
|
|
59
71
|
|
|
60
72
|
// Local state to indicate the button has been clicked and dialog is open, awaiting user selection
|
|
61
73
|
const [isManuallyInitiated, setIsManuallyInitiated] = useState(false);
|
|
62
74
|
|
|
75
|
+
const sizeProps = getWalletButtonSizeProps(size);
|
|
76
|
+
|
|
63
77
|
useEffect(() => {
|
|
64
78
|
if (isConnected && hideWhenConnected) {
|
|
65
79
|
setDialogOpen(false);
|
|
@@ -96,19 +110,19 @@ const ConnectButtonContent: React.FC<{
|
|
|
96
110
|
const showButtonLoading = isHookConnecting || isManuallyInitiated;
|
|
97
111
|
|
|
98
112
|
return (
|
|
99
|
-
<div className={cn('flex items-center', className)}>
|
|
113
|
+
<div className={cn('flex items-center', fullWidth && 'w-full', className)}>
|
|
100
114
|
<Button
|
|
101
115
|
onClick={handleConnectClick}
|
|
102
116
|
disabled={showButtonLoading || isConnected}
|
|
103
|
-
variant=
|
|
104
|
-
size=
|
|
105
|
-
className=
|
|
117
|
+
variant={variant || 'outline'}
|
|
118
|
+
size={sizeProps.size}
|
|
119
|
+
className={cn(sizeProps.className, fullWidth && 'w-full')}
|
|
106
120
|
title={isConnected ? 'Connected' : connectError?.message || 'Connect Wallet'}
|
|
107
121
|
>
|
|
108
122
|
{showButtonLoading ? (
|
|
109
|
-
<Loader2 className=
|
|
123
|
+
<Loader2 className={cn(sizeProps.iconSize, 'animate-spin mr-1')} />
|
|
110
124
|
) : (
|
|
111
|
-
<Wallet className=
|
|
125
|
+
<Wallet className={cn(sizeProps.iconSize, 'mr-1')} />
|
|
112
126
|
)}
|
|
113
127
|
{showButtonLoading ? 'Connecting...' : 'Connect Wallet'}
|
|
114
128
|
</Button>
|
|
@@ -1,10 +1,5 @@
|
|
|
1
1
|
import React, { useEffect, useState } from 'react';
|
|
2
2
|
|
|
3
|
-
import {
|
|
4
|
-
useDerivedAccountStatus,
|
|
5
|
-
useDerivedConnectStatus,
|
|
6
|
-
} from '@openzeppelin/ui-builder-react-core';
|
|
7
|
-
import type { Connector } from '@openzeppelin/ui-builder-types';
|
|
8
3
|
import {
|
|
9
4
|
Button,
|
|
10
5
|
Dialog,
|
|
@@ -12,7 +7,9 @@ import {
|
|
|
12
7
|
DialogDescription,
|
|
13
8
|
DialogHeader,
|
|
14
9
|
DialogTitle,
|
|
15
|
-
} from '@openzeppelin/ui-
|
|
10
|
+
} from '@openzeppelin/ui-components';
|
|
11
|
+
import { useDerivedAccountStatus, useDerivedConnectStatus } from '@openzeppelin/ui-react';
|
|
12
|
+
import type { Connector } from '@openzeppelin/ui-types';
|
|
16
13
|
|
|
17
14
|
import { isConfigEnabled, useUiKitConfig } from '../../hooks/useUiKitConfig';
|
|
18
15
|
import { SafeWagmiComponent } from '../../utils/SafeWagmiComponent';
|
|
@@ -2,20 +2,24 @@ import { Loader2 } from 'lucide-react';
|
|
|
2
2
|
import type { Chain } from 'viem';
|
|
3
3
|
import React from 'react';
|
|
4
4
|
|
|
5
|
-
import {
|
|
6
|
-
useDerivedAccountStatus,
|
|
7
|
-
useDerivedChainInfo,
|
|
8
|
-
useDerivedSwitchChainStatus,
|
|
9
|
-
} from '@openzeppelin/ui-builder-react-core';
|
|
10
|
-
import type { BaseComponentProps } from '@openzeppelin/ui-builder-types';
|
|
11
5
|
import {
|
|
12
6
|
Select,
|
|
13
7
|
SelectContent,
|
|
14
8
|
SelectItem,
|
|
15
9
|
SelectTrigger,
|
|
16
10
|
SelectValue,
|
|
17
|
-
} from '@openzeppelin/ui-
|
|
18
|
-
import {
|
|
11
|
+
} from '@openzeppelin/ui-components';
|
|
12
|
+
import {
|
|
13
|
+
useDerivedAccountStatus,
|
|
14
|
+
useDerivedChainInfo,
|
|
15
|
+
useDerivedSwitchChainStatus,
|
|
16
|
+
} from '@openzeppelin/ui-react';
|
|
17
|
+
import type { BaseComponentProps } from '@openzeppelin/ui-types';
|
|
18
|
+
import {
|
|
19
|
+
cn,
|
|
20
|
+
getWalletNetworkSwitcherSizeProps,
|
|
21
|
+
getWalletNetworkSwitcherVariantClassName,
|
|
22
|
+
} from '@openzeppelin/ui-utils';
|
|
19
23
|
|
|
20
24
|
import { SafeWagmiComponent } from '../../utils/SafeWagmiComponent';
|
|
21
25
|
|
|
@@ -23,21 +27,39 @@ import { SafeWagmiComponent } from '../../utils/SafeWagmiComponent';
|
|
|
23
27
|
* A component that displays the current network and allows switching to other networks.
|
|
24
28
|
* Uses the chainId and switchChain hooks from wagmi.
|
|
25
29
|
*/
|
|
26
|
-
export const CustomNetworkSwitcher: React.FC<BaseComponentProps> = ({
|
|
30
|
+
export const CustomNetworkSwitcher: React.FC<BaseComponentProps> = ({
|
|
31
|
+
className,
|
|
32
|
+
size,
|
|
33
|
+
variant,
|
|
34
|
+
fullWidth,
|
|
35
|
+
}) => {
|
|
27
36
|
// Use the SafeWagmiComponent with null fallback
|
|
28
37
|
return (
|
|
29
38
|
<SafeWagmiComponent fallback={null}>
|
|
30
|
-
<NetworkSwitcherContent
|
|
39
|
+
<NetworkSwitcherContent
|
|
40
|
+
className={className}
|
|
41
|
+
size={size}
|
|
42
|
+
variant={variant}
|
|
43
|
+
fullWidth={fullWidth}
|
|
44
|
+
/>
|
|
31
45
|
</SafeWagmiComponent>
|
|
32
46
|
);
|
|
33
47
|
};
|
|
34
48
|
|
|
35
49
|
// Inner component that uses wagmi hooks
|
|
36
|
-
const NetworkSwitcherContent: React.FC<
|
|
50
|
+
const NetworkSwitcherContent: React.FC<BaseComponentProps> = ({
|
|
51
|
+
className,
|
|
52
|
+
size,
|
|
53
|
+
variant,
|
|
54
|
+
fullWidth,
|
|
55
|
+
}) => {
|
|
37
56
|
const { isConnected } = useDerivedAccountStatus();
|
|
38
57
|
const { currentChainId, availableChains: unknownChains } = useDerivedChainInfo();
|
|
39
58
|
const { switchChain, isSwitching: isPending, error } = useDerivedSwitchChainStatus();
|
|
40
59
|
|
|
60
|
+
const sizeProps = getWalletNetworkSwitcherSizeProps(size);
|
|
61
|
+
const variantClassName = getWalletNetworkSwitcherVariantClassName(variant);
|
|
62
|
+
|
|
41
63
|
// Cast to Chain[] for use within this EVM-specific component
|
|
42
64
|
const typedAvailableChains = unknownChains as Chain[];
|
|
43
65
|
|
|
@@ -55,13 +77,19 @@ const NetworkSwitcherContent: React.FC<{ className?: string }> = ({ className })
|
|
|
55
77
|
const currentChainName = currentChain?.name || 'Network';
|
|
56
78
|
|
|
57
79
|
return (
|
|
58
|
-
<div className={cn('flex items-center', className)}>
|
|
80
|
+
<div className={cn('flex items-center', fullWidth && 'w-full', className)}>
|
|
59
81
|
<Select
|
|
60
82
|
value={currentChainId?.toString() ?? ''}
|
|
61
83
|
onValueChange={(value: string) => handleNetworkChange(Number(value))}
|
|
62
84
|
disabled={isPending || typedAvailableChains.length === 0}
|
|
63
85
|
>
|
|
64
|
-
<SelectTrigger
|
|
86
|
+
<SelectTrigger
|
|
87
|
+
className={cn(
|
|
88
|
+
sizeProps.triggerClassName,
|
|
89
|
+
variantClassName,
|
|
90
|
+
fullWidth && 'w-full max-w-none'
|
|
91
|
+
)}
|
|
92
|
+
>
|
|
65
93
|
<SelectValue placeholder="Network">{currentChainName}</SelectValue>
|
|
66
94
|
</SelectTrigger>
|
|
67
95
|
<SelectContent
|
|
@@ -71,7 +99,11 @@ const NetworkSwitcherContent: React.FC<{ className?: string }> = ({ className })
|
|
|
71
99
|
className="w-auto min-w-[160px] max-h-[300px]"
|
|
72
100
|
>
|
|
73
101
|
{typedAvailableChains.map((chain) => (
|
|
74
|
-
<SelectItem
|
|
102
|
+
<SelectItem
|
|
103
|
+
key={chain.id}
|
|
104
|
+
value={chain.id.toString()}
|
|
105
|
+
className={sizeProps.itemClassName}
|
|
106
|
+
>
|
|
75
107
|
{chain.name}
|
|
76
108
|
</SelectItem>
|
|
77
109
|
))}
|
|
@@ -79,8 +111,8 @@ const NetworkSwitcherContent: React.FC<{ className?: string }> = ({ className })
|
|
|
79
111
|
</Select>
|
|
80
112
|
|
|
81
113
|
{isPending && (
|
|
82
|
-
<span className="text-
|
|
83
|
-
<Loader2 className=
|
|
114
|
+
<span className="text-muted-foreground ml-2">
|
|
115
|
+
<Loader2 className={cn(sizeProps.loaderSize, 'animate-spin')} />
|
|
84
116
|
</span>
|
|
85
117
|
)}
|
|
86
118
|
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import type { Config as WagmiConfig } from '@wagmi/core';
|
|
2
2
|
import type React from 'react';
|
|
3
3
|
|
|
4
|
-
import type { UiKitConfiguration } from '@openzeppelin/ui-
|
|
5
|
-
import { logger } from '@openzeppelin/ui-
|
|
4
|
+
import type { UiKitConfiguration } from '@openzeppelin/ui-types';
|
|
5
|
+
import { logger } from '@openzeppelin/ui-utils';
|
|
6
6
|
|
|
7
7
|
import { getEvmWalletImplementation } from './utils/walletImplementationManager';
|
|
8
8
|
|
|
@@ -23,7 +23,7 @@ import {
|
|
|
23
23
|
type UseWaitForTransactionReceiptReturnType,
|
|
24
24
|
} from 'wagmi';
|
|
25
25
|
|
|
26
|
-
import type { EcosystemSpecificReactHooks } from '@openzeppelin/ui-
|
|
26
|
+
import type { EcosystemSpecificReactHooks } from '@openzeppelin/ui-types';
|
|
27
27
|
|
|
28
28
|
/**
|
|
29
29
|
* Direct export of wagmi hooks as our facade hooks
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { UiKitConfiguration } from '@openzeppelin/ui-
|
|
2
|
-
import { appConfigService, logger } from '@openzeppelin/ui-
|
|
1
|
+
import type { UiKitConfiguration } from '@openzeppelin/ui-types';
|
|
2
|
+
import { appConfigService, logger } from '@openzeppelin/ui-utils';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* Default configuration when no specific configuration is provided
|
|
@@ -20,8 +20,8 @@ import {
|
|
|
20
20
|
} from '@wagmi/core';
|
|
21
21
|
import { http, PublicClient, WalletClient, type Chain } from 'viem';
|
|
22
22
|
|
|
23
|
-
import type { Connector, UiKitConfiguration } from '@openzeppelin/ui-
|
|
24
|
-
import { appConfigService, logger } from '@openzeppelin/ui-
|
|
23
|
+
import type { Connector, UiKitConfiguration } from '@openzeppelin/ui-types';
|
|
24
|
+
import { appConfigService, logger } from '@openzeppelin/ui-utils';
|
|
25
25
|
|
|
26
26
|
import { getUserRpcUrl } from '../../configuration/rpc';
|
|
27
27
|
import { evmNetworks } from '../../networks';
|
|
@@ -133,7 +133,7 @@ export class WagmiWalletImplementation {
|
|
|
133
133
|
*/
|
|
134
134
|
private setupRpcConfigListener(): void {
|
|
135
135
|
// Import dynamically to avoid circular dependencies
|
|
136
|
-
import('@openzeppelin/ui-
|
|
136
|
+
import('@openzeppelin/ui-utils')
|
|
137
137
|
.then(({ userRpcConfigService }) => {
|
|
138
138
|
// Subscribe to all RPC config changes
|
|
139
139
|
this.rpcConfigUnsubscribe = userRpcConfigService.subscribe('*', (event) => {
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { Loader2 } from 'lucide-react';
|
|
2
2
|
import React, { useContext, useEffect, useRef, useState } from 'react';
|
|
3
3
|
|
|
4
|
-
import
|
|
5
|
-
import {
|
|
6
|
-
import { cn, logger } from '@openzeppelin/ui-
|
|
4
|
+
import { Button } from '@openzeppelin/ui-components';
|
|
5
|
+
import type { BaseComponentProps } from '@openzeppelin/ui-types';
|
|
6
|
+
import { cn, getWalletButtonSizeProps, logger } from '@openzeppelin/ui-utils';
|
|
7
7
|
|
|
8
8
|
import { CustomConnectButton } from '../components';
|
|
9
9
|
import { WagmiProviderInitializedContext } from '../context/wagmi-context';
|
|
@@ -79,14 +79,16 @@ export const RainbowKitConnectButton: React.FC<BaseComponentProps> = (props) =>
|
|
|
79
79
|
};
|
|
80
80
|
}, []); // Effect for dynamic import runs once
|
|
81
81
|
|
|
82
|
+
const sizeProps = getWalletButtonSizeProps(props.size);
|
|
83
|
+
|
|
82
84
|
const renderLoadingPlaceholder = (message: string) => (
|
|
83
85
|
<Button
|
|
84
86
|
disabled={true}
|
|
85
|
-
variant=
|
|
86
|
-
size=
|
|
87
|
-
className={cn(
|
|
87
|
+
variant={props.variant || 'outline'}
|
|
88
|
+
size={sizeProps.size}
|
|
89
|
+
className={cn(sizeProps.className, props.fullWidth && 'w-full', props.className)}
|
|
88
90
|
>
|
|
89
|
-
<Loader2 className=
|
|
91
|
+
<Loader2 className={cn(sizeProps.iconSize, 'animate-spin mr-1.5')} />
|
|
90
92
|
{message}
|
|
91
93
|
</Button>
|
|
92
94
|
);
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { Config, http } from '@wagmi/core';
|
|
2
2
|
import { type Chain } from 'viem';
|
|
3
3
|
|
|
4
|
-
import type { UiKitConfiguration } from '@openzeppelin/ui-
|
|
5
|
-
import { logger } from '@openzeppelin/ui-
|
|
4
|
+
import type { UiKitConfiguration } from '@openzeppelin/ui-types';
|
|
5
|
+
import { logger } from '@openzeppelin/ui-utils';
|
|
6
6
|
|
|
7
7
|
import { type WagmiConfigChains } from '../types';
|
|
8
8
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { UiKitConfiguration } from '@openzeppelin/ui-
|
|
2
|
-
import { logger } from '@openzeppelin/ui-
|
|
1
|
+
import type { UiKitConfiguration } from '@openzeppelin/ui-types';
|
|
2
|
+
import { logger } from '@openzeppelin/ui-utils';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* RainbowKit configuration options definition
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { NativeConfigLoader, UiKitConfiguration } from '@openzeppelin/ui-
|
|
2
|
-
import { logger } from '@openzeppelin/ui-
|
|
1
|
+
import type { NativeConfigLoader, UiKitConfiguration } from '@openzeppelin/ui-types';
|
|
2
|
+
import { logger } from '@openzeppelin/ui-utils';
|
|
3
3
|
|
|
4
4
|
import { resolveAndInitializeKitConfig } from '../utils';
|
|
5
5
|
|
package/src/wallet/types.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { Chain } from 'viem';
|
|
2
2
|
|
|
3
|
-
import type { WalletConnectionStatus } from '@openzeppelin/ui-
|
|
3
|
+
import type { WalletConnectionStatus } from '@openzeppelin/ui-types';
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* EVM-specific wallet connection status extending the base interface.
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { beforeEach, describe, expect, it, vi } from 'vitest';
|
|
2
2
|
|
|
3
|
-
import type { ComponentExclusionConfig, UiKitConfiguration } from '@openzeppelin/ui-
|
|
4
|
-
import { logger } from '@openzeppelin/ui-
|
|
3
|
+
import type { ComponentExclusionConfig, UiKitConfiguration } from '@openzeppelin/ui-types';
|
|
4
|
+
import { logger } from '@openzeppelin/ui-utils';
|
|
5
5
|
|
|
6
6
|
import { CustomAccountDisplay, CustomConnectButton, CustomNetworkSwitcher } from '../../components';
|
|
7
7
|
import { getResolvedWalletComponents } from '../uiKitService';
|
|
8
8
|
|
|
9
9
|
// Mock the logger
|
|
10
|
-
vi.mock('@openzeppelin/ui-
|
|
10
|
+
vi.mock('@openzeppelin/ui-utils', () => ({
|
|
11
11
|
logger: {
|
|
12
12
|
info: vi.fn(),
|
|
13
13
|
warn: vi.fn(),
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { GetAccountReturnType } from '@wagmi/core';
|
|
2
2
|
|
|
3
|
-
import type { Connector } from '@openzeppelin/ui-
|
|
4
|
-
import { logger } from '@openzeppelin/ui-
|
|
3
|
+
import type { Connector } from '@openzeppelin/ui-types';
|
|
4
|
+
import { logger } from '@openzeppelin/ui-utils';
|
|
5
5
|
|
|
6
6
|
import {
|
|
7
7
|
getEvmWalletImplementation,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import type { EcosystemWalletComponents, UiKitConfiguration } from '@openzeppelin/ui-
|
|
2
|
-
import { ECOSYSTEM_WALLET_COMPONENT_KEYS } from '@openzeppelin/ui-
|
|
3
|
-
import { logger } from '@openzeppelin/ui-
|
|
1
|
+
import type { EcosystemWalletComponents, UiKitConfiguration } from '@openzeppelin/ui-types';
|
|
2
|
+
import { ECOSYSTEM_WALLET_COMPONENT_KEYS } from '@openzeppelin/ui-types';
|
|
3
|
+
import { logger } from '@openzeppelin/ui-utils';
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* Filters a set of wallet components based on an exclusion list.
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { EcosystemWalletComponents, UiKitConfiguration } from '@openzeppelin/ui-
|
|
2
|
-
import { logger } from '@openzeppelin/ui-
|
|
1
|
+
import type { EcosystemWalletComponents, UiKitConfiguration } from '@openzeppelin/ui-types';
|
|
2
|
+
import { logger } from '@openzeppelin/ui-utils';
|
|
3
3
|
|
|
4
4
|
import { CustomAccountDisplay, CustomConnectButton, CustomNetworkSwitcher } from '../components';
|
|
5
5
|
import { createRainbowKitComponents, validateRainbowKitConfig } from '../rainbowkit';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { UiKitConfiguration } from '@openzeppelin/ui-
|
|
2
|
-
import { appConfigService, logger } from '@openzeppelin/ui-
|
|
1
|
+
import type { UiKitConfiguration } from '@openzeppelin/ui-types';
|
|
2
|
+
import { appConfigService, logger } from '@openzeppelin/ui-utils';
|
|
3
3
|
|
|
4
4
|
import { WagmiWalletImplementation } from '../implementation/wagmi-implementation';
|
|
5
5
|
|
package/src/wallet/utils.ts
CHANGED
|
@@ -2,8 +2,8 @@ import type {
|
|
|
2
2
|
EcosystemWalletComponents,
|
|
3
3
|
NativeConfigLoader,
|
|
4
4
|
UiKitConfiguration,
|
|
5
|
-
} from '@openzeppelin/ui-
|
|
6
|
-
import { logger } from '@openzeppelin/ui-
|
|
5
|
+
} from '@openzeppelin/ui-types';
|
|
6
|
+
import { logger } from '@openzeppelin/ui-utils';
|
|
7
7
|
|
|
8
8
|
// Import the actual service functions instead of using placeholders
|
|
9
9
|
import { getResolvedWalletComponents as getWalletComponentsFromService } from './utils/uiKitService';
|