@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.cjs CHANGED
@@ -2514,6 +2514,7 @@ var WagmiWalletImplementation = class {
2514
2514
  __publicField(this, "unsubscribe");
2515
2515
  __publicField(this, "initialized", false);
2516
2516
  __publicField(this, "walletConnectProjectId");
2517
+ __publicField(this, "rpcConfigUnsubscribe");
2517
2518
  this.walletConnectProjectId = walletConnectProjectIdFromAppConfig;
2518
2519
  import_ui_builder_utils15.logger.info(
2519
2520
  LOG_SYSTEM,
@@ -2525,6 +2526,39 @@ var WagmiWalletImplementation = class {
2525
2526
  LOG_SYSTEM,
2526
2527
  "WagmiWalletImplementation instance initialized (Wagmi config creation deferred)."
2527
2528
  );
2529
+ this.setupRpcConfigListener();
2530
+ }
2531
+ /**
2532
+ * Sets up a listener for RPC configuration changes to invalidate the cached Wagmi config
2533
+ * when user changes RPC settings.
2534
+ */
2535
+ setupRpcConfigListener() {
2536
+ import("@openzeppelin/ui-builder-utils").then(({ userRpcConfigService }) => {
2537
+ this.rpcConfigUnsubscribe = userRpcConfigService.subscribe("*", (event) => {
2538
+ if (event.type === "rpc-config-changed" || event.type === "rpc-config-cleared") {
2539
+ import_ui_builder_utils15.logger.info(
2540
+ LOG_SYSTEM,
2541
+ `RPC config changed for network ${event.networkId}. Invalidating cached Wagmi config.`
2542
+ );
2543
+ this.defaultInstanceConfig = null;
2544
+ }
2545
+ });
2546
+ }).catch((error) => {
2547
+ import_ui_builder_utils15.logger.error(LOG_SYSTEM, "Failed to setup RPC config listener:", error);
2548
+ });
2549
+ }
2550
+ /**
2551
+ * Cleanup method to unsubscribe from RPC config changes
2552
+ */
2553
+ cleanup() {
2554
+ if (this.rpcConfigUnsubscribe) {
2555
+ this.rpcConfigUnsubscribe();
2556
+ this.rpcConfigUnsubscribe = void 0;
2557
+ }
2558
+ if (this.unsubscribe) {
2559
+ this.unsubscribe();
2560
+ this.unsubscribe = void 0;
2561
+ }
2528
2562
  }
2529
2563
  /**
2530
2564
  * Sets the externally determined, currently active WagmiConfig instance.
@@ -2706,7 +2740,9 @@ var WagmiWalletImplementation = class {
2706
2740
  "getActiveConfigForManager: RainbowKit config failed, falling back to default."
2707
2741
  );
2708
2742
  }
2709
- this.defaultInstanceConfig = this.createDefaultConfig();
2743
+ if (!this.defaultInstanceConfig) {
2744
+ this.defaultInstanceConfig = this.createDefaultConfig();
2745
+ }
2710
2746
  return this.defaultInstanceConfig;
2711
2747
  }
2712
2748
  /**
@@ -4218,6 +4254,16 @@ function extractArrayElementType(parameterType) {
4218
4254
  function getDefaultValidation() {
4219
4255
  return { required: true };
4220
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
+ };
4221
4267
  function generateEvmDefaultField(parameter) {
4222
4268
  const fieldType = mapEvmParamTypeToFieldType(parameter.type);
4223
4269
  const baseField = {
@@ -4229,7 +4275,11 @@ function generateEvmDefaultField(parameter) {
4229
4275
  placeholder: `Enter ${parameter.displayName || parameter.name || parameter.type}`,
4230
4276
  helperText: parameter.description || "",
4231
4277
  defaultValue: (0, import_ui_builder_utils30.getDefaultValueForType)(fieldType),
4232
- validation: getDefaultValidation(),
4278
+ validation: (0, import_ui_builder_utils30.enhanceNumericValidation)(
4279
+ getDefaultValidation(),
4280
+ parameter.type,
4281
+ EVM_NUMERIC_BOUNDS
4282
+ ),
4233
4283
  width: "full"
4234
4284
  };
4235
4285
  if (fieldType === "array") {
@@ -4241,7 +4291,11 @@ function generateEvmDefaultField(parameter) {
4241
4291
  elementType: elementFieldType,
4242
4292
  elementFieldConfig: {
4243
4293
  type: elementFieldType,
4244
- validation: getDefaultValidation(),
4294
+ validation: (0, import_ui_builder_utils30.enhanceNumericValidation)(
4295
+ getDefaultValidation(),
4296
+ elementType,
4297
+ EVM_NUMERIC_BOUNDS
4298
+ ),
4245
4299
  placeholder: `Enter ${elementType}`
4246
4300
  }
4247
4301
  };