From e96ff0f0878265b05ced74eb10d92902d4c5eb37 Mon Sep 17 00:00:00 2001 From: Phuong Nguyen Date: Tue, 19 Jul 2022 18:32:13 -0700 Subject: [PATCH] Expose tokens_burnt (#168) --- workspaces/src/network/testnet.rs | 1 + workspaces/src/result.rs | 7 ++++++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/workspaces/src/network/testnet.rs b/workspaces/src/network/testnet.rs index 339fc88b..b6114726 100644 --- a/workspaces/src/network/testnet.rs +++ b/workspaces/src/network/testnet.rs @@ -97,6 +97,7 @@ impl TopLevelAccountCreator for Testnet { logs: Vec::new(), receipt_ids: Vec::new(), gas_burnt: 0, + tokens_burnt: 0, executor_id: "testnet".parse()?, status: ExecutionStatusView::SuccessValue(String::new()), }, diff --git a/workspaces/src/result.rs b/workspaces/src/result.rs index 8fbbca23..04cd2922 100644 --- a/workspaces/src/result.rs +++ b/workspaces/src/result.rs @@ -6,7 +6,7 @@ use near_primitives::views::{ FinalExecutionStatus, }; -use crate::types::{CryptoHash, Gas}; +use crate::types::{Balance, CryptoHash, Gas}; /// Struct to hold a type we want to return along w/ the execution result view. /// This view has extra info about the execution, such as gas usage and whether @@ -240,6 +240,10 @@ pub struct ExecutionOutcome { pub receipt_ids: Vec, /// The amount of the gas burnt by the given transaction or receipt. pub gas_burnt: Gas, + /// The amount of tokens burnt corresponding to the burnt gas amount. + /// This value doesn't always equal to the `gas_burnt` multiplied by the gas price, because + /// the prepaid gas price might be lower than the actual gas price and it creates a deficit. + pub tokens_burnt: Balance, /// The id of the account on which the execution happens. For transaction this is signer_id, /// for receipt this is receiver_id. pub executor_id: AccountId, @@ -303,6 +307,7 @@ impl From for ExecutionOutcome { .map(|c| CryptoHash(c.0)) .collect(), gas_burnt: view.outcome.gas_burnt, + tokens_burnt: view.outcome.tokens_burnt, executor_id: view.outcome.executor_id, status: view.outcome.status, }