@@ -19,6 +19,20 @@ export type EngineAccountOptions = {
1919 * The backend wallet to use for sending transactions inside engine.
2020 */
2121 walletAddress : string ;
22+ overrides ?: {
23+ /**
24+ * The address of the smart account to act on behalf of. Requires your backend wallet to be a valid signer on that smart account.
25+ */
26+ accountAddress ?: string ;
27+ /**
28+ * The address of the smart account factory to use for creating smart accounts.
29+ */
30+ accountFactoryAddress ?: string ;
31+ /**
32+ * The salt to use for creating the smart account.
33+ */
34+ accountSalt ?: string ;
35+ } ;
2236 /**
2337 * The chain to use for signing messages and typed data (smart backend wallet only).
2438 */
@@ -55,7 +69,7 @@ export type EngineAccountOptions = {
5569 * ```
5670 */
5771export function engineAccount ( options : EngineAccountOptions ) : Account {
58- const { engineUrl, authToken, walletAddress, chain } = options ;
72+ const { engineUrl, authToken, walletAddress, chain, overrides } = options ;
5973
6074 // these are shared across all methods
6175 const headers : HeadersInit = {
@@ -64,6 +78,16 @@ export function engineAccount(options: EngineAccountOptions): Account {
6478 "Content-Type" : "application/json" ,
6579 } ;
6680
81+ if ( overrides ?. accountAddress ) {
82+ headers [ "x-account-address" ] = overrides . accountAddress ;
83+ }
84+ if ( overrides ?. accountFactoryAddress ) {
85+ headers [ "x-account-factory-address" ] = overrides . accountFactoryAddress ;
86+ }
87+ if ( overrides ?. accountSalt ) {
88+ headers [ "x-account-salt" ] = overrides . accountSalt ;
89+ }
90+
6791 return {
6892 address : walletAddress ,
6993 sendTransaction : async ( transaction : SendTransactionOption ) => {
@@ -181,12 +205,14 @@ export function engineAccount(options: EngineAccountOptions): Account {
181205 domain : _typedData . domain ,
182206 types : _typedData . types ,
183207 value : _typedData . message ,
208+ primaryType : _typedData . primaryType ,
209+ chainId : chain ?. id ,
184210 } ) ,
185211 } ) ;
186212 if ( ! engineRes . ok ) {
187- engineRes . body ?. cancel ( ) ;
213+ const body = await engineRes . text ( ) ;
188214 throw new Error (
189- `Engine request failed with status ${ engineRes . status } ` ,
215+ `Engine request failed with status ${ engineRes . status } - ${ body } ` ,
190216 ) ;
191217 }
192218 const engineJson = ( await engineRes . json ( ) ) as {
0 commit comments