@openzeppelin/ui-builder-adapter-evm 0.15.1 → 0.16.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 CHANGED
@@ -4254,6 +4254,16 @@ function extractArrayElementType(parameterType) {
4254
4254
  function getDefaultValidation() {
4255
4255
  return { required: true };
4256
4256
  }
4257
+ var EVM_NUMERIC_BOUNDS = {
4258
+ uint: { min: 0 },
4259
+ uint8: { min: 0, max: 255 },
4260
+ uint16: { min: 0, max: 65535 },
4261
+ uint32: { min: 0, max: 4294967295 },
4262
+ int: {},
4263
+ int8: { min: -128, max: 127 },
4264
+ int16: { min: -32768, max: 32767 },
4265
+ int32: { min: -2147483648, max: 2147483647 }
4266
+ };
4257
4267
  function generateEvmDefaultField(parameter) {
4258
4268
  const fieldType = mapEvmParamTypeToFieldType(parameter.type);
4259
4269
  const baseField = {
@@ -4265,7 +4275,11 @@ function generateEvmDefaultField(parameter) {
4265
4275
  placeholder: `Enter ${parameter.displayName || parameter.name || parameter.type}`,
4266
4276
  helperText: parameter.description || "",
4267
4277
  defaultValue: (0, import_ui_builder_utils30.getDefaultValueForType)(fieldType),
4268
- validation: getDefaultValidation(),
4278
+ validation: (0, import_ui_builder_utils30.enhanceNumericValidation)(
4279
+ getDefaultValidation(),
4280
+ parameter.type,
4281
+ EVM_NUMERIC_BOUNDS
4282
+ ),
4269
4283
  width: "full"
4270
4284
  };
4271
4285
  if (fieldType === "array") {
@@ -4277,7 +4291,11 @@ function generateEvmDefaultField(parameter) {
4277
4291
  elementType: elementFieldType,
4278
4292
  elementFieldConfig: {
4279
4293
  type: elementFieldType,
4280
- validation: getDefaultValidation(),
4294
+ validation: (0, import_ui_builder_utils30.enhanceNumericValidation)(
4295
+ getDefaultValidation(),
4296
+ elementType,
4297
+ EVM_NUMERIC_BOUNDS
4298
+ ),
4281
4299
  placeholder: `Enter ${elementType}`
4282
4300
  }
4283
4301
  };