From d9741e884b9fb7d44f8f3a8e877a56b11825d3e4 Mon Sep 17 00:00:00 2001 From: sourabhxyz Date: Mon, 8 Jan 2024 21:17:15 +0530 Subject: [PATCH 1/2] Updates to Maestro provider in sync with changes done in Anastasia-Labs/lucid --- 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 c290042..a7cf594 100644 --- a/src/provider/maestro.ts +++ b/src/provider/maestro.ts @@ -114,7 +114,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", @@ -182,7 +184,7 @@ export class Maestro implements Provider { method: "POST", headers: { "Content-Type": "application/json", - ...this.commonHeaders(), + ...(this.requireAmountsAsStrings(this.commonHeaders())), }, body: body, }), @@ -211,7 +213,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(), }, @@ -278,6 +280,10 @@ export class Maestro implements Provider { return { "api-key": this.apiKey, translucent: packageJson.version }; } + private requireAmountsAsStrings(obj: { "api-key": string; translucent: string }) { + return { ...obj, "amounts-as-strings": "true" }; + } + private maestroUtxoToUtxo(result: MaestroUtxo): UTxO { return { txHash: result.tx_hash, @@ -356,7 +362,7 @@ type MaestroScript = { type MaestroAsset = { unit: string; - amount: number; + amount: string; }; type MaestroUtxo = { From f1b1772f3743809b30f75202caeb729f372a00f3 Mon Sep 17 00:00:00 2001 From: sourabhxyz Date: Mon, 15 Jan 2024 14:42:23 +0530 Subject: [PATCH 2/2] Updated example usage of Maestro provider --- README.md | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 0941c72..161089b 100644 --- a/README.md +++ b/README.md @@ -67,7 +67,11 @@ optimizeDeps: { import { Maestro, Translucent } from "translucent-cardano"; const translucent = await Translucent.new( - new Maestro({ network: "Mainnet", apiKey: "" }), + new Maestro({ + network: "Mainnet", + apiKey: "", + turboSubmit: true + }), "Mainnet", );