zellic-audit
Initial commit
f998fcd
raw
history blame
3.29 kB
{
"language": "Solidity",
"sources": {
"contracts/lib_utilities/options/OptionSpecies.sol": {
"content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.12;\n\nimport \"../../lib_constants/TraitDefs.sol\";\nimport \"../../lib_constants/trait_options/TraitOptionsSpecies.sol\";\nimport \"../Gene.sol\";\n\nlibrary OptionSpecies {\n function getOption(uint256 dna) public pure returns (uint8) {\n uint16 species = Gene.getGene(TraitDefs.SPECIES, dna);\n // this gene is hard-coded at \"mint\" or at \"merge\"\n // 1 is black\n // 2 is polar\n // 3 is panda\n // 4 is reverse panda\n // 5 is gold panda\n\n if (species == 1) {\n return TraitOptionsSpecies.BLACK;\n } else if (species == 2) {\n return TraitOptionsSpecies.POLAR;\n } else if (species == 3) {\n return TraitOptionsSpecies.PANDA;\n } else if (species == 4) {\n return TraitOptionsSpecies.REVERSE_PANDA;\n } else if (species == 5) {\n return TraitOptionsSpecies.GOLD_PANDA;\n }\n return TraitOptionsSpecies.BLACK;\n }\n}\n"
},
"contracts/lib_constants/TraitDefs.sol": {
"content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.9;\n\nlibrary TraitDefs {\n uint8 constant SPECIES = 0;\n uint8 constant LOCALE = 1;\n uint8 constant BELLY = 2;\n uint8 constant ARMS = 3;\n uint8 constant EYES = 4;\n uint8 constant MOUTH = 5;\n uint8 constant NOSE = 6;\n uint8 constant CLOTHING = 7;\n uint8 constant HAT = 8;\n uint8 constant JEWELRY = 9;\n uint8 constant FOOTWEAR = 10;\n uint8 constant ACCESSORIES = 11;\n uint8 constant FACE_ACCESSORY = 12;\n uint8 constant BACKGROUND = 13;\n}\n"
},
"contracts/lib_constants/trait_options/TraitOptionsSpecies.sol": {
"content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.9;\n\nlibrary TraitOptionsSpecies {\n uint8 constant BLACK = 1;\n uint8 constant POLAR = 2;\n uint8 constant PANDA = 3;\n uint8 constant REVERSE_PANDA = 4;\n uint8 constant GOLD_PANDA = 5;\n}\n"
},
"contracts/lib_utilities/Gene.sol": {
"content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.12;\n\nimport \"../lib_constants/TraitDefs.sol\";\n\nlibrary Gene {\n function getGene(uint8 traitDef, uint256 dna) internal pure returns (uint16) {\n // type(uint16).max\n // right shift traitDef * 16, then bitwise & with the max 16 bit number\n return uint16((dna >> (traitDef * 16)) & uint256(type(uint16).max));\n }\n\n function getSpeciesGene(uint256 dna) internal pure returns (uint16) {\n return getGene(TraitDefs.SPECIES, dna);\n }\n\n // returns what dna would look like with gene passed in\n function setSpecies(uint16 gene, uint256 dna)\n internal\n pure\n returns (uint256)\n {\n uint256 snippedDNA = (dna >> 16) << 16; //zero out the gene\n\n // then bitwise & with uint256(gene);\n return snippedDNA | uint256(gene);\n }\n}\n"
}
},
"settings": {
"optimizer": {
"enabled": false,
"runs": 200
},
"outputSelection": {
"*": {
"*": [
"evm.bytecode",
"evm.deployedBytecode",
"devdoc",
"userdoc",
"metadata",
"abi"
]
}
},
"libraries": {}
}
}