Skip to content
This repository has been archived by the owner on Dec 7, 2023. It is now read-only.

Show gas before send #823

Merged
merged 1 commit into from
Sep 16, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 9 additions & 12 deletions neo-cli/CLI/MainService.Wallet.cs
Original file line number Diff line number Diff line change
Expand Up @@ -510,7 +510,7 @@ private void OnSendCommand(UInt160 asset, UInt160 to, string amount, UInt160 fro
}
var snapshot = NeoSystem.StoreView;
Transaction tx;
AssetDescriptor descriptor = new AssetDescriptor(snapshot, NeoSystem.Settings, asset);
AssetDescriptor descriptor = new(snapshot, NeoSystem.Settings, asset);
if (!BigDecimal.TryParse(amount, descriptor.Decimals, out BigDecimal decimalAmount) || decimalAmount.Sign <= 0)
{
ConsoleHelper.Error("Incorrect Amount Format");
Expand All @@ -533,7 +533,7 @@ private void OnSendCommand(UInt160 asset, UInt160 to, string amount, UInt160 fro
Scopes = WitnessScope.CalledByEntry,
Account = p
})
.ToArray() ?? new Signer[0]);
.ToArray() ?? Array.Empty<Signer>());
}
catch (Exception e)
{
Expand All @@ -547,18 +547,15 @@ private void OnSendCommand(UInt160 asset, UInt160 to, string amount, UInt160 fro
return;
}

ContractParametersContext context = new ContractParametersContext(snapshot, tx, neoSystem.Settings.Network);
CurrentWallet.Sign(context);
if (context.Completed)
{
tx.Witnesses = context.GetWitnesses();
NeoSystem.Blockchain.Tell(tx);
ConsoleHelper.Info("TXID:\n", $"{tx.Hash}");
}
else
ConsoleHelper.Info("Network fee: ",
$"{new BigDecimal((BigInteger)tx.NetworkFee, NativeContract.GAS.Decimals)}\t",
"Total fee: ",
$"{new BigDecimal((BigInteger)(tx.SystemFee + tx.NetworkFee), NativeContract.GAS.Decimals)} GAS");
if (!ReadUserInput("Relay tx? (no|yes)").IsYes())
{
ConsoleHelper.Info("SignatureContext:\n", $"{context}");
return;
}
SignAndSendTx(NeoSystem.StoreView, tx);
}

/// <summary>
Expand Down