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

Tx builder max output size fixes #204

Merged
merged 10 commits into from
Sep 19, 2021
2 changes: 1 addition & 1 deletion package-lock.json

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

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "cardano-serialization-lib",
"version": "8.1.0",
"version": "9.0.0-beta.1",
"description": "(De)serialization functions for the Cardano blockchain along with related utility functions",
"scripts": {
"rust:build-nodejs": "rimraf ./rust/pkg && cd rust; wasm-pack build --target=nodejs; wasm-pack pack; cd .. && npm run js:flowgen",
Expand Down
4 changes: 1 addition & 3 deletions rust/Cargo.lock

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

2 changes: 1 addition & 1 deletion rust/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "cardano-serialization-lib"
version = "8.1.0"
version = "9.0.0-beta.1"
edition = "2018"
authors = ["EMURGO"]
license = "MIT"
Expand Down
1 change: 0 additions & 1 deletion rust/pkg/.gitignore

This file was deleted.

149 changes: 92 additions & 57 deletions rust/pkg/cardano_serialization_lib.js.flow
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,42 @@
* @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 {string} password
* @param {string} salt
Expand Down Expand Up @@ -120,42 +156,6 @@ declare export function min_ada_required(
minimum_utxo_val: BigNum
): BigNum;

/**
* @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;

/**
*/

Expand Down Expand Up @@ -225,6 +225,26 @@ declare export var NetworkIdKind: {|
+Mainnet: 1, // 1
|};

/**
*/

declare export var TransactionMetadatumKind: {|
+MetadataMap: 0, // 0
+MetadataList: 1, // 1
+Int: 2, // 2
+Bytes: 3, // 3
+Text: 4, // 4
|};

/**
*/

declare export var MetadataJsonSchema: {|
+NoConversions: 0, // 0
+BasicConversions: 1, // 1
+DetailedSchema: 2, // 2
|};

/**
*/

Expand Down Expand Up @@ -253,26 +273,6 @@ declare export var RedeemerTagKind: {|
+Reward: 3, // 3
|};

/**
*/

declare export var TransactionMetadatumKind: {|
+MetadataMap: 0, // 0
+MetadataList: 1, // 1
+Int: 2, // 2
+Bytes: 3, // 3
+Text: 4, // 4
|};

/**
*/

declare export var MetadataJsonSchema: {|
+NoConversions: 0, // 0
+BasicConversions: 1, // 1
+DetailedSchema: 2, // 2
|};

/**
*/
declare export class Address {
Expand Down Expand Up @@ -375,6 +375,17 @@ declare export class AssetNames {
declare export class Assets {
free(): void;

/**
* @returns {Uint8Array}
*/
to_bytes(): Uint8Array;

/**
* @param {Uint8Array} bytes
* @returns {Assets}
*/
static from_bytes(bytes: Uint8Array): Assets;

/**
* @returns {Assets}
*/
Expand Down Expand Up @@ -612,6 +623,11 @@ declare export class BigNum {
*/
to_str(): string;

/**
* @returns {BigNum}
*/
static zero(): BigNum;

/**
* @param {BigNum} other
* @returns {BigNum}
Expand Down Expand Up @@ -4889,13 +4905,17 @@ declare export class TransactionBuilder {
* @param {BigNum} minimum_utxo_val
* @param {BigNum} pool_deposit
* @param {BigNum} key_deposit
* @param {number} max_output_size
* @param {number} max_tx_size
* @returns {TransactionBuilder}
*/
static new(
linear_fee: LinearFee,
minimum_utxo_val: BigNum,
pool_deposit: BigNum,
key_deposit: BigNum
key_deposit: BigNum,
max_output_size: number,
max_tx_size: number
): TransactionBuilder;

/**
Expand Down Expand Up @@ -4933,6 +4953,21 @@ declare export class TransactionBuilder {
*/
add_change_if_needed(address: Address): boolean;

/**
* @returns {number}
*/
full_size(): number;

/**
* @returns {Uint32Array}
*/
output_sizes(): Uint32Array;

/**
* @returns {Uint32Array}
*/
output_value_sizes(): Uint32Array;

/**
* @returns {TransactionBody}
*/
Expand Down
8 changes: 5 additions & 3 deletions rust/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -385,7 +385,7 @@ impl TransactionInput {
#[derive(Clone, Debug)]
pub struct TransactionOutput {
address: Address,
amount: Value,
pub (crate) amount: Value,
data_hash: Option<DataHash>,
}

Expand Down Expand Up @@ -2461,7 +2461,9 @@ pub type PolicyIDs = ScriptHashes;

#[wasm_bindgen]
#[derive(Clone, Debug, Eq, Ord, PartialEq, PartialOrd)]
pub struct Assets(std::collections::BTreeMap<AssetName, BigNum>);
pub struct Assets(pub (crate) std::collections::BTreeMap<AssetName, BigNum>);

to_from_bytes!(Assets);

#[wasm_bindgen]
impl Assets {
Expand All @@ -2488,7 +2490,7 @@ impl Assets {

#[wasm_bindgen]
#[derive(Clone, Debug, Eq, Ord, PartialEq)]
pub struct MultiAsset(std::collections::BTreeMap<PolicyID, Assets>);
pub struct MultiAsset(pub (crate) std::collections::BTreeMap<PolicyID, Assets>);

to_from_bytes!(MultiAsset);

Expand Down
Loading