Skip to content

Commit

Permalink
fix: Hybrid acc deploy for sepolia/local, deploy local script fixed, ..
Browse files Browse the repository at this point in the history
  • Loading branch information
wsdt committed Aug 14, 2024
1 parent 86d6e76 commit d55c3bd
Show file tree
Hide file tree
Showing 12 changed files with 558 additions and 441 deletions.
19 changes: 19 additions & 0 deletions contracts/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Contracts
Make sure you have setup your machine as outlined in the main [README](../README.md).

## Scripts
Depending on whether you want to test out the example on Boba Sepolia or on a completely local stack either `script/deploy-sepolia.ts` or `script/deploy-local.ts` are run by the commands in the root `package.json`.

Run `pnpm start:local` or `pnpm start:sepolia` in the root folder, to setup the complete example as outlined in the [README](../README.md).

The deploy scripts will automatically update **all environment variables** in all projects to make sure everything runs smoothly.

### registerUrl
This is the only script not used by the default deployment procedure on Boba Sepolia, since this smart contract call requires you to be the **contract owner**.


So, feel free to ignore it - but it may be useful under certain circumstances if you want to rerun this on your local machine or if you actually have the private key to the owner account.


### depositHybridAccount
This script can be used to further add funds to your HybridAccount in order to call HybridCompute. This doesn't need to be explicitly called through the script, as the `deploy-{network}.ts` files do that for you.
228 changes: 124 additions & 104 deletions contracts/broadcast/deploy-hybrid-account.s.sol/28882/run-latest.json

Large diffs are not rendered by default.

20 changes: 12 additions & 8 deletions contracts/script/deploy-hybrid-account.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,18 @@ pragma solidity ^0.8.13;
import "forge-std/Script.sol";
import "../contracts/samples/HybridAccount.sol";
import "../contracts/core/HCHelper.sol";
import {HybridAccountFactory} from "../contracts/samples/HybridAccountFactory.sol";

contract DeployExample is Script {
// Configs
uint256 public deployerPrivateKey = vm.envUint("PRIVATE_KEY");
string public backendURL = "https://aa-hc-example.onrender.com/hc"; // default backend for boba sepolia
address public deployerAddress;
address public hcHelperAddr = address(0x1c64EC0A5E2C58295c3208a63209A2A719dF68D8); // System-wide HCHelper
string public backendURL = vm.envString("BACKEND_URL"); // default backend for boba sepolia
address public hcHelperAddr = vm.envAddress("HC_HELPER_ADDR"); // System-wide HCHelper

// Contracts
address public entrypoint = vm.envAddress("ENTRY_POINT"); // system wide
address public haFactory = address(0x3DD6EE2e539CCd7EaB881173fB704f766e877848); // System-wide Account factory

// Contracts
HybridAccount public hybridAccount;
Expand All @@ -19,26 +24,25 @@ contract DeployExample is Script {

function run() public {
deployerAddress = vm.addr(deployerPrivateKey);

vm.startBroadcast(deployerPrivateKey);

hcHelper = new HCHelper(
entrypoint,
hcHelperAddr
);

hybridAccount = new HybridAccount(
IEntryPoint(entrypoint), // System-wide Entrypoint
hcHelperAddr
);
hybridAccount.initialize(deployerAddress);
// Deploy using HybridAccountFactory, salt = block.number to force redeploy HybridAccount if already existing from this wallet
hybridAccount = HybridAccountFactory(haFactory).createAccount(deployerAddress, block.number);
IEntryPoint(entrypoint).depositTo{value: 0.001 ether}(address(hybridAccount));
console.log(address(hybridAccount));


// register url, add credit
// only owner - reach out to Boba foundation: hcHelper.RegisterUrl(address(hybridAccount), backendURL);
hcHelper.AddCredit(address(hybridAccount), 100);
// permit caller
hybridAccount.initialize(deployerAddress);
// not needed most likely: hybridAccount.initialize(deployerAddress);
vm.stopBroadcast();
}
}
Loading

0 comments on commit d55c3bd

Please sign in to comment.