Skip to content
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

cardano-cli Plutus Datum JSON format support #357

Merged
merged 11 commits into from
Jul 29, 2022
61 changes: 60 additions & 1 deletion rust/pkg/cardano_serialization_lib.js.flow
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,26 @@ declare export function decrypt_with_password(
data: string
): string;

/**
* @param {string} json
* @param {number} schema
* @returns {PlutusData}
*/
declare export function encode_json_str_to_plutus_datum(
json: string,
schema: number
): PlutusData;

/**
* @param {PlutusData} datum
* @param {number} schema
* @returns {string}
*/
declare export function decode_plutus_datum_to_json_str(
datum: PlutusData,
schema: number
): string;

/**
*/

Expand Down Expand Up @@ -276,8 +296,8 @@ declare export var ScriptSchema: {|
|};

/**
* Used to choosed the schema for a script JSON string
*/

declare export var TransactionMetadatumKind: {|
+MetadataMap: 0, // 0
+MetadataList: 1, // 1
Expand Down Expand Up @@ -320,6 +340,23 @@ declare export var LanguageKind: {|
+PlutusV1: 0, // 0
|};

/**
*/

declare export var RedeemerTagKind: {|
+Spend: 0, // 0
+Mint: 1, // 1
+Cert: 2, // 2
+Reward: 3, // 3
|};

/**
*/

declare export var LanguageKind: {|
+PlutusV1: 0, // 0
|};

/**
*/

Expand All @@ -341,6 +378,23 @@ declare export var RedeemerTagKind: {|
+Reward: 3, // 3
|};

/**
* JSON <-> PlutusData conversion schemas.
* Follows ScriptDataJsonSchema in cardano-cli defined at:
* https://github.com/input-output-hk/cardano-node/blob/master/cardano-api/src/Cardano/Api/ScriptData.hs#L254
*
* All methods here have the following restrictions due to limitations on dependencies:
* * JSON numbers above u64::MAX (positive) or below i64::MIN (negative) will throw errors
* * Hex strings for bytes don't accept odd-length (half-byte) strings.
* cardano-cli seems to support these however but it seems to be different than just 0-padding
* on either side when tested so proceed with caution
*/

declare export var PlutusDatumSchema: {|
+BasicConversions: 0, // 0
+DetailedSchema: 1, // 1
|};

/**
*/
declare export class Address {
Expand Down Expand Up @@ -653,6 +707,11 @@ declare export class BigInt {
*/
as_u64(): BigNum | void;

/**
* @returns {Int | void}
*/
as_int(): Int | void;

/**
* @param {string} text
* @returns {BigInt}
Expand Down
Loading