Skip to content

Commit

Permalink
fix(ethexe): fix WVara decimals; retrieve 10 WVara default exec balan…
Browse files Browse the repository at this point in the history
…ce on creation (#4329)
  • Loading branch information
breathx authored Nov 11, 2024
1 parent 93a5a60 commit 0790732
Show file tree
Hide file tree
Showing 7 changed files with 23 additions and 4 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ jobs:
- name: "Install: Node.js"
uses: actions/setup-node@v4
with:
node-version: 20.x
node-version: 22.x

- name: "Show: Versioning"
run: |
Expand Down
3 changes: 3 additions & 0 deletions ethexe/cli/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -359,6 +359,9 @@ async fn incoming_transfers() {
let ping_id = res.program_id;

let wvara = env.ethereum.router().wvara();

assert_eq!(wvara.query().decimals().await.unwrap(), 12);

let ping = env.ethereum.mirror(ping_id.to_address_lossy().into());

let on_eth_balance = wvara
Expand Down
5 changes: 4 additions & 1 deletion ethexe/contracts/src/Router.sol
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import {IRouter} from "./IRouter.sol";
import {IMirror} from "./IMirror.sol";
import {IWrappedVara} from "./IWrappedVara.sol";
import {IERC20} from "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import {IERC20Metadata} from "@openzeppelin/contracts/token/ERC20/extensions/IERC20Metadata.sol";

contract Router is IRouter, OwnableUpgradeable, ReentrancyGuardTransient {
using ECDSA for bytes32;
Expand Down Expand Up @@ -297,7 +298,9 @@ contract Router is IRouter, OwnableUpgradeable, ReentrancyGuardTransient {
require(router.codes[codeId] == CodeState.Validated, "code must be validated before program creation");

uint128 baseFeeValue = baseFee();
uint128 executableBalance = baseFeeValue * 10;

// By default get 10 WVara for executable balance.
uint128 executableBalance = uint128(10 ** IERC20Metadata(router.wrappedVara).decimals());

uint128 totalValue = baseFeeValue + executableBalance + _value;

Expand Down
4 changes: 4 additions & 0 deletions ethexe/contracts/src/WrappedVara.sol
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,10 @@ contract WrappedVara is

function reinitialize() public onlyOwner reinitializer(2) {}

function decimals() public pure override returns (uint8) {
return 12;
}

function mint(address to, uint256 amount) public onlyOwner {
_mint(to, amount);
}
Expand Down
2 changes: 1 addition & 1 deletion ethexe/ethereum/Router.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion ethexe/ethereum/WrappedVara.json

Large diffs are not rendered by default.

9 changes: 9 additions & 0 deletions ethexe/ethereum/src/wvara/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,15 @@ impl WVaraQuery {
)))
}

pub async fn decimals(&self) -> Result<u8> {
self.0
.decimals()
.call()
.await
.map(|res| res._0)
.map_err(Into::into)
}

pub async fn total_supply(&self) -> Result<u128> {
self.0
.totalSupply()
Expand Down

0 comments on commit 0790732

Please sign in to comment.