@nadohq/engine-client 0.22.0 → 0.22.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
1
- {"version":3,"file":"EngineBaseClient-D4T3zroY.d.cts","names":[],"sources":["../src/src/EngineBaseClient.ts"],"mappings":";;;;;;;;UA+BiB,gBAAA;EAEf,GAAA;EAEA,YAAA,GAAe,uBAAA;EAEf,wBAAA,GAA2B,uBAAuB;AAAA;AAAA,KAI/C,wBAAA,GAA2B,OAAO,CAAC,gCAAA;AAVxC;;;AAAA,cAwBa,gBAAA;EAAA,SACF,IAAA,EAAM,gBAAA;EAAA,SACN,aAAA,EAAe,aAAA;cAEZ,IAAA,EAAM,gBAAA;EAtBlB;;;AAAkD;AACnD;EAmCQ,eAAA,CACL,wBAAA,EAA0B,uBAAA;EAKf,UAAA,CAAW,OAAA,YAAmB,OAAA;EAc9B,SAAA,CACX,MAAA,EAAQ,qBAAA,GACP,OAAA,CAAQ,uBAAA;EAtD2D;AAcxE;;;;;;EAwDe,KAAA,sBAA2B,4BAAA,CAAA,CACtC,WAAA,EAAa,YAAA,EACb,MAAA,EAAQ,8BAAA,CAA+B,YAAA,IACtC,OAAA,CAAQ,+BAAA,CAAgC,YAAA;EAnCA;;;;;;;;;EA8D9B,SAAA,sBACU,kCAAA,CAAA,CAErB,WAAA,EAAa,YAAA,EACb,MAAA,EAAQ,oCAAA,CAAqC,YAAA,IAC5C,OAAA,CAAQ,qCAAA,CAAsC,YAAA;EAhC9C;;;;;;;;;EA4DU,gBAAA,sBACU,kCAAA,CAAA,CAErB,WAAA,EAAa,YAAA,EACb,MAAA,EAAQ,oCAAA,CAAqC,YAAA,IAC5C,OAAA,CAAQ,qCAAA,CAAsC,YAAA;EADvC;;;;;;;;EAqBG,OAAA,sBAA6B,8BAAA,CAAA,CACxC,WAAA,EAAa,YAAA,EACb,MAAA,EAAQ,gCAAA,CAAiC,YAAA,IACxC,OAAA,CAAQ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oCAAA,CAAqC,YAAA,IAC5C,OAAA,CAAQ,qCAAA,CAAsC,YAAA;EAhC9C;;;;;;;;;EA4DU,gBAAA,sBACU,kCAAA,CAAA,CAErB,WAAA,EAAa,YAAA,EACb,MAAA,EAAQ,oCAAA,CAAqC,YAAA,IAC5C,OAAA,CAAQ,qCAAA,CAAsC,YAAA;EADvC;;;;;;;;EAqBG,OAAA,sBAA6B,8BAAA,CAAA,CACxC,WAAA,EAAa,YAAA,EACb,MAAA,EAAQ,gCAAA,CAAiC,YAAA,IACxC,OAAA,CAAQ,gCAAA,CAAiC,YAAA;EAAA;;;;;;;;EAqBrC,eAAA,qDAAA,CACL,WAAA,EAAa,YAAA,EACb,MAAA,EAAQ,OAAA;IACL,IAAA,EAAM,YAAA;EAAA,IAAiB,OAAA;EAgBzB;;;;;;EAHI,iBAAA,sBAAuC,8BAAA,CAAA,CAC5C,WAAA,EAAa,YAAA,EACb,MAAA,EAAQ,gCAAA,CAAiC,YAAA,IACxC,wBAAA;EAmBqC;;;;;;;;;EAJ3B,IAAA,WAAe,mBAAA,CAAA,CAC1B,WAAA,EAAa,CAAA,EACb,iBAAA,UACA,OAAA,UACA,MAAA,EAAQ,2BAAA,CAA4B,CAAA,IAAE,OAAA;EAAA,QAyBhC,mBAAA;EAAA,QAQA,iBAAA;AAAA"}
@@ -150,7 +150,10 @@ var EngineBaseClient = class {
150
150
  * @public
151
151
  */
152
152
  async sign(requestType, verifyingContract, chainId, params) {
153
- const walletClient = this.opts.linkedSignerWalletClient ?? this.opts.walletClient;
153
+ const walletClient = (() => {
154
+ if (requestType === "withdraw_collateral_v2") return this.opts.walletClient;
155
+ return this.opts.linkedSignerWalletClient ?? this.opts.walletClient;
156
+ })();
154
157
  if (!walletClient) throw new _nadohq_shared.WalletNotProvidedError();
155
158
  return (0, _nadohq_shared.getSignedTransactionRequest)({
156
159
  chainId,
@@ -181,4 +184,4 @@ Object.defineProperty(exports, "__toESM", {
181
184
  }
182
185
  });
183
186
 
184
- //# sourceMappingURL=EngineBaseClient-zgQmbhJv.cjs.map
187
+ //# sourceMappingURL=EngineBaseClient-J3nMzK0q.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"EngineBaseClient-zgQmbhJv.cjs","names":["WalletNotProvidedError","successResponse","EngineServerFailureError"],"sources":["../src/EngineBaseClient.ts"],"sourcesContent":["import {\n getSignedTransactionRequest,\n SignableRequestType,\n SignableRequestTypeToParams,\n WalletClientWithAccount,\n WalletNotProvidedError,\n} from '@nadohq/shared';\nimport axios, { AxiosInstance, AxiosResponse } from 'axios';\nimport {\n EngineServerCachedQueryRequestByType,\n EngineServerCachedQueryRequestType,\n EngineServerCachedQueryResponse,\n EngineServerCachedQueryResponseByType,\n EngineServerCachedQuerySuccessResponse,\n EngineServerEdgeControlRequestByType,\n EngineServerEdgeControlRequestType,\n EngineServerEdgeControlResponseByType,\n EngineServerExecuteRequestByType,\n EngineServerExecuteRequestType,\n EngineServerExecuteResult,\n EngineServerExecuteSuccessResult,\n EngineServerQueryRequestByType,\n EngineServerQueryRequestType,\n EngineServerQueryResponse,\n EngineServerQueryResponseByType,\n EngineServerQuerySuccessResponse,\n GetEngineNoncesParams,\n GetEngineNoncesResponse,\n} from './types';\nimport { EngineServerFailureError } from './types/EngineServerFailureError';\n\nexport interface EngineClientOpts {\n // Server URL\n url: string;\n // Wallet client for EIP712 signing\n walletClient?: WalletClientWithAccount;\n // Linked signer registered through the engine, if provided, execute requests will use this signer\n linkedSignerWalletClient?: WalletClientWithAccount;\n}\n\n// Only 1 key can be defined per execute request\ntype EngineExecuteRequestBody = Partial<EngineServerExecuteRequestByType>;\n\ntype EngineQueryRequestResponse<\n T extends EngineServerQueryRequestType = EngineServerQueryRequestType,\n> = EngineServerQueryResponse<T>;\n\ntype EngineCachedQueryRequestResponse<\n T extends EngineServerCachedQueryRequestType =\n EngineServerCachedQueryRequestType,\n> = EngineServerCachedQueryResponse<T>;\n\n/**\n * Base client for all engine requests\n */\nexport class EngineBaseClient {\n readonly opts: EngineClientOpts;\n readonly axiosInstance: AxiosInstance;\n\n constructor(opts: EngineClientOpts) {\n this.opts = opts;\n this.axiosInstance = axios.create({\n withCredentials: true,\n // We have custom logic to validate response status and create an appropriate error\n validateStatus: () => true,\n });\n }\n\n /**\n * Sets the linked signer for execute requests\n *\n * @param linkedSignerWalletClient The linkedSigner to use for all signatures. Set to null to revert to the chain signer\n */\n public setLinkedSigner(\n linkedSignerWalletClient: WalletClientWithAccount | null,\n ) {\n this.opts.linkedSignerWalletClient = linkedSignerWalletClient ?? undefined;\n }\n\n public async getTxNonce(address?: string): Promise<string> {\n const addr = address ?? this.opts.walletClient?.account.address;\n\n if (!addr) {\n throw new WalletNotProvidedError();\n }\n\n return (\n await this.getNonces({\n address: addr,\n })\n ).txNonce;\n }\n\n public async getNonces(\n params: GetEngineNoncesParams,\n ): Promise<GetEngineNoncesResponse> {\n const baseResp = await this.query('nonces', params);\n\n return {\n orderNonce: baseResp.order_nonce,\n txNonce: baseResp.tx_nonce,\n };\n }\n\n /**\n * Queries the engine, all query params are stringified into the query string\n *\n * @param requestType\n * @param params\n * @public\n */\n public async query<TRequestType extends EngineServerQueryRequestType>(\n requestType: TRequestType,\n params: EngineServerQueryRequestByType[TRequestType],\n ): Promise<EngineServerQueryResponseByType[TRequestType]> {\n const request = this.getQueryRequest(requestType, params);\n const response = await this.axiosInstance.post<EngineQueryRequestResponse>(\n `${this.opts.url}/query`,\n request,\n );\n\n this.checkResponseStatus(response);\n this.checkServerStatus(response);\n\n // checkServerStatus throws on failure responses so the cast to the success response is acceptable here\n const successResponse = response as AxiosResponse<\n EngineServerQuerySuccessResponse<TRequestType>\n >;\n\n return successResponse.data.data;\n }\n\n /**\n * Queries the gateway's in-memory cache via the `/edge/query` endpoint. Lower latency than\n * {@link query} at the cost of eventual consistency — do not use for order, margin, or\n * settlement decisions.\n *\n * @param requestType\n * @param params\n * @public\n */\n public async edgeQuery<\n TRequestType extends EngineServerCachedQueryRequestType,\n >(\n requestType: TRequestType,\n params: EngineServerCachedQueryRequestByType[TRequestType],\n ): Promise<EngineServerCachedQueryResponseByType[TRequestType]> {\n const request = this.getQueryRequest(requestType, params);\n const response =\n await this.axiosInstance.post<EngineCachedQueryRequestResponse>(\n `${this.opts.url}/edge/query`,\n request,\n );\n\n this.checkResponseStatus(response);\n this.checkServerStatus(response);\n\n // checkServerStatus throws on failure responses so the cast to the success response is acceptable here\n const successResponse = response as AxiosResponse<\n EngineServerCachedQuerySuccessResponse<TRequestType>\n >;\n\n return successResponse.data.data;\n }\n\n /**\n * Sends an edge control message (`ping` / `time`) via the `/edge/query` endpoint. These\n * return immediately from the server clock and use a different envelope than the cached data\n * queries (no `data` field), so the whole response body is returned.\n *\n * @param requestType\n * @param params\n * @public\n */\n public async edgeControlQuery<\n TRequestType extends EngineServerEdgeControlRequestType,\n >(\n requestType: TRequestType,\n params: EngineServerEdgeControlRequestByType[TRequestType],\n ): Promise<EngineServerEdgeControlResponseByType[TRequestType]> {\n const request = this.getQueryRequest(requestType, params);\n const response = await this.axiosInstance.post<\n EngineServerEdgeControlResponseByType[TRequestType]\n >(`${this.opts.url}/edge/query`, request);\n\n this.checkResponseStatus(response);\n this.checkServerStatus(response);\n\n return response.data;\n }\n\n /**\n * POSTs an execute message to the engine and returns the successful response. Throws the failure response wrapped\n * in an EngineServerFailureError on failure.\n *\n * @param requestType\n * @param params\n * @public\n */\n public async execute<TRequestType extends EngineServerExecuteRequestType>(\n requestType: TRequestType,\n params: EngineServerExecuteRequestByType[TRequestType],\n ): Promise<EngineServerExecuteSuccessResult<TRequestType>> {\n const reqBody = this.getExecuteRequest(requestType, params);\n const response = await this.axiosInstance.post<\n EngineServerExecuteResult<TRequestType>\n >(`${this.opts.url}/execute`, reqBody);\n\n this.checkResponseStatus(response);\n this.checkServerStatus(response);\n\n // checkServerStatus catches the failure result and throws the error, so the cast to the success response is acceptable here\n return response.data as EngineServerExecuteSuccessResult<TRequestType>;\n }\n\n /**\n * A simple, typechecked fn for constructing a `type`-tagged request body in the format expected\n * by the server. Generic over the request type / params pair so it can build live query, edge\n * (cached) query, and edge control request bodies alike.\n *\n * @param requestType\n * @param params\n */\n public getQueryRequest<TRequestType extends string, TParams extends object>(\n requestType: TRequestType,\n params: TParams,\n ): { type: TRequestType } & TParams {\n return {\n type: requestType,\n ...params,\n };\n }\n\n /**\n * A simple, typechecked fn for constructing an execute request in the format expected by the server.\n *\n * @param requestType\n * @param params\n */\n public getExecuteRequest<TRequestType extends EngineServerExecuteRequestType>(\n requestType: TRequestType,\n params: EngineServerExecuteRequestByType[TRequestType],\n ): EngineExecuteRequestBody {\n return {\n [requestType]: params,\n };\n }\n\n /**\n * Signs a given request with the signer provided to the engine\n *\n * @param requestType\n * @param verifyingContract\n * @param chainId\n * @param params\n * @public\n */\n public async sign<T extends SignableRequestType>(\n requestType: T,\n verifyingContract: string,\n chainId: number,\n params: SignableRequestTypeToParams[T],\n ) {\n // Use the linked signer if provided, otherwise use the default signer provided to the engine\n const walletClient =\n this.opts.linkedSignerWalletClient ?? this.opts.walletClient;\n\n if (!walletClient) {\n throw new WalletNotProvidedError();\n }\n\n return getSignedTransactionRequest({\n chainId,\n requestParams: params,\n requestType,\n walletClient,\n verifyingContract,\n });\n }\n\n private checkResponseStatus(response: AxiosResponse) {\n if (response.status !== 200 || !response.data) {\n throw Error(\n `Unexpected response from server: ${response.status} ${response.statusText}. Data: ${response.data}`,\n );\n }\n }\n\n private checkServerStatus(\n response: AxiosResponse<\n | EngineServerExecuteResult\n | EngineQueryRequestResponse\n | EngineCachedQueryRequestResponse\n | EngineServerEdgeControlResponseByType[EngineServerEdgeControlRequestType]\n >,\n ) {\n if (response.data.status !== 'success') {\n throw new EngineServerFailureError(response.data);\n }\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAuDA,IAAa,mBAAb,MAA8B;CAI5B,YAAY,MAAwB;EAClC,KAAK,OAAO;EACZ,KAAK,gBAAgB,MAAA,QAAM,OAAO;GAChC,i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AAK,kBAAkB,aAAa,MAAM;EAC1D,MAAM,WAAW,MAAM,KAAK,cAAc,KAExC,GAAG,KAAK,KAAK,IAAI,WAAW,OAAO;EAErC,KAAK,oBAAoB,QAAQ;EACjC,KAAK,kBAAkB,QAAQ;EAG/B,OAAO,SAAS;CAClB;;;;;;;;;CAUA,gBACE,aACA,QACkC;EAClC,OAAO;GACL,MAAM;GACN,GAAG;EACL;CACF;;;;;;;CAQA,kBACE,aACA,QAC0B;EAC1B,OAAO,GACJ,cAAc,OACjB;CACF;;;;;;;;;;CAWA,MAAa,KACX,aACA,mBACA,SACA,QACA;EAEA,MAAM,eACJ,KAAK,KAAK,4BAA4B,KAAK,KAAK;EAElD,IAAI,CAAC,cACH,MAAM,IAAID,eAAAA,uBAAuB;EAGnC,QAAA,GAAA,eAAA,6BAAmC;GACjC;GACA,eAAe;GACf;GACA;GACA;EACF,CAAC;CACH;CAEA,oBAA4B,UAAyB;EACnD,IAAI,SAAS,WAAW,OAAO,CAAC,SAAS,MACvC,MAAM,MACJ,oCAAoC,SAAS,OAAO,GAAG,SAAS,WAAW,UAAU,SAAS,MAChG;CAEJ;CAEA,kBACE,UAMA;EACA,IAAI,SAAS,KAAK,WAAW,WAC3B,MAAM,IAAIE,uCAAAA,yBAAyB,SAAS,IAAI;CAEpD;AACF"}
1
+ {"version":3,"file":"EngineBaseClient-J3nMzK0q.cjs","names":["WalletNotProvidedError","successResponse","EngineServerFailureError"],"sources":["../src/EngineBaseClient.ts"],"sourcesContent":["import {\n getSignedTransactionRequest,\n SignableRequestType,\n SignableRequestTypeToParams,\n WalletClientWithAccount,\n WalletNotProvidedError,\n} from '@nadohq/shared';\nimport axios, { AxiosInstance, AxiosResponse } from 'axios';\nimport {\n EngineServerCachedQueryRequestByType,\n EngineServerCachedQueryRequestType,\n EngineServerCachedQueryResponse,\n EngineServerCachedQueryResponseByType,\n EngineServerCachedQuerySuccessResponse,\n EngineServerEdgeControlRequestByType,\n EngineServerEdgeControlRequestType,\n EngineServerEdgeControlResponseByType,\n EngineServerExecuteRequestByType,\n EngineServerExecuteRequestType,\n EngineServerExecuteResult,\n EngineServerExecuteSuccessResult,\n EngineServerQueryRequestByType,\n EngineServerQueryRequestType,\n EngineServerQueryResponse,\n EngineServerQueryResponseByType,\n EngineServerQuerySuccessResponse,\n GetEngineNoncesParams,\n GetEngineNoncesResponse,\n} from './types';\nimport { EngineServerFailureError } from './types/EngineServerFailureError';\n\nexport interface EngineClientOpts {\n // Server URL\n url: string;\n // Wallet client for EIP712 signing\n walletClient?: WalletClientWithAccount;\n // Linked signer registered through the engine, if provided, execute requests will use this signer\n linkedSignerWalletClient?: WalletClientWithAccount;\n}\n\n// Only 1 key can be defined per execute request\ntype EngineExecuteRequestBody = Partial<EngineServerExecuteRequestByType>;\n\ntype EngineQueryRequestResponse<\n T extends EngineServerQueryRequestType = EngineServerQueryRequestType,\n> = EngineServerQueryResponse<T>;\n\ntype EngineCachedQueryRequestResponse<\n T extends EngineServerCachedQueryRequestType =\n EngineServerCachedQueryRequestType,\n> = EngineServerCachedQueryResponse<T>;\n\n/**\n * Base client for all engine requests\n */\nexport class EngineBaseClient {\n readonly opts: EngineClientOpts;\n readonly axiosInstance: AxiosInstance;\n\n constructor(opts: EngineClientOpts) {\n this.opts = opts;\n this.axiosInstance = axios.create({\n withCredentials: true,\n // We have custom logic to validate response status and create an appropriate error\n validateStatus: () => true,\n });\n }\n\n /**\n * Sets the linked signer for execute requests\n *\n * @param linkedSignerWalletClient The linkedSigner to use for all signatures. Set to null to revert to the chain signer\n */\n public setLinkedSigner(\n linkedSignerWalletClient: WalletClientWithAccount | null,\n ) {\n this.opts.linkedSignerWalletClient = linkedSignerWalletClient ?? undefined;\n }\n\n public async getTxNonce(address?: string): Promise<string> {\n const addr = address ?? this.opts.walletClient?.account.address;\n\n if (!addr) {\n throw new WalletNotProvidedError();\n }\n\n return (\n await this.getNonces({\n address: addr,\n })\n ).txNonce;\n }\n\n public async getNonces(\n params: GetEngineNoncesParams,\n ): Promise<GetEngineNoncesResponse> {\n const baseResp = await this.query('nonces', params);\n\n return {\n orderNonce: baseResp.order_nonce,\n txNonce: baseResp.tx_nonce,\n };\n }\n\n /**\n * Queries the engine, all query params are stringified into the query string\n *\n * @param requestType\n * @param params\n * @public\n */\n public async query<TRequestType extends EngineServerQueryRequestType>(\n requestType: TRequestType,\n params: EngineServerQueryRequestByType[TRequestType],\n ): Promise<EngineServerQueryResponseByType[TRequestType]> {\n const request = this.getQueryRequest(requestType, params);\n const response = await this.axiosInstance.post<EngineQueryRequestResponse>(\n `${this.opts.url}/query`,\n request,\n );\n\n this.checkResponseStatus(response);\n this.checkServerStatus(response);\n\n // checkServerStatus throws on failure responses so the cast to the success response is acceptable here\n const successResponse = response as AxiosResponse<\n EngineServerQuerySuccessResponse<TRequestType>\n >;\n\n return successResponse.data.data;\n }\n\n /**\n * Queries the gateway's in-memory cache via the `/edge/query` endpoint. Lower latency than\n * {@link query} at the cost of eventual consistency — do not use for order, margin, or\n * settlement decisions.\n *\n * @param requestType\n * @param params\n * @public\n */\n public async edgeQuery<\n TRequestType extends EngineServerCachedQueryRequestType,\n >(\n requestType: TRequestType,\n params: EngineServerCachedQueryRequestByType[TRequestType],\n ): Promise<EngineServerCachedQueryResponseByType[TRequestType]> {\n const request = this.getQueryRequest(requestType, params);\n const response =\n await this.axiosInstance.post<EngineCachedQueryRequestResponse>(\n `${this.opts.url}/edge/query`,\n request,\n );\n\n this.checkResponseStatus(response);\n this.checkServerStatus(response);\n\n // checkServerStatus throws on failure responses so the cast to the success response is acceptable here\n const successResponse = response as AxiosResponse<\n EngineServerCachedQuerySuccessResponse<TRequestType>\n >;\n\n return successResponse.data.data;\n }\n\n /**\n * Sends an edge control message (`ping` / `time`) via the `/edge/query` endpoint. These\n * return immediately from the server clock and use a different envelope than the cached data\n * queries (no `data` field), so the whole response body is returned.\n *\n * @param requestType\n * @param params\n * @public\n */\n public async edgeControlQuery<\n TRequestType extends EngineServerEdgeControlRequestType,\n >(\n requestType: TRequestType,\n params: EngineServerEdgeControlRequestByType[TRequestType],\n ): Promise<EngineServerEdgeControlResponseByType[TRequestType]> {\n const request = this.getQueryRequest(requestType, params);\n const response = await this.axiosInstance.post<\n EngineServerEdgeControlResponseByType[TRequestType]\n >(`${this.opts.url}/edge/query`, request);\n\n this.checkResponseStatus(response);\n this.checkServerStatus(response);\n\n return response.data;\n }\n\n /**\n * POSTs an execute message to the engine and returns the successful response. Throws the failure response wrapped\n * in an EngineServerFailureError on failure.\n *\n * @param requestType\n * @param params\n * @public\n */\n public async execute<TRequestType extends EngineServerExecuteRequestType>(\n requestType: TRequestType,\n params: EngineServerExecuteRequestByType[TRequestType],\n ): Promise<EngineServerExecuteSuccessResult<TRequestType>> {\n const reqBody = this.getExecuteRequest(requestType, params);\n const response = await this.axiosInstance.post<\n EngineServerExecuteResult<TRequestType>\n >(`${this.opts.url}/execute`, reqBody);\n\n this.checkResponseStatus(response);\n this.checkServerStatus(response);\n\n // checkServerStatus catches the failure result and throws the error, so the cast to the success response is acceptable here\n return response.data as EngineServerExecuteSuccessResult<TRequestType>;\n }\n\n /**\n * A simple, typechecked fn for constructing a `type`-tagged request body in the format expected\n * by the server. Generic over the request type / params pair so it can build live query, edge\n * (cached) query, and edge control request bodies alike.\n *\n * @param requestType\n * @param params\n */\n public getQueryRequest<TRequestType extends string, TParams extends object>(\n requestType: TRequestType,\n params: TParams,\n ): { type: TRequestType } & TParams {\n return {\n type: requestType,\n ...params,\n };\n }\n\n /**\n * A simple, typechecked fn for constructing an execute request in the format expected by the server.\n *\n * @param requestType\n * @param params\n */\n public getExecuteRequest<TRequestType extends EngineServerExecuteRequestType>(\n requestType: TRequestType,\n params: EngineServerExecuteRequestByType[TRequestType],\n ): EngineExecuteRequestBody {\n return {\n [requestType]: params,\n };\n }\n\n /**\n * Signs a given request with the signer provided to the engine\n *\n * @param requestType\n * @param verifyingContract\n * @param chainId\n * @param params\n * @public\n */\n public async sign<T extends SignableRequestType>(\n requestType: T,\n verifyingContract: string,\n chainId: number,\n params: SignableRequestTypeToParams[T],\n ) {\n // Use the linked signer if provided, otherwise use the default signer provided to the engine\n // However, always use wallet signer for withdraw_collateral_v2 as linked signers are not allowed for different\n // withdrawal addresses\n const walletClient = (() => {\n if (requestType === 'withdraw_collateral_v2') {\n return this.opts.walletClient;\n }\n return this.opts.linkedSignerWalletClient ?? this.opts.walletClient;\n })();\n\n if (!walletClient) {\n throw new WalletNotProvidedError();\n }\n\n return getSignedTransactionRequest({\n chainId,\n requestParams: params,\n requestType,\n walletClient,\n verifyingContract,\n });\n }\n\n private checkResponseStatus(response: AxiosResponse) {\n if (response.status !== 200 || !response.data) {\n throw Error(\n `Unexpected response from server: ${response.status} ${response.statusText}. Data: ${response.data}`,\n );\n }\n }\n\n private checkServerStatus(\n response: AxiosResponse<\n | EngineServerExecuteResult\n | EngineQueryRequestResponse\n | EngineCachedQueryRequestResponse\n | EngineServerEdgeControlResponseByType[EngineServerEdgeControlRequestType]\n >,\n ) {\n if (response.data.status !== 'success') {\n throw new EngineServerFailureError(response.data);\n }\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAuDA,IAAa,mBAAb,MAA8B;CAI5B,YAAY,MAAwB;EAClC,KAAK,OAAO;EACZ,KAAK,gBAAgB,MAAA,QAAM,OAAO;GAChC,iBAAiB;GAEjB,sBAAsB;EACxB,CAAC;CACH;;;;;;CAOA,gBACE,0BACA;EACA,KAAK,KAAK,2BAA2B,4BAA4B,KAAA;CACnE;CAEA,MAAa,WAAW,SAAmC;EACzD,MAAM,OAAO,WAAW,KAAK,KAAK,cAAc,QAAQ;EAExD,IAAI,CAAC,MACH,MAAM,IAAIA,eAAAA,uBAAuB;EAGnC,QACE,MAAM,KAAK,UAAU,EACnB,SAAS,KACX,CAAC,GACD;CACJ;CAEA,MAAa,UACX,QACkC;EAClC,MAAM,WAAW,MAAM,KAAK,MAAM,UAAU,MAAM;EAElD,OAAO;GACL,YAAY,SAAS;GACr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Symbol.toStringTag, { value: "Module" });
2
- const require_EngineBaseClient = require("./EngineBaseClient-zgQmbhJv.cjs");
2
+ const require_EngineBaseClient = require("./EngineBaseClient-J3nMzK0q.cjs");
3
3
  exports.EngineBaseClient = require_EngineBaseClient.EngineBaseClient;
@@ -127,7 +127,10 @@ var EngineBaseClient = class {
127
127
  * @public
128
128
  */
129
129
  async sign(requestType, verifyingContract, chainId, params) {
130
- const walletClient = this.opts.linkedSignerWalletClient ?? this.opts.walletClient;
130
+ const walletClient = (() => {
131
+ if (requestType === "withdraw_collateral_v2") return this.opts.walletClient;
132
+ return this.opts.linkedSignerWalletClient ?? this.opts.walletClient;
133
+ })();
131
134
  if (!walletClient) throw new WalletNotProvidedError();
132
135
  return getSignedTransactionRequest({
133
136
  chainId,
@@ -1 +1 @@
1
- {"version":3,"file":"EngineBaseClient.js","names":["successResponse"],"sources":["../src/EngineBaseClient.ts"],"sourcesContent":["import {\n getSignedTransactionRequest,\n SignableRequestType,\n SignableRequestTypeToParams,\n WalletClientWithAccount,\n WalletNotProvidedError,\n} from '@nadohq/shared';\nimport axios, { AxiosInstance, AxiosResponse } from 'axios';\nimport {\n EngineServerCachedQueryRequestByType,\n EngineServerCachedQueryRequestType,\n EngineServerCachedQueryResponse,\n EngineServerCachedQueryResponseByType,\n EngineServerCachedQuerySuccessResponse,\n EngineServerEdgeControlRequestByType,\n EngineServerEdgeControlRequestType,\n EngineServerEdgeControlResponseByType,\n EngineServerExecuteRequestByType,\n EngineServerExecuteRequestType,\n EngineServerExecuteResult,\n EngineServerExecuteSuccessResult,\n EngineServerQueryRequestByType,\n EngineServerQueryRequestType,\n EngineServerQueryResponse,\n EngineServerQueryResponseByType,\n EngineServerQuerySuccessResponse,\n GetEngineNoncesParams,\n GetEngineNoncesResponse,\n} from './types';\nimport { EngineServerFailureError } from './types/EngineServerFailureError';\n\nexport interface EngineClientOpts {\n // Server URL\n url: string;\n // Wallet client for EIP712 signing\n walletClient?: WalletClientWithAccount;\n // Linked signer registered through the engine, if provided, execute requests will use this signer\n linkedSignerWalletClient?: WalletClientWithAccount;\n}\n\n// Only 1 key can be defined per execute request\ntype EngineExecuteRequestBody = Partial<EngineServerExecuteRequestByType>;\n\ntype EngineQueryRequestResponse<\n T extends EngineServerQueryRequestType = EngineServerQueryRequestType,\n> = EngineServerQueryResponse<T>;\n\ntype EngineCachedQueryRequestResponse<\n T extends EngineServerCachedQueryRequestType =\n EngineServerCachedQueryRequestType,\n> = EngineServerCachedQueryResponse<T>;\n\n/**\n * Base client for all engine requests\n */\nexport class EngineBaseClient {\n readonly opts: EngineClientOpts;\n readonly axiosInstance: AxiosInstance;\n\n constructor(opts: EngineClientOpts) {\n this.opts = opts;\n this.axiosInstance = axios.create({\n withCredentials: true,\n // We have custom logic to validate response status and create an appropriate error\n validateStatus: () => true,\n });\n }\n\n /**\n * Sets the linked signer for execute requests\n *\n * @param linkedSignerWalletClient The linkedSigner to use for all signatures. Set to null to revert to the chain signer\n */\n public setLinkedSigner(\n linkedSignerWalletClient: WalletClientWithAccount | null,\n ) {\n this.opts.linkedSignerWalletClient = linkedSignerWalletClient ?? undefined;\n }\n\n public async getTxNonce(address?: string): Promise<string> {\n const addr = address ?? this.opts.walletClient?.account.address;\n\n if (!addr) {\n throw new WalletNotProvidedError();\n }\n\n return (\n await this.getNonces({\n address: addr,\n })\n ).txNonce;\n }\n\n public async getNonces(\n params: GetEngineNoncesParams,\n ): Promise<GetEngineNoncesResponse> {\n const baseResp = await this.query('nonces', params);\n\n return {\n orderNonce: baseResp.order_nonce,\n txNonce: baseResp.tx_nonce,\n };\n }\n\n /**\n * Queries the engine, all query params are stringified into the query string\n *\n * @param requestType\n * @param params\n * @public\n */\n public async query<TRequestType extends EngineServerQueryRequestType>(\n requestType: TRequestType,\n params: EngineServerQueryRequestByType[TRequestType],\n ): Promise<EngineServerQueryResponseByType[TRequestType]> {\n const request = this.getQueryRequest(requestType, params);\n const response = await this.axiosInstance.post<EngineQueryRequestResponse>(\n `${this.opts.url}/query`,\n request,\n );\n\n this.checkResponseStatus(response);\n this.checkServerStatus(response);\n\n // checkServerStatus throws on failure responses so the cast to the success response is acceptable here\n const successResponse = response as AxiosResponse<\n EngineServerQuerySuccessResponse<TRequestType>\n >;\n\n return successResponse.data.data;\n }\n\n /**\n * Queries the gateway's in-memory cache via the `/edge/query` endpoint. Lower latency than\n * {@link query} at the cost of eventual consistency — do not use for order, margin, or\n * settlement decisions.\n *\n * @param requestType\n * @param params\n * @public\n */\n public async edgeQuery<\n TRequestType extends EngineServerCachedQueryRequestType,\n >(\n requestType: TRequestType,\n params: EngineServerCachedQueryRequestByType[TRequestType],\n ): Promise<EngineServerCachedQueryResponseByType[TRequestType]> {\n const request = this.getQueryRequest(requestType, params);\n const response =\n await this.axiosInstance.post<EngineCachedQueryRequestResponse>(\n `${this.opts.url}/edge/query`,\n request,\n );\n\n this.checkResponseStatus(response);\n this.checkServerStatus(response);\n\n // checkServerStatus throws on failure responses so the cast to the success response is acceptable here\n const successResponse = response as AxiosResponse<\n EngineServerCachedQuerySuccessResponse<TRequestType>\n >;\n\n return successResponse.data.data;\n }\n\n /**\n * Sends an edge control message (`ping` / `time`) via the `/edge/query` endpoint. These\n * return immediately from the server clock and use a different envelope than the cached data\n * queries (no `data` field), so the whole response body is returned.\n *\n * @param requestType\n * @param params\n * @public\n */\n public async edgeControlQuery<\n TRequestType extends EngineServerEdgeControlRequestType,\n >(\n requestType: TRequestType,\n params: EngineServerEdgeControlRequestByType[TRequestType],\n ): Promise<EngineServerEdgeControlResponseByType[TRequestType]> {\n const request = this.getQueryRequest(requestType, params);\n const response = await this.axiosInstance.post<\n EngineServerEdgeControlResponseByType[TRequestType]\n >(`${this.opts.url}/edge/query`, request);\n\n this.checkResponseStatus(response);\n this.checkServerStatus(response);\n\n return response.data;\n }\n\n /**\n * POSTs an execute message to the engine and returns the successful response. Throws the failure response wrapped\n * in an EngineServerFailureError on failure.\n *\n * @param requestType\n * @param params\n * @public\n */\n public async execute<TRequestType extends EngineServerExecuteRequestType>(\n requestType: TRequestType,\n params: EngineServerExecuteRequestByType[TRequestType],\n ): Promise<EngineServerExecuteSuccessResult<TRequestType>> {\n const reqBody = this.getExecuteRequest(requestType, params);\n const response = await this.axiosInstance.post<\n EngineServerExecuteResult<TRequestType>\n >(`${this.opts.url}/execute`, reqBody);\n\n this.checkResponseStatus(response);\n this.checkServerStatus(response);\n\n // checkServerStatus catches the failure result and throws the error, so the cast to the success response is acceptable here\n return response.data as EngineServerExecuteSuccessResult<TRequestType>;\n }\n\n /**\n * A simple, typechecked fn for constructing a `type`-tagged request body in the format expected\n * by the server. Generic over the request type / params pair so it can build live query, edge\n * (cached) query, and edge control request bodies alike.\n *\n * @param requestType\n * @param params\n */\n public getQueryRequest<TRequestType extends string, TParams extends object>(\n requestType: TRequestType,\n params: TParams,\n ): { type: TRequestType } & TParams {\n return {\n type: requestType,\n ...params,\n };\n }\n\n /**\n * A simple, typechecked fn for constructing an execute request in the format expected by the server.\n *\n * @param requestType\n * @param params\n */\n public getExecuteRequest<TRequestType extends EngineServerExecuteRequestType>(\n requestType: TRequestType,\n params: EngineServerExecuteRequestByType[TRequestType],\n ): EngineExecuteRequestBody {\n return {\n [requestType]: params,\n };\n }\n\n /**\n * Signs a given request with the signer provided to the engine\n *\n * @param requestType\n * @param verifyingContract\n * @param chainId\n * @param params\n * @public\n */\n public async sign<T extends SignableRequestType>(\n requestType: T,\n verifyingContract: string,\n chainId: number,\n params: SignableRequestTypeToParams[T],\n ) {\n // Use the linked signer if provided, otherwise use the default signer provided to the engine\n const walletClient =\n this.opts.linkedSignerWalletClient ?? this.opts.walletClient;\n\n if (!walletClient) {\n throw new WalletNotProvidedError();\n }\n\n return getSignedTransactionRequest({\n chainId,\n requestParams: params,\n requestType,\n walletClient,\n verifyingContract,\n });\n }\n\n private checkResponseStatus(response: AxiosResponse) {\n if (response.status !== 200 || !response.data) {\n throw Error(\n `Unexpected response from server: ${response.status} ${response.statusText}. Data: ${response.data}`,\n );\n }\n }\n\n private checkServerStatus(\n response: AxiosResponse<\n | EngineServerExecuteResult\n | EngineQueryRequestResponse\n | EngineCachedQueryRequestResponse\n | EngineServerEdgeControlResponseByType[EngineServerEdgeControlRequestType]\n >,\n ) {\n if (response.data.status !== 'success') {\n throw new EngineServerFailureError(response.data);\n }\n }\n}\n"],"mappings":";;;;;;;AAuDA,IAAa,mBAAb,MAA8B;CAI5B,YAAY,MAAwB;EAClC,KAAK,OAAO;EACZ,KAAK,gBAAgB,MAAM,OAAO;GAChC,iBAAiB;GAEjB,sBAAsB;EACxB,CAAC;CACH;;;;;;CAOA,gBACE,0BACA;EACA,KAAK,KAAK,2BAA2B,4BAA4B,KAAA;CACnE;CAEA,MAAa,WAAW,SAAmC;EACzD,MAAM,OAAO,WAAW,KAAK,KAAK,cAAc,QAAQ;EAExD,IAAI,CAAC,MACH,MAAM,IAAI,uBAAuB;EAGnC,QACE,MAAM,KAAK,UAAU,EACnB,SAAS,KACX,CAAC,GACD;CACJ;CAEA,MAAa,UACX,QACkC;EAClC,MAAM,WAAW,MAAM,KAAK,MAAM,UAAU,MAAM;EAElD,OAAO;GACL,YAAY,SAAS;GACrB,SAAS,SAAS;EACpB;CACF;;;;;;;;CASA,MAAa,MACX,aACA,QACwD;EACxD,MAAM,UAAU,KAAK,gBAAgB,aAAa,MAAM;EACxD,MAAM,WAAW,MAAM,KAAK,cAAc,KACxC,GAAG,KAAK,KAAK,IAAI,SACjB,OACF;EAEA,KAAK,oBAAoB,QAAQ;EACjC,KAAK,kBAAkB,QAAQ;EAO/B,OAAOA,SAAgB,KAAK;CAC9B;;;;;;;;;;CAWA,MAAa,UAGX,aACA,QAC8D;EAC9D,MAAM,UAAU,KAAK,gBAAgB,aAAa,MAAM;EACxD,MAAM,WACJ,MAAM,KAAK,cAAc,KACvB,GAAG,KAAK,KAAK,IAAI,cACjB,OACF;EAEF,KAAK,oBAAoB,QAAQ;EACjC,KAAK,kBAAkB,QAAQ;EAO/B,OAAOA,SAAgB,KAAK;CAC9B;;;;;;;;;;CAWA,MAAa,iBAGX,aACA,QAC8D;EAC9D,MAAM,UAAU,KAAK,gBAAgB,aAAa,MAAM;EACxD,MAAM,WAAW,MAAM,KAAK,cAAc,KAExC,GAAG,KAAK,KAAK,IAAI,cAAc,OAAO;EAExC,KAAK,oBAAoB,QAAQ;EACjC,KAAK,kBAAkB,QAAQ;EAE/B,OAAO,SAAS;CAClB;;;;;;;;;CAUA,MAAa,QACX,aACA,QACyD;EACzD,MAAM,UAAU,KAAK,kBAAkB,aAAa,MAAM;EAC1D,MAAM,WAAW,MAAM,KAAK,cAAc,KAExC,GAAG,KAAK,KAAK,IAAI,WAAW,OAAO;EAErC,KAAK,oBAAoB,QAAQ;EACjC,KAAK,kBAAkB,QAAQ;EAG/B,OAAO,SAAS;CAClB;;;;;;;;;CAUA,gBACE,aACA,QACkC;EAClC,OAAO;GACL,MAAM;GACN,GAAG;EACL;CACF;;;;;;;CAQA,kBACE,aACA,QAC0B;EAC1B,OAAO,GACJ,cAAc,OACjB;CACF;;;;;;;;;;CAWA,MAAa,KACX,aACA,mBACA,SACA,QACA;EAEA,MAAM,eACJ,KAAK,KAAK,4BAA4B,KAAK,KAAK;EAElD,IAAI,CAAC,cACH,MAAM,IAAI,uBAAuB;EAGnC,OAAO,4BAA4B;GACjC;GACA,eAAe;GACf;GACA;GACA;EACF,CAAC;CACH;CAEA,oBAA4B,UAAyB;EACnD,IAAI,SAAS,WAAW,OAAO,CAAC,SAAS,MACvC,MAAM,MACJ,oCAAoC,SAAS,OAAO,GAAG,SAAS,WAAW,UAAU,SAAS,MAChG;CAEJ;CAEA,kBACE,UAMA;EACA,IAAI,SAAS,KAAK,WAAW,WAC3B,MAAM,IAAI,yBAAyB,SAAS,IAAI;CAEpD;AACF"}
1
+ {"version":3,"file":"EngineBaseClient.js","names":["successResponse"],"sources":["../src/EngineBaseClient.ts"],"sourcesContent":["import {\n getSignedTransactionRequest,\n SignableRequestType,\n SignableRequestTypeToParams,\n WalletClientWithAccount,\n WalletNotProvidedError,\n} from '@nadohq/shared';\nimport axios, { AxiosInstance, AxiosResponse } from 'axios';\nimport {\n EngineServerCachedQueryRequestByType,\n EngineServerCachedQueryRequestType,\n EngineServerCachedQueryResponse,\n EngineServerCachedQueryResponseByType,\n EngineServerCachedQuerySuccessResponse,\n EngineServerEdgeControlRequestByType,\n EngineServerEdgeControlRequestType,\n EngineServerEdgeControlResponseByType,\n EngineServerExecuteRequestByType,\n EngineServerExecuteRequestType,\n EngineServerExecuteResult,\n EngineServerExecuteSuccessResult,\n EngineServerQueryRequestByType,\n EngineServerQueryRequestType,\n EngineServerQueryResponse,\n EngineServerQueryResponseByType,\n EngineServerQuerySuccessResponse,\n GetEngineNoncesParams,\n GetEngineNoncesResponse,\n} from './types';\nimport { EngineServerFailureError } from './types/EngineServerFailureError';\n\nexport interface EngineClientOpts {\n // Server URL\n url: string;\n // Wallet client for EIP712 signing\n walletClient?: WalletClientWithAccount;\n // Linked signer registered through the engine, if provided, execute requests will use this signer\n linkedSignerWalletClient?: WalletClientWithAccount;\n}\n\n// Only 1 key can be defined per execute request\ntype EngineExecuteRequestBody = Partial<EngineServerExecuteRequestByType>;\n\ntype EngineQueryRequestResponse<\n T extends EngineServerQueryRequestType = EngineServerQueryRequestType,\n> = EngineServerQueryResponse<T>;\n\ntype EngineCachedQueryRequestResponse<\n T extends EngineServerCachedQueryRequestType =\n EngineServerCachedQueryRequestType,\n> = EngineServerCachedQueryResponse<T>;\n\n/**\n * Base client for all engine requests\n */\nexport class EngineBaseClient {\n readonly opts: EngineClientOpts;\n readonly axiosInstance: AxiosInstance;\n\n constructor(opts: EngineClientOpts) {\n this.opts = opts;\n this.axiosInstance = axios.create({\n withCredentials: true,\n // We have custom logic to validate response status and create an appropriate error\n validateStatus: () => true,\n });\n }\n\n /**\n * Sets the linked signer for execute requests\n *\n * @param linkedSignerWalletClient The linkedSigner to use for all signatures. Set to null to revert to the chain signer\n */\n public setLinkedSigner(\n linkedSignerWalletClient: WalletClientWithAccount | null,\n ) {\n this.opts.linkedSignerWalletClient = linkedSignerWalletClient ?? undefined;\n }\n\n public async getTxNonce(address?: string): Promise<string> {\n const addr = address ?? this.opts.walletClient?.account.address;\n\n if (!addr) {\n throw new WalletNotProvidedError();\n }\n\n return (\n await this.getNonces({\n address: addr,\n })\n ).txNonce;\n }\n\n public async getNonces(\n params: GetEngineNoncesParams,\n ): Promise<GetEngineNoncesResponse> {\n const baseResp = await this.query('nonces', params);\n\n return {\n orderNonce: baseResp.order_nonce,\n txNonce: baseResp.tx_nonce,\n };\n }\n\n /**\n * Queries the engine, all query params are stringified into the query string\n *\n * @param requestType\n * @param params\n * @public\n */\n public async query<TRequestType extends EngineServerQueryRequestType>(\n requestType: TRequestType,\n params: EngineServerQueryRequestByType[TRequestType],\n ): Promise<EngineServerQueryResponseByType[TRequestType]> {\n const request = this.getQueryRequest(requestType, params);\n const response = await this.axiosInstance.post<EngineQueryRequestResponse>(\n `${this.opts.url}/query`,\n request,\n );\n\n this.checkResponseStatus(response);\n this.checkServerStatus(response);\n\n // checkServerStatus throws on failure responses so the cast to the success response is acceptable here\n const successResponse = response as AxiosResponse<\n EngineServerQuerySuccessResponse<TRequestType>\n >;\n\n return successResponse.data.data;\n }\n\n /**\n * Queries the gateway's in-memory cache via the `/edge/query` endpoint. Lower latency than\n * {@link query} at the cost of eventual consistency — do not use for order, margin, or\n * settlement decisions.\n *\n * @param requestType\n * @param params\n * @public\n */\n public async edgeQuery<\n TRequestType extends EngineServerCachedQueryRequestType,\n >(\n requestType: TRequestType,\n params: EngineServerCachedQueryRequestByType[TRequestType],\n ): Promise<EngineServerCachedQueryResponseByType[TRequestType]> {\n const request = this.getQueryRequest(requestType, params);\n const response =\n await this.axiosInstance.post<EngineCachedQueryRequestResponse>(\n `${this.opts.url}/edge/query`,\n request,\n );\n\n this.checkResponseStatus(response);\n this.checkServerStatus(response);\n\n // checkServerStatus throws on failure responses so the cast to the success response is acceptable here\n const successResponse = response as AxiosResponse<\n EngineServerCachedQuerySuccessResponse<TRequestType>\n >;\n\n return successResponse.data.data;\n }\n\n /**\n * Sends an edge control message (`ping` / `time`) via the `/edge/query` endpoint. These\n * return immediately from the server clock and use a different envelope than the cached data\n * queries (no `data` field), so the whole response body is returned.\n *\n * @param requestType\n * @param params\n * @public\n */\n public async edgeControlQuery<\n TRequestType extends EngineServerEdgeControlRequestType,\n >(\n requestType: TRequestType,\n params: EngineServerEdgeControlRequestByType[TRequestType],\n ): Promise<EngineServerEdgeControlResponseByType[TRequestType]> {\n const request = this.getQueryRequest(requestType, params);\n const response = await this.axiosInstance.post<\n EngineServerEdgeControlResponseByType[TRequestType]\n >(`${this.opts.url}/edge/query`, request);\n\n this.checkResponseStatus(response);\n this.checkServerStatus(response);\n\n return response.data;\n }\n\n /**\n * POSTs an execute message to the engine and returns the successful response. Throws the failure response wrapped\n * in an EngineServerFailureError on failure.\n *\n * @param requestType\n * @param params\n * @public\n */\n public async execute<TRequestType extends EngineServerExecuteRequestType>(\n requestType: TRequestType,\n params: EngineServerExecuteRequestByType[TRequestType],\n ): Promise<EngineServerExecuteSuccessResult<TRequestType>> {\n const reqBody = this.getExecuteRequest(requestType, params);\n const response = await this.axiosInstance.post<\n EngineServerExecuteResult<TRequestType>\n >(`${this.opts.url}/execute`, reqBody);\n\n this.checkResponseStatus(response);\n this.checkServerStatus(response);\n\n // checkServerStatus catches the failure result and throws the error, so the cast to the success response is acceptable here\n return response.data as EngineServerExecuteSuccessResult<TRequestType>;\n }\n\n /**\n * A simple, typechecked fn for constructing a `type`-tagged request body in the format expected\n * by the server. Generic over the request type / params pair so it can build live query, edge\n * (cached) query, and edge control request bodies alike.\n *\n * @param requestType\n * @param params\n */\n public getQueryRequest<TRequestType extends string, TParams extends object>(\n requestType: TRequestType,\n params: TParams,\n ): { type: TRequestType } & TParams {\n return {\n type: requestType,\n ...params,\n };\n }\n\n /**\n * A simple, typechecked fn for constructing an execute request in the format expected by the server.\n *\n * @param requestType\n * @param params\n */\n public getExecuteRequest<TRequestType extends EngineServerExecuteRequestType>(\n requestType: TRequestType,\n params: EngineServerExecuteRequestByType[TRequestType],\n ): EngineExecuteRequestBody {\n return {\n [requestType]: params,\n };\n }\n\n /**\n * Signs a given request with the signer provided to the engine\n *\n * @param requestType\n * @param verifyingContract\n * @param chainId\n * @param params\n * @public\n */\n public async sign<T extends SignableRequestType>(\n requestType: T,\n verifyingContract: string,\n chainId: number,\n params: SignableRequestTypeToParams[T],\n ) {\n // Use the linked signer if provided, otherwise use the default signer provided to the engine\n // However, always use wallet signer for withdraw_collateral_v2 as linked signers are not allowed for different\n // withdrawal addresses\n const walletClient = (() => {\n if (requestType === 'withdraw_collateral_v2') {\n return this.opts.walletClient;\n }\n return this.opts.linkedSignerWalletClient ?? this.opts.walletClient;\n })();\n\n if (!walletClient) {\n throw new WalletNotProvidedError();\n }\n\n return getSignedTransactionRequest({\n chainId,\n requestParams: params,\n requestType,\n walletClient,\n verifyingContract,\n });\n }\n\n private checkResponseStatus(response: AxiosResponse) {\n if (response.status !== 200 || !response.data) {\n throw Error(\n `Unexpected response from server: ${response.status} ${response.statusText}. Data: ${response.data}`,\n );\n }\n }\n\n private checkServerStatus(\n response: AxiosResponse<\n | EngineServerExecuteResult\n | EngineQueryRequestResponse\n | EngineCachedQueryRequestResponse\n | EngineServerEdgeControlResponseByType[EngineServerEdgeControlRequestType]\n >,\n ) {\n if (response.data.status !== 'success') {\n throw new EngineServerFailureError(response.data);\n }\n }\n}\n"],"mappings":";;;;;;;AAuDA,IAAa,mBAAb,MAA8B;CAI5B,YAAY,MAAwB;EAClC,KAAK,OAAO;EACZ,KAAK,gBAAgB,MAAM,OAAO;GAChC,iBAAiB;GAEjB,sBAAsB;EACxB,CAAC;CACH;;;;;;CAOA,gBACE,0BACA;EACA,KAAK,KAAK,2BAA2B,4BAA4B,KAAA;CACnE;CAEA,MAAa,WAAW,SAAmC;EACzD,MAAM,OAAO,WAAW,KAAK,KAAK,cAAc,QAAQ;EAExD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UA,gBACE,aACA,QACkC;EAClC,OAAO;GACL,MAAM;GACN,GAAG;EACL;CACF;;;;;;;CAQA,kBACE,aACA,QAC0B;EAC1B,OAAO,GACJ,cAAc,OACjB;CACF;;;;;;;;;;CAWA,MAAa,KACX,aACA,mBACA,SACA,QACA;EAIA,MAAM,sBAAsB;GAC1B,IAAI,gBAAgB,0BAClB,OAAO,KAAK,KAAK;GAEnB,OAAO,KAAK,KAAK,4BAA4B,KAAK,KAAK;EACzD,GAAG;EAEH,IAAI,CAAC,cACH,MAAM,IAAI,uBAAuB;EAGnC,OAAO,4BAA4B;GACjC;GACA,eAAe;GACf;GACA;GACA;EACF,CAAC;CACH;CAEA,oBAA4B,UAAyB;EACnD,IAAI,SAAS,WAAW,OAAO,CAAC,SAAS,MACvC,MAAM,MACJ,oCAAoC,SAAS,OAAO,GAAG,SAAS,WAAW,UAAU,SAAS,MAChG;CAEJ;CAEA,kBACE,UAMA;EACA,IAAI,SAAS,KAAK,WAAW,WAC3B,MAAM,IAAI,yBAAyB,SAAS,IAAI;CAEpD;AACF"}
@@ -1,5 +1,5 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
- require("./EngineBaseClient-zgQmbhJv.cjs");
2
+ require("./EngineBaseClient-J3nMzK0q.cjs");
3
3
  const require_EngineEdgeQueryClient = require("./EngineEdgeQueryClient.cjs");
4
4
  const require_EngineExecuteClient = require("./EngineExecuteClient.cjs");
5
5
  const require_EngineQueryClient = require("./EngineQueryClient.cjs");
@@ -1,5 +1,5 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
- const require_EngineBaseClient = require("./EngineBaseClient-zgQmbhJv.cjs");
2
+ const require_EngineBaseClient = require("./EngineBaseClient-J3nMzK0q.cjs");
3
3
  const require_utils_productEngineTypeMappers = require("./utils/productEngineTypeMappers.cjs");
4
4
  const require_utils_queryDataMappers = require("./utils/queryDataMappers.cjs");
5
5
  let _nadohq_shared = require("@nadohq/shared");
@@ -1,5 +1,5 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
- require("./EngineBaseClient-zgQmbhJv.cjs");
2
+ require("./EngineBaseClient-J3nMzK0q.cjs");
3
3
  let _nadohq_shared = require("@nadohq/shared");
4
4
  //#region src/EngineExecuteBuilder.ts
5
5
  /**
@@ -1,5 +1,5 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
- const require_EngineBaseClient = require("./EngineBaseClient-zgQmbhJv.cjs");
2
+ const require_EngineBaseClient = require("./EngineBaseClient-J3nMzK0q.cjs");
3
3
  const require_EngineExecuteBuilder = require("./EngineExecuteBuilder.cjs");
4
4
  let _nadohq_shared = require("@nadohq/shared");
5
5
  //#region src/EngineExecuteClient.ts
@@ -1,5 +1,5 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
- const require_EngineBaseClient = require("./EngineBaseClient-zgQmbhJv.cjs");
2
+ const require_EngineBaseClient = require("./EngineBaseClient-J3nMzK0q.cjs");
3
3
  const require_utils_productEngineTypeMappers = require("./utils/productEngineTypeMappers.cjs");
4
4
  const require_utils_queryDataMappers = require("./utils/queryDataMappers.cjs");
5
5
  let _nadohq_shared = require("@nadohq/shared");
@@ -1,5 +1,5 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
- const require_EngineBaseClient = require("./EngineBaseClient-zgQmbhJv.cjs");
2
+ const require_EngineBaseClient = require("./EngineBaseClient-J3nMzK0q.cjs");
3
3
  //#region src/EngineWebClient.ts
4
4
  const COUNTRY_HEADER = "x-nado-country";
5
5
  /**
@@ -1,5 +1,5 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
- require("../EngineBaseClient-zgQmbhJv.cjs");
2
+ require("../EngineBaseClient-J3nMzK0q.cjs");
3
3
  let _nadohq_shared = require("@nadohq/shared");
4
4
  //#region src/utils/productEngineTypeMappers.ts
5
5
  function mapProductEngineType(productEngineType) {
@@ -1,5 +1,5 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
- require("../EngineBaseClient-zgQmbhJv.cjs");
2
+ require("../EngineBaseClient-J3nMzK0q.cjs");
3
3
  const require_utils_productEngineTypeMappers = require("./productEngineTypeMappers.cjs");
4
4
  let _nadohq_shared = require("@nadohq/shared");
5
5
  //#region src/utils/queryDataMappers.ts
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nadohq/engine-client",
3
- "version": "0.22.0",
3
+ "version": "0.22.1",
4
4
  "type": "module",
5
5
  "sideEffects": false,
6
6
  "description": "HTTP client for the Nado off-chain matching engine",
@@ -41,7 +41,7 @@
41
41
  "module": "./dist/index.js",
42
42
  "types": "./dist/index.d.ts",
43
43
  "dependencies": {
44
- "@nadohq/shared": "^0.22.0",
44
+ "@nadohq/shared": "^0.22.1",
45
45
  "axios": "1.16.1",
46
46
  "ts-mixer": "6.0.4"
47
47
  },
@@ -53,5 +53,5 @@
53
53
  "bignumber.js": "11.1.1",
54
54
  "viem": "2.52.0"
55
55
  },
56
- "gitHead": "51832b1df792a24e2793a7365267126a0ecd678e"
56
+ "gitHead": "040857b674c8236b280441329664c9f802728af2"
57
57
  }
@@ -262,8 +262,14 @@ export class EngineBaseClient {
262
262
  params: SignableRequestTypeToParams[T],
263
263
  ) {
264
264
  // Use the linked signer if provided, otherwise use the default signer provided to the engine
265
- const walletClient =
266
- this.opts.linkedSignerWalletClient ?? this.opts.walletClient;
265
+ // However, always use wallet signer for withdraw_collateral_v2 as linked signers are not allowed for different
266
+ // withdrawal addresses
267
+ const walletClient = (() => {
268
+ if (requestType === 'withdraw_collateral_v2') {
269
+ return this.opts.walletClient;
270
+ }
271
+ return this.opts.linkedSignerWalletClient ?? this.opts.walletClient;
272
+ })();
267
273
 
268
274
  if (!walletClient) {
269
275
  throw new WalletNotProvidedError();