From aa29fb0b7904879b6a82a189570434501bd5ef66 Mon Sep 17 00:00:00 2001 From: Filipp Makarov Date: Fri, 22 Nov 2024 16:00:58 +0300 Subject: [PATCH] add view methods --- contracts/token/BiconomyTokenPaymaster.sol | 18 ++++++++++++++++++ .../concrete/TestTokenPaymaster.Base.t.sol | 2 +- 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/contracts/token/BiconomyTokenPaymaster.sol b/contracts/token/BiconomyTokenPaymaster.sol index dbb85af..7b6d479 100644 --- a/contracts/token/BiconomyTokenPaymaster.sol +++ b/contracts/token/BiconomyTokenPaymaster.sol @@ -440,6 +440,24 @@ contract BiconomyTokenPaymaster is ); } + /** + * @dev Get the price of a token in USD + * @param tokenAddress The address of the token to get the price of + * @return price The price of the token in USD + */ + function getPrice(address tokenAddress) public view returns (uint256) { + return _getPrice(tokenAddress); + } + + /** + * @dev Check if a token is supported + * @param tokenAddress The address of the token to check + * @return bool True if the token is supported, false otherwise + */ + function isTokenSupported(address tokenAddress) public view returns (bool) { + return independentTokenDirectory[tokenAddress].oracle != IOracle(address(0)); + } + /** * @dev Validate a user operation. * This method is abstract in BasePaymaster and must be implemented in derived contracts. diff --git a/test/unit/concrete/TestTokenPaymaster.Base.t.sol b/test/unit/concrete/TestTokenPaymaster.Base.t.sol index 072ca9c..c4ba592 100644 --- a/test/unit/concrete/TestTokenPaymaster.Base.t.sol +++ b/test/unit/concrete/TestTokenPaymaster.Base.t.sol @@ -152,7 +152,7 @@ contract TestTokenPaymasterBase is TestBase { // usdc.approve(address(SWAP_ROUTER_ADDRESS), usdc.balanceOf(address(tokenPaymaster))); // vm.stopPrank(); - // Todo: Review reason for failure + // Review reason for failure startPrank(PAYMASTER_OWNER.addr); tokenPaymaster.swapTokenAndDeposit(address(usdc), 1e6, 0); stopPrank();