suppose i have:
struct Features {
uint256 _level;
uint256 _strength;
}
mapping(uint256 => Features) public tokenIdToFeatures;
Now i wanna set both feature from 2 different functions, like this:
function getLevels(uint256 _tokenId) public returns (string memory) {
level++;
tokenToFeatures[_tokenId] = Features({_level: level})
return level.toString();
}
function getStrength(uint256 _tokenId) public returns(string memory){
strength++;
tokenIdToFeatures[_tokenId] = Features({_strength: strength});
}
Is it right approach? if not then what is the right approach? N.B: As i creating a NFT so i will have to set this 2 features in 2 places, like this:
'<svg xmlns="http://www.w3.org/2000/svg" preserveAspectRatio="xMinYMin meet" viewBox="0 0 350 350">',
'<style>.base { fill: white; font-family: serif; font-size: 14px; }</style>',
'<rect width="100%" height="100%" fill="black" />',
'<text x="50%" y="40%" class="base" dominant-baseline="middle" text-anchor="middle">',
"Warrior",
"</text>",
'<text x="50%" y="50%" class="base" dominant-baseline="middle" text-anchor="middle">',
"Levels: ",
getLevels(_tokenId),
"</text>",
'<text x="50%" y="50%" class="base" dominant-baseline="middle" text-anchor="middle">',
"Levels: ",
getStrength(_tokenId),
"</text>",
"</svg>"
That is why i created 2 different functions.