Ver código fonte

chore(api-reference) Fix Input fieulds (#2994)

* chore(api-reference) Fix Input fieulds

* update

* update
Aditya Arora 2 meses atrás
pai
commit
08f2c371c7

+ 5 - 0
apps/api-reference/src/apis/evm/parse-price-feed-updates-unique.tsx

@@ -53,6 +53,8 @@ export const parsePriceFeedUpdatesUnique = writeApi<
       type: ParameterType.HexArray,
       description:
         "The price update data for the contract to verify. Fetch this data from [Hermes API](https://hermes.pyth.network/docs/#/rest/latest_price_updates).",
+      defaultValue:
+        "0x504e41550100000003b801000000040d00cea20e5677f66ed178e9410ddd8280617c06921916e8fd4b71e597d7f6c6d0a14daf3bb3e1a0d8c9e051c8d0................",
     },
     {
       name: "priceId",
@@ -63,17 +65,20 @@ export const parsePriceFeedUpdatesUnique = writeApi<
       name: "minPublishTime",
       type: ParameterType.Int,
       description: "The minimum timestamp for each returned feed.",
+      defaultValue: "1721765108",
     },
     {
       name: "maxPublishTime",
       type: ParameterType.Int,
       description: "The maximum timestamp for each returned feed.",
+      defaultValue: "1721765108",
     },
     {
       name: "fee",
       type: ParameterType.Int,
       description:
         "The update fee in wei. This fee is sent as the value of the transaction.",
+      defaultValue: "1",
     },
   ],
   valueParam: "fee",

+ 5 - 0
apps/api-reference/src/apis/evm/parse-price-feed-updates.tsx

@@ -48,6 +48,8 @@ export const parsePriceFeedUpdates = writeApi<
       type: ParameterType.HexArray,
       description:
         "The price update data for the contract to verify. Fetch this data from [Hermes API](https://hermes.pyth.network/docs/#/rest/latest_price_updates).",
+      defaultValue:
+        "0x504e41550100000003b801000000040d00cea20e5677f66ed178e9410ddd8280617c06921916e8fd4b71e597d7f6c6d0a14daf3bb3e1a0d8c9e051c8d0................",
     },
     {
       name: "priceId",
@@ -58,17 +60,20 @@ export const parsePriceFeedUpdates = writeApi<
       name: "minPublishTime",
       type: ParameterType.Int,
       description: "The minimum timestamp for each returned feed.",
+      defaultValue: "1721765108",
     },
     {
       name: "maxPublishTime",
       type: ParameterType.Int,
       description: "The maximum timestamp for each returned feed.",
+      defaultValue: "1721765108",
     },
     {
       name: "fee",
       type: ParameterType.Int,
       description:
         "The update fee in wei. This fee is sent as the value of the transaction.",
+      defaultValue: "1",
     },
   ],
   valueParam: "fee",

+ 4 - 0
apps/api-reference/src/apis/evm/update-price-feeds-if-necessary.tsx

@@ -48,6 +48,8 @@ export const updatePriceFeedsIfNecessary = writeApi<
       type: ParameterType.HexArray,
       description:
         "The price update data for the contract to verify. Fetch this data from [Hermes API](https://hermes.pyth.network/docs/#/rest/latest_price_updates).",
+      defaultValue:
+        "0x504e41550100000003b801000000040d00cea20e5677f66ed178e9410ddd8280617c06921916e8fd4b71e597d7f6c6d0a14daf3bb3e1a0d8c9e051c8d0................",
     },
     {
       name: "priceId",
@@ -59,12 +61,14 @@ export const updatePriceFeedsIfNecessary = writeApi<
       type: ParameterType.IntArray,
       description:
         "The timestamp for each price id that determines whether to apply the update.",
+      defaultValue: "1721765108",
     },
     {
       name: "fee",
       type: ParameterType.Int,
       description:
         "The update fee in wei. This fee is sent as the value of the transaction.",
+      defaultValue: "1",
     },
   ],
   valueParam: "fee",

+ 3 - 0
apps/api-reference/src/apis/evm/update-price-feeds.tsx

@@ -39,12 +39,15 @@ export const updatePriceFeeds = writeApi<"updateData" | "fee">({
       type: ParameterType.HexArray,
       description:
         "The price update data for the contract to verify. Fetch this data from [Hermes API](https://hermes.pyth.network/docs/#/rest/latest_price_updates).",
+      defaultValue:
+        "0x504e41550100000003b801000000040d00cea20e5677f66ed178e9410ddd8280617c06921916e8fd4b71e597d7f6c6d0a14daf3bb3e1a0d8c9e051c8d0................",
     },
     {
       name: "fee",
       type: ParameterType.Int,
       description:
         "The update fee in **wei**. This fee is sent as the value of the transaction.",
+      defaultValue: "1",
     },
   ],
   valueParam: "fee",

+ 3 - 3
apps/api-reference/src/components/EvmApi/parameter-input.tsx

@@ -13,10 +13,10 @@ import { useState, useCallback, useMemo, useEffect } from "react";
 
 import type { Parameter } from "./parameter";
 import {
-  PLACEHOLDERS,
   isValid,
   getValidationError,
   ParameterType,
+  getPlaceHolder,
 } from "./parameter";
 import type { PriceFeed } from "../../use-price-feed-list";
 import {
@@ -93,7 +93,7 @@ const PriceFeedIdInput = <ParameterName extends string>({
         validationError={validationError}
         label={spec.name}
         description={<Markdown inline>{spec.description}</Markdown>}
-        placeholder={PLACEHOLDERS[spec.type]}
+        placeholder={getPlaceHolder(spec)}
         required={true}
       />
       <div className="absolute right-0 top-0 z-50 mt-20 hidden w-full min-w-[34rem] overflow-hidden rounded-lg border border-neutral-400 bg-neutral-100 text-sm shadow focus-visible:border-pythpurple-600 focus-visible:outline-none group-data-[open]:block dark:border-neutral-600 dark:bg-neutral-800 dark:shadow-white/20 dark:focus-visible:border-pythpurple-400">
@@ -221,7 +221,7 @@ const DefaultParameterInput = <ParameterName extends string>({
       validationError={validationError}
       label={spec.name}
       description={<Markdown inline>{spec.description}</Markdown>}
-      placeholder={PLACEHOLDERS[spec.type]}
+      placeholder={getPlaceHolder(spec)}
       required={true}
       value={internalValue}
       onChange={onChangeInput}

+ 4 - 0
apps/api-reference/src/components/EvmApi/parameter.ts

@@ -2,6 +2,7 @@ export type Parameter<Name extends string> = {
   name: Name;
   type: ParameterType;
   description: string;
+  defaultValue?: string; // Optional default value for the parameter
 };
 
 export enum ParameterType {
@@ -21,6 +22,9 @@ export const TRANSFORMS: Partial<
   [ParameterType.IntArray]: (value) => [value],
 };
 
+export const getPlaceHolder = (parameter: Parameter<string>): string =>
+  parameter.defaultValue ?? PLACEHOLDERS[parameter.type];
+
 export const PLACEHOLDERS: Record<ParameterType, string> = {
   [ParameterType.PriceFeedId]:
     "0x1111111111111111111111111111111111111111111111111111111111111111",