-
Notifications
You must be signed in to change notification settings - Fork 4
feat/provider full utxo resolution scripts datums #128
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
c1948ae
2742e40
d42ca5f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,27 @@ | ||
| --- | ||
| "@evolution-sdk/evolution": patch | ||
| --- | ||
|
|
||
| ### Provider Improvements: Full UTxO Resolution with Scripts and Datums | ||
|
|
||
| **Blockfrost Provider:** | ||
| - Added pagination support for `getUtxos` and `getUtxosWithUnit` (handles addresses with >100 UTxOs) | ||
| - Full UTxO resolution now fetches reference scripts and resolves datum hashes | ||
| - Updated `BlockfrostDelegation` schema to match actual `/accounts/{stake_address}` endpoint response | ||
| - Added `BlockfrostAssetAddress` and `BlockfrostTxUtxos` schemas for proper endpoint handling | ||
| - Improved `evaluateTx` to always use the more reliable `/utils/txs/evaluate/utxos` JSON endpoint | ||
| - Added `EvaluationFailure` handling in evaluation response schema | ||
| - Fixed delegation transformation to use `withdrawable_amount` for rewards | ||
| - Added Conway era governance parameters (`drep_deposit`, `gov_action_deposit`) to protocol params | ||
|
|
||
| **Kupmios Provider:** | ||
| - Removed unnecessary double CBOR encoding for Plutus scripts (Kupo returns properly encoded scripts) | ||
|
|
||
| **PoolKeyHash:** | ||
| - Added `FromBech32` schema for parsing pool IDs in bech32 format (pool1...) | ||
| - Added `fromBech32` and `toBech32` helper functions | ||
|
|
||
| **Transaction Builder:** | ||
| - Added `passAdditionalUtxos` option to control UTxO passing to provider evaluators (default: false to avoid OverlappingAdditionalUtxo errors) | ||
| - Added `scriptDataFormat` option to choose between Conway-era array format and Babbage-era map format for redeemers | ||
| - Fixed cost model detection to check reference scripts (not just witness set scripts) for Plutus version detection |
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -1,4 +1,5 @@ | ||||||||||||||||||||||||||||||||||
| import { Equal, FastCheck, Hash, Inspectable, Schema } from "effect" | ||||||||||||||||||||||||||||||||||
| import { bech32 } from "@scure/base" | ||||||||||||||||||||||||||||||||||
| import { Effect as Eff, Equal, FastCheck, Hash, Inspectable, ParseResult, Schema } from "effect" | ||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
| import * as Bytes from "./Bytes.js" | ||||||||||||||||||||||||||||||||||
| import * as Hash28 from "./Hash28.js" | ||||||||||||||||||||||||||||||||||
|
|
@@ -59,6 +60,38 @@ export const FromHex = Schema.compose(Hash28.BytesFromHex, FromBytes).annotation | |||||||||||||||||||||||||||||||||
| identifier: "PoolKeyHash.FromHex" | ||||||||||||||||||||||||||||||||||
| }) | ||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
| /** | ||||||||||||||||||||||||||||||||||
| * Schema transformer from bech32 string (pool1...) to PoolKeyHash. | ||||||||||||||||||||||||||||||||||
| * | ||||||||||||||||||||||||||||||||||
| * @since 2.0.0 | ||||||||||||||||||||||||||||||||||
| * @category schemas | ||||||||||||||||||||||||||||||||||
| */ | ||||||||||||||||||||||||||||||||||
| export const FromBech32 = Schema.transformOrFail(Schema.String, Schema.typeSchema(PoolKeyHash), { | ||||||||||||||||||||||||||||||||||
| strict: true, | ||||||||||||||||||||||||||||||||||
| encode: (poolKeyHash) => | ||||||||||||||||||||||||||||||||||
| Eff.gen(function* () { | ||||||||||||||||||||||||||||||||||
| const words = bech32.toWords(poolKeyHash.hash) | ||||||||||||||||||||||||||||||||||
| return bech32.encode("pool", words, false) | ||||||||||||||||||||||||||||||||||
| }), | ||||||||||||||||||||||||||||||||||
| decode: (fromA, _, ast) => | ||||||||||||||||||||||||||||||||||
| Eff.gen(function* () { | ||||||||||||||||||||||||||||||||||
| const result = yield* Eff.try({ | ||||||||||||||||||||||||||||||||||
| try: () => { | ||||||||||||||||||||||||||||||||||
| // Note: `as any` needed because bech32.decode expects template literal type `${Prefix}1${string}` | ||||||||||||||||||||||||||||||||||
| // but Schema provides plain string. Consider using decodeToBytes which accepts string. | ||||||||||||||||||||||||||||||||||
| const decoded = bech32.decode(fromA as any, false) | ||||||||||||||||||||||||||||||||||
| const bytes = bech32.fromWords(decoded.words) | ||||||||||||||||||||||||||||||||||
| return new Uint8Array(bytes) | ||||||||||||||||||||||||||||||||||
| }, | ||||||||||||||||||||||||||||||||||
| catch: () => new ParseResult.Type(ast, fromA, `Failed to decode Bech32 pool id: ${fromA}`) | ||||||||||||||||||||||||||||||||||
|
Comment on lines
+84
to
+86
|
||||||||||||||||||||||||||||||||||
| return new Uint8Array(bytes) | |
| }, | |
| catch: () => new ParseResult.Type(ast, fromA, `Failed to decode Bech32 pool id: ${fromA}`) | |
| if (bytes.length !== Hash28.BYTES_LENGTH) { | |
| throw new ParseResult.Type( | |
| ast, | |
| fromA, | |
| `Invalid PoolKeyHash length: expected ${Hash28.BYTES_LENGTH} bytes, got ${bytes.length}` | |
| ) | |
| } | |
| return new Uint8Array(bytes) | |
| }, | |
| catch: (error) => | |
| error instanceof ParseResult.Type | |
| ? error | |
| : new ParseResult.Type(ast, fromA, `Failed to decode Bech32 pool id: ${fromA}`) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The type assertion
as anyis used here to bypass type checking for the bech32.decode function. This is a code smell that could hide potential type mismatches. Consider removing the type assertion and ensuring the input string type matches the expected signature of bech32.decode, or add a proper type guard if needed.