Skip to content

Commit ce41194

Browse files
committed
flowgen update and merge fixes
1 parent fb79f26 commit ce41194

File tree

4 files changed

+241
-62
lines changed

4 files changed

+241
-62
lines changed

rust/Cargo.lock

Lines changed: 0 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

rust/pkg/cardano_serialization_lib.js.flow

Lines changed: 234 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -5,42 +5,6 @@
55
* @flow
66
*/
77

8-
/**
9-
* @param {Uint8Array} bytes
10-
* @returns {TransactionMetadatum}
11-
*/
12-
declare export function encode_arbitrary_bytes_as_metadatum(
13-
bytes: Uint8Array
14-
): TransactionMetadatum;
15-
16-
/**
17-
* @param {TransactionMetadatum} metadata
18-
* @returns {Uint8Array}
19-
*/
20-
declare export function decode_arbitrary_bytes_from_metadatum(
21-
metadata: TransactionMetadatum
22-
): Uint8Array;
23-
24-
/**
25-
* @param {string} json
26-
* @param {number} schema
27-
* @returns {TransactionMetadatum}
28-
*/
29-
declare export function encode_json_str_to_metadatum(
30-
json: string,
31-
schema: number
32-
): TransactionMetadatum;
33-
34-
/**
35-
* @param {TransactionMetadatum} metadatum
36-
* @param {number} schema
37-
* @returns {string}
38-
*/
39-
declare export function decode_metadatum_to_json_str(
40-
metadatum: TransactionMetadatum,
41-
schema: number
42-
): string;
43-
448
/**
459
* @param {TransactionHash} tx_body_hash
4610
* @param {ByronAddress} addr
@@ -165,6 +129,42 @@ declare export function encode_json_str_to_native_script(
165129
schema: number
166130
): NativeScript;
167131

132+
/**
133+
* @param {Uint8Array} bytes
134+
* @returns {TransactionMetadatum}
135+
*/
136+
declare export function encode_arbitrary_bytes_as_metadatum(
137+
bytes: Uint8Array
138+
): TransactionMetadatum;
139+
140+
/**
141+
* @param {TransactionMetadatum} metadata
142+
* @returns {Uint8Array}
143+
*/
144+
declare export function decode_arbitrary_bytes_from_metadatum(
145+
metadata: TransactionMetadatum
146+
): Uint8Array;
147+
148+
/**
149+
* @param {string} json
150+
* @param {number} schema
151+
* @returns {TransactionMetadatum}
152+
*/
153+
declare export function encode_json_str_to_metadatum(
154+
json: string,
155+
schema: number
156+
): TransactionMetadatum;
157+
158+
/**
159+
* @param {TransactionMetadatum} metadatum
160+
* @param {number} schema
161+
* @returns {string}
162+
*/
163+
declare export function decode_metadatum_to_json_str(
164+
metadatum: TransactionMetadatum,
165+
schema: number
166+
): string;
167+
168168
/**
169169
* @param {string} password
170170
* @param {string} salt
@@ -246,17 +246,6 @@ declare export var NativeScriptKind: {|
246246
+TimelockExpiry: 5, // 5
247247
|};
248248

249-
/**
250-
* Each new language uses a different namespace for hashing its script
251-
* This is because you could have a language where the same bytes have different semantics
252-
* So this avoids scripts in different languages mapping to the same hash
253-
* Note that the enum value here is different than the enum value for deciding the cost model of a script
254-
*/
255-
256-
declare export var ScriptHashNamespace: {|
257-
+NativeScript: 0, // 0
258-
|};
259-
260249
/**
261250
*/
262251

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

279268
declare export var LanguageKind: {|
280269
+PlutusV1: 0, // 0
270+
+PlutusV2: 1, // 1
281271
|};
282272

283273
/**
@@ -301,6 +291,29 @@ declare export var RedeemerTagKind: {|
301291
+Reward: 3, // 3
302292
|};
303293

294+
/**
295+
* Each new language uses a different namespace for hashing its script
296+
* This is because you could have a language where the same bytes have different semantics
297+
* So this avoids scripts in different languages mapping to the same hash
298+
* Note that the enum value here is different than the enum value for deciding the cost model of a script
299+
* https://github.com/input-output-hk/cardano-ledger/blob/9c3b4737b13b30f71529e76c5330f403165e28a6/eras/alonzo/impl/src/Cardano/Ledger/Alonzo.hs#L127
300+
*/
301+
302+
declare export var ScriptHashNamespace: {|
303+
+NativeScript: 0, // 0
304+
+PlutusV1: 1, // 1
305+
+PlutusV2: 2, // 2
306+
|};
307+
308+
/**
309+
* Used to choose the schema for a script JSON string
310+
*/
311+
312+
declare export var ScriptSchema: {|
313+
+Wallet: 0, // 0
314+
+Node: 1, // 1
315+
|};
316+
304317
/**
305318
*/
306319

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

324-
/**
325-
* Used to choosed the schema for a script JSON string
326-
*/
327-
328-
declare export var ScriptSchema: {|
329-
+Wallet: 0, // 0
330-
+Node: 1, // 1
331-
|};
332-
333337
/**
334338
*/
335339

@@ -2175,6 +2179,11 @@ declare export class Language {
21752179
*/
21762180
static new_plutus_v1(): Language;
21772181

2182+
/**
2183+
* @returns {Language}
2184+
*/
2185+
static new_plutus_v2(): Language;
2186+
21782187
/**
21792188
* @returns {number}
21802189
*/
@@ -3145,6 +3154,12 @@ declare export class PlutusScript {
31453154
*/
31463155
static from_bytes(bytes: Uint8Array): PlutusScript;
31473156

3157+
/**
3158+
* @param {number} namespace
3159+
* @returns {ScriptHash}
3160+
*/
3161+
hash(namespace: number): ScriptHash;
3162+
31483163
/**
31493164
* Creates a new Plutus script from the RAW bytes of the compiled script.
31503165
* This does NOT include any CBOR encoding around these bytes (e.g. from "cborBytes" in cardano-cli)
@@ -4071,6 +4086,28 @@ declare export class RedeemerTag {
40714086
*/
40724087
kind(): number;
40734088
}
4089+
/**
4090+
*/
4091+
declare export class RedeemerWitnessKey {
4092+
free(): void;
4093+
4094+
/**
4095+
* @returns {RedeemerTag}
4096+
*/
4097+
tag(): RedeemerTag;
4098+
4099+
/**
4100+
* @returns {BigNum}
4101+
*/
4102+
index(): BigNum;
4103+
4104+
/**
4105+
* @param {RedeemerTag} tag
4106+
* @param {BigNum} index
4107+
* @returns {RedeemerWitnessKey}
4108+
*/
4109+
static new(tag: RedeemerTag, index: BigNum): RedeemerWitnessKey;
4110+
}
40744111
/**
40754112
*/
40764113
declare export class Redeemers {
@@ -4199,6 +4236,91 @@ declare export class Relays {
41994236
*/
42004237
add(elem: Relay): void;
42014238
}
4239+
/**
4240+
*/
4241+
declare export class RequiredWitnessSet {
4242+
free(): void;
4243+
4244+
/**
4245+
* @param {Vkeywitness} vkey
4246+
*/
4247+
add_vkey(vkey: Vkeywitness): void;
4248+
4249+
/**
4250+
* @param {Vkey} vkey
4251+
*/
4252+
add_vkey_key(vkey: Vkey): void;
4253+
4254+
/**
4255+
* @param {Ed25519KeyHash} hash
4256+
*/
4257+
add_vkey_key_hash(hash: Ed25519KeyHash): void;
4258+
4259+
/**
4260+
* @param {BootstrapWitness} bootstrap
4261+
*/
4262+
add_bootstrap(bootstrap: BootstrapWitness): void;
4263+
4264+
/**
4265+
* @param {Vkey} bootstrap
4266+
*/
4267+
add_bootstrap_key(bootstrap: Vkey): void;
4268+
4269+
/**
4270+
* @param {Ed25519KeyHash} hash
4271+
*/
4272+
add_bootstrap_key_hash(hash: Ed25519KeyHash): void;
4273+
4274+
/**
4275+
* @param {NativeScript} native_script
4276+
*/
4277+
add_native_script(native_script: NativeScript): void;
4278+
4279+
/**
4280+
* @param {ScriptHash} native_script
4281+
*/
4282+
add_native_script_hash(native_script: ScriptHash): void;
4283+
4284+
/**
4285+
* @param {PlutusScript} plutus_script
4286+
*/
4287+
add_plutus_script(plutus_script: PlutusScript): void;
4288+
4289+
/**
4290+
* @param {ScriptHash} plutus_script
4291+
*/
4292+
add_plutus_hash(plutus_script: ScriptHash): void;
4293+
4294+
/**
4295+
* @param {PlutusData} plutus_datum
4296+
*/
4297+
add_plutus_datum(plutus_datum: PlutusData): void;
4298+
4299+
/**
4300+
* @param {DataHash} plutus_datum
4301+
*/
4302+
add_plutus_datum_hash(plutus_datum: DataHash): void;
4303+
4304+
/**
4305+
* @param {Redeemer} redeemer
4306+
*/
4307+
add_redeemer(redeemer: Redeemer): void;
4308+
4309+
/**
4310+
* @param {RedeemerWitnessKey} redeemer
4311+
*/
4312+
add_redeemer_tag(redeemer: RedeemerWitnessKey): void;
4313+
4314+
/**
4315+
* @param {RequiredWitnessSet} requirements
4316+
*/
4317+
add_all(requirements: RequiredWitnessSet): void;
4318+
4319+
/**
4320+
* @returns {RequiredWitnessSet}
4321+
*/
4322+
static new(): RequiredWitnessSet;
4323+
}
42024324
/**
42034325
*/
42044326
declare export class RewardAddress {
@@ -5933,6 +6055,62 @@ declare export class TransactionWitnessSet {
59336055
*/
59346056
static new(): TransactionWitnessSet;
59356057
}
6058+
/**
6059+
* Builder de-duplicates witnesses as they are added
6060+
*/
6061+
declare export class TransactionWitnessSetBuilder {
6062+
free(): void;
6063+
6064+
/**
6065+
* @param {Vkeywitness} vkey
6066+
*/
6067+
add_vkey(vkey: Vkeywitness): void;
6068+
6069+
/**
6070+
* @param {BootstrapWitness} bootstrap
6071+
*/
6072+
add_bootstrap(bootstrap: BootstrapWitness): void;
6073+
6074+
/**
6075+
* @param {NativeScript} native_script
6076+
*/
6077+
add_native_script(native_script: NativeScript): void;
6078+
6079+
/**
6080+
* @param {PlutusScript} plutus_script
6081+
*/
6082+
add_plutus_script(plutus_script: PlutusScript): void;
6083+
6084+
/**
6085+
* @param {PlutusData} plutus_datum
6086+
*/
6087+
add_plutus_datum(plutus_datum: PlutusData): void;
6088+
6089+
/**
6090+
* @param {Redeemer} redeemer
6091+
*/
6092+
add_redeemer(redeemer: Redeemer): void;
6093+
6094+
/**
6095+
* @param {RequiredWitnessSet} required_wits
6096+
*/
6097+
add_required_wits(required_wits: RequiredWitnessSet): void;
6098+
6099+
/**
6100+
* @returns {TransactionWitnessSetBuilder}
6101+
*/
6102+
static new(): TransactionWitnessSetBuilder;
6103+
6104+
/**
6105+
* @param {TransactionWitnessSet} wit_set
6106+
*/
6107+
add_existing(wit_set: TransactionWitnessSet): void;
6108+
6109+
/**
6110+
* @returns {TransactionWitnessSet}
6111+
*/
6112+
build(): TransactionWitnessSet;
6113+
}
59366114
/**
59376115
*/
59386116
declare export class TransactionWitnessSets {

rust/src/plutus.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -466,11 +466,11 @@ impl PlutusData {
466466
#[wasm_bindgen]
467467
#[derive(Clone, Debug, Eq, Ord, PartialEq, PartialOrd)]
468468
pub struct PlutusList {
469-
elems: Vec<PlutusData>,
469+
pub(crate) elems: Vec<PlutusData>,
470470
// We should always preserve the original datums when deserialized as this is NOT canonicized
471471
// before computing datum hashes. This field will default to cardano-cli behavior if None
472472
// and will re-use the provided one if deserialized, unless the list is modified.
473-
definite_encoding: Option<bool>,
473+
pub(crate) definite_encoding: Option<bool>,
474474
}
475475

476476
to_from_bytes!(PlutusList);

0 commit comments

Comments
 (0)