Skip to content

Commit 050a2e4

Browse files
authored
fix: return executeQuote result to client (#227)
* Return execute quote result * Add changeset
1 parent 45191c7 commit 050a2e4

File tree

4 files changed

+44
-5
lines changed

4 files changed

+44
-5
lines changed

.changeset/three-papayas-tie.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@across-protocol/app-sdk": minor
3+
---
4+
5+
The executeQuote client function should return a deposit id and deposit/fill transaction receipts.

packages/sdk/src/actions/executeQuote.ts

Lines changed: 25 additions & 3 deletions
Original file line numberDiff line numberDiff 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;

packages/sdk/src/client.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ import {
3333
SimulateUpdateDepositTxParams,
3434
signUpdateDepositTypedData,
3535
SignUpdateDepositTypedDataParams,
36+
ExecuteQuoteResponseParams,
3637
} from "./actions/index.js";
3738
import {
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,

packages/sdk/test/e2e/executeQuote.test.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import {
99
} from "vitest";
1010
import { mainnetTestClient as testClient } from "../common/sdk.js";
1111
import {
12+
ExecuteQuoteResponseParams,
1213
parseDepositLogs,
1314
parseFillLogs,
1415
type Quote,
@@ -58,6 +59,7 @@ let depositTxSuccess = false;
5859
let fillTxSuccess = false;
5960
let depositLog: ReturnType<typeof parseDepositLogs> | undefined;
6061
let fillLog: ReturnType<typeof parseFillLogs> | undefined;
62+
let executeQuoteResult: ExecuteQuoteResponseParams;
6163

6264
describe("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
});

0 commit comments

Comments
 (0)