@openzeppelin/ui-builder-adapter-evm 1.4.0 → 1.4.2
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 +30 -5
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +30 -5
- package/dist/index.js.map +1 -1
- package/package.json +4 -4
package/dist/index.cjs
CHANGED
|
@@ -2198,8 +2198,8 @@ var EVM_TYPE_TO_FIELD_TYPE = {
|
|
|
2198
2198
|
int128: "bigint",
|
|
2199
2199
|
int256: "bigint",
|
|
2200
2200
|
bool: "checkbox",
|
|
2201
|
-
bytes: "
|
|
2202
|
-
bytes32: "
|
|
2201
|
+
bytes: "bytes",
|
|
2202
|
+
bytes32: "bytes"
|
|
2203
2203
|
};
|
|
2204
2204
|
var EVM_DYNAMIC_PATTERNS = [
|
|
2205
2205
|
{ name: "array", syntax: "T[]", mapsTo: "array", description: "Dynamic array of primitives" },
|
|
@@ -2229,6 +2229,9 @@ function mapEvmParamTypeToFieldType(parameterType) {
|
|
|
2229
2229
|
if (baseType.startsWith("tuple")) {
|
|
2230
2230
|
return "object";
|
|
2231
2231
|
}
|
|
2232
|
+
if (baseType.match(/^bytes\d+$/)) {
|
|
2233
|
+
return "bytes";
|
|
2234
|
+
}
|
|
2232
2235
|
return EVM_TYPE_TO_FIELD_TYPE[baseType] || "text";
|
|
2233
2236
|
}
|
|
2234
2237
|
function getEvmCompatibleFieldTypes(parameterType) {
|
|
@@ -2260,11 +2263,21 @@ function getEvmCompatibleFieldTypes(parameterType) {
|
|
|
2260
2263
|
int256: ["bigint", "number", "text"],
|
|
2261
2264
|
bool: ["checkbox", "select", "radio", "text"],
|
|
2262
2265
|
string: ["text", "textarea", "email", "password"],
|
|
2263
|
-
bytes: ["textarea", "text"],
|
|
2264
|
-
bytes32: ["
|
|
2266
|
+
bytes: ["bytes", "textarea", "text"],
|
|
2267
|
+
bytes32: ["bytes", "textarea", "text"]
|
|
2265
2268
|
};
|
|
2269
|
+
if (baseType.match(/^bytes\d+$/)) {
|
|
2270
|
+
return ["bytes", "textarea", "text"];
|
|
2271
|
+
}
|
|
2266
2272
|
return compatibilityMap[baseType] || ["text"];
|
|
2267
2273
|
}
|
|
2274
|
+
function extractBytesSize(parameterType) {
|
|
2275
|
+
const match = parameterType.match(/^bytes(\d+)$/);
|
|
2276
|
+
if (match) {
|
|
2277
|
+
return Number.parseInt(match[1], 10);
|
|
2278
|
+
}
|
|
2279
|
+
return void 0;
|
|
2280
|
+
}
|
|
2268
2281
|
function extractArrayElementType(parameterType) {
|
|
2269
2282
|
const arrayMatch = parameterType.match(/^(.+)\[\d*\]$/);
|
|
2270
2283
|
if (arrayMatch) {
|
|
@@ -2303,10 +2316,18 @@ function generateEvmDefaultField(parameter) {
|
|
|
2303
2316
|
),
|
|
2304
2317
|
width: "full"
|
|
2305
2318
|
};
|
|
2319
|
+
const bytesSize = extractBytesSize(parameter.type);
|
|
2320
|
+
if (bytesSize !== void 0) {
|
|
2321
|
+
baseField.metadata = {
|
|
2322
|
+
...baseField.metadata ?? {},
|
|
2323
|
+
exactBytes: bytesSize
|
|
2324
|
+
};
|
|
2325
|
+
}
|
|
2306
2326
|
if (fieldType === "array") {
|
|
2307
2327
|
const elementType = extractArrayElementType(parameter.type);
|
|
2308
2328
|
if (elementType) {
|
|
2309
2329
|
const elementFieldType = mapEvmParamTypeToFieldType(elementType);
|
|
2330
|
+
const elementBytesSize = extractBytesSize(elementType);
|
|
2310
2331
|
const arrayField = {
|
|
2311
2332
|
...baseField,
|
|
2312
2333
|
elementType: elementFieldType,
|
|
@@ -2317,7 +2338,11 @@ function generateEvmDefaultField(parameter) {
|
|
|
2317
2338
|
elementType,
|
|
2318
2339
|
EVM_NUMERIC_BOUNDS
|
|
2319
2340
|
),
|
|
2320
|
-
placeholder: `Enter ${elementType}
|
|
2341
|
+
placeholder: `Enter ${elementType}`,
|
|
2342
|
+
// Include exactBytes metadata for fixed-size bytes array elements (e.g., bytes32[])
|
|
2343
|
+
...elementBytesSize !== void 0 && {
|
|
2344
|
+
metadata: { exactBytes: elementBytesSize }
|
|
2345
|
+
}
|
|
2321
2346
|
}
|
|
2322
2347
|
};
|
|
2323
2348
|
return arrayField;
|