Skip to content

Commit

Permalink
Merge pull request #324 from bob-collective/feat/quote-total
Browse files Browse the repository at this point in the history
feat: optional amount for quote total
  • Loading branch information
gregdhill authored Aug 28, 2024
2 parents 858761f + c8022b0 commit d1345da
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 2 deletions.
2 changes: 1 addition & 1 deletion sdk/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@gobob/bob-sdk",
"version": "2.1.0",
"version": "2.2.0",
"main": "dist/index.js",
"types": "dist/index.d.ts",
"scripts": {
Expand Down
4 changes: 3 additions & 1 deletion sdk/src/gateway/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,8 @@ type GatewayStartOrderResult = GatewayCreateOrderResponse & {
psbtBase64?: string;
};

type Optional<T, K extends keyof T> = Omit<T, K> & Partial<T>;

/**
* Base url for the mainnet Gateway API.
* @default "https://gateway-api-mainnet.gobob.xyz"
Expand Down Expand Up @@ -133,7 +135,7 @@ export class GatewayApiClient {
*
* @param params The parameters for the quote.
*/
async getQuote(params: GatewayQuoteParams): Promise<GatewayQuote> {
async getQuote(params: Optional<GatewayQuoteParams, "amount" | "toUserAddress">): Promise<GatewayQuote> {
const isMainnet = params.toChain === 60808 || typeof params.toChain === "string" && params.toChain.toLowerCase() === Chains.BOB;
const isTestnet = params.toChain === 808813 || typeof params.toChain === "string" && params.toChain.toLowerCase() === Chains.BOBSepolia;

Expand Down
10 changes: 10 additions & 0 deletions sdk/test/gateway.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,16 @@ describe("Gateway Tests", () => {
toUserAddress: ZeroAddress,
amount: 1000,
}), mockQuote);

// get the total available without amount
nock(`${MAINNET_GATEWAY_BASE_URL}`)
.get(`/quote/${SYMBOL_LOOKUP["tbtc"].bob}/`)
.reply(200, mockQuote);
assert.deepEqual(await gatewaySDK.getQuote({
toChain: "BOB",
toToken: SYMBOL_LOOKUP["tbtc"].bob,
toUserAddress: ZeroAddress,
}), mockQuote);
});

it("should start order", async () => {
Expand Down

0 comments on commit d1345da

Please sign in to comment.