diff --git a/src/JBMultiTerminal.sol b/src/JBMultiTerminal.sol index bbc5d2b8..515f6a52 100644 --- a/src/JBMultiTerminal.sol +++ b/src/JBMultiTerminal.sol @@ -406,15 +406,15 @@ contract JBMultiTerminal is JBPermissioned, ERC2771Context, IJBMultiTerminal { knownInvalidDecimals = true; } else if (accountingContext.token != JBConstants.NATIVE_TOKEN) { // slither-disable-next-line calls-loop - try IERC165(accountingContext.token).supportsInterface(type(IERC20Metadata).interfaceId) returns ( - bool doesSupport - ) { + try IERC20Metadata(accountingContext.token).decimals() returns (uint8 decimals) { // slither-disable-next-line calls-loop - if (doesSupport && accountingContext.decimals != IERC20Metadata(accountingContext.token).decimals()) - { + if (accountingContext.decimals != decimals) { knownInvalidDecimals = true; } - } catch {} + } catch { + // The token didn't support `decimals`. + knownInvalidDecimals = false; + } } // Make sure the decimals are correct. diff --git a/test/units/static/JBMultiTerminal/TestAccountingContextsOf.sol b/test/units/static/JBMultiTerminal/TestAccountingContextsOf.sol index c3a9af75..bb754b74 100644 --- a/test/units/static/JBMultiTerminal/TestAccountingContextsOf.sol +++ b/test/units/static/JBMultiTerminal/TestAccountingContextsOf.sol @@ -4,7 +4,7 @@ pragma solidity 0.8.23; import /* {*} from */ "../../../helpers/TestBaseWorkflow.sol"; import {JBMultiTerminalSetup} from "./JBMultiTerminalSetup.sol"; -contract TestAccountingContextsFor_Local is JBMultiTerminalSetup { +contract TestAccountingContextsOf_Local is JBMultiTerminalSetup { uint256 _projectId = 1; address _usdc = makeAddr("USDC"); uint256 _usdcCurrency = uint32(uint160(_usdc)); @@ -29,8 +29,6 @@ contract TestAccountingContextsFor_Local is JBMultiTerminalSetup { // mock call to tokens decimals() mockExpect(_usdc, abi.encodeCall(IERC20Metadata.decimals, ()), abi.encode(6)); - // mock call to rulesets currentOf returning 0 to bypass ruleset checking - // setup: return data JBRuleset memory ruleset = JBRuleset({ cycleNumber: 1, @@ -44,13 +42,9 @@ contract TestAccountingContextsFor_Local is JBMultiTerminalSetup { metadata: 0 }); + // mock call to rulesets currentOf returning 0 to bypass ruleset checking mockExpect(address(rulesets), abi.encodeCall(IJBRulesets.currentOf, (_projectId)), abi.encode(ruleset)); - // mock supports interface call - mockExpect( - _usdc, abi.encodeCall(IERC165.supportsInterface, (type(IERC20Metadata).interfaceId)), abi.encode(true) - ); - // call params JBAccountingContext[] memory _tokens = new JBAccountingContext[](1); _tokens[0] = JBAccountingContext({token: _usdc, decimals: 6, currency: uint32(uint160(_usdc))}); diff --git a/test/units/static/JBMultiTerminal/TestAddAccountingContextsFor.sol b/test/units/static/JBMultiTerminal/TestAddAccountingContextsFor.sol index 9cf0a908..da960c7c 100644 --- a/test/units/static/JBMultiTerminal/TestAddAccountingContextsFor.sol +++ b/test/units/static/JBMultiTerminal/TestAddAccountingContextsFor.sol @@ -79,8 +79,6 @@ contract TestAddAccountingContextsFor_Local is JBMultiTerminalSetup { // mock call to tokens decimals() mockExpect(_usdc, abi.encodeCall(IERC20Metadata.decimals, ()), abi.encode(6)); - // mock call to rulesets currentOf returning 0 to bypass ruleset checking - // setup: return data JBRuleset memory ruleset = JBRuleset({ cycleNumber: 1, @@ -94,13 +92,9 @@ contract TestAddAccountingContextsFor_Local is JBMultiTerminalSetup { metadata: 0 }); + // mock call to rulesets currentOf returning 0 to bypass ruleset checking mockExpect(address(rulesets), abi.encodeCall(IJBRulesets.currentOf, (_projectId)), abi.encode(ruleset)); - // mock supports interface call - mockExpect( - _usdc, abi.encodeCall(IERC165.supportsInterface, (type(IERC20Metadata).interfaceId)), abi.encode(true) - ); - // call params JBAccountingContext[] memory _tokens = new JBAccountingContext[](1); _tokens[0] = JBAccountingContext({token: _usdc, decimals: 6, currency: uint32(uint160(_usdc))}); @@ -284,13 +278,6 @@ contract TestAddAccountingContextsFor_Local is JBMultiTerminalSetup { // mock rulesets call mockExpect(address(rulesets), abi.encodeCall(IJBRulesets.currentOf, (_projectId)), abi.encode(ruleset)); - // mock token interface support call - mockExpect( - address(someToken), - abi.encodeCall(IERC165.supportsInterface, (type(IERC20Metadata).interfaceId)), - abi.encode(true) - ); - // mock token call mockExpect(address(someToken), abi.encodeCall(IERC20Metadata.decimals, ()), abi.encode(18)); @@ -323,13 +310,6 @@ contract TestAddAccountingContextsFor_Local is JBMultiTerminalSetup { // mock rulesets call mockExpect(address(rulesets), abi.encodeCall(IJBRulesets.currentOf, (_projectId)), abi.encode(ruleset)); - // mock token interface support call - mockExpect( - address(someToken), - abi.encodeCall(IERC165.supportsInterface, (type(IERC20Metadata).interfaceId)), - abi.encode(true) - ); - // mock token call mockExpect(address(someToken), abi.encodeCall(IERC20Metadata.decimals, ()), abi.encode(18)); diff --git a/test/units/static/JBMultiTerminal/TestPay.sol b/test/units/static/JBMultiTerminal/TestPay.sol index aaaa1a78..77c246c1 100644 --- a/test/units/static/JBMultiTerminal/TestPay.sol +++ b/test/units/static/JBMultiTerminal/TestPay.sol @@ -72,13 +72,6 @@ contract TestPay_Local is JBMultiTerminalSetup { address(directory), abi.encodeCall(IJBDirectory.controllerOf, (_projectId)), abi.encode(address(this)) ); - // mock supports interface call - mockExpect( - address(_mockToken), - abi.encodeCall(IERC165.supportsInterface, (type(IERC20Metadata).interfaceId)), - abi.encode(true) - ); - // mock call to token decimals mockExpect(address(_mockToken), abi.encodeCall(IERC20Metadata.decimals, ()), abi.encode(6));