From 8e39e487a0762f1bc33ae7c8402164e48bf7f7be Mon Sep 17 00:00:00 2001 From: sourabhxyz Date: Sat, 25 Nov 2023 12:35:33 +0530 Subject: [PATCH] Feat #235: Update in Maestro provider to allow for correctly parsing 64 bit signed integer values --- src/provider/maestro.ts | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/src/provider/maestro.ts b/src/provider/maestro.ts index 26f37113..c2626561 100644 --- a/src/provider/maestro.ts +++ b/src/provider/maestro.ts @@ -109,7 +109,9 @@ export class Maestro implements Provider { }); const result: MaestroUtxos = await this.getAllPagesData( async (qry: string) => - await fetch(qry, { headers: this.commonHeaders() }), + await fetch(qry, { + headers: this.requireAmountsAsStrings(this.commonHeaders()), + }), `${this.url}${queryPredicate}/utxos`, qparams, "Location: getUtxosInternal. Error: Could not fetch UTxOs from Maestro", @@ -177,7 +179,7 @@ export class Maestro implements Provider { method: "POST", headers: { "Content-Type": "application/json", - ...this.commonHeaders(), + ...(this.requireAmountsAsStrings(this.commonHeaders())), }, body: body, }), @@ -206,7 +208,7 @@ export class Maestro implements Provider { async getDatum(datumHash: DatumHash): Promise { const timestampedResultResponse = await fetch( - `${this.url}/datum/${datumHash}`, + `${this.url}/datums/${datumHash}`, { headers: this.commonHeaders(), }, @@ -271,6 +273,10 @@ export class Maestro implements Provider { return { "api-key": this.apiKey, lucid }; } + private requireAmountsAsStrings(obj: { "api-key": string; lucid: string }) { + return { ...obj, "amounts-as-strings": "true" }; + } + private maestroUtxoToUtxo(result: MaestroUtxo): UTxO { return { txHash: result.tx_hash, @@ -344,7 +350,7 @@ type MaestroScript = { type MaestroAsset = { unit: string; - amount: number; + amount: string; }; type MaestroUtxo = {