Skip to content

Commit

Permalink
merge: pull request #20 from transmissions11/patch
Browse files Browse the repository at this point in the history
refactor: use modern Solidity instead of assembly for create2
  • Loading branch information
PaulRBerg authored Mar 10, 2022
2 parents 6f69fb5 + f3e5886 commit 41d92d1
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 17 deletions.
10 changes: 1 addition & 9 deletions contracts/PRBProxyFactory.sol
Original file line number Diff line number Diff line change
Expand Up @@ -47,16 +47,8 @@ contract PRBProxyFactory is IPRBProxyFactory {
// Prevent front-running the salt by hashing the concatenation of "tx.origin" and the user-provided seed.
bytes32 salt = keccak256(abi.encode(tx.origin, seed));

// Load the proxy bytecode.
bytes memory bytecode = type(PRBProxy).creationCode;

// Deploy the proxy with CREATE2.
assembly {
let endowment := 0
let bytecodeStart := add(bytecode, 0x20)
let bytecodeLength := mload(bytecode)
proxy := create2(endowment, bytecodeStart, bytecodeLength, salt)
}
proxy = payable(new PRBProxy{ salt: salt }());

// Transfer the ownership from this factory contract to the specified owner.
IPRBProxy(proxy).transferOwnership(owner);
Expand Down
9 changes: 1 addition & 8 deletions src/types/factories/PRBProxyFactory__factory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -138,15 +138,8 @@ const _abi = [
];

const _bytecode =
"0x608060405234801561001057600080fd5b50610bac806100206000396000f3fe608060405234801561001057600080fd5b50600436106100675760003560e01c806354fd4d501161005057806354fd4d50146100e457806374912cd2146100ec578063775c300c1461011757600080fd5b8063297103881461006c57806337a6be16146100ad575b600080fd5b61009861007a3660046102b2565b6001600160a01b031660009081526020819052604090205460ff1690565b60405190151581526020015b60405180910390f35b6100d66100bb3660046102b2565b6001600160a01b031660009081526001602052604090205490565b6040519081526020016100a4565b6100d6600181565b6100ff6100fa3660046102b2565b61011f565b6040516001600160a01b0390911681526020016100a4565b6100ff610295565b3260008181526001602090815260408083205481519283019490945281018390529091908290606001604051602081830303815290604052805190602001209050600060405180602001610172906102a5565b6020820181038252601f19601f820116604052509050600060208201825184818385f56040517ff2fde38b0000000000000000000000000000000000000000000000000000000081526001600160a01b038a81166004830152919850908816935063f2fde38b92506024019050600060405180830381600087803b1580156101f957600080fd5b505af115801561020d573d6000803e3d6000fd5b505050506001600160a01b03848116600081815260208181526040808320805460ff191660019081179091553280855281845293829020908901905580518881529182018790528101929092529187169133917f6aafca263a35a9d2a6e4e4659a84688092f4ae153df2f95cd7659508d95c18709060600160405180910390a4505050919050565b60006102a03361011f565b905090565b6108bd806102e383390190565b6000602082840312156102c457600080fd5b81356001600160a01b03811681146102db57600080fd5b939250505056fe608060405234801561001057600080fd5b50611388600155600080546001600160a01b0319163390811782556040519091907f5c486528ec3e3f0ea91181cff8116f02bfa350e03b8b6f12e00765adbb5af85c908290a3610858806100656000396000f3fe6080604052600436106100745760003560e01c80639d1595681161004e5780639d15956814610103578063da8d882c14610127578063e64624fa14610193578063f2fde38b146101b357600080fd5b806309924a40146100805780631cff79cd146100a25780638da5cb5b146100cb57600080fd5b3661007b57005b600080fd5b34801561008c57600080fd5b506100a061009b3660046105c5565b6101d3565b005b6100b56100b03660046105fa565b61021d565b6040516100c291906106ca565b60405180910390f35b3480156100d757600080fd5b506000546100eb906001600160a01b031681565b6040516001600160a01b0390911681526020016100c2565b34801561010f57600080fd5b5061011960015481565b6040519081526020016100c2565b34801561013357600080fd5b506101836101423660046106fc565b6001600160a01b0392831660009081526002602090815260408083209490951682529283528381206001600160e01b03199290921681529152205460ff1690565b60405190151581526020016100c2565b34801561019f57600080fd5b506100a06101ae36600461073f565b610491565b3480156101bf57600080fd5b506100a06101ce36600461079a565b610521565b6000546001600160a01b031633146102185760005460405163ac976e3960e01b81526001600160a01b0390911660048201523360248201526044015b60405180910390fd5b600155565b6000546060906001600160a01b031633146102d2573360009081526002602090815260408083206001600160a01b0388168452825280832086356001600160e01b03198116855292529091205460ff166102d0576000546040517fa2ee03b80000000000000000000000000000000000000000000000000000000081526001600160a01b03918216600482015233602482015290861660448201526001600160e01b03198216606482015260840161020f565b505b833b80610316576040517f29ba3bdf0000000000000000000000000000000000000000000000000000000081526001600160a01b038616600482015260240161020f565b600080546001546001600160a01b0390911691905a61033591906107b5565b90506000876001600160a01b03168288886040516103549291906107f3565b6000604051808303818686f4925050503d8060008114610390576040519150601f19603f3d011682016040523d82523d6000602084013e610395565b606091505b506000549096509091506001600160a01b038481169116146103fa576000546040517fbcac60ce0000000000000000000000000000000000000000000000000000000081526001600160a01b038086166004830152909116602482015260440161020f565b876001600160a01b03167fb24ebe141c5f2a744b103bea65fce6c40e0dc65d7341d092c09b160f4044799088888860405161043793929190610803565b60405180910390a280610486578451156104545784518086602001fd5b6040517fe336368800000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b505050509392505050565b6000546001600160a01b031633146104d15760005460405163ac976e3960e01b81526001600160a01b03909116600482015233602482015260440161020f565b6001600160a01b0393841660009081526002602090815260408083209590961682529384528481206001600160e01b03199390931681529190925291909120805460ff1916911515919091179055565b6000546001600160a01b031633811461055e5760405163ac976e3960e01b81526001600160a01b038216600482015233602482015260440161020f565b600080547fffffffffffffffffffffffff0000000000000000000000000000000000000000166001600160a01b0384811691821783556040519192908416917f5c486528ec3e3f0ea91181cff8116f02bfa350e03b8b6f12e00765adbb5af85c9190a35050565b6000602082840312156105d757600080fd5b5035919050565b80356001600160a01b03811681146105f557600080fd5b919050565b60008060006040848603121561060f57600080fd5b610618846105de565b9250602084013567ffffffffffffffff8082111561063557600080fd5b818601915086601f83011261064957600080fd5b81358181111561065857600080fd5b87602082850101111561066a57600080fd5b6020830194508093505050509250925092565b6000815180845260005b818110156106a357602081850181015186830182015201610687565b818111156106b5576000602083870101525b50601f01601f19169290920160200192915050565b6020815260006106dd602083018461067d565b9392505050565b80356001600160e01b0319811681146105f557600080fd5b60008060006060848603121561071157600080fd5b61071a846105de565b9250610728602085016105de565b9150610736604085016106e4565b90509250925092565b6000806000806080858703121561075557600080fd5b61075e856105de565b935061076c602086016105de565b925061077a604086016106e4565b91506060850135801515811461078f57600080fd5b939692955090935050565b6000602082840312156107ac57600080fd5b6106dd826105de565b6000828210156107ee577f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b500390565b8183823760009101908152919050565b60408152826040820152828460608301376000606084830101526000601f19601f85011682016060838203016020840152610841606082018561067d565b969550505050505056fea164736f6c6343000809000aa164736f6c6343000809000a";
"0x608060405234801561001057600080fd5b50610b9f806100206000396000f3fe608060405234801561001057600080fd5b50600436106100675760003560e01c806354fd4d501161005057806354fd4d50146100e457806374912cd2146100ec578063775c300c1461011757600080fd5b8063297103881461006c57806337a6be16146100ad575b600080fd5b61009861007a3660046102a6565b6001600160a01b031660009081526020819052604090205460ff1690565b60405190151581526020015b60405180910390f35b6100d66100bb3660046102a6565b6001600160a01b031660009081526001602052604090205490565b6040519081526020016100a4565b6100d6600181565b6100ff6100fa3660046102a6565b61011f565b6040516001600160a01b0390911681526020016100a4565b6100ff610289565b32600081815260016020908152604080832054815192830194909452810183905290919082906060016040516020818303038152906040528051906020012090508060405161016d90610299565b8190604051809103906000f590508015801561018d573d6000803e3d6000fd5b506040517ff2fde38b0000000000000000000000000000000000000000000000000000000081526001600160a01b0386811660048301529194509084169063f2fde38b90602401600060405180830381600087803b1580156101ee57600080fd5b505af1158015610202573d6000803e3d6000fd5b505050506001600160a01b03838116600081815260208181526040808320805460ff191660019081179091553280855281845293829020908801905580518781529182018690528101929092529186169133917f6aafca263a35a9d2a6e4e4659a84688092f4ae153df2f95cd7659508d95c18709060600160405180910390a45050919050565b60006102943361011f565b905090565b6108bc806102d783390190565b6000602082840312156102b857600080fd5b81356001600160a01b03811681146102cf57600080fd5b939250505056fe608060405234801561001057600080fd5b50611388600155600080546001600160a01b0319163390811782556040519091907f5c486528ec3e3f0ea91181cff8116f02bfa350e03b8b6f12e00765adbb5af85c908290a3610857806100656000396000f3fe6080604052600436106100745760003560e01c80639d1595681161004e5780639d15956814610103578063da8d882c14610127578063e64624fa14610193578063f2fde38b146101b357600080fd5b806309924a40146100805780631cff79cd146100a25780638da5cb5b146100cb57600080fd5b3661007b57005b600080fd5b34801561008c57600080fd5b506100a061009b3660046105c4565b6101d3565b005b6100b56100b03660046105f9565b61021d565b6040516100c291906106c9565b60405180910390f35b3480156100d757600080fd5b506000546100eb906001600160a01b031681565b6040516001600160a01b0390911681526020016100c2565b34801561010f57600080fd5b5061011960015481565b6040519081526020016100c2565b34801561013357600080fd5b506101836101423660046106fb565b6001600160a01b0392831660009081526002602090815260408083209490951682529283528381206001600160e01b03199290921681529152205460ff1690565b60405190151581526020016100c2565b34801561019f57600080fd5b506100a06101ae36600461073e565b610491565b3480156101bf57600080fd5b506100a06101ce366004610799565b610521565b6000546001600160a01b031633146102185760005460405163ac976e3960e01b81526001600160a01b0390911660048201523360248201526044015b60405180910390fd5b600155565b6000546060906001600160a01b031633146102d2573360009081526002602090815260408083206001600160a01b0388168452825280832086356001600160e01b03198116855292529091205460ff166102d0576000546040517fa2ee03b80000000000000000000000000000000000000000000000000000000081526001600160a01b03918216600482015233602482015290861660448201526001600160e01b03198216606482015260840161020f565b505b833b80610316576040517f29ba3bdf0000000000000000000000000000000000000000000000000000000081526001600160a01b038616600482015260240161020f565b600080546001546001600160a01b0390911691905a61033591906107b4565b90506000876001600160a01b03168288886040516103549291906107f2565b6000604051808303818686f4925050503d8060008114610390576040519150601f19603f3d011682016040523d82523d6000602084013e610395565b606091505b506000549096509091506001600160a01b038481169116146103fa576000546040517fbcac60ce0000000000000000000000000000000000000000000000000000000081526001600160a01b038086166004830152909116602482015260440161020f565b876001600160a01b03167fb24ebe141c5f2a744b103bea65fce6c40e0dc65d7341d092c09b160f4044799088888860405161043793929190610802565b60405180910390a280610486578451156104545784518086602001fd5b6040517fe336368800000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b505050509392505050565b6000546001600160a01b031633146104d15760005460405163ac976e3960e01b81526001600160a01b03909116600482015233602482015260440161020f565b6001600160a01b0393841660009081526002602090815260408083209590961682529384528481206001600160e01b03199390931681529190925291909120805460ff1916911515919091179055565b6000546001600160a01b031633146105615760005460405163ac976e3960e01b81526001600160a01b03909116600482015233602482015260440161020f565b600080547fffffffffffffffffffffffff0000000000000000000000000000000000000000166001600160a01b0383169081178255604051909182917f5c486528ec3e3f0ea91181cff8116f02bfa350e03b8b6f12e00765adbb5af85c9190a350565b6000602082840312156105d657600080fd5b5035919050565b80356001600160a01b03811681146105f457600080fd5b919050565b60008060006040848603121561060e57600080fd5b610617846105dd565b9250602084013567ffffffffffffffff8082111561063457600080fd5b818601915086601f83011261064857600080fd5b81358181111561065757600080fd5b87602082850101111561066957600080fd5b6020830194508093505050509250925092565b6000815180845260005b818110156106a257602081850181015186830182015201610686565b818111156106b4576000602083870101525b50601f01601f19169290920160200192915050565b6020815260006106dc602083018461067c565b9392505050565b80356001600160e01b0319811681146105f457600080fd5b60008060006060848603121561071057600080fd5b610719846105dd565b9250610727602085016105dd565b9150610735604085016106e3565b90509250925092565b6000806000806080858703121561075457600080fd5b61075d856105dd565b935061076b602086016105dd565b9250610779604086016106e3565b91506060850135801515811461078e57600080fd5b939692955090935050565b6000602082840312156107ab57600080fd5b6106dc826105dd565b6000828210156107ed577f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b500390565b8183823760009101908152919050565b60408152826040820152828460608301376000606084830101526000601f19601f85011682016060838203016020840152610840606082018561067c565b969550505050505056fea164736f6c6343000809000aa164736f6c6343000809000a";

type PRBProxyFactoryConstructorParams =
| [signer?: Signer]
| ConstructorParameters<typeof ContractFactory>;

const isSuperArgs = (
xs: PRBProxyFactoryConstructorParams
): xs is ConstructorParameters<typeof ContractFactory> => xs.length > 1;

export class PRBProxyFactory__factory extends ContractFactory {
constructor(...args: PRBProxyFactoryConstructorParams) {
Expand Down

0 comments on commit 41d92d1

Please sign in to comment.