Skip to content

Commit

Permalink
Merge 8e9963c into a977312
Browse files Browse the repository at this point in the history
  • Loading branch information
skimaharvey authored Oct 2, 2023
2 parents a977312 + 8e9963c commit 40ec7a7
Show file tree
Hide file tree
Showing 25 changed files with 429 additions and 208 deletions.
59 changes: 30 additions & 29 deletions constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ export const INTERFACE_IDS = {
ERC725Y: '0x629aa694',
LSP0ERC725Account: '0x24871b3d',
LSP1UniversalReceiver: '0x6bb56a14',
LSP6KeyManager: '0x66918867',
LSP6KeyManager: '0xe7424397',
LSP7DigitalAsset: '0x05519512',
LSP8IdentifiableDigitalAsset: '0x1ae9ba1f',
LSP9Vault: '0x28af17e6',
Expand All @@ -35,7 +35,7 @@ export const INTERFACE_IDS = {
LSP17Extendable: '0xa918fa6b',
LSP17Extension: '0xcee78b40',
LSP20CallVerification: '0x1a0eb6a5',
LSP20CallVerifier: '0x480c0ec2',
LSP20CallVerifier: '0xc9dfc532',
LSP25ExecuteRelayCall: '0x5ac79908',
};

Expand All @@ -60,10 +60,10 @@ export const ERC1271_VALUES = {
*/
export const LSP20_MAGIC_VALUES = {
VERIFY_CALL: {
// bytes3(keccak256("lsp20VerifyCall(address,uint256,bytes)")) + "0x01"
WITH_POST_VERIFICATION: '0x9bf04b01',
// bytes3(keccak256("lsp20VerifyCall(address,uint256,bytes)")) + "0x00"
NO_POST_VERIFICATION: '0x9bf04b00',
// bytes3(keccak256("lsp20VerifyCall(address,address,uint256,bytes)")) + "0x00"
NO_POST_VERIFICATION: '0x1a238000',
// bytes3(keccak256("lsp20VerifyCall(address,address,uint256,bytes)")) + "0x01"
WITH_POST_VERIFICATION: '0x1a238001',
},
// bytes4(keccak256("lsp20VerifyCallResult(bytes32,bytes)"))
VERIFY_CALL_RESULT: '0xd3fc45d3',
Expand Down Expand Up @@ -274,7 +274,7 @@ export const CALLTYPE = {
/**
* @dev `bytes32` hex value for all the LSP6 permissions excluding REENTRANCY, DELEGATECALL and SUPER_DELEGATECALL for security (these should be set manually)
*/
export const ALL_PERMISSIONS = '0x00000000000000000000000000000000000000000000000000000000003f3f7f';
export const ALL_PERMISSIONS = '0x00000000000000000000000000000000000000000000000000000000007f3f7f';

export type LSP6PermissionName = keyof typeof PERMISSIONS;

Expand All @@ -283,28 +283,29 @@ export type LSP6PermissionName = keyof typeof PERMISSIONS;
*/
// prettier-ignore
export const PERMISSIONS = {
CHANGEOWNER: "0x0000000000000000000000000000000000000000000000000000000000000001",
ADDCONTROLLER: "0x0000000000000000000000000000000000000000000000000000000000000002",
EDITPERMISSIONS: "0x0000000000000000000000000000000000000000000000000000000000000004",
ADDEXTENSIONS: "0x0000000000000000000000000000000000000000000000000000000000000008",
CHANGEEXTENSIONS: "0x0000000000000000000000000000000000000000000000000000000000000010",
ADDUNIVERSALRECEIVERDELEGATE: "0x0000000000000000000000000000000000000000000000000000000000000020",
CHANGEUNIVERSALRECEIVERDELEGATE: "0x0000000000000000000000000000000000000000000000000000000000000040",
REENTRANCY: "0x0000000000000000000000000000000000000000000000000000000000000080",
SUPER_TRANSFERVALUE: "0x0000000000000000000000000000000000000000000000000000000000000100",
TRANSFERVALUE: "0x0000000000000000000000000000000000000000000000000000000000000200",
SUPER_CALL: "0x0000000000000000000000000000000000000000000000000000000000000400",
CALL: "0x0000000000000000000000000000000000000000000000000000000000000800",
SUPER_STATICCALL: "0x0000000000000000000000000000000000000000000000000000000000001000",
STATICCALL: "0x0000000000000000000000000000000000000000000000000000000000002000",
SUPER_DELEGATECALL: "0x0000000000000000000000000000000000000000000000000000000000004000",
DELEGATECALL: "0x0000000000000000000000000000000000000000000000000000000000008000",
DEPLOY: "0x0000000000000000000000000000000000000000000000000000000000010000",
SUPER_SETDATA: "0x0000000000000000000000000000000000000000000000000000000000020000",
SETDATA: "0x0000000000000000000000000000000000000000000000000000000000040000",
ENCRYPT: "0x0000000000000000000000000000000000000000000000000000000000080000",
DECRYPT: "0x0000000000000000000000000000000000000000000000000000000000100000",
SIGN: "0x0000000000000000000000000000000000000000000000000000000000200000",
CHANGEOWNER: '0x0000000000000000000000000000000000000000000000000000000000000001', // .... .... .... .... .... 0001
ADDCONTROLLER: '0x0000000000000000000000000000000000000000000000000000000000000002', // .... .... .... .... .... 0010
EDITPERMISSIONS: '0x0000000000000000000000000000000000000000000000000000000000000004', // .... .... .... .... .... 0100
ADDEXTENSIONS: '0x0000000000000000000000000000000000000000000000000000000000000008', // .... .... .... .... .... 1000
CHANGEEXTENSIONS: '0x0000000000000000000000000000000000000000000000000000000000000010', // .... .... .... .... 0001 0000
ADDUNIVERSALRECEIVERDELEGATE: '0x0000000000000000000000000000000000000000000000000000000000000020', // .... .... .... .... 0010 0000
CHANGEUNIVERSALRECEIVERDELEGATE: '0x0000000000000000000000000000000000000000000000000000000000000040', // .... .... .... .... 0100 0000
REENTRANCY: '0x0000000000000000000000000000000000000000000000000000000000000080', // .... .... .... .... 1000 0000
SUPER_TRANSFERVALUE: '0x0000000000000000000000000000000000000000000000000000000000000100', // .... .... .... 0001 0000 0000
TRANSFERVALUE: '0x0000000000000000000000000000000000000000000000000000000000000200', // .... .... .... 0010 0000 0000
SUPER_CALL: '0x0000000000000000000000000000000000000000000000000000000000000400', // .... .... .... 0100 0000 0000
CALL: '0x0000000000000000000000000000000000000000000000000000000000000800', // .... .... .... 1000 0000 0000
SUPER_STATICCALL: '0x0000000000000000000000000000000000000000000000000000000000001000', // .... .... 0001 0000 0000 0000
STATICCALL: '0x0000000000000000000000000000000000000000000000000000000000002000', // .... .... 0010 0000 0000 0000
SUPER_DELEGATECALL: '0x0000000000000000000000000000000000000000000000000000000000004000', // .... .... 0100 0000 0000 0000
DELEGATECALL: '0x0000000000000000000000000000000000000000000000000000000000008000', // .... .... 1000 0000 0000 0000
DEPLOY: '0x0000000000000000000000000000000000000000000000000000000000010000', // .... 0001 0000 0000 0000 0000
SUPER_SETDATA: '0x0000000000000000000000000000000000000000000000000000000000020000', // .... 0010 0000 0000 0000 0000
SETDATA: '0x0000000000000000000000000000000000000000000000000000000000040000', // .... 0100 0000 0000 0000 0000
ENCRYPT: '0x0000000000000000000000000000000000000000000000000000000000080000', // .... 1000 0000 0000 0000 0000
DECRYPT: '0x0000000000000000000000000000000000000000000000000000000000100000', // 0001 0000 0000 0000 0000 0000
SIGN: '0x0000000000000000000000000000000000000000000000000000000000200000', // 0010 0000 0000 0000 0000 0000
EXECUTE_RELAY_CALL: '0x0000000000000000000000000000000000000000000000000000000000400000', // 0100 0000 0000 0000 0000 0000
}

/**
Expand Down
2 changes: 2 additions & 0 deletions contracts/LSP20CallVerification/ILSP20CallVerifier.sol
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,13 @@ interface ILSP20CallVerifier {
* the function is allowed, concatened with a byte that determines if the lsp20VerifyCallResult function should
* be called after the original function call. The byte that invoke the lsp20VerifyCallResult function is strictly `0x01`.
*
* @param callee The address of the contract that implements the `LSP20CallVerification` interface
* @param caller The address who called the function on the msg.sender
* @param value The value sent by the caller to the function called on the msg.sender
* @param receivedCalldata The receivedCalldata sent by the caller to the msg.sender
*/
function lsp20VerifyCall(
address callee,
address caller,
uint256 value,
bytes memory receivedCalldata
Expand Down
12 changes: 10 additions & 2 deletions contracts/LSP20CallVerification/LSP20CallVerification.sol
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ abstract contract LSP20CallVerification {
(bool success, bytes memory returnedData) = logicVerifier.call(
abi.encodeWithSelector(
ILSP20.lsp20VerifyCall.selector,
address(this),
msg.sender,
msg.value,
msg.data
Expand All @@ -46,7 +47,7 @@ abstract contract LSP20CallVerification {
if (bytes3(magicValue) != bytes3(ILSP20.lsp20VerifyCall.selector))
revert LSP20InvalidMagicValue(false, returnedData);

return bytes1(magicValue[3]) == 0x01;
return magicValue[3] == 0x01;
}

/**
Expand All @@ -60,7 +61,14 @@ abstract contract LSP20CallVerification {
(bool success, bytes memory returnedData) = logicVerifier.call(
abi.encodeWithSelector(
ILSP20.lsp20VerifyCallResult.selector,
keccak256(abi.encodePacked(msg.sender, msg.value, msg.data)),
keccak256(
abi.encodePacked(
address(this),
msg.sender,
msg.value,
msg.data
)
),
callResult
)
);
Expand Down
8 changes: 4 additions & 4 deletions contracts/LSP20CallVerification/LSP20Constants.sol
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@ pragma solidity ^0.8.4;
// bytes4(keccak256("LSP20CallVerification"))
bytes4 constant _INTERFACEID_LSP20_CALL_VERIFICATION = 0x1a0eb6a5;

// `lsp20VerifyCall(address,uint256,bytes)` selector XOR `lsp20VerifyCallResult(bytes32,bytes)` selector
bytes4 constant _INTERFACEID_LSP20_CALL_VERIFIER = 0x480c0ec2;
// `lsp20VerifyCall(address,address,uint256,bytes)` selector XOR `lsp20VerifyCallResult(bytes32,bytes)` selector
bytes4 constant _INTERFACEID_LSP20_CALL_VERIFIER = 0xc9dfc532;

// bytes4(bytes.concat(bytes3(ILSP20.lsp20VerifyCall.selector), hex"01"))
bytes4 constant _LSP20_VERIFY_CALL_MAGIC_VALUE_WITH_POST_VERIFICATION = 0x9bf04b01;
bytes4 constant _LSP20_VERIFY_CALL_MAGIC_VALUE_WITH_POST_VERIFICATION = 0x1a238001;

// bytes4(bytes.concat(bytes3(ILSP20.lsp20VerifyCall.selector), hex"00"))
bytes4 constant _LSP20_VERIFY_CALL_MAGIC_VALUE_WITHOUT_POST_VERIFICATION = 0x9bf04b00;
bytes4 constant _LSP20_VERIFY_CALL_MAGIC_VALUE_WITHOUT_POST_VERIFICATION = 0x1a238000;

// bytes4(ILSP20.lsp20VerifyCallResult.selector)
bytes4 constant _LSP20_VERIFY_CALL_RESULT_MAGIC_VALUE = 0xd3fc45d3;
5 changes: 3 additions & 2 deletions contracts/LSP6KeyManager/LSP6Constants.sol
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
pragma solidity ^0.8.4;

// --- ERC165 interface ids
bytes4 constant _INTERFACEID_LSP6 = 0x66918867;
bytes4 constant _INTERFACEID_LSP6 = 0xe7424397;

// --- ERC725Y Data Keys

Expand Down Expand Up @@ -52,9 +52,10 @@ bytes32 constant _PERMISSION_SETDATA = 0x000000000000000
bytes32 constant _PERMISSION_ENCRYPT = 0x0000000000000000000000000000000000000000000000000000000000080000;
bytes32 constant _PERMISSION_DECRYPT = 0x0000000000000000000000000000000000000000000000000000000000100000;
bytes32 constant _PERMISSION_SIGN = 0x0000000000000000000000000000000000000000000000000000000000200000;
bytes32 constant _PERMISSION_EXECUTE_RELAY_CALL = 0x0000000000000000000000000000000000000000000000000000000000400000;

// All Permissions currently exclude REENTRANCY, DELEGATECALL and SUPER_DELEGATECALL for security
bytes32 constant ALL_REGULAR_PERMISSIONS = 0x00000000000000000000000000000000000000000000000000000000003f3f7f;
bytes32 constant ALL_REGULAR_PERMISSIONS = 0x00000000000000000000000000000000000000000000000000000000007f3f7f;

// AllowedCalls types
bytes4 constant _ALLOWEDCALLS_TRANSFERVALUE = 0x00000001; // 0000 0001
Expand Down
1 change: 0 additions & 1 deletion contracts/LSP6KeyManager/LSP6KeyManager.sol
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,5 @@ contract LSP6KeyManager is LSP6KeyManagerCore {
constructor(address target_) {
if (target_ == address(0)) revert InvalidLSP6Target();
_target = target_;
_setupLSP6ReentrancyGuard();
}
}
Loading

0 comments on commit 40ec7a7

Please sign in to comment.