@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
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@openzeppelin/ui-builder-adapter-evm",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.3.0",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "EVM Adapter for UI Builder",
|
|
6
6
|
"keywords": [
|
|
@@ -37,16 +37,16 @@
|
|
|
37
37
|
},
|
|
38
38
|
"dependencies": {
|
|
39
39
|
"@openzeppelin/relayer-sdk": "1.4.0",
|
|
40
|
+
"@openzeppelin/ui-components": "^1.0.4",
|
|
41
|
+
"@openzeppelin/ui-react": "^1.1.0",
|
|
42
|
+
"@openzeppelin/ui-types": "^1.2.0",
|
|
43
|
+
"@openzeppelin/ui-utils": "^1.1.0",
|
|
40
44
|
"@wagmi/connectors": "5.7.13",
|
|
41
45
|
"@wagmi/core": "^2.20.3",
|
|
42
46
|
"@web3icons/react": "^4.0.19",
|
|
43
47
|
"lodash": "^4.17.21",
|
|
44
48
|
"lucide-react": "^0.510.0",
|
|
45
|
-
"react-hook-form": "^7.62.0"
|
|
46
|
-
"@openzeppelin/ui-builder-react-core": "^1.0.0",
|
|
47
|
-
"@openzeppelin/ui-builder-types": "^1.0.0",
|
|
48
|
-
"@openzeppelin/ui-builder-ui": "^1.0.0",
|
|
49
|
-
"@openzeppelin/ui-builder-utils": "^1.0.0"
|
|
49
|
+
"react-hook-form": "^7.62.0"
|
|
50
50
|
},
|
|
51
51
|
"devDependencies": {
|
|
52
52
|
"@rainbow-me/rainbowkit": "^2.2.8",
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import { beforeEach, describe, expect, it } from 'vitest';
|
|
2
2
|
|
|
3
3
|
// Adjust path as needed
|
|
4
|
-
import type { ContractFunction, FunctionParameter } from '@openzeppelin/ui-
|
|
4
|
+
import type { ContractFunction, FunctionParameter } from '@openzeppelin/ui-types';
|
|
5
5
|
|
|
6
6
|
import { mockEvmNetworkConfig } from './mocks/mock-network-configs';
|
|
7
7
|
|
|
8
8
|
import { EvmAdapter } from '../adapter';
|
|
9
|
+
import { EVM_TYPE_TO_FIELD_TYPE } from '../mapping';
|
|
9
10
|
import { parseEvmInput as parseEvmInputFunction } from '../transform';
|
|
10
11
|
|
|
11
12
|
// Mock FunctionParameter type helper
|
|
@@ -464,3 +465,68 @@ describe('EvmAdapter Output Formatting', () => {
|
|
|
464
465
|
|
|
465
466
|
// Potential TODO: Add test for error during stringifyWithBigInt if possible (e.g., circular refs, though unlikely here)
|
|
466
467
|
});
|
|
468
|
+
|
|
469
|
+
// --- getTypeMappingInfo Tests ---
|
|
470
|
+
describe('EvmAdapter getTypeMappingInfo', () => {
|
|
471
|
+
let adapter: EvmAdapter;
|
|
472
|
+
|
|
473
|
+
beforeEach(() => {
|
|
474
|
+
adapter = new EvmAdapter(mockEvmNetworkConfig);
|
|
475
|
+
});
|
|
476
|
+
|
|
477
|
+
it('should return TypeMappingInfo with primitives and dynamicPatterns', () => {
|
|
478
|
+
const info = adapter.getTypeMappingInfo();
|
|
479
|
+
expect(info).toHaveProperty('primitives');
|
|
480
|
+
expect(info).toHaveProperty('dynamicPatterns');
|
|
481
|
+
expect(typeof info.primitives).toBe('object');
|
|
482
|
+
expect(Array.isArray(info.dynamicPatterns)).toBe(true);
|
|
483
|
+
});
|
|
484
|
+
|
|
485
|
+
it('should return primitives matching EVM_TYPE_TO_FIELD_TYPE constant', () => {
|
|
486
|
+
const info = adapter.getTypeMappingInfo();
|
|
487
|
+
const expectedTypes = Object.keys(EVM_TYPE_TO_FIELD_TYPE);
|
|
488
|
+
expect(Object.keys(info.primitives)).toEqual(expectedTypes);
|
|
489
|
+
});
|
|
490
|
+
|
|
491
|
+
it('should include expected EVM primitive types in primitives', () => {
|
|
492
|
+
const { primitives } = adapter.getTypeMappingInfo();
|
|
493
|
+
// Core EVM primitive types
|
|
494
|
+
expect(primitives).toHaveProperty('address');
|
|
495
|
+
expect(primitives).toHaveProperty('bool');
|
|
496
|
+
expect(primitives).toHaveProperty('string');
|
|
497
|
+
expect(primitives).toHaveProperty('bytes');
|
|
498
|
+
expect(primitives).toHaveProperty('bytes32');
|
|
499
|
+
// Integer types
|
|
500
|
+
expect(primitives).toHaveProperty('uint256');
|
|
501
|
+
expect(primitives).toHaveProperty('int256');
|
|
502
|
+
});
|
|
503
|
+
|
|
504
|
+
it('should NOT include dynamic types in primitives', () => {
|
|
505
|
+
const { primitives } = adapter.getTypeMappingInfo();
|
|
506
|
+
Object.keys(primitives).forEach((type) => {
|
|
507
|
+
expect(type).not.toMatch(/\[\]$/); // No array types
|
|
508
|
+
expect(type).not.toMatch(/^tuple/); // No tuple types
|
|
509
|
+
});
|
|
510
|
+
});
|
|
511
|
+
|
|
512
|
+
it('should include dynamic patterns for arrays and tuples', () => {
|
|
513
|
+
const { dynamicPatterns } = adapter.getTypeMappingInfo();
|
|
514
|
+
const patternNames = dynamicPatterns.map((p) => p.name);
|
|
515
|
+
expect(patternNames).toContain('array');
|
|
516
|
+
expect(patternNames).toContain('tuple');
|
|
517
|
+
expect(patternNames).toContain('tuple-array');
|
|
518
|
+
});
|
|
519
|
+
|
|
520
|
+
it('should have properly structured dynamic patterns', () => {
|
|
521
|
+
const { dynamicPatterns } = adapter.getTypeMappingInfo();
|
|
522
|
+
dynamicPatterns.forEach((pattern) => {
|
|
523
|
+
expect(pattern).toHaveProperty('name');
|
|
524
|
+
expect(pattern).toHaveProperty('syntax');
|
|
525
|
+
expect(pattern).toHaveProperty('mapsTo');
|
|
526
|
+
expect(pattern).toHaveProperty('description');
|
|
527
|
+
expect(typeof pattern.name).toBe('string');
|
|
528
|
+
expect(typeof pattern.syntax).toBe('string');
|
|
529
|
+
expect(typeof pattern.description).toBe('string');
|
|
530
|
+
});
|
|
531
|
+
});
|
|
532
|
+
});
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { TypedEvmNetworkConfig } from '../../types';
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* Mock EVM Network Configuration for testing purposes.
|
|
5
5
|
*/
|
|
6
|
-
export const mockEvmNetworkConfig:
|
|
6
|
+
export const mockEvmNetworkConfig: TypedEvmNetworkConfig = {
|
|
7
7
|
id: 'test-evm-mocknet',
|
|
8
8
|
exportConstName: 'mockEvmNetworkConfig',
|
|
9
9
|
name: 'Test EVM Mocknet',
|
|
@@ -15,6 +15,7 @@ export const mockEvmNetworkConfig: EvmNetworkConfig = {
|
|
|
15
15
|
rpcUrl: 'http://localhost:8545', // Mock RPC URL
|
|
16
16
|
nativeCurrency: { name: 'TestETH', symbol: 'TETH', decimals: 18 },
|
|
17
17
|
apiUrl: 'https://api.etherscan.io/api', // Mock API URL
|
|
18
|
+
viemChain: undefined, // Optional viem Chain object
|
|
18
19
|
};
|
|
19
20
|
|
|
20
21
|
// Add mocks for other ecosystems here if needed later
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';
|
|
2
2
|
|
|
3
|
-
import { appConfigService, userNetworkServiceConfigService } from '@openzeppelin/ui-
|
|
3
|
+
import { appConfigService, userNetworkServiceConfigService } from '@openzeppelin/ui-utils';
|
|
4
4
|
|
|
5
5
|
import { loadEvmContract } from '../abi/loader';
|
|
6
6
|
import type { TypedEvmNetworkConfig } from '../types';
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
import type { AbiFunction } from 'viem';
|
|
5
5
|
import { describe, expect, it, vi } from 'vitest';
|
|
6
6
|
|
|
7
|
-
import type { ContractFunction, ContractSchema } from '@openzeppelin/ui-
|
|
7
|
+
import type { ContractFunction, ContractSchema } from '@openzeppelin/ui-types';
|
|
8
8
|
|
|
9
9
|
import type { AbiItem } from '../../types';
|
|
10
10
|
// Adjust path as necessary
|
package/src/abi/comparison.ts
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
|
|
6
6
|
import type { Abi } from 'viem';
|
|
7
7
|
|
|
8
|
-
import { logger, simpleHash } from '@openzeppelin/ui-
|
|
8
|
+
import { logger, simpleHash } from '@openzeppelin/ui-utils';
|
|
9
9
|
|
|
10
10
|
import type { AbiComparisonResult, AbiDifference, AbiValidationResult } from './types';
|
|
11
11
|
import { isValidAbiArray } from './types';
|
package/src/abi/etherscan-v2.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { ContractSchema } from '@openzeppelin/ui-
|
|
2
|
-
import { logger } from '@openzeppelin/ui-
|
|
1
|
+
import type { ContractSchema } from '@openzeppelin/ui-types';
|
|
2
|
+
import { logger } from '@openzeppelin/ui-utils';
|
|
3
3
|
|
|
4
4
|
import { resolveExplorerConfig } from '../configuration/explorer';
|
|
5
5
|
import type { AbiItem, TypedEvmNetworkConfig } from '../types';
|
package/src/abi/etherscan.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { ContractSchema } from '@openzeppelin/ui-
|
|
2
|
-
import { logger } from '@openzeppelin/ui-
|
|
1
|
+
import type { ContractSchema } from '@openzeppelin/ui-types';
|
|
2
|
+
import { logger } from '@openzeppelin/ui-utils';
|
|
3
3
|
|
|
4
4
|
import { resolveExplorerConfig } from '../configuration/explorer';
|
|
5
5
|
import type { AbiItem, TypedEvmNetworkConfig } from '../types';
|
package/src/abi/loader.ts
CHANGED
|
@@ -5,14 +5,14 @@ import type {
|
|
|
5
5
|
ContractSchema,
|
|
6
6
|
EvmNetworkConfig,
|
|
7
7
|
ProxyInfo,
|
|
8
|
-
} from '@openzeppelin/ui-
|
|
8
|
+
} from '@openzeppelin/ui-types';
|
|
9
9
|
import {
|
|
10
10
|
appConfigService,
|
|
11
11
|
logger,
|
|
12
12
|
simpleHash,
|
|
13
13
|
userNetworkServiceConfigService,
|
|
14
14
|
withTimeout,
|
|
15
|
-
} from '@openzeppelin/ui-
|
|
15
|
+
} from '@openzeppelin/ui-utils';
|
|
16
16
|
|
|
17
17
|
import { getEvmExplorerAddressUrl } from '../configuration/explorer';
|
|
18
18
|
import { detectProxyFromAbi, getAdminAddress, getImplementationAddress } from '../proxy/detection';
|
package/src/abi/sourcify.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { ContractSchema } from '@openzeppelin/ui-
|
|
2
|
-
import { logger } from '@openzeppelin/ui-
|
|
1
|
+
import type { ContractSchema } from '@openzeppelin/ui-types';
|
|
2
|
+
import { logger } from '@openzeppelin/ui-utils';
|
|
3
3
|
|
|
4
4
|
import type { AbiItem, TypedEvmNetworkConfig } from '../types';
|
|
5
5
|
import { transformAbiToSchema } from './transformer';
|
package/src/abi/transformer.ts
CHANGED
|
@@ -1,11 +1,7 @@
|
|
|
1
1
|
import type { AbiFunction, AbiParameter, AbiStateMutability } from 'viem';
|
|
2
2
|
|
|
3
|
-
import type {
|
|
4
|
-
|
|
5
|
-
ContractSchema,
|
|
6
|
-
FunctionParameter,
|
|
7
|
-
} from '@openzeppelin/ui-builder-types';
|
|
8
|
-
import { logger } from '@openzeppelin/ui-builder-utils';
|
|
3
|
+
import type { ContractFunction, ContractSchema, FunctionParameter } from '@openzeppelin/ui-types';
|
|
4
|
+
import { logger } from '@openzeppelin/ui-utils';
|
|
9
5
|
|
|
10
6
|
import type { AbiItem } from '../types';
|
|
11
7
|
import { formatInputName, formatMethodName } from '../utils';
|
package/src/adapter.ts
CHANGED
|
@@ -23,12 +23,13 @@ import type {
|
|
|
23
23
|
RelayerDetailsRich,
|
|
24
24
|
TransactionStatusUpdate,
|
|
25
25
|
TxStatus,
|
|
26
|
+
TypeMappingInfo,
|
|
26
27
|
UiKitConfiguration,
|
|
27
28
|
UserExplorerConfig,
|
|
28
29
|
UserRpcProviderConfig,
|
|
29
30
|
WalletConnectionStatus,
|
|
30
|
-
} from '@openzeppelin/ui-
|
|
31
|
-
import { logger } from '@openzeppelin/ui-
|
|
31
|
+
} from '@openzeppelin/ui-types';
|
|
32
|
+
import { logger } from '@openzeppelin/ui-utils';
|
|
32
33
|
|
|
33
34
|
import { abiComparisonService } from './abi/comparison';
|
|
34
35
|
import {
|
|
@@ -60,6 +61,7 @@ import {
|
|
|
60
61
|
import {
|
|
61
62
|
generateEvmDefaultField,
|
|
62
63
|
getEvmCompatibleFieldTypes,
|
|
64
|
+
getEvmTypeMappingInfo,
|
|
63
65
|
mapEvmParamTypeToFieldType,
|
|
64
66
|
} from './mapping';
|
|
65
67
|
import { isEvmViewFunction, queryEvmViewFunction } from './query';
|
|
@@ -783,6 +785,13 @@ Get your WalletConnect projectId from <a href="https://cloud.walletconnect.com"
|
|
|
783
785
|
public hashContractDefinition(definition: string): string {
|
|
784
786
|
return abiComparisonService.hashAbi(definition);
|
|
785
787
|
}
|
|
788
|
+
|
|
789
|
+
/**
|
|
790
|
+
* @inheritdoc
|
|
791
|
+
*/
|
|
792
|
+
public getTypeMappingInfo(): TypeMappingInfo {
|
|
793
|
+
return getEvmTypeMappingInfo();
|
|
794
|
+
}
|
|
786
795
|
}
|
|
787
796
|
|
|
788
797
|
// Also export as default to ensure compatibility with various import styles
|
package/src/config.ts
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
* when generating exported projects. It follows the AdapterConfig
|
|
6
6
|
* interface to provide a structured approach to dependency management.
|
|
7
7
|
*/
|
|
8
|
-
import type { AdapterConfig } from '@openzeppelin/ui-
|
|
8
|
+
import type { AdapterConfig } from '@openzeppelin/ui-types';
|
|
9
9
|
|
|
10
10
|
export const evmAdapterConfig: AdapterConfig = {
|
|
11
11
|
/**
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';
|
|
2
2
|
|
|
3
|
-
import { EvmNetworkConfig, UserExplorerConfig } from '@openzeppelin/ui-
|
|
3
|
+
import { EvmNetworkConfig, UserExplorerConfig } from '@openzeppelin/ui-types';
|
|
4
4
|
|
|
5
5
|
import { testEvmExplorerConnection, validateEvmExplorerConfig } from '../../configuration/explorer';
|
|
6
6
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { beforeEach, describe, expect, it, vi } from 'vitest';
|
|
2
2
|
|
|
3
|
-
import type { EvmNetworkConfig } from '@openzeppelin/ui-
|
|
4
|
-
import { appConfigService } from '@openzeppelin/ui-
|
|
3
|
+
import type { EvmNetworkConfig } from '@openzeppelin/ui-types';
|
|
4
|
+
import { appConfigService } from '@openzeppelin/ui-utils';
|
|
5
5
|
|
|
6
6
|
import { resolveRpcUrl } from '../rpc';
|
|
7
7
|
|
|
@@ -24,8 +24,8 @@ const createMockConfig = (id: string, rpcUrl?: string, name?: string): EvmNetwor
|
|
|
24
24
|
});
|
|
25
25
|
|
|
26
26
|
// Mock the appConfigService from the correct package
|
|
27
|
-
vi.mock('@openzeppelin/ui-
|
|
28
|
-
const original = await importOriginal<typeof import('@openzeppelin/ui-
|
|
27
|
+
vi.mock('@openzeppelin/ui-utils', async (importOriginal) => {
|
|
28
|
+
const original = await importOriginal<typeof import('@openzeppelin/ui-utils')>(); // Ensure correct type for original
|
|
29
29
|
return {
|
|
30
30
|
...original,
|
|
31
31
|
logger: {
|
|
@@ -4,8 +4,8 @@ import type {
|
|
|
4
4
|
ExecutionMethodDetail,
|
|
5
5
|
MultisigExecutionConfig,
|
|
6
6
|
RelayerExecutionConfig,
|
|
7
|
-
} from '@openzeppelin/ui-
|
|
8
|
-
import { logger } from '@openzeppelin/ui-
|
|
7
|
+
} from '@openzeppelin/ui-types';
|
|
8
|
+
import { logger } from '@openzeppelin/ui-utils';
|
|
9
9
|
|
|
10
10
|
import { validateEoaConfig, validateRelayerConfig } from '../validation';
|
|
11
11
|
import { EvmWalletConnectionStatus } from '../wallet/types';
|
|
@@ -1,9 +1,5 @@
|
|
|
1
|
-
import { NetworkConfig, UserExplorerConfig } from '@openzeppelin/ui-
|
|
2
|
-
import {
|
|
3
|
-
appConfigService,
|
|
4
|
-
logger,
|
|
5
|
-
userNetworkServiceConfigService,
|
|
6
|
-
} from '@openzeppelin/ui-builder-utils';
|
|
1
|
+
import { NetworkConfig, UserExplorerConfig } from '@openzeppelin/ui-types';
|
|
2
|
+
import { appConfigService, logger, userNetworkServiceConfigService } from '@openzeppelin/ui-utils';
|
|
7
3
|
|
|
8
4
|
import { shouldUseV2Api, testEtherscanV2Connection } from '../abi/etherscan-v2';
|
|
9
5
|
import { TypedEvmNetworkConfig } from '../types';
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import type { NetworkServiceForm } from '@openzeppelin/ui-
|
|
2
|
-
import { UserExplorerConfig, UserRpcProviderConfig } from '@openzeppelin/ui-
|
|
3
|
-
import { appConfigService, userNetworkServiceConfigService } from '@openzeppelin/ui-
|
|
1
|
+
import type { NetworkServiceForm } from '@openzeppelin/ui-types';
|
|
2
|
+
import { UserExplorerConfig, UserRpcProviderConfig } from '@openzeppelin/ui-types';
|
|
3
|
+
import { appConfigService, userNetworkServiceConfigService } from '@openzeppelin/ui-utils';
|
|
4
4
|
|
|
5
5
|
import { TypedEvmNetworkConfig } from '../types';
|
|
6
6
|
import { EvmProviderKeys, isEvmProviderKey } from '../types/providers';
|
package/src/configuration/rpc.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import type { EvmNetworkConfig, UserRpcProviderConfig } from '@openzeppelin/ui-
|
|
1
|
+
import type { EvmNetworkConfig, UserRpcProviderConfig } from '@openzeppelin/ui-types';
|
|
2
2
|
import {
|
|
3
3
|
appConfigService,
|
|
4
4
|
isValidUrl,
|
|
5
5
|
logger,
|
|
6
6
|
userNetworkServiceConfigService,
|
|
7
|
-
} from '@openzeppelin/ui-
|
|
7
|
+
} from '@openzeppelin/ui-utils';
|
|
8
8
|
|
|
9
9
|
/**
|
|
10
10
|
* Builds a complete RPC URL from a user RPC provider configuration.
|
package/src/mapping/constants.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { FieldType } from '@openzeppelin/ui-
|
|
1
|
+
import type { FieldType, TypeMappingInfo } from '@openzeppelin/ui-types';
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* EVM-specific type mapping to default form field types.
|
|
@@ -30,3 +30,28 @@ export const EVM_TYPE_TO_FIELD_TYPE: Record<string, FieldType> = {
|
|
|
30
30
|
bytes: 'textarea',
|
|
31
31
|
bytes32: 'text',
|
|
32
32
|
};
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* EVM dynamic type patterns handled through pattern matching.
|
|
36
|
+
*/
|
|
37
|
+
const EVM_DYNAMIC_PATTERNS: TypeMappingInfo['dynamicPatterns'] = [
|
|
38
|
+
{ name: 'array', syntax: 'T[]', mapsTo: 'array', description: 'Dynamic array of primitives' },
|
|
39
|
+
{ name: 'fixed-array', syntax: 'T[N]', mapsTo: 'array', description: 'Fixed-size array' },
|
|
40
|
+
{
|
|
41
|
+
name: 'tuple-array',
|
|
42
|
+
syntax: 'tuple[]',
|
|
43
|
+
mapsTo: 'array-object',
|
|
44
|
+
description: 'Array of structs',
|
|
45
|
+
},
|
|
46
|
+
{ name: 'tuple', syntax: 'tuple', mapsTo: 'object', description: 'Struct/tuple type' },
|
|
47
|
+
];
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* Returns complete type mapping information for EVM.
|
|
51
|
+
*/
|
|
52
|
+
export function getEvmTypeMappingInfo(): TypeMappingInfo {
|
|
53
|
+
return {
|
|
54
|
+
primitives: { ...EVM_TYPE_TO_FIELD_TYPE },
|
|
55
|
+
dynamicPatterns: EVM_DYNAMIC_PATTERNS,
|
|
56
|
+
};
|
|
57
|
+
}
|
|
@@ -6,12 +6,12 @@ import type {
|
|
|
6
6
|
FieldValue,
|
|
7
7
|
FormFieldType,
|
|
8
8
|
FunctionParameter,
|
|
9
|
-
} from '@openzeppelin/ui-
|
|
9
|
+
} from '@openzeppelin/ui-types';
|
|
10
10
|
import {
|
|
11
11
|
enhanceNumericValidation,
|
|
12
12
|
getDefaultValueForType,
|
|
13
13
|
type NumericBoundsMap,
|
|
14
|
-
} from '@openzeppelin/ui-
|
|
14
|
+
} from '@openzeppelin/ui-utils';
|
|
15
15
|
|
|
16
16
|
import { mapEvmParamTypeToFieldType } from './type-mapper';
|
|
17
17
|
|
package/src/proxy/detection.ts
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
*/
|
|
7
7
|
import { createPublicClient, http, keccak256, parseAbi, toHex } from 'viem';
|
|
8
8
|
|
|
9
|
-
import { logger } from '@openzeppelin/ui-
|
|
9
|
+
import { logger } from '@openzeppelin/ui-utils';
|
|
10
10
|
|
|
11
11
|
import { resolveRpcUrl } from '../configuration';
|
|
12
12
|
import { AbiItem, TypedEvmNetworkConfig } from '../types';
|
package/src/query/handler.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { createPublicClient, http, isAddress, type Chain, type PublicClient } from 'viem';
|
|
2
2
|
|
|
3
|
-
import type { ContractSchema, FunctionParameter } from '@openzeppelin/ui-
|
|
4
|
-
import { logger } from '@openzeppelin/ui-
|
|
3
|
+
import type { ContractSchema, FunctionParameter } from '@openzeppelin/ui-types';
|
|
4
|
+
import { logger } from '@openzeppelin/ui-utils';
|
|
5
5
|
|
|
6
6
|
import { createAbiFunctionItem } from '../abi';
|
|
7
7
|
import { getUserRpcUrl, resolveRpcUrl } from '../configuration';
|
|
@@ -9,8 +9,8 @@ import {
|
|
|
9
9
|
AccordionTrigger,
|
|
10
10
|
BooleanField,
|
|
11
11
|
NumberField,
|
|
12
|
-
} from '@openzeppelin/ui-
|
|
13
|
-
import { cn } from '@openzeppelin/ui-
|
|
12
|
+
} from '@openzeppelin/ui-components';
|
|
13
|
+
import { cn } from '@openzeppelin/ui-utils';
|
|
14
14
|
|
|
15
15
|
import { EvmRelayerFormData } from './useEvmRelayerOptions';
|
|
16
16
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
|
|
3
|
-
import { Tabs, TabsContent, TabsList, TabsTrigger } from '@openzeppelin/ui-
|
|
3
|
+
import { Tabs, TabsContent, TabsList, TabsTrigger } from '@openzeppelin/ui-components';
|
|
4
4
|
|
|
5
5
|
import { AdvancedInfo } from './AdvancedInfo';
|
|
6
6
|
import { CustomGasParameters } from './CustomGasParameters';
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
|
|
3
3
|
import { Speed } from '@openzeppelin/relayer-sdk';
|
|
4
|
-
import { RadioGroup, RadioGroupItem } from '@openzeppelin/ui-
|
|
4
|
+
import { RadioGroup, RadioGroupItem } from '@openzeppelin/ui-components';
|
|
5
5
|
|
|
6
6
|
interface SpeedSelectionProps {
|
|
7
7
|
selectedSpeed: Speed | undefined;
|
package/src/transaction/eoa.ts
CHANGED
|
@@ -6,8 +6,8 @@ import {
|
|
|
6
6
|
ExecutionConfig,
|
|
7
7
|
TransactionStatusUpdate,
|
|
8
8
|
TxStatus,
|
|
9
|
-
} from '@openzeppelin/ui-
|
|
10
|
-
import { logger } from '@openzeppelin/ui-
|
|
9
|
+
} from '@openzeppelin/ui-types';
|
|
10
|
+
import { logger } from '@openzeppelin/ui-utils';
|
|
11
11
|
|
|
12
12
|
import { WriteContractParameters } from '../types';
|
|
13
13
|
import { validateEoaConfig } from '../validation';
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ExecutionConfig, TransactionStatusUpdate, TxStatus } from '@openzeppelin/ui-
|
|
1
|
+
import { ExecutionConfig, TransactionStatusUpdate, TxStatus } from '@openzeppelin/ui-types';
|
|
2
2
|
|
|
3
3
|
import { WriteContractParameters } from '../types';
|
|
4
4
|
import { WagmiWalletImplementation } from '../wallet/implementation/wagmi-implementation';
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { isAddress } from 'viem';
|
|
2
2
|
|
|
3
|
-
import type { ContractSchema, FormFieldType } from '@openzeppelin/ui-
|
|
4
|
-
import { logger } from '@openzeppelin/ui-
|
|
3
|
+
import type { ContractSchema, FormFieldType } from '@openzeppelin/ui-types';
|
|
4
|
+
import { logger } from '@openzeppelin/ui-utils';
|
|
5
5
|
|
|
6
6
|
import { createAbiFunctionItem } from '../abi';
|
|
7
7
|
import { parseEvmInput } from '../transform';
|
|
@@ -16,8 +16,8 @@ import {
|
|
|
16
16
|
RelayerExecutionConfig,
|
|
17
17
|
TransactionStatusUpdate,
|
|
18
18
|
TxStatus,
|
|
19
|
-
} from '@openzeppelin/ui-
|
|
20
|
-
import { logger } from '@openzeppelin/ui-
|
|
19
|
+
} from '@openzeppelin/ui-types';
|
|
20
|
+
import { logger } from '@openzeppelin/ui-utils';
|
|
21
21
|
|
|
22
22
|
import { TypedEvmNetworkConfig, WriteContractParameters } from '../types';
|
|
23
23
|
import { WagmiWalletImplementation } from '../wallet/implementation/wagmi-implementation';
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import type { GetAccountReturnType } from '@wagmi/core';
|
|
2
2
|
import type { TransactionReceipt, WalletClient } from 'viem';
|
|
3
3
|
|
|
4
|
-
import type { ExecutionConfig } from '@openzeppelin/ui-
|
|
5
|
-
import { logger } from '@openzeppelin/ui-
|
|
4
|
+
import type { ExecutionConfig } from '@openzeppelin/ui-types';
|
|
5
|
+
import { logger } from '@openzeppelin/ui-utils';
|
|
6
6
|
|
|
7
7
|
import type { WriteContractParameters } from '../types';
|
|
8
8
|
import type { WagmiWalletImplementation } from '../wallet/implementation/wagmi-implementation';
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { getAddress, isAddress } from 'viem';
|
|
2
2
|
|
|
3
|
-
import type { FunctionParameter } from '@openzeppelin/ui-
|
|
4
|
-
import { logger } from '@openzeppelin/ui-
|
|
3
|
+
import type { FunctionParameter } from '@openzeppelin/ui-types';
|
|
4
|
+
import { logger } from '@openzeppelin/ui-utils';
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
7
|
* Recursively parses a raw input value based on its expected ABI type definition.
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { ContractFunction } from '@openzeppelin/ui-
|
|
2
|
-
import { logger } from '@openzeppelin/ui-
|
|
1
|
+
import type { ContractFunction } from '@openzeppelin/ui-types';
|
|
2
|
+
import { logger } from '@openzeppelin/ui-utils';
|
|
3
3
|
|
|
4
4
|
import { stringifyWithBigInt } from '../utils';
|
|
5
5
|
|
package/src/types.ts
CHANGED
package/src/validation/eoa.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { EoaExecutionConfig } from '@openzeppelin/ui-
|
|
2
|
-
import { logger } from '@openzeppelin/ui-
|
|
1
|
+
import { EoaExecutionConfig } from '@openzeppelin/ui-types';
|
|
2
|
+
import { logger } from '@openzeppelin/ui-utils';
|
|
3
3
|
|
|
4
4
|
import { isValidEvmAddress } from '../utils';
|
|
5
5
|
import { EvmWalletConnectionStatus } from '../wallet/types';
|
package/src/wallet/README.md
CHANGED
|
@@ -13,7 +13,7 @@ This architecture allows applications to switch between different wallet UIs (li
|
|
|
13
13
|
## Purpose
|
|
14
14
|
|
|
15
15
|
- **UI Environment Provision**: Sets up a stable UI environment for EVM wallet interactions. The adapter exports `EvmWalletUiRoot`, a React component that internally uses a singleton `EvmUiKitManager` to manage the `WagmiConfig`, UI kit assets (like RainbowKit's provider and CSS), and overall state. This root component ensures `WagmiProvider` and `QueryClientProvider` are always rendered, aiming to prevent UI flicker during network or configuration changes.
|
|
16
|
-
- **Facade Hooks**: Exposes a standardized set of React hooks (`evmFacadeHooks`) for wallet, account, and network management, wrapping `wagmi` core hooks. These are primarily consumed via `useWalletState()` from `@openzeppelin/ui-
|
|
16
|
+
- **Facade Hooks**: Exposes a standardized set of React hooks (`evmFacadeHooks`) for wallet, account, and network management, wrapping `wagmi` core hooks. These are primarily consumed via `useWalletState()` from `@openzeppelin/ui-react`.
|
|
17
17
|
- **UI Kit Integration**: Supports third-party UI kits like RainbowKit, as well as a default set of custom-styled wallet UI components (`CustomConnectButton`, `CustomAccountDisplay`, `CustomNetworkSwitcher`).
|
|
18
18
|
- **Configuration**: Provides a flexible, layered configuration system allowing applications to define UI kit preferences and kit-specific parameters through global application configuration (`AppConfigService`), user-authored native TypeScript configuration files, and programmatic overrides.
|
|
19
19
|
|
|
@@ -172,7 +172,7 @@ The consuming application (via the `loadConfigModule` prop on `WalletStateProvid
|
|
|
172
172
|
**Example from `packages/builder/src/App.tsx` or exported app's `main.tsx`:**
|
|
173
173
|
|
|
174
174
|
```typescript
|
|
175
|
-
import { logger } from '@openzeppelin/ui-
|
|
175
|
+
import { logger } from '@openzeppelin/ui-utils';
|
|
176
176
|
|
|
177
177
|
const loadAppConfigModule = async (
|
|
178
178
|
relativePath: string
|
|
@@ -209,7 +209,7 @@ When `kitName` is configured to `'rainbowkit'`, the `EvmAdapter` (via `EvmUiKitM
|
|
|
209
209
|
|
|
210
210
|
## Usage within Application
|
|
211
211
|
|
|
212
|
-
The primary way to interact with wallet functionalities and UI components is through `@openzeppelin/ui-
|
|
212
|
+
The primary way to interact with wallet functionalities and UI components is through `@openzeppelin/ui-react`:
|
|
213
213
|
|
|
214
214
|
- **`WalletStateProvider`**: Wraps the application (or relevant parts) to provide wallet context.
|
|
215
215
|
- **`useWalletState()`**: Hook to access `activeAdapter`, `activeNetworkConfig`, `walletFacadeHooks`, `isAdapterLoading`, etc.
|
|
@@ -221,7 +221,7 @@ The primary way to interact with wallet functionalities and UI components is thr
|
|
|
221
221
|
import {
|
|
222
222
|
useWalletState,
|
|
223
223
|
useDerivedAccountStatus,
|
|
224
|
-
} from '@openzeppelin/ui-
|
|
224
|
+
} from '@openzeppelin/ui-react';
|
|
225
225
|
|
|
226
226
|
function WalletConnectionHeader() {
|
|
227
227
|
const { activeAdapter, isAdapterLoading } = useWalletState();
|