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

TxBuilder: Implement CIP-0002 Coin Selection #232

Merged
merged 4 commits into from
Nov 7, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
70 changes: 65 additions & 5 deletions rust/Cargo.lock

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

1 change: 1 addition & 0 deletions rust/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ num-bigint = "0.4.0"
# feature or this one
clear_on_drop = { version = "0.2", features = ["no_cc"] }
itertools = "0.10.1"
rand = "0.8.4"

# non-wasm
[target.'cfg(not(all(target_arch = "wasm32", not(target_os = "emscripten"))))'.dependencies]
Expand Down
6 changes: 3 additions & 3 deletions rust/src/address.rs
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ impl Deserialize for StakeCredential {
}
}

#[derive(Debug, Clone)]
#[derive(Debug, Clone, Eq, Ord, PartialEq, PartialOrd)]
enum AddrType {
Base(BaseAddress),
Ptr(PointerAddress),
Expand All @@ -177,7 +177,7 @@ enum AddrType {
}

#[wasm_bindgen]
#[derive(Clone, Debug)]
#[derive(Debug, Clone, Eq, Ord, PartialEq, PartialOrd)]
pub struct ByronAddress(pub (crate) ExtendedAddr);
#[wasm_bindgen]
impl ByronAddress {
Expand Down Expand Up @@ -264,7 +264,7 @@ impl ByronAddress {
}

#[wasm_bindgen]
#[derive(Debug, Clone)]
#[derive(Debug, Clone, Eq, Ord, PartialEq, PartialOrd)]
pub struct Address(AddrType);

from_bytes!(Address, data, {
Expand Down
8 changes: 4 additions & 4 deletions rust/src/legacy_address/address.rs
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ impl cbor_event::de::Deserialize for AddrType {

type HDAddressPayload = Vec<u8>;

#[derive(Debug, PartialEq, Eq, PartialOrd, Ord, Clone)]
#[derive(Debug, Clone, Eq, Hash, Ord, PartialEq, PartialOrd)]
pub struct Attributes {
pub derivation_path: Option<HDAddressPayload>,
pub protocol_magic: Option<u32>,
Expand Down Expand Up @@ -182,10 +182,10 @@ fn hash_spending_data(addr_type: AddrType, xpub: &XPub, attrs: &Attributes) -> [
}

/// A valid cardano Address that is displayed in base58
#[derive(Debug, PartialEq, Eq, PartialOrd, Ord, Clone)]
#[derive(Debug, Clone, Eq, Hash, Ord, PartialEq, PartialOrd)]
pub struct Addr(Vec<u8>);

#[derive(Debug, Clone, Copy, PartialEq, Eq)]
#[derive(Debug, Clone, Eq, Hash, Ord, PartialEq, PartialOrd)]
pub enum AddressMatchXPub {
Yes,
No,
Expand Down Expand Up @@ -277,7 +277,7 @@ impl cbor_event::de::Deserialize for Addr {
const EXTENDED_ADDR_LEN: usize = 28;

/// A valid cardano address deconstructed
#[derive(Debug, PartialEq, Eq, Clone)]
#[derive(Debug, Clone, Eq, Ord, PartialEq, PartialOrd)]
pub struct ExtendedAddr {
pub addr: [u8; EXTENDED_ADDR_LEN],
pub attributes: Attributes,
Expand Down
2 changes: 1 addition & 1 deletion rust/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -383,7 +383,7 @@ impl TransactionInput {
}

#[wasm_bindgen]
#[derive(Clone, Debug)]
#[derive(Debug, Clone, Eq, Ord, PartialEq, PartialOrd)]
pub struct TransactionOutput {
address: Address,
pub (crate) amount: Value,
Expand Down
Loading