crytic / crytic/slither

[Bug]: Slither does not recognize Contract Structs when referenced in other contracts

Open
#1,985 2 comments 0 reactions 0 assignees View on GitHub
bug
Dominant language
Python
Stars
6.4k
Forks
1.1k
PR merge metrics
No merged PRs in 30d

Description

### Describe the issue:

Slither seems to not be able to recognize type Structs when they are referenced outside of the Contract in which they are declared. For example, if contract A has a struct called foo, contract B that imports contract A, uses A.foo in it's logic. A.foo is considered an unknown type. In order to work around this, our check had to remove all files that used external structs that are referred to with the naming pattern "ContractName"."StructName"

### Code example to reproduce the issue:

```
pragma solidity 0.8.14;

import 'forge-std/Test.sol';
import './utils/Deploy.sol';
import '../../contracts/WatchChallengeArena.sol';
import '../../contracts/FedexCupToken.sol';

contract Test_WatchChallengeArena is TourStandardNftsFixture {
TourStandardERC721 tourStandardNFTTransferable1;
TourStandardERC721 tourStandardNFTTransferable2;
TourStandardERC721 tourStandardNFTTransferable3;
TourStandardERC721 tourStandardNFTTransferable4;
WatchChallengeArena watchChallengeArena;
WatchChallengeArena.WatchChallenge challenge1;
WatchChallengeArena.WatchChallenge challenge2;
}

contract WatchChallengeArena is AccessControlEnumerable {
uint32 public numChallenges;
bytes32 public constant ADMIN_ROLE = keccak256('ADMIN_ROLE');
mapping(uint32 => WatchChallenge) watchChallenges;
mapping(address => mapping(uint32 => UserDeposit)) userDepositByChallengeIds;
mapping(address => UserDeposit) totalDepositsByUser;
SemiTransferableERC20 private rewardToken;

// Pull over Push Rewards
mapping(address => uint256) rewardsBalance;

struct UserDeposit {
address[] lockedContracts;
uint256[] lockedTokenIds;
}

struct WatchChallenge {
ChallengeType challengeType;
uint256 rewardAmountPerWin;
uint256 lumpSumRewardAmount;
uint256 bonusPercentagePerRarityStar;
uint256 initialPercentageBonus;
uint256 numNftsRequired;
uint256 depositDeadline;
bool isSettled;
address[] participants;
}
}

```

### Version:

0.9.3

### Relevant log output:

```shell
`Error:
Type not found struct WatchChallengeArena.WatchChallenge`
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.