Skip to content

Commit 0739404

Browse files
committed
Merge remote-tracking branch 'origin/main' into bduran/dual-publish
2 parents 16495c4 + eb3eedf commit 0739404

File tree

16 files changed

+131
-259
lines changed

16 files changed

+131
-259
lines changed

Cargo.lock

Lines changed: 14 additions & 14 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

apps/entropy-explorer/src/components/Home/request-drawer.tsx

Lines changed: 50 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import { StatCard } from "@pythnetwork/component-library/StatCard";
99
import { Table } from "@pythnetwork/component-library/Table";
1010
import { Term } from "@pythnetwork/component-library/Term";
1111
import type { OpenDrawerArgs } from "@pythnetwork/component-library/useDrawer";
12+
import type { ComponentProps } from "react";
1213
import { useNumberFormatter } from "react-aria";
1314
import TimeAgo from "react-timeago";
1415

@@ -75,7 +76,7 @@ const RequestDrawerBody = ({
7576
<CallbackErrorInfo request={request} />
7677
)}
7778
{request.status === Status.Failed && (
78-
<RevealFailedInfo request={request} />
79+
<FailureInfo header="Reveal failed!" request={request} />
7980
)}
8081
<Table
8182
label="Details"
@@ -253,28 +254,7 @@ const CallbackErrorInfo = ({ request }: { request: CallbackErrorRequest }) => {
253254

254255
return (
255256
<>
256-
<InfoBox
257-
header="Callback failed!"
258-
icon={<Warning />}
259-
className={styles.message}
260-
variant="warning"
261-
>
262-
<Button
263-
hideText
264-
beforeIcon={<Question />}
265-
rounded
266-
size="sm"
267-
variant="ghost"
268-
className={styles.helpButton ?? ""}
269-
href={getHelpLink(request.returnValue)}
270-
target="_blank"
271-
>
272-
Help
273-
</Button>
274-
<div className={styles.failureMessage}>
275-
<FailureMessage reason={request.returnValue} />
276-
</div>
277-
</InfoBox>
257+
<FailureInfo header="Callback failed!" request={request} />
278258
<InfoBox
279259
header="Retry the callback yourself"
280260
icon={<Code />}
@@ -311,12 +291,17 @@ const CallbackErrorInfo = ({ request }: { request: CallbackErrorRequest }) => {
311291
);
312292
};
313293

314-
const RevealFailedInfo = ({ request }: { request: FailedRequest }) => (
294+
const FailureInfo = ({
295+
request,
296+
...props
297+
}: ComponentProps<typeof InfoBox> & {
298+
request: CallbackErrorRequest | FailedRequest;
299+
}) => (
315300
<InfoBox
316-
header="Reveal failed!"
317301
icon={<Warning />}
318302
className={styles.message}
319303
variant="warning"
304+
{...props}
320305
>
321306
<Button
322307
hideText
@@ -325,37 +310,55 @@ const RevealFailedInfo = ({ request }: { request: FailedRequest }) => (
325310
size="sm"
326311
variant="ghost"
327312
className={styles.helpButton ?? ""}
328-
href={getHelpLink(request.reason)}
313+
href={getHelpLink(request)}
329314
target="_blank"
330315
>
331316
Help
332317
</Button>
333318
<div className={styles.failureMessage}>
334-
<FailureMessage reason={request.reason} />
319+
<FailureMessage request={request} />
335320
</div>
336321
</InfoBox>
337322
);
338323

339-
const getHelpLink = (reason: string) => {
340-
const details = getErrorDetails(reason);
341-
return (
342-
details?.[2] ??
343-
"https://docs.pyth.network/entropy/best-practices#handling-callback-failures"
344-
);
324+
const getHelpLink = (request: CallbackErrorRequest | FailedRequest) => {
325+
const details = getErrorDetails(request.reason);
326+
if (details === undefined) {
327+
return isGasLimitExceeded(request)
328+
? "https://docs.pyth.network/entropy/best-practices#limit-gas-usage-on-the-callback"
329+
: "https://docs.pyth.network/entropy/best-practices#handling-callback-failures";
330+
} else {
331+
return details[2];
332+
}
345333
};
346334

347-
const FailureMessage = ({ reason }: { reason: string }) => {
348-
const details = getErrorDetails(reason);
349-
return details ? (
350-
<>
351-
<p>The callback encountered the following error:</p>
352-
<p className={styles.details}>
353-
<b>{details[0]}</b> (<code>{reason}</code>): {details[1]}
354-
</p>
355-
</>
356-
) : (
357-
<>
358-
<b>Error response:</b> {reason}
359-
</>
360-
);
335+
const FailureMessage = ({
336+
request,
337+
}: {
338+
request: CallbackErrorRequest | FailedRequest;
339+
}) => {
340+
const details = getErrorDetails(request.reason);
341+
if (details) {
342+
return (
343+
<>
344+
<p>The callback encountered the following error:</p>
345+
<p className={styles.details}>
346+
<b>{details[0]}</b> (<code>{request.reason}</code>): {details[1]}
347+
</p>
348+
</>
349+
);
350+
} else if (isGasLimitExceeded(request)) {
351+
return "The callback used more gas than the set gas limit";
352+
} else {
353+
return (
354+
<>
355+
<b>Error response:</b> {request.reason}
356+
</>
357+
);
358+
}
361359
};
360+
361+
const isGasLimitExceeded = (request: CallbackErrorRequest | FailedRequest) =>
362+
request.status === Status.CallbackError &&
363+
request.reason === "0x" &&
364+
request.gasUsed > request.gasLimit;

apps/entropy-explorer/src/requests.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ export const getRequests = async ({
8686
return request.state.callback_failed
8787
? Request.CallbackErrored({
8888
...completedCommon,
89-
returnValue: request.state.callback_return_value,
89+
reason: request.state.callback_return_value,
9090
})
9191
: Request.Complete({
9292
...completedCommon,
@@ -244,7 +244,7 @@ type CompletedArgs = BaseArgs & {
244244
callbackTxHash: `0x${string}`;
245245
};
246246
type CallbackErrorArgs = CompletedArgs & {
247-
returnValue: string;
247+
reason: string;
248248
};
249249

250250
const Request = {

apps/insights/src/components/Root/index.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ import {
1010
GOOGLE_ANALYTICS_ID,
1111
} from "../../config/server";
1212
import { getPublishersWithRankings } from "../../get-publishers-with-rankings";
13-
import { LivePriceDataProvider } from "../../hooks/use-live-price-data";
1413
import { Cluster } from "../../services/pyth";
1514
import { getFeeds } from "../../services/pyth/get-feeds";
1615
import { PriceFeedIcon } from "../PriceFeedIcon";
@@ -32,7 +31,7 @@ export const Root = ({ children }: Props) => (
3231
amplitudeApiKey={AMPLITUDE_API_KEY}
3332
googleAnalyticsId={GOOGLE_ANALYTICS_ID}
3433
enableAccessibilityReporting={ENABLE_ACCESSIBILITY_REPORTING}
35-
providers={[NuqsAdapter, LivePriceDataProvider]}
34+
providers={[NuqsAdapter]}
3635
tabs={TABS}
3736
extraCta={<SearchButton />}
3837
>

0 commit comments

Comments
 (0)