Skip to content

Commit dbcd3e3

Browse files
authored
Merge pull request #582 from Emurgo/evgenii/safe_txbody_roundtrip
TxBody roundtrip
2 parents dfcc32e + fbaa6a2 commit dbcd3e3

File tree

5 files changed

+474
-41
lines changed

5 files changed

+474
-41
lines changed

rust/pkg/cardano_serialization_lib.js.flow

+148-40
Original file line numberDiff line numberDiff line change
@@ -5,26 +5,6 @@
55
* @flow
66
*/
77

8-
/**
9-
* @param {string} json
10-
* @param {number} schema
11-
* @returns {PlutusData}
12-
*/
13-
declare export function encode_json_str_to_plutus_datum(
14-
json: string,
15-
schema: number
16-
): PlutusData;
17-
18-
/**
19-
* @param {PlutusData} datum
20-
* @param {number} schema
21-
* @returns {string}
22-
*/
23-
declare export function decode_plutus_datum_to_json_str(
24-
datum: PlutusData,
25-
schema: number
26-
): string;
27-
288
/**
299
* @param {Uint8Array} bytes
3010
* @returns {TransactionMetadatum}
@@ -61,6 +41,26 @@ declare export function decode_metadatum_to_json_str(
6141
schema: number
6242
): string;
6343

44+
/**
45+
* @param {string} json
46+
* @param {number} schema
47+
* @returns {PlutusData}
48+
*/
49+
declare export function encode_json_str_to_plutus_datum(
50+
json: string,
51+
schema: number
52+
): PlutusData;
53+
54+
/**
55+
* @param {PlutusData} datum
56+
* @param {number} schema
57+
* @returns {string}
58+
*/
59+
declare export function decode_plutus_datum_to_json_str(
60+
datum: PlutusData,
61+
schema: number
62+
): string;
63+
6464
/**
6565
* @param {Transaction} tx
6666
* @param {LinearFee} linear_fee
@@ -333,6 +333,26 @@ declare export var NetworkIdKind: {|
333333
+Mainnet: 1, // 1
334334
|};
335335

336+
/**
337+
*/
338+
339+
declare export var TransactionMetadatumKind: {|
340+
+MetadataMap: 0, // 0
341+
+MetadataList: 1, // 1
342+
+Int: 2, // 2
343+
+Bytes: 3, // 3
344+
+Text: 4, // 4
345+
|};
346+
347+
/**
348+
*/
349+
350+
declare export var MetadataJsonSchema: {|
351+
+NoConversions: 0, // 0
352+
+BasicConversions: 1, // 1
353+
+DetailedSchema: 2, // 2
354+
|};
355+
336356
/**
337357
*/
338358

@@ -379,26 +399,6 @@ declare export var PlutusDatumSchema: {|
379399
+DetailedSchema: 1, // 1
380400
|};
381401

382-
/**
383-
*/
384-
385-
declare export var TransactionMetadatumKind: {|
386-
+MetadataMap: 0, // 0
387-
+MetadataList: 1, // 1
388-
+Int: 2, // 2
389-
+Bytes: 3, // 3
390-
+Text: 4, // 4
391-
|};
392-
393-
/**
394-
*/
395-
396-
declare export var MetadataJsonSchema: {|
397-
+NoConversions: 0, // 0
398-
+BasicConversions: 1, // 1
399-
+DetailedSchema: 2, // 2
400-
|};
401-
402402
/**
403403
*/
404404

@@ -2452,6 +2452,114 @@ declare export class ExUnits {
24522452
*/
24532453
static new(mem: BigNum, steps: BigNum): ExUnits;
24542454
}
2455+
/**
2456+
*/
2457+
declare export class FixedTransaction {
2458+
free(): void;
2459+
2460+
/**
2461+
* @returns {Uint8Array}
2462+
*/
2463+
to_bytes(): Uint8Array;
2464+
2465+
/**
2466+
* @param {Uint8Array} bytes
2467+
* @returns {FixedTransaction}
2468+
*/
2469+
static from_bytes(bytes: Uint8Array): FixedTransaction;
2470+
2471+
/**
2472+
* @returns {string}
2473+
*/
2474+
to_hex(): string;
2475+
2476+
/**
2477+
* @param {string} hex_str
2478+
* @returns {FixedTransaction}
2479+
*/
2480+
static from_hex(hex_str: string): FixedTransaction;
2481+
2482+
/**
2483+
* @param {Uint8Array} raw_body
2484+
* @param {Uint8Array} raw_witness_set
2485+
* @param {boolean} is_valid
2486+
* @returns {FixedTransaction}
2487+
*/
2488+
static new(
2489+
raw_body: Uint8Array,
2490+
raw_witness_set: Uint8Array,
2491+
is_valid: boolean
2492+
): FixedTransaction;
2493+
2494+
/**
2495+
* @param {Uint8Array} raw_body
2496+
* @param {Uint8Array} raw_witness_set
2497+
* @param {Uint8Array} raw_auxiliary_data
2498+
* @param {boolean} is_valid
2499+
* @returns {FixedTransaction}
2500+
*/
2501+
static new_with_auxiliary(
2502+
raw_body: Uint8Array,
2503+
raw_witness_set: Uint8Array,
2504+
raw_auxiliary_data: Uint8Array,
2505+
is_valid: boolean
2506+
): FixedTransaction;
2507+
2508+
/**
2509+
* @returns {TransactionBody}
2510+
*/
2511+
body(): TransactionBody;
2512+
2513+
/**
2514+
* @returns {Uint8Array}
2515+
*/
2516+
raw_body(): Uint8Array;
2517+
2518+
/**
2519+
* @param {Uint8Array} raw_body
2520+
*/
2521+
set_body(raw_body: Uint8Array): void;
2522+
2523+
/**
2524+
* @param {Uint8Array} raw_witness_set
2525+
*/
2526+
set_witness_set(raw_witness_set: Uint8Array): void;
2527+
2528+
/**
2529+
* @returns {TransactionWitnessSet}
2530+
*/
2531+
witness_set(): TransactionWitnessSet;
2532+
2533+
/**
2534+
* @returns {Uint8Array}
2535+
*/
2536+
raw_witness_set(): Uint8Array;
2537+
2538+
/**
2539+
* @param {boolean} valid
2540+
*/
2541+
set_is_valid(valid: boolean): void;
2542+
2543+
/**
2544+
* @returns {boolean}
2545+
*/
2546+
is_valid(): boolean;
2547+
2548+
/**
2549+
* @param {Uint8Array} raw_auxiliary_data
2550+
*/
2551+
set_auxiliary_data(raw_auxiliary_data: Uint8Array): void;
2552+
2553+
/**
2554+
* @returns {AuxiliaryData | void}
2555+
*/
2556+
auxiliary_data(): AuxiliaryData | void;
2557+
2558+
/**
2559+
* @returns {Uint8Array | void}
2560+
*/
2561+
raw_auxiliary_data(): Uint8Array | void;
2562+
}
24552563
/**
24562564
*/
24572565
declare export class GeneralTransactionMetadata {

rust/src/lib.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ pub mod traits;
5252
pub mod tx_builder;
5353
pub mod tx_builder_constants;
5454
pub mod typed_bytes;
55+
pub mod protocol_types;
5556
#[macro_use]
5657
pub mod utils;
5758
mod fakes;
@@ -109,7 +110,7 @@ type Slot32 = u32;
109110
type SlotBigNum = BigNum;
110111

111112
#[wasm_bindgen]
112-
#[derive(Clone, serde::Serialize, serde::Deserialize, JsonSchema)]
113+
#[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize, JsonSchema)]
113114
pub struct Transaction {
114115
body: TransactionBody,
115116
witness_set: TransactionWitnessSet,

0 commit comments

Comments
 (0)