Skip to content

Commit

Permalink
Merge pull request #31 from sourabhxyz/upd-maestro-provider
Browse files Browse the repository at this point in the history
Updates to Maestro provider in sync with changes done in Anastasia-La…
  • Loading branch information
micahkendall authored Jan 17, 2024
2 parents 4dd6903 + f1b1772 commit e103655
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 5 deletions.
6 changes: 5 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,11 @@ optimizeDeps: {
import { Maestro, Translucent } from "translucent-cardano";

const translucent = await Translucent.new(
new Maestro({ network: "Mainnet", apiKey: "<apikey>" }),
new Maestro({
network: "Mainnet",
apiKey: "<apikey>",
turboSubmit: true
}),
"Mainnet",
);

Expand Down
14 changes: 10 additions & 4 deletions src/provider/maestro.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -182,7 +184,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 @@ -211,7 +213,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 @@ -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,
Expand Down Expand Up @@ -356,7 +362,7 @@ type MaestroScript = {

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

type MaestroUtxo = {
Expand Down

0 comments on commit e103655

Please sign in to comment.