Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add ipfs gateway #51

Closed
wants to merge 2 commits into from
Closed
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
17 changes: 15 additions & 2 deletions src/app/components/transaction.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,11 @@ import { BlockfrostProvider, deserializeAddress } from "@meshsdk/core";
import { Button, TextField, Box, Typography, Container, Table, TableBody, TableCell, TableContainer, TableRow, Paper } from "@mui/material";
import * as CLS from "@emurgo/cardano-serialization-lib-browser";
import ReactJsonPretty from 'react-json-pretty';
import * as dotenv from 'dotenv';

dotenv.config();

const NEXT_PUBLIC_REST_IPFS_GATEWAY = process.env.NEXT_PUBLIC_REST_IPFS_GATEWAY;

// Function to decode an unasigned transaction
const decodeTransaction = (unsignedTransactionHex: string) => {
Expand Down Expand Up @@ -34,6 +39,7 @@ export const TransactionButton = () => {
const [isInOutputPlutusData , setIsInOutputPlutusData] = useState(false);
const [voteResult, setVoteResult] = useState<string>();
const [voteID, setVoteID] = useState<string>();
const [voterType, setVoterType] = useState<string>();
const [cardanoscan, setCardanoscan] = useState<string>();
const [metadataAnchorURL, setmetadataAnchorURL] = useState<string>();
const [metadataAnchorHash, setMetadataAnchorHash] = useState<string>();
Expand All @@ -49,6 +55,7 @@ export const TransactionButton = () => {
setIsInOutputPlutusData(false);
setVoteResult("");
setVoteID("");
setVoterType("");
setMessage("Please connect your wallet first.");
return;
}
Expand Down Expand Up @@ -125,6 +132,7 @@ export const TransactionButton = () => {
console.log("voterJSON:", voterJSON);
let script;
// Function to check if the voterJSON has ConstitutionalCommitteeHotCred to avoid type error
// Check voter type
function isConstitutionalCommitteeHotCred(voter: CLS.VoterJSON): voter is { ConstitutionalCommitteeHotCred: { Script: string } } {
return (voter as { ConstitutionalCommitteeHotCred: any }).ConstitutionalCommitteeHotCred !== undefined;
}
Expand All @@ -133,6 +141,7 @@ export const TransactionButton = () => {
// If it has ConstitutionalCommitteeHotCred, extract the Script hex
const credType = voterJSON.ConstitutionalCommitteeHotCred;
script = credType.Script;
setVoterType("Constitutional Committee");
console.log("ConstitutionalCommitteeHotCred Script:", script);

}
Expand Down Expand Up @@ -306,9 +315,13 @@ export const TransactionButton = () => {
<TableCell sx={{ fontWeight: "bold" }}>Vote Choice </TableCell>
<TableCell>{voteResult}</TableCell>
</TableRow>
<TableRow>
<TableCell sx={{ fontWeight: "bold" }}>Voter Type </TableCell>
<TableCell>{voterType}</TableCell>
</TableRow>
<TableRow>
<TableCell sx={{ fontWeight: "bold" }}>Metadata Anchor URL</TableCell>
<TableCell><a href={metadataAnchorURL} target="_blank">{metadataAnchorURL}</a></TableCell>
<TableCell><a href={`https://${NEXT_PUBLIC_REST_IPFS_GATEWAY}${metadataAnchorURL?.slice(7)}`} target="_blank">{metadataAnchorURL}</a></TableCell>
</TableRow>
<TableRow>
<TableCell sx={{ fontWeight: "bold" }}>Metadata Anchor Hash</TableCell>
Expand Down Expand Up @@ -383,4 +396,4 @@ export const TransactionButton = () => {


);
};
};