@openzeppelin/ui-builder-adapter-evm 1.2.0 → 1.4.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 +33 -18
- package/dist/index.cjs +4651 -4448
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +12 -226
- package/dist/index.d.ts +12 -226
- package/dist/index.js +4737 -4535
- package/dist/index.js.map +1 -1
- package/package.json +7 -6
- package/src/__tests__/adapter-parsing.test.ts +4 -3
- package/src/__tests__/getDefaultServiceConfig.test.ts +185 -0
- package/src/__tests__/mocks/mock-network-configs.ts +1 -1
- package/src/__tests__/provenanceLinks.test.ts +6 -4
- package/src/__tests__/providerSelection.test.ts +5 -4
- package/src/__tests__/timeouts.test.ts +5 -3
- package/src/__tests__/wallet-connect.test.ts +2 -2
- package/src/adapter.ts +61 -107
- package/src/configuration/execution.ts +1 -52
- package/src/configuration/index.ts +2 -3
- package/src/configuration/network-services.ts +47 -60
- package/src/index.ts +22 -13
- package/src/networks/index.ts +2 -1
- package/src/networks/mainnet.ts +1 -1
- package/src/networks/testnet.ts +1 -1
- package/src/query/adapter-query.ts +72 -0
- package/src/query/index.ts +2 -2
- package/src/transaction/components/useEvmRelayerOptions.ts +5 -3
- package/src/transaction/index.ts +1 -5
- package/src/types/artifacts.ts +5 -30
- package/src/types/providers.ts +7 -18
- package/src/wallet/components/EvmWalletUiRoot.tsx +1 -1
- package/src/wallet/evmUiKitManager.ts +26 -129
- package/src/wallet/hooks/index.ts +0 -1
- package/src/wallet/implementation/wagmi-implementation.ts +45 -577
- package/src/wallet/index.ts +2 -3
- package/src/wallet/rainbowkit/__tests__/export-service.test.ts +1 -2
- package/src/wallet/rainbowkit/componentFactory.ts +10 -8
- package/src/wallet/rainbowkit/components.tsx +16 -133
- package/src/wallet/rainbowkit/index.ts +27 -5
- package/src/wallet/utils/__tests__/uiKitService.test.ts +5 -1
- package/src/wallet/utils/connection.ts +8 -52
- package/src/wallet/utils/index.ts +0 -2
- package/src/wallet/utils/uiKitService.ts +7 -3
- package/src/wallet/utils/walletImplementationManager.ts +5 -4
- package/src/wallet/utils.ts +1 -65
- package/src/abi/__tests__/etherscan-v2.test.ts +0 -117
- package/src/abi/__tests__/transformer.test.ts +0 -342
- package/src/abi/comparison.ts +0 -389
- package/src/abi/etherscan-v2.ts +0 -243
- package/src/abi/etherscan.ts +0 -158
- package/src/abi/index.ts +0 -7
- package/src/abi/loader.ts +0 -415
- package/src/abi/sourcify.ts +0 -75
- package/src/abi/transformer.ts +0 -163
- package/src/abi/types.ts +0 -101
- package/src/configuration/__tests__/explorer.test.ts +0 -174
- package/src/configuration/__tests__/rpc.test.ts +0 -176
- package/src/configuration/explorer.ts +0 -243
- package/src/configuration/rpc.ts +0 -257
- package/src/mapping/__tests__/field-generator.test.ts +0 -137
- package/src/mapping/__tests__/type-mapper.test.ts +0 -139
- package/src/mapping/constants.ts +0 -57
- package/src/mapping/field-generator.ts +0 -115
- package/src/mapping/index.ts +0 -4
- package/src/mapping/type-mapper.ts +0 -80
- package/src/proxy/detection.ts +0 -465
- package/src/query/handler.ts +0 -227
- package/src/query/view-checker.ts +0 -10
- package/src/transaction/eoa.ts +0 -98
- package/src/transaction/execution-strategy.ts +0 -33
- package/src/transaction/formatter.ts +0 -101
- package/src/transaction/relayer.ts +0 -380
- package/src/transaction/sender.ts +0 -185
- package/src/transform/index.ts +0 -3
- package/src/transform/input-parser.ts +0 -177
- package/src/transform/output-formatter.ts +0 -64
- package/src/types/__tests__/artifacts.test.ts +0 -105
- package/src/types.ts +0 -92
- package/src/utils/__tests__/artifacts.test.ts +0 -81
- package/src/utils/artifacts.ts +0 -30
- package/src/utils/formatting.ts +0 -25
- package/src/utils/gas.ts +0 -17
- package/src/utils/index.ts +0 -6
- package/src/utils/json.ts +0 -19
- package/src/utils/validation.ts +0 -10
- package/src/validation/eoa.ts +0 -33
- package/src/validation/index.ts +0 -2
- package/src/validation/relayer.ts +0 -13
- package/src/wallet/__tests__/utils.test.ts +0 -149
- package/src/wallet/components/account/AccountDisplay.tsx +0 -52
- package/src/wallet/components/connect/ConnectButton.tsx +0 -125
- package/src/wallet/components/connect/ConnectorDialog.tsx +0 -140
- package/src/wallet/components/index.ts +0 -4
- package/src/wallet/components/network/NetworkSwitcher.tsx +0 -90
- package/src/wallet/context/index.ts +0 -1
- package/src/wallet/context/wagmi-context.tsx +0 -7
- package/src/wallet/hooks/useIsWagmiProviderInitialized.ts +0 -11
- package/src/wallet/rainbowkit/config-generator.ts +0 -56
- package/src/wallet/rainbowkit/config-service.ts +0 -169
- package/src/wallet/rainbowkit/export-service.ts +0 -18
- package/src/wallet/rainbowkit/rainbowkitAssetManager.ts +0 -74
- package/src/wallet/rainbowkit/types.ts +0 -74
- package/src/wallet/rainbowkit/utils.ts +0 -96
- package/src/wallet/services/configResolutionService.ts +0 -65
- package/src/wallet/utils/SafeWagmiComponent.tsx +0 -72
- package/src/wallet/utils/filterWalletComponents.ts +0 -89
|
@@ -1,96 +0,0 @@
|
|
|
1
|
-
import type { UiKitConfiguration } from '@openzeppelin/ui-types';
|
|
2
|
-
import { logger } from '@openzeppelin/ui-utils';
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* RainbowKit configuration options definition
|
|
6
|
-
*/
|
|
7
|
-
|
|
8
|
-
/**
|
|
9
|
-
* Validates the RainbowKit configuration to ensure required fields are present.
|
|
10
|
-
*
|
|
11
|
-
* @param kitConfig - The RainbowKit configuration object
|
|
12
|
-
* @returns Object containing the validation result and any missing fields or error message
|
|
13
|
-
*/
|
|
14
|
-
export function validateRainbowKitConfig(kitConfig?: UiKitConfiguration['kitConfig']): {
|
|
15
|
-
isValid: boolean;
|
|
16
|
-
missingFields?: string[];
|
|
17
|
-
error?: string;
|
|
18
|
-
} {
|
|
19
|
-
// Detailed log to inspect the received kitConfig
|
|
20
|
-
logger.debug(
|
|
21
|
-
'validateRainbowKitConfig',
|
|
22
|
-
'Received kitConfig for validation:',
|
|
23
|
-
JSON.stringify(kitConfig)
|
|
24
|
-
);
|
|
25
|
-
|
|
26
|
-
if (!kitConfig) {
|
|
27
|
-
logger.warn('validateRainbowKitConfig', 'Validation failed: No kitConfig provided.');
|
|
28
|
-
return { isValid: false, error: 'No kitConfig provided for RainbowKit' };
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
// kitConfig is the fully resolved configuration object which should contain wagmiParams and providerProps.
|
|
32
|
-
// Access wagmiParams from within kitConfig.
|
|
33
|
-
const wagmiParamsFromKitConfig = (kitConfig as Record<string, unknown>).wagmiParams as
|
|
34
|
-
| Record<string, unknown>
|
|
35
|
-
| undefined;
|
|
36
|
-
|
|
37
|
-
if (
|
|
38
|
-
!wagmiParamsFromKitConfig ||
|
|
39
|
-
typeof wagmiParamsFromKitConfig !== 'object' ||
|
|
40
|
-
wagmiParamsFromKitConfig === null
|
|
41
|
-
) {
|
|
42
|
-
logger.warn(
|
|
43
|
-
'validateRainbowKitConfig',
|
|
44
|
-
'Validation failed: kitConfig.wagmiParams is missing or invalid.',
|
|
45
|
-
{ wagmiParamsFromKitConfig }
|
|
46
|
-
);
|
|
47
|
-
return { isValid: false, error: 'kitConfig.wagmiParams is missing or not a valid object' };
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
const missingFields: string[] = [];
|
|
51
|
-
if (
|
|
52
|
-
!('appName' in wagmiParamsFromKitConfig) ||
|
|
53
|
-
typeof wagmiParamsFromKitConfig.appName !== 'string'
|
|
54
|
-
) {
|
|
55
|
-
missingFields.push('wagmiParams.appName');
|
|
56
|
-
}
|
|
57
|
-
if (
|
|
58
|
-
!('projectId' in wagmiParamsFromKitConfig) ||
|
|
59
|
-
typeof wagmiParamsFromKitConfig.projectId !== 'string'
|
|
60
|
-
) {
|
|
61
|
-
missingFields.push('wagmiParams.projectId');
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
if (missingFields.length > 0) {
|
|
65
|
-
const errorMsg = `Missing or invalid required fields in wagmiParams: ${missingFields.join(', ')}`;
|
|
66
|
-
logger.warn('validateRainbowKitConfig', 'Validation failed:', errorMsg, { missingFields });
|
|
67
|
-
return {
|
|
68
|
-
isValid: false,
|
|
69
|
-
missingFields,
|
|
70
|
-
error: errorMsg,
|
|
71
|
-
};
|
|
72
|
-
}
|
|
73
|
-
logger.debug('validateRainbowKitConfig', 'Validation successful.');
|
|
74
|
-
return { isValid: true };
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
/**
|
|
78
|
-
* Extracts and type-guards a RainbowKit configuration from a UiKitConfiguration
|
|
79
|
-
*
|
|
80
|
-
* @param config The UI kit configuration
|
|
81
|
-
* @returns The raw kitConfig Record<string, unknown> or undefined.
|
|
82
|
-
*/
|
|
83
|
-
export function getRawUserNativeConfig(
|
|
84
|
-
config: UiKitConfiguration
|
|
85
|
-
): Record<string, unknown> | undefined {
|
|
86
|
-
if (config.kitName !== 'rainbowkit' || !config.kitConfig) {
|
|
87
|
-
return undefined;
|
|
88
|
-
}
|
|
89
|
-
// kitConfig is already expected to be Record<string, unknown> or undefined by UiKitConfiguration type.
|
|
90
|
-
// We just ensure it's not null and is an object here for safety if it were `any` somewhere up the chain.
|
|
91
|
-
if (typeof config.kitConfig === 'object' && config.kitConfig !== null) {
|
|
92
|
-
return config.kitConfig as Record<string, unknown>;
|
|
93
|
-
}
|
|
94
|
-
logger.warn('rainbowkit/utils', 'kitConfig for RainbowKit is not a valid object.');
|
|
95
|
-
return undefined;
|
|
96
|
-
}
|
|
@@ -1,65 +0,0 @@
|
|
|
1
|
-
import type { NativeConfigLoader, UiKitConfiguration } from '@openzeppelin/ui-types';
|
|
2
|
-
import { logger } from '@openzeppelin/ui-utils';
|
|
3
|
-
|
|
4
|
-
import { resolveAndInitializeKitConfig } from '../utils';
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* Resolves the final, complete UiKitConfiguration by merging various sources.
|
|
8
|
-
*
|
|
9
|
-
* @param programmaticOverrides - Overrides passed directly to the configureUiKit call.
|
|
10
|
-
* @param initialAppServiceKitName - The kitName noted from AppConfigService when the adapter instance was constructed.
|
|
11
|
-
* @param currentAppServiceConfig - The full UiKitConfiguration from AppConfigService, re-fetched at the time of the call.
|
|
12
|
-
* @param options - Options, including the callback to load user's native config file.
|
|
13
|
-
* @returns A Promise resolving to the final UiKitConfiguration.
|
|
14
|
-
*/
|
|
15
|
-
export async function resolveFullUiKitConfiguration(
|
|
16
|
-
programmaticOverrides: Partial<UiKitConfiguration>,
|
|
17
|
-
initialAppServiceKitName: UiKitConfiguration['kitName'],
|
|
18
|
-
currentAppServiceConfig: UiKitConfiguration, // This is the result of loadInitialConfigFromAppService()
|
|
19
|
-
options?: {
|
|
20
|
-
loadUiKitNativeConfig?: NativeConfigLoader;
|
|
21
|
-
}
|
|
22
|
-
): Promise<UiKitConfiguration> {
|
|
23
|
-
logger.debug(
|
|
24
|
-
'configResolutionService:resolveFullUiKitConfiguration',
|
|
25
|
-
'Starting resolution with:',
|
|
26
|
-
{
|
|
27
|
-
programmaticOverrides,
|
|
28
|
-
initialAppServiceKitName,
|
|
29
|
-
currentAppServiceConfig,
|
|
30
|
-
hasLoadNativeCallback: !!options?.loadUiKitNativeConfig,
|
|
31
|
-
hasCustomCode: !!programmaticOverrides.customCode,
|
|
32
|
-
}
|
|
33
|
-
);
|
|
34
|
-
|
|
35
|
-
const effectiveKitName: UiKitConfiguration['kitName'] =
|
|
36
|
-
programmaticOverrides.kitName ||
|
|
37
|
-
initialAppServiceKitName ||
|
|
38
|
-
currentAppServiceConfig.kitName ||
|
|
39
|
-
'custom';
|
|
40
|
-
|
|
41
|
-
// Resolve from native config file (if loader is provided)
|
|
42
|
-
const resolvedUserNativeAndProgrammaticKitConfig = await resolveAndInitializeKitConfig(
|
|
43
|
-
effectiveKitName,
|
|
44
|
-
programmaticOverrides.kitConfig,
|
|
45
|
-
options?.loadUiKitNativeConfig
|
|
46
|
-
);
|
|
47
|
-
|
|
48
|
-
const finalFullConfig: UiKitConfiguration = {
|
|
49
|
-
kitName: effectiveKitName,
|
|
50
|
-
kitConfig: {
|
|
51
|
-
...(currentAppServiceConfig.kitConfig || {}),
|
|
52
|
-
...(resolvedUserNativeAndProgrammaticKitConfig || {}),
|
|
53
|
-
// customCode is NOT applied to runtime config
|
|
54
|
-
},
|
|
55
|
-
// Pass through customCode for export purposes only
|
|
56
|
-
customCode: programmaticOverrides.customCode,
|
|
57
|
-
};
|
|
58
|
-
|
|
59
|
-
logger.debug(
|
|
60
|
-
'configResolutionService:resolveFullUiKitConfiguration',
|
|
61
|
-
'Resolved finalFullConfig:',
|
|
62
|
-
finalFullConfig
|
|
63
|
-
);
|
|
64
|
-
return finalFullConfig;
|
|
65
|
-
}
|
|
@@ -1,72 +0,0 @@
|
|
|
1
|
-
import React, { useEffect, useState } from 'react';
|
|
2
|
-
|
|
3
|
-
import { logger } from '@openzeppelin/ui-utils';
|
|
4
|
-
|
|
5
|
-
import { useIsWagmiProviderInitialized } from '../hooks/useIsWagmiProviderInitialized';
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
* A wrapper component that safely renders children that use wagmi hooks.
|
|
9
|
-
* It handles errors and provider initialization state to prevent crashes.
|
|
10
|
-
*/
|
|
11
|
-
export const SafeWagmiComponent = ({
|
|
12
|
-
children,
|
|
13
|
-
fallback = null,
|
|
14
|
-
}: {
|
|
15
|
-
children: React.ReactNode;
|
|
16
|
-
fallback?: React.ReactNode;
|
|
17
|
-
}) => {
|
|
18
|
-
const isProviderInitialized = useIsWagmiProviderInitialized();
|
|
19
|
-
const [hasError, setHasError] = useState(false);
|
|
20
|
-
|
|
21
|
-
useEffect(() => {
|
|
22
|
-
// Reset error state if provider initializes
|
|
23
|
-
if (isProviderInitialized) {
|
|
24
|
-
setHasError(false);
|
|
25
|
-
}
|
|
26
|
-
}, [isProviderInitialized]);
|
|
27
|
-
|
|
28
|
-
// Setup global error handler for wagmi errors
|
|
29
|
-
useEffect(() => {
|
|
30
|
-
const handleError = (event: ErrorEvent) => {
|
|
31
|
-
// Only handle wagmi-related errors
|
|
32
|
-
if (
|
|
33
|
-
event.error?.message?.includes('useConfig') ||
|
|
34
|
-
event.error?.message?.includes('WagmiProvider')
|
|
35
|
-
) {
|
|
36
|
-
logger.debug(
|
|
37
|
-
'SafeWagmiComponent',
|
|
38
|
-
'Caught wagmi error via window error event:',
|
|
39
|
-
event.error
|
|
40
|
-
);
|
|
41
|
-
setHasError(true);
|
|
42
|
-
event.preventDefault(); // Prevent the error from propagating
|
|
43
|
-
}
|
|
44
|
-
};
|
|
45
|
-
|
|
46
|
-
window.addEventListener('error', handleError);
|
|
47
|
-
return () => {
|
|
48
|
-
window.removeEventListener('error', handleError);
|
|
49
|
-
};
|
|
50
|
-
}, []);
|
|
51
|
-
|
|
52
|
-
// If provider isn't ready yet or we had an error, show fallback
|
|
53
|
-
if (!isProviderInitialized || hasError) {
|
|
54
|
-
return <>{fallback}</>;
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
try {
|
|
58
|
-
return <>{children}</>;
|
|
59
|
-
} catch (error) {
|
|
60
|
-
// Only catch render errors related to wagmi hooks
|
|
61
|
-
if (
|
|
62
|
-
error instanceof Error &&
|
|
63
|
-
(error.message.includes('useConfig') || error.message.includes('WagmiProvider'))
|
|
64
|
-
) {
|
|
65
|
-
logger.debug('SafeWagmiComponent', 'Caught wagmi error:', error);
|
|
66
|
-
setHasError(true);
|
|
67
|
-
return <>{fallback}</>;
|
|
68
|
-
}
|
|
69
|
-
// Re-throw other errors
|
|
70
|
-
throw error;
|
|
71
|
-
}
|
|
72
|
-
};
|
|
@@ -1,89 +0,0 @@
|
|
|
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
|
-
|
|
5
|
-
/**
|
|
6
|
-
* Filters a set of wallet components based on an exclusion list.
|
|
7
|
-
*
|
|
8
|
-
* @param allPossibleComponents - An object containing all potential components for a kit.
|
|
9
|
-
* @param exclusions - An array of component keys to exclude.
|
|
10
|
-
* @param kitName - The name of the kit being filtered (for logging purposes).
|
|
11
|
-
* @returns The filtered EcosystemWalletComponents object, or undefined if all components are excluded.
|
|
12
|
-
*/
|
|
13
|
-
export function filterWalletComponents(
|
|
14
|
-
allPossibleComponents: EcosystemWalletComponents,
|
|
15
|
-
exclusions: Array<keyof EcosystemWalletComponents>,
|
|
16
|
-
kitName: string = 'custom' // Default to custom for logging context
|
|
17
|
-
): EcosystemWalletComponents | undefined {
|
|
18
|
-
logger.debug(
|
|
19
|
-
'filterWalletComponents',
|
|
20
|
-
`Filtering components for kit: ${kitName}. Exclusions: ${exclusions.join(', ')}.`
|
|
21
|
-
);
|
|
22
|
-
if (!allPossibleComponents || Object.keys(allPossibleComponents).length === 0) {
|
|
23
|
-
logger.debug('filterWalletComponents', `No components provided to filter for kit: ${kitName}.`);
|
|
24
|
-
return undefined;
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
if (exclusions.length === 0) {
|
|
28
|
-
logger.debug(
|
|
29
|
-
'filterWalletComponents',
|
|
30
|
-
`Providing all components for kit: ${kitName}.`,
|
|
31
|
-
allPossibleComponents
|
|
32
|
-
);
|
|
33
|
-
return allPossibleComponents;
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
const filteredComponents: Partial<EcosystemWalletComponents> = {};
|
|
37
|
-
let componentCount = 0;
|
|
38
|
-
for (const key in allPossibleComponents) {
|
|
39
|
-
const componentKey = key as keyof EcosystemWalletComponents;
|
|
40
|
-
if (!exclusions.includes(componentKey)) {
|
|
41
|
-
if (allPossibleComponents[componentKey]) {
|
|
42
|
-
// Ensure the component actually exists before adding
|
|
43
|
-
filteredComponents[componentKey] = allPossibleComponents[componentKey];
|
|
44
|
-
componentCount++;
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
if (componentCount > 0) {
|
|
50
|
-
logger.debug(
|
|
51
|
-
'filterWalletComponents',
|
|
52
|
-
`Providing filtered components for kit: ${kitName} after exclusions (${exclusions.join(', ')}).`,
|
|
53
|
-
filteredComponents
|
|
54
|
-
);
|
|
55
|
-
return filteredComponents as EcosystemWalletComponents;
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
logger.debug('filterWalletComponents', `All components were excluded for kit: ${kitName}.`);
|
|
59
|
-
return undefined;
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
/**
|
|
63
|
-
* Extracts the component exclusion list from a UI kit configuration object.
|
|
64
|
-
*
|
|
65
|
-
* @param kitConfig - The `kitConfig` object from `UiKitConfiguration`.
|
|
66
|
-
* @returns An array of component keys to exclude, or an empty array if none are specified or config is invalid.
|
|
67
|
-
*/
|
|
68
|
-
export function getComponentExclusionsFromConfig(
|
|
69
|
-
kitConfig: UiKitConfiguration['kitConfig']
|
|
70
|
-
): Array<keyof EcosystemWalletComponents> {
|
|
71
|
-
if (kitConfig && typeof kitConfig === 'object' && 'components' in kitConfig) {
|
|
72
|
-
const componentsCfg = kitConfig.components;
|
|
73
|
-
if (
|
|
74
|
-
componentsCfg &&
|
|
75
|
-
typeof componentsCfg === 'object' &&
|
|
76
|
-
'exclude' in componentsCfg &&
|
|
77
|
-
Array.isArray(componentsCfg.exclude)
|
|
78
|
-
) {
|
|
79
|
-
// Ensure all elements are valid keys of EcosystemWalletComponents
|
|
80
|
-
// This provides a bit more type safety at runtime if the config comes from an untyped source
|
|
81
|
-
return componentsCfg.exclude.filter(
|
|
82
|
-
(key): key is keyof EcosystemWalletComponents =>
|
|
83
|
-
typeof key === 'string' &&
|
|
84
|
-
(ECOSYSTEM_WALLET_COMPONENT_KEYS as readonly string[]).includes(key)
|
|
85
|
-
) as Array<keyof EcosystemWalletComponents>;
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
|
-
return [];
|
|
89
|
-
}
|