@@ -14,15 +14,16 @@ import {
14
14
15
15
import { copyRequest } from "./provider.js" ;
16
16
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" ;
19
21
20
22
import type {
21
23
BlockTag , Provider , TransactionRequest , TransactionResponse
22
24
} from "./provider.js" ;
23
25
import type { Signer } from "./signer.js" ;
24
26
25
-
26
27
function checkProvider ( signer : AbstractSigner , operation : string ) : Provider {
27
28
if ( signer . provider ) { return signer . provider ; }
28
29
assert ( false , "missing provider" , "UNSUPPORTED_OPERATION" , { operation } ) ;
@@ -194,7 +195,7 @@ export abstract class AbstractSigner<P extends null | Provider = null | Provider
194
195
operation : "signer.getFeeData" } ) ;
195
196
}
196
197
197
- } else if ( pop . type === 2 || pop . type === 3 ) {
198
+ } else if ( pop . type === 2 || pop . type === 3 || pop . type === 4 ) {
198
199
// Explicitly using EIP-1559 or EIP-4844
199
200
200
201
// Populate missing fee data
@@ -213,6 +214,21 @@ export abstract class AbstractSigner<P extends null | Provider = null | Provider
213
214
return await resolveProperties ( pop ) ;
214
215
}
215
216
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
+
216
232
async estimateGas ( tx : TransactionRequest ) : Promise < bigint > {
217
233
return checkProvider ( this , "estimateGas" ) . estimateGas ( await this . populateCall ( tx ) ) ;
218
234
}
@@ -235,6 +251,12 @@ export abstract class AbstractSigner<P extends null | Provider = null | Provider
235
251
return await provider . broadcastTransaction ( await this . signTransaction ( txObj ) ) ;
236
252
}
237
253
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
+
238
260
abstract signTransaction ( tx : TransactionRequest ) : Promise < string > ;
239
261
abstract signMessage ( message : string | Uint8Array ) : Promise < string > ;
240
262
abstract signTypedData ( domain : TypedDataDomain , types : Record < string , Array < TypedDataField > > , value : Record < string , any > ) : Promise < string > ;
0 commit comments