Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed unchecked initial operator fee in the Profile, redeployed contr… #239

Merged
merged 2 commits into from
Feb 14, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions abi/Profile.json
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,17 @@
"name": "OnlyWhitelistedAddressesFunction",
"type": "error"
},
{
"inputs": [
{
"internalType": "uint8",
"name": "operatorFee",
"type": "uint8"
}
],
"name": "OperatorFeeOutOfRange",
"type": "error"
},
{
"inputs": [
{
Expand Down Expand Up @@ -211,6 +222,12 @@
"internalType": "address",
"name": "sharesContractAddress",
"type": "address"
},
{
"indexed": false,
"internalType": "uint8",
"name": "initialOperatorFee",
"type": "uint8"
}
],
"name": "ProfileCreated",
Expand Down
15 changes: 12 additions & 3 deletions contracts/v1/Profile.sol
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,18 @@ import {UnorderedIndexableContractDynamicSetLib} from "./utils/UnorderedIndexabl
import {ADMIN_KEY, OPERATIONAL_KEY} from "./constants/IdentityConstants.sol";

contract Profile is Named, Versioned, ContractStatus, Initializable {
event ProfileCreated(uint72 indexed identityId, bytes nodeId, address adminWallet, address sharesContractAddress);
event ProfileCreated(
uint72 indexed identityId,
bytes nodeId,
address adminWallet,
address sharesContractAddress,
uint8 initialOperatorFee
);
event ProfileDeleted(uint72 indexed identityId);
event AskUpdated(uint72 indexed identityId, bytes nodeId, uint96 ask);

string private constant _NAME = "Profile";
string private constant _VERSION = "1.1.0";
string private constant _VERSION = "1.1.1";

HashingProxy public hashingProxy;
Identity public identityContract;
Expand Down Expand Up @@ -119,6 +125,9 @@ contract Profile is Named, Versioned, ContractStatus, Initializable {
if (ps.sharesSymbols(sharesTokenSymbol)) {
revert ProfileErrors.SharesTokenSymbolAlreadyExists(sharesTokenSymbol);
}
if (initialOperatorFee > 100) {
revert ProfileErrors.OperatorFeeOutOfRange(initialOperatorFee);
}
uint72 identityId = id.createIdentity(msg.sender, adminWallet);
id.addOperationalWallets(identityId, operationalWallets);

Expand All @@ -129,7 +138,7 @@ contract Profile is Named, Versioned, ContractStatus, Initializable {

stakingStorage.setOperatorFee(identityId, initialOperatorFee);

emit ProfileCreated(identityId, nodeId, adminWallet, address(sharesContract));
emit ProfileCreated(identityId, nodeId, adminWallet, address(sharesContract), initialOperatorFee);
}

function setAsk(uint72 identityId, uint96 ask) external onlyIdentityOwner(identityId) {
Expand Down
1 change: 1 addition & 0 deletions contracts/v1/errors/ProfileErrors.sol
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ library ProfileErrors {
error EmptySharesTokenSymbol();
error SharesTokenNameAlreadyExists(string tokenName);
error SharesTokenSymbolAlreadyExists(string tokenSymbol);
error OperatorFeeOutOfRange(uint8 operatorFee);
error ZeroAsk();
error NoOperatorFees(uint72 identityId);
error ProfileDoesntExist(uint72 identityId);
Expand Down
3 changes: 2 additions & 1 deletion deploy/001_deploy_hub_v2.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) {

const Hub = await hre.deployments.deploy('Hub', { contract: 'HubV2', from: deployer, log: true });

hre.helpers.updateDeploymentsJson('Hub', Hub.address);
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
hre.helpers.updateDeploymentsJson('Hub', Hub.address, Hub.receipt!.blockNumber);
}
}

Expand Down
3 changes: 2 additions & 1 deletion deploy/002_deploy_hub.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) {

const Hub = await hre.deployments.deploy('Hub', { from: deployer, log: true });

hre.helpers.updateDeploymentsJson('Hub', Hub.address);
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
hre.helpers.updateDeploymentsJson('Hub', Hub.address, Hub.receipt!.blockNumber);
}
}

Expand Down
Loading
Loading