Skip to content
Merged
Show file tree
Hide file tree
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
3 changes: 0 additions & 3 deletions src/components/common/overall-layout/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -135,13 +135,10 @@ export default function RootLayout({
let drepKeyHash = "";
try {
const dRepKey = await wallet.getDRep();
console.log("DRep key:", dRepKey);
if (dRepKey && dRepKey.publicKeyHash) {
drepKeyHash = dRepKey.publicKeyHash;
}
} catch (error) {
// DRep key is optional, so we continue without it
console.log("No DRep key available for this wallet");
}

// 4) Create or update user (upsert pattern handles both cases)
Expand Down
5 changes: 4 additions & 1 deletion src/components/pages/wallet/governance/card-info.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,10 @@ export default function CardInfo({ appWallet }: { appWallet: Wallet }) {
const { toast } = useToast();

// Get DRep ID from multisig wallet if available, otherwise fallback to appWallet
const dRepId = multisigWallet?.getDRepId() || appWallet.dRepId;
const dRepId = multisigWallet?.getKeysByRole(3) ? multisigWallet?.getDRepId() : appWallet?.dRepId;
if (!dRepId) {
throw new Error("DRep not found");
}

// Check if DRep is actually registered (has info from Blockfrost)
const isDRepRegistered = drepInfo?.active === true;
Expand Down
7 changes: 5 additions & 2 deletions src/components/pages/wallet/governance/drep/registerDrep.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,10 @@ export default function RegisterDRep() {

setLoading(true);
const txBuilder = getTxBuilder(network);
const drepIds = getDRepIds(multisigWallet.getDRepId()!);
const dRepId = multisigWallet?.getKeysByRole(3) ? multisigWallet?.getDRepId() : appWallet?.dRepId;
if (!dRepId) {
throw new Error("DRep not found");
}
try {
const { anchorUrl, anchorHash } = await createAnchor();

Expand All @@ -107,7 +110,7 @@ export default function RegisterDRep() {
}

txBuilder
.drepRegistrationCertificate(drepIds.cip105, {
.drepRegistrationCertificate(dRepId, {
anchorUrl: anchorUrl,
anchorDataHash: anchorHash,
})
Expand Down
7 changes: 5 additions & 2 deletions src/components/pages/wallet/governance/drep/retire.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,10 @@ export default function Retire({ appWallet }: { appWallet: Wallet }) {
if (selectedUtxos.length === 0) throw new Error("No relevant UTxOs found");

const txBuilder = getTxBuilder(network);

const dRepId = multisigWallet?.getKeysByRole(3) ? multisigWallet?.getDRepId() : appWallet?.dRepId;
if (!dRepId) {
throw new Error("DRep not found");
}
for (const utxo of selectedUtxos) {
txBuilder.txIn(
utxo.input.txHash,
Expand All @@ -49,7 +52,7 @@ export default function Retire({ appWallet }: { appWallet: Wallet }) {
txBuilder
.txInScript(multisigWallet.getScript().scriptCbor!)
.changeAddress(multisigWallet.getScript().address)
.drepDeregistrationCertificate(multisigWallet.getDRepId()!, "500000000")
.drepDeregistrationCertificate(dRepId, "500000000")
.certificateScript(multisigWallet.getDRepScript()!);

await newTransaction({
Expand Down
7 changes: 5 additions & 2 deletions src/components/pages/wallet/governance/drep/updateDrep.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,10 @@ export default function UpdateDRep() {

setLoading(true);
const txBuilder = getTxBuilder(network);
const drepIds = getDRepIds(multisigWallet.getDRepId()!);
const dRepId = multisigWallet?.getKeysByRole(3) ? multisigWallet?.getDRepId() : appWallet?.dRepId;
if (!dRepId) {
throw new Error("DRep not found");
}
try {
const { anchorUrl, anchorHash } = await createAnchor();

Expand All @@ -107,7 +110,7 @@ export default function UpdateDRep() {
}

txBuilder
.drepUpdateCertificate(drepIds.cip105, {
.drepUpdateCertificate(dRepId, {
anchorUrl: anchorUrl,
anchorDataHash: anchorHash,
})
Expand Down
12 changes: 11 additions & 1 deletion src/components/pages/wallet/governance/proposal/voteButtton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,17 @@ export default function VoteButton({
}
if (!multisigWallet)
throw new Error("Multisig Wallet could not be built.");
const dRepId = appWallet.dRepId;
const dRepId = multisigWallet?.getKeysByRole(3) ? multisigWallet?.getDRepId() : appWallet?.dRepId;
if (!dRepId) {
setAlert("DRep not found");
toast({
title: "DRep not found",
description: `Please register as a DRep and retry.`,
duration: 10000,
variant: "destructive",
});
return;
}
const txBuilder = getTxBuilder(network);

const assetMap = new Map<Unit, Quantity>();
Expand Down
5 changes: 4 additions & 1 deletion src/components/pages/wallet/info/card-info.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,10 @@ function ShowInfo({ appWallet }: { appWallet: Wallet }) {
const { multisigWallet } = useMultisigWallet();

// Get DRep ID from multisig wallet if available, otherwise fallback to appWallet
const dRepId = multisigWallet?.getDRepId() || appWallet.dRepId;
const dRepId = multisigWallet?.getKeysByRole(3) ? multisigWallet?.getDRepId() : appWallet?.dRepId;
if (!dRepId) {
throw new Error("DRep not found");
}

return (
<>
Expand Down