Skip to content

Commit

Permalink
Update for rusty-kaspa 'typescript' branch compatibility
Browse files Browse the repository at this point in the history
  • Loading branch information
aspect committed Mar 2, 2024
1 parent 9137bc7 commit bf689d8
Show file tree
Hide file tree
Showing 10 changed files with 416 additions and 312 deletions.
591 changes: 345 additions & 246 deletions Cargo.lock

Large diffs are not rendered by default.

99 changes: 50 additions & 49 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -59,37 +59,38 @@ egui-notify = "=0.11.0"
# | \ |__| ___] | | | \_ | | ___] | | |
# _______________________________________________________

kaspa-addresses = "0.13.4"
kaspa-alloc = "0.13.4"
kaspa-bip32 = "0.13.4"
kaspa-cli = "0.13.4"
kaspa-consensus-core = "0.13.4"
kaspa-core = "0.13.4"
kaspa-metrics-core = "0.13.4"
kaspa-notify = "0.13.4"
kaspa-rpc-core = "0.13.4"
kaspa-rpc-service = "0.13.4"
kaspa-utils = "0.13.4"
kaspa-wallet-core = "0.13.4"
kaspa-wrpc-client = "0.13.4"
kaspa-wrpc-server = "0.13.4"
kaspad = "0.13.4"

# kaspa-addresses = { path = "../rusty-kaspa/crypto/addresses" }
# kaspa-alloc = { path = "../rusty-kaspa/utils/alloc" }
# kaspa-bip32 = { path = "../rusty-kaspa/wallet/bip32" }
# kaspa-cli = { path = "../rusty-kaspa/cli" }
# kaspa-consensus-core = { path = "../rusty-kaspa/consensus/core" }
# kaspa-core = { path = "../rusty-kaspa/core" }
# kaspa-metrics-core = { path = "../rusty-kaspa/metrics/core" }
# kaspa-notify = { path = "../rusty-kaspa/notify" }
# kaspa-rpc-core = { path = "../rusty-kaspa/rpc/core" }
# kaspa-rpc-service = { path = "../rusty-kaspa/rpc/service" }
# kaspa-utils = { path = "../rusty-kaspa/utils" }
# kaspa-wallet-core = { path = "../rusty-kaspa/wallet/core", features=["no-unsafe-eval"] }
# kaspa-wrpc-client = { path = "../rusty-kaspa/rpc/wrpc/client", features=["no-unsafe-eval"] }
# kaspa-wrpc-server = { path = "../rusty-kaspa/rpc/wrpc/server" }
# kaspad = { path = "../rusty-kaspa/kaspad" }
# kaspa-addresses = "0.13.4"
# kaspa-alloc = "0.13.4"
# kaspa-bip32 = "0.13.4"
# kaspa-cli = "0.13.4"
# kaspa-consensus-core = "0.13.4"
# kaspa-core = "0.13.4"
# kaspa-metrics-core = "0.13.4"
# kaspa-notify = "0.13.4"
# kaspa-rpc-core = "0.13.4"
# kaspa-rpc-service = "0.13.4"
# kaspa-utils = "0.13.4"
# kaspa-wallet-core = "0.13.4"
# kaspa-wrpc-client = "0.13.4"
# kaspa-wrpc-server = "0.13.4"
# kaspad = "0.13.4"

kaspa-addresses = { path = "../rusty-kaspa/crypto/addresses" }
kaspa-alloc = { path = "../rusty-kaspa/utils/alloc" }
kaspa-bip32 = { path = "../rusty-kaspa/wallet/bip32" }
kaspa-cli = { path = "../rusty-kaspa/cli" }
kaspa-consensus-core = { path = "../rusty-kaspa/consensus/core" }
kaspa-core = { path = "../rusty-kaspa/core" }
kaspa-metrics-core = { path = "../rusty-kaspa/metrics/core" }
kaspa-notify = { path = "../rusty-kaspa/notify" }
kaspa-rpc-core = { path = "../rusty-kaspa/rpc/core" }
kaspa-rpc-service = { path = "../rusty-kaspa/rpc/service" }
kaspa-utils = { path = "../rusty-kaspa/utils" }
kaspa-wallet-core = { path = "../rusty-kaspa/wallet/core" }
kaspa-wallet-keys = { path = "../rusty-kaspa/wallet/keys" }
kaspa-wrpc-client = { path = "../rusty-kaspa/rpc/wrpc/client"}
kaspa-wrpc-server = { path = "../rusty-kaspa/rpc/wrpc/server" }
kaspad = { path = "../rusty-kaspa/kaspad" }

# kaspa-addresses = { git = "https://github.com/kaspanet/rusty-kaspa.git", branch = "master" }
# kaspa-alloc = { git = "https://github.com/kaspanet/rusty-kaspa.git", branch = "master" }
Expand Down Expand Up @@ -129,26 +130,26 @@ kaspad = "0.13.4"
# |_|_| |__| | \ | \_ | |___ |__| |_|_| | \ ___]
# _________________________________________________________

workflow-core = { version = "0.10.3", features = ["no-unsafe-eval"] }
workflow-i18n = { version = "0.11.0" }
workflow-chrome = "0.10.3"
workflow-dom = "0.10.3"
workflow-http = "0.10.3"
workflow-log = "0.10.3"
workflow-store = "0.10.3"
workflow-wasm = "0.10.3"

# workflow-core = { path = "../workflow-rs/core", features = ["no-unsafe-eval"] }
# workflow-i18n = { path = "../workflow-rs/i18n", features = ["preserve-order"] }
# workflow-chrome = { path = "../workflow-rs/chrome" }
# workflow-dom = { path = "../workflow-rs/dom" }
# workflow-http = { path = "../workflow-rs/http" }
# workflow-log = { path = "../workflow-rs/log" }
# workflow-store = { path = "../workflow-rs/store" }
# workflow-wasm = { path = "../workflow-rs/wasm" }
# workflow-core = { version = "0.10.3", features = ["no-unsafe-eval"] }
# workflow-i18n = { version = "0.11.0" }
# workflow-chrome = "0.10.3"
# workflow-dom = "0.10.3"
# workflow-http = "0.10.3"
# workflow-log = "0.10.3"
# workflow-store = "0.10.3"
# workflow-wasm = "0.10.3"

workflow-core = { path = "../workflow-rs/core" }
workflow-i18n = { path = "../workflow-rs/i18n" }
workflow-chrome = { path = "../workflow-rs/chrome" }
workflow-dom = { path = "../workflow-rs/dom" }
workflow-http = { path = "../workflow-rs/http" }
workflow-log = { path = "../workflow-rs/log" }
workflow-store = { path = "../workflow-rs/store" }
workflow-wasm = { path = "../workflow-rs/wasm" }

# workflow-core = { git = "https://github.com/workflow-rs/workflow-rs.git", branch = "master", features = ["no-unsafe-eval"] }
# workflow-i18n = { git = "https://github.com/workflow-rs/workflow-rs.git", branch = "master", features = ["preserve-order"] }
# workflow-i18n = { git = "https://github.com/workflow-rs/workflow-rs.git", branch = "master" }
# workflow-chrome = { git = "https://github.com/workflow-rs/workflow-rs.git", branch = "master" }
# workflow-dom = { git = "https://github.com/workflow-rs/workflow-rs.git", branch = "master" }
# workflow-http = { git = "https://github.com/workflow-rs/workflow-rs.git", branch = "master" }
Expand Down
1 change: 1 addition & 0 deletions core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ kaspa-notify.workspace = true
kaspa-rpc-core.workspace = true
kaspa-utils.workspace = true
kaspa-wallet-core.workspace = true
kaspa-wallet-keys.workspace = true
kaspa-wrpc-client.workspace = true

workflow-core.workspace = true
Expand Down
2 changes: 1 addition & 1 deletion core/src/core.rs
Original file line number Diff line number Diff line change
Expand Up @@ -890,7 +890,7 @@ impl Core {
self.purge_secure_stack();
}
CoreWallet::AccountSelection { id: _ } => {}
CoreWallet::DAAScoreChange { current_daa_score } => {
CoreWallet::DaaScoreChange { current_daa_score } => {
self.state.current_daa_score.replace(current_daa_score);
}
// Ignore scan notifications
Expand Down
2 changes: 1 addition & 1 deletion core/src/modules/import.rs
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ impl ModuleT for Import {
);

if ui.add_sized(size, egui::Button::new("Unlock")).clicked() {
let wallet_secret = kaspa_wallet_core::secret::Secret::new(
let wallet_secret = Secret::new(
self.wallet_secret.as_bytes().to_vec()
);
self.wallet_secret.zeroize();
Expand Down
4 changes: 2 additions & 2 deletions core/src/modules/wallet_create.rs
Original file line number Diff line number Diff line change
Expand Up @@ -852,7 +852,7 @@ impl ModuleT for WalletCreate {

let wallet_secret = Secret::from(args.wallet_secret.as_str());
let payment_secret = args.import_with_bip39_passphrase.then_some(Secret::from(args.payment_secret.as_str()));
let mnemonic = sanitize_mnemonic(args.import_private_key_mnemonic.as_str());
let mnemonic = Secret::from(sanitize_mnemonic(args.import_private_key_mnemonic.as_str()));


let request = AccountsDiscoveryRequest {
Expand Down Expand Up @@ -973,7 +973,7 @@ impl ModuleT for WalletCreate {
let prv_key_data_args = PrvKeyDataCreateArgs::new(
None,
payment_secret.clone(),
mnemonic_phrase_string.clone(),
Secret::from(mnemonic_phrase_string.clone()),
);

let prv_key_data_id = wallet.clone().prv_key_data_create(wallet_secret.clone(), prv_key_data_args).await?;
Expand Down
2 changes: 1 addition & 1 deletion core/src/modules/wallet_open.rs
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ impl ModuleT for WalletOpen {
.render(ui);

if *unlock.borrow() {
let wallet_secret = kaspa_wallet_core::secret::Secret::new(
let wallet_secret = Secret::new(
self.wallet_secret.as_bytes().to_vec(),
);
self.wallet_secret.zeroize();
Expand Down
21 changes: 12 additions & 9 deletions core/src/runtime/services/kaspa/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ impl KaspaService {
}
}
} else {
// log_warning!("Node settings are not initialized");
// log_warn!("Node settings are not initialized");
}

Self {
Expand All @@ -137,15 +137,18 @@ impl KaspaService {
pub fn create_rpc_client(config: &RpcConfig, network: Network) -> Result<Rpc> {
match config {
RpcConfig::Wrpc { url, encoding } => {
// log_warning!("create_rpc_client - RPC URL: {:?}", url);
// log_warn!("create_rpc_client - RPC URL: {:?}", url);
let url = url.clone().unwrap_or_else(|| "127.0.0.1".to_string());
let url =
KaspaRpcClient::parse_url(url, *encoding, NetworkId::from(network).into())?;

let wrpc_client = Arc::new(KaspaRpcClient::new_with_args(
*encoding,
NotificationMode::MultiListeners,
url.as_str(),
Some(url.as_str()),
// TODO ex1
None,
None,
)?);
let rpc_ctl = wrpc_client.ctl().clone();
let rpc_api: Arc<DynRpcApi> = wrpc_client;
Expand All @@ -171,7 +174,7 @@ impl KaspaService {
connect_timeout: None,
retry_interval: Some(Duration::from_millis(3000)),
};
wrpc_client.connect(options).await?;
wrpc_client.connect(Some(options)).await?;
} else {
#[cfg(not(target_arch = "wasm32"))]
{
Expand Down Expand Up @@ -229,7 +232,7 @@ impl KaspaService {
.clone()
.downcast_arc::<KaspaRpcClient>()
{
Some(wrpc_client.url().to_string())
wrpc_client.url()
} else {
None
}
Expand Down Expand Up @@ -277,7 +280,7 @@ impl KaspaService {
let instant = Instant::now();
service.clone().detach_rpc().await?;
if instant.elapsed().as_millis() > 1_000 {
log_warning!(
log_warn!(
"WARNING: detach_rpc() for '{}' took {} msec",
service.name(),
instant.elapsed().as_millis()
Expand Down Expand Up @@ -316,7 +319,7 @@ impl KaspaService {
let rpc_api = rpc.rpc_api().clone();

self.wallet()
.set_network_id(network.into())
.set_network_id(&network.into())
.expect("Can not change network id while the wallet is connected");

self.wallet().bind_rpc(Some(rpc)).await.unwrap();
Expand Down Expand Up @@ -408,7 +411,7 @@ impl Service for KaspaService {
use kaspa_wallet_core::events::Events as CoreWallet;

match *event {
CoreWallet::DAAScoreChange{ .. } => {
CoreWallet::DaaScoreChange{ .. } => {
}
CoreWallet::Connect { .. } => {
self.connect_all_services().await?;
Expand Down Expand Up @@ -529,7 +532,7 @@ impl Service for KaspaService {
// to be opened offline in disconnected
// mode by changing network id in settings
self.wallet()
.set_network_id(network.into()).ok();
.set_network_id(&network.into()).ok();
}

KaspadServiceEvents::Exit => {
Expand Down
4 changes: 2 additions & 2 deletions core/src/settings.rs
Original file line number Diff line number Diff line change
Expand Up @@ -659,10 +659,10 @@ impl Settings {
#[allow(clippy::if_same_then_else)]
if matches!(error, workflow_store::error::Error::SerdeJson(..)) {
// TODO - recovery process
log_warning!("Settings::load() error: {}", error);
log_warn!("Settings::load() error: {}", error);
Ok(Self::default())
} else {
log_warning!("Settings::load() error: {}", error);
log_warn!("Settings::load() error: {}", error);
Ok(Self::default())
}
}
Expand Down
2 changes: 1 addition & 1 deletion extensions/chrome/src/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ impl Server {
fn _post_notify(&self, op: u64, data: Vec<u8>) -> Result<()> {
spawn_local(async move {
if let Err(err) = send_message(&notify_to_jsv(op, &data)).await {
log_warning!("Unable to post notification: {:?}", err);
log_warn!("Unable to post notification: {:?}", err);
}
});

Expand Down

0 comments on commit bf689d8

Please sign in to comment.