-
Notifications
You must be signed in to change notification settings - Fork 35
7779 bases management + use in MSA #41
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
Merged
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
b2b5cd3
7779 bases management + use in MSA
dafb83d
clean package.json
c9e07a7
rm _addBase from using w/o module flow
fe0f49a
apply 7779 for 7702 only
e999763
lint
e0a663b
clean
9cf07e8
add naive onRedelegation
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1 +1,2 @@ | ||
| shamefully-hoist=true | ||
| shamefully-hoist=true | ||
| package-manager-strict=false |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,26 @@ | ||
| // SPDX-License-Identifier: MIT | ||
| pragma solidity ^0.8.27; | ||
|
|
||
| interface IERC7779 { | ||
| /* | ||
| * @dev Externally shares the storage bases that has been used throughout the account. | ||
| * Majority of 7702 accounts will have their distinctive storage base to reduce the chance of storage collision. | ||
| * This allows the external entities to know what the storage base is of the account. | ||
| * Wallets willing to redelegate already-delegated accounts should call accountStorageBase() to check if it confirms with the account it plans to redelegate. | ||
| * | ||
| * The bytes32 array should be stored at the storage slot: keccak(keccak('InteroperableDelegatedAccount.ERC.Storage')-1) & ~0xff | ||
| * This is an append-only array so newly redelegated accounts should not overwrite the storage at this slot, but just append their base to the array. | ||
| * This append operation should be done during the initialization of the account. | ||
| */ | ||
| function accountStorageBases() external view returns (bytes32[] memory); | ||
|
|
||
| /* | ||
| * @dev Function called before redelegation. | ||
| * This function should prepare the account for a delegation to a different implementation. | ||
| * This function could be triggered by the new wallet that wants to redelegate an already delegated EOA. | ||
| * It should uninitialize storages if needed and execute wallet-specific logic to prepare for redelegation. | ||
| * msg.sender should be the owner of the account. | ||
| */ | ||
| function onRedelegation() external returns (bool); | ||
|
|
||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,36 @@ | ||
| // SPDX-License-Identifier: MIT | ||
| pragma solidity ^0.8.27; | ||
|
|
||
| import { MockERC7779 } from "../mocks/MockERC7779.sol"; | ||
| import "forge-std/Test.sol"; | ||
|
|
||
| /// @title TestFuzz_ERC7779Adapter | ||
| /// @notice Tests the ERC7779Adapter contract | ||
| contract TestFuzz_ERC7779Adapter is Test { | ||
| MockERC7779 private mockERC7779; | ||
|
|
||
| function setUp() public { | ||
| mockERC7779 = new MockERC7779(); | ||
| //bytes32 erc7779StorageBase = | ||
| // keccak256(abi.encode(uint256(keccak256(bytes("InteroperableDelegatedAccount.ERC.Storage"))) | ||
| // - 1)) & ~bytes32(uint256(0xff)); | ||
| //console.logBytes32(erc7779StorageBase); | ||
| } | ||
|
|
||
| function test_Fuzz_ERC7779Adapter_AddStorageBases(uint256 amountOfBases) public { | ||
| vm.assume(amountOfBases > 0 && amountOfBases < 100); | ||
| bytes32[] memory expectedStorageBases = new bytes32[](amountOfBases); | ||
|
|
||
| for (uint256 i = 0; i < amountOfBases; i++) { | ||
| bytes32 storageBase = bytes32(uint256(i)); | ||
| expectedStorageBases[i] = storageBase; | ||
| mockERC7779.addStorageBase(storageBase); | ||
| } | ||
|
|
||
| bytes32[] memory retrievedStorageBases = mockERC7779.accountStorageBases(); | ||
| assertEq(retrievedStorageBases.length, amountOfBases); | ||
| for (uint256 i = 0; i < amountOfBases; i++) { | ||
| assertEq(retrievedStorageBases[i], expectedStorageBases[i]); | ||
| } | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,14 @@ | ||
| // SPDX-License-Identifier: MIT | ||
| pragma solidity ^0.8.27; | ||
|
|
||
| import { ERC7779Adapter } from "src/core/ERC7779Adapter.sol"; | ||
|
|
||
| contract MockERC7779 is ERC7779Adapter { | ||
| function addStorageBase(bytes32 storageBase) external { | ||
| _addStorageBase(storageBase); | ||
| } | ||
|
|
||
| function _onRedelegation() internal override { | ||
| // do nothing | ||
| } | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.