Skip to content

Commit

Permalink
Fix PlutusV3 cost model encoding in Blockfrost (#231)
Browse files Browse the repository at this point in the history
* fix: use raw cost models and don't sort

* chore: commit changeset
  • Loading branch information
yHSJ authored Jan 17, 2025
1 parent 5abe8ce commit 57d4c3c
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 9 deletions.
5 changes: 5 additions & 0 deletions .changeset/shaggy-turkeys-end.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@blaze-cardano/query": patch
---

fix cost model encoding for plutusv3
15 changes: 6 additions & 9 deletions packages/blaze-query/src/blockfrost.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,15 +83,11 @@ export class Blockfrost extends Provider {
}
// Build cost models
const costModels: CostModels = new Map();
for (const cm of Object.keys(
response.cost_models,
) as BlockfrostLanguageVersions[]) {
const costModel: number[] = [];
const keys = Object.keys(response.cost_models[cm]).sort();
for (const key of keys) {
costModel.push(response.cost_models[cm][key]!);
}
costModels.set(fromBlockfrostLanguageVersion(cm), costModel);
for (const [key, value] of Object.entries(response.cost_models_raw)) {
costModels.set(
fromBlockfrostLanguageVersion(key as BlockfrostLanguageVersions),
value,
);
}

return {
Expand Down Expand Up @@ -737,6 +733,7 @@ export interface BlockfrostProtocolParametersResponse {
min_pool_cost: number;
nonce: string;
cost_models: Record<BlockfrostLanguageVersions, { [key: string]: number }>;
cost_models_raw: Record<BlockfrostLanguageVersions, number[]>;
price_mem: string;
price_step: string;
max_tx_ex_mem: number;
Expand Down

0 comments on commit 57d4c3c

Please sign in to comment.