@@ -14,15 +14,16 @@ import {
1414
1515import { copyRequest } from "./provider.js" ;
1616
17- import type { TypedDataDomain , TypedDataField } from "../hash/index.js" ;
18- import type { TransactionLike } from "../transaction/index.js" ;
17+ import type {
18+ AuthorizationRequest , TypedDataDomain , TypedDataField
19+ } from "../hash/index.js" ;
20+ import type { Authorization , TransactionLike } from "../transaction/index.js" ;
1921
2022import type {
2123 BlockTag , Provider , TransactionRequest , TransactionResponse
2224} from "./provider.js" ;
2325import type { Signer } from "./signer.js" ;
2426
25-
2627function checkProvider ( signer : AbstractSigner , operation : string ) : Provider {
2728 if ( signer . provider ) { return signer . provider ; }
2829 assert ( false , "missing provider" , "UNSUPPORTED_OPERATION" , { operation } ) ;
@@ -194,7 +195,7 @@ export abstract class AbstractSigner<P extends null | Provider = null | Provider
194195 operation : "signer.getFeeData" } ) ;
195196 }
196197
197- } else if ( pop . type === 2 || pop . type === 3 ) {
198+ } else if ( pop . type === 2 || pop . type === 3 || pop . type === 4 ) {
198199 // Explicitly using EIP-1559 or EIP-4844
199200
200201 // Populate missing fee data
@@ -213,6 +214,21 @@ export abstract class AbstractSigner<P extends null | Provider = null | Provider
213214 return await resolveProperties ( pop ) ;
214215 }
215216
217+ async populateAuthorization ( _auth : AuthorizationRequest ) : Promise < AuthorizationRequest > {
218+ const auth = Object . assign ( { } , _auth ) ;
219+
220+ // Add a chain ID if not explicitly set to 0
221+ if ( auth . chainId == null ) {
222+ auth . chainId = ( await checkProvider ( this , "getNetwork" ) . getNetwork ( ) ) . chainId ;
223+ }
224+
225+ // @TODO : Take chain ID into account when populating noce?
226+
227+ if ( auth . nonce == null ) { auth . nonce = await this . getNonce ( ) ; }
228+
229+ return auth ;
230+ }
231+
216232 async estimateGas ( tx : TransactionRequest ) : Promise < bigint > {
217233 return checkProvider ( this , "estimateGas" ) . estimateGas ( await this . populateCall ( tx ) ) ;
218234 }
@@ -235,6 +251,12 @@ export abstract class AbstractSigner<P extends null | Provider = null | Provider
235251 return await provider . broadcastTransaction ( await this . signTransaction ( txObj ) ) ;
236252 }
237253
254+ // @TODO : in v7 move this to be abstract
255+ authorize ( authorization : AuthorizationRequest ) : Promise < Authorization > {
256+ assert ( false , "authorization not implemented for this signer" ,
257+ "UNSUPPORTED_OPERATION" , { operation : "authorize" } ) ;
258+ }
259+
238260 abstract signTransaction ( tx : TransactionRequest ) : Promise < string > ;
239261 abstract signMessage ( message : string | Uint8Array ) : Promise < string > ;
240262 abstract signTypedData ( domain : TypedDataDomain , types : Record < string , Array < TypedDataField > > , value : Record < string , any > ) : Promise < string > ;
0 commit comments