Skip to content

Commit

Permalink
re-typings
Browse files Browse the repository at this point in the history
  • Loading branch information
giuseppecrj committed Sep 9, 2024
2 parents a171cd1 + 0bc97f9 commit a9f61e5
Show file tree
Hide file tree
Showing 119 changed files with 1,431 additions and 1,026 deletions.
Empty file.
24 changes: 24 additions & 0 deletions .github/workflows/Network_diff_upgrade.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
name: Network Diff Upgrade

on:
workflow_dispatch:

jobs:
Run_Bytecode_Diff_Upgrade:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
ref: main

- name: Gamma Network Diff Report
uses: ./.github/workflows/Bytecode_diff_report.yml
with:
origin_environment: alpha
target_environment: gamma

- name: Upgrade Gamma Facets
uses: ./.github/workflows/Upgrade_network_facets.yml
with:
environment_name: gamma
Empty file.
4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,7 @@ jobs:
permissions: write-all
if: github.event_name != 'workflow_dispatch' || !inputs.skip_multinode_ent
runs-on: ubuntu-latest-8-cores
timeout-minutes: 30
timeout-minutes: 40
services:
postgres-core:
image: postgres:latest
Expand Down Expand Up @@ -431,7 +431,7 @@ jobs:
permissions: write-all
if: github.event_name != 'workflow_dispatch' || !inputs.skip_multinode_ent_legacy
runs-on: ubuntu-latest-8-cores
timeout-minutes: 30
timeout-minutes: 40
services:
postgres-core:
image: postgres:latest
Expand Down
3 changes: 3 additions & 0 deletions contracts/deployments/omega/base/addresses/erc721aFacet.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"address": "0xEb7f78a7C86216FB039E40781D7E51cA3FA22393"
}
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
"address": "0x4126B770453000BE73bcf678bd9828fA9bE5F3F3"
"address": "0x364Ad89E6ef239D4489cd9f462a28ce391A52220"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"address": "0x8762Fa32Dd5e9B83d137C32A6CF5556292f385f3"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"address": "0x91F9C60deB821fB6c9ce8b3E8a964BD7D7ba8cdE"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"address": "0xC11Bc92Fd7F2054B4753058bAa44C441aa8A697e"
}
6 changes: 6 additions & 0 deletions contracts/makefile
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,12 @@ interact-any-explicit :;
forge script scripts/interactions/${contract}.s.sol:${contract} \
--ffi --rpc-url ${rpc} --private-key ${private_key} --broadcast --verifier-url ${verifier} --etherscan-api-key ${etherscan} --verify

interact-any-explicit-blockscout :;
@echo "Running $(contract) on remote network"
@SAVE_DEPLOYMENTS=1 $(if $(context),DEPLOYMENT_CONTEXT=$(context)) \
forge script scripts/interactions/${contract}.s.sol:${contract} \
--ffi --rpc-url ${rpc} --private-key ${private_key} --broadcast --verifier-url ${verifier} --verifier=blockscout --verify

interact-resume-any-explicit :;
@echo "Running $(contract) on remote network"
@SAVE_DEPLOYMENTS=1 $(if $(context),DEPLOYMENT_CONTEXT=$(context)) \
Expand Down
File renamed without changes.
37 changes: 0 additions & 37 deletions contracts/src/diamond/utils/multicall/Multicall.sol

This file was deleted.

16 changes: 8 additions & 8 deletions contracts/src/spaces/facets/Entitled.sol
Original file line number Diff line number Diff line change
Expand Up @@ -49,15 +49,15 @@ abstract contract Entitled is
uint256[] memory bannedTokens = _bannedTokenIds();
uint256 bannedTokensLen = bannedTokens.length;

for (uint256 i = 0; i < linkedWalletsLength; i++) {
for (uint256 i; i < linkedWalletsLength; ++i) {
address wallet = wallets[i];

if (wallet == owner) {
return true;
}

// check if banned
for (uint256 j; j < bannedTokensLen; j++) {
for (uint256 j; j < bannedTokensLen; ++j) {
if (_ownerOf(bannedTokens[j]) == wallet) {
return false;
}
Expand All @@ -69,13 +69,13 @@ abstract contract Entitled is
.layout();
uint256 entitlementsLength = ds.entitlements.length();

for (uint256 i = 0; i < entitlementsLength; i++) {
EntitlementsManagerStorage.Entitlement memory e = ds.entitlementByAddress[
ds.entitlements.at(i)
];
for (uint256 i; i < entitlementsLength; ++i) {
IEntitlement entitlement = ds
.entitlementByAddress[ds.entitlements.at(i)]
.entitlement;
if (
!e.entitlement.isCrosschain() &&
e.entitlement.isEntitled(channelId, wallets, permission)
!entitlement.isCrosschain() &&
entitlement.isEntitled(channelId, wallets, permission)
) {
return true;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ contract EntitlementsManager is
Entitled
{
function addImmutableEntitlements(
address[] memory entitlements
address[] calldata entitlements
) external onlyOwner {
_addImmutableEntitlements(entitlements);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ import {EntitlementsManagerService} from "contracts/src/spaces/facets/entitlemen
// contracts

contract EntitlementsManagerBase is IEntitlementsManagerBase {
function _addImmutableEntitlements(address[] memory entitlements) internal {
for (uint256 i = 0; i < entitlements.length; i++) {
function _addImmutableEntitlements(address[] calldata entitlements) internal {
for (uint256 i; i < entitlements.length; ++i) {
EntitlementsManagerService.validateEntitlement(entitlements[i]);
EntitlementsManagerService.addEntitlement(entitlements[i], true);
}
Expand Down Expand Up @@ -73,7 +73,7 @@ contract EntitlementsManagerBase is IEntitlementsManagerBase {

modules = new Entitlement[](entitlements.length);

for (uint256 i = 0; i < entitlements.length; i++) {
for (uint256 i; i < entitlements.length; ++i) {
(
string memory name,
address entitlementAddress,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,8 @@ library EntitlementsManagerStorage {
}

function layout() internal pure returns (Layout storage ds) {
bytes32 slot = STORAGE_SLOT;
assembly {
ds.slot := slot
ds.slot := STORAGE_SLOT
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ interface IEntitlementsManagerBase {
interface IEntitlementsManager is IEntitlementsManagerBase {
/// @notice Allows the space owner to add immutable entitlements to the space
/// @param entitlements The entitlements to add
function addImmutableEntitlements(address[] memory entitlements) external;
function addImmutableEntitlements(address[] calldata entitlements) external;

/// @notice Checks if a user is entitled to a permission in the space
/// @param user The user to check
Expand Down
4 changes: 2 additions & 2 deletions contracts/src/spaces/facets/proxy/SpaceProxy.sol
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import {MembershipBase} from "contracts/src/spaces/facets/membership/MembershipB
import {ERC721ABase} from "contracts/src/diamond/facets/token/ERC721A/ERC721ABase.sol";
import {IntrospectionBase} from "contracts/src/diamond/facets/introspection/IntrospectionBase.sol";
import {EntitlementGatedBase} from "contracts/src/spaces/facets/gated/EntitlementGatedBase.sol";
import {Multicall} from "contracts/src/diamond/utils/multicall/Multicall.sol";
import {Multicallable} from "solady/utils/Multicallable.sol";

contract SpaceProxy is
IntrospectionBase,
Expand All @@ -24,7 +24,7 @@ contract SpaceProxy is
ERC721ABase,
MembershipBase,
EntitlementGatedBase,
Multicall
Multicallable
{
constructor(
address owner,
Expand Down
15 changes: 9 additions & 6 deletions contracts/test/diamond/multicall/Multicall.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,9 @@ import {TestUtils} from "contracts/test/utils/TestUtils.sol";
import {MockMulticall} from "contracts/test/mocks/MockMulticall.sol";

contract MulticallTest is TestUtils {
MockMulticall public mockMulticall;
MockMulticall internal mockMulticall = new MockMulticall();

function setUp() external {
mockMulticall = new MockMulticall();
}

function testMulticall() external {
function test_multicall() external {
bytes[] memory data = new bytes[](2);

data[0] = abi.encodeWithSelector(MockMulticall.one.selector);
Expand All @@ -30,4 +26,11 @@ contract MulticallTest is TestUtils {
assertEq(abi.decode(results[0], (uint256)), 1);
assertEq(abi.decode(results[1], (uint256)), 2);
}

function test_fuzz_multicall(bytes[] memory data) external {
bytes[] memory results = mockMulticall.multicall(data);
for (uint256 i; i < results.length; ++i) {
assertEq(results[i], data[i]);
}
}
}
8 changes: 6 additions & 2 deletions contracts/test/mocks/MockMulticall.sol
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,18 @@ pragma solidity ^0.8.23;
// libraries

// contracts
import {Multicall} from "contracts/src/diamond/utils/multicall/Multicall.sol";
import {Multicallable} from "solady/utils/Multicallable.sol";

contract MockMulticall is Multicall {
contract MockMulticall is Multicallable {
function one() external pure returns (uint256) {
return 1;
}

function two() external pure returns (uint256) {
return 2;
}

fallback(bytes calldata) external returns (bytes memory) {
return msg.data;
}
}
54 changes: 54 additions & 0 deletions contracts/test/spaces/multicall/Multicall.t.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.23;

// utils

//interfaces
import {IChannelBase, IChannel} from "contracts/src/spaces/facets/channels/IChannel.sol";

//libraries
import {ChannelService__ChannelDoesNotExist} from "contracts/src/spaces/facets/channels/ChannelService.sol";

//contracts
import {Multicallable} from "solady/utils/Multicallable.sol";
import {BaseSetup} from "../BaseSetup.sol";

contract MulticallTest is BaseSetup {
function test_multicall() external {
bytes32 channelId = "my-cool-channel";
string memory channelMetadata = "Metadata";

bytes[] memory data = new bytes[](3);
data[0] = abi.encodeCall(
IChannel.createChannel,
(channelId, channelMetadata, new uint256[](0))
);
data[1] = abi.encodeCall(IChannel.getChannel, (channelId));
data[2] = abi.encodeCall(IChannel.removeChannel, (channelId));

vm.prank(founder);
bytes[] memory results = Multicallable(everyoneSpace).multicall(data);

assertEq(results.length, 3);
assertEq(results[0].length, 0);
IChannelBase.Channel memory channel = abi.decode(
results[1],
(IChannelBase.Channel)
);
assertEq(channel.id, channelId);
assertEq(channel.disabled, false);
assertEq(channel.metadata, channelMetadata);
assertEq(channel.roleIds, new uint256[](0));
assertEq(results[2].length, 0);
}

function test_revert_multicall() external {
bytes32 channelId = "my-cool-channel";

bytes[] memory data = new bytes[](1);
data[0] = abi.encodeCall(IChannel.getChannel, (channelId));

vm.expectRevert(ChannelService__ChannelDoesNotExist.selector);
Multicallable(everyoneSpace).multicall(data);
}
}
Loading

0 comments on commit a9f61e5

Please sign in to comment.