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

fix: mark function visibility and apply formatting #455

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
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
445 changes: 440 additions & 5 deletions .gas-snapshot

Large diffs are not rendered by default.

4 changes: 3 additions & 1 deletion script/DeployL1.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,9 @@ contract DeployL1 is ImmutableCreate2Deployer {
runDeploy(loadDeploymentParams());
}

function runDeploy(DeploymentParams memory params) public returns (Contracts memory) {
function runDeploy(
DeploymentParams memory params
) public returns (Contracts memory) {
return runDeploy(params, true);
}

Expand Down
10 changes: 7 additions & 3 deletions script/DeployL2.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,9 @@ contract DeployL2 is ImmutableCreate2Deployer {
runSetup(runDeploy(loadDeploymentParams()));
}

function runDeploy(DeploymentParams memory params) public returns (Contracts memory) {
function runDeploy(
DeploymentParams memory params
) public returns (Contracts memory) {
return runDeploy(params, true);
}

Expand Down Expand Up @@ -175,12 +177,14 @@ contract DeployL2 is ImmutableCreate2Deployer {
}
}

function runSetup(Contracts memory contracts) public {
function runSetup(
Contracts memory contracts
) public {
DeploymentParams memory params = loadDeploymentParams();
runSetup(contracts, params, true);
}

function loadDeploymentParams() internal returns (DeploymentParams memory) {
function loadDeploymentParams() internal view returns (DeploymentParams memory) {
return DeploymentParams({
initialIdRegistryOwner: vm.envAddress("ID_REGISTRY_OWNER_ADDRESS"),
initialKeyRegistryOwner: vm.envAddress("KEY_REGISTRY_OWNER_ADDRESS"),
Expand Down
13 changes: 4 additions & 9 deletions script/LocalDeploy.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -36,16 +36,11 @@ contract LocalDeploy is Script {

vm.startBroadcast();
(AggregatorV3Interface priceFeed, AggregatorV3Interface uptimeFeed) = _getOrDeployPriceFeeds();
IdRegistry idRegistry = new IdRegistry{salt: ID_REGISTRY_CREATE2_SALT}(
migrator,
initialIdRegistryOwner
IdRegistry idRegistry = new IdRegistry{salt: ID_REGISTRY_CREATE2_SALT}(migrator, initialIdRegistryOwner);
KeyRegistry keyRegistry = new KeyRegistry{salt: KEY_REGISTRY_CREATE2_SALT}(
address(idRegistry), migrator, initialKeyRegistryOwner, 1000
);
KeyRegistry keyRegistry = new KeyRegistry{
salt: KEY_REGISTRY_CREATE2_SALT
}(address(idRegistry), migrator, initialKeyRegistryOwner, 1000);
StorageRegistry storageRegistry = new StorageRegistry{
salt: STORAGE_RENT_CREATE2_SALT
}(
StorageRegistry storageRegistry = new StorageRegistry{salt: STORAGE_RENT_CREATE2_SALT}(
priceFeed,
uptimeFeed,
INITIAL_USD_UNIT_PRICE,
Expand Down
10 changes: 7 additions & 3 deletions script/UpgradeL2.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,9 @@ contract UpgradeL2 is ImmutableCreate2Deployer, Test {
runSetup(runDeploy(loadDeploymentParams()));
}

function runDeploy(DeploymentParams memory params) public returns (Contracts memory) {
function runDeploy(
DeploymentParams memory params
) public returns (Contracts memory) {
return runDeploy(params, true);
}

Expand Down Expand Up @@ -182,12 +184,14 @@ contract UpgradeL2 is ImmutableCreate2Deployer, Test {
}
}

function runSetup(Contracts memory contracts) public {
function runSetup(
Contracts memory contracts
) public {
DeploymentParams memory params = loadDeploymentParams();
runSetup(contracts, params, true);
}

function loadDeploymentParams() internal returns (DeploymentParams memory) {
function loadDeploymentParams() internal view returns (DeploymentParams memory) {
return DeploymentParams({
initialIdRegistryOwner: vm.envAddress("ID_REGISTRY_OWNER_ADDRESS"),
initialKeyRegistryOwner: vm.envAddress("KEY_REGISTRY_OWNER_ADDRESS"),
Expand Down
12 changes: 9 additions & 3 deletions script/abstract/ImmutableCreate2Deployer.sol
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@ import "forge-std/console.sol";
import {Strings} from "openzeppelin/contracts/utils/Strings.sol";

interface ImmutableCreate2Factory {
function hasBeenDeployed(address deploymentAddress) external view returns (bool);
function hasBeenDeployed(
address deploymentAddress
) external view returns (bool);

function findCreate2Address(
bytes32 salt,
Expand Down Expand Up @@ -132,7 +134,9 @@ abstract contract ImmutableCreate2Deployer is Script {
/**
* @dev Deploy all registered contracts.
*/
function deploy(bool broadcast) internal {
function deploy(
bool broadcast
) internal {
console.log(pad("State", 10), pad("Name", 27), pad("Address", 43), "Initcode hash");
for (uint256 i; i < names.length; i++) {
_deploy(names[i], broadcast);
Expand All @@ -153,7 +157,9 @@ abstract contract ImmutableCreate2Deployer is Script {
_deploy(name, broadcast);
}

function deploy(string memory name) internal {
function deploy(
string memory name
) internal {
deploy(name, true);
}

Expand Down
4 changes: 3 additions & 1 deletion src/Bundler.sol
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,9 @@ contract Bundler is IBundler {
/**
* @inheritdoc IBundler
*/
function price(uint256 extraStorage) external view returns (uint256) {
function price(
uint256 extraStorage
) external view returns (uint256) {
return idGateway.price(extraStorage);
}

Expand Down
16 changes: 12 additions & 4 deletions src/FnameResolver.sol
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@ import {ERC165} from "openzeppelin/contracts/utils/introspection/ERC165.sol";
import {EIP712} from "./abstract/EIP712.sol";

interface IAddressQuery {
function addr(bytes32 node) external view returns (address);
function addr(
bytes32 node
) external view returns (address);
}

interface IExtendedResolver {
Expand Down Expand Up @@ -183,7 +185,9 @@ contract FnameResolver is IExtendedResolver, EIP712, ERC165, Ownable2Step {
*
* @param signer The signer address.
*/
function addSigner(address signer) external onlyOwner {
function addSigner(
address signer
) external onlyOwner {
signers[signer] = true;
emit AddSigner(signer);
}
Expand All @@ -193,7 +197,9 @@ contract FnameResolver is IExtendedResolver, EIP712, ERC165, Ownable2Step {
*
* @param signer The signer address.
*/
function removeSigner(address signer) external onlyOwner {
function removeSigner(
address signer
) external onlyOwner {
signers[signer] = false;
emit RemoveSigner(signer);
}
Expand All @@ -202,7 +208,9 @@ contract FnameResolver is IExtendedResolver, EIP712, ERC165, Ownable2Step {
INTERFACE DETECTION
//////////////////////////////////////////////////////////////*/

function supportsInterface(bytes4 interfaceId) public view override returns (bool) {
function supportsInterface(
bytes4 interfaceId
) public view override returns (bool) {
return interfaceId == type(IExtendedResolver).interfaceId || super.supportsInterface(interfaceId);
}
}
17 changes: 14 additions & 3 deletions src/IdGateway.sol
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import {TransferHelper} from "./libraries/TransferHelper.sol";
import {EIP712} from "./abstract/EIP712.sol";
import {Nonces} from "./abstract/Nonces.sol";
import {Signatures} from "./abstract/Signatures.sol";
import {Address} from "openzeppelin/contracts/utils/Address.sol";

/**
* @title Farcaster IdGateway
Expand All @@ -19,6 +20,7 @@ import {Signatures} from "./abstract/Signatures.sol";
*/
contract IdGateway is IIdGateway, Guardians, Signatures, EIP712, Nonces {
using TransferHelper for address;
using Address for address;

/*//////////////////////////////////////////////////////////////
CONSTANTS
Expand Down Expand Up @@ -90,7 +92,9 @@ contract IdGateway is IIdGateway, Guardians, Signatures, EIP712, Nonces {
/**
* @inheritdoc IIdGateway
*/
function price(uint256 extraStorage) external view returns (uint256) {
function price(
uint256 extraStorage
) external view returns (uint256) {
return storageRegistry.price(1 + extraStorage);
}

Expand All @@ -101,7 +105,9 @@ contract IdGateway is IIdGateway, Guardians, Signatures, EIP712, Nonces {
/**
* @inheritdoc IIdGateway
*/
function register(address recovery) external payable returns (uint256, uint256) {
function register(
address recovery
) external payable returns (uint256, uint256) {
return register(recovery, 0);
}

Expand Down Expand Up @@ -145,7 +151,12 @@ contract IdGateway is IIdGateway, Guardians, Signatures, EIP712, Nonces {
/**
* @inheritdoc IIdGateway
*/
function setStorageRegistry(address _storageRegistry) external onlyOwner {
function setStorageRegistry(
address _storageRegistry
) external onlyOwner {
if (_storageRegistry == address(0)) revert Unauthorized();
if (!_storageRegistry.isContract()) revert Unauthorized();

emit SetStorageRegistry(address(storageRegistry), _storageRegistry);
storageRegistry = IStorageRegistry(_storageRegistry);
}
Expand Down
20 changes: 15 additions & 5 deletions src/IdRegistry.sol
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,9 @@ contract IdRegistry is IIdRegistry, Migration, Signatures, EIP712, Nonces {
/**
* @inheritdoc IIdRegistry
*/
function changeRecoveryAddress(address recovery) external whenNotPaused {
function changeRecoveryAddress(
address recovery
) external whenNotPaused {
/* Revert if the caller does not own an fid */
uint256 ownerId = idOf[msg.sender];
if (ownerId == 0) revert HasNoId();
Expand Down Expand Up @@ -359,7 +361,9 @@ contract IdRegistry is IIdRegistry, Migration, Signatures, EIP712, Nonces {
/**
* @inheritdoc IIdRegistry
*/
function setIdGateway(address _idGateway) external onlyOwner {
function setIdGateway(
address _idGateway
) external onlyOwner {
if (gatewayFrozen) revert GatewayFrozen();
emit SetIdGateway(idGateway, _idGateway);
idGateway = _idGateway;
Expand All @@ -378,7 +382,9 @@ contract IdRegistry is IIdRegistry, Migration, Signatures, EIP712, Nonces {
MIGRATION
//////////////////////////////////////////////////////////////*/

function bulkRegisterIds(BulkRegisterData[] calldata ids) external onlyMigrator {
function bulkRegisterIds(
BulkRegisterData[] calldata ids
) external onlyMigrator {
// Safety: i can be incremented unchecked since it is bound by ids.length.
unchecked {
for (uint256 i = 0; i < ids.length; i++) {
Expand All @@ -403,7 +409,9 @@ contract IdRegistry is IIdRegistry, Migration, Signatures, EIP712, Nonces {
}
}

function bulkResetIds(uint24[] calldata ids) external onlyMigrator {
function bulkResetIds(
uint24[] calldata ids
) external onlyMigrator {
// Safety: i can be incremented unchecked since it is bound by ids.length.
unchecked {
for (uint256 i = 0; i < ids.length; i++) {
Expand All @@ -419,7 +427,9 @@ contract IdRegistry is IIdRegistry, Migration, Signatures, EIP712, Nonces {
}
}

function setIdCounter(uint256 _counter) external onlyMigrator {
function setIdCounter(
uint256 _counter
) external onlyMigrator {
emit SetIdCounter(idCounter, _counter);
idCounter = _counter;
}
Expand Down
28 changes: 21 additions & 7 deletions src/KeyRegistry.sol
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,9 @@ contract KeyRegistry is IKeyRegistry, Migration, Signatures, EIP712, Nonces {
/**
* @inheritdoc IKeyRegistry
*/
function remove(bytes calldata key) external whenNotPaused {
function remove(
bytes calldata key
) external whenNotPaused {
_remove(_fidOf(msg.sender), key);
}

Expand All @@ -218,7 +220,9 @@ contract KeyRegistry is IKeyRegistry, Migration, Signatures, EIP712, Nonces {
/**
* @inheritdoc IKeyRegistry
*/
function bulkAddKeysForMigration(BulkAddData[] calldata items) external onlyMigrator {
function bulkAddKeysForMigration(
BulkAddData[] calldata items
) external onlyMigrator {
// Safety: i and j can be incremented unchecked since they are bound by items.length and
// items[i].keys.length respectively.
unchecked {
Expand All @@ -234,7 +238,9 @@ contract KeyRegistry is IKeyRegistry, Migration, Signatures, EIP712, Nonces {
/**
* @inheritdoc IKeyRegistry
*/
function bulkResetKeysForMigration(BulkResetData[] calldata items) external onlyMigrator {
function bulkResetKeysForMigration(
BulkResetData[] calldata items
) external onlyMigrator {
// Safety: i and j can be incremented unchecked since they are bound by items.length and
// items[i].keys.length respectively.
unchecked {
Expand Down Expand Up @@ -264,15 +270,19 @@ contract KeyRegistry is IKeyRegistry, Migration, Signatures, EIP712, Nonces {
/**
* @inheritdoc IKeyRegistry
*/
function setIdRegistry(address _idRegistry) external onlyOwner {
function setIdRegistry(
address _idRegistry
) external onlyOwner {
emit SetIdRegistry(address(idRegistry), _idRegistry);
idRegistry = IdRegistryLike(_idRegistry);
}

/**
* @inheritdoc IKeyRegistry
*/
function setKeyGateway(address _keyGateway) external onlyOwner {
function setKeyGateway(
address _keyGateway
) external onlyOwner {
if (gatewayFrozen) revert GatewayFrozen();
emit SetKeyGateway(keyGateway, _keyGateway);
keyGateway = _keyGateway;
Expand All @@ -290,7 +300,9 @@ contract KeyRegistry is IKeyRegistry, Migration, Signatures, EIP712, Nonces {
/**
* @inheritdoc IKeyRegistry
*/
function setMaxKeysPerFid(uint256 _maxKeysPerFid) external onlyOwner {
function setMaxKeysPerFid(
uint256 _maxKeysPerFid
) external onlyOwner {
if (_maxKeysPerFid <= maxKeysPerFid) revert InvalidMaxKeys();
emit SetMaxKeysPerFid(maxKeysPerFid, _maxKeysPerFid);
maxKeysPerFid = _maxKeysPerFid;
Expand Down Expand Up @@ -376,7 +388,9 @@ contract KeyRegistry is IKeyRegistry, Migration, Signatures, EIP712, Nonces {
FID HELPERS
//////////////////////////////////////////////////////////////*/

function _fidOf(address fidOwner) internal view returns (uint256 fid) {
function _fidOf(
address fidOwner
) internal view returns (uint256 fid) {
fid = idRegistry.idOf(fidOwner);
if (fid == 0) revert Unauthorized();
}
Expand Down
4 changes: 3 additions & 1 deletion src/RecoveryProxy.sol
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,9 @@ contract RecoveryProxy is Ownable2Step {
*
* @param _idRegistry IDRegistry contract address.
*/
function setIdRegistry(IIdRegistry _idRegistry) external onlyOwner {
function setIdRegistry(
IIdRegistry _idRegistry
) external onlyOwner {
emit SetIdRegistry(idRegistry, _idRegistry);
idRegistry = _idRegistry;
}
Expand Down
Loading