Skip to content

Commit 0043066

Browse files
authored
Merge branch 'master' into bump-bindgen
2 parents e3250ce + 324834c commit 0043066

File tree

7 files changed

+98
-91
lines changed

7 files changed

+98
-91
lines changed

package-lock.json

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "cardano-serialization-lib",
3-
"version": "10.0.0-beta.8",
3+
"version": "10.0.0-beta.9",
44
"description": "(De)serialization functions for the Cardano blockchain along with related utility functions",
55
"scripts": {
66
"rust:build-nodejs": "(rimraf ./rust/pkg && cd rust; wasm-pack build --target=nodejs; wasm-pack pack) && npm run js:flowgen",

rust/Cargo.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

rust/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "cardano-serialization-lib"
3-
version = "10.0.0-beta.8"
3+
version = "10.0.0-beta.9"
44
edition = "2018"
55
authors = ["EMURGO"]
66
license = "MIT"

rust/pkg/cardano_serialization_lib.js.flow

Lines changed: 67 additions & 75 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,42 @@
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+
844
/**
945
* @param {TransactionHash} tx_body_hash
1046
* @param {ByronAddress} addr
@@ -129,56 +165,6 @@ declare export function encode_json_str_to_native_script(
129165
schema: number
130166
): NativeScript;
131167

132-
/**
133-
* @param {Transaction} tx
134-
* @param {LinearFee} linear_fee
135-
* @returns {BigNum}
136-
*/
137-
declare export function min_fee(tx: Transaction, linear_fee: LinearFee): BigNum;
138-
139-
/**
140-
* @param {Uint8Array} bytes
141-
* @returns {TransactionMetadatum}
142-
*/
143-
declare export function encode_arbitrary_bytes_as_metadatum(
144-
bytes: Uint8Array
145-
): TransactionMetadatum;
146-
147-
/**
148-
* @param {TransactionMetadatum} metadata
149-
* @returns {Uint8Array}
150-
*/
151-
declare export function decode_arbitrary_bytes_from_metadatum(
152-
metadata: TransactionMetadatum
153-
): Uint8Array;
154-
155-
/**
156-
* @param {string} json
157-
* @param {number} schema
158-
* @returns {TransactionMetadatum}
159-
*/
160-
declare export function encode_json_str_to_metadatum(
161-
json: string,
162-
schema: number
163-
): TransactionMetadatum;
164-
165-
/**
166-
* @param {TransactionMetadatum} metadatum
167-
* @param {number} schema
168-
* @returns {string}
169-
*/
170-
declare export function decode_metadatum_to_json_str(
171-
metadatum: TransactionMetadatum,
172-
schema: number
173-
): string;
174-
175-
/**
176-
* @param {Transaction} tx
177-
* @param {LinearFee} linear_fee
178-
* @returns {BigNum}
179-
*/
180-
declare export function min_fee(tx: Transaction, linear_fee: LinearFee): BigNum;
181-
182168
/**
183169
* @param {string} password
184170
* @param {string} salt
@@ -203,6 +189,13 @@ declare export function decrypt_with_password(
203189
data: string
204190
): string;
205191

192+
/**
193+
* @param {Transaction} tx
194+
* @param {LinearFee} linear_fee
195+
* @returns {BigNum}
196+
*/
197+
declare export function min_fee(tx: Transaction, linear_fee: LinearFee): BigNum;
198+
206199
/**
207200
*/
208201

@@ -272,6 +265,14 @@ declare export var NetworkIdKind: {|
272265
+Mainnet: 1, // 1
273266
|};
274267

268+
/**
269+
*/
270+
271+
declare export var StakeCredKind: {|
272+
+Key: 0, // 0
273+
+Script: 1, // 1
274+
|};
275+
275276
/**
276277
*/
277278

@@ -300,15 +301,6 @@ declare export var RedeemerTagKind: {|
300301
+Reward: 3, // 3
301302
|};
302303

303-
/**
304-
* Used to choosed the schema for a script JSON string
305-
*/
306-
307-
declare export var ScriptSchema: {|
308-
+Wallet: 0, // 0
309-
+Node: 1, // 1
310-
|};
311-
312304
/**
313305
*/
314306

@@ -330,11 +322,12 @@ declare export var MetadataJsonSchema: {|
330322
|};
331323

332324
/**
325+
* Used to choosed the schema for a script JSON string
333326
*/
334327

335-
declare export var StakeCredKind: {|
336-
+Key: 0, // 0
337-
+Script: 1, // 1
328+
declare export var ScriptSchema: {|
329+
+Wallet: 0, // 0
330+
+Node: 1, // 1
338331
|};
339332

340333
/**
@@ -347,14 +340,6 @@ declare export var CoinSelectionStrategyCIP2: {|
347340
+RandomImproveMultiAsset: 3, // 3
348341
|};
349342

350-
/**
351-
*/
352-
353-
declare export var StakeCredKind: {|
354-
+Key: 0, // 0
355-
+Script: 1, // 1
356-
|};
357-
358343
/**
359344
*/
360345
declare export class Address {
@@ -3161,17 +3146,17 @@ declare export class PlutusScript {
31613146
static from_bytes(bytes: Uint8Array): PlutusScript;
31623147

31633148
/**
3164-
* * Creates a new Plutus script from the RAW bytes of the compiled script.
3165-
* * This does NOT include any CBOR encoding around these bytes (e.g. from "cborBytes" in cardano-cli)
3166-
* * If you creating this from those you should use PlutusScript::from_bytes() instead.
3149+
* Creates a new Plutus script from the RAW bytes of the compiled script.
3150+
* This does NOT include any CBOR encoding around these bytes (e.g. from "cborBytes" in cardano-cli)
3151+
* If you creating this from those you should use PlutusScript::from_bytes() instead.
31673152
* @param {Uint8Array} bytes
31683153
* @returns {PlutusScript}
31693154
*/
31703155
static new(bytes: Uint8Array): PlutusScript;
31713156

31723157
/**
3173-
* * The raw bytes of this compiled Plutus script.
3174-
* * If you need "cborBytes" for cardano-cli use PlutusScript::to_bytes() instead.
3158+
* The raw bytes of this compiled Plutus script.
3159+
* If you need "cborBytes" for cardano-cli use PlutusScript::to_bytes() instead.
31753160
* @returns {Uint8Array}
31763161
*/
31773162
bytes(): Uint8Array;
@@ -4992,6 +4977,13 @@ declare export class TransactionBody {
49924977
/**
49934978
* @returns {Mint | void}
49944979
*/
4980+
mint(): Mint | void;
4981+
4982+
/**
4983+
* This function returns the mint value of the transaction
4984+
* Use `.mint()` instead.
4985+
* @returns {Mint | void}
4986+
*/
49954987
multiassets(): Mint | void;
49964988

49974989
/**

rust/src/tx_builder.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,8 @@ fn fake_full_tx(tx_builder: &TransactionBuilder, body: TransactionBody) -> Resul
9696
0 => None,
9797
_x => {
9898
// TODO: figure out how to populate fake witnesses for these
99-
return Err(JsError::from_str("Script inputs not supported yet"))
99+
// return Err(JsError::from_str("Script inputs not supported yet"))
100+
None
100101
},
101102
};
102103
let bootstrap_keys = match tx_builder.input_types.bootstraps.len() {

rust/src/utils.rs

Lines changed: 25 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -898,19 +898,33 @@ pub fn hash_plutus_data(plutus_data: &PlutusData) -> DataHash {
898898
}
899899
#[wasm_bindgen]
900900
pub fn hash_script_data(redeemers: &Redeemers, cost_models: &Costmdls, datums: Option<PlutusList>) -> ScriptDataHash {
901-
/*
902-
; script data format:
903-
; [ redeemers | datums | language views ]
904-
; The redeemers are exactly the data present in the transaction witness set.
905-
; Similarly for the datums, if present. If no datums are provided, the middle
906-
; field is an empty string.
907-
*/
908901
let mut buf = Vec::new();
909-
buf.extend(redeemers.to_bytes());
910-
if let Some(d) = &datums {
911-
buf.extend(d.to_bytes());
902+
if redeemers.len() == 0 && datums.is_some() {
903+
/*
904+
; Finally, note that in the case that a transaction includes datums but does not
905+
; include any redeemers, the script data format becomes (in hex):
906+
; [ 80 | datums | A0 ]
907+
; corresponding to a CBOR empty list and an empty map (our apologies).
908+
*/
909+
buf.push(0x80);
910+
if let Some(d) = &datums {
911+
buf.extend(d.to_bytes());
912+
}
913+
buf.push(0xA0);
914+
} else {
915+
/*
916+
; script data format:
917+
; [ redeemers | datums | language views ]
918+
; The redeemers are exactly the data present in the transaction witness set.
919+
; Similarly for the datums, if present. If no datums are provided, the middle
920+
; field is an empty string.
921+
*/
922+
buf.extend(redeemers.to_bytes());
923+
if let Some(d) = &datums {
924+
buf.extend(d.to_bytes());
925+
}
926+
buf.extend(cost_models.language_views_encoding());
912927
}
913-
buf.extend(cost_models.language_views_encoding());
914928
ScriptDataHash::from(blake2b256(&buf))
915929
}
916930

0 commit comments

Comments
 (0)