Skip to content

Commit

Permalink
add fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
jeesunikim committed Jul 30, 2024
1 parent 8292fb6 commit 3453e72
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 9 deletions.
20 changes: 15 additions & 5 deletions src/app/(sidebar)/endpoints/[[...pages]]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -138,19 +138,29 @@ export default function Endpoints() {
case Routes.ENDPOINTS_GET_EVENTS: {
const filteredParams = params.filters ? JSON.parse(params.filters) : {};

// do not display the empty string unless its field is filled
const filteredContractIds = filteredParams.contract_ids.filter(
(topic: string) => topic.length,
);
// [filter] do not display the empty string unless its field is filled
// [map] Parse the JSON string to JSON
const filteredTopics = filteredParams.topics
.filter((topic: string) => topic.length)
.map((item: string) => JSON.parse(item));

return {
...defaultRpcRequestBody,
params: {
startLedger: Number(params.ledger),
startLedger: Number(params.startLedger),
pagination: {
cursor: params.cursor,
limit: Number(params.limit) || undefined,
},
filters: [
{
type: filteredParams.type ?? "",
contractIds: filteredParams.contract_ids ?? "",
topics: filteredParams.topics ?? "",
contractIds: filteredContractIds ?? "",
topics: filteredTopics ?? [],
},
],
},
Expand Down Expand Up @@ -179,7 +189,7 @@ export default function Endpoints() {
return {
...defaultRpcRequestBody,
params: {
startLedger: Number(params.ledger),
startLedger: Number(params.startLedger),
pagination: {
cursor: params.cursor,
limit: Number(params.limit) || undefined,
Expand All @@ -203,7 +213,7 @@ export default function Endpoints() {
params: {
transaction: params.tx ?? "",
resourceConfig: {
instructionLeeway: params.resourceConfig,
instructionLeeway: Number(params.resourceConfig) || undefined,
},
},
};
Expand Down
16 changes: 16 additions & 0 deletions src/components/formComponentTemplateEndpoints.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -370,6 +370,22 @@ export const formComponentTemplateEndpoints = (
),
validate: validate.getPositiveIntError,
};
case "startLedger":
return {
render: (templ: TemplateRenderProps) => (
<PositiveIntPicker
key={id}
id={id}
label="Start Ledger Sequence"
placeholder="Ex: 1714814"
labelSuffix={!templ.isRequired ? "optional" : undefined}
value={templ.value || ""}
error={templ.error}
onChange={templ.onChange}
/>
),
validate: validate.getPositiveIntError,
};
case "limit":
return {
render: (templ: TemplateRenderProps) => (
Expand Down
8 changes: 4 additions & 4 deletions src/constants/endpointsPages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,9 @@ export const ENDPOINTS_PAGES_RPC: EndpointsPagesProps = {
docsUrl:
"https://developers.stellar.org/docs/data/rpc/api-reference/methods/getEvents",
docsLabel: "getEvents",
endpointUrlTemplate: "{?ledger,cursor,limit,filters}",
endpointUrlTemplate: "{?startLedger,cursor,limit,filters}",
requestMethod: "POST",
requiredParams: "ledger,filters",
requiredParams: "startLedger,filters",
rpcMethod: "getEvents",
isStreaming: false,
},
Expand Down Expand Up @@ -133,9 +133,9 @@ export const ENDPOINTS_PAGES_RPC: EndpointsPagesProps = {
docsUrl:
"https://developers.stellar.org/docs/data/rpc/api-reference/methods/getTransactions",
docsLabel: "getTransactions",
endpointUrlTemplate: "{?ledger,cursor,limit}",
endpointUrlTemplate: "{?startLedger,cursor,limit}",
requestMethod: "POST",
requiredParams: "ledger",
requiredParams: "startLedger",
rpcMethod: "getTransactions",
isStreaming: false,
},
Expand Down

0 comments on commit 3453e72

Please sign in to comment.