In my function, while using my mapping to reference to an array, I keep getting the error message below:
TypeError: Type struct etherGifter.CryptoGift storage ref[] storage ref is not
implicitly convertible to expected type struct etherGifter.CryptoGift memory.
--> contracts/gifter4.sol:100:9:
|
100 | CryptoGift memory validGifts = myGifts[msg.sender];
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Can someone kindly help me resolve this?
Find below my snippets of my code:
enum Status { pendingGifting, giftGifted }
struct CryptoGift {
Status GiftStatus;
}
mapping(address => CryptoGift[]) private myGifts;
function viewMyGifts() public view returns ( CryptoGift[] memory ) {
CryptoGift memory validGifts = myGifts[msg.sender];
require( validGifts.GiftStatus != Status.giftGifted, "You have no active gifts!" );
return myGifts[msg.sender];
}