Skip to content

Commit

Permalink
refactor(sdk): improve error message for jup swap (#691)
Browse files Browse the repository at this point in the history
  • Loading branch information
ChesterSim authored Nov 13, 2023
1 parent 5b5f488 commit 78392ab
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
4 changes: 4 additions & 0 deletions sdk/src/driftClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3733,6 +3733,10 @@ export class DriftClient {
quote = fetchedQuote;
}

if (!quote) {
throw new Error("Could not fetch Jupiter's quote. Please try again.");
}

const transaction = await jupiterClient.getSwap({
quote,
userPublicKey: this.provider.wallet.publicKey,
Expand Down
4 changes: 4 additions & 0 deletions sdk/src/jupiter/jupiterClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -319,6 +319,10 @@ export class JupiterClient {
userPublicKey: PublicKey;
slippageBps?: number;
}): Promise<VersionedTransaction> {
if (!quote) {
throw new Error("Jupiter swap quote not provided. Please try again.");
}

const resp = await (
await fetch(`${this.url}/v6/swap`, {
method: 'POST',
Expand Down

0 comments on commit 78392ab

Please sign in to comment.