As you can see in the code, Solidity provides create2 assembly function, but working with it is cumbersome. It would be much easier if there were 2 new features in Solidity:
new2 operator. Similar to new, but also accept salt parameter, and uses CREARE opcode. So in my Factory I would have written Holder holder = new2(Holder, _owner) without having to put the byte code of the Holder contract inside the function
Function create2_address, which allows computing address of CREATE2 contract. I would have used it twice, first in Token.getHolderContract function: address payable holder_address = create2_address(factory, a, Holder), and second in Holder.setOwner function: require(create2_address(factor, _owner, Holder) == address(this))
It would be great to have (at least in a branch) a version of Solidity (derived from the current) supporting these two things. That would make further development of contracts like that much easier.
Check this out! Should at least make your life a little bit easier! (It is a contract exposing all functions as public but it can of course be rewritten as a library/contract where all functions are internal/private)
Recently I also needed to implement the same thing
You can preserve a bit more of the new semantics by doing: new(salt) C(args...) that will create the contract C using args as arguments with create2.
The address could be accessed with C.create2Address(salt)