@@ -125,8 +125,15 @@ export abstract class BaseWallet implements Wallet {
125125 protected log = createLogger ( 'wallet-sdk:base_wallet' ) ,
126126 ) { }
127127
128- protected scopesFrom ( from : AztecAddress | NoFrom , additionalScopes : AztecAddress [ ] = [ ] ) : AztecAddress [ ] {
129- const allScopes = from === NO_FROM ? additionalScopes : [ from , ...additionalScopes ] ;
128+ protected scopesFrom (
129+ from : AztecAddress | NoFrom ,
130+ additionalScopes : AztecAddress [ ] ,
131+ sendMessagesAs : AztecAddress | undefined ,
132+ ) : AztecAddress [ ] {
133+ // The sendMessagesAs account must be in scope so that its tagging secrets can be accessed.
134+ const tagSenderScopes = sendMessagesAs ? [ sendMessagesAs ] : [ ] ;
135+ const baseScopes = from === NO_FROM ? [ ] : [ from ] ;
136+ const allScopes = [ ...baseScopes , ...additionalScopes , ...tagSenderScopes ] ;
130137 const scopeSet = new Set ( allScopes . map ( address => address . toString ( ) ) ) ;
131138 return [ ...scopeSet ] . map ( AztecAddress . fromStringUnsafe ) ;
132139 }
@@ -402,7 +409,7 @@ export abstract class BaseWallet implements Wallet {
402409 simulatePublic : true ,
403410 skipTxValidation : opts . skipTxValidation ,
404411 skipFeeEnforcement : opts . skipFeeEnforcement ,
405- scopes : this . scopesFrom ( opts . from , opts . additionalScopes ) ,
412+ scopes : this . scopesFrom ( opts . from , opts . additionalScopes ?? [ ] , opts . sendMessagesAs ) ,
406413 senderForTags : this . senderForTagsFrom ( opts . from , opts . sendMessagesAs ) ,
407414 overrides : opts . overrides ,
408415 } ) ;
@@ -498,7 +505,7 @@ export abstract class BaseWallet implements Wallet {
498505 return this . pxe . profileTx ( txRequest , {
499506 profileMode : opts . profileMode ,
500507 skipProofGeneration : opts . skipProofGeneration ?? true ,
501- scopes : this . scopesFrom ( opts . from , opts . additionalScopes ) ,
508+ scopes : this . scopesFrom ( opts . from , opts . additionalScopes ?? [ ] , opts . sendMessagesAs ) ,
502509 senderForTags : this . senderForTagsFrom ( opts . from , opts . sendMessagesAs ) ,
503510 } ) ;
504511 }
@@ -515,7 +522,7 @@ export abstract class BaseWallet implements Wallet {
515522 } ) ;
516523 const txRequest = await this . createTxExecutionRequestFromPayloadAndFee ( executionPayload , opts . from , feeOptions ) ;
517524 const provenTx = await this . pxe . proveTx ( txRequest , {
518- scopes : this . scopesFrom ( opts . from , opts . additionalScopes ) ,
525+ scopes : this . scopesFrom ( opts . from , opts . additionalScopes ?? [ ] , opts . sendMessagesAs ) ,
519526 senderForTags : this . senderForTagsFrom ( opts . from , opts . sendMessagesAs ) ,
520527 } ) ;
521528 const offchainOutput = extractOffchainOutput (
0 commit comments