@@ -22,14 +22,16 @@ public partial class EngineWallet : IThirdwebWallet
2222 private readonly string _walletAddress ;
2323 private readonly IThirdwebHttpClient _engineClient ;
2424 private readonly int ? _timeoutSeconds ;
25+ private readonly bool _forwardLocalGasFees ;
2526
26- internal EngineWallet ( ThirdwebClient client , IThirdwebHttpClient engineClient , string engineUrl , string walletAddress , int ? timeoutSeconds )
27+ internal EngineWallet ( ThirdwebClient client , IThirdwebHttpClient engineClient , string engineUrl , string walletAddress , int ? timeoutSeconds , bool forwardLocalGasFees )
2728 {
2829 this . Client = client ;
2930 this . _engineUrl = engineUrl ;
3031 this . _walletAddress = walletAddress ;
3132 this . _engineClient = engineClient ;
3233 this . _timeoutSeconds = timeoutSeconds ;
34+ this . _forwardLocalGasFees = forwardLocalGasFees ;
3335 }
3436
3537 #region Creation
@@ -43,7 +45,16 @@ internal EngineWallet(ThirdwebClient client, IThirdwebHttpClient engineClient, s
4345 /// <param name="walletAddress">The backend wallet address to use.</param>
4446 /// <param name="timeoutSeconds">The timeout in seconds for the transaction. Defaults to no timeout.</param>
4547 /// <param name="additionalHeaders">Additional headers to include in requests. Authorization and X-Backend-Wallet-Address automatically included.</param>
46- public static EngineWallet Create ( ThirdwebClient client , string engineUrl , string authToken , string walletAddress , int ? timeoutSeconds = null , Dictionary < string , string > additionalHeaders = null )
48+ /// <param name="forwardLocalGasFees">Whether to forward locally calculated gas price/fees to the engine. Defaults to false.</param>
49+ public static EngineWallet Create (
50+ ThirdwebClient client ,
51+ string engineUrl ,
52+ string authToken ,
53+ string walletAddress ,
54+ int ? timeoutSeconds = null ,
55+ Dictionary < string , string > additionalHeaders = null ,
56+ bool forwardLocalGasFees = false
57+ )
4758 {
4859 if ( client == null )
4960 {
@@ -72,7 +83,7 @@ public static EngineWallet Create(ThirdwebClient client, string engineUrl, strin
7283
7384 walletAddress = walletAddress . ToChecksumAddress ( ) ;
7485
75- var engineClient = Utils . ReconstructHttpClient ( client . HttpClient , new Dictionary < string , string > { { "Authorization" , $ "Bearer { authToken } " } , } ) ;
86+ var engineClient = Utils . ReconstructHttpClient ( client . HttpClient , new Dictionary < string , string > { { "Authorization" , $ "Bearer { authToken } " } } ) ;
7687 engineClient . AddHeader ( "X-Backend-Wallet-Address" , walletAddress ) ;
7788 if ( additionalHeaders != null )
7889 {
@@ -81,7 +92,7 @@ public static EngineWallet Create(ThirdwebClient client, string engineUrl, strin
8192 engineClient . AddHeader ( header . Key , header . Value ) ;
8293 }
8394 }
84- var wallet = new EngineWallet ( client , engineClient , engineUrl , walletAddress , timeoutSeconds ) ;
95+ var wallet = new EngineWallet ( client , engineClient , engineUrl , walletAddress , timeoutSeconds , forwardLocalGasFees ) ;
8596 Utils . TrackConnection ( wallet ) ;
8697 return wallet ;
8798 }
@@ -125,28 +136,25 @@ private object ToEngineTransaction(ThirdwebTransactionInput transaction)
125136 data = transaction . Data ,
126137 value = transaction . Value ? . HexValue ?? "0x00" ,
127138 authorizationList = transaction . AuthorizationList != null && transaction . AuthorizationList . Count > 0
128- ? transaction . AuthorizationList
129- . Select (
130- authorization =>
131- new
132- {
133- chainId = authorization . ChainId . HexToNumber ( ) ,
134- address = authorization . Address ,
135- nonce = authorization . Nonce . HexToNumber ( ) ,
136- yParity = authorization . YParity . HexToNumber ( ) ,
137- r = authorization . R ,
138- s = authorization . S
139- }
140- )
139+ ? transaction
140+ . AuthorizationList . Select ( authorization => new
141+ {
142+ chainId = authorization . ChainId . HexToNumber ( ) ,
143+ address = authorization . Address ,
144+ nonce = authorization . Nonce . HexToNumber ( ) ,
145+ yParity = authorization . YParity . HexToNumber ( ) ,
146+ r = authorization . R ,
147+ s = authorization . S ,
148+ } )
141149 . ToArray ( )
142150 : null ,
143151 txOverrides = this . _timeoutSeconds != null || transaction . Gas != null || transaction . GasPrice != null || transaction . MaxFeePerGas != null || transaction . MaxPriorityFeePerGas != null
144152 ? new
145153 {
146154 gas = transaction . Gas ? . Value . ToString ( ) ,
147- gasPrice = transaction . GasPrice ? . Value . ToString ( ) ,
148- maxFeePerGas = transaction . MaxFeePerGas ? . Value . ToString ( ) ,
149- maxPriorityFeePerGas = transaction . MaxPriorityFeePerGas ? . Value . ToString ( ) ,
155+ gasPrice = this . _forwardLocalGasFees ? transaction . GasPrice ? . Value . ToString ( ) : null ,
156+ maxFeePerGas = this . _forwardLocalGasFees ? transaction . MaxFeePerGas ? . Value . ToString ( ) : null ,
157+ maxPriorityFeePerGas = this . _forwardLocalGasFees ? transaction . MaxPriorityFeePerGas ? . Value . ToString ( ) : null ,
150158 timeoutSeconds = this . _timeoutSeconds ,
151159 }
152160 : null ,
@@ -271,7 +279,7 @@ public async Task<string> SignTransaction(ThirdwebTransactionInput transaction)
271279 throw new ArgumentNullException ( nameof ( transaction ) ) ;
272280 }
273281
274- object payload = new { transaction = this . ToEngineTransaction ( transaction ) , } ;
282+ object payload = new { transaction = this . ToEngineTransaction ( transaction ) } ;
275283
276284 var url = $ "{ this . _engineUrl } /backend-wallet/sign-transaction";
277285
0 commit comments