Skip to content

Commit

Permalink
Merge pull request #102 from dashpay/v0.5-dev
Browse files Browse the repository at this point in the history
v0.5-dev to master
  • Loading branch information
ogabrielides authored Nov 27, 2024
2 parents 3e304a7 + f37eb9c commit e422bb4
Show file tree
Hide file tree
Showing 37 changed files with 1,790 additions and 321 deletions.
4 changes: 1 addition & 3 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ MAINNET_CORE_RPC_PORT=9998
MAINNET_CORE_RPC_USER=dashrpc
MAINNET_CORE_RPC_PASSWORD=password
MAINNET_INSIGHT_API_URL=https://insight.dash.org/insight-api
MAINNET_WALLET_PRIVATE_KEY=

# Testnet configuration
TESTNET_SHOW_IN_UI=true
Expand All @@ -15,5 +14,4 @@ TESTNET_CORE_HOST=127.0.0.1
TESTNET_CORE_RPC_PORT=19998
TESTNET_CORE_RPC_USER=dashrpc
TESTNET_CORE_RPC_PASSWORD=password
TESTNET_INSIGHT_API_URL=https://testnet-insight.dash.org/insight-api
TESTNET_WALLET_PRIVATE_KEY=
TESTNET_INSIGHT_API_URL=https://testnet-insight.dash.org/insight-api
15 changes: 1 addition & 14 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -22,17 +22,4 @@ Cargo.lock
*.pdb
.DS_Store
.idea/
**/.DS_Store

# Explorer state
*_explorer.state
*_explorer.state.*
explorer.drive

# Logs
explorer.log

# Supporting files
supporting_files/strategy_exports/
supporting_files/new_identity_private_keys.log
/identities.db
**/.DS_Store
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ strum = { version = "0.26.1", features = ["derive"] }
bs58 = "0.5.0"
base64 = "0.22.1"
copypasta = "0.10.1"
dash-sdk = { git = "https://github.com/dashpay/platform", rev = "c49af53698bad1070fcfc344ccaf6b3cc404e516" }
dash-sdk = { git = "https://github.com/dashpay/platform", rev = "f78f152403d789cdd091f3e88165671e975a6d63" }
thiserror = "1"
serde = "1.0.197"
serde_json = "1.0.120"
Expand Down
5 changes: 4 additions & 1 deletion src/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -423,6 +423,9 @@ impl App for AppState {
BackendTaskSuccessResult::RegisteredIdentity(_) => {
self.visible_screen_mut().display_task_result(message);
}
BackendTaskSuccessResult::ToppedUpIdentity(_) => {
self.visible_screen_mut().display_task_result(message);
}
},
TaskResult::Error(message) => {
self.visible_screen_mut()
Expand Down Expand Up @@ -457,7 +460,7 @@ impl App for AppState {
let core_item =
CoreItem::ReceivedAvailableUTXOTransaction(tx.clone(), utxos);
self.visible_screen_mut()
.display_task_result(core_item.into());
.display_task_result(BackendTaskSuccessResult::CoreItem(core_item));
}
Err(e) => {
eprintln!("Failed to store asset lock: {}", e);
Expand Down
2 changes: 0 additions & 2 deletions src/backend_task/core/start_dash_qt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@ use crate::context::AppContext;
use dash_sdk::dpp::dashcore::Network;
use std::path::PathBuf;
use std::process::{Command, Stdio};
use std::sync::Arc;
use std::time::{Duration, SystemTime, UNIX_EPOCH};
use std::{env, io};

impl AppContext {
Expand Down
7 changes: 4 additions & 3 deletions src/backend_task/identity/load_identity.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,22 +7,21 @@ use crate::model::qualified_identity::PrivateKeyTarget::{
self, PrivateKeyOnMainIdentity, PrivateKeyOnVoterIdentity,
};
use crate::model::qualified_identity::{DPNSNameInfo, IdentityType, QualifiedIdentity};
use crate::model::wallet::WalletSeedHash;
use dash_sdk::dashcore_rpc::dashcore::key::Secp256k1;
use dash_sdk::dashcore_rpc::dashcore::PrivateKey;
use dash_sdk::dpp::dashcore::hashes::Hash;
use dash_sdk::dpp::document::DocumentV0Getters;
use dash_sdk::dpp::identifier::MasternodeIdentifiers;
use dash_sdk::dpp::identity::accessors::IdentityGettersV0;
use dash_sdk::dpp::identity::identity_public_key::accessors::v0::IdentityPublicKeyGettersV0;
use dash_sdk::dpp::identity::{KeyType, SecurityLevel};
use dash_sdk::dpp::identity::SecurityLevel;
use dash_sdk::dpp::platform_value::string_encoding::Encoding;
use dash_sdk::dpp::platform_value::Value;
use dash_sdk::drive::query::{WhereClause, WhereOperator};
use dash_sdk::platform::{Document, DocumentQuery, Fetch, FetchMany, Identifier, Identity};
use dash_sdk::Sdk;
use egui::ahash::HashMap;
use std::collections::{BTreeMap, HashSet};
use std::collections::BTreeMap;

impl AppContext {
pub(super) async fn load_identity(
Expand Down Expand Up @@ -295,6 +294,8 @@ impl AppContext {
.iter()
.map(|wallet| (wallet.read().unwrap().seed_hash(), wallet.clone()))
.collect(),
wallet_index: None, //todo
top_ups: Default::default(),
};

// Insert qualified identity into the database
Expand Down
4 changes: 3 additions & 1 deletion src/backend_task/identity/load_identity_from_wallet.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use crate::model::qualified_identity::qualified_identity_public_key::QualifiedId
use crate::model::qualified_identity::{
DPNSNameInfo, IdentityType, PrivateKeyTarget, QualifiedIdentity,
};
use crate::model::wallet::{Wallet, WalletArcRef};
use crate::model::wallet::WalletArcRef;
use dash_sdk::dpp::dashcore::bip32::{DerivationPath, KeyDerivationType};
use dash_sdk::dpp::dashcore::hashes::Hash;
use dash_sdk::dpp::document::DocumentV0Getters;
Expand Down Expand Up @@ -137,6 +137,8 @@ impl AppContext {
wallet_arc_ref.wallet.read().unwrap().seed_hash(),
wallet_arc_ref.wallet.clone(),
)]),
wallet_index: Some(identity_index),
top_ups: Default::default(),
};

// Insert qualified identity into the database
Expand Down
35 changes: 31 additions & 4 deletions src/backend_task/identity/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ mod load_identity_from_wallet;
mod refresh_identity;
mod register_dpns_name;
mod register_identity;
mod top_up_identity;
mod transfer;
mod withdraw_from_identity;

Expand All @@ -19,7 +20,7 @@ use dash_sdk::dashcore_rpc::dashcore::key::Secp256k1;
use dash_sdk::dashcore_rpc::dashcore::{Address, PrivateKey, TxOut};
use dash_sdk::dpp::balances::credits::Duffs;
use dash_sdk::dpp::dashcore::hashes::Hash;
use dash_sdk::dpp::dashcore::{OutPoint, PublicKey, Transaction};
use dash_sdk::dpp::dashcore::{OutPoint, Transaction};
use dash_sdk::dpp::fee::Credits;
use dash_sdk::dpp::identity::accessors::IdentityGettersV0;
use dash_sdk::dpp::identity::identity_public_key::accessors::v0::IdentityPublicKeyGettersV0;
Expand Down Expand Up @@ -191,30 +192,52 @@ impl IdentityKeys {
}

pub type IdentityIndex = u32;
pub type TopUpIndex = u32;
#[derive(Debug, Clone, PartialEq, Eq)]
pub enum IdentityRegistrationMethod {
pub enum RegisterIdentityFundingMethod {
UseAssetLock(Address, AssetLockProof, Transaction),
FundWithUtxo(OutPoint, TxOut, Address, IdentityIndex),
FundWithWallet(Duffs, IdentityIndex),
}

#[derive(Debug, Clone, PartialEq, Eq)]
pub enum TopUpIdentityFundingMethod {
UseAssetLock(Address, AssetLockProof, Transaction),
FundWithUtxo(OutPoint, TxOut, Address, IdentityIndex, TopUpIndex),
FundWithWallet(Duffs, IdentityIndex, TopUpIndex),
}

#[derive(Debug, Clone)]
pub struct IdentityRegistrationInfo {
pub alias_input: String,
pub keys: IdentityKeys,
pub wallet: Arc<RwLock<Wallet>>,
pub wallet_identity_index: u32,
pub identity_registration_method: IdentityRegistrationMethod,
pub identity_funding_method: RegisterIdentityFundingMethod,
}

impl PartialEq for IdentityRegistrationInfo {
fn eq(&self, other: &Self) -> bool {
self.alias_input == other.alias_input
&& self.identity_registration_method == other.identity_registration_method
&& self.identity_funding_method == other.identity_funding_method
&& self.keys == other.keys
}
}

#[derive(Debug, Clone)]
pub struct IdentityTopUpInfo {
pub qualified_identity: QualifiedIdentity,
pub wallet: Arc<RwLock<Wallet>>,
pub identity_funding_method: TopUpIdentityFundingMethod,
}

impl PartialEq for IdentityTopUpInfo {
fn eq(&self, other: &Self) -> bool {
self.qualified_identity == other.qualified_identity
&& self.identity_funding_method == other.identity_funding_method
}
}

#[derive(Debug, Clone, PartialEq)]
pub struct RegisterDpnsNameInput {
pub qualified_identity: QualifiedIdentity,
Expand All @@ -226,6 +249,7 @@ pub(crate) enum IdentityTask {
LoadIdentity(IdentityInputToLoad),
SearchIdentityFromWallet(WalletArcRef, IdentityIndex),
RegisterIdentity(IdentityRegistrationInfo),
TopUpIdentity(IdentityTopUpInfo),
AddKeyToIdentity(QualifiedIdentity, QualifiedIdentityPublicKey, [u8; 32]),
WithdrawFromIdentity(QualifiedIdentity, Option<Address>, Credits, Option<KeyID>),
Transfer(QualifiedIdentity, Identifier, Credits, Option<KeyID>),
Expand Down Expand Up @@ -440,6 +464,9 @@ impl AppContext {
self.load_user_identity_from_wallet(sdk, wallet, identity_index)
.await
}
IdentityTask::TopUpIdentity(top_up_info) => {
self.top_up_identity(top_up_info, sender).await
}
}
}
}
Loading

0 comments on commit e422bb4

Please sign in to comment.