From 7a585e5a706f7d0ee4d6b946c5c9dffd0532924b Mon Sep 17 00:00:00 2001 From: Elena Bardho Date: Thu, 20 Feb 2025 12:29:53 +0000 Subject: [PATCH 1/3] Change the data structure of the .signature file --- src/app/components/downloadFiles.tsx | 40 ++++++++++++++++++++++++++++ src/app/components/transaction.tsx | 8 ++++-- 2 files changed, 46 insertions(+), 2 deletions(-) create mode 100644 src/app/components/downloadFiles.tsx diff --git a/src/app/components/downloadFiles.tsx b/src/app/components/downloadFiles.tsx new file mode 100644 index 0000000..5d3f3e9 --- /dev/null +++ b/src/app/components/downloadFiles.tsx @@ -0,0 +1,40 @@ +import { Button } from '@mui/material'; +import React from 'react'; + +const downloadFile = (data : any, filename : string , fileExtension = "json") => { + const jsonString = JSON.stringify(data, null, 2); + const blob = new Blob([jsonString], { type: 'application/json' }); + const href = URL.createObjectURL(blob); + const link = document.createElement('a'); + link.href = href; + link.download = `${filename}.${fileExtension}`; + document.body.appendChild(link); + link.click(); + + // Cleanup + document.body.removeChild(link); + URL.revokeObjectURL(data); +}; + +const downloadSigniture = (govActionID : string, signature : string) => { + const data = { + type: "Unwitnessed Tx ConwayEra", + description: "Ledger Cddl Format", + govActionID, + cborHex: signature + }; + downloadFile(data, "vote", "signature"); +} + +interface DownloadButtonProps { + govActionID: string; + signature: string; + } + +export default function DownloadButton({ govActionID, signature }: DownloadButtonProps) { + return ; + } + \ No newline at end of file diff --git a/src/app/components/transaction.tsx b/src/app/components/transaction.tsx index 0cc3cda..c999bb7 100644 --- a/src/app/components/transaction.tsx +++ b/src/app/components/transaction.tsx @@ -5,11 +5,12 @@ import { useWallet } from "@meshsdk/react"; import { deserializeAddress } from "@meshsdk/core"; import { Button, TextField, Box, Typography, Container } from "@mui/material"; import * as CSL from "@emurgo/cardano-serialization-lib-browser"; -import ReactJsonPretty from 'react-json-pretty'; +import ReactJsonPretty from "react-json-pretty"; import * as txValidationUtils from "../utils/txValidationUtils"; import { TransactionChecks } from "./validationChecks"; -import { decodeHextoTx,convertGAToBech, getCardanoScanURL } from "../utils/txUtils"; +import {decodeHextoTx,convertGAToBech,getCardanoScanURL} from "../utils/txUtils"; import { VotingDetails } from "./votingDetails"; +import DownloadButton from "./downloadFiles"; export const TransactionButton = () => { const [message, setMessage] = useState(""); @@ -298,6 +299,9 @@ export const TransactionButton = () => { > {signature} + + + )} From aae637a00919ea320f6be02d295674aa6f3b8343 Mon Sep 17 00:00:00 2001 From: Elena Bardho Date: Thu, 20 Feb 2025 14:55:56 +0000 Subject: [PATCH 2/3] Modify code to add voter key hash on .signature file --- src/app/components/downloadFiles.tsx | 8 +++++--- src/app/components/transaction.tsx | 2 +- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/app/components/downloadFiles.tsx b/src/app/components/downloadFiles.tsx index 5d3f3e9..c7fcae5 100644 --- a/src/app/components/downloadFiles.tsx +++ b/src/app/components/downloadFiles.tsx @@ -16,11 +16,12 @@ const downloadFile = (data : any, filename : string , fileExtension = "json") => URL.revokeObjectURL(data); }; -const downloadSigniture = (govActionID : string, signature : string) => { +const downloadSignature = (govActionID : string, voterKeyHash : string , signature : string) => { const data = { type: "Unwitnessed Tx ConwayEra", description: "Ledger Cddl Format", govActionID, + voterKeyHash, cborHex: signature }; downloadFile(data, "vote", "signature"); @@ -28,13 +29,14 @@ const downloadSigniture = (govActionID : string, signature : string) => { interface DownloadButtonProps { govActionID: string; + voterKeyHash: string; signature: string; } -export default function DownloadButton({ govActionID, signature }: DownloadButtonProps) { +export default function DownloadButton({ govActionID, voterKeyHash, signature }: DownloadButtonProps) { return ; + onClick={() => downloadSignature(govActionID,voterKeyHash, signature)}>Download Signature; } \ No newline at end of file diff --git a/src/app/components/transaction.tsx b/src/app/components/transaction.tsx index c999bb7..375410f 100644 --- a/src/app/components/transaction.tsx +++ b/src/app/components/transaction.tsx @@ -300,7 +300,7 @@ export const TransactionButton = () => { {signature} - + )} From b6bc8ab2aa915366c24ed8680c08584276edc3e4 Mon Sep 17 00:00:00 2001 From: Elena Bardho Date: Thu, 20 Feb 2025 17:06:12 +0000 Subject: [PATCH 3/3] Remove placeholder for stake credential on download button --- src/app/components/transaction.tsx | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/app/components/transaction.tsx b/src/app/components/transaction.tsx index 375410f..c2d0551 100644 --- a/src/app/components/transaction.tsx +++ b/src/app/components/transaction.tsx @@ -23,6 +23,7 @@ export const TransactionButton = () => { const [cardanoscan, setCardanoscan] = useState(""); const [metadataAnchorURL, setMetadataAnchorURL] = useState(""); const [metadataAnchorHash, setMetadataAnchorHash] = useState(""); + const [stakeCredentialHash, setStakeCredentialHash] = useState(""); const [validationState, setValidationState] = useState({ isPartOfSigners: false, isOneVote: false, @@ -81,6 +82,7 @@ export const TransactionButton = () => { const changeAddress = await wallet.getChangeAddress(); const stakeCred = deserializeAddress(changeAddress).stakeCredentialHash; + setStakeCredentialHash(stakeCred); console.log("Connected wallet network ID:", network); console.log("unsignedTransaction:", unsignedTransaction); @@ -110,7 +112,7 @@ export const TransactionButton = () => { isMetadataAnchorValid: await txValidationUtils.checkMetadataAnchor(voteMetadataURL,voteMetadataHash), isUnsignedTransaction: txValidationUtils.isUnsignedTransaction(unsignedTransaction), }); - + //********************************************Voting Details *********************************************************************/ const transactionNetworkID = transactionBody.outputs().get(0).address().to_bech32().startsWith("addr_test1") ? 0 : 1; if (votes && hasOneVote) { @@ -300,7 +302,7 @@ export const TransactionButton = () => { {signature} - + )}