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
2 changes: 1 addition & 1 deletion prisma/schema.prisma
Original file line number Diff line number Diff line change
Expand Up @@ -107,4 +107,4 @@ model BalanceSnapshot {
assetBalances Json
isArchived Boolean
snapshotDate DateTime @default(now())
}
}
34 changes: 29 additions & 5 deletions src/components/pages/wallet/governance/ballot/ballot.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,32 @@ export default function BallotCard({
setLoading(true);
try {
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 scriptCbor = multisigWallet?.getKeysByRole(3) ? multisigWallet?.getScript().scriptCbor : appWallet.scriptCbor;
const drepCbor = multisigWallet?.getKeysByRole(3) ? multisigWallet?.getDRepScript() : appWallet.scriptCbor;
if (!scriptCbor) {
setAlert("Script not found");
return;
}
if (!drepCbor) {
setAlert("DRep script not found");
return;
}
const changeAddress = multisigWallet?.getKeysByRole(3) ? multisigWallet?.getScript().address : appWallet.address;
if (!changeAddress) {
setAlert("Change address not found");
return;
}
const txBuilder = getTxBuilder(network);

// Ensure minimum ADA for fee and voting
Expand All @@ -134,7 +159,7 @@ export default function BallotCard({
utxo.output.amount,
utxo.output.address,
)
.txInScript(appWallet.scriptCbor);
.txInScript(scriptCbor);
}

// Submit a vote for each proposal in the ballot
Expand Down Expand Up @@ -162,9 +187,8 @@ export default function BallotCard({
}

txBuilder
.voteScript(appWallet.scriptCbor)
.selectUtxosFrom(utxos)
.changeAddress(appWallet.address);
.voteScript(drepCbor)
.changeAddress(changeAddress);

await newTransaction({
txBuilder,
Expand Down
12 changes: 10 additions & 2 deletions src/components/pages/wallet/governance/drep/registerDrep.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,14 @@ export default function RegisterDRep() {
if (!dRepId) {
throw new Error("DRep not found");
}
const scriptCbor = multisigWallet?.getKeysByRole(3) ? multisigWallet?.getScript().scriptCbor : appWallet.scriptCbor;
const drepCbor = multisigWallet?.getKeysByRole(3) ? multisigWallet?.getDRepScript() : appWallet.scriptCbor;
if (!scriptCbor) {
throw new Error("Script not found");
}
if (!drepCbor) {
throw new Error("DRep script not found");
}
try {
const { anchorUrl, anchorHash } = await createAnchor();

Expand All @@ -106,15 +114,15 @@ export default function RegisterDRep() {
utxo.output.amount,
utxo.output.address,
)
.txInScript(multisigWallet.getScript().scriptCbor!);
.txInScript(scriptCbor);
}

txBuilder
.drepRegistrationCertificate(dRepId, {
anchorUrl: anchorUrl,
anchorDataHash: anchorHash,
})
.certificateScript(multisigWallet.getDRepScript()!)
.certificateScript(drepCbor)
.changeAddress(multisigWallet.getScript().address);


Expand Down
18 changes: 15 additions & 3 deletions src/components/pages/wallet/governance/drep/retire.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,18 @@ export default function Retire({ appWallet }: { appWallet: Wallet }) {

const txBuilder = getTxBuilder(network);
const dRepId = multisigWallet?.getKeysByRole(3) ? multisigWallet?.getDRepId() : appWallet?.dRepId;
const scriptCbor = multisigWallet?.getKeysByRole(3) ? multisigWallet?.getScript().scriptCbor : appWallet.scriptCbor;
const drepCbor = multisigWallet?.getKeysByRole(3) ? multisigWallet?.getDRepScript() : appWallet.scriptCbor;
const changeAddress = multisigWallet?.getKeysByRole(3) ? multisigWallet?.getScript().address : appWallet.address;
if (!changeAddress) {
throw new Error("Change address not found");
}
if (!scriptCbor) {
throw new Error("Script not found");
}
if (!drepCbor) {
throw new Error("DRep script not found");
}
if (!dRepId) {
throw new Error("DRep not found");
}
Expand All @@ -50,10 +62,10 @@ export default function Retire({ appWallet }: { appWallet: Wallet }) {
}

txBuilder
.txInScript(multisigWallet.getScript().scriptCbor!)
.changeAddress(multisigWallet.getScript().address)
.txInScript(scriptCbor)
.changeAddress(changeAddress)
.drepDeregistrationCertificate(dRepId, "500000000")
.certificateScript(multisigWallet.getDRepScript()!);
.certificateScript(drepCbor);

await newTransaction({
txBuilder,
Expand Down
18 changes: 15 additions & 3 deletions src/components/pages/wallet/governance/drep/updateDrep.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,18 @@ export default function UpdateDRep() {
if (!dRepId) {
throw new Error("DRep not found");
}
const scriptCbor = multisigWallet?.getKeysByRole(3) ? multisigWallet?.getScript().scriptCbor : appWallet.scriptCbor;
const drepCbor = multisigWallet?.getKeysByRole(3) ? multisigWallet?.getDRepScript() : appWallet.scriptCbor;
if (!scriptCbor) {
throw new Error("Script not found");
}
if (!drepCbor) {
throw new Error("DRep script not found");
}
const changeAddress = multisigWallet?.getKeysByRole(3) ? multisigWallet?.getScript().address : appWallet.address;
if (!changeAddress) {
throw new Error("Change address not found");
}
try {
const { anchorUrl, anchorHash } = await createAnchor();

Expand All @@ -106,16 +118,16 @@ export default function UpdateDRep() {
utxo.output.amount,
utxo.output.address,
)
.txInScript(multisigWallet.getScript().scriptCbor!);
.txInScript(scriptCbor);
}

txBuilder
.drepUpdateCertificate(dRepId, {
anchorUrl: anchorUrl,
anchorDataHash: anchorHash,
})
.certificateScript(multisigWallet.getDRepScript()!)
.changeAddress(multisigWallet.getScript().address);
.certificateScript(drepCbor)
.changeAddress(changeAddress);

await newTransaction({
txBuilder,
Expand Down
21 changes: 18 additions & 3 deletions src/components/pages/wallet/governance/proposal/voteButtton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,21 @@ export default function VoteButton({
});
return;
}
const scriptCbor = multisigWallet?.getKeysByRole(3) ? multisigWallet?.getScript().scriptCbor : appWallet.scriptCbor;
const drepCbor = multisigWallet?.getKeysByRole(3) ? multisigWallet?.getDRepScript() : appWallet.scriptCbor;
if (!scriptCbor) {
setAlert("Script not found");
return;
}
if (!drepCbor) {
setAlert("DRep script not found");
return;
}
const changeAddress = multisigWallet?.getKeysByRole(3) ? multisigWallet?.getScript().address : appWallet.address;
if (!changeAddress) {
setAlert("Change address not found");
return;
}
const txBuilder = getTxBuilder(network);

const assetMap = new Map<Unit, Quantity>();
Expand All @@ -117,7 +132,7 @@ export default function VoteButton({
utxo.output.amount,
utxo.output.address,
)
.txInScript(appWallet.scriptCbor);
.txInScript(scriptCbor);
}
txBuilder
.vote(
Expand All @@ -133,8 +148,8 @@ export default function VoteButton({
voteKind: voteKind,
},
)
.voteScript(appWallet.scriptCbor)
.changeAddress(appWallet.address);
.voteScript(drepCbor)
.changeAddress(changeAddress);

await newTransaction({
txBuilder,
Expand Down