11import * as ox__Authorization from "ox/Authorization" ;
2- import type { EIP1193Provider } from "viem" ;
2+ import * as ox__Signature from "ox/Signature" ;
3+ import { type EIP1193Provider } from "viem" ;
34import {
45 getTypesForEIP712Domain ,
56 type SignTypedDataParameters ,
@@ -188,7 +189,7 @@ function createAccount({
188189 async sendTransaction ( tx : SendTransactionOption ) {
189190 const gasFees = tx . gasPrice
190191 ? {
191- gasPrice : tx . gasPrice ? numberToHex ( tx . gasPrice ) : undefined ,
192+ gasPrice : numberToHex ( tx . gasPrice ) ,
192193 }
193194 : {
194195 maxFeePerGas : tx . maxFeePerGas
@@ -201,6 +202,7 @@ function createAccount({
201202 const params = [
202203 {
203204 ...tx ,
205+ authorizationList : tx . authorizationList ? ox__Authorization . toRpcList ( tx . authorizationList ) : undefined ,
204206 ...gasFees ,
205207 from : this . address ,
206208 gas : tx . gas ? numberToHex ( tx . gas ) : undefined ,
@@ -269,10 +271,25 @@ function createAccount({
269271 } ,
270272 async signAuthorization ( authorization : AuthorizationRequest ) {
271273 const payload = ox__Authorization . getSignPayload ( authorization ) ;
272- return await provider . request ( {
273- method : "eth_sign" ,
274- params : [ getAddress ( account . address ) , payload ] ,
275- } ) ;
274+ let signature : Hex | undefined ;
275+ try {
276+ signature = await provider . request ( {
277+ method : "eth_sign" ,
278+ params : [ getAddress ( account . address ) , payload ] ,
279+ } ) ;
280+ } catch {
281+ // fallback to secp256k1_sign, some providers don't support eth_sign
282+ signature = await provider . request ( {
283+ // @ts -expect-error - overriding types here
284+ method : "secp256k1_sign" ,
285+ params : [ payload ] ,
286+ } ) ;
287+ }
288+ if ( ! signature ) {
289+ throw new Error ( "Failed to sign authorization" ) ;
290+ }
291+ const parsedSignature = ox__Signature . fromHex ( signature as Hex ) ;
292+ return { ...authorization , ...parsedSignature } ;
276293 } ,
277294 async signTypedData ( typedData ) {
278295 if ( ! provider || ! account . address ) {
0 commit comments