@@ -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 } ) ;
@@ -150,7 +151,11 @@ export abstract class AbstractSigner<P extends null | Provider = null | Provider
150151 // The network supports EIP-1559!
151152
152153 // Upgrade transaction from null to eip-1559
153- pop . type = 2 ;
154+ if ( pop . authorizationList && pop . authorizationList . length ) {
155+ pop . type = 4 ;
156+ } else {
157+ pop . type = 2 ;
158+ }
154159
155160 if ( pop . gasPrice != null ) {
156161 // Using legacy gasPrice property on an eip-1559 network,
@@ -194,7 +199,7 @@ export abstract class AbstractSigner<P extends null | Provider = null | Provider
194199 operation : "signer.getFeeData" } ) ;
195200 }
196201
197- } else if ( pop . type === 2 || pop . type === 3 ) {
202+ } else if ( pop . type === 2 || pop . type === 3 || pop . type === 4 ) {
198203 // Explicitly using EIP-1559 or EIP-4844
199204
200205 // Populate missing fee data
@@ -213,6 +218,21 @@ export abstract class AbstractSigner<P extends null | Provider = null | Provider
213218 return await resolveProperties ( pop ) ;
214219 }
215220
221+ async populateAuthorization ( _auth : AuthorizationRequest ) : Promise < AuthorizationRequest > {
222+ const auth = Object . assign ( { } , _auth ) ;
223+
224+ // Add a chain ID if not explicitly set to 0
225+ if ( auth . chainId == null ) {
226+ auth . chainId = ( await checkProvider ( this , "getNetwork" ) . getNetwork ( ) ) . chainId ;
227+ }
228+
229+ // @TODO : Take chain ID into account when populating noce?
230+
231+ if ( auth . nonce == null ) { auth . nonce = await this . getNonce ( ) ; }
232+
233+ return auth ;
234+ }
235+
216236 async estimateGas ( tx : TransactionRequest ) : Promise < bigint > {
217237 return checkProvider ( this , "estimateGas" ) . estimateGas ( await this . populateCall ( tx ) ) ;
218238 }
@@ -235,6 +255,12 @@ export abstract class AbstractSigner<P extends null | Provider = null | Provider
235255 return await provider . broadcastTransaction ( await this . signTransaction ( txObj ) ) ;
236256 }
237257
258+ // @TODO : in v7 move this to be abstract
259+ authorize ( authorization : AuthorizationRequest ) : Promise < Authorization > {
260+ assert ( false , "authorization not implemented for this signer" ,
261+ "UNSUPPORTED_OPERATION" , { operation : "authorize" } ) ;
262+ }
263+
238264 abstract signTransaction ( tx : TransactionRequest ) : Promise < string > ;
239265 abstract signMessage ( message : string | Uint8Array ) : Promise < string > ;
240266 abstract signTypedData ( domain : TypedDataDomain , types : Record < string , Array < TypedDataField > > , value : Record < string , any > ) : Promise < string > ;
0 commit comments