Skip to content

Commit

Permalink
Support native script for query utxo by outRef
Browse files Browse the repository at this point in the history
  • Loading branch information
thanhvh2205 authored and infrmtcs committed Oct 18, 2024
1 parent 20f0210 commit 299652e
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 6 deletions.
14 changes: 11 additions & 3 deletions deno.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,15 @@
"test:core": "cd src/core/libs/cardano_multiplatform_lib && cargo test; cd ../cardano_message_signing && cargo test"
},
"lint": {
"include": ["src/"],
"exclude": ["src/core/"]
"files": {
"include": [
"src/"
],
"exclude": [
"src/core/",
"src/provider/blockfrost.ts",
"src/provider/maestro.ts"
]
}
}
}
}
10 changes: 7 additions & 3 deletions src/provider/blockfrost.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { C } from "../core/mod.ts";
import { applyDoubleCborEncoding, fromHex, toHex } from "../utils/mod.ts";
import { applyDoubleCborEncoding, nativeScriptFromJson, fromHex, toHex } from "../utils/mod.ts";
import {
Address,
Credential,
Expand Down Expand Up @@ -262,8 +262,12 @@ export class Blockfrost implements Provider {
},
).then((res) => res.json());
// TODO: support native scripts
if (type === "Native" || type === "native") {
throw new Error("Native script ref not implemented!");
if (type === "Native" || type === "native" || type === "timelock") {
const { json: script } = await fetch(
`${this.url}/scripts/${r.reference_script_hash}/json`,
{ headers: { project_id: this.projectId, lucid } },
).then((res) => res.json());
return nativeScriptFromJson(script);
}
const { cbor: script } = await fetch(
`${this.url}/scripts/${r.reference_script_hash}/cbor`,
Expand Down

0 comments on commit 299652e

Please sign in to comment.