From 171db610f91260ea6d72dc8f7a9267e4afe7c2bc Mon Sep 17 00:00:00 2001 From: enitrat Date: Mon, 4 Nov 2024 13:29:52 +0700 Subject: [PATCH] fix: DualVMToken totalSupply --- solidity_contracts/src/CairoPrecompiles/DualVmToken.sol | 3 ++- tests/end_to_end/CairoPrecompiles/test_dual_vm_token.py | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/solidity_contracts/src/CairoPrecompiles/DualVmToken.sol b/solidity_contracts/src/CairoPrecompiles/DualVmToken.sol index f20e3aee9..ff4af0aeb 100644 --- a/solidity_contracts/src/CairoPrecompiles/DualVmToken.sol +++ b/solidity_contracts/src/CairoPrecompiles/DualVmToken.sol @@ -79,7 +79,8 @@ contract DualVmToken { function totalSupply() external view returns (uint256) { bytes memory returnData = starknetToken.staticcallCairo("total_supply"); - return abi.decode(returnData, (uint256)); + (uint128 valueLow, uint128 valueHigh) = abi.decode(returnData, (uint128, uint128)); + return uint256(valueLow) + (uint256(valueHigh) << 128); } /// @dev This function is used to get the balance of an evm account diff --git a/tests/end_to_end/CairoPrecompiles/test_dual_vm_token.py b/tests/end_to_end/CairoPrecompiles/test_dual_vm_token.py index 99cd1b1b4..ec56a7444 100644 --- a/tests/end_to_end/CairoPrecompiles/test_dual_vm_token.py +++ b/tests/end_to_end/CairoPrecompiles/test_dual_vm_token.py @@ -12,7 +12,7 @@ @pytest_asyncio.fixture(scope="function") async def starknet_token(owner): address = await deploy_starknet( - "StarknetToken", int(1e18), owner.starknet_contract.address + "StarknetToken", int(2**256 - 1), owner.starknet_contract.address ) return get_contract_starknet("StarknetToken", address=address)