Skip to content

Commit

Permalink
flowgen update and merge fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
vsubhuman committed Feb 5, 2022
1 parent fb79f26 commit ce41194
Show file tree
Hide file tree
Showing 4 changed files with 241 additions and 62 deletions.
2 changes: 0 additions & 2 deletions rust/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

290 changes: 234 additions & 56 deletions rust/pkg/cardano_serialization_lib.js.flow
Original file line number Diff line number Diff line change
Expand Up @@ -5,42 +5,6 @@
* @flow
*/

/**
* @param {Uint8Array} bytes
* @returns {TransactionMetadatum}
*/
declare export function encode_arbitrary_bytes_as_metadatum(
bytes: Uint8Array
): TransactionMetadatum;

/**
* @param {TransactionMetadatum} metadata
* @returns {Uint8Array}
*/
declare export function decode_arbitrary_bytes_from_metadatum(
metadata: TransactionMetadatum
): Uint8Array;

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

/**
* @param {TransactionMetadatum} metadatum
* @param {number} schema
* @returns {string}
*/
declare export function decode_metadatum_to_json_str(
metadatum: TransactionMetadatum,
schema: number
): string;

/**
* @param {TransactionHash} tx_body_hash
* @param {ByronAddress} addr
Expand Down Expand Up @@ -165,6 +129,42 @@ declare export function encode_json_str_to_native_script(
schema: number
): NativeScript;

/**
* @param {Uint8Array} bytes
* @returns {TransactionMetadatum}
*/
declare export function encode_arbitrary_bytes_as_metadatum(
bytes: Uint8Array
): TransactionMetadatum;

/**
* @param {TransactionMetadatum} metadata
* @returns {Uint8Array}
*/
declare export function decode_arbitrary_bytes_from_metadatum(
metadata: TransactionMetadatum
): Uint8Array;

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

/**
* @param {TransactionMetadatum} metadatum
* @param {number} schema
* @returns {string}
*/
declare export function decode_metadatum_to_json_str(
metadatum: TransactionMetadatum,
schema: number
): string;

/**
* @param {string} password
* @param {string} salt
Expand Down Expand Up @@ -246,17 +246,6 @@ declare export var NativeScriptKind: {|
+TimelockExpiry: 5, // 5
|};

/**
* Each new language uses a different namespace for hashing its script
* This is because you could have a language where the same bytes have different semantics
* So this avoids scripts in different languages mapping to the same hash
* Note that the enum value here is different than the enum value for deciding the cost model of a script
*/

declare export var ScriptHashNamespace: {|
+NativeScript: 0, // 0
|};

/**
*/

Expand All @@ -278,6 +267,7 @@ declare export var StakeCredKind: {|

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

/**
Expand All @@ -301,6 +291,29 @@ declare export var RedeemerTagKind: {|
+Reward: 3, // 3
|};

/**
* Each new language uses a different namespace for hashing its script
* This is because you could have a language where the same bytes have different semantics
* So this avoids scripts in different languages mapping to the same hash
* Note that the enum value here is different than the enum value for deciding the cost model of a script
* https://github.com/input-output-hk/cardano-ledger/blob/9c3b4737b13b30f71529e76c5330f403165e28a6/eras/alonzo/impl/src/Cardano/Ledger/Alonzo.hs#L127
*/

declare export var ScriptHashNamespace: {|
+NativeScript: 0, // 0
+PlutusV1: 1, // 1
+PlutusV2: 2, // 2
|};

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

declare export var ScriptSchema: {|
+Wallet: 0, // 0
+Node: 1, // 1
|};

/**
*/

Expand All @@ -321,15 +334,6 @@ declare export var MetadataJsonSchema: {|
+DetailedSchema: 2, // 2
|};

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

declare export var ScriptSchema: {|
+Wallet: 0, // 0
+Node: 1, // 1
|};

/**
*/

Expand Down Expand Up @@ -2175,6 +2179,11 @@ declare export class Language {
*/
static new_plutus_v1(): Language;

/**
* @returns {Language}
*/
static new_plutus_v2(): Language;

/**
* @returns {number}
*/
Expand Down Expand Up @@ -3145,6 +3154,12 @@ declare export class PlutusScript {
*/
static from_bytes(bytes: Uint8Array): PlutusScript;

/**
* @param {number} namespace
* @returns {ScriptHash}
*/
hash(namespace: number): ScriptHash;

/**
* Creates a new Plutus script from the RAW bytes of the compiled script.
* This does NOT include any CBOR encoding around these bytes (e.g. from "cborBytes" in cardano-cli)
Expand Down Expand Up @@ -4071,6 +4086,28 @@ declare export class RedeemerTag {
*/
kind(): number;
}
/**
*/
declare export class RedeemerWitnessKey {
free(): void;

/**
* @returns {RedeemerTag}
*/
tag(): RedeemerTag;

/**
* @returns {BigNum}
*/
index(): BigNum;

/**
* @param {RedeemerTag} tag
* @param {BigNum} index
* @returns {RedeemerWitnessKey}
*/
static new(tag: RedeemerTag, index: BigNum): RedeemerWitnessKey;
}
/**
*/
declare export class Redeemers {
Expand Down Expand Up @@ -4199,6 +4236,91 @@ declare export class Relays {
*/
add(elem: Relay): void;
}
/**
*/
declare export class RequiredWitnessSet {
free(): void;

/**
* @param {Vkeywitness} vkey
*/
add_vkey(vkey: Vkeywitness): void;

/**
* @param {Vkey} vkey
*/
add_vkey_key(vkey: Vkey): void;

/**
* @param {Ed25519KeyHash} hash
*/
add_vkey_key_hash(hash: Ed25519KeyHash): void;

/**
* @param {BootstrapWitness} bootstrap
*/
add_bootstrap(bootstrap: BootstrapWitness): void;

/**
* @param {Vkey} bootstrap
*/
add_bootstrap_key(bootstrap: Vkey): void;

/**
* @param {Ed25519KeyHash} hash
*/
add_bootstrap_key_hash(hash: Ed25519KeyHash): void;

/**
* @param {NativeScript} native_script
*/
add_native_script(native_script: NativeScript): void;

/**
* @param {ScriptHash} native_script
*/
add_native_script_hash(native_script: ScriptHash): void;

/**
* @param {PlutusScript} plutus_script
*/
add_plutus_script(plutus_script: PlutusScript): void;

/**
* @param {ScriptHash} plutus_script
*/
add_plutus_hash(plutus_script: ScriptHash): void;

/**
* @param {PlutusData} plutus_datum
*/
add_plutus_datum(plutus_datum: PlutusData): void;

/**
* @param {DataHash} plutus_datum
*/
add_plutus_datum_hash(plutus_datum: DataHash): void;

/**
* @param {Redeemer} redeemer
*/
add_redeemer(redeemer: Redeemer): void;

/**
* @param {RedeemerWitnessKey} redeemer
*/
add_redeemer_tag(redeemer: RedeemerWitnessKey): void;

/**
* @param {RequiredWitnessSet} requirements
*/
add_all(requirements: RequiredWitnessSet): void;

/**
* @returns {RequiredWitnessSet}
*/
static new(): RequiredWitnessSet;
}
/**
*/
declare export class RewardAddress {
Expand Down Expand Up @@ -5933,6 +6055,62 @@ declare export class TransactionWitnessSet {
*/
static new(): TransactionWitnessSet;
}
/**
* Builder de-duplicates witnesses as they are added
*/
declare export class TransactionWitnessSetBuilder {
free(): void;

/**
* @param {Vkeywitness} vkey
*/
add_vkey(vkey: Vkeywitness): void;

/**
* @param {BootstrapWitness} bootstrap
*/
add_bootstrap(bootstrap: BootstrapWitness): void;

/**
* @param {NativeScript} native_script
*/
add_native_script(native_script: NativeScript): void;

/**
* @param {PlutusScript} plutus_script
*/
add_plutus_script(plutus_script: PlutusScript): void;

/**
* @param {PlutusData} plutus_datum
*/
add_plutus_datum(plutus_datum: PlutusData): void;

/**
* @param {Redeemer} redeemer
*/
add_redeemer(redeemer: Redeemer): void;

/**
* @param {RequiredWitnessSet} required_wits
*/
add_required_wits(required_wits: RequiredWitnessSet): void;

/**
* @returns {TransactionWitnessSetBuilder}
*/
static new(): TransactionWitnessSetBuilder;

/**
* @param {TransactionWitnessSet} wit_set
*/
add_existing(wit_set: TransactionWitnessSet): void;

/**
* @returns {TransactionWitnessSet}
*/
build(): TransactionWitnessSet;
}
/**
*/
declare export class TransactionWitnessSets {
Expand Down
4 changes: 2 additions & 2 deletions rust/src/plutus.rs
Original file line number Diff line number Diff line change
Expand Up @@ -466,11 +466,11 @@ impl PlutusData {
#[wasm_bindgen]
#[derive(Clone, Debug, Eq, Ord, PartialEq, PartialOrd)]
pub struct PlutusList {
elems: Vec<PlutusData>,
pub(crate) elems: Vec<PlutusData>,
// We should always preserve the original datums when deserialized as this is NOT canonicized
// before computing datum hashes. This field will default to cardano-cli behavior if None
// and will re-use the provided one if deserialized, unless the list is modified.
definite_encoding: Option<bool>,
pub(crate) definite_encoding: Option<bool>,
}

to_from_bytes!(PlutusList);
Expand Down
Loading

0 comments on commit ce41194

Please sign in to comment.