@openzeppelin/ui-builder-adapter-evm 0.15.0 → 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.js CHANGED
@@ -2544,6 +2544,7 @@ var WagmiWalletImplementation = class {
2544
2544
  __publicField(this, "unsubscribe");
2545
2545
  __publicField(this, "initialized", false);
2546
2546
  __publicField(this, "walletConnectProjectId");
2547
+ __publicField(this, "rpcConfigUnsubscribe");
2547
2548
  this.walletConnectProjectId = walletConnectProjectIdFromAppConfig;
2548
2549
  logger11.info(
2549
2550
  LOG_SYSTEM,
@@ -2555,6 +2556,39 @@ var WagmiWalletImplementation = class {
2555
2556
  LOG_SYSTEM,
2556
2557
  "WagmiWalletImplementation instance initialized (Wagmi config creation deferred)."
2557
2558
  );
2559
+ this.setupRpcConfigListener();
2560
+ }
2561
+ /**
2562
+ * Sets up a listener for RPC configuration changes to invalidate the cached Wagmi config
2563
+ * when user changes RPC settings.
2564
+ */
2565
+ setupRpcConfigListener() {
2566
+ import("@openzeppelin/ui-builder-utils").then(({ userRpcConfigService }) => {
2567
+ this.rpcConfigUnsubscribe = userRpcConfigService.subscribe("*", (event) => {
2568
+ if (event.type === "rpc-config-changed" || event.type === "rpc-config-cleared") {
2569
+ logger11.info(
2570
+ LOG_SYSTEM,
2571
+ `RPC config changed for network ${event.networkId}. Invalidating cached Wagmi config.`
2572
+ );
2573
+ this.defaultInstanceConfig = null;
2574
+ }
2575
+ });
2576
+ }).catch((error) => {
2577
+ logger11.error(LOG_SYSTEM, "Failed to setup RPC config listener:", error);
2578
+ });
2579
+ }
2580
+ /**
2581
+ * Cleanup method to unsubscribe from RPC config changes
2582
+ */
2583
+ cleanup() {
2584
+ if (this.rpcConfigUnsubscribe) {
2585
+ this.rpcConfigUnsubscribe();
2586
+ this.rpcConfigUnsubscribe = void 0;
2587
+ }
2588
+ if (this.unsubscribe) {
2589
+ this.unsubscribe();
2590
+ this.unsubscribe = void 0;
2591
+ }
2558
2592
  }
2559
2593
  /**
2560
2594
  * Sets the externally determined, currently active WagmiConfig instance.
@@ -2736,7 +2770,9 @@ var WagmiWalletImplementation = class {
2736
2770
  "getActiveConfigForManager: RainbowKit config failed, falling back to default."
2737
2771
  );
2738
2772
  }
2739
- this.defaultInstanceConfig = this.createDefaultConfig();
2773
+ if (!this.defaultInstanceConfig) {
2774
+ this.defaultInstanceConfig = this.createDefaultConfig();
2775
+ }
2740
2776
  return this.defaultInstanceConfig;
2741
2777
  }
2742
2778
  /**
@@ -4255,7 +4291,10 @@ function getEvmCompatibleFieldTypes(parameterType) {
4255
4291
 
4256
4292
  // src/mapping/field-generator.ts
4257
4293
  import { startCase } from "lodash";
4258
- import { getDefaultValueForType } from "@openzeppelin/ui-builder-utils";
4294
+ import {
4295
+ enhanceNumericValidation,
4296
+ getDefaultValueForType
4297
+ } from "@openzeppelin/ui-builder-utils";
4259
4298
  function extractArrayElementType(parameterType) {
4260
4299
  const arrayMatch = parameterType.match(/^(.+)\[\d*\]$/);
4261
4300
  if (arrayMatch) {
@@ -4266,6 +4305,16 @@ function extractArrayElementType(parameterType) {
4266
4305
  function getDefaultValidation() {
4267
4306
  return { required: true };
4268
4307
  }
4308
+ var EVM_NUMERIC_BOUNDS = {
4309
+ uint: { min: 0 },
4310
+ uint8: { min: 0, max: 255 },
4311
+ uint16: { min: 0, max: 65535 },
4312
+ uint32: { min: 0, max: 4294967295 },
4313
+ int: {},
4314
+ int8: { min: -128, max: 127 },
4315
+ int16: { min: -32768, max: 32767 },
4316
+ int32: { min: -2147483648, max: 2147483647 }
4317
+ };
4269
4318
  function generateEvmDefaultField(parameter) {
4270
4319
  const fieldType = mapEvmParamTypeToFieldType(parameter.type);
4271
4320
  const baseField = {
@@ -4277,7 +4326,11 @@ function generateEvmDefaultField(parameter) {
4277
4326
  placeholder: `Enter ${parameter.displayName || parameter.name || parameter.type}`,
4278
4327
  helperText: parameter.description || "",
4279
4328
  defaultValue: getDefaultValueForType(fieldType),
4280
- validation: getDefaultValidation(),
4329
+ validation: enhanceNumericValidation(
4330
+ getDefaultValidation(),
4331
+ parameter.type,
4332
+ EVM_NUMERIC_BOUNDS
4333
+ ),
4281
4334
  width: "full"
4282
4335
  };
4283
4336
  if (fieldType === "array") {
@@ -4289,7 +4342,11 @@ function generateEvmDefaultField(parameter) {
4289
4342
  elementType: elementFieldType,
4290
4343
  elementFieldConfig: {
4291
4344
  type: elementFieldType,
4292
- validation: getDefaultValidation(),
4345
+ validation: enhanceNumericValidation(
4346
+ getDefaultValidation(),
4347
+ elementType,
4348
+ EVM_NUMERIC_BOUNDS
4349
+ ),
4293
4350
  placeholder: `Enter ${elementType}`
4294
4351
  }
4295
4352
  };