Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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................",
Comment on lines +56 to +57
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

curious whats this

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is updateData / signed message/ VAA from our hermes. This is just a hardcoded example.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about we add a comment in the code ?

},
{
name: "priceId",
Expand All @@ -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",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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",
Expand Down
3 changes: 3 additions & 0 deletions apps/api-reference/src/apis/evm/update-price-feeds.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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">
Expand Down Expand Up @@ -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}
Expand Down
4 changes: 4 additions & 0 deletions apps/api-reference/src/components/EvmApi/parameter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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",
Expand Down
Loading