Skip to content

Commit

Permalink
!fix: decoder api
Browse files Browse the repository at this point in the history
  • Loading branch information
jagnani73 committed Feb 18, 2024
1 parent 28c112d commit a78f67f
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,14 @@ const meta: Meta<typeof DecodedTransactionComponent> = {
title: "Molecules",
component: DecodedTransactionComponent,
argTypes: {
setMetadata: {
setTxMetadata: {
control: false,
table: {
disable: true,
},
},
},
render: ({ chain_name, tx_hash, setMetadata }) => (
render: ({ chain_name, tx_hash, setTxMetadata }) => (
<section>
<div className="mb-8">
<TypographyH1>Decoded Transaction</TypographyH1>
Expand All @@ -24,7 +24,7 @@ const meta: Meta<typeof DecodedTransactionComponent> = {
<DecodedTransactionComponent
chain_name={chain_name}
tx_hash={tx_hash}
setMetadata={setMetadata}
setTxMetadata={setTxMetadata}
/>
</section>
),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import { Address } from "@/components/Atoms/Address/Address";
export const DecodedTransaction: React.FC<DecodedTransactionProps> = ({
chain_name,
tx_hash,
setMetadata,
setTxMetadata,
}) => {
const { apikey, chains } = useCovalent();

Expand Down Expand Up @@ -48,8 +48,8 @@ export const DecodedTransaction: React.FC<DecodedTransactionProps> = ({
try {
setResult(None);
setErrorMessage(null);
if (setMetadata) {
setMetadata(None);
if (setTxMetadata) {
setTxMetadata(None);
}
const response = await fetch(
"https://goldrush-decoder.vercel.app/api/v1/tx/decode",
Expand All @@ -69,21 +69,21 @@ export const DecodedTransaction: React.FC<DecodedTransactionProps> = ({
success: boolean;
message?: string;
events?: DecodedEventType[];
metadata: DecodedTransactionMetadata | null;
tx_metadata: DecodedTransactionMetadata | null;
};
if (!data.success) {
setErrorMessage(data.message as string);
throw Error(data.message);
}
setResult(new Some(data.events!));
if (setMetadata) {
setMetadata(new Some(data.metadata));
if (setTxMetadata) {
setTxMetadata(new Some(data.tx_metadata));
}
} catch (exception) {
console.error(exception);
setResult(new Some([]));
if (setMetadata) {
setMetadata(new Some(null));
if (setTxMetadata) {
setTxMetadata(new Some(null));
}
}
})();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ export const TransactionReceiptView: React.FC<TransactionReceiptViewProps> = ({
<DecodedTransaction
chain_name={chain_name}
tx_hash={tx_hash}
setMetadata={setResult}
setTxMetadata={setResult}
/>

{maybeResult.match({
Expand Down
2 changes: 1 addition & 1 deletion src/utils/types/molecules.types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ export interface XYKWalletInformationProps {
export interface DecodedTransactionProps {
chain_name: Chain;
tx_hash: string;
setMetadata?: React.Dispatch<
setTxMetadata?: React.Dispatch<
React.SetStateAction<Option<DecodedTransactionMetadata | null>>
>;
}
Expand Down

0 comments on commit a78f67f

Please sign in to comment.