Skip to content

Commit

Permalink
Merge pull request #239 from OriginTrail/gnosis-mainnet-delegations
Browse files Browse the repository at this point in the history
Fixed unchecked initial operator fee in the Profile, redeployed contr…
  • Loading branch information
u-hubar authored Feb 14, 2024
2 parents 26881f1 + e6d0b1a commit 7d0db0b
Show file tree
Hide file tree
Showing 9 changed files with 304 additions and 214 deletions.
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

0 comments on commit 7d0db0b

Please sign in to comment.