File tree Expand file tree Collapse file tree 7 files changed +34
-12
lines changed
Expand file tree Collapse file tree 7 files changed +34
-12
lines changed Original file line number Diff line number Diff line change @@ -135,13 +135,10 @@ export default function RootLayout({
135135 let drepKeyHash = "" ;
136136 try {
137137 const dRepKey = await wallet . getDRep ( ) ;
138- console . log ( "DRep key:" , dRepKey ) ;
139138 if ( dRepKey && dRepKey . publicKeyHash ) {
140139 drepKeyHash = dRepKey . publicKeyHash ;
141140 }
142141 } catch ( error ) {
143- // DRep key is optional, so we continue without it
144- console . log ( "No DRep key available for this wallet" ) ;
145142 }
146143
147144 // 4) Create or update user (upsert pattern handles both cases)
Original file line number Diff line number Diff line change @@ -19,7 +19,10 @@ export default function CardInfo({ appWallet }: { appWallet: Wallet }) {
1919 const { toast } = useToast ( ) ;
2020
2121 // Get DRep ID from multisig wallet if available, otherwise fallback to appWallet
22- const dRepId = multisigWallet ?. getDRepId ( ) || appWallet . dRepId ;
22+ const dRepId = multisigWallet ?. getKeysByRole ( 3 ) ? multisigWallet ?. getDRepId ( ) : appWallet ?. dRepId ;
23+ if ( ! dRepId ) {
24+ throw new Error ( "DRep not found" ) ;
25+ }
2326
2427 // Check if DRep is actually registered (has info from Blockfrost)
2528 const isDRepRegistered = drepInfo ?. active === true ;
Original file line number Diff line number Diff line change @@ -84,7 +84,10 @@ export default function RegisterDRep() {
8484
8585 setLoading ( true ) ;
8686 const txBuilder = getTxBuilder ( network ) ;
87- const drepIds = getDRepIds ( multisigWallet . getDRepId ( ) ! ) ;
87+ const dRepId = multisigWallet ?. getKeysByRole ( 3 ) ? multisigWallet ?. getDRepId ( ) : appWallet ?. dRepId ;
88+ if ( ! dRepId ) {
89+ throw new Error ( "DRep not found" ) ;
90+ }
8891 try {
8992 const { anchorUrl, anchorHash } = await createAnchor ( ) ;
9093
@@ -107,7 +110,7 @@ export default function RegisterDRep() {
107110 }
108111
109112 txBuilder
110- . drepRegistrationCertificate ( drepIds . cip105 , {
113+ . drepRegistrationCertificate ( dRepId , {
111114 anchorUrl : anchorUrl ,
112115 anchorDataHash : anchorHash ,
113116 } )
Original file line number Diff line number Diff line change @@ -36,7 +36,10 @@ export default function Retire({ appWallet }: { appWallet: Wallet }) {
3636 if ( selectedUtxos . length === 0 ) throw new Error ( "No relevant UTxOs found" ) ;
3737
3838 const txBuilder = getTxBuilder ( network ) ;
39-
39+ const dRepId = multisigWallet ?. getKeysByRole ( 3 ) ? multisigWallet ?. getDRepId ( ) : appWallet ?. dRepId ;
40+ if ( ! dRepId ) {
41+ throw new Error ( "DRep not found" ) ;
42+ }
4043 for ( const utxo of selectedUtxos ) {
4144 txBuilder . txIn (
4245 utxo . input . txHash ,
@@ -49,7 +52,7 @@ export default function Retire({ appWallet }: { appWallet: Wallet }) {
4952 txBuilder
5053 . txInScript ( multisigWallet . getScript ( ) . scriptCbor ! )
5154 . changeAddress ( multisigWallet . getScript ( ) . address )
52- . drepDeregistrationCertificate ( multisigWallet . getDRepId ( ) ! , "500000000" )
55+ . drepDeregistrationCertificate ( dRepId , "500000000" )
5356 . certificateScript ( multisigWallet . getDRepScript ( ) ! ) ;
5457
5558 await newTransaction ( {
Original file line number Diff line number Diff line change @@ -84,7 +84,10 @@ export default function UpdateDRep() {
8484
8585 setLoading ( true ) ;
8686 const txBuilder = getTxBuilder ( network ) ;
87- const drepIds = getDRepIds ( multisigWallet . getDRepId ( ) ! ) ;
87+ const dRepId = multisigWallet ?. getKeysByRole ( 3 ) ? multisigWallet ?. getDRepId ( ) : appWallet ?. dRepId ;
88+ if ( ! dRepId ) {
89+ throw new Error ( "DRep not found" ) ;
90+ }
8891 try {
8992 const { anchorUrl, anchorHash } = await createAnchor ( ) ;
9093
@@ -107,7 +110,7 @@ export default function UpdateDRep() {
107110 }
108111
109112 txBuilder
110- . drepUpdateCertificate ( drepIds . cip105 , {
113+ . drepUpdateCertificate ( dRepId , {
111114 anchorUrl : anchorUrl ,
112115 anchorDataHash : anchorHash ,
113116 } )
Original file line number Diff line number Diff line change @@ -92,7 +92,17 @@ export default function VoteButton({
9292 }
9393 if ( ! multisigWallet )
9494 throw new Error ( "Multisig Wallet could not be built." ) ;
95- const dRepId = appWallet . dRepId ;
95+ const dRepId = multisigWallet ?. getKeysByRole ( 3 ) ? multisigWallet ?. getDRepId ( ) : appWallet ?. dRepId ;
96+ if ( ! dRepId ) {
97+ setAlert ( "DRep not found" ) ;
98+ toast ( {
99+ title : "DRep not found" ,
100+ description : `Please register as a DRep and retry.` ,
101+ duration : 10000 ,
102+ variant : "destructive" ,
103+ } ) ;
104+ return ;
105+ }
96106 const txBuilder = getTxBuilder ( network ) ;
97107
98108 const assetMap = new Map < Unit , Quantity > ( ) ;
Original file line number Diff line number Diff line change @@ -175,7 +175,10 @@ function ShowInfo({ appWallet }: { appWallet: Wallet }) {
175175 const { multisigWallet } = useMultisigWallet ( ) ;
176176
177177 // Get DRep ID from multisig wallet if available, otherwise fallback to appWallet
178- const dRepId = multisigWallet ?. getDRepId ( ) || appWallet . dRepId ;
178+ const dRepId = multisigWallet ?. getKeysByRole ( 3 ) ? multisigWallet ?. getDRepId ( ) : appWallet ?. dRepId ;
179+ if ( ! dRepId ) {
180+ throw new Error ( "DRep not found" ) ;
181+ }
179182
180183 return (
181184 < >
You can’t perform that action at this time.
0 commit comments