-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: adds settings JSON-RPC call to allow changes to indexer URL (#744)
Description --- Add new jrpc calls that will allow change of the indexer jrpc url in the wallet daemon. Motivation and Context --- How Has This Been Tested? --- as below What process can a PR reviewer use to test or verify this change? --- Run dan-testing with 2 indexers. And call the jrpc method to change it. And e.g. send money using the new indexer. Then you should clearly see in the logs which one was used. Breaking Changes --- - [x] None - [ ] Requires data directory to be deleted - [ ] Other - Please specify
- Loading branch information
Showing
14 changed files
with
159 additions
and
93 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
39 changes: 39 additions & 0 deletions
39
applications/tari_dan_wallet_daemon/src/handlers/settings.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
// Copyright 2023 The Tari Project | ||
// SPDX-License-Identifier: BSD-3-Clause | ||
|
||
use tari_dan_common_types::optional::Optional; | ||
use tari_dan_wallet_sdk::{ | ||
apis::{config::ConfigKey, jwt::JrpcPermission}, | ||
network::WalletNetworkInterface, | ||
}; | ||
use tari_wallet_daemon_client::types::{SettingsGetResponse, SettingsSetRequest, SettingsSetResponse}; | ||
|
||
use crate::handlers::HandlerContext; | ||
|
||
pub async fn handle_get( | ||
context: &HandlerContext, | ||
token: Option<String>, | ||
_value: serde_json::Value, | ||
) -> Result<SettingsGetResponse, anyhow::Error> { | ||
let sdk = context.wallet_sdk().clone(); | ||
sdk.jwt_api().check_auth(token, &[JrpcPermission::Admin])?; | ||
let indexer_url = if let Some(indexer_url) = sdk.config_api().get(ConfigKey::IndexerUrl).optional()? { | ||
indexer_url | ||
} else { | ||
sdk.get_config().indexer_jrpc_endpoint.clone() | ||
}; | ||
|
||
Ok(SettingsGetResponse { indexer_url }) | ||
} | ||
|
||
pub async fn handle_set( | ||
context: &HandlerContext, | ||
token: Option<String>, | ||
req: SettingsSetRequest, | ||
) -> Result<SettingsSetResponse, anyhow::Error> { | ||
let mut sdk = context.wallet_sdk().clone(); | ||
sdk.jwt_api().check_auth(token, &[JrpcPermission::Admin])?; | ||
sdk.get_network_interface().set_endpoint(&req.indexer_url)?; | ||
sdk.config_api().set(ConfigKey::IndexerUrl, &req.indexer_url, false)?; | ||
Ok(SettingsSetResponse {}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.