File tree Expand file tree Collapse file tree 4 files changed +44
-5
lines changed
Expand file tree Collapse file tree 4 files changed +44
-5
lines changed Original file line number Diff line number Diff line change 1+ ---
2+ " @across-protocol/app-sdk " : minor
3+ ---
4+
5+ The executeQuote client function should return a deposit id and deposit/fill transaction receipts.
Original file line number Diff line number Diff line change @@ -163,16 +163,38 @@ export type ExecuteQuoteParams = {
163163 logger ?: LoggerT ;
164164} ;
165165
166+ /**
167+ * Response parameters for {@link executeQuote}.
168+ */
169+ export type ExecuteQuoteResponseParams = {
170+ /**
171+ * The ID of the deposit transaction.
172+ */
173+ depositId ?: DepositStatus [ "depositId" ] ;
174+ /**
175+ * The receipt of the deposit transaction.
176+ */
177+ depositTxReceipt ?: TransactionReceipt ;
178+ /**
179+ * The receipt of the fill transaction.
180+ */
181+ fillTxReceipt ?: TransactionReceipt ;
182+ /**
183+ * Error object if an error occurred and throwOnError was false.
184+ */
185+ error ?: Error ;
186+ } ;
187+
166188/**
167189 * Executes a quote by:
168190 * 1. Approving the SpokePool contract if necessary
169191 * 2. Depositing the input token on the origin chain
170192 * 3. Waiting for the deposit to be filled on the destination chain
171193 * @param params - See {@link ExecuteQuoteParams}.
172- * @returns The deposit ID and receipts for the deposit and fill transactions.
194+ * @returns The deposit ID and receipts for the deposit and fill transactions. See { @link ExecuteQuoteResponseParams}.
173195 * @public
174196 */
175- export async function executeQuote ( params : ExecuteQuoteParams ) {
197+ export async function executeQuote ( params : ExecuteQuoteParams ) : Promise < ExecuteQuoteResponseParams > {
176198 const {
177199 integratorId,
178200 deposit,
@@ -409,7 +431,7 @@ export async function executeQuote(params: ExecuteQuoteParams) {
409431 } ) ;
410432
411433 if ( ! throwOnError ) {
412- return { error } ;
434+ return { error : error as Error } ;
413435 }
414436
415437 throw error ;
Original file line number Diff line number Diff line change @@ -33,6 +33,7 @@ import {
3333 SimulateUpdateDepositTxParams ,
3434 signUpdateDepositTypedData ,
3535 SignUpdateDepositTypedDataParams ,
36+ ExecuteQuoteResponseParams ,
3637} from "./actions/index.js" ;
3738import {
3839 MAINNET_API_URL ,
@@ -286,7 +287,7 @@ export class AcrossClient {
286287 ExecuteQuoteParams ,
287288 "logger" | "originClient" | "destinationClient" | "integratorId"
288289 > ,
289- ) {
290+ ) : Promise < ExecuteQuoteResponseParams > {
290291 const logger = params ?. logger ?? this . logger ;
291292 const originClient =
292293 params ?. originClient ??
@@ -304,7 +305,7 @@ export class AcrossClient {
304305 }
305306
306307 try {
307- await executeQuote ( {
308+ return await executeQuote ( {
308309 ...params ,
309310 integratorId,
310311 logger,
Original file line number Diff line number Diff line change 99} from "vitest" ;
1010import { mainnetTestClient as testClient } from "../common/sdk.js" ;
1111import {
12+ ExecuteQuoteResponseParams ,
1213 parseDepositLogs ,
1314 parseFillLogs ,
1415 type Quote ,
@@ -58,6 +59,7 @@ let depositTxSuccess = false;
5859let fillTxSuccess = false ;
5960let depositLog : ReturnType < typeof parseDepositLogs > | undefined ;
6061let fillLog : ReturnType < typeof parseFillLogs > | undefined ;
62+ let executeQuoteResult : ExecuteQuoteResponseParams ;
6163
6264describe ( "executeQuote" , async ( ) => {
6365 test ( "Gets available routes for intent" , async ( ) => {
@@ -196,6 +198,8 @@ describe("executeQuote", async () => {
196198 rej ( false ) ;
197199 }
198200 } ,
201+ } ) . then ( ( result : ExecuteQuoteResponseParams ) => {
202+ executeQuoteResult = result ;
199203 } ) ;
200204 } ) ;
201205 } ) ;
@@ -253,5 +257,12 @@ describe("executeQuote", async () => {
253257 ) ;
254258 } ) ;
255259 } ) ;
260+
261+ test ( "ExecuteQuote returns expected result" , ( ) => {
262+ expect ( executeQuoteResult . depositId ) . toBeDefined ( ) ;
263+ expect ( executeQuoteResult . depositTxReceipt ) . toBeDefined ( ) ;
264+ expect ( executeQuoteResult . fillTxReceipt ) . toBeDefined ( ) ;
265+ expect ( executeQuoteResult . error ) . toBeUndefined ( ) ;
266+ } ) ;
256267 } ) ;
257268} ) ;
You can’t perform that action at this time.
0 commit comments