Skip to content

Commit

Permalink
event and some contract changes
Browse files Browse the repository at this point in the history
  • Loading branch information
rperez89 committed Jun 20, 2024
1 parent f375ff2 commit 2eff39c
Show file tree
Hide file tree
Showing 17 changed files with 90 additions and 36 deletions.
12 changes: 3 additions & 9 deletions .prettierrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,20 +14,14 @@
"^~/(.*)$",
"^[./]"
],
"importOrderParserPlugins": [
"typescript",
"jsx",
"decorators-legacy"
],
"importOrderParserPlugins": ["typescript", "jsx", "decorators-legacy"],
"importOrderTypeScriptVersion": "4.4.0",
"overrides": [
{
"files": [
"*.yaml|*.yml"
],
"files": ["*.yaml|*.yml"],
"options": {
"bracketSpacing": false
}
}
]
}
}
4 changes: 2 additions & 2 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
"solidity.packageDefaultDependenciesContractsDirectory": "pkg/contracts/src",
"solidity.packageDefaultDependenciesDirectory": "lib",
"[solidity]": {
"editor.defaultFormatter": "NomicFoundation.hardhat-solidity",
"editor.defaultFormatter": "JuanBlanco.solidity",
"editor.formatOnSave": true
},
"solidity.formatter": "forge",
"solidity.formatter": "forge"
}
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
"devDependencies": {
"eslint-config-custom": "workspace:*",
"prettier": "latest",
"prettier-plugin-solidity": "^1.3.1",
"turbo": "^1.7.4"
},
"engines": {
Expand All @@ -25,4 +26,4 @@
"@typescript-eslint/parser": "6.18.2-alpha.2"
},
"packageManager": "[email protected]"
}
}
2 changes: 1 addition & 1 deletion pkg/contracts/out/CVStrategy.sol/CVStrategy.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion pkg/contracts/out/CVStrategy.sol/IPointStrategy.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion pkg/contracts/out/CVStrategy.sol/StrategyStruct.json

Large diffs are not rendered by default.

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion pkg/contracts/out/PassportScorer.sol/PassportScorer.json

Large diffs are not rendered by default.

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion pkg/contracts/out/RegistryCommunity.sol/FAllo.json

Large diffs are not rendered by default.

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion pkg/contracts/out/RegistryFactory.sol/RegistryFactory.json

Large diffs are not rendered by default.

2 changes: 0 additions & 2 deletions pkg/contracts/script/DeployCV.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,6 @@ contract DeployCV is Native, CVStrategyHelpers, Script, SafeSetup {

sybilScorer = new PassportScorer(scorer_list_manager());

sybilScorer.setThreshold(MINIMUM_SCORER_THRESHOLD);

registryFactory = new RegistryFactory();

console2.log("Registry Factory Addr: %s", address(registryFactory));
Expand Down
1 change: 0 additions & 1 deletion pkg/contracts/src/ISybilScorer.sol
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,4 @@ interface ISybilScorer {
function addUserScore(address _user, PassportData memory _passportData) external;
function removeUser(address _user) external;
function changeListManager(address _newManager) external;
function setThreshold(uint256 _newThreshold) external;
}
19 changes: 12 additions & 7 deletions pkg/contracts/src/PassportScorer.sol
Original file line number Diff line number Diff line change
@@ -1,23 +1,28 @@
// SPDX-License-Identifier: AGPL-3.0-or-later
pragma solidity ^0.8.19;

import {Ownable} from "@openzeppelin/contracts/access/Ownable.sol";
import {Ownable} from "openzeppelin-contracts/contracts/access/Ownable.sol";
import {ISybilScorer, PassportData} from "./ISybilScorer.sol";

contract PassportScorer is Ownable, ISybilScorer {
address public listManager;
uint256 public threshold;

mapping(address user => PassportData passportData) public userScores;
mapping(address => PassportData) public userScores;

event UserScoreAdded(address user, uint256 score, uint256 lastUpdated);
event UserRemoved(address user);
event ListManagerChanged(address oldManager, address newManager);

error OnlyAuthorized();
error ZeroAddress();

modifier onlyAuthorized() {
if (msg.sender == owner() || msg.sender == listManager) {
_;
} else {
revert OnlyAuthorized();
}
revert OnlyAuthorized();
}

function _revertZeroAddress(address _address) private pure {
Expand All @@ -34,20 +39,20 @@ contract PassportScorer is Ownable, ISybilScorer {
function addUserScore(address _user, PassportData memory _passportData) external override onlyAuthorized {
_revertZeroAddress(_user);
userScores[_user] = _passportData;
emit UserScoreAdded(_user, _passportData.score, _passportData.lastUpdated);
}

function removeUser(address _user) external override onlyAuthorized {
_revertZeroAddress(_user);
delete userScores[_user];
emit UserRemoved(_user);
}

function changeListManager(address _newManager) external override onlyOwner {
_revertZeroAddress(_newManager);
address oldManager = listManager;
listManager = _newManager;
}

function setThreshold(uint256 _newThreshold) external override onlyOwner {
threshold = _newThreshold;
emit ListManagerChanged(oldManager, _newManager);
}

function getUserScore(address _user) external view returns (PassportData memory) {
Expand Down
36 changes: 33 additions & 3 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

31 changes: 29 additions & 2 deletions remappings.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,33 @@
ds-test/=lib/forge-std/lib/ds-test/src/
@openzeppelin/contracts/=lib/allo-v2/lib/openzeppelin-contracts/contracts/
@prb/math/=lib/allo-v2/lib/v2-core/lib/prb-math/
@prb/test/=lib/allo-v2/lib/v2-core/lib/prb-test/src/
@sablier/v2-core/=lib/allo-v2/lib/v2-core/
ERC1155/=lib/allo-v2/lib/hats-protocol/lib/ERC1155/
allo-v2/=lib/allo-v2/
ds-test/=lib/allo-v2/lib/forge-std/lib/ds-test/src/
eas-contracts/=lib/allo-v2/lib/eas-contracts/contracts/
eas-proxy/=lib/allo-v2/lib/eas-proxy/contracts/
erc4626-tests/=lib/openzeppelin-contracts/lib/erc4626-tests/
forge-gas-snapshot/=lib/allo-v2/lib/permit2/lib/forge-gas-snapshot/src/
forge-std/=lib/forge-std/src/
halmos-cheatcodes/=lib/openzeppelin-contracts/lib/halmos-cheatcodes/src/
hats-protocol/=lib/allo-v2/lib/hats-protocol/
hedgey-vesting/=lib/allo-v2/lib/hedgey-vesting/contracts/
openzeppelin-contracts-upgradeable/=lib/allo-v2/lib/openzeppelin-contracts-upgradeable/
openzeppelin-contracts/=lib/openzeppelin-contracts/
openzeppelin/=lib/openzeppelin-contracts/contracts/
permit2/=lib/allo-v2/lib/permit2/
prb-math/=lib/allo-v2/lib/v2-core/lib/prb-math/src/
prb-test/=lib/allo-v2/lib/v2-core/lib/prb-test/src/
safe-contracts/=lib/safe-contracts/
solady/=lib/allo-v2/lib/solady/
solarray/=lib/allo-v2/lib/v2-core/lib/solarray/src/
solbase/=lib/allo-v2/lib/hats-protocol/lib/solbase/src/
solmate/=lib/allo-v2/lib/permit2/lib/solmate/
superfluid-protocol-monorepo/=lib/allo-v2/lib/superfluid-protocol-monorepo/packages/solidity-semantic-money/src/
utils/=lib/allo-v2/lib/hats-protocol/lib/utils/
v2-core/=lib/allo-v2/lib/v2-core/
safe-contracts/=lib/safe-contracts/
allo-v2/=lib/allo-v2/
allo-v2-contracts/=lib/allo-v2/contracts/
allo-v2-test/=lib/allo-v2/test/
allo-v2-test/=lib/allo-v2/test/

0 comments on commit 2eff39c

Please sign in to comment.