Skip to content

Commit

Permalink
Merge pull request #30 from xWerk/chore/local-thirdweb-deps
Browse files Browse the repository at this point in the history
Install deps with Bun
  • Loading branch information
gabrielstoica authored Nov 4, 2024
2 parents d3884cd + b03a2d8 commit d05a473
Show file tree
Hide file tree
Showing 22 changed files with 360 additions and 70 deletions.
14 changes: 9 additions & 5 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,21 +18,25 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
submodules: recursive

- name: Install Foundry
- name: "Install Foundry"
uses: foundry-rs/foundry-toolchain@v1
with:
version: nightly

- name: Run Forge build
- name: "Install Bun"
uses: "oven-sh/setup-bun@v1"

- name: "Install the Node.js dependencies"
run: "bun install --frozen-lockfile"

- name: "Run Forge build"
run: |
forge --version
forge build
id: build

- name: Run Forge tests
- name: "Run Forge tests"
run: |
forge test -vvv
id: test
10 changes: 8 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# Compiler files
# Directories
cache/
out/
node_modules

# Coverage
coverage/
Expand All @@ -15,4 +16,9 @@ coverage/

# Others
.npmrc
*lcov.info
.DS_Store
.pnp.*
*lcov.info
package-lock.json
pnpm-lock.yaml
yarn.lock
24 changes: 0 additions & 24 deletions .gitmodules

This file was deleted.

Binary file added bun.lockb
Binary file not shown.
4 changes: 2 additions & 2 deletions foundry.toml
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
[profile.default]
src = "src"
out = "out"
libs = ["lib"]
script = "script"
test = "test"
optimizer = true
optimizer_runs = 1000
gas_reports = ["ModuleKeeper", "DockRegistry", "Container"]
ffi = true
ast = true
build_info = true
extra_output = ["storageLayout"]
Expand Down
1 change: 0 additions & 1 deletion lib/contracts
Submodule contracts deleted from 5c96c2
1 change: 0 additions & 1 deletion lib/forge-std
Submodule forge-std deleted from 978ac6
1 change: 0 additions & 1 deletion lib/openzeppelin-contracts
Submodule openzeppelin-contracts deleted from dbb610
1 change: 0 additions & 1 deletion lib/openzeppelin-contracts-upgradeable
Submodule openzeppelin-contracts-upgradeable deleted from 723f8c
1 change: 0 additions & 1 deletion lib/openzeppelin-foundry-upgrades
Submodule openzeppelin-foundry-upgrades deleted from 4cd15f
1 change: 0 additions & 1 deletion lib/prb-math
Submodule prb-math deleted from 39eec8
1 change: 0 additions & 1 deletion lib/v2-core
Submodule v2-core deleted from 733569
11 changes: 11 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"devDependencies": {
"forge-std": "github:foundry-rs/forge-std#v1.9.4"
},
"dependencies": {
"@openzeppelin/contracts": "^5.1.0",
"@prb/math": "^4.1.0",
"@sablier/v2-core": "^1.2.0",
"@thirdweb-dev/contracts": "^3.15.0"
}
}
13 changes: 5 additions & 8 deletions remappings.txt
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
@openzeppelin/contracts/=lib/openzeppelin-contracts/contracts/
@openzeppelin/contracts-upgradeable/=lib/openzeppelin-contracts-upgradeable/contracts/
@sablier/v2-core/=lib/v2-core/
@prb/math/=lib/prb-math/
@nomad-xyz/excessively-safe-call/=lib/nomad-xyz/excessively-safe-call/
@thirdweb/contracts/=lib/contracts/contracts/
ds-test/=lib/openzeppelin-contracts/lib/forge-std/lib/ds-test/src/
forge-std/=lib/forge-std/src/
@openzeppelin/contracts/=node_modules/@openzeppelin/contracts/
@sablier/v2-core/=node_modules/@sablier/v2-core/
@prb/math/=node_modules/@prb/math/
@thirdweb/contracts/=node_modules/@thirdweb-dev/contracts/
forge-std/=node_modules/forge-std/src/
4 changes: 2 additions & 2 deletions script/DeployDeterministicStationRegistry.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ pragma solidity ^0.8.26;
import { BaseScript } from "./Base.s.sol";
import { StationRegistry } from "./../src/StationRegistry.sol";
import { ModuleKeeper } from "./../src/ModuleKeeper.sol";
import { EntryPoint } from "@thirdweb/contracts/prebuilts/account/utils/Entrypoint.sol";
import { IEntryPoint } from "@thirdweb/contracts/prebuilts/account/interface/IEntrypoint.sol";

/// @notice Deploys at deterministic addresses across chains an instance of {StationRegistry}
/// @dev Reverts if any contract has already been deployed
Expand All @@ -14,7 +14,7 @@ contract DeployDeterministicStationRegistry is BaseScript {
function run(
string memory create2Salt,
address initialAdmin,
EntryPoint entrypoint,
IEntryPoint entrypoint,
ModuleKeeper moduleKeeper
) public virtual broadcast returns (StationRegistry stationRegistry) {
bytes32 salt = bytes32(abi.encodePacked(create2Salt));
Expand Down
20 changes: 15 additions & 5 deletions src/Space.sol
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,9 @@ contract Space is ISpace, AccountCore, ERC1271, ModuleManager {
}

/// @inheritdoc ISpace
function withdrawNative(uint256 amount) public onlyAdminOrEntrypoint {
function withdrawNative(
uint256 amount
) public onlyAdminOrEntrypoint {
// Checks: the native balance of the space minus the amount locked for operations is greater than the requested amount
if (amount > address(this).balance) revert Errors.InsufficientNativeToWithdraw();

Expand All @@ -177,7 +179,9 @@ contract Space is ISpace, AccountCore, ERC1271, ModuleManager {
}

/// @inheritdoc IModuleManager
function enableModule(address module) public override onlyAdminOrEntrypoint {
function enableModule(
address module
) public override onlyAdminOrEntrypoint {
// Retrieve the address of the {ModuleKeeper}
ModuleKeeper moduleKeeper = StationRegistry(factory).moduleKeeper();

Expand All @@ -186,7 +190,9 @@ contract Space is ISpace, AccountCore, ERC1271, ModuleManager {
}

/// @inheritdoc IModuleManager
function disableModule(address module) public override onlyAdminOrEntrypoint {
function disableModule(
address module
) public override onlyAdminOrEntrypoint {
// Effects: disable the module
_disableModule(module);
}
Expand Down Expand Up @@ -224,14 +230,18 @@ contract Space is ISpace, AccountCore, ERC1271, ModuleManager {
}

/// @inheritdoc ISpace
function getMessageHash(bytes32 _hash) public view returns (bytes32) {
function getMessageHash(
bytes32 _hash
) public view returns (bytes32) {
bytes32 messageHash = keccak256(abi.encode(_hash));
bytes32 typedDataHash = keccak256(abi.encode(MSG_TYPEHASH, messageHash));
return keccak256(abi.encodePacked("\x19\x01", _domainSeparatorV4(), typedDataHash));
}

/// @inheritdoc IERC165
function supportsInterface(bytes4 interfaceId) public pure returns (bool) {
function supportsInterface(
bytes4 interfaceId
) public pure returns (bool) {
return interfaceId == type(ISpace).interfaceId || interfaceId == type(IERC1155Receiver).interfaceId
|| interfaceId == type(IERC721Receiver).interfaceId || interfaceId == type(IERC165).interfaceId;
}
Expand Down
12 changes: 8 additions & 4 deletions src/StationRegistry.sol
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
// SPDX-License-Identifier: GPL-3.0-or-later
pragma solidity ^0.8.26;

import { BaseAccountFactory } from "@thirdweb/contracts/prebuilts/account/utils/BaseAccountFactory.sol";
import { IEntryPoint } from "@thirdweb/contracts/prebuilts/account/interface/IEntrypoint.sol";
import { PermissionsEnumerable } from "@thirdweb/contracts/extension/PermissionsEnumerable.sol";
import { EnumerableSet } from "@thirdweb/contracts/external-deps/openzeppelin/utils/structs/EnumerableSet.sol";

import { IStationRegistry } from "./interfaces/IStationRegistry.sol";
import { Space } from "./Space.sol";
import { ModuleKeeper } from "./ModuleKeeper.sol";
import { Errors } from "./libraries/Errors.sol";
import { IStationRegistry } from "./interfaces/IStationRegistry.sol";
import { BaseAccountFactory } from "./utils/BaseAccountFactory.sol";

/// @title StationRegistry
/// @notice See the documentation in {IStationRegistry}
Expand Down Expand Up @@ -111,7 +111,9 @@ contract StationRegistry is IStationRegistry, BaseAccountFactory, PermissionsEnu
}

/// @inheritdoc IStationRegistry
function updateModuleKeeper(ModuleKeeper newModuleKeeper) external onlyRole(DEFAULT_ADMIN_ROLE) {
function updateModuleKeeper(
ModuleKeeper newModuleKeeper
) external onlyRole(DEFAULT_ADMIN_ROLE) {
// Effects: update the {ModuleKeeper} address
moduleKeeper = newModuleKeeper;

Expand All @@ -124,7 +126,9 @@ contract StationRegistry is IStationRegistry, BaseAccountFactory, PermissionsEnu
//////////////////////////////////////////////////////////////////////////*/

/// @inheritdoc IStationRegistry
function totalAccountsOfSigner(address signer) public view returns (uint256) {
function totalAccountsOfSigner(
address signer
) public view returns (uint256) {
return accountsOfSigner[signer].length();
}

Expand Down
Loading

0 comments on commit d05a473

Please sign in to comment.