Skip to content

Commit

Permalink
Merge pull request #220 from Bananapus/cantina/11
Browse files Browse the repository at this point in the history
cantina/11
  • Loading branch information
mejango authored Jan 9, 2025
2 parents 877c4ba + 427a5d2 commit edcbc0e
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 42 deletions.
12 changes: 6 additions & 6 deletions src/JBMultiTerminal.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
10 changes: 2 additions & 8 deletions test/units/static/JBMultiTerminal/TestAccountingContextsOf.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand All @@ -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,
Expand All @@ -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))});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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))});
Expand Down Expand Up @@ -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));

Expand Down Expand Up @@ -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));

Expand Down
7 changes: 0 additions & 7 deletions test/units/static/JBMultiTerminal/TestPay.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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));

Expand Down

0 comments on commit edcbc0e

Please sign in to comment.