@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
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@openzeppelin/ui-builder-adapter-evm",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.4.0",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "EVM Adapter for UI Builder",
|
|
6
6
|
"keywords": [
|
|
@@ -37,16 +37,17 @@
|
|
|
37
37
|
},
|
|
38
38
|
"dependencies": {
|
|
39
39
|
"@openzeppelin/relayer-sdk": "1.4.0",
|
|
40
|
-
"@openzeppelin/ui-components": "^1.0
|
|
41
|
-
"@openzeppelin/ui-react": "^1.
|
|
42
|
-
"@openzeppelin/ui-types": "^1.
|
|
43
|
-
"@openzeppelin/ui-utils": "^1.
|
|
40
|
+
"@openzeppelin/ui-components": "^1.2.0",
|
|
41
|
+
"@openzeppelin/ui-react": "^1.1.0",
|
|
42
|
+
"@openzeppelin/ui-types": "^1.5.0",
|
|
43
|
+
"@openzeppelin/ui-utils": "^1.2.0",
|
|
44
44
|
"@wagmi/connectors": "5.7.13",
|
|
45
45
|
"@wagmi/core": "^2.20.3",
|
|
46
46
|
"@web3icons/react": "^4.0.19",
|
|
47
47
|
"lodash": "^4.17.21",
|
|
48
48
|
"lucide-react": "^0.510.0",
|
|
49
|
-
"react-hook-form": "^7.62.0"
|
|
49
|
+
"react-hook-form": "^7.62.0",
|
|
50
|
+
"@openzeppelin/ui-builder-adapter-evm-core": "1.0.0"
|
|
50
51
|
},
|
|
51
52
|
"devDependencies": {
|
|
52
53
|
"@rainbow-me/rainbowkit": "^2.2.8",
|
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
import { beforeEach, describe, expect, it } from 'vitest';
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
import {
|
|
4
|
+
EVM_TYPE_TO_FIELD_TYPE,
|
|
5
|
+
parseEvmInput as parseEvmInputFunction,
|
|
6
|
+
} from '@openzeppelin/ui-builder-adapter-evm-core';
|
|
4
7
|
import type { ContractFunction, FunctionParameter } from '@openzeppelin/ui-types';
|
|
5
8
|
|
|
6
9
|
import { mockEvmNetworkConfig } from './mocks/mock-network-configs';
|
|
7
10
|
|
|
8
11
|
import { EvmAdapter } from '../adapter';
|
|
9
|
-
import { EVM_TYPE_TO_FIELD_TYPE } from '../mapping';
|
|
10
|
-
import { parseEvmInput as parseEvmInputFunction } from '../transform';
|
|
11
12
|
|
|
12
13
|
// Mock FunctionParameter type helper
|
|
13
14
|
const createParam = (
|
|
@@ -0,0 +1,185 @@
|
|
|
1
|
+
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';
|
|
2
|
+
|
|
3
|
+
import type { TypedEvmNetworkConfig } from '@openzeppelin/ui-builder-adapter-evm-core';
|
|
4
|
+
import type { EvmNetworkConfig } from '@openzeppelin/ui-types';
|
|
5
|
+
import { appConfigService } from '@openzeppelin/ui-utils';
|
|
6
|
+
|
|
7
|
+
import { getEvmDefaultServiceConfig } from '../configuration/network-services';
|
|
8
|
+
|
|
9
|
+
describe('getEvmDefaultServiceConfig', () => {
|
|
10
|
+
const createMockNetworkConfig = (
|
|
11
|
+
overrides: Partial<TypedEvmNetworkConfig> = {}
|
|
12
|
+
): EvmNetworkConfig => ({
|
|
13
|
+
id: 'ethereum',
|
|
14
|
+
exportConstName: 'ethereum',
|
|
15
|
+
name: 'Ethereum',
|
|
16
|
+
ecosystem: 'evm',
|
|
17
|
+
network: 'mainnet',
|
|
18
|
+
type: 'mainnet',
|
|
19
|
+
isTestnet: false,
|
|
20
|
+
chainId: 1,
|
|
21
|
+
rpcUrl: 'https://eth.llamarpc.com',
|
|
22
|
+
explorerUrl: 'https://etherscan.io',
|
|
23
|
+
apiUrl: 'https://api.etherscan.io/api',
|
|
24
|
+
nativeCurrency: {
|
|
25
|
+
name: 'Ether',
|
|
26
|
+
symbol: 'ETH',
|
|
27
|
+
decimals: 18,
|
|
28
|
+
},
|
|
29
|
+
...overrides,
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
beforeEach(() => {
|
|
33
|
+
vi.spyOn(appConfigService, 'getGlobalServiceConfig').mockReturnValue(undefined);
|
|
34
|
+
vi.spyOn(appConfigService, 'getExplorerApiKey').mockReturnValue(undefined);
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
afterEach(() => {
|
|
38
|
+
vi.restoreAllMocks();
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
describe('rpc service', () => {
|
|
42
|
+
it('should return RPC config when rpcUrl is present', () => {
|
|
43
|
+
const networkConfig = createMockNetworkConfig();
|
|
44
|
+
|
|
45
|
+
const result = getEvmDefaultServiceConfig(networkConfig, 'rpc');
|
|
46
|
+
|
|
47
|
+
expect(result).toEqual({
|
|
48
|
+
rpcUrl: 'https://eth.llamarpc.com',
|
|
49
|
+
});
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
it('should return null when rpcUrl is missing', () => {
|
|
53
|
+
const networkConfig = createMockNetworkConfig({
|
|
54
|
+
rpcUrl: undefined,
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
const result = getEvmDefaultServiceConfig(networkConfig, 'rpc');
|
|
58
|
+
|
|
59
|
+
expect(result).toBeNull();
|
|
60
|
+
});
|
|
61
|
+
});
|
|
62
|
+
|
|
63
|
+
describe('explorer service', () => {
|
|
64
|
+
it('should return explorer config with explorerUrl and apiUrl when present', () => {
|
|
65
|
+
const networkConfig = createMockNetworkConfig();
|
|
66
|
+
|
|
67
|
+
const result = getEvmDefaultServiceConfig(networkConfig, 'explorer');
|
|
68
|
+
|
|
69
|
+
expect(result).toEqual({
|
|
70
|
+
explorerUrl: 'https://etherscan.io',
|
|
71
|
+
apiUrl: 'https://api.etherscan.io/api',
|
|
72
|
+
});
|
|
73
|
+
});
|
|
74
|
+
|
|
75
|
+
it('should include global V2 API key for V2-compatible networks', () => {
|
|
76
|
+
vi.spyOn(appConfigService, 'getGlobalServiceConfig').mockReturnValue({
|
|
77
|
+
apiKey: 'test-v2-api-key',
|
|
78
|
+
});
|
|
79
|
+
|
|
80
|
+
const networkConfig = createMockNetworkConfig({
|
|
81
|
+
supportsEtherscanV2: true,
|
|
82
|
+
primaryExplorerApiIdentifier: 'etherscan-v2',
|
|
83
|
+
});
|
|
84
|
+
|
|
85
|
+
const result = getEvmDefaultServiceConfig(networkConfig, 'explorer');
|
|
86
|
+
|
|
87
|
+
expect(result).toEqual({
|
|
88
|
+
explorerUrl: 'https://etherscan.io',
|
|
89
|
+
apiUrl: 'https://api.etherscan.io/api',
|
|
90
|
+
apiKey: 'test-v2-api-key',
|
|
91
|
+
});
|
|
92
|
+
expect(appConfigService.getGlobalServiceConfig).toHaveBeenCalledWith('etherscanv2');
|
|
93
|
+
});
|
|
94
|
+
|
|
95
|
+
it('should include app API key from globalServiceConfigs for non-V2 networks', () => {
|
|
96
|
+
vi.spyOn(appConfigService, 'getGlobalServiceConfig').mockReturnValue({
|
|
97
|
+
apiKey: 'test-routescan-key',
|
|
98
|
+
});
|
|
99
|
+
|
|
100
|
+
const networkConfig = createMockNetworkConfig({
|
|
101
|
+
supportsEtherscanV2: false,
|
|
102
|
+
primaryExplorerApiIdentifier: 'routescan',
|
|
103
|
+
});
|
|
104
|
+
|
|
105
|
+
const result = getEvmDefaultServiceConfig(networkConfig, 'explorer');
|
|
106
|
+
|
|
107
|
+
expect(result).toEqual({
|
|
108
|
+
explorerUrl: 'https://etherscan.io',
|
|
109
|
+
apiUrl: 'https://api.etherscan.io/api',
|
|
110
|
+
apiKey: 'test-routescan-key',
|
|
111
|
+
});
|
|
112
|
+
expect(appConfigService.getGlobalServiceConfig).toHaveBeenCalledWith('routescan');
|
|
113
|
+
});
|
|
114
|
+
|
|
115
|
+
it('should fallback to getExplorerApiKey when globalServiceConfig has no apiKey', () => {
|
|
116
|
+
vi.spyOn(appConfigService, 'getGlobalServiceConfig').mockReturnValue(undefined);
|
|
117
|
+
vi.spyOn(appConfigService, 'getExplorerApiKey').mockReturnValue('fallback-api-key');
|
|
118
|
+
|
|
119
|
+
const networkConfig = createMockNetworkConfig({
|
|
120
|
+
supportsEtherscanV2: false,
|
|
121
|
+
primaryExplorerApiIdentifier: 'blockscout',
|
|
122
|
+
});
|
|
123
|
+
|
|
124
|
+
const result = getEvmDefaultServiceConfig(networkConfig, 'explorer');
|
|
125
|
+
|
|
126
|
+
expect(result).toEqual({
|
|
127
|
+
explorerUrl: 'https://etherscan.io',
|
|
128
|
+
apiUrl: 'https://api.etherscan.io/api',
|
|
129
|
+
apiKey: 'fallback-api-key',
|
|
130
|
+
});
|
|
131
|
+
expect(appConfigService.getExplorerApiKey).toHaveBeenCalledWith('blockscout');
|
|
132
|
+
});
|
|
133
|
+
|
|
134
|
+
it('should return null when explorerUrl is missing and no API key configured', () => {
|
|
135
|
+
const networkConfig = createMockNetworkConfig({
|
|
136
|
+
explorerUrl: undefined,
|
|
137
|
+
apiUrl: undefined,
|
|
138
|
+
});
|
|
139
|
+
|
|
140
|
+
const result = getEvmDefaultServiceConfig(networkConfig, 'explorer');
|
|
141
|
+
|
|
142
|
+
expect(result).toBeNull();
|
|
143
|
+
});
|
|
144
|
+
|
|
145
|
+
it('should return config with API key when explorerUrl is missing but API key is available', () => {
|
|
146
|
+
vi.spyOn(appConfigService, 'getGlobalServiceConfig').mockReturnValue({
|
|
147
|
+
apiKey: 'test-api-key-only',
|
|
148
|
+
});
|
|
149
|
+
|
|
150
|
+
const networkConfig = createMockNetworkConfig({
|
|
151
|
+
explorerUrl: undefined,
|
|
152
|
+
apiUrl: undefined,
|
|
153
|
+
supportsEtherscanV2: true,
|
|
154
|
+
primaryExplorerApiIdentifier: 'etherscan-v2',
|
|
155
|
+
});
|
|
156
|
+
|
|
157
|
+
const result = getEvmDefaultServiceConfig(networkConfig, 'explorer');
|
|
158
|
+
|
|
159
|
+
expect(result).toEqual({
|
|
160
|
+
explorerUrl: undefined,
|
|
161
|
+
apiUrl: undefined,
|
|
162
|
+
apiKey: 'test-api-key-only',
|
|
163
|
+
});
|
|
164
|
+
});
|
|
165
|
+
});
|
|
166
|
+
|
|
167
|
+
describe('contract-definitions service', () => {
|
|
168
|
+
it('should return null for contract-definitions service', () => {
|
|
169
|
+
const networkConfig = createMockNetworkConfig();
|
|
170
|
+
|
|
171
|
+
const result = getEvmDefaultServiceConfig(networkConfig, 'contract-definitions');
|
|
172
|
+
|
|
173
|
+
expect(result).toBeNull();
|
|
174
|
+
});
|
|
175
|
+
});
|
|
176
|
+
|
|
177
|
+
describe('unknown service', () => {
|
|
178
|
+
it('should return null for unknown service IDs', () => {
|
|
179
|
+
const networkConfig = createMockNetworkConfig();
|
|
180
|
+
|
|
181
|
+
expect(getEvmDefaultServiceConfig(networkConfig, 'indexer')).toBeNull();
|
|
182
|
+
expect(getEvmDefaultServiceConfig(networkConfig, 'unknown')).toBeNull();
|
|
183
|
+
});
|
|
184
|
+
});
|
|
185
|
+
});
|
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import { describe, expect, it, vi } from 'vitest';
|
|
2
2
|
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
3
|
+
import {
|
|
4
|
+
getEvmExplorerAddressUrl,
|
|
5
|
+
loadEvmContract,
|
|
6
|
+
type EvmContractArtifacts,
|
|
7
|
+
type TypedEvmNetworkConfig,
|
|
8
|
+
} from '@openzeppelin/ui-builder-adapter-evm-core';
|
|
7
9
|
|
|
8
10
|
describe('EVM provenance links', () => {
|
|
9
11
|
it('builds address URL from explorer config', () => {
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';
|
|
2
2
|
|
|
3
|
+
import {
|
|
4
|
+
loadEvmContract,
|
|
5
|
+
type EvmContractArtifacts,
|
|
6
|
+
type TypedEvmNetworkConfig,
|
|
7
|
+
} from '@openzeppelin/ui-builder-adapter-evm-core';
|
|
3
8
|
import { appConfigService, userNetworkServiceConfigService } from '@openzeppelin/ui-utils';
|
|
4
9
|
|
|
5
|
-
import { loadEvmContract } from '../abi/loader';
|
|
6
|
-
import type { TypedEvmNetworkConfig } from '../types';
|
|
7
|
-
import type { EvmContractArtifacts } from '../types/artifacts';
|
|
8
|
-
|
|
9
10
|
describe('EVM provider selection (etherscan → sourcify, forced/app/ui precedence)', () => {
|
|
10
11
|
const mockFetch = vi.fn();
|
|
11
12
|
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import { describe, expect, it, vi } from 'vitest';
|
|
2
2
|
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
|
|
3
|
+
import {
|
|
4
|
+
loadEvmContract,
|
|
5
|
+
type EvmContractArtifacts,
|
|
6
|
+
type TypedEvmNetworkConfig,
|
|
7
|
+
} from '@openzeppelin/ui-builder-adapter-evm-core';
|
|
6
8
|
|
|
7
9
|
describe('EVM provider timeouts', () => {
|
|
8
10
|
it('moves to next provider when the first provider exceeds per-provider timeout', async () => {
|
|
@@ -8,7 +8,7 @@ import { mockEvmNetworkConfig } from './mocks/mock-network-configs';
|
|
|
8
8
|
|
|
9
9
|
import { EvmAdapter } from '../adapter';
|
|
10
10
|
|
|
11
|
-
// Mock the
|
|
11
|
+
// Mock the createEvmWalletImplementation factory to isolate EvmAdapter logic
|
|
12
12
|
vi.mock('../wallet/implementation/wagmi-implementation', () => {
|
|
13
13
|
// --- Mock implementations for WagmiWalletImplementation methods ---
|
|
14
14
|
const mockGetAvailableConnectors = vi.fn().mockResolvedValue([
|
|
@@ -50,7 +50,7 @@ vi.mock('../wallet/implementation/wagmi-implementation', () => {
|
|
|
50
50
|
// --- End Mock Implementations ---
|
|
51
51
|
|
|
52
52
|
return {
|
|
53
|
-
|
|
53
|
+
createEvmWalletImplementation: vi.fn().mockImplementation(() => ({
|
|
54
54
|
// Expose mocks
|
|
55
55
|
getAvailableConnectors: mockGetAvailableConnectors,
|
|
56
56
|
connect: mockConnect,
|
package/src/adapter.ts
CHANGED
|
@@ -1,6 +1,42 @@
|
|
|
1
1
|
import { type TransactionReceipt } from 'viem';
|
|
2
2
|
import React from 'react';
|
|
3
3
|
|
|
4
|
+
// Core module imports - reusable EVM logic
|
|
5
|
+
import {
|
|
6
|
+
compareContractDefinitions as coreCompareContractDefinitions,
|
|
7
|
+
hashContractDefinition as coreHashContractDefinition,
|
|
8
|
+
validateContractDefinition as coreValidateContractDefinition,
|
|
9
|
+
EvmProviderKeys,
|
|
10
|
+
executeEvmTransaction,
|
|
11
|
+
formatEvmFunctionResult,
|
|
12
|
+
formatEvmTransactionData,
|
|
13
|
+
generateEvmDefaultField,
|
|
14
|
+
generateRainbowKitConfigFile,
|
|
15
|
+
generateRainbowKitExportables,
|
|
16
|
+
getEvmCompatibleFieldTypes,
|
|
17
|
+
getEvmCurrentBlock,
|
|
18
|
+
getEvmExplorerAddressUrl,
|
|
19
|
+
getEvmExplorerTxUrl,
|
|
20
|
+
getEvmTypeMappingInfo,
|
|
21
|
+
isEvmViewFunction,
|
|
22
|
+
isValidEvmAddress,
|
|
23
|
+
loadContractSchema,
|
|
24
|
+
loadContractWithFullMetadata,
|
|
25
|
+
mapEvmParamTypeToFieldType,
|
|
26
|
+
RelayerExecutionStrategy,
|
|
27
|
+
resolveFullUiKitConfiguration,
|
|
28
|
+
testEvmExplorerConnection,
|
|
29
|
+
testEvmNetworkServiceConnection,
|
|
30
|
+
testEvmRpcConnection,
|
|
31
|
+
validateEvmExecutionConfig,
|
|
32
|
+
validateEvmExplorerConfig,
|
|
33
|
+
validateEvmNetworkServiceConfig,
|
|
34
|
+
validateEvmRpcEndpoint,
|
|
35
|
+
waitForEvmTransactionConfirmation,
|
|
36
|
+
type EvmContractDefinitionProviderKey,
|
|
37
|
+
type TypedEvmNetworkConfig,
|
|
38
|
+
type WriteContractParameters,
|
|
39
|
+
} from '@openzeppelin/ui-builder-adapter-evm-core';
|
|
4
40
|
import type {
|
|
5
41
|
AvailableUiKit,
|
|
6
42
|
Connector,
|
|
@@ -31,52 +67,20 @@ import type {
|
|
|
31
67
|
} from '@openzeppelin/ui-types';
|
|
32
68
|
import { logger } from '@openzeppelin/ui-utils';
|
|
33
69
|
|
|
34
|
-
import { abiComparisonService } from './abi/comparison';
|
|
35
|
-
import {
|
|
36
|
-
getEvmNetworkServiceForms,
|
|
37
|
-
testEvmNetworkServiceConnection,
|
|
38
|
-
validateEvmNetworkServiceConfig,
|
|
39
|
-
} from './configuration/network-services';
|
|
40
|
-
import { EvmProviderKeys, type EvmContractDefinitionProviderKey } from './types/providers';
|
|
41
70
|
import { EvmWalletUiRoot } from './wallet/components/EvmWalletUiRoot';
|
|
42
71
|
import { evmUiKitManager } from './wallet/evmUiKitManager';
|
|
43
72
|
import { evmFacadeHooks } from './wallet/hooks/facade-hooks';
|
|
44
73
|
import { loadInitialConfigFromAppService } from './wallet/hooks/useUiKitConfig';
|
|
45
|
-
import { generateRainbowKitConfigFile } from './wallet/rainbowkit/config-generator';
|
|
46
|
-
import { generateRainbowKitExportables } from './wallet/rainbowkit/export-service';
|
|
47
|
-
import { resolveFullUiKitConfiguration } from './wallet/services/configResolutionService';
|
|
48
74
|
|
|
49
|
-
|
|
75
|
+
// Adapter-specific imports - EVM adapter orchestration
|
|
50
76
|
import {
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
getEvmExplorerTxUrl,
|
|
77
|
+
getEvmDefaultServiceConfig,
|
|
78
|
+
getEvmNetworkServiceForms,
|
|
54
79
|
getEvmSupportedExecutionMethods,
|
|
55
|
-
testEvmExplorerConnection,
|
|
56
|
-
testEvmRpcConnection,
|
|
57
|
-
validateEvmExecutionConfig,
|
|
58
|
-
validateEvmExplorerConfig,
|
|
59
|
-
validateEvmRpcEndpoint,
|
|
60
80
|
} from './configuration';
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
getEvmTypeMappingInfo,
|
|
65
|
-
mapEvmParamTypeToFieldType,
|
|
66
|
-
} from './mapping';
|
|
67
|
-
import { isEvmViewFunction, queryEvmViewFunction } from './query';
|
|
68
|
-
import {
|
|
69
|
-
EoaExecutionStrategy,
|
|
70
|
-
EvmRelayerOptions,
|
|
71
|
-
ExecutionStrategy,
|
|
72
|
-
formatEvmTransactionData,
|
|
73
|
-
RelayerExecutionStrategy,
|
|
74
|
-
waitForEvmTransactionConfirmation,
|
|
75
|
-
} from './transaction';
|
|
76
|
-
import { formatEvmFunctionResult } from './transform';
|
|
77
|
-
import { TypedEvmNetworkConfig } from './types';
|
|
78
|
-
import type { WriteContractParameters } from './types';
|
|
79
|
-
import { isValidEvmAddress, validateAndConvertEvmArtifacts } from './utils';
|
|
81
|
+
// Adapter-specific query with RPC resolution
|
|
82
|
+
import { queryEvmViewFunction } from './query';
|
|
83
|
+
import { EvmRelayerOptions } from './transaction';
|
|
80
84
|
import {
|
|
81
85
|
connectAndEnsureCorrectNetwork,
|
|
82
86
|
convertWagmiToEvmStatus,
|
|
@@ -160,14 +164,18 @@ export class EvmAdapter implements ContractAdapter {
|
|
|
160
164
|
return testEvmNetworkServiceConnection(serviceId, values, this.networkConfig);
|
|
161
165
|
}
|
|
162
166
|
|
|
167
|
+
/**
|
|
168
|
+
* @inheritdoc
|
|
169
|
+
*/
|
|
170
|
+
public getDefaultServiceConfig(serviceId: string): Record<string, unknown> | null {
|
|
171
|
+
return getEvmDefaultServiceConfig(this.networkConfig, serviceId);
|
|
172
|
+
}
|
|
173
|
+
|
|
163
174
|
/**
|
|
164
175
|
* @inheritdoc
|
|
165
176
|
*/
|
|
166
177
|
public async loadContract(source: string | Record<string, unknown>): Promise<ContractSchema> {
|
|
167
|
-
|
|
168
|
-
const artifacts = validateAndConvertEvmArtifacts(source);
|
|
169
|
-
const result = await loadEvmContract(artifacts, this.networkConfig);
|
|
170
|
-
return result.schema;
|
|
178
|
+
return loadContractSchema(source, this.networkConfig);
|
|
171
179
|
}
|
|
172
180
|
|
|
173
181
|
/**
|
|
@@ -186,30 +194,9 @@ export class EvmAdapter implements ContractAdapter {
|
|
|
186
194
|
};
|
|
187
195
|
proxyInfo?: ProxyInfo;
|
|
188
196
|
}> {
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
const result = await loadEvmContract(artifacts, this.networkConfig);
|
|
193
|
-
|
|
194
|
-
return {
|
|
195
|
-
schema: result.schema,
|
|
196
|
-
source: result.source,
|
|
197
|
-
contractDefinitionOriginal: result.contractDefinitionOriginal,
|
|
198
|
-
metadata: result.metadata,
|
|
199
|
-
proxyInfo: result.proxyInfo,
|
|
200
|
-
};
|
|
201
|
-
} catch (error) {
|
|
202
|
-
// Check if this is an unverified contract error
|
|
203
|
-
const errorMessage = (error as Error).message || '';
|
|
204
|
-
if (errorMessage.includes('not verified on the block explorer')) {
|
|
205
|
-
// For unverified contracts, we still need to throw but include metadata
|
|
206
|
-
// The UI will handle this error and can extract verification status from the message
|
|
207
|
-
throw error;
|
|
208
|
-
}
|
|
209
|
-
|
|
210
|
-
// Re-throw other errors
|
|
211
|
-
throw error;
|
|
212
|
-
}
|
|
197
|
+
// Delegate to core convenience function
|
|
198
|
+
// Errors (including unverified contract errors) are handled by the core function
|
|
199
|
+
return loadContractWithFullMetadata(source, this.networkConfig);
|
|
213
200
|
}
|
|
214
201
|
|
|
215
202
|
/**
|
|
@@ -257,19 +244,7 @@ export class EvmAdapter implements ContractAdapter {
|
|
|
257
244
|
runtimeApiKey?: string
|
|
258
245
|
): Promise<{ txHash: string }> {
|
|
259
246
|
const walletImplementation = await getEvmWalletImplementation();
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
switch (executionConfig.method) {
|
|
263
|
-
case 'relayer':
|
|
264
|
-
strategy = new RelayerExecutionStrategy();
|
|
265
|
-
break;
|
|
266
|
-
case 'eoa':
|
|
267
|
-
default:
|
|
268
|
-
strategy = new EoaExecutionStrategy();
|
|
269
|
-
break;
|
|
270
|
-
}
|
|
271
|
-
|
|
272
|
-
return strategy.execute(
|
|
247
|
+
return executeEvmTransaction(
|
|
273
248
|
transactionData as WriteContractParameters,
|
|
274
249
|
executionConfig,
|
|
275
250
|
walletImplementation,
|
|
@@ -388,7 +363,7 @@ export class EvmAdapter implements ContractAdapter {
|
|
|
388
363
|
params,
|
|
389
364
|
contractSchema,
|
|
390
365
|
walletImplementation,
|
|
391
|
-
(src) => this.loadContract({ contractAddress: src })
|
|
366
|
+
(src: string) => this.loadContract({ contractAddress: src })
|
|
392
367
|
);
|
|
393
368
|
}
|
|
394
369
|
|
|
@@ -741,26 +716,8 @@ Get your WalletConnect projectId from <a href="https://cloud.walletconnect.com"
|
|
|
741
716
|
severity: 'none' | 'minor' | 'major' | 'breaking';
|
|
742
717
|
summary: string;
|
|
743
718
|
}> {
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
return {
|
|
747
|
-
identical: result.identical,
|
|
748
|
-
differences: result.differences.map((diff) => ({
|
|
749
|
-
type: diff.type,
|
|
750
|
-
section: diff.section,
|
|
751
|
-
name: diff.name,
|
|
752
|
-
details: diff.details,
|
|
753
|
-
impact: diff.impact,
|
|
754
|
-
oldSignature: diff.oldSignature,
|
|
755
|
-
newSignature: diff.newSignature,
|
|
756
|
-
})),
|
|
757
|
-
severity: result.severity,
|
|
758
|
-
summary: result.summary,
|
|
759
|
-
};
|
|
760
|
-
} catch (error) {
|
|
761
|
-
logger.error('EVM contract definition comparison failed:', (error as Error).message);
|
|
762
|
-
throw new Error(`Contract definition comparison failed: ${(error as Error).message}`);
|
|
763
|
-
}
|
|
719
|
+
// Delegate to core convenience function
|
|
720
|
+
return coreCompareContractDefinitions(storedSchema, freshSchema);
|
|
764
721
|
}
|
|
765
722
|
|
|
766
723
|
/**
|
|
@@ -771,19 +728,16 @@ Get your WalletConnect projectId from <a href="https://cloud.walletconnect.com"
|
|
|
771
728
|
errors: string[];
|
|
772
729
|
warnings: string[];
|
|
773
730
|
} {
|
|
774
|
-
|
|
775
|
-
return
|
|
776
|
-
valid: result.valid,
|
|
777
|
-
errors: result.errors,
|
|
778
|
-
warnings: result.warnings,
|
|
779
|
-
};
|
|
731
|
+
// Delegate to core convenience function
|
|
732
|
+
return coreValidateContractDefinition(definition);
|
|
780
733
|
}
|
|
781
734
|
|
|
782
735
|
/**
|
|
783
736
|
* @inheritdoc
|
|
784
737
|
*/
|
|
785
738
|
public hashContractDefinition(definition: string): string {
|
|
786
|
-
|
|
739
|
+
// Delegate to core convenience function
|
|
740
|
+
return coreHashContractDefinition(definition);
|
|
787
741
|
}
|
|
788
742
|
|
|
789
743
|
/**
|
|
@@ -1,17 +1,6 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
EoaExecutionConfig,
|
|
3
|
-
ExecutionConfig,
|
|
4
|
-
ExecutionMethodDetail,
|
|
5
|
-
MultisigExecutionConfig,
|
|
6
|
-
RelayerExecutionConfig,
|
|
7
|
-
} from '@openzeppelin/ui-types';
|
|
1
|
+
import type { ExecutionMethodDetail } from '@openzeppelin/ui-types';
|
|
8
2
|
import { logger } from '@openzeppelin/ui-utils';
|
|
9
3
|
|
|
10
|
-
import { validateEoaConfig, validateRelayerConfig } from '../validation';
|
|
11
|
-
import { EvmWalletConnectionStatus } from '../wallet/types';
|
|
12
|
-
|
|
13
|
-
const SYSTEM_LOG_TAG = 'adapter-evm-execution-config';
|
|
14
|
-
|
|
15
4
|
/**
|
|
16
5
|
* Returns details for execution methods supported by the EVM adapter.
|
|
17
6
|
*/
|
|
@@ -41,43 +30,3 @@ export async function getEvmSupportedExecutionMethods(): Promise<ExecutionMethod
|
|
|
41
30
|
},
|
|
42
31
|
]);
|
|
43
32
|
}
|
|
44
|
-
|
|
45
|
-
/**
|
|
46
|
-
* Validates Multisig execution configuration (placeholder).
|
|
47
|
-
*/
|
|
48
|
-
async function _validateMultisigConfig(
|
|
49
|
-
_config: MultisigExecutionConfig,
|
|
50
|
-
_walletStatus: EvmWalletConnectionStatus
|
|
51
|
-
): Promise<true | string> {
|
|
52
|
-
logger.info(SYSTEM_LOG_TAG, 'Multisig execution config validation: Not yet fully implemented.');
|
|
53
|
-
// TODO: Add validation for Safe address, required signers, etc.
|
|
54
|
-
return true; // Placeholder
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
/**
|
|
58
|
-
* Validates the complete execution configuration object against the
|
|
59
|
-
* requirements and capabilities of the EVM adapter.
|
|
60
|
-
*/
|
|
61
|
-
export async function validateEvmExecutionConfig(
|
|
62
|
-
config: ExecutionConfig,
|
|
63
|
-
walletStatus: EvmWalletConnectionStatus
|
|
64
|
-
): Promise<true | string> {
|
|
65
|
-
logger.info(SYSTEM_LOG_TAG, 'Validating EVM execution config:', { config, walletStatus });
|
|
66
|
-
|
|
67
|
-
switch (config.method) {
|
|
68
|
-
case 'eoa':
|
|
69
|
-
return validateEoaConfig(config as EoaExecutionConfig, walletStatus);
|
|
70
|
-
case 'relayer':
|
|
71
|
-
return validateRelayerConfig(config as RelayerExecutionConfig);
|
|
72
|
-
case 'multisig':
|
|
73
|
-
return _validateMultisigConfig(config as MultisigExecutionConfig, walletStatus);
|
|
74
|
-
default: {
|
|
75
|
-
const unknownMethod = (config as ExecutionConfig).method;
|
|
76
|
-
logger.warn(
|
|
77
|
-
SYSTEM_LOG_TAG,
|
|
78
|
-
`Unsupported execution method type encountered: ${unknownMethod}`
|
|
79
|
-
);
|
|
80
|
-
return `Unsupported execution method type: ${unknownMethod}`;
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
// Barrel file for
|
|
1
|
+
// Barrel file for configuration module
|
|
2
|
+
// Adapter-specific exports only - core configuration utilities available from @openzeppelin/ui-builder-adapter-evm-core
|
|
2
3
|
export * from './execution';
|
|
3
|
-
export * from './explorer';
|
|
4
4
|
export * from './network-services';
|
|
5
|
-
export * from './rpc';
|