generated from huff-language/huff-project-template
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
206 additions
and
183 deletions.
There are no files selected for viewing
This file contains 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 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 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,120 @@ | ||
/// @title MinimalAccountFactory | ||
/// @notice Factory for the MinimalAccount | ||
/// @author kopy-kat <https://github.com/kopy-kat> | ||
/// @custom:inspiration SimpleAccountFactory <https://github.com/eth-infinitism/account-abstraction/blob/develop/contracts/samples/SimpleAccountFactory.sol> | ||
|
||
/* Interface */ | ||
#define function createAccount(address,uint256) nonpayable returns (address) | ||
#define function getAddress(address,uint256) view returns (address) | ||
|
||
/* Constants */ | ||
#define constant ACCOUNT_INITCODE = 0x61015880600a3d393df360003560e01c80633a871cdd14610021578063b61d27f61461011e5760006000fd5b33735ff137d4b0fdcd49dca30c7cf57e578a026d2789146100425760006000fd5b6101a43560a401803590602090038035906040013560f81c6024356020527b19457468657265756d205369676e6564204d6573736167653a0a3332600052603c6004207f7fffffffffffffffffffffffffffffff5d576e7357a4501ddfe92f46681b20a084116100d457600052602052604052606052602060406080600060015afa5060006060523d606003516100db565b5050505060005b737e5f4552091a69125d5dfcb7b8c2659029395bdf1461010057600160005260206000f35b6044358060001461011857600060006000600093335af15b60206080f35b33735ff137d4b0fdcd49dca30c7cf57e578a026d27891461013f5760006000fd5b606435806084600037600060209160006024356004355af1 | ||
#define constant ACCOUNT_INITCODE_LENGTH = 0x164 | ||
#define constant ACCOUNT_INITCODE_HASH = 0xf62ad50462f93b6a5d1b025f45d9b88bb5ea39d677f69a666816cfdf628fd446 | ||
|
||
/* Internal functions */ | ||
#define macro GET_ACCOUNT_INITCODE() = takes (0) returns (0) { | ||
0x61015880600a3d393df360003560e01c80633a871cdd14610021578063b61d27 0x00 mstore | ||
0xf61461011e5760006000fd5b33735ff137d4b0fdcd49dca30c7cf57e578a026d 0x20 mstore | ||
0x2789146100425760006000fd5b6101a43560a401803590602090038035906040 0x40 mstore | ||
0x013560f81c6024356020527b19457468657265756d205369676e6564204d6573 0x60 mstore | ||
0x736167653a0a3332600052603c6004207f7fffffffffffffffffffffffffffff 0x80 mstore | ||
0xff5d576e7357a4501ddfe92f46681b20a084116100d457600052602052604052 0xa0 mstore | ||
0x606052602060406080600060015afa5060006060523d606003516100db565b50 0xc0 mstore | ||
0x50505060005b737e5f4552091a69125d5dfcb7b8c2659029395bdf1461010057 0xe0 mstore | ||
0x600160005260206000f35b604435806000146101185760006000600060009333 0x100 mstore | ||
0x5af15b60206080f35b33735ff137d4b0fdcd49dca30c7cf57e578a026d278914 0x120 mstore | ||
0x61013f5760006000fd5b60643580608460003760006020916000602435600435 0x140 mstore | ||
0x5af1000000000000000000000000000000000000000000000000000000000000 0x160 mstore | ||
} | ||
|
||
/* External functions */ | ||
#define macro CREATE_ACCOUNT() = takes (0) returns (0) { | ||
|
||
// [ACCOUNT_BYTECODE] 0x00 mstore | ||
|
||
// 0x60908060093d393df360003560e01c80633a871cdd14610021578063b61d27f6 0x00 mstore | ||
// 0x146100565760006000fd5b33735ff137d4b0fdcd49dca30c7cf57e578a026d27 0x20 mstore | ||
// 0x89146100425760006000fd5b6000600060006000604435335af160206000f35b 0x40 mstore | ||
// 0x33735ff137d4b0fdcd49dca30c7cf57e578a026d2789146100775760006000fd 0x60 mstore | ||
// 0x5b606435806084600037600060209160006024356004355af100000000000000 0x80 mstore | ||
|
||
// 0x61018480600a3d393df360003560e01c80633a871cdd14610021578063b61d27 0x00 mstore | ||
// 0xf61461014a5760006000fd5b33735ff137d4b0fdcd49dca30c7cf57e578a026d 0x20 mstore | ||
// 0x2789146100425760006000fd5b7f68eaa91fcee1235f6cbcdfed4958c9eb8bfe 0x40 mstore | ||
// 0x0a270174ed08e8bca0bc5b3cf93e7f498e7bf7455b69dbf0b2e93f1c23f206f4 0x60 mstore | ||
// 0xabd35d22bd73df5daea4f668ed43b0601c6024356020527b1945746865726575 0x80 mstore | ||
// 0x6d205369676e6564204d6573736167653a0a3332600052603c6004207f7fffff 0xa0 mstore | ||
// 0xffffffffffffffffffffffffff5d576e7357a4501ddfe92f46681b20a0841161 0xc0 mstore | ||
// 0x010057600052602052604052606052602060406080600060015afa5060006060 0xe0 mstore | ||
// 0x523d60600351610107565b5050505060005b737e5f4552091a69125d5dfcb7b8 0x100 mstore | ||
// 0xc2659029395bdf1461012c57600160005260206000f35b604435806000146101 0x120 mstore | ||
// 0x4457600060006000600093335af15b60206080f35b33735ff137d4b0fdcd49dc 0x140 mstore | ||
// 0xa30c7cf57e578a026d27891461016b5760006000fd5b60643580608460003760 0x160 mstore | ||
// 0x0060209160006024356004355af1000000000000000000000000000000000000 0x180 mstore | ||
|
||
// 0x61015880600a3d393df360003560e01c80633a871cdd14610021578063b61d27 0x00 mstore | ||
// 0xf61461011e5760006000fd5b33735ff137d4b0fdcd49dca30c7cf57e578a026d 0x20 mstore | ||
// 0x2789146100425760006000fd5b6101a43560a401803590602090038035906040 0x40 mstore | ||
// 0x013560f81c6024356020527b19457468657265756d205369676e6564204d6573 0x60 mstore | ||
// 0x736167653a0a3332600052603c6004207f7fffffffffffffffffffffffffffff 0x80 mstore | ||
// 0xff5d576e7357a4501ddfe92f46681b20a084116100d457600052602052604052 0xa0 mstore | ||
// 0x606052602060406080600060015afa5060006060523d606003516100db565b50 0xc0 mstore | ||
// 0x50505060005b737e5f4552091a69125d5dfcb7b8c2659029395bdf1461010057 0xe0 mstore | ||
// 0x600160005260206000f35b604435806000146101185760006000600060009333 0x100 mstore | ||
// 0x5af15b60206080f35b33735ff137d4b0fdcd49dca30c7cf57e578a026d278914 0x120 mstore | ||
// 0x61013f5760006000fd5b60643580608460003760006020916000602435600435 0x140 mstore | ||
// 0x5af1000000000000000000000000000000000000000000000000000000000000 0x160 mstore | ||
|
||
GET_ACCOUNT_INITCODE() | ||
|
||
0x24 calldataload // [salt] | ||
[ACCOUNT_INITCODE_LENGTH] // [bytesize, salt] | ||
0x00 // [offset, bytesize, salt] | ||
0x00 // [value, offset, bytesize, salt] | ||
create2 | ||
|
||
0x00 mstore | ||
0x20 0x00 return | ||
} | ||
|
||
#define macro GET_ADDRESS() = takes (0) returns (0) { | ||
// Store the code hash @ 0x54:0x74 | ||
GET_ACCOUNT_INITCODE() | ||
[ACCOUNT_INITCODE_LENGTH] 0x00 sha3 | ||
0x54 mstore | ||
|
||
// Store the prefix @ 0x00:0x20 | ||
0xff 0x00 mstore | ||
|
||
// Store this address @ 0x20:0x34 | ||
address 0x60 shl 0x20 mstore | ||
|
||
// Store the salt @ 0x34:0x54 | ||
0x24 calldataload | ||
0x34 mstore | ||
|
||
// Hash the packed data | ||
0x55 0x1f sha3 // [raw_hash] | ||
|
||
// Clean the upper 12 bytes (96 bits or 0x60) | ||
0x60 shl 0x60 shr // [address] | ||
|
||
0x74 mstore | ||
0x20 0x74 return | ||
} | ||
|
||
#define macro MAIN() = takes (0) returns (0) { | ||
// Identify which function is being called. | ||
0x00 calldataload 0xE0 shr | ||
dup1 __FUNC_SIG(createAccount) eq createAccount jumpi | ||
dup1 __FUNC_SIG(getAddress) eq getAddress jumpi | ||
|
||
0x00 0x00 revert | ||
|
||
createAccount: | ||
CREATE_ACCOUNT() | ||
getAddress: | ||
GET_ADDRESS() | ||
|
||
} |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.