Skip to main content

foundry_common/transactions/
builder.rs

1use crate::tempo::configurable_account::ConfigurableAccountSigner;
2use alloy_consensus::{
3    BlobTransactionSidecar, BlobTransactionSidecarEip7594, BlobTransactionSidecarVariant,
4};
5use alloy_eips::{Encodable2718, eip7702::SignedAuthorization};
6use alloy_network::{
7    AnyNetwork, Ethereum, Network, NetworkTransactionBuilder, NetworkWallet, TransactionBuilder,
8};
9use alloy_primitives::{Address, B256, Bytes, Signature, TxKind, U256};
10use alloy_provider::Provider;
11use alloy_rpc_types::{TransactionRequest, serde_helpers::WithOtherFields};
12use eyre::Result;
13use std::num::NonZeroU64;
14use tempo_alloy::{
15    TempoNetwork,
16    accounts::TempoAccountsWallet,
17    rpc::{ConfigurableAccountSimulationSpec, TempoTransactionRequest},
18};
19use tempo_primitives::{
20    SignatureType, TempoTxType,
21    transaction::{Call, TempoSignedAuthorization},
22};
23
24#[cfg(feature = "base")]
25use base_common_network::Base;
26#[cfg(feature = "base")]
27use base_common_rpc_types::BaseTransactionRequest;
28
29#[cfg(feature = "optimism")]
30use op_alloy_network::Optimism;
31#[cfg(feature = "optimism")]
32use op_alloy_rpc_types::OpTransactionRequest;
33
34/// Composite transaction builder trait for Foundry transactions.
35///
36/// This extends the base `TransactionBuilder` trait with the same methods as
37/// [`alloy_network::TransactionBuilder4844`] for handling blob transaction sidecars, and
38/// [`alloy_network::TransactionBuilder7702`] for handling EIP-7702 authorization lists.
39///
40/// By default, all methods have no-op implementations, so this can be implemented for any Network.
41///
42/// If the Network supports Eip4844 blob transactions implement these methods:
43/// - [`FoundryTransactionBuilder::max_fee_per_blob_gas`]
44/// - [`FoundryTransactionBuilder::set_max_fee_per_blob_gas`]
45/// - [`FoundryTransactionBuilder::blob_versioned_hashes`]
46/// - [`FoundryTransactionBuilder::set_blob_versioned_hashes`]
47/// - [`FoundryTransactionBuilder::blob_sidecar`]
48/// - [`FoundryTransactionBuilder::set_blob_sidecar`]
49///
50/// If the Network supports EIP-7702 authorization lists, implement these methods:
51/// - [`FoundryTransactionBuilder::authorization_list`]
52/// - [`FoundryTransactionBuilder::set_authorization_list`]
53///
54/// If the Network supports Tempo transactions, implement these methods:
55/// - [`FoundryTransactionBuilder::set_fee_token`]
56/// - [`FoundryTransactionBuilder::set_nonce_key`]
57/// - [`FoundryTransactionBuilder::set_key_id`]
58/// - [`FoundryTransactionBuilder::set_valid_before`]
59/// - [`FoundryTransactionBuilder::set_valid_after`]
60/// - [`FoundryTransactionBuilder::set_fee_payer_signature`]
61pub trait FoundryTransactionBuilder<N: Network>: NetworkTransactionBuilder<N> {
62    /// Reset gas limit
63    fn reset_gas_limit(&mut self);
64
65    /// Get the max fee per blob gas for the transaction.
66    fn max_fee_per_blob_gas(&self) -> Option<u128> {
67        None
68    }
69
70    /// Set the max fee per blob gas for the transaction.
71    fn set_max_fee_per_blob_gas(&mut self, _max_fee_per_blob_gas: u128) {}
72
73    /// Builder-pattern method for setting max fee per blob gas.
74    fn with_max_fee_per_blob_gas(mut self, max_fee_per_blob_gas: u128) -> Self {
75        self.set_max_fee_per_blob_gas(max_fee_per_blob_gas);
76        self
77    }
78
79    /// Gets the EIP-4844 blob versioned hashes of the transaction.
80    ///
81    /// These may be set independently of the sidecar, e.g. when the sidecar
82    /// has been pruned but the hashes are still needed for `eth_call`.
83    fn blob_versioned_hashes(&self) -> Option<&[B256]> {
84        None
85    }
86
87    /// Sets the EIP-4844 blob versioned hashes of the transaction.
88    fn set_blob_versioned_hashes(&mut self, _hashes: Vec<B256>) {}
89
90    /// Builder-pattern method for setting the EIP-4844 blob versioned hashes.
91    fn with_blob_versioned_hashes(mut self, hashes: Vec<B256>) -> Self {
92        self.set_blob_versioned_hashes(hashes);
93        self
94    }
95
96    /// Gets the blob sidecar (either EIP-4844 or EIP-7594 variant) of the transaction.
97    fn blob_sidecar(&self) -> Option<&BlobTransactionSidecarVariant> {
98        None
99    }
100
101    /// Sets the blob sidecar (either EIP-4844 or EIP-7594 variant) of the transaction.
102    ///
103    /// Note: This will also set the versioned blob hashes accordingly:
104    /// [BlobTransactionSidecarVariant::versioned_hashes]
105    fn set_blob_sidecar(&mut self, _sidecar: BlobTransactionSidecarVariant) {}
106
107    /// Builder-pattern method for setting the blob sidecar of the transaction.
108    fn with_blob_sidecar(mut self, sidecar: BlobTransactionSidecarVariant) -> Self {
109        self.set_blob_sidecar(sidecar);
110        self
111    }
112
113    /// Gets the EIP-4844 blob sidecar if the current sidecar is of that variant.
114    fn blob_sidecar_4844(&self) -> Option<&BlobTransactionSidecar> {
115        self.blob_sidecar().and_then(|s| s.as_eip4844())
116    }
117
118    /// Sets the EIP-4844 blob sidecar of the transaction.
119    fn set_blob_sidecar_4844(&mut self, sidecar: BlobTransactionSidecar) {
120        self.set_blob_sidecar(BlobTransactionSidecarVariant::Eip4844(sidecar));
121    }
122
123    /// Builder-pattern method for setting the EIP-4844 blob sidecar of the transaction.
124    fn with_blob_sidecar_4844(mut self, sidecar: BlobTransactionSidecar) -> Self {
125        self.set_blob_sidecar_4844(sidecar);
126        self
127    }
128
129    /// Gets the EIP-7594 blob sidecar if the current sidecar is of that variant.
130    fn blob_sidecar_7594(&self) -> Option<&BlobTransactionSidecarEip7594> {
131        self.blob_sidecar().and_then(|s| s.as_eip7594())
132    }
133
134    /// Sets the EIP-7594 blob sidecar of the transaction.
135    fn set_blob_sidecar_7594(&mut self, sidecar: BlobTransactionSidecarEip7594) {
136        self.set_blob_sidecar(BlobTransactionSidecarVariant::Eip7594(sidecar));
137    }
138
139    /// Builder-pattern method for setting the EIP-7594 blob sidecar of the transaction.
140    fn with_blob_sidecar_7594(mut self, sidecar: BlobTransactionSidecarEip7594) -> Self {
141        self.set_blob_sidecar_7594(sidecar);
142        self
143    }
144
145    /// Get the EIP-7702 authorization list for the transaction.
146    fn authorization_list(&self) -> Option<&Vec<SignedAuthorization>> {
147        None
148    }
149
150    /// Sets the EIP-7702 authorization list.
151    fn set_authorization_list(&mut self, _authorization_list: Vec<SignedAuthorization>) {}
152
153    /// Builder-pattern method for setting the authorization list.
154    fn with_authorization_list(mut self, authorization_list: Vec<SignedAuthorization>) -> Self {
155        self.set_authorization_list(authorization_list);
156        self
157    }
158
159    /// Get the fee token for a Tempo transaction.
160    fn fee_token(&self) -> Option<Address> {
161        None
162    }
163
164    /// Gets top-level Tempo calls for local fee-token inference.
165    fn tempo_calls(&self) -> Vec<(TxKind, &[u8])> {
166        Vec::new()
167    }
168
169    /// Returns true when [`Self::tempo_calls`] came from a Tempo AA `calls` list.
170    fn has_tempo_call_list(&self) -> bool {
171        false
172    }
173
174    /// Sets the input of the first Tempo AA call, or the transaction input without a call list.
175    fn set_first_call_input(&mut self, input: Bytes) {
176        self.set_input(input);
177    }
178
179    /// Returns true when this request will be built as a Tempo AA transaction.
180    fn is_tempo_aa(&self) -> bool {
181        false
182    }
183
184    /// Returns true when this request type can pay fees in a Tempo fee token.
185    fn supports_fee_token(&self) -> bool {
186        false
187    }
188
189    /// Set the fee token for a Tempo transaction.
190    fn set_fee_token(&mut self, _fee_token: Address) {}
191
192    /// Builder-pattern method for setting the Tempo fee token.
193    fn with_fee_token(mut self, fee_token: Address) -> Self {
194        self.set_fee_token(fee_token);
195        self
196    }
197
198    /// Get the 2D nonce key for a Tempo transaction.
199    fn nonce_key(&self) -> Option<U256> {
200        None
201    }
202
203    /// Set the 2D nonce key for the Tempo transaction.
204    fn set_nonce_key(&mut self, _nonce_key: U256) {}
205
206    /// Builder-pattern method for setting a 2D nonce key for a Tempo transaction.
207    fn with_nonce_key(mut self, nonce_key: U256) -> Self {
208        self.set_nonce_key(nonce_key);
209        self
210    }
211
212    /// Clone this request and prepare it for browser-wallet gas estimation.
213    ///
214    /// Complete signer hints are preserved. Missing or incomplete hints default to a conservative
215    /// WebAuthn signature size.
216    fn browser_wallet_gas_estimation_request(&self) -> Self
217    where
218        Self: Clone,
219    {
220        self.clone()
221    }
222
223    /// Get the access key ID for a Tempo transaction.
224    fn key_id(&self) -> Option<Address> {
225        None
226    }
227
228    /// Set the access key ID for a Tempo transaction.
229    ///
230    /// Used during gas estimation to override the key_id that would normally be
231    /// recovered from the signature.
232    fn set_key_id(&mut self, _key_id: Address) {}
233
234    /// Builder-pattern method for setting the Tempo access key ID.
235    fn with_key_id(mut self, key_id: Address) -> Self {
236        self.set_key_id(key_id);
237        self
238    }
239
240    /// Set the configurable account owner quorum that gas estimation models for the sender of a
241    /// Tempo transaction signed with a `0x05` signature.
242    fn set_configurable_account_simulation(&mut self, _spec: ConfigurableAccountSimulationSpec) {}
243
244    /// Get the valid_before timestamp for a Tempo expiring nonce transaction.
245    fn valid_before(&self) -> Option<NonZeroU64> {
246        None
247    }
248
249    /// Set the valid_before timestamp for a Tempo expiring nonce transaction.
250    fn set_valid_before(&mut self, _valid_before: NonZeroU64) {}
251
252    /// Builder-pattern method for setting the valid_before timestamp.
253    fn with_valid_before(mut self, valid_before: NonZeroU64) -> Self {
254        self.set_valid_before(valid_before);
255        self
256    }
257
258    /// Get the valid_after timestamp for a Tempo expiring nonce transaction.
259    fn valid_after(&self) -> Option<NonZeroU64> {
260        None
261    }
262
263    /// Set the valid_after timestamp for a Tempo expiring nonce transaction.
264    fn set_valid_after(&mut self, _valid_after: NonZeroU64) {}
265
266    /// Builder-pattern method for setting the valid_after timestamp.
267    fn with_valid_after(mut self, valid_after: NonZeroU64) -> Self {
268        self.set_valid_after(valid_after);
269        self
270    }
271
272    /// Get the fee payer (sponsor) signature for a Tempo sponsored transaction.
273    fn fee_payer_signature(&self) -> Option<Signature> {
274        None
275    }
276
277    /// Set the fee payer (sponsor) signature for a Tempo sponsored transaction.
278    fn set_fee_payer_signature(&mut self, _signature: Signature) {}
279
280    /// Builder-pattern method for setting the fee payer signature.
281    fn with_fee_payer_signature(mut self, signature: Signature) -> Self {
282        self.set_fee_payer_signature(signature);
283        self
284    }
285
286    /// Computes the sponsor (fee payer) signature hash for this transaction.
287    ///
288    /// This builds an unsigned consensus-level transaction from the request and computes
289    /// the hash that a sponsor needs to sign. Returns `None` for networks that don't
290    /// support sponsored transactions.
291    fn compute_sponsor_hash(&self, _from: Address) -> Option<B256> {
292        None
293    }
294
295    /// Prepare a Tempo access-key wallet before gas estimation or sponsorship.
296    fn prepare_with_tempo_wallet<'a>(
297        &'a mut self,
298        _provider: &'a impl Provider<N>,
299        _wallet: &'a TempoAccountsWallet,
300    ) -> impl Future<Output = Result<TempoAccountsWallet>> + Send + 'a
301    where
302        Self: Send,
303    {
304        std::future::ready(Err(eyre::eyre!(
305            "Tempo access-key wallets are not supported for this network"
306        )))
307    }
308
309    /// Converts a CREATE transaction into an AA-compatible call entry.
310    ///
311    /// Tempo AA transactions use a `calls` list instead of `to`+`input`. Must be
312    /// called before gas estimation so the RPC sees the correct tx structure.
313    /// No-op for non-Tempo networks.
314    fn convert_create_to_call(&mut self) {}
315
316    /// Clears the `to` and `value` fields for batch transactions that use `calls`.
317    ///
318    /// In Tempo AA batch transactions, targets are specified in the `calls` field, not in `to`.
319    /// If `to` is set, `build_aa()` would add a spurious extra call. Must be called after
320    /// `prepare()` sets `kind`/`to` but before gas estimation.
321    /// No-op for non-Tempo networks.
322    fn clear_batch_to(&mut self) {}
323
324    /// Sign a prepared request using a Tempo access-key wallet.
325    fn sign_with_tempo_wallet(
326        self,
327        _wallet: &TempoAccountsWallet,
328    ) -> impl Future<Output = Result<Vec<u8>>> + Send {
329        std::future::ready(Err(eyre::eyre!(
330            "Tempo access-key wallets are not supported for this network"
331        )))
332    }
333
334    /// Sign a prepared request as a Tempo configurable account with its owners' approvals.
335    fn sign_with_configurable_account(
336        self,
337        _signer: &ConfigurableAccountSigner,
338    ) -> impl Future<Output = Result<Vec<u8>>> + Send {
339        std::future::ready(Err(eyre::eyre!(
340            "Tempo configurable accounts are not supported for this network"
341        )))
342    }
343}
344
345impl FoundryTransactionBuilder<Ethereum> for TransactionRequest {
346    fn reset_gas_limit(&mut self) {
347        self.gas = None;
348    }
349
350    fn max_fee_per_blob_gas(&self) -> Option<u128> {
351        self.max_fee_per_blob_gas
352    }
353
354    fn set_max_fee_per_blob_gas(&mut self, max_fee_per_blob_gas: u128) {
355        self.max_fee_per_blob_gas = Some(max_fee_per_blob_gas);
356    }
357
358    fn blob_versioned_hashes(&self) -> Option<&[B256]> {
359        self.blob_versioned_hashes.as_deref()
360    }
361
362    fn set_blob_versioned_hashes(&mut self, hashes: Vec<B256>) {
363        self.blob_versioned_hashes = Some(hashes);
364    }
365
366    fn blob_sidecar(&self) -> Option<&BlobTransactionSidecarVariant> {
367        self.sidecar.as_ref()
368    }
369
370    fn set_blob_sidecar(&mut self, sidecar: BlobTransactionSidecarVariant) {
371        self.sidecar = Some(sidecar);
372        self.populate_blob_hashes();
373    }
374
375    fn authorization_list(&self) -> Option<&Vec<SignedAuthorization>> {
376        self.authorization_list.as_ref()
377    }
378
379    fn set_authorization_list(&mut self, authorization_list: Vec<SignedAuthorization>) {
380        self.authorization_list = Some(authorization_list);
381    }
382}
383
384impl FoundryTransactionBuilder<AnyNetwork> for WithOtherFields<TransactionRequest> {
385    fn reset_gas_limit(&mut self) {
386        self.gas = None;
387    }
388
389    fn max_fee_per_blob_gas(&self) -> Option<u128> {
390        self.max_fee_per_blob_gas
391    }
392
393    fn set_max_fee_per_blob_gas(&mut self, max_fee_per_blob_gas: u128) {
394        self.max_fee_per_blob_gas = Some(max_fee_per_blob_gas);
395    }
396
397    fn blob_versioned_hashes(&self) -> Option<&[B256]> {
398        self.blob_versioned_hashes.as_deref()
399    }
400
401    fn set_blob_versioned_hashes(&mut self, hashes: Vec<B256>) {
402        self.blob_versioned_hashes = Some(hashes);
403    }
404
405    fn blob_sidecar(&self) -> Option<&BlobTransactionSidecarVariant> {
406        self.sidecar.as_ref()
407    }
408
409    fn set_blob_sidecar(&mut self, sidecar: BlobTransactionSidecarVariant) {
410        self.sidecar = Some(sidecar);
411        self.populate_blob_hashes();
412    }
413
414    fn authorization_list(&self) -> Option<&Vec<SignedAuthorization>> {
415        self.authorization_list.as_ref()
416    }
417
418    fn set_authorization_list(&mut self, authorization_list: Vec<SignedAuthorization>) {
419        self.authorization_list = Some(authorization_list);
420    }
421}
422
423#[cfg(feature = "base")]
424impl FoundryTransactionBuilder<Base> for BaseTransactionRequest {
425    fn reset_gas_limit(&mut self) {
426        self.as_mut().gas = None;
427    }
428
429    fn authorization_list(&self) -> Option<&Vec<SignedAuthorization>> {
430        self.as_ref().authorization_list.as_ref()
431    }
432
433    fn set_authorization_list(&mut self, authorization_list: Vec<SignedAuthorization>) {
434        self.as_mut().authorization_list = Some(authorization_list);
435    }
436}
437
438#[cfg(feature = "optimism")]
439impl FoundryTransactionBuilder<Optimism> for OpTransactionRequest {
440    fn reset_gas_limit(&mut self) {
441        self.as_mut().gas = None;
442    }
443
444    fn authorization_list(&self) -> Option<&Vec<SignedAuthorization>> {
445        self.as_ref().authorization_list.as_ref()
446    }
447
448    fn set_authorization_list(&mut self, authorization_list: Vec<SignedAuthorization>) {
449        self.as_mut().authorization_list = Some(authorization_list);
450    }
451}
452
453/// Viem's Tempo formatter uses a 1,400-byte WebAuthn placeholder when the signature is not yet
454/// available. Tempo RPC encodes that size as a two-byte big-endian `keyData` value (`0x0578`).
455///
456/// See <https://github.com/wevm/viem/blob/61a40ec943652a09ee6622e2349c5fedca97ed5e/src/tempo/Formatters.ts#L148-L159>.
457const TEMPO_BROWSER_WEBAUTHN_DATA_SIZE: u16 = 1_400;
458
459impl FoundryTransactionBuilder<TempoNetwork> for TempoTransactionRequest {
460    fn reset_gas_limit(&mut self) {
461        self.gas = None;
462    }
463
464    fn authorization_list(&self) -> Option<&Vec<SignedAuthorization>> {
465        self.authorization_list.as_ref()
466    }
467
468    /// A Tempo AA transaction carries its authorizations in `tempo_authorization_list` and
469    /// ignores the Ethereum list, so they go there once Tempo options have made the request AA.
470    /// A list with an invalid signature stays in the Ethereum list, where it is never applied.
471    fn set_authorization_list(&mut self, authorization_list: Vec<SignedAuthorization>) {
472        if self.is_tempo_aa()
473            && let Ok(tempo_authorization_list) = authorization_list
474                .iter()
475                .map(|auth| {
476                    let signature = auth.signature()?;
477                    Ok(TempoSignedAuthorization::new_unchecked(
478                        auth.inner().clone(),
479                        signature.into(),
480                    ))
481                })
482                .collect::<Result<_, alloy_primitives::SignatureError>>()
483        {
484            self.tempo_authorization_list = tempo_authorization_list;
485        } else {
486            self.authorization_list = Some(authorization_list);
487        }
488    }
489
490    fn fee_token(&self) -> Option<Address> {
491        self.fee_token
492    }
493
494    fn tempo_calls(&self) -> Vec<(TxKind, &[u8])> {
495        self.calls
496            .iter()
497            .map(|call| (call.to, call.input.as_ref()))
498            .chain(self.inner.to.map(|to| {
499                (to, self.inner.input.input().map_or(&[] as &[u8], |input| input.as_ref()))
500            }))
501            .collect()
502    }
503
504    fn has_tempo_call_list(&self) -> bool {
505        !self.calls.is_empty()
506    }
507
508    fn set_first_call_input(&mut self, input: Bytes) {
509        match self.calls.first_mut() {
510            Some(call) => call.input = input,
511            None => self.set_input(input),
512        }
513    }
514
515    fn is_tempo_aa(&self) -> bool {
516        NetworkTransactionBuilder::<TempoNetwork>::output_tx_type(self) == TempoTxType::AA
517    }
518
519    fn supports_fee_token(&self) -> bool {
520        true
521    }
522
523    fn set_fee_token(&mut self, fee_token: Address) {
524        self.fee_token = Some(fee_token);
525    }
526
527    fn nonce_key(&self) -> Option<U256> {
528        self.nonce_key
529    }
530
531    fn set_nonce_key(&mut self, nonce_key: U256) {
532        self.nonce_key = Some(nonce_key);
533    }
534
535    fn browser_wallet_gas_estimation_request(&self) -> Self {
536        let mut request = self.clone();
537        if request.key_type.is_none() {
538            request.key_type = Some(SignatureType::WebAuthn);
539            request.key_data = Some(TEMPO_BROWSER_WEBAUTHN_DATA_SIZE.to_be_bytes().into());
540        } else if matches!(request.key_type, Some(SignatureType::WebAuthn))
541            && request.key_data.is_none()
542        {
543            request.key_data = Some(TEMPO_BROWSER_WEBAUTHN_DATA_SIZE.to_be_bytes().into());
544        }
545        request.convert_create_to_call();
546        request
547    }
548
549    fn key_id(&self) -> Option<Address> {
550        self.key_id
551    }
552
553    fn set_key_id(&mut self, key_id: Address) {
554        self.key_id = Some(key_id);
555    }
556
557    fn set_configurable_account_simulation(&mut self, spec: ConfigurableAccountSimulationSpec) {
558        self.configurable_account_simulation = Some(spec);
559    }
560
561    fn valid_before(&self) -> Option<NonZeroU64> {
562        self.valid_before
563    }
564
565    fn set_valid_before(&mut self, valid_before: NonZeroU64) {
566        self.valid_before = Some(valid_before);
567    }
568
569    fn valid_after(&self) -> Option<NonZeroU64> {
570        self.valid_after
571    }
572
573    fn set_valid_after(&mut self, valid_after: NonZeroU64) {
574        self.valid_after = Some(valid_after);
575    }
576
577    fn fee_payer_signature(&self) -> Option<Signature> {
578        self.fee_payer_signature
579    }
580
581    fn set_fee_payer_signature(&mut self, signature: Signature) {
582        self.fee_payer_signature = Some(signature);
583    }
584
585    fn compute_sponsor_hash(&self, from: Address) -> Option<B256> {
586        let tx = self.clone().build_aa().ok()?;
587        Some(tx.fee_payer_signature_hash(from))
588    }
589
590    async fn prepare_with_tempo_wallet<'a>(
591        &'a mut self,
592        provider: &'a impl Provider<TempoNetwork>,
593        wallet: &'a TempoAccountsWallet,
594    ) -> Result<TempoAccountsWallet>
595    where
596        Self: Send,
597    {
598        wallet.prepare_request(provider, self).await.map_err(Into::into)
599    }
600
601    fn convert_create_to_call(&mut self) {
602        if self.calls.is_empty() && self.inner.to.is_some_and(|to| to.is_create()) {
603            let input = self.inner.input.input().cloned().unwrap_or_default();
604            let value = self.inner.value.unwrap_or(U256::ZERO);
605            self.calls.push(Call { to: TxKind::Create, value, input });
606            self.inner.input = Default::default();
607            self.inner.value = None;
608            self.inner.to = None;
609        }
610    }
611
612    fn clear_batch_to(&mut self) {
613        if !self.calls.is_empty() {
614            self.inner.to = None;
615            self.inner.value = None;
616        }
617    }
618
619    async fn sign_with_tempo_wallet(self, wallet: &TempoAccountsWallet) -> Result<Vec<u8>> {
620        wallet.sign_request(self).await.map(|envelope| envelope.encoded_2718()).map_err(Into::into)
621    }
622
623    async fn sign_with_configurable_account(
624        self,
625        signer: &ConfigurableAccountSigner,
626    ) -> Result<Vec<u8>> {
627        signer.sign_request(self).await.map(|envelope| envelope.encoded_2718())
628    }
629}