File tree Expand file tree Collapse file tree 4 files changed +36
-4
lines changed
Expand file tree Collapse file tree 4 files changed +36
-4
lines changed Original file line number Diff line number Diff line change @@ -449,6 +449,14 @@ export function useWalletFlowState(): WalletFlowState {
449449
450450 async function handleCreateNewWallet ( ) {
451451 if ( router . pathname == "/wallets/new-wallet-flow/save" ) {
452+ if ( ! userAddress ) {
453+ toast ( {
454+ title : "Error" ,
455+ description : "Please connect your wallet before creating a wallet." ,
456+ variant : "destructive" ,
457+ } ) ;
458+ return ;
459+ }
452460 setLoading ( true ) ;
453461 createNewWallet ( {
454462 name : name ,
@@ -457,7 +465,7 @@ export function useWalletFlowState(): WalletFlowState {
457465 signersDescriptions : signersDescriptions ,
458466 signersStakeKeys : signersStakeKeys ,
459467 signersDRepKeys : signersDRepKeys ,
460- ownerAddress : userAddress ! ,
468+ ownerAddress : userAddress ,
461469 numRequiredSigners : numRequiredSigners ,
462470 stakeCredentialHash : stakeKey || undefined ,
463471 scriptType : nativeScriptType ,
Original file line number Diff line number Diff line change @@ -239,6 +239,14 @@ export default function PageNewWallet() {
239239
240240 async function handleCreateNewWallet ( ) {
241241 if ( router . pathname == "/wallets/new-wallet" ) {
242+ if ( ! userAddress ) {
243+ toast ( {
244+ title : "Error" ,
245+ description : "Please connect your wallet before creating a wallet." ,
246+ variant : "destructive" ,
247+ } ) ;
248+ return ;
249+ }
242250 setLoading ( true ) ;
243251 createNewWallet ( {
244252 name : name ,
@@ -247,7 +255,7 @@ export default function PageNewWallet() {
247255 signersDescriptions : signersDescriptions ,
248256 signersStakeKeys : signersStakeKeys ,
249257 signersDRepKeys : signersDRepKeys ,
250- ownerAddress : userAddress ! ,
258+ ownerAddress : userAddress ,
251259 numRequiredSigners : numRequiredSigners ,
252260 stakeCredentialHash : stakeKey || undefined ,
253261 scriptType : nativeScriptType ,
Original file line number Diff line number Diff line change @@ -335,6 +335,15 @@ export function useMigrationWalletFlowState(appWallet: Wallet): MigrationWalletF
335335 return ;
336336 }
337337
338+ if ( ! userAddress ) {
339+ toast ( {
340+ title : "Error" ,
341+ description : "Please connect your wallet before creating a wallet invite link." ,
342+ variant : "destructive" ,
343+ } ) ;
344+ return ;
345+ }
346+
338347 setLoading ( true ) ;
339348 try {
340349 const walletData = {
@@ -345,7 +354,7 @@ export function useMigrationWalletFlowState(appWallet: Wallet): MigrationWalletF
345354 signersStakeKeys : signersStakeKeys ,
346355 signersDRepKeys : signersDRepKeys ,
347356 numRequiredSigners : numRequiredSigners ,
348- ownerAddress : userAddress ?? "" ,
357+ ownerAddress : userAddress ,
349358 stakeCredentialHash : stakeKey || undefined ,
350359 scriptType : nativeScriptType || undefined ,
351360 } ;
Original file line number Diff line number Diff line change @@ -342,7 +342,14 @@ export const walletRouter = createTRPCRouter({
342342 )
343343 . mutation ( async ( { ctx, input } ) => {
344344 const sessionAddress = requireSessionAddress ( ctx ) ;
345- if ( sessionAddress !== input . ownerAddress ) {
345+ const sessionWallets : string [ ] = ( ctx as any ) . sessionWallets ?? [ ] ;
346+
347+ // Allow ownerAddress to be either the sessionAddress or any address in sessionWallets
348+ const isAuthorized =
349+ sessionAddress === input . ownerAddress ||
350+ sessionWallets . includes ( input . ownerAddress ) ;
351+
352+ if ( ! isAuthorized ) {
346353 throw new TRPCError ( { code : "FORBIDDEN" , message : "Owner address mismatch" } ) ;
347354 }
348355 const numRequired = ( input . scriptType === "all" || input . scriptType === "any" ) ? null : input . numRequiredSigners ;
You can’t perform that action at this time.
0 commit comments