@openzeppelin/ui-builder-adapter-evm 0.11.1 → 0.13.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +77 -75
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +63 -38
- package/dist/index.js.map +1 -1
- package/package.json +6 -5
- package/src/__tests__/mocks/mock-network-configs.ts +0 -1
- package/src/mapping/__tests__/field-generator.test.ts +100 -0
- package/src/mapping/__tests__/type-mapper.test.ts +139 -0
- package/src/mapping/constants.ts +12 -6
- package/src/mapping/field-generator.ts +6 -5
- package/src/mapping/type-mapper.ts +6 -6
- package/src/networks/README.md +1 -1
- package/src/networks/mainnet.ts +23 -11
- package/src/networks/testnet.ts +25 -12
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@openzeppelin/ui-builder-adapter-evm",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.13.0",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "EVM Adapter for UI Builder",
|
|
6
6
|
"keywords": [
|
|
@@ -39,13 +39,14 @@
|
|
|
39
39
|
"@openzeppelin/relayer-sdk": "1.4.0",
|
|
40
40
|
"@wagmi/connectors": "5.7.13",
|
|
41
41
|
"@wagmi/core": "^2.20.3",
|
|
42
|
+
"@web3icons/react": "^4.0.19",
|
|
42
43
|
"lodash": "^4.17.21",
|
|
43
44
|
"lucide-react": "^0.510.0",
|
|
44
45
|
"react-hook-form": "^7.62.0",
|
|
45
|
-
"@openzeppelin/ui-builder-react-core": "^0.
|
|
46
|
-
"@openzeppelin/ui-builder-types": "^0.
|
|
47
|
-
"@openzeppelin/ui-builder-
|
|
48
|
-
"@openzeppelin/ui-builder-
|
|
46
|
+
"@openzeppelin/ui-builder-react-core": "^0.13.0",
|
|
47
|
+
"@openzeppelin/ui-builder-types": "^0.13.0",
|
|
48
|
+
"@openzeppelin/ui-builder-ui": "^0.13.0",
|
|
49
|
+
"@openzeppelin/ui-builder-utils": "^0.13.0"
|
|
49
50
|
},
|
|
50
51
|
"devDependencies": {
|
|
51
52
|
"@rainbow-me/rainbowkit": "^2.2.8",
|
|
@@ -15,7 +15,6 @@ 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
|
-
icon: 'ethereum',
|
|
19
18
|
};
|
|
20
19
|
|
|
21
20
|
// Add mocks for other ecosystems here if needed later
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
import { describe, expect, it } from 'vitest';
|
|
2
|
+
|
|
3
|
+
import type { FunctionParameter } from '@openzeppelin/ui-builder-types';
|
|
4
|
+
|
|
5
|
+
import { generateEvmDefaultField } from '../field-generator';
|
|
6
|
+
|
|
7
|
+
// Helper to create a mock function parameter
|
|
8
|
+
const createParam = (type: string, name: string, description?: string): FunctionParameter => ({
|
|
9
|
+
name,
|
|
10
|
+
type,
|
|
11
|
+
displayName: name,
|
|
12
|
+
description,
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
describe('EVM Field Generator', () => {
|
|
16
|
+
describe('generateEvmDefaultField', () => {
|
|
17
|
+
it('should generate a number field for small integer types', () => {
|
|
18
|
+
const param = createParam('uint32', 'count');
|
|
19
|
+
const field = generateEvmDefaultField(param);
|
|
20
|
+
|
|
21
|
+
expect(field.type).toBe('number');
|
|
22
|
+
expect(field.validation.required).toBe(true);
|
|
23
|
+
expect(field.validation.pattern).toBeUndefined();
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
it('should generate a bigint field for uint128', () => {
|
|
27
|
+
const param = createParam('uint128', 'amount');
|
|
28
|
+
const field = generateEvmDefaultField(param);
|
|
29
|
+
|
|
30
|
+
expect(field.type).toBe('bigint');
|
|
31
|
+
expect(field.validation.required).toBe(true);
|
|
32
|
+
// BigIntField component handles its own validation and UI guidance
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
it('should generate a bigint field for uint256', () => {
|
|
36
|
+
const param = createParam('uint256', 'value');
|
|
37
|
+
const field = generateEvmDefaultField(param);
|
|
38
|
+
|
|
39
|
+
expect(field.type).toBe('bigint');
|
|
40
|
+
expect(field.validation.required).toBe(true);
|
|
41
|
+
// BigIntField component handles its own validation and UI guidance
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
it('should generate a bigint field for int128', () => {
|
|
45
|
+
const param = createParam('int128', 'delta');
|
|
46
|
+
const field = generateEvmDefaultField(param);
|
|
47
|
+
|
|
48
|
+
expect(field.type).toBe('bigint');
|
|
49
|
+
expect(field.validation.required).toBe(true);
|
|
50
|
+
// BigIntField component handles its own validation and UI guidance
|
|
51
|
+
});
|
|
52
|
+
|
|
53
|
+
it('should generate a bigint field for int256', () => {
|
|
54
|
+
const param = createParam('int256', 'offset');
|
|
55
|
+
const field = generateEvmDefaultField(param);
|
|
56
|
+
|
|
57
|
+
expect(field.type).toBe('bigint');
|
|
58
|
+
expect(field.validation.required).toBe(true);
|
|
59
|
+
// BigIntField component handles its own validation and UI guidance
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
it('should preserve parameter description in helper text', () => {
|
|
63
|
+
const param = createParam('uint256', 'tokenId', 'The unique identifier of the NFT');
|
|
64
|
+
const field = generateEvmDefaultField(param);
|
|
65
|
+
|
|
66
|
+
expect(field.type).toBe('bigint');
|
|
67
|
+
expect(field.helperText).toBe('The unique identifier of the NFT');
|
|
68
|
+
});
|
|
69
|
+
|
|
70
|
+
it('should generate a blockchain-address field for address type', () => {
|
|
71
|
+
const param = createParam('address', 'recipient');
|
|
72
|
+
const field = generateEvmDefaultField(param);
|
|
73
|
+
|
|
74
|
+
expect(field.type).toBe('blockchain-address');
|
|
75
|
+
expect(field.validation.required).toBe(true);
|
|
76
|
+
expect(field.validation.pattern).toBeUndefined();
|
|
77
|
+
});
|
|
78
|
+
|
|
79
|
+
it('should generate array field with proper element config for uint256[]', () => {
|
|
80
|
+
const param = createParam('uint256[]', 'amounts');
|
|
81
|
+
const field = generateEvmDefaultField(param);
|
|
82
|
+
|
|
83
|
+
expect(field.type).toBe('array');
|
|
84
|
+
expect(field.elementFieldConfig).toBeDefined();
|
|
85
|
+
expect(field.elementFieldConfig?.type).toBe('bigint');
|
|
86
|
+
// Integer validation is handled by BigIntField component internally
|
|
87
|
+
});
|
|
88
|
+
|
|
89
|
+
it('should include proper field metadata', () => {
|
|
90
|
+
const param = createParam('uint256', 'value');
|
|
91
|
+
const field = generateEvmDefaultField(param);
|
|
92
|
+
|
|
93
|
+
expect(field.id).toBeDefined();
|
|
94
|
+
expect(field.name).toBe('value');
|
|
95
|
+
expect(field.label).toBe('Value');
|
|
96
|
+
expect(field.placeholder).toContain('value');
|
|
97
|
+
expect(field.width).toBe('full');
|
|
98
|
+
});
|
|
99
|
+
});
|
|
100
|
+
});
|
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
import { describe, expect, it } from 'vitest';
|
|
2
|
+
|
|
3
|
+
import { getEvmCompatibleFieldTypes, mapEvmParamTypeToFieldType } from '../type-mapper';
|
|
4
|
+
|
|
5
|
+
describe('EVM Type Mapper', () => {
|
|
6
|
+
describe('mapEvmParamTypeToFieldType', () => {
|
|
7
|
+
it('should map small integer types to number field', () => {
|
|
8
|
+
expect(mapEvmParamTypeToFieldType('uint')).toBe('number');
|
|
9
|
+
expect(mapEvmParamTypeToFieldType('uint8')).toBe('number');
|
|
10
|
+
expect(mapEvmParamTypeToFieldType('uint16')).toBe('number');
|
|
11
|
+
expect(mapEvmParamTypeToFieldType('uint32')).toBe('number');
|
|
12
|
+
expect(mapEvmParamTypeToFieldType('int')).toBe('number');
|
|
13
|
+
expect(mapEvmParamTypeToFieldType('int8')).toBe('number');
|
|
14
|
+
expect(mapEvmParamTypeToFieldType('int16')).toBe('number');
|
|
15
|
+
expect(mapEvmParamTypeToFieldType('int32')).toBe('number');
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
it('should map 64-bit and larger integer types to bigint field to avoid precision loss', () => {
|
|
19
|
+
// These types can hold values larger than JavaScript's Number.MAX_SAFE_INTEGER (2^53-1)
|
|
20
|
+
expect(mapEvmParamTypeToFieldType('uint64')).toBe('bigint');
|
|
21
|
+
expect(mapEvmParamTypeToFieldType('uint128')).toBe('bigint');
|
|
22
|
+
expect(mapEvmParamTypeToFieldType('uint256')).toBe('bigint');
|
|
23
|
+
expect(mapEvmParamTypeToFieldType('int64')).toBe('bigint');
|
|
24
|
+
expect(mapEvmParamTypeToFieldType('int128')).toBe('bigint');
|
|
25
|
+
expect(mapEvmParamTypeToFieldType('int256')).toBe('bigint');
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
it('should map address to blockchain-address field', () => {
|
|
29
|
+
expect(mapEvmParamTypeToFieldType('address')).toBe('blockchain-address');
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
it('should map bool to checkbox field', () => {
|
|
33
|
+
expect(mapEvmParamTypeToFieldType('bool')).toBe('checkbox');
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
it('should map string to text field', () => {
|
|
37
|
+
expect(mapEvmParamTypeToFieldType('string')).toBe('text');
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
it('should map bytes types to text/textarea fields', () => {
|
|
41
|
+
expect(mapEvmParamTypeToFieldType('bytes')).toBe('textarea');
|
|
42
|
+
expect(mapEvmParamTypeToFieldType('bytes32')).toBe('text');
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
it('should map array types correctly', () => {
|
|
46
|
+
expect(mapEvmParamTypeToFieldType('uint256[]')).toBe('array');
|
|
47
|
+
expect(mapEvmParamTypeToFieldType('address[]')).toBe('array');
|
|
48
|
+
expect(mapEvmParamTypeToFieldType('string[]')).toBe('array');
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
it('should map tuple types to object', () => {
|
|
52
|
+
expect(mapEvmParamTypeToFieldType('tuple')).toBe('object');
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
it('should map array of tuples to array-object', () => {
|
|
56
|
+
expect(mapEvmParamTypeToFieldType('tuple[]')).toBe('array-object');
|
|
57
|
+
expect(mapEvmParamTypeToFieldType('tuple[5]')).toBe('array-object');
|
|
58
|
+
});
|
|
59
|
+
|
|
60
|
+
it('should default to text for unknown types', () => {
|
|
61
|
+
expect(mapEvmParamTypeToFieldType('unknown')).toBe('text');
|
|
62
|
+
expect(mapEvmParamTypeToFieldType('custom')).toBe('text');
|
|
63
|
+
});
|
|
64
|
+
});
|
|
65
|
+
|
|
66
|
+
describe('getEvmCompatibleFieldTypes', () => {
|
|
67
|
+
it('should return bigint as first compatible type for 64-bit and larger unsigned integers', () => {
|
|
68
|
+
// Verify uint64
|
|
69
|
+
const compatibleTypesUint64 = getEvmCompatibleFieldTypes('uint64');
|
|
70
|
+
expect(compatibleTypesUint64[0]).toBe('bigint'); // First (recommended) type
|
|
71
|
+
expect(compatibleTypesUint64).toContain('number');
|
|
72
|
+
expect(compatibleTypesUint64).toContain('amount');
|
|
73
|
+
expect(compatibleTypesUint64).toContain('text');
|
|
74
|
+
|
|
75
|
+
// Verify uint128
|
|
76
|
+
const compatibleTypesUint128 = getEvmCompatibleFieldTypes('uint128');
|
|
77
|
+
expect(compatibleTypesUint128[0]).toBe('bigint'); // First (recommended) type
|
|
78
|
+
expect(compatibleTypesUint128).toContain('number');
|
|
79
|
+
expect(compatibleTypesUint128).toContain('amount');
|
|
80
|
+
expect(compatibleTypesUint128).toContain('text');
|
|
81
|
+
|
|
82
|
+
// Verify uint256
|
|
83
|
+
const compatibleTypesUint256 = getEvmCompatibleFieldTypes('uint256');
|
|
84
|
+
expect(compatibleTypesUint256[0]).toBe('bigint'); // First (recommended) type
|
|
85
|
+
expect(compatibleTypesUint256).toContain('number');
|
|
86
|
+
expect(compatibleTypesUint256).toContain('amount');
|
|
87
|
+
expect(compatibleTypesUint256).toContain('text');
|
|
88
|
+
});
|
|
89
|
+
|
|
90
|
+
it('should return bigint as first compatible type for 64-bit and larger signed integers', () => {
|
|
91
|
+
// Verify int64
|
|
92
|
+
const compatibleTypesInt64 = getEvmCompatibleFieldTypes('int64');
|
|
93
|
+
expect(compatibleTypesInt64[0]).toBe('bigint'); // First (recommended) type
|
|
94
|
+
expect(compatibleTypesInt64).toContain('number');
|
|
95
|
+
expect(compatibleTypesInt64).toContain('text');
|
|
96
|
+
|
|
97
|
+
// Verify int128
|
|
98
|
+
const compatibleTypesInt128 = getEvmCompatibleFieldTypes('int128');
|
|
99
|
+
expect(compatibleTypesInt128[0]).toBe('bigint'); // First (recommended) type
|
|
100
|
+
expect(compatibleTypesInt128).toContain('number');
|
|
101
|
+
expect(compatibleTypesInt128).toContain('text');
|
|
102
|
+
|
|
103
|
+
// Verify int256
|
|
104
|
+
const compatibleTypesInt256 = getEvmCompatibleFieldTypes('int256');
|
|
105
|
+
expect(compatibleTypesInt256[0]).toBe('bigint'); // First (recommended) type
|
|
106
|
+
expect(compatibleTypesInt256).toContain('number');
|
|
107
|
+
expect(compatibleTypesInt256).toContain('text');
|
|
108
|
+
});
|
|
109
|
+
|
|
110
|
+
it('should return number as first compatible type for small integers', () => {
|
|
111
|
+
// Small integers that fit within JavaScript Number precision
|
|
112
|
+
const compatibleTypes = getEvmCompatibleFieldTypes('uint32');
|
|
113
|
+
expect(compatibleTypes[0]).toBe('number'); // First (recommended) type
|
|
114
|
+
expect(compatibleTypes).toContain('amount');
|
|
115
|
+
expect(compatibleTypes).toContain('text');
|
|
116
|
+
});
|
|
117
|
+
|
|
118
|
+
it('should return compatible field types for address', () => {
|
|
119
|
+
const compatibleTypes = getEvmCompatibleFieldTypes('address');
|
|
120
|
+
expect(compatibleTypes[0]).toBe('blockchain-address'); // First (recommended) type
|
|
121
|
+
expect(compatibleTypes).toContain('text');
|
|
122
|
+
});
|
|
123
|
+
|
|
124
|
+
it('should return compatible field types for bool', () => {
|
|
125
|
+
const compatibleTypes = getEvmCompatibleFieldTypes('bool');
|
|
126
|
+
expect(compatibleTypes[0]).toBe('checkbox'); // First (recommended) type
|
|
127
|
+
expect(compatibleTypes).toContain('select');
|
|
128
|
+
expect(compatibleTypes).toContain('radio');
|
|
129
|
+
expect(compatibleTypes).toContain('text');
|
|
130
|
+
});
|
|
131
|
+
|
|
132
|
+
it('should return compatible field types for arrays', () => {
|
|
133
|
+
const compatibleTypes = getEvmCompatibleFieldTypes('uint256[]');
|
|
134
|
+
expect(compatibleTypes[0]).toBe('array'); // First (recommended) type
|
|
135
|
+
expect(compatibleTypes).toContain('textarea');
|
|
136
|
+
expect(compatibleTypes).toContain('text');
|
|
137
|
+
});
|
|
138
|
+
});
|
|
139
|
+
});
|
package/src/mapping/constants.ts
CHANGED
|
@@ -2,6 +2,12 @@ import type { FieldType } from '@openzeppelin/ui-builder-types';
|
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* EVM-specific type mapping to default form field types.
|
|
5
|
+
*
|
|
6
|
+
* Note: Large integer types (uint128, uint256, int128, int256) are mapped to 'bigint'
|
|
7
|
+
* instead of 'number' to avoid JavaScript's Number precision limitations.
|
|
8
|
+
* JavaScript's Number type can only safely represent integers up to 2^53 - 1,
|
|
9
|
+
* but these types can hold much larger values. The BigIntField component stores values
|
|
10
|
+
* as strings and the EVM adapter handles BigInt conversion automatically.
|
|
5
11
|
*/
|
|
6
12
|
export const EVM_TYPE_TO_FIELD_TYPE: Record<string, FieldType> = {
|
|
7
13
|
address: 'blockchain-address',
|
|
@@ -10,16 +16,16 @@ export const EVM_TYPE_TO_FIELD_TYPE: Record<string, FieldType> = {
|
|
|
10
16
|
uint8: 'number',
|
|
11
17
|
uint16: 'number',
|
|
12
18
|
uint32: 'number',
|
|
13
|
-
uint64: '
|
|
14
|
-
uint128: '
|
|
15
|
-
uint256: '
|
|
19
|
+
uint64: 'bigint',
|
|
20
|
+
uint128: 'bigint',
|
|
21
|
+
uint256: 'bigint',
|
|
16
22
|
int: 'number',
|
|
17
23
|
int8: 'number',
|
|
18
24
|
int16: 'number',
|
|
19
25
|
int32: 'number',
|
|
20
|
-
int64: '
|
|
21
|
-
int128: '
|
|
22
|
-
int256: '
|
|
26
|
+
int64: 'bigint',
|
|
27
|
+
int128: 'bigint',
|
|
28
|
+
int256: 'bigint',
|
|
23
29
|
bool: 'checkbox',
|
|
24
30
|
bytes: 'textarea',
|
|
25
31
|
bytes32: 'text',
|
|
@@ -26,10 +26,10 @@ function extractArrayElementType(parameterType: string): string | null {
|
|
|
26
26
|
}
|
|
27
27
|
|
|
28
28
|
/**
|
|
29
|
-
* Get default validation rules for a parameter
|
|
30
|
-
*
|
|
29
|
+
* Get default validation rules for a parameter.
|
|
30
|
+
* Field-specific validation is handled by the field components themselves.
|
|
31
31
|
*/
|
|
32
|
-
function
|
|
32
|
+
function getDefaultValidation(): FieldValidation {
|
|
33
33
|
return { required: true };
|
|
34
34
|
}
|
|
35
35
|
|
|
@@ -40,6 +40,7 @@ export function generateEvmDefaultField<T extends FieldType = FieldType>(
|
|
|
40
40
|
parameter: FunctionParameter
|
|
41
41
|
): FormFieldType<T> {
|
|
42
42
|
const fieldType = mapEvmParamTypeToFieldType(parameter.type) as T;
|
|
43
|
+
|
|
43
44
|
const baseField: FormFieldType<T> = {
|
|
44
45
|
id: `field-${Math.random().toString(36).substring(2, 9)}`,
|
|
45
46
|
name: parameter.name || parameter.type, // Use type if name missing
|
|
@@ -48,7 +49,7 @@ export function generateEvmDefaultField<T extends FieldType = FieldType>(
|
|
|
48
49
|
placeholder: `Enter ${parameter.displayName || parameter.name || parameter.type}`,
|
|
49
50
|
helperText: parameter.description || '',
|
|
50
51
|
defaultValue: getDefaultValueForType(fieldType) as FieldValue<T>,
|
|
51
|
-
validation:
|
|
52
|
+
validation: getDefaultValidation(),
|
|
52
53
|
width: 'full',
|
|
53
54
|
};
|
|
54
55
|
|
|
@@ -64,7 +65,7 @@ export function generateEvmDefaultField<T extends FieldType = FieldType>(
|
|
|
64
65
|
elementType: elementFieldType,
|
|
65
66
|
elementFieldConfig: {
|
|
66
67
|
type: elementFieldType,
|
|
67
|
-
validation:
|
|
68
|
+
validation: getDefaultValidation(),
|
|
68
69
|
placeholder: `Enter ${elementType}`,
|
|
69
70
|
},
|
|
70
71
|
};
|
|
@@ -60,16 +60,16 @@ export function getEvmCompatibleFieldTypes(parameterType: string): FieldType[] {
|
|
|
60
60
|
uint8: ['number', 'amount', 'text'],
|
|
61
61
|
uint16: ['number', 'amount', 'text'],
|
|
62
62
|
uint32: ['number', 'amount', 'text'],
|
|
63
|
-
uint64: ['number', 'amount', 'text'],
|
|
64
|
-
uint128: ['number', 'amount', 'text'],
|
|
65
|
-
uint256: ['number', 'amount', 'text'],
|
|
63
|
+
uint64: ['bigint', 'number', 'amount', 'text'],
|
|
64
|
+
uint128: ['bigint', 'number', 'amount', 'text'],
|
|
65
|
+
uint256: ['bigint', 'number', 'amount', 'text'],
|
|
66
66
|
int: ['number', 'text'],
|
|
67
67
|
int8: ['number', 'text'],
|
|
68
68
|
int16: ['number', 'text'],
|
|
69
69
|
int32: ['number', 'text'],
|
|
70
|
-
int64: ['number', 'text'],
|
|
71
|
-
int128: ['number', 'text'],
|
|
72
|
-
int256: ['number', 'text'],
|
|
70
|
+
int64: ['bigint', 'number', 'text'],
|
|
71
|
+
int128: ['bigint', 'number', 'text'],
|
|
72
|
+
int256: ['bigint', 'number', 'text'],
|
|
73
73
|
bool: ['checkbox', 'select', 'radio', 'text'],
|
|
74
74
|
string: ['text', 'textarea', 'email', 'password'],
|
|
75
75
|
bytes: ['textarea', 'text'],
|
package/src/networks/README.md
CHANGED
|
@@ -102,7 +102,7 @@ export const myNewNetworkMainnet: EvmNetworkConfig = {
|
|
|
102
102
|
explorerUrl: 'https://explorer.mynewnetwork.io',
|
|
103
103
|
apiUrl: 'https://api.explorer.mynewnetwork.io/api',
|
|
104
104
|
primaryExplorerApiIdentifier: 'mynewnetwork-mainnet',
|
|
105
|
-
|
|
105
|
+
iconComponent: NetworkMyNewNetwork,
|
|
106
106
|
nativeCurrency: {
|
|
107
107
|
name: 'My Token',
|
|
108
108
|
symbol: 'MTK',
|
package/src/networks/mainnet.ts
CHANGED
|
@@ -1,3 +1,15 @@
|
|
|
1
|
+
import {
|
|
2
|
+
NetworkArbitrumOne,
|
|
3
|
+
NetworkAvalanche,
|
|
4
|
+
NetworkBase,
|
|
5
|
+
NetworkBinanceSmartChain,
|
|
6
|
+
NetworkEthereum,
|
|
7
|
+
NetworkLinea,
|
|
8
|
+
NetworkOptimism,
|
|
9
|
+
NetworkPolygon,
|
|
10
|
+
NetworkScroll,
|
|
11
|
+
NetworkZksync,
|
|
12
|
+
} from '@web3icons/react';
|
|
1
13
|
import {
|
|
2
14
|
arbitrum as viemArbitrum,
|
|
3
15
|
avalanche as viemAvalanche,
|
|
@@ -28,7 +40,7 @@ export const ethereumMainnet: TypedEvmNetworkConfig = {
|
|
|
28
40
|
apiUrl: 'https://api.etherscan.io/v2/api',
|
|
29
41
|
primaryExplorerApiIdentifier: 'etherscan-v2',
|
|
30
42
|
supportsEtherscanV2: true,
|
|
31
|
-
|
|
43
|
+
iconComponent: NetworkEthereum,
|
|
32
44
|
nativeCurrency: {
|
|
33
45
|
name: 'Ether',
|
|
34
46
|
symbol: 'ETH',
|
|
@@ -51,7 +63,7 @@ export const arbitrumMainnet: TypedEvmNetworkConfig = {
|
|
|
51
63
|
apiUrl: 'https://api.etherscan.io/v2/api',
|
|
52
64
|
primaryExplorerApiIdentifier: 'etherscan-v2',
|
|
53
65
|
supportsEtherscanV2: true,
|
|
54
|
-
|
|
66
|
+
iconComponent: NetworkArbitrumOne,
|
|
55
67
|
nativeCurrency: {
|
|
56
68
|
name: 'Ether',
|
|
57
69
|
symbol: 'ETH',
|
|
@@ -74,7 +86,7 @@ export const polygonMainnet: TypedEvmNetworkConfig = {
|
|
|
74
86
|
apiUrl: 'https://api.etherscan.io/v2/api',
|
|
75
87
|
primaryExplorerApiIdentifier: 'etherscan-v2',
|
|
76
88
|
supportsEtherscanV2: true,
|
|
77
|
-
|
|
89
|
+
iconComponent: NetworkPolygon,
|
|
78
90
|
nativeCurrency: {
|
|
79
91
|
name: 'MATIC',
|
|
80
92
|
symbol: 'MATIC',
|
|
@@ -97,7 +109,7 @@ export const polygonZkEvmMainnet: TypedEvmNetworkConfig = {
|
|
|
97
109
|
apiUrl: 'https://api.etherscan.io/v2/api',
|
|
98
110
|
primaryExplorerApiIdentifier: 'etherscan-v2',
|
|
99
111
|
supportsEtherscanV2: true,
|
|
100
|
-
|
|
112
|
+
iconComponent: NetworkPolygon,
|
|
101
113
|
nativeCurrency: {
|
|
102
114
|
name: 'Ether',
|
|
103
115
|
symbol: 'ETH',
|
|
@@ -120,7 +132,7 @@ export const baseMainnet: TypedEvmNetworkConfig = {
|
|
|
120
132
|
apiUrl: 'https://api.etherscan.io/v2/api',
|
|
121
133
|
primaryExplorerApiIdentifier: 'etherscan-v2',
|
|
122
134
|
supportsEtherscanV2: true,
|
|
123
|
-
|
|
135
|
+
iconComponent: NetworkBase,
|
|
124
136
|
nativeCurrency: {
|
|
125
137
|
name: 'Ether',
|
|
126
138
|
symbol: 'ETH',
|
|
@@ -143,7 +155,7 @@ export const bscMainnet: TypedEvmNetworkConfig = {
|
|
|
143
155
|
apiUrl: 'https://api.etherscan.io/v2/api',
|
|
144
156
|
primaryExplorerApiIdentifier: 'etherscan-v2',
|
|
145
157
|
supportsEtherscanV2: true,
|
|
146
|
-
|
|
158
|
+
iconComponent: NetworkBinanceSmartChain,
|
|
147
159
|
nativeCurrency: {
|
|
148
160
|
name: 'BNB',
|
|
149
161
|
symbol: 'BNB',
|
|
@@ -166,7 +178,7 @@ export const optimismMainnet: TypedEvmNetworkConfig = {
|
|
|
166
178
|
apiUrl: 'https://api.etherscan.io/v2/api',
|
|
167
179
|
primaryExplorerApiIdentifier: 'etherscan-v2',
|
|
168
180
|
supportsEtherscanV2: true,
|
|
169
|
-
|
|
181
|
+
iconComponent: NetworkOptimism,
|
|
170
182
|
nativeCurrency: {
|
|
171
183
|
name: 'Ether',
|
|
172
184
|
symbol: 'ETH',
|
|
@@ -189,7 +201,7 @@ export const avalancheMainnet: TypedEvmNetworkConfig = {
|
|
|
189
201
|
apiUrl: 'https://api.etherscan.io/v2/api',
|
|
190
202
|
primaryExplorerApiIdentifier: 'etherscan-v2',
|
|
191
203
|
supportsEtherscanV2: true,
|
|
192
|
-
|
|
204
|
+
iconComponent: NetworkAvalanche,
|
|
193
205
|
nativeCurrency: {
|
|
194
206
|
name: 'Avalanche',
|
|
195
207
|
symbol: 'AVAX',
|
|
@@ -213,7 +225,7 @@ export const zkSyncEraMainnet: TypedEvmNetworkConfig = {
|
|
|
213
225
|
apiUrl: 'https://block-explorer-api.mainnet.zksync.io/api',
|
|
214
226
|
primaryExplorerApiIdentifier: 'zksync-era-mainnet',
|
|
215
227
|
supportsEtherscanV2: false,
|
|
216
|
-
|
|
228
|
+
iconComponent: NetworkZksync,
|
|
217
229
|
nativeCurrency: {
|
|
218
230
|
name: 'Ether',
|
|
219
231
|
symbol: 'ETH',
|
|
@@ -236,7 +248,7 @@ export const scrollMainnet: TypedEvmNetworkConfig = {
|
|
|
236
248
|
apiUrl: 'https://api.etherscan.io/v2/api',
|
|
237
249
|
primaryExplorerApiIdentifier: 'etherscan-v2',
|
|
238
250
|
supportsEtherscanV2: true,
|
|
239
|
-
|
|
251
|
+
iconComponent: NetworkScroll,
|
|
240
252
|
nativeCurrency: {
|
|
241
253
|
name: 'Ether',
|
|
242
254
|
symbol: 'ETH',
|
|
@@ -259,7 +271,7 @@ export const lineaMainnet: TypedEvmNetworkConfig = {
|
|
|
259
271
|
apiUrl: 'https://api.etherscan.io/v2/api',
|
|
260
272
|
primaryExplorerApiIdentifier: 'etherscan-v2',
|
|
261
273
|
supportsEtherscanV2: true,
|
|
262
|
-
|
|
274
|
+
iconComponent: NetworkLinea,
|
|
263
275
|
nativeCurrency: {
|
|
264
276
|
name: 'Ether',
|
|
265
277
|
symbol: 'ETH',
|
package/src/networks/testnet.ts
CHANGED
|
@@ -1,3 +1,16 @@
|
|
|
1
|
+
import {
|
|
2
|
+
NetworkArbitrumOne,
|
|
3
|
+
NetworkAvalanche,
|
|
4
|
+
NetworkBase,
|
|
5
|
+
NetworkBinanceSmartChain,
|
|
6
|
+
NetworkEthereum,
|
|
7
|
+
NetworkLinea,
|
|
8
|
+
NetworkMonad,
|
|
9
|
+
NetworkOptimism,
|
|
10
|
+
NetworkPolygon,
|
|
11
|
+
NetworkScroll,
|
|
12
|
+
NetworkZksync,
|
|
13
|
+
} from '@web3icons/react';
|
|
1
14
|
import {
|
|
2
15
|
arbitrumSepolia as viemArbitrumSepolia,
|
|
3
16
|
avalancheFuji as viemAvalancheFuji,
|
|
@@ -29,7 +42,7 @@ export const ethereumSepolia: TypedEvmNetworkConfig = {
|
|
|
29
42
|
apiUrl: 'https://api.etherscan.io/v2/api',
|
|
30
43
|
primaryExplorerApiIdentifier: 'etherscan-v2',
|
|
31
44
|
supportsEtherscanV2: true,
|
|
32
|
-
|
|
45
|
+
iconComponent: NetworkEthereum,
|
|
33
46
|
nativeCurrency: {
|
|
34
47
|
name: 'Sepolia Ether',
|
|
35
48
|
symbol: 'ETH',
|
|
@@ -52,7 +65,7 @@ export const arbitrumSepolia: TypedEvmNetworkConfig = {
|
|
|
52
65
|
apiUrl: 'https://api.etherscan.io/v2/api',
|
|
53
66
|
primaryExplorerApiIdentifier: 'etherscan-v2',
|
|
54
67
|
supportsEtherscanV2: true,
|
|
55
|
-
|
|
68
|
+
iconComponent: NetworkArbitrumOne,
|
|
56
69
|
nativeCurrency: {
|
|
57
70
|
name: 'Arbitrum Sepolia Ether',
|
|
58
71
|
symbol: 'ETH',
|
|
@@ -75,7 +88,7 @@ export const polygonAmoy: TypedEvmNetworkConfig = {
|
|
|
75
88
|
apiUrl: 'https://api.etherscan.io/v2/api',
|
|
76
89
|
primaryExplorerApiIdentifier: 'etherscan-v2',
|
|
77
90
|
supportsEtherscanV2: true,
|
|
78
|
-
|
|
91
|
+
iconComponent: NetworkPolygon,
|
|
79
92
|
nativeCurrency: {
|
|
80
93
|
name: 'MATIC',
|
|
81
94
|
symbol: 'MATIC',
|
|
@@ -98,7 +111,7 @@ export const polygonZkEvmCardona: TypedEvmNetworkConfig = {
|
|
|
98
111
|
apiUrl: 'https://api.etherscan.io/v2/api',
|
|
99
112
|
primaryExplorerApiIdentifier: 'etherscan-v2',
|
|
100
113
|
supportsEtherscanV2: true,
|
|
101
|
-
|
|
114
|
+
iconComponent: NetworkPolygon,
|
|
102
115
|
nativeCurrency: {
|
|
103
116
|
name: 'Ether',
|
|
104
117
|
symbol: 'ETH',
|
|
@@ -121,7 +134,7 @@ export const baseSepolia: TypedEvmNetworkConfig = {
|
|
|
121
134
|
apiUrl: 'https://api.etherscan.io/v2/api',
|
|
122
135
|
primaryExplorerApiIdentifier: 'etherscan-v2',
|
|
123
136
|
supportsEtherscanV2: true,
|
|
124
|
-
|
|
137
|
+
iconComponent: NetworkBase,
|
|
125
138
|
nativeCurrency: {
|
|
126
139
|
name: 'Sepolia Ether',
|
|
127
140
|
symbol: 'ETH',
|
|
@@ -144,7 +157,7 @@ export const bscTestnet: TypedEvmNetworkConfig = {
|
|
|
144
157
|
apiUrl: 'https://api.etherscan.io/v2/api',
|
|
145
158
|
primaryExplorerApiIdentifier: 'etherscan-v2',
|
|
146
159
|
supportsEtherscanV2: true,
|
|
147
|
-
|
|
160
|
+
iconComponent: NetworkBinanceSmartChain,
|
|
148
161
|
nativeCurrency: {
|
|
149
162
|
name: 'BNB',
|
|
150
163
|
symbol: 'BNB',
|
|
@@ -167,7 +180,7 @@ export const optimismSepolia: TypedEvmNetworkConfig = {
|
|
|
167
180
|
apiUrl: 'https://api.etherscan.io/v2/api',
|
|
168
181
|
primaryExplorerApiIdentifier: 'etherscan-v2',
|
|
169
182
|
supportsEtherscanV2: true,
|
|
170
|
-
|
|
183
|
+
iconComponent: NetworkOptimism,
|
|
171
184
|
nativeCurrency: {
|
|
172
185
|
name: 'Sepolia Ether',
|
|
173
186
|
symbol: 'ETH',
|
|
@@ -191,7 +204,7 @@ export const avalancheFuji: TypedEvmNetworkConfig = {
|
|
|
191
204
|
primaryExplorerApiIdentifier: 'etherscan-v2', // Unified identifier for V2 API
|
|
192
205
|
supportsEtherscanV2: true,
|
|
193
206
|
requiresExplorerApiKey: true,
|
|
194
|
-
|
|
207
|
+
iconComponent: NetworkAvalanche,
|
|
195
208
|
nativeCurrency: {
|
|
196
209
|
name: 'Avalanche',
|
|
197
210
|
symbol: 'AVAX',
|
|
@@ -215,7 +228,7 @@ export const zksyncSepoliaTestnet: TypedEvmNetworkConfig = {
|
|
|
215
228
|
apiUrl: 'https://block-explorer-api.sepolia.zksync.dev/api',
|
|
216
229
|
primaryExplorerApiIdentifier: 'zksync-era-sepolia',
|
|
217
230
|
supportsEtherscanV2: false,
|
|
218
|
-
|
|
231
|
+
iconComponent: NetworkZksync,
|
|
219
232
|
nativeCurrency: {
|
|
220
233
|
name: 'Ether',
|
|
221
234
|
symbol: 'ETH',
|
|
@@ -238,7 +251,7 @@ export const scrollSepolia: TypedEvmNetworkConfig = {
|
|
|
238
251
|
apiUrl: 'https://api.etherscan.io/v2/api',
|
|
239
252
|
primaryExplorerApiIdentifier: 'etherscan-v2',
|
|
240
253
|
supportsEtherscanV2: true,
|
|
241
|
-
|
|
254
|
+
iconComponent: NetworkScroll,
|
|
242
255
|
nativeCurrency: {
|
|
243
256
|
name: 'Ether',
|
|
244
257
|
symbol: 'ETH',
|
|
@@ -261,7 +274,7 @@ export const lineaSepolia: TypedEvmNetworkConfig = {
|
|
|
261
274
|
apiUrl: 'https://api.etherscan.io/v2/api',
|
|
262
275
|
primaryExplorerApiIdentifier: 'etherscan-v2',
|
|
263
276
|
supportsEtherscanV2: true,
|
|
264
|
-
|
|
277
|
+
iconComponent: NetworkLinea,
|
|
265
278
|
nativeCurrency: {
|
|
266
279
|
name: 'Linea Ether',
|
|
267
280
|
symbol: 'ETH',
|
|
@@ -284,7 +297,7 @@ export const monadTestnet: TypedEvmNetworkConfig = {
|
|
|
284
297
|
apiUrl: 'https://api.etherscan.io/v2/api',
|
|
285
298
|
primaryExplorerApiIdentifier: 'etherscan-v2',
|
|
286
299
|
supportsEtherscanV2: true,
|
|
287
|
-
|
|
300
|
+
iconComponent: NetworkMonad,
|
|
288
301
|
nativeCurrency: {
|
|
289
302
|
name: 'Monad',
|
|
290
303
|
symbol: 'MON',
|