Skip to content

Commit

Permalink
rename ContractAccessControlType NONE to ALLOW_ALL_ACCESS
Browse files Browse the repository at this point in the history
  • Loading branch information
adamegyed committed Jan 31, 2024
1 parent 8af27be commit 3348dfe
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 15 deletions.
6 changes: 4 additions & 2 deletions src/plugins/session/ISessionKeyPlugin.sol
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,11 @@ interface ISessionKeyPlugin {

// Valid access control types for contract access control lists.
enum ContractAccessControlType {
ALLOWLIST, // Allowlist is default
// Allowlist is default
ALLOWLIST,
DENYLIST,
NONE
// Disables contract access control
ALLOW_ALL_ACCESS
}

// Struct returned by view functions to provide information about a session key's spend limit.
Expand Down
6 changes: 4 additions & 2 deletions test/plugin/session/SessionKeyPluginWithMultiOwner.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,8 @@ contract SessionKeyPluginWithMultiOwnerTest is Test {
// Disable the allowlist and native token spend checking
bytes[] memory permissionUpdates = new bytes[](2);
permissionUpdates[0] = abi.encodeCall(
ISessionKeyPermissionsUpdates.setAccessListType, (ISessionKeyPlugin.ContractAccessControlType.NONE)
ISessionKeyPermissionsUpdates.setAccessListType,
(ISessionKeyPlugin.ContractAccessControlType.ALLOW_ALL_ACCESS)
);
permissionUpdates[1] =
abi.encodeCall(ISessionKeyPermissionsUpdates.setNativeTokenSpendLimit, (type(uint256).max, 0));
Expand Down Expand Up @@ -544,7 +545,8 @@ contract SessionKeyPluginWithMultiOwnerTest is Test {
// To disable the allowlist and native token spend checking
bytes[] memory permissionUpdates = new bytes[](2);
permissionUpdates[0] = abi.encodeCall(
ISessionKeyPermissionsUpdates.setAccessListType, (ISessionKeyPlugin.ContractAccessControlType.NONE)
ISessionKeyPermissionsUpdates.setAccessListType,
(ISessionKeyPlugin.ContractAccessControlType.ALLOW_ALL_ACCESS)
);
permissionUpdates[1] =
abi.encodeCall(ISessionKeyPermissionsUpdates.setNativeTokenSpendLimit, (type(uint256).max, 0));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,8 @@ contract SessionKeyERC20SpendLimitsTest is Test {
// Disable the allowlist
bytes[] memory updates = new bytes[](1);
updates[0] = abi.encodeCall(
ISessionKeyPermissionsUpdates.setAccessListType, (ISessionKeyPlugin.ContractAccessControlType.NONE)
ISessionKeyPermissionsUpdates.setAccessListType,
(ISessionKeyPlugin.ContractAccessControlType.ALLOW_ALL_ACCESS)
);
vm.prank(owner1);
SessionKeyPlugin(address(account1)).updateKeyPermissions(sessionKey1, updates);
Expand All @@ -137,7 +138,7 @@ contract SessionKeyERC20SpendLimitsTest is Test {
// correctly
assertTrue(
sessionKeyPlugin.getAccessControlType(address(account1), sessionKey1)
== ISessionKeyPlugin.ContractAccessControlType.NONE
== ISessionKeyPlugin.ContractAccessControlType.ALLOW_ALL_ACCESS
);
}

Expand Down
3 changes: 2 additions & 1 deletion test/plugin/session/permissions/SessionKeyGasLimits.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,8 @@ contract SessionKeyGasLimitsTest is Test {

bytes[] memory updates = new bytes[](1);
updates[0] = abi.encodeCall(
ISessionKeyPermissionsUpdates.setAccessListType, (ISessionKeyPlugin.ContractAccessControlType.NONE)
ISessionKeyPermissionsUpdates.setAccessListType,
(ISessionKeyPlugin.ContractAccessControlType.ALLOW_ALL_ACCESS)
);
vm.prank(owner1);
SessionKeyPlugin(address(account1)).updateKeyPermissions(sessionKey1, updates);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,8 @@ contract SessionKeyNativeTokenSpendLimitsTest is Test {
// Remove the allowlist
bytes[] memory updates = new bytes[](1);
updates[0] = abi.encodeCall(
ISessionKeyPermissionsUpdates.setAccessListType, (ISessionKeyPlugin.ContractAccessControlType.NONE)
ISessionKeyPermissionsUpdates.setAccessListType,
(ISessionKeyPlugin.ContractAccessControlType.ALLOW_ALL_ACCESS)
);
vm.prank(owner1);
SessionKeyPlugin(address(account1)).updateKeyPermissions(sessionKey1, updates);
Expand All @@ -129,7 +130,7 @@ contract SessionKeyNativeTokenSpendLimitsTest is Test {
// correctly
assertTrue(
sessionKeyPlugin.getAccessControlType(address(account1), sessionKey1)
== ISessionKeyPlugin.ContractAccessControlType.NONE
== ISessionKeyPlugin.ContractAccessControlType.ALLOW_ALL_ACCESS
);
}

Expand Down
17 changes: 11 additions & 6 deletions test/plugin/session/permissions/SessionKeyPermissions.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,8 @@ contract SessionKeyPermissionsTest is Test {
// Remove the allowlist
bytes[] memory updates = new bytes[](1);
updates[0] = abi.encodeCall(
ISessionKeyPermissionsUpdates.setAccessListType, (ISessionKeyPlugin.ContractAccessControlType.NONE)
ISessionKeyPermissionsUpdates.setAccessListType,
(ISessionKeyPlugin.ContractAccessControlType.ALLOW_ALL_ACCESS)
);
vm.prank(owner1);
SessionKeyPlugin(address(account1)).updateKeyPermissions(sessionKey1, updates);
Expand Down Expand Up @@ -369,7 +370,8 @@ contract SessionKeyPermissionsTest is Test {
// Remove the default allowlist
bytes[] memory updates = new bytes[](1);
updates[0] = abi.encodeCall(
ISessionKeyPermissionsUpdates.setAccessListType, (ISessionKeyPlugin.ContractAccessControlType.NONE)
ISessionKeyPermissionsUpdates.setAccessListType,
(ISessionKeyPlugin.ContractAccessControlType.ALLOW_ALL_ACCESS)
);
vm.prank(owner1);
SessionKeyPlugin(address(account1)).updateKeyPermissions(sessionKey1, updates);
Expand Down Expand Up @@ -458,7 +460,8 @@ contract SessionKeyPermissionsTest is Test {
// Disable the allowlist and disable native token spend checking.
bytes[] memory updates = new bytes[](2);
updates[0] = abi.encodeCall(
ISessionKeyPermissionsUpdates.setAccessListType, (ISessionKeyPlugin.ContractAccessControlType.NONE)
ISessionKeyPermissionsUpdates.setAccessListType,
(ISessionKeyPlugin.ContractAccessControlType.ALLOW_ALL_ACCESS)
);
updates[1] = abi.encodeCall(ISessionKeyPermissionsUpdates.setNativeTokenSpendLimit, (type(uint256).max, 0));

Expand Down Expand Up @@ -517,7 +520,8 @@ contract SessionKeyPermissionsTest is Test {
// Disable the allowlist
bytes[] memory updates = new bytes[](1);
updates[0] = abi.encodeCall(
ISessionKeyPermissionsUpdates.setAccessListType, (ISessionKeyPlugin.ContractAccessControlType.NONE)
ISessionKeyPermissionsUpdates.setAccessListType,
(ISessionKeyPlugin.ContractAccessControlType.ALLOW_ALL_ACCESS)
);
vm.prank(owner1);
SessionKeyPlugin(address(account1)).updateKeyPermissions(sessionKey1, updates);
Expand Down Expand Up @@ -598,7 +602,8 @@ contract SessionKeyPermissionsTest is Test {

bytes[] memory updates = new bytes[](1);
updates[0] = abi.encodeCall(
ISessionKeyPermissionsUpdates.setAccessListType, (ISessionKeyPlugin.ContractAccessControlType.NONE)
ISessionKeyPermissionsUpdates.setAccessListType,
(ISessionKeyPlugin.ContractAccessControlType.ALLOW_ALL_ACCESS)
);
vm.prank(owner1);
SessionKeyPlugin(address(account1)).updateKeyPermissions(sessionKey1, updates);
Expand All @@ -608,7 +613,7 @@ contract SessionKeyPermissionsTest is Test {

assertEq(
uint8(accessControlType1),
uint8(ISessionKeyPlugin.ContractAccessControlType.NONE),
uint8(ISessionKeyPlugin.ContractAccessControlType.ALLOW_ALL_ACCESS),
"sessionKey1 should now have no allowlist"
);
assertEq(
Expand Down

0 comments on commit 3348dfe

Please sign in to comment.