@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.js CHANGED
@@ -2181,8 +2181,8 @@ var EVM_TYPE_TO_FIELD_TYPE = {
2181
2181
  int128: "bigint",
2182
2182
  int256: "bigint",
2183
2183
  bool: "checkbox",
2184
- bytes: "textarea",
2185
- bytes32: "text"
2184
+ bytes: "bytes",
2185
+ bytes32: "bytes"
2186
2186
  };
2187
2187
  var EVM_DYNAMIC_PATTERNS = [
2188
2188
  { name: "array", syntax: "T[]", mapsTo: "array", description: "Dynamic array of primitives" },
@@ -2212,6 +2212,9 @@ function mapEvmParamTypeToFieldType(parameterType) {
2212
2212
  if (baseType.startsWith("tuple")) {
2213
2213
  return "object";
2214
2214
  }
2215
+ if (baseType.match(/^bytes\d+$/)) {
2216
+ return "bytes";
2217
+ }
2215
2218
  return EVM_TYPE_TO_FIELD_TYPE[baseType] || "text";
2216
2219
  }
2217
2220
  function getEvmCompatibleFieldTypes(parameterType) {
@@ -2243,11 +2246,21 @@ function getEvmCompatibleFieldTypes(parameterType) {
2243
2246
  int256: ["bigint", "number", "text"],
2244
2247
  bool: ["checkbox", "select", "radio", "text"],
2245
2248
  string: ["text", "textarea", "email", "password"],
2246
- bytes: ["textarea", "text"],
2247
- bytes32: ["text", "textarea"]
2249
+ bytes: ["bytes", "textarea", "text"],
2250
+ bytes32: ["bytes", "textarea", "text"]
2248
2251
  };
2252
+ if (baseType.match(/^bytes\d+$/)) {
2253
+ return ["bytes", "textarea", "text"];
2254
+ }
2249
2255
  return compatibilityMap[baseType] || ["text"];
2250
2256
  }
2257
+ function extractBytesSize(parameterType) {
2258
+ const match = parameterType.match(/^bytes(\d+)$/);
2259
+ if (match) {
2260
+ return Number.parseInt(match[1], 10);
2261
+ }
2262
+ return void 0;
2263
+ }
2251
2264
  function extractArrayElementType(parameterType) {
2252
2265
  const arrayMatch = parameterType.match(/^(.+)\[\d*\]$/);
2253
2266
  if (arrayMatch) {
@@ -2286,10 +2299,18 @@ function generateEvmDefaultField(parameter) {
2286
2299
  ),
2287
2300
  width: "full"
2288
2301
  };
2302
+ const bytesSize = extractBytesSize(parameter.type);
2303
+ if (bytesSize !== void 0) {
2304
+ baseField.metadata = {
2305
+ ...baseField.metadata ?? {},
2306
+ exactBytes: bytesSize
2307
+ };
2308
+ }
2289
2309
  if (fieldType === "array") {
2290
2310
  const elementType = extractArrayElementType(parameter.type);
2291
2311
  if (elementType) {
2292
2312
  const elementFieldType = mapEvmParamTypeToFieldType(elementType);
2313
+ const elementBytesSize = extractBytesSize(elementType);
2293
2314
  const arrayField = {
2294
2315
  ...baseField,
2295
2316
  elementType: elementFieldType,
@@ -2300,7 +2321,11 @@ function generateEvmDefaultField(parameter) {
2300
2321
  elementType,
2301
2322
  EVM_NUMERIC_BOUNDS
2302
2323
  ),
2303
- placeholder: `Enter ${elementType}`
2324
+ placeholder: `Enter ${elementType}`,
2325
+ // Include exactBytes metadata for fixed-size bytes array elements (e.g., bytes32[])
2326
+ ...elementBytesSize !== void 0 && {
2327
+ metadata: { exactBytes: elementBytesSize }
2328
+ }
2304
2329
  }
2305
2330
  };
2306
2331
  return arrayField;