Skip to content

Commit

Permalink
feat: add token specific deploy events in deployer contract (#14)
Browse files Browse the repository at this point in the history
While the underlying factories emit a `CreateToken` event, there was a
request to have specific deployment events for each token emitted by the
deployer.
  • Loading branch information
0x-r4bbit committed Sep 22, 2023
1 parent 5772805 commit 16121a4
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 15 deletions.
29 changes: 14 additions & 15 deletions .gas-snapshot
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,14 @@ CreateTest:test_RevertWhen_SenderIsNotTokenDeployer() (gas: 16421)
CreateTest:test_RevertWhen_SenderIsNotTokenDeployer() (gas: 16524)
DeployContracts:test() (gas: 120)
DeployOwnerAndMasterToken:test() (gas: 120)
DeployTest:test_Deploy() (gas: 4776466)
DeployTest:test_Deployment() (gas: 14925)
DeployTest:test_RevertWhen_AlreadyDeployed() (gas: 4772349)
DeployTest:test_RevertWhen_DeploymentSignatureExpired() (gas: 53642)
DeployTest:test_RevertWhen_InvalidCommunityAddress() (gas: 51341)
DeployTest:test_RevertWhen_InvalidDeployerAddress() (gas: 55329)
DeployTest:test_RevertWhen_InvalidDeploymentSignature() (gas: 65663)
DeployTest:test_RevertWhen_InvalidSignerPublicKey() (gas: 53435)
DeployTest:test_RevertWhen_InvalidTokenMetadata() (gas: 2612126)
DeployTest:test_Deploy() (gas: 4778686)
DeployTest:test_Deployment() (gas: 14947)
DeployTest:test_RevertWhen_AlreadyDeployed() (gas: 4774488)
DeployTest:test_RevertWhen_InvalidCommunityAddress() (gas: 51318)
DeployTest:test_RevertWhen_InvalidDeployerAddress() (gas: 55205)
DeployTest:test_RevertWhen_InvalidDeploymentSignature() (gas: 65550)
DeployTest:test_RevertWhen_InvalidSignerPublicKey() (gas: 53366)
DeployTest:test_RevertWhen_InvalidTokenMetadata() (gas: 2612983)
DeploymentTest:test_Deployment() (gas: 14671)
DeploymentTest:test_Deployment() (gas: 14671)
DeploymentTest:test_Deployment() (gas: 17250)
Expand Down Expand Up @@ -52,9 +51,9 @@ SetDeploymentRegistryAddressTest:test_RevertWhen_InvalidDeploymentRegistryAddres
SetDeploymentRegistryAddressTest:test_RevertWhen_SenderIsNotOwner() (gas: 12508)
SetDeploymentRegistryAddressTest:test_SetDeploymentRegistryAddress() (gas: 22903)
SetMasterTokenFactoryAddressTest:test_Deployment() (gas: 14805)
SetMasterTokenFactoryAddressTest:test_RevertWhen_InvalidTokenFactoryAddress() (gas: 13014)
SetMasterTokenFactoryAddressTest:test_RevertWhen_SenderIsNotOwner() (gas: 12487)
SetMasterTokenFactoryAddressTest:test_SetOwnerTokenFactoryAddress() (gas: 22861)
SetMasterTokenFactoryAddressTest:test_RevertWhen_InvalidTokenFactoryAddress() (gas: 12992)
SetMasterTokenFactoryAddressTest:test_RevertWhen_SenderIsNotOwner() (gas: 12465)
SetMasterTokenFactoryAddressTest:test_SetOwnerTokenFactoryAddress() (gas: 22839)
SetMaxSupplyTest:test_Deployment() (gas: 29720)
SetMaxSupplyTest:test_Deployment() (gas: 85482)
SetMaxSupplyTest:test_RevertWhen_CalledBecauseMaxSupplyIsLocked() (gas: 16533)
Expand All @@ -63,9 +62,9 @@ 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: 12992)
SetOwnerTokenFactoryAddressTest:test_RevertWhen_SenderIsNotOwner() (gas: 12465)
SetOwnerTokenFactoryAddressTest:test_SetOwnerTokenFactoryAddress() (gas: 22862)
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)
Expand Down
8 changes: 8 additions & 0 deletions contracts/CommunityTokenDeployer.sol
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@ contract CommunityTokenDeployer is EIP712("CommunityTokenDeployer", "1"), Ownabl
event OwnerTokenFactoryAddressChange(address indexed);
event MasterTokenFactoryAddressChange(address indexed);
event DeploymentRegistryAddressChange(address indexed);
event DeployOwnerToken(address indexed);
event DeployMasterToken(address indexed);

/// @dev Needed to avoid "Stack too deep" error.
struct TokenConfig {
Expand Down Expand Up @@ -107,6 +109,8 @@ contract CommunityTokenDeployer is EIP712("CommunityTokenDeployer", "1"), Ownabl
* @dev Anyone can call this function but a valid EIP712 hash signature has to be
* provided for a successful deployment.
* @dev Emits {CreateToken} events via underlying token factories.
* @dev Emits {DeployOwnerToken} event.
* @dev Emits {DeployMasterToken} event.
*
* @param _ownerToken A `TokenConfig` containing ERC721 metadata for `OwnerToken`
* @param _masterToken A `TokenConfig` containing ERC721 metadata for `MasterToken`
Expand Down Expand Up @@ -144,10 +148,14 @@ contract CommunityTokenDeployer is EIP712("CommunityTokenDeployer", "1"), Ownabl
_ownerToken.name, _ownerToken.symbol, _ownerToken.baseURI, msg.sender, _signerPublicKey
);

emit DeployOwnerToken(ownerToken);

address masterToken = ITokenFactory(masterTokenFactory).create(
_masterToken.name, _masterToken.symbol, _masterToken.baseURI, ownerToken, bytes("")
);

emit DeployMasterToken(masterToken);

IAddressRegistry(deploymentRegistry).addEntry(_signature.signer, ownerToken);
return (ownerToken, masterToken);
}
Expand Down

0 comments on commit 16121a4

Please sign in to comment.