Skip to content
This repository was archived by the owner on Jun 1, 2026. It is now read-only.

Replace unwrap_or with BigNumberFormatter for Tron stake amount parsing - #923

Merged
gemcoder21 merged 2 commits into
tron-unstake-all-bugfrom
copilot/sub-pr-920
Feb 3, 2026
Merged

gemcoder21 merged 2 commits into
tron-unstake-all-bugfrom
copilot/sub-pr-920

Conversation

Copilot AI commented Feb 3, 2026 •

Copy link
Copy Markdown
Contributor

Addresses feedback to use BigNumberFormatter instead of unwrap_or(0) for parsing stake amounts in Tron preload logic, ensuring proper error propagation and consistent number formatting.

Changes:

  • Replace input.value.parse::<u64>().unwrap_or(0) / 10_u64.pow(asset.decimals as u32) with BigNumberFormatter::value_as_u64(&input.value, asset.decimals as u32)? for decimal conversion
  • Replace input.value.parse().unwrap_or(0) with BigNumberFormatter::value_as_u64(&input.value, 0)? for base unit parsing
  • Add number_formatter dependency to gem_tron crate with rpc feature

Before:

let amount = input.value.parse::<u64>().unwrap_or(0) / 10_u64.pow(asset.decimals as u32);
// ...
return Ok(TronStakeData::Unfreeze(calculate_unfreeze_amounts(
    account.frozen_v2.as_ref(), 
    input.value.parse().unwrap_or(0)
)));

After:

let amount = BigNumberFormatter::value_as_u64(&input.value, asset.decimals as u32)?;
// ...
return Ok(TronStakeData::Unfreeze(calculate_unfreeze_amounts(
    account.frozen_v2.as_ref(),
    BigNumberFormatter::value_as_u64(&input.value, 0)?
)));

💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

@semanticdiff-com

semanticdiff-com Bot commented Feb 3, 2026 •

Copy link
Copy Markdown

Review changes with  SemanticDiff

Changed Files
File Status
  crates/gem_tron/src/provider/preload.rs  71% smaller
  Cargo.lock Unsupported file format
  crates/gem_tron/Cargo.toml Unsupported file format

Copilot AI changed the title [WIP] Fix BigNumberFormatter usage in Tron unstake PR Replace unwrap_or with BigNumberFormatter for Tron stake amount parsing Feb 3, 2026
Copilot AI requested a review from gemcoder21 February 3, 2026 21:22
@gemcoder21
gemcoder21 marked this pull request as ready for review February 3, 2026 22:02
@gemcoder21
gemcoder21 merged commit 76fc7b7 into tron-unstake-all-bug Feb 3, 2026
@gemcoder21
gemcoder21 deleted the copilot/sub-pr-920 branch February 3, 2026 22:02
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants