Skip to content
Merged
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
2 changes: 1 addition & 1 deletion .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ jobs:
UPGRADE_TEST_OLD_PROXY: ${{ secrets.UPGRADE_TEST_OLD_PROXY }}
UPGRADE_TEST_OLD_VERSION: ${{ secrets.UPGRADE_TEST_OLD_VERSION }}
run: |
forge test --rerun -vvvvv
forge test -vvv

- name: Format contracts and generate snapshots
if: github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name == github.repository
Expand Down
1 change: 1 addition & 0 deletions CNAME
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
legion-rouge.vercel.app
45 changes: 45 additions & 0 deletions test/Account.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -354,4 +354,49 @@ contract AccountTest is BaseTest {
uint256 keysCount137 = IthacaAccount(eoaAddress).keyCount();
assertEq(keysCount137, 2, "Keys should be added on chain 137");
}

function testContextKeyHash() public {
DelegatedEOA memory d = _randomEIP7702DelegatedEOA();

PassKey memory key = _randomPassKey();
key.k.isSuperAdmin = true;

vm.prank(d.eoa);
d.d.authorize(key.k);

// Orchestrator workflow
vm.prank(d.d.ORCHESTRATOR());
ERC7821.Call[] memory calls = new ERC7821.Call[](1);
calls[0].data = abi.encodeWithSelector(this.targetFunctionContextKeyHash.selector);
calls[0].to = address(this);
calls[0].value = 0;
bytes memory opData = abi.encode(key.keyHash);
bytes memory executionData = abi.encode(calls, opData);
d.d.execute(_ERC7821_BATCH_EXECUTION_MODE, executionData);

assertEq(contextKeyHash, key.keyHash, "Context key hash mismatch orchestrator workflow");

// Reset context key hash
contextKeyHash = bytes32(0);

// Workflow with opData
uint256 nonce = d.d.getNonce(0);
bytes memory signature = _sig(key, d.d.computeDigest(calls, nonce));
opData = abi.encodePacked(nonce, signature);
executionData = abi.encode(calls, opData);
d.d.execute(_ERC7821_BATCH_EXECUTION_MODE, executionData);

assertEq(contextKeyHash, key.keyHash, "Context key hash mismatch orchestrator workflow");
Comment thread
Dargon789 marked this conversation as resolved.

// Reset context key hash
contextKeyHash = bytes32(0);

// Simple workflow without opData (self-execution)
bytes memory emptyOpData;
executionData = abi.encode(calls, emptyOpData);
vm.prank(address(d.d));
d.d.execute(_ERC7821_BATCH_EXECUTION_MODE, executionData);

assertEq(contextKeyHash, bytes32(0), "Context key hash should be zero for self-execution without opData");
}
}
5 changes: 5 additions & 0 deletions test/Base.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ contract BaseTest is SoladyTest {
EIP7702Proxy eip7702Proxy;
TargetFunctionPayload[] targetFunctionPayloads;
Simulator simulator;
bytes32 contextKeyHash;

struct TargetFunctionPayload {
address by;
Expand Down Expand Up @@ -94,6 +95,10 @@ contract BaseTest is SoladyTest {
targetFunctionPayloads.push(TargetFunctionPayload(msg.sender, msg.value, data));
}

function targetFunctionContextKeyHash() public payable {
contextKeyHash = IthacaAccount(payable(msg.sender)).getContextKeyHash();
}

function _setEIP7702Delegation(address eoa) internal {
vm.etch(eoa, abi.encodePacked(hex"ef0100", address(account)));
}
Expand Down