Skip to content

Commit

Permalink
feat: building parsing inline datum
Browse files Browse the repository at this point in the history
  • Loading branch information
SIDANWhatever committed Apr 17, 2024
1 parent 11361ae commit 57464c2
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
2 changes: 1 addition & 1 deletion package.json
@@ -1,7 +1,7 @@
{
"name": "@meshsdk/mesh-csl",
"description": "Cardano Off-chain Code APIs built on cardano-serialization-lib",
"version": "0.0.1-beta.3",
"version": "0.0.1-beta.4",
"license": "MIT",
"main": "dist/cjs/index.js",
"module": "dist/mjs/index.js",
Expand Down
6 changes: 6 additions & 0 deletions src/core/utils/datum.ts
Expand Up @@ -6,3 +6,9 @@ export const parseInlineDatum = <T extends { inline_datum?: string }, X>(utxo: T
const datum: X = JSON.parse(parsedDatum.to_json(1));
return datum as X;
};

export const parseDatumCbor = <T = any>(datumCbor: string): T => {

Check warning on line 10 in src/core/utils/datum.ts

View workflow job for this annotation

GitHub Actions / build

Unexpected any. Specify a different type

Check warning on line 10 in src/core/utils/datum.ts

View workflow job for this annotation

GitHub Actions / build

Unexpected any. Specify a different type

Check warning on line 10 in src/core/utils/datum.ts

View workflow job for this annotation

GitHub Actions / publish-npm

Unexpected any. Specify a different type
const parsedDatum = csl.PlutusData.from_hex(datumCbor);
const datum: T = JSON.parse(parsedDatum.to_json(1));
return datum as T;
};

0 comments on commit 57464c2

Please sign in to comment.