Skip to content

Commit

Permalink
feat: new correct hchelper with credits & registered url
Browse files Browse the repository at this point in the history
  • Loading branch information
wsdt committed Aug 13, 2024
1 parent 09d4ff0 commit 66ccd74
Show file tree
Hide file tree
Showing 15 changed files with 232 additions and 65 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,9 @@ When you follow the steps above your application will use the already deployed b

| Name | Address | Explainer |
|------------------|--------------------------------------------------|-------------------------------------|
| BACKEND | https://aa-hc-example.onrender.com | |
| BACKEND | https://aa-hc-example.onrender.com/hc | |
| FRONTEND | https://aa-hc-example-fe.onrender.com | |
| HC_HELPER_ADDR | 0x587a06089ed54101dd6d9A8ecDe1d146f97Af6B8 | HC Helper is system-wide available |
| HC_HELPER_ADDR | 0x1c64EC0A5E2C58295c3208a63209A2A719dF68D8 | HC Helper is system-wide available |
| TOKEN_PRICE_ADDR | 0xcad49c0381c1B0779A318c2326Db43A6073adC1e |
| RPC_URL | https://gateway.tenderly.co/public/boba-sepolia | |
| -> More RPC URls | https://chainlist.org/chain/28882 | |
Expand Down
4 changes: 2 additions & 2 deletions backend/.env-template
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
OC_LISTEN_PORT=1234
OC_HYBRID_ACCOUNT=0xd237e48bcf22af223e28283fb6d03a6e2bd34d31
OC_HYBRID_ACCOUNT=0x734ab78da8f5ad3290b6abf784d0bea6bd480be1
ENTRY_POINTS=0x5ff137d4b0fdcd49dca30c7cf57e578a026d2789
CHAIN_ID=28882
HC_HELPER_ADDR=0x587a06089ed54101dd6d9A8ecDe1d146f97Af6B8
HC_HELPER_ADDR=0x1c64EC0A5E2C58295c3208a63209A2A719dF68D8
CONRANKING_API_KEY=
OC_PRIVKEY=
2 changes: 1 addition & 1 deletion backend/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ Of course you can use whichever cloud provider you like. But for demo purposes w

Our demo server will spin down with inactivity or due to exceeding the free monthly limit since we are using the free version. In this case your smart contract call will fail.

The demo server should still be available here: https://aa-hc-example.onrender.com
The demo server should still be available here: https://aa-hc-example.onrender.com/hc

If you want to setup your own server on Render, just follow these steps:
1. Create account on [render.com](https://render.com)
Expand Down
2 changes: 1 addition & 1 deletion backend/tests/server.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ describe("RPC Server", () => {
process.env.OC_LISTEN_PORT = "1234";
process.env.COINRANKING_API_KEY = "fake-api-key";
process.env.OC_HYBRID_ACCOUNT =
"0xd0ca3C1ECa49635259f6c577A09634053Ab79577";
"0x734ab78da8f5ad3290b6abf784d0bea6bd480be1";
process.env.ENTRY_POINTS = "0x43536f912f87490fa70d0AB6D58f8B9CD250394A";
process.env.CHAIN_ID = "901";
process.env.OC_PRIVKEY =
Expand Down
4 changes: 2 additions & 2 deletions backend/tests/token-price.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ describe("getTokenPrice", () => {
process.env.OC_LISTEN_PORT = "1234";
process.env.COINRANKING_API_KEY = "fake-api-key";
process.env.OC_HYBRID_ACCOUNT =
"0xd0ca3C1ECa49635259f6c577A09634053Ab79577";
"0x734ab78da8f5ad3290b6abf784d0bea6bd480be1";
process.env.ENTRY_POINTS = "0x43536f912f87490fa70d0AB6D58f8B9CD250394A";
process.env.CHAIN_ID = "901";
process.env.OC_PRIVKEY =
Expand Down Expand Up @@ -85,7 +85,7 @@ describe("generateResponse", () => {
process.env.OC_LISTEN_PORT = "1234";
process.env.COINRANKING_API_KEY = "fake-api-key";
process.env.OC_HYBRID_ACCOUNT =
"0xd0ca3C1ECa49635259f6c577A09634053Ab79577";
"0x734ab78da8f5ad3290b6abf784d0bea6bd480be1";
process.env.ENTRY_POINTS = "0x43536f912f87490fa70d0AB6D58f8B9CD250394A";
process.env.CHAIN_ID = "901";
process.env.OC_PRIVKEY =
Expand Down
6 changes: 3 additions & 3 deletions contracts/.env-example
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
HYBRID_ACCOUNT=0xd237e48bcf22af223e28283fb6d03a6e2bd34d31
ENTRY_POINT=0x5ff137d4b0fdcd49dca30c7cf57e578a026d2789
TOKEN_PRICE_CONTRACT=0xcad49c0381c1B0779A318c2326Db43A6073adC1e
HC_HELPER_ADDR=0x587a06089ed54101dd6d9A8ecDe1d146f97Af6B8 # boba sepolia system wide helper address
BACKEND_URL=https://aa-hc-example.onrender.com
HC_HELPER_ADDR=0x1c64EC0A5E2C58295c3208a63209A2A719dF68D8 # boba sepolia system wide helper address
BACKEND_URL=https://aa-hc-example.onrender.com/hc
# 0x...
PRIVATE_KEY=
RPC_URL=https://sepolia.boba.network
CLIENT_ADDR=
BUNDLER_RPC=https://bundler.testnet.bnb.boba.network
BUNDLER_RPC=https://bundler-hc.sepolia.boba.network
221 changes: 182 additions & 39 deletions contracts/broadcast/deploy-hybrid-account.s.sol/28882/run-latest.json

Large diffs are not rendered by default.

22 changes: 20 additions & 2 deletions contracts/script/deploy-hybrid-account.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -3,24 +3,42 @@ pragma solidity ^0.8.13;

import "forge-std/Script.sol";
import "../contracts/samples/HybridAccount.sol";
import "../contracts/core/HCHelper.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

// Contracts
HybridAccount public hybridAccount;
HCHelper public hcHelper;
address public entrypoint = address(0x5FF137D4b0FDCD49DcA30c7CF57E578a026d2789);

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

hcHelper = new HCHelper(
entrypoint,
hcHelperAddr
);

hybridAccount = new HybridAccount(
IEntryPoint(0x5FF137D4b0FDCD49DcA30c7CF57E578a026d2789),
address(0x587a06089ed54101dd6d9A8ecDe1d146f97Af6B8)
IEntryPoint(entrypoint), // System-wide Entrypoint
hcHelperAddr
);
hybridAccount.initialize(deployerAddress);
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);
vm.stopBroadcast();
}
}
2 changes: 1 addition & 1 deletion contracts/script/deploy-local.ts
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ async function main() {

console.log("Funding L2 done...");

const BACKEND_URL = process.env.BACKEND_URL ?? `http://${getLocalIpAddress()}:1234`
const BACKEND_URL = process.env.BACKEND_URL ?? `http://${getLocalIpAddress()}:1234/rpc`
if (!process.env.BACKEND_URL) {
console.warn('[deploy-local.ts] No BACKEND_URL defined. Might be expected for default deployments and CI. Using localhost.')
}
Expand Down
10 changes: 8 additions & 2 deletions contracts/script/deploy-sepolia.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ dotenv.config();

const DEFAULT_BOBA_SEPOLIA = {
RPC_URL: 'https://sepolia.boba.network',
HC_HELPER_ADDR: '0x587a06089ed54101dd6d9A8ecDe1d146f97Af6B8',
HC_HELPER_ADDR: '0x1c64EC0A5E2C58295c3208a63209A2A719dF68D8',
}

const readHybridAccountAddress = () => {
Expand Down Expand Up @@ -104,7 +104,7 @@ async function main() {
console.log('-------------------')

if (!BACKEND_URL) {
console.warn('BACKEND_URL not defined. Using default public endpoint https://aa-hc-example.onrender.com')
console.warn('BACKEND_URL not defined. Using default public endpoint https://aa-hc-example.onrender.com/hc')
}
if (!HC_HELPER_ADDR || !hybridAccountAddress || !tokenPriceAddress || !PRIVATE_KEY) {
throw Error("Configuration missing")
Expand All @@ -125,6 +125,12 @@ async function main() {
updateEnvVariable("VITE_SNAP_VERSION", DEFAULT_SNAP_VERSION, frontendEnvPath);
updateEnvVariable("VITE_RPC_PROVIDER", RPC_URL ?? 'https://sepolia.boba.network', frontendEnvPath);

const frontendEnvPathSnapLocal = '../../frontend/.env-boba-sepolia-snaplocal'
updateEnvVariable("VITE_SMART_CONTRACT", tokenPriceAddress, frontendEnvPath);
updateEnvVariable("VITE_SNAP_ORIGIN", 'local:http://localhost:8080', frontendEnvPath);
updateEnvVariable("VITE_SNAP_VERSION", DEFAULT_SNAP_VERSION, frontendEnvPath);
updateEnvVariable("VITE_RPC_PROVIDER", RPC_URL ?? 'https://sepolia.boba.network', frontendEnvPath);

const snapSiteEnvFolder = '../../snap-account-abstraction-keyring/packages/site/'
updateEnvVariable('USE_LOCAL_NETWORK', "false", `${snapSiteEnvFolder}/.env`)
updateEnvVariable('USE_LOCAL_NETWORK', "false", `${snapSiteEnvFolder}/.env.development`)
Expand Down
2 changes: 1 addition & 1 deletion contracts/script/pushProduction.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ const PRIVATE_KEY = args[1];
const HC_HELPER_ADDR = args[2];
const HYBRID_ACCOUNT = args[3];
const TOKEN_PRICE_ACCOUNT_ADDR = args[4];
const BACKEND_URL = args[5] ?? 'https://aa-hc-example.onrender.com'; // use public backend by default
const BACKEND_URL = args[5] ?? 'https://aa-hc-example.onrender.com/hc'; // use public backend by default

console.log('HCH = ', HC_HELPER_ADDR)
console.log('HA = ', HYBRID_ACCOUNT);
Expand Down
4 changes: 2 additions & 2 deletions frontend/.env-boba-sepolia
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
VITE_SMART_CONTRACT=0xDD8A55B3430AeccaBBe81Cb6dcA7daB826Cc0C34
VITE_SMART_CONTRACT=0x6B62ECe2058a63d3BF77cA0a2124C104c0722008
VITE_RPC_PROVIDER=https://sepolia.boba.network
VITE_SNAP_ORIGIN=npm:@bobanetwork/snap-account-abstraction-keyring-hc
VITE_SNAP_ORIGIN=local:http://localhost:8080
VITE_SNAP_VERSION=1.1.3
2 changes: 1 addition & 1 deletion frontend/.env-boba-sepolia-snaplocal
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
VITE_SMART_CONTRACT=0xDD8A55B3430AeccaBBe81Cb6dcA7daB826Cc0C34
VITE_SMART_CONTRACT=0x7F854444C38F13363aD1D1Cd3348E7d142f7a2CC
VITE_RPC_PROVIDER=https://sepolia.boba.network
VITE_SNAP_ORIGIN=local:http://localhost:8080
VITE_SNAP_VERSION=1.1.3
2 changes: 1 addition & 1 deletion frontend/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ Our demo frontend will spin down with inactivity since we are using the free ver
The demo frontend should be live here (free, so might have some delay on cold starts):
https://aa-hc-example-fe.onrender.com

Also the backend is hosted as free version on Render. So make sure to open https://aa-hc-example.onrender.com/ in Browser once to warm up the server. Otherwise the user operation might fail due to timeout.
Also the backend is hosted as free version on Render. So make sure to open https://aa-hc-example.onrender.com/hc/ in Browser once to warm up the server. Otherwise the user operation might fail due to timeout.

If you want to setup your own server on Render, just follow these steps:
1. Create account on [render.com](https://render.com)
Expand Down
10 changes: 5 additions & 5 deletions frontend/src/components/TokenPriceFetcher.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,11 @@ const FormComponent = () => {
to: import.meta.env.VITE_SMART_CONTRACT,
value: "0",
data: txData,
overrides: {
callGasLimitReq: 10_000_000,
maxFeePerGasReq: 10_000_000,
maxPriorityFeePerGasReq: 10_000_000,
},
/*overrides: {
callGasLimitReq: 11_000_000,
maxFeePerGasReq: 11_000_000,
maxPriorityFeePerGasReq: 11_000_000,
},*/
},
account: state.selectedAcount.id,
scope: `eip155:${state.chain}`,
Expand Down

0 comments on commit 66ccd74

Please sign in to comment.