From 0927d9c77d12c97f328e27795c46d3803ac73f37 Mon Sep 17 00:00:00 2001 From: Agustin Armellini Fischer Date: Wed, 18 Dec 2024 09:29:40 +0100 Subject: [PATCH] Fix crossmint api calls --- typescript/.changeset/weak-books-wonder.md | 5 +++++ .../crossmint/src/plugins/faucet.service.ts | 9 +++++++-- .../wallets/crossmint/src/plugins/mint.service.ts | 15 ++++++++++++--- 3 files changed, 24 insertions(+), 5 deletions(-) create mode 100644 typescript/.changeset/weak-books-wonder.md diff --git a/typescript/.changeset/weak-books-wonder.md b/typescript/.changeset/weak-books-wonder.md new file mode 100644 index 000000000..fd14b8b1a --- /dev/null +++ b/typescript/.changeset/weak-books-wonder.md @@ -0,0 +1,5 @@ +--- +"@goat-sdk/crossmint": patch +--- + +Add content type to API calls diff --git a/typescript/packages/wallets/crossmint/src/plugins/faucet.service.ts b/typescript/packages/wallets/crossmint/src/plugins/faucet.service.ts index fbd446f66..02ed0cfc0 100644 --- a/typescript/packages/wallets/crossmint/src/plugins/faucet.service.ts +++ b/typescript/packages/wallets/crossmint/src/plugins/faucet.service.ts @@ -35,14 +35,19 @@ export class CrossmintFaucetService { const options = { method: "POST", - headers: this.client.authHeaders, + headers: { + ...this.client.authHeaders, + "Content-Type": "application/json", + }, body: JSON.stringify({ - amount: parameters.amount, + amount: 10, currency: "usdc", chain, }), }; + console.log("options", options); + const response = await fetch( `${this.client.baseUrl}/api/v1-alpha2/wallets/${resolvedWalletAddress}/balances`, options, diff --git a/typescript/packages/wallets/crossmint/src/plugins/mint.service.ts b/typescript/packages/wallets/crossmint/src/plugins/mint.service.ts index a2338d6fb..09802f5cb 100644 --- a/typescript/packages/wallets/crossmint/src/plugins/mint.service.ts +++ b/typescript/packages/wallets/crossmint/src/plugins/mint.service.ts @@ -17,7 +17,10 @@ export class CrossmintMintService { ...parameters, chain: getCrossmintChainString(walletClient.getChain()), }), - headers: this.client.authHeaders, + headers: { + ...this.client.authHeaders, + "Content-Type": "application/json", + }, }); const result = await response.json(); @@ -44,7 +47,10 @@ export class CrossmintMintService { }) async getAllCollections(walletClient: EVMWalletClient, parameters: GetAllCollectionsParameters) { const response = await fetch(`${this.client.baseUrl}/collections/`, { - headers: this.client.authHeaders, + headers: { + ...this.client.authHeaders, + "Content-Type": "application/json", + }, }); return await response.json(); @@ -101,7 +107,10 @@ export class CrossmintMintService { while (true) { attempts++; const response = await fetch(`${this.client.baseUrl}/api/2022-06-09/actions/${actionId}`, { - headers: this.client.authHeaders, + headers: { + ...this.client.authHeaders, + "Content-Type": "application/json", + }, }); const body = await response.json();