-
Notifications
You must be signed in to change notification settings - Fork 112
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Refactor ContractCallNestedCallsHistoricalTest (#9164)
This pr refactors ContractCallNestedCallsHistoricalTest to use the web3j plugin and use native java type. The class test 3 method getTokenInfo, getApproved and mintNft in historical context. The historical context is for blocks pre evm 34 version. This PR modifies: TestWeb3jService - Adds a new check to execute estimate gas calls only when we are not in historical context since estimate gas does not support historical blocks. Added NestedCallHistorical.sol file. Modified the 3 tests to not return "hardcoded result" but instead take the response from the Hts call. Modified ContractCallNestedCallsHistoricalTest to use the new approach with web3j. --------- Signed-off-by: Kristiyan Selveliev <[email protected]>
- Loading branch information
1 parent
4ae8918
commit 01c881a
Showing
3 changed files
with
281 additions
and
49 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
22 changes: 22 additions & 0 deletions
22
hedera-mirror-web3/src/test/solidity_historical/NestedCallsHistorical.sol
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
pragma solidity ^0.8.0; | ||
|
||
import "./HederaTokenService.sol"; | ||
import "./HederaResponseCodes.sol"; | ||
|
||
contract NestedCallsHistorical is HederaTokenService { | ||
|
||
function nestedGetTokenInfo(address token) external returns (IHederaTokenService.TokenInfo memory) { | ||
(int responseCode, IHederaTokenService.TokenInfo memory retrievedTokenInfo) = HederaTokenService.getTokenInfo(token); | ||
return retrievedTokenInfo; | ||
} | ||
|
||
function nestedHtsGetApproved(address token, uint256 serialNumber) public returns (address) { | ||
(int _responseCode, address approved) = HederaTokenService.getApproved(token, serialNumber); | ||
return approved; | ||
} | ||
|
||
function nestedMintToken(address token, int64 amount, bytes[] memory metadata) public returns (int64) { | ||
(int responseCode, int64 newTotalSupply, int64[] memory serialNumbers) = HederaTokenService.mintToken(token, amount, metadata); | ||
return newTotalSupply; | ||
} | ||
} |