refactor: use immutable properties where possible (#5)
This commit changes a few token properties to be `immutable` as this reduces gas costs even further. This was reported by Slither. A gas report with changes in gas cost is attached.
This commit is contained in:
parent
8f633ee442
commit
e7d799b761
|
@ -2,11 +2,11 @@ AddEntryTest:test_AddEntry() (gas: 44392)
|
|||
AddEntryTest:test_RevertWhen_EntryAlreadyExists() (gas: 42644)
|
||||
AddEntryTest:test_RevertWhen_InvalidAddress() (gas: 25133)
|
||||
AddEntryTest:test_RevertWhen_SenderIsNotTokenDeployer() (gas: 14827)
|
||||
CollectibleV1Test:test_Deployment() (gas: 38626)
|
||||
CommunityERC20Test:test_Deployment() (gas: 29720)
|
||||
CollectibleV1Test:test_Deployment() (gas: 36386)
|
||||
CommunityERC20Test:test_Deployment() (gas: 27614)
|
||||
CommunityTokenDeployerTest:test_Deployment() (gas: 14805)
|
||||
CreateTest:test_Create() (gas: 2216454)
|
||||
CreateTest:test_Create() (gas: 2489668)
|
||||
CreateTest:test_Create() (gas: 2251262)
|
||||
CreateTest:test_Create() (gas: 2548166)
|
||||
CreateTest:test_RevertWhen_InvalidOwnerTokenAddress() (gas: 15523)
|
||||
CreateTest:test_RevertWhen_InvalidReceiverAddress() (gas: 15656)
|
||||
CreateTest:test_RevertWhen_InvalidSignerPublicKey() (gas: 17057)
|
||||
|
@ -16,33 +16,33 @@ CreateTest:test_RevertWhen_SenderIsNotTokenDeployer() (gas: 16421)
|
|||
CreateTest:test_RevertWhen_SenderIsNotTokenDeployer() (gas: 16524)
|
||||
DeployContracts:test() (gas: 120)
|
||||
DeployOwnerAndMasterToken:test() (gas: 120)
|
||||
DeployTest:test_Deploy() (gas: 4778776)
|
||||
DeployTest:test_Deploy() (gas: 4872082)
|
||||
DeployTest:test_Deployment() (gas: 14947)
|
||||
DeployTest:test_RevertWhen_AlreadyDeployed() (gas: 4774645)
|
||||
DeployTest:test_RevertWhen_AlreadyDeployed() (gas: 4868312)
|
||||
DeployTest:test_RevertWhen_InvalidCommunityAddress() (gas: 51385)
|
||||
DeployTest:test_RevertWhen_InvalidDeployerAddress() (gas: 55272)
|
||||
DeployTest:test_RevertWhen_InvalidDeploymentSignature() (gas: 65617)
|
||||
DeployTest:test_RevertWhen_InvalidSignerPublicKey() (gas: 53433)
|
||||
DeployTest:test_RevertWhen_InvalidTokenMetadata() (gas: 2613184)
|
||||
DeployTest:test_RevertWhen_InvalidTokenMetadata() (gas: 2671682)
|
||||
DeploymentTest:test_Deployment() (gas: 14671)
|
||||
DeploymentTest:test_Deployment() (gas: 14671)
|
||||
DeploymentTest:test_Deployment() (gas: 17295)
|
||||
GetEntryTest:test_ReturnZeroAddressIfEntryDoesNotExist() (gas: 11906)
|
||||
MintToTest:test_Deployment() (gas: 29742)
|
||||
MintToTest:test_Deployment() (gas: 38626)
|
||||
MintToTest:test_Deployment() (gas: 85460)
|
||||
MintToTest:test_MintTo() (gas: 509094)
|
||||
MintToTest:test_Deployment() (gas: 27636)
|
||||
MintToTest:test_Deployment() (gas: 36386)
|
||||
MintToTest:test_Deployment() (gas: 83220)
|
||||
MintToTest:test_MintTo() (gas: 506888)
|
||||
MintToTest:test_RevertWhen_AddressesAndAmountsAreNotEqualLength() (gas: 23778)
|
||||
MintToTest:test_RevertWhen_MaxSupplyIsReached() (gas: 22859)
|
||||
MintToTest:test_RevertWhen_MaxSupplyIsReached() (gas: 505067)
|
||||
MintToTest:test_RevertWhen_MaxSupplyIsReached() (gas: 20653)
|
||||
MintToTest:test_RevertWhen_MaxSupplyIsReached() (gas: 502655)
|
||||
MintToTest:test_RevertWhen_MaxSupplyReached() (gas: 122988)
|
||||
MintToTest:test_RevertWhen_SenderIsNotOwner() (gas: 35956)
|
||||
OwnerTokenTest:test_Deployment() (gas: 85460)
|
||||
RemoteBurnTest:test_Deployment() (gas: 38626)
|
||||
RemoteBurnTest:test_Deployment() (gas: 85482)
|
||||
RemoteBurnTest:test_RemoteBurn() (gas: 455309)
|
||||
RemoteBurnTest:test_RevertWhen_RemoteBurn() (gas: 19091)
|
||||
RemoteBurnTest:test_RevertWhen_SenderIsNotOwner() (gas: 24791)
|
||||
MintToTest:test_RevertWhen_SenderIsNotOwner() (gas: 31544)
|
||||
OwnerTokenTest:test_Deployment() (gas: 83220)
|
||||
RemoteBurnTest:test_Deployment() (gas: 36386)
|
||||
RemoteBurnTest:test_Deployment() (gas: 83242)
|
||||
RemoteBurnTest:test_RemoteBurn() (gas: 450780)
|
||||
RemoteBurnTest:test_RevertWhen_RemoteBurn() (gas: 14768)
|
||||
RemoteBurnTest:test_RevertWhen_SenderIsNotOwner() (gas: 20379)
|
||||
SetCommunityTokenDeployerAddressTest:test_RevertWhen_InvalidTokenDeployerAddress() (gas: 12941)
|
||||
SetCommunityTokenDeployerAddressTest:test_RevertWhen_SenderIsNotOwner() (gas: 12482)
|
||||
SetCommunityTokenDeployerAddressTest:test_SetCommunityTokenDeployerAddress() (gas: 22808)
|
||||
|
@ -54,20 +54,20 @@ SetMasterTokenFactoryAddressTest:test_Deployment() (gas: 14805)
|
|||
SetMasterTokenFactoryAddressTest:test_RevertWhen_InvalidTokenFactoryAddress() (gas: 12992)
|
||||
SetMasterTokenFactoryAddressTest:test_RevertWhen_SenderIsNotOwner() (gas: 12465)
|
||||
SetMasterTokenFactoryAddressTest:test_SetOwnerTokenFactoryAddress() (gas: 22861)
|
||||
SetMaxSupplyTest:test_Deployment() (gas: 29720)
|
||||
SetMaxSupplyTest:test_Deployment() (gas: 85482)
|
||||
SetMaxSupplyTest:test_RevertWhen_CalledBecauseMaxSupplyIsLocked() (gas: 16533)
|
||||
SetMaxSupplyTest:test_Deployment() (gas: 27614)
|
||||
SetMaxSupplyTest:test_Deployment() (gas: 83242)
|
||||
SetMaxSupplyTest:test_RevertWhen_CalledBecauseMaxSupplyIsLocked() (gas: 14327)
|
||||
SetMaxSupplyTest:test_RevertWhen_MaxSupplyLowerThanTotalSupply() (gas: 148572)
|
||||
SetMaxSupplyTest:test_RevertWhen_SenderIsNotOwner() (gas: 12527)
|
||||
SetMaxSupplyTest:test_RevertWhen_SenderIsNotOwner() (gas: 12817)
|
||||
SetMaxSupplyTest:test_RevertWhen_SenderIsNotOwner() (gas: 16939)
|
||||
SetMaxSupplyTest:test_SetMaxSupply() (gas: 15597)
|
||||
SetOwnerTokenFactoryAddressTest:test_Deployment() (gas: 14805)
|
||||
SetOwnerTokenFactoryAddressTest:test_RevertWhen_InvalidTokenFactoryAddress() (gas: 12970)
|
||||
SetOwnerTokenFactoryAddressTest:test_RevertWhen_SenderIsNotOwner() (gas: 12443)
|
||||
SetOwnerTokenFactoryAddressTest:test_SetOwnerTokenFactoryAddress() (gas: 22840)
|
||||
SetSignerPublicKeyTest:test_Deployment() (gas: 85460)
|
||||
SetSignerPublicKeyTest:test_RevertWhen_SenderIsNotOwner() (gas: 17634)
|
||||
SetSignerPublicKeyTest:test_SetSignerPublicKey() (gas: 26369)
|
||||
SetSignerPublicKeyTest:test_Deployment() (gas: 83220)
|
||||
SetSignerPublicKeyTest:test_RevertWhen_SenderIsNotOwner() (gas: 13222)
|
||||
SetSignerPublicKeyTest:test_SetSignerPublicKey() (gas: 24163)
|
||||
SetTokenDeployerAddressTest:test_RevertWhen_InvalidTokenDeployerAddress() (gas: 12964)
|
||||
SetTokenDeployerAddressTest:test_RevertWhen_InvalidTokenDeployerAddress() (gas: 12964)
|
||||
SetTokenDeployerAddressTest:test_RevertWhen_SenderIsNotOwner() (gas: 12438)
|
||||
|
|
|
@ -27,18 +27,18 @@ abstract contract BaseToken is Context, ERC721Enumerable {
|
|||
*/
|
||||
uint256 public maxSupply;
|
||||
|
||||
address public ownerToken;
|
||||
address public masterToken;
|
||||
address public immutable ownerToken;
|
||||
address public immutable masterToken;
|
||||
|
||||
/**
|
||||
* If set to true, the contract owner can burn any token.
|
||||
*/
|
||||
bool public remoteBurnable;
|
||||
bool public immutable remoteBurnable;
|
||||
|
||||
/**
|
||||
* If set to false it acts as a soulbound token.
|
||||
*/
|
||||
bool public transferable;
|
||||
bool public immutable transferable;
|
||||
|
||||
string public baseTokenURI;
|
||||
|
||||
|
|
|
@ -15,7 +15,7 @@ contract CommunityERC20 is Context, Ownable, ERC20 {
|
|||
*/
|
||||
uint256 public maxSupply;
|
||||
|
||||
uint8 private customDecimals;
|
||||
uint8 private immutable customDecimals;
|
||||
|
||||
constructor(
|
||||
string memory _name,
|
||||
|
|
Loading…
Reference in New Issue