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

Feat/update cardano ser lib #1477

Merged
merged 2 commits into from
Nov 27, 2024
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
86 changes: 72 additions & 14 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/apps/cardano/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,4 @@ bech32 = { workspace = true }

[dependencies.cardano-serialization-lib]
git = "https://[email protected]/KeystoneHQ/cardano-serialization-lib.git"
tag = "keystone-0.1.4"
tag = "keystone-0.1.5"
20 changes: 9 additions & 11 deletions rust/apps/cardano/src/address.rs
Original file line number Diff line number Diff line change
@@ -1,16 +1,14 @@
use crate::errors::{CardanoError, R};
use alloc::string::{String, ToString};

use cardano_serialization_lib::address::{
BaseAddress, EnterpriseAddress, RewardAddress, StakeCredential,
use cardano_serialization_lib::protocol_types::credential::*;
use cardano_serialization_lib::protocol_types::{
BaseAddress, Ed25519KeyHash, EnterpriseAddress, RewardAddress,
};
use cardano_serialization_lib::crypto::Ed25519KeyHash;

use cryptoxide::hashing::blake2b_224;
use ed25519_bip32_core::{DerivationScheme, XPub};
use hex;
use ur_registry::crypto_key_path::CryptoKeyPath;

pub enum AddressType {
Base,
Stake,
Expand All @@ -21,7 +19,7 @@ pub fn calc_stake_address_from_xpub(stake_key: [u8; 32]) -> R<String> {
let stake_key_hash = blake2b_224(&stake_key);
let address = RewardAddress::new(
1,
&StakeCredential::from_keyhash(&Ed25519KeyHash::from(stake_key_hash)),
&Credential::from_keyhash(&Ed25519KeyHash::from(stake_key_hash)),
);
address
.to_address()
Expand Down Expand Up @@ -65,8 +63,8 @@ pub fn derive_address(
let stake_key_hash = blake2b_224(&stake_key);
let address = BaseAddress::new(
network,
&StakeCredential::from_keyhash(&Ed25519KeyHash::from(payment_key_hash)),
&StakeCredential::from_keyhash(&Ed25519KeyHash::from(stake_key_hash)),
&Credential::from_keyhash(&Ed25519KeyHash::from(payment_key_hash)),
&Credential::from_keyhash(&Ed25519KeyHash::from(stake_key_hash)),
);
address
.to_address()
Expand All @@ -81,7 +79,7 @@ pub fn derive_address(
let stake_key_hash = blake2b_224(&stake_key);
let address = RewardAddress::new(
network,
&StakeCredential::from_keyhash(&Ed25519KeyHash::from(stake_key_hash)),
&Credential::from_keyhash(&Ed25519KeyHash::from(stake_key_hash)),
);
address
.to_address()
Expand All @@ -96,7 +94,7 @@ pub fn derive_address(
let payment_key_hash = blake2b_224(&payment_key);
let address = EnterpriseAddress::new(
network,
&StakeCredential::from_keyhash(&Ed25519KeyHash::from(payment_key_hash)),
&Credential::from_keyhash(&Ed25519KeyHash::from(payment_key_hash)),
);
address
.to_address()
Expand Down Expand Up @@ -124,7 +122,7 @@ mod tests {
use alloc::string::ToString;
use alloc::vec;
use bech32;
use cardano_serialization_lib::address::{Address, BaseAddress};
use cardano_serialization_lib::protocol_types::{Address, BaseAddress};
use cryptoxide::hashing::blake2b_224;
use keystore;

Expand Down
2 changes: 1 addition & 1 deletion rust/apps/cardano/src/errors.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use alloc::string::{String, ToString};
use cardano_serialization_lib::error::DeserializeError;
use cardano_serialization_lib::DeserializeError;
use ed25519_bip32_core::DerivationError;
use thiserror;
use thiserror::Error;
Expand Down
2 changes: 1 addition & 1 deletion rust/apps/cardano/src/governance.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use crate::errors::{CardanoError, R};
use crate::structs::SignVotingRegistrationResult;
use alloc::string::{String, ToString};
use alloc::vec::Vec;
use cardano_serialization_lib::address::{Address, BaseAddress};
use cardano_serialization_lib::protocol_types::Address;
use cryptoxide::hashing::blake2b_256;
use ed25519_bip32_core::{XPrv, XPub};
use hex;
Expand Down
Loading
Loading