how do i go about removing values from inside a struct and or a mapping. For example iam creating a smart contract that acts kind of like a vault, iam not yet finished but i have a create an account feature.I would like to add a delete an account feature aswell, i thought about just changing the values inside the struct but there bust be a better way. Here is some of my code:
// Global variables
uint256 uniqueId;
// Account details storage
struct AccDetails {
string accNickName;
uint256 creationTimeStamp;
}
mapping(address => AccDetails) public accDetails;
mapping(address => uint256) public balanceOf;
mapping(address => uint256) addrTouniqueIdentifier;
mapping(uint256 => address) uniqueIdentifierToAddr;
// Variables set on contract deployment
constructor() {
uniqueId = 1;
}
function createAccount(string memory _accNickName) public {
if(accDetails[msg.sender].creationTimeStamp == 0) {
accDetails[msg.sender] = AccDetails(_accNickName, block.timestamp);
addrTouniqueIdentifier[msg.sender] = uniqueId;
uniqueIdentifierToAddr[uniqueId] = msg.sender;
emit accountCreated(msg.sender,_accNickName, block.timestamp);
uniqueId = uniqueId.add(1);
}else {
revert("You already have an account created.");
}
}