diff --git a/contracts/misc/package.json b/contracts/misc/package.json index 2b185b960..c8d207fa5 100644 --- a/contracts/misc/package.json +++ b/contracts/misc/package.json @@ -8,5 +8,8 @@ "devDependencies": { "ds-test": "github:dapphub/ds-test", "forge-std": "github:foundry-rs/forge-std" + }, + "dependencies": { + "createx": "github:pcaversaccio/createx" } } diff --git a/contracts/misc/pnpm-lock.yaml b/contracts/misc/pnpm-lock.yaml index 4f9f0c683..e69694e40 100644 --- a/contracts/misc/pnpm-lock.yaml +++ b/contracts/misc/pnpm-lock.yaml @@ -7,6 +7,10 @@ settings: importers: .: + dependencies: + createx: + specifier: github:pcaversaccio/createx + version: https://codeload.github.com/pcaversaccio/createx/tar.gz/ff43c668db7381216ce4e0059ff44ac0d119bfd6 devDependencies: ds-test: specifier: github:dapphub/ds-test @@ -17,6 +21,10 @@ importers: packages: + createx@https://codeload.github.com/pcaversaccio/createx/tar.gz/ff43c668db7381216ce4e0059ff44ac0d119bfd6: + resolution: {tarball: https://codeload.github.com/pcaversaccio/createx/tar.gz/ff43c668db7381216ce4e0059ff44ac0d119bfd6} + version: 1.0.0 + ds-test@https://codeload.github.com/dapphub/ds-test/tar.gz/e282159d5170298eb2455a6c05280ab5a73a4ef0: resolution: {tarball: https://codeload.github.com/dapphub/ds-test/tar.gz/e282159d5170298eb2455a6c05280ab5a73a4ef0} version: 1.0.0 @@ -27,6 +35,8 @@ packages: snapshots: + createx@https://codeload.github.com/pcaversaccio/createx/tar.gz/ff43c668db7381216ce4e0059ff44ac0d119bfd6: {} + ds-test@https://codeload.github.com/dapphub/ds-test/tar.gz/e282159d5170298eb2455a6c05280ab5a73a4ef0: {} forge-std@https://codeload.github.com/foundry-rs/forge-std/tar.gz/2b59872eee0b8088ddcade39fe8c041e17bb79c0: {} diff --git a/contracts/misc/script/pledge/Pledge.s.sol b/contracts/misc/script/pledge/Pledge.s.sol new file mode 100644 index 000000000..a9794b617 --- /dev/null +++ b/contracts/misc/script/pledge/Pledge.s.sol @@ -0,0 +1,29 @@ +// SPDX-License-Identifier: GPL-3.0-only +pragma solidity =0.8.24; + +import { Pledge } from "../../src/pledge/Pledge.sol"; +import { Script, console2 } from "forge-std/Script.sol"; +import { ICreateX } from "createx/src/ICreateX.sol"; + +contract PledgeScript is Script { + ICreateX public createX = ICreateX(0xba5Ed099633D3B313e4D5F7bdc1305d3c28ba5Ed); + address public omni = 0x5e9A8Aa213C912Bf54C86bf64aDB8ed6A79C04d1; + bytes32 public salt = 0xa779fc675db318dab004ab8d538cb320d0013f42009066ee4061894802758139; + + function getInitCodeHash() public view returns (bytes32) { + bytes memory bytecode = type(Pledge).creationCode; + bytes memory initCode = abi.encodePacked(bytecode, abi.encode(omni)); + return keccak256(initCode); + } + + function deploy() external { + bytes memory bytecode = type(Pledge).creationCode; + bytes memory initCode = abi.encodePacked(bytecode, abi.encode(omni)); + + vm.startBroadcast(); + address pledge = createX.deployCreate2(salt, initCode); + vm.stopBroadcast(); + //solhint-disable-next-line no-console + console2.log("Pledge deployed at", pledge); + } +}