Skip to content

Commit

Permalink
Feat spacebudz#235: Update in Maestro provider to allow for correctly…
Browse files Browse the repository at this point in the history
… parsing 64 bit signed integer values
  • Loading branch information
sourabhxyz committed Nov 25, 2023
1 parent 81e4b4e commit 8e39e48
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions src/provider/maestro.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -177,7 +179,7 @@ export class Maestro implements Provider {
method: "POST",
headers: {
"Content-Type": "application/json",
...this.commonHeaders(),
...(this.requireAmountsAsStrings(this.commonHeaders())),
},
body: body,
}),
Expand Down Expand Up @@ -206,7 +208,7 @@ export class Maestro implements Provider {

async getDatum(datumHash: DatumHash): Promise<Datum> {
const timestampedResultResponse = await fetch(
`${this.url}/datum/${datumHash}`,
`${this.url}/datums/${datumHash}`,
{
headers: this.commonHeaders(),
},
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -344,7 +350,7 @@ type MaestroScript = {

type MaestroAsset = {
unit: string;
amount: number;
amount: string;
};

type MaestroUtxo = {
Expand Down

0 comments on commit 8e39e48

Please sign in to comment.