diff --git a/applications/tari_dan_wallet_web_ui/src/routes/Wallet/Components/Accounts.tsx b/applications/tari_dan_wallet_web_ui/src/routes/Wallet/Components/Accounts.tsx index 247c33452..8b70fd6f3 100644 --- a/applications/tari_dan_wallet_web_ui/src/routes/Wallet/Components/Accounts.tsx +++ b/applications/tari_dan_wallet_web_ui/src/routes/Wallet/Components/Accounts.tsx @@ -21,7 +21,7 @@ // USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. import { ReactNode, useEffect, useState } from "react"; -import { accountsClaimBurn, accountsCreate, accountsList } from "../../../utils/json_rpc"; +import {accountsClaimBurn, accountsCreate, accountsCreateFreeTestCoins, accountsList} from "../../../utils/json_rpc"; import Error from "./Error"; import Table from "@mui/material/Table"; import TableBody from "@mui/material/TableBody"; @@ -98,6 +98,10 @@ function Accounts() { setAccountFormState({ ...accountFormState, [e.target.name]: e.target.value }); }; + const onClaimFreeCoins = () => { + accountsCreateFreeTestCoins("TestAccount", 100000, 1000).then((response) => { loadAccounts(); }); + } + const onClaimBurn = () => { accountsClaimBurn(claimBurnFormState.account, JSON.parse(claimBurnFormState.claimProof), +claimBurnFormState.fee) .then((response) => { @@ -130,6 +134,11 @@ function Accounts() { {error} ) : null} +
+ +
{showAccountDialog && (
diff --git a/applications/tari_dan_wallet_web_ui/src/utils/json_rpc.tsx b/applications/tari_dan_wallet_web_ui/src/utils/json_rpc.tsx index 0c16793d5..bbbb121cb 100644 --- a/applications/tari_dan_wallet_web_ui/src/utils/json_rpc.tsx +++ b/applications/tari_dan_wallet_web_ui/src/utils/json_rpc.tsx @@ -169,6 +169,7 @@ export const accountsCreate = ( fee, is_default, ]); +export const accountsCreateFreeTestCoins = (accountName: string | undefined, amount: number | undefined, fee: number | undefined) => jsonRpc("accounts.create_free_test_coins", [{ "Name": accountName}, amount, fee]); export const accountsList = (offset: number, limit: number) => jsonRpc('accounts.list', [offset, limit]); export const accountsGetBalances = (accountName: string) => diff --git a/applications/tari_indexer/src/json_rpc/handlers.rs b/applications/tari_indexer/src/json_rpc/handlers.rs index 42327981c..f6a5a547f 100644 --- a/applications/tari_indexer/src/json_rpc/handlers.rs +++ b/applications/tari_indexer/src/json_rpc/handlers.rs @@ -161,10 +161,10 @@ impl JsonRpcHandlers { let response = json!({ "vns": vns }); Ok(JsonRpcResponse::success(answer_id, response)) }, - Err(e) => { - warn!(target: LOG_TARGET, "Failed to get all vns: {}", e); - Err(Self::generic_error_response(answer_id)) - }, + Err(e) => Err(Self::generic_error_response( + answer_id, + format!("Failed to get all vns: {}", e), + )), } } @@ -190,18 +190,18 @@ impl JsonRpcHandlers { &tari_comms::net_address::PeerAddressSource::Config, ) .await - .map_err(|_| Self::generic_error_response(answer_id))?; + .map_err(|e| Self::generic_error_response(answer_id, format!("Could not update peer: {}", e)))?; if wait_for_dial { let _conn = connectivity .dial_peer(node_id) .await - .map_err(|_| Self::generic_error_response(answer_id))?; + .map_err(|e| Self::generic_error_response(answer_id, e.to_string()))?; } else { // Dial without waiting connectivity .request_many_dials(Some(node_id)) .await - .map_err(|_| Self::generic_error_response(answer_id))?; + .map_err(|e| Self::generic_error_response(answer_id, e.to_string()))?; } Ok(JsonRpcResponse::success(answer_id, AddPeerResponse {})) @@ -216,7 +216,10 @@ impl JsonRpcHandlers { }, Err(e) => { warn!(target: LOG_TARGET, "Failed to get comms stats: {}", e); - Err(Self::generic_error_response(answer_id)) + Err(Self::generic_error_response( + answer_id, + format!("Failed to get comms stats: {}", e), + )) }, } } @@ -267,7 +270,7 @@ impl JsonRpcHandlers { .await .map_err(|e| { warn!(target: LOG_TARGET, "Error getting substate: {}", e); - Self::generic_error_response(answer_id) + Self::generic_error_response(answer_id, format!("Error getting substate: {}", e)) })? { Some(substate_resp) => Ok(JsonRpcResponse::success(answer_id, GetSubstateResponse { address: substate_resp.address, @@ -359,7 +362,7 @@ impl JsonRpcHandlers { .await .map_err(|e| { warn!(target: LOG_TARGET, "Error getting substate: {}", e); - Self::generic_error_response(answer_id) + Self::generic_error_response(answer_id, format!("Error getting substate: {}", e)) })? .ok_or_else(|| { JsonRpcResponse::error( @@ -394,7 +397,10 @@ impl JsonRpcHandlers { Ok(addresses) => Ok(JsonRpcResponse::success(answer_id, addresses)), Err(e) => { warn!(target: LOG_TARGET, "Error getting addresses: {}", e); - Err(Self::generic_error_response(answer_id)) + Err(Self::generic_error_response( + answer_id, + format!("Error getting addresses: {}", e), + )) }, } } @@ -411,7 +417,10 @@ impl JsonRpcHandlers { Ok(_) => Ok(JsonRpcResponse::success(answer_id, ())), Err(e) => { warn!(target: LOG_TARGET, "Error adding address: {}", e); - Err(Self::generic_error_response(answer_id)) + Err(Self::generic_error_response( + answer_id, + format!("Error adding address: {}", e), + )) }, } } @@ -424,7 +433,10 @@ impl JsonRpcHandlers { Ok(_) => Ok(JsonRpcResponse::success(answer_id, ())), Err(e) => { warn!(target: LOG_TARGET, "Error deleting address: {}", e); - Err(Self::generic_error_response(answer_id)) + Err(Self::generic_error_response( + answer_id, + format!("Error deleting address: {}", e), + )) }, } } @@ -436,7 +448,10 @@ impl JsonRpcHandlers { Ok(_) => Ok(JsonRpcResponse::success(answer_id, ())), Err(e) => { warn!(target: LOG_TARGET, "Error clearing addresses: {}", e); - Err(Self::generic_error_response(answer_id)) + Err(Self::generic_error_response( + answer_id, + format!("Error clearing addresses: {}", e), + )) }, } } @@ -450,7 +465,10 @@ impl JsonRpcHandlers { Ok(collections) => Ok(JsonRpcResponse::success(answer_id, collections)), Err(e) => { warn!(target: LOG_TARGET, "Error getting non fungible collections: {}", e); - Err(Self::generic_error_response(answer_id)) + Err(Self::generic_error_response( + answer_id, + format!("Error getting non fungible collections: {}", e), + )) }, } } @@ -464,7 +482,7 @@ impl JsonRpcHandlers { .await .map_err(|e| { warn!(target: LOG_TARGET, "Error getting non fungible count: {}", e); - Self::generic_error_response(answer_id) + Self::generic_error_response(answer_id, format!("Error getting non fungible count: {}", e)) })?; Ok(JsonRpcResponse::success(answer_id, count)) @@ -557,7 +575,11 @@ impl JsonRpcHandlers { } // TODO: pass the error in here and log it instead of "squashing" it (switch to using Self::internal_error) - fn generic_error_response(answer_id: i64) -> JsonRpcResponse { - Self::error_response(answer_id, JsonRpcErrorReason::InternalError, "Something went wrong") + fn generic_error_response(answer_id: i64, error: String) -> JsonRpcResponse { + Self::error_response( + answer_id, + JsonRpcErrorReason::InternalError, + format!("Something went wrong: {}", error), + ) } } diff --git a/applications/tari_validator_node/log4rs_sample.yml b/applications/tari_validator_node/log4rs_sample.yml index 3736e9f84..561c2b4ee 100644 --- a/applications/tari_validator_node/log4rs_sample.yml +++ b/applications/tari_validator_node/log4rs_sample.yml @@ -120,6 +120,11 @@ loggers: - stdout additive: false + tari::dan::engine: + level: debug + appenders: + - engine + # Route log events sent to the "comms" logger to the "network" appender comms: level: debug diff --git a/dan_layer/engine/src/runtime/impl.rs b/dan_layer/engine/src/runtime/impl.rs index a0529e928..959b3f522 100644 --- a/dan_layer/engine/src/runtime/impl.rs +++ b/dan_layer/engine/src/runtime/impl.rs @@ -180,7 +180,7 @@ impl> RuntimeInte let template_address = self.tracker.get_template_address()?; let event = Event::new(component_address, template_address, tx_hash, topic, payload); - + log::log!(target: "tari::dan::engine::runtime", log::Level::Debug, "{}", event.to_string()); self.tracker.add_event(event); Ok(()) } diff --git a/dan_layer/engine/src/wasm/process.rs b/dan_layer/engine/src/wasm/process.rs index a9c3f2b57..55b28622e 100644 --- a/dan_layer/engine/src/wasm/process.rs +++ b/dan_layer/engine/src/wasm/process.rs @@ -55,7 +55,7 @@ use crate::{ }, }; -const LOG_TARGET: &str = "tari::dan::wasm::process"; +const LOG_TARGET: &str = "tari::dan::engine::wasm::process"; #[derive(Debug)] pub struct WasmProcess {