From d55c3bd70ffd7f39f83e156dcb595c1cc103719a Mon Sep 17 00:00:00 2001 From: wsdt Date: Wed, 14 Aug 2024 12:45:11 +0200 Subject: [PATCH] fix: Hybrid acc deploy for sepolia/local, deploy local script fixed, .. --- contracts/README.md | 19 + .../28882/run-latest.json | 228 +++---- contracts/script/deploy-hybrid-account.s.sol | 20 +- contracts/script/deploy-local.ts | 562 ++++++++---------- contracts/script/deploy-sepolia.ts | 36 +- contracts/script/deploy.s.sol | 33 +- contracts/script/depositHybridAccount.sol | 33 + contracts/script/pushProduction.js | 16 +- contracts/script/registerUrl.s.sol | 34 ++ frontend/.env-boba-sepolia | 4 +- frontend/.env-boba-sepolia-snaplocal | 2 +- frontend/src/components/TokenPriceFetcher.tsx | 12 +- 12 files changed, 558 insertions(+), 441 deletions(-) create mode 100644 contracts/README.md create mode 100644 contracts/script/depositHybridAccount.sol create mode 100644 contracts/script/registerUrl.s.sol diff --git a/contracts/README.md b/contracts/README.md new file mode 100644 index 0000000..d03ca08 --- /dev/null +++ b/contracts/README.md @@ -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. \ No newline at end of file diff --git a/contracts/broadcast/deploy-hybrid-account.s.sol/28882/run-latest.json b/contracts/broadcast/deploy-hybrid-account.s.sol/28882/run-latest.json index f971cc0..603e573 100644 --- a/contracts/broadcast/deploy-hybrid-account.s.sol/28882/run-latest.json +++ b/contracts/broadcast/deploy-hybrid-account.s.sol/28882/run-latest.json @@ -1,10 +1,10 @@ { "transactions": [ { - "hash": "0x3b3ce5696b044acfd3342ab7037df109ef2423888ceebf369d702ca74cc03880", + "hash": "0x5c3613b3ac1c593b7d2d653548eeb8cc31e0280b3f60d0dd5b2a00c53429de75", "transactionType": "CREATE", "contractName": "HCHelper", - "contractAddress": "0x63a774fefcef04d6e138edbcb9ec85cfb7e2c933", + "contractAddress": "0x446559ce4bfade99c036c43f861af681a10433b9", "function": null, "arguments": [ "0x5FF137D4b0FDCD49DcA30c7CF57E578a026d2789", @@ -15,92 +15,97 @@ "gas": "0x1c6a82", "value": "0x0", "input": "0x60a0604052348015600f57600080fd5b50604051611935380380611935833981016040819052602c91606e565b6001600160a01b03918216608052600280546001600160a01b03191691909216179055609c565b80516001600160a01b0381168114606957600080fd5b919050565b60008060408385031215608057600080fd5b6087836053565b91506093602084016053565b90509250929050565b60805161187e6100b76000396000610ca8015261187e6000f3fe608060405234801561001057600080fd5b50600436106100f55760003560e01c80637f8d6fb911610097578063c25fcdff11610066578063c25fcdff1461020b578063dfc98ae81461021e578063e2af398014610231578063fde89b641461024457600080fd5b80637f8d6fb9146101bb57806387fc1b25146101ce5780638da5cb5b146101e1578063c1907c9b146101f457600080fd5b80634f5539c0116100d35780634f5539c0146101355780635fbe4d1d146101485780636868c6b9146101785780636c7f457d1461019957600080fd5b806310404d34146100fa578063364b6f631461010f578063485cc95514610122575b600080fd5b61010d610108366004611036565b610257565b005b61010d61011d3660046110c2565b61032e565b61010d6101303660046110f2565b610374565b61010d610143366004611120565b6103e0565b60025461015b906001600160a01b031681565b6040516001600160a01b0390911681526020015b60405180910390f35b61018b6101863660046111fe565b61040f565b60405161016f929190611295565b6101ac6101a73660046112b4565b61068e565b60405161016f939291906112d8565b61010d6101c93660046112b4565b610743565b61010d6101dc36600461130c565b61078f565b60015461015b906001600160a01b031681565b6101fd60035481565b60405190815260200161016f565b61010d61021936600461137a565b6107f8565b61010d61022c3660046113cf565b61085e565b60045461015b906001600160a01b031681565b61010d6102523660046113cf565b6109c0565b6004546001600160a01b031633146102ca5760405162461bcd60e51b815260206004820152602b60248201527f4f6e6c792073797374656d4163636f756e74206d61792063616c6c2052656d6f60448201526a7665526573706f6e73657360a81b60648201526084015b60405180910390fd5b60005b63ffffffff81168211156103295760008084848463ffffffff168181106102f6576102f6611402565b90506020020135815260200190815260200160002060006103179190610fe0565b806103218161142e565b9150506102cd565b505050565b6001546001600160a01b031633146103585760405162461bcd60e51b81526004016102c190611453565b600254610370906001600160a01b0316308385610b10565b5050565b6001546001600160a01b031633148061039657506001546001600160a01b0316155b6103b25760405162461bcd60e51b81526004016102c190611453565b600180546001600160a01b039384166001600160a01b03199182161790915560048054929093169116179055565b6001546001600160a01b0316331461040a5760405162461bcd60e51b81526004016102c190611453565b600355565b336000908152600560205260408120546060908290819083906001600160a01b031661047d5760405162461bcd60e51b815260206004820152601f60248201527f43616c6c696e6720636f6e7472616374206e6f7420726567697374657265640060448201526064016102c1565b3360009081526005602052604081206002015490036104d057600560405180604001604052806013815260200172125b9cdd59999a58da595b9d0818dc99591a5d606a1b81525094509450505050610687565b3360009081526005602052604081206002018054600192906104f3908490611477565b909155505060405160009061050e9089908990602001611490565b6040516020818303038152906040528051906020012090506000338260405160200161053b9291906114b6565b60405160208183030381529060405280519060200120905061055c81610b6a565b91965094509250841561057757509194509250610687915050565b6000308360405160200161058c9291906114b6565b6040516020818303038152906040528051906020012090506105ad81610b6a565b9197509550935085156106135760028563ffffffff1610156106035760405162461bcd60e51b815260206004820152600f60248201526e696e76616c696420657272436f646560881b60448201526064016102c1565b5092955090935061068792505050565b6000604051806040016040528060088152602001675f48435f5452494760c01b8152509050600081338d8d604051602001610650939291906114d8565b60408051601f198184030181529082905261066e9291602001611517565b6040516020818303038152906040529050805160208201fd5b9250929050565b600560205260009081526040902080546001820180546001600160a01b0390921692916106ba90611546565b80601f01602080910402602001604051908101604052809291908181526020018280546106e690611546565b80156107335780601f1061070857610100808354040283529160200191610733565b820191906000526020600020905b81548152906001019060200180831161071657829003601f168201915b5050505050908060020154905083565b6001546001600160a01b0316331461076d5760405162461bcd60e51b81526004016102c190611453565b600480546001600160a01b0319166001600160a01b0392909216919091179055565b600354156107c4576000600354826107a79190611580565b6002549091506107c2906001600160a01b0316333084610b10565b505b6001600160a01b038216600090815260056020526040812060020180548392906107ef908490611597565b90915550505050565b6001546001600160a01b031633146108225760405162461bcd60e51b81526004016102c190611453565b6001600160a01b038316600090815260056020526040902080546001600160a01b031916331781556001016108588284836115f8565b50505050565b336000908152600560205260409020546001600160a01b03166108b95760405162461bcd60e51b81526020600482015260136024820152722ab73932b3b4b9ba32b932b21031b0b63632b960691b60448201526064016102c1565b60808110156108ff5760405162461bcd60e51b815260206004820152601260248201527114995cdc1bdb9cd9481d1bdbc81cda1bdc9d60721b60448201526064016102c1565b600061090d828401846116ca565b509250505060028163ffffffff16106109725760405162461bcd60e51b815260206004820152602160248201527f696e76616c696420657272436f646520666f7220507574526573706f6e7365286044820152602960f81b60648201526084016102c1565b600033856040516020016109879291906114b6565b60408051601f19818403018152918152815160209283012060008181529283905291209091506109b88486836115f8565b505050505050565b6004546001600160a01b03163314610a2d5760405162461bcd60e51b815260206004820152602a60248201527f4f6e6c792073797374656d4163636f756e74206d61792063616c6c20507574536044820152697973526573706f6e736560b01b60648201526084016102c1565b6080811015610a735760405162461bcd60e51b815260206004820152601260248201527114995cdc1bdb9cd9481d1bdbc81cda1bdc9d60721b60448201526064016102c1565b6000610a81828401846116ca565b509250505060028163ffffffff161015610afb5760405162461bcd60e51b815260206004820152603560248201527f507574537973526573706f6e73652829206d6179206f6e6c79206265207573656044820152746420666f72206572726f7220726573706f6e73657360581b60648201526084016102c1565b600030856040516020016109879291906114b6565b604080516001600160a01b0385811660248301528416604482015260648082018490528251808303909101815260849091019091526020810180516001600160e01b03166323b872dd60e01b179052610858908590610d7b565b60008060608060008060606000806000808b81526020019081526020016000208054610b9590611546565b80601f0160208091040260200160405190810160405280929190818152602001828054610bc190611546565b8015610c0e5780601f10610be357610100808354040283529160200191610c0e565b820191906000526020600020905b815481529060010190602001808311610bf157829003601f168201915b505050505095508551600103610c515760405162461bcd60e51b81526020600482015260086024820152675f48435f5652465960c01b60448201526064016102c1565b855115610d6c576001945085806020019051810190610c709190611736565b60408051631aab3f0d60e11b81526001600160a01b0380871660048301529185901c60248201819052939950919750939550919350917f0000000000000000000000000000000000000000000000000000000000000000916000918316906335567e1a90604401602060405180830381865afa158015610cf4573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610d1891906117de565b905080610d26856001611597565b14610d5157600097506000965060405180604001604052806002815260200161060f60f31b81525095505b60008d8152602081905260408120610d6891610fe0565b5050505b50929891975095509350505050565b6000610dd0826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b0316610e509092919063ffffffff16565b9050805160001480610df1575080806020019051810190610df191906117f7565b6103295760405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e6044820152691bdd081cdd58d8d9595960b21b60648201526084016102c1565b6060610e5f8484600085610e67565b949350505050565b606082471015610ec85760405162461bcd60e51b815260206004820152602660248201527f416464726573733a20696e73756666696369656e742062616c616e636520666f6044820152651c8818d85b1b60d21b60648201526084016102c1565b600080866001600160a01b03168587604051610ee49190611819565b60006040518083038185875af1925050503d8060008114610f21576040519150601f19603f3d011682016040523d82523d6000602084013e610f26565b606091505b5091509150610f3787838387610f42565b979650505050505050565b60608315610fb1578251600003610faa576001600160a01b0385163b610faa5760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e747261637400000060448201526064016102c1565b5081610e5f565b610e5f8383815115610fc65781518083602001fd5b8060405162461bcd60e51b81526004016102c19190611835565b508054610fec90611546565b6000825580601f10610ffc575050565b601f01602090049060005260206000209081019061101a919061101d565b50565b5b80821115611032576000815560010161101e565b5090565b6000806020838503121561104957600080fd5b823567ffffffffffffffff81111561106057600080fd5b8301601f8101851361107157600080fd5b803567ffffffffffffffff81111561108857600080fd5b8560208260051b840101111561109d57600080fd5b6020919091019590945092505050565b6001600160a01b038116811461101a57600080fd5b600080604083850312156110d557600080fd5b8235915060208301356110e7816110ad565b809150509250929050565b6000806040838503121561110557600080fd5b8235611110816110ad565b915060208301356110e7816110ad565b60006020828403121561113257600080fd5b5035919050565b634e487b7160e01b600052604160045260246000fd5b604051601f8201601f1916810167ffffffffffffffff8111828210171561117857611178611139565b604052919050565b600067ffffffffffffffff82111561119a5761119a611139565b50601f01601f191660200190565b600082601f8301126111b957600080fd5b81356111cc6111c782611180565b61114f565b8181528460208386010111156111e157600080fd5b816020850160208301376000918101602001919091529392505050565b6000806040838503121561121157600080fd5b82359150602083013567ffffffffffffffff81111561122f57600080fd5b61123b858286016111a8565b9150509250929050565b60005b83811015611260578181015183820152602001611248565b50506000910152565b60008151808452611281816020860160208601611245565b601f01601f19169290920160200192915050565b63ffffffff83168152604060208201526000610e5f6040830184611269565b6000602082840312156112c657600080fd5b81356112d1816110ad565b9392505050565b6001600160a01b03841681526060602082018190526000906112fc90830185611269565b9050826040830152949350505050565b6000806040838503121561131f57600080fd5b823561132a816110ad565b946020939093013593505050565b60008083601f84011261134a57600080fd5b50813567ffffffffffffffff81111561136257600080fd5b60208301915083602082850101111561068757600080fd5b60008060006040848603121561138f57600080fd5b833561139a816110ad565b9250602084013567ffffffffffffffff8111156113b657600080fd5b6113c286828701611338565b9497909650939450505050565b6000806000604084860312156113e457600080fd5b83359250602084013567ffffffffffffffff8111156113b657600080fd5b634e487b7160e01b600052603260045260246000fd5b634e487b7160e01b600052601160045260246000fd5b600063ffffffff821663ffffffff810361144a5761144a611418565b60010192915050565b6020808252600a908201526927b7363c9037bbb732b960b11b604082015260600190565b8181038181111561148a5761148a611418565b92915050565b828152600082516114a8816020850160208701611245565b919091016020019392505050565b60609290921b6bffffffffffffffffffffffff19168252601482015260340190565b6bffffffffffffffffffffffff198460601b16815282601482015260008251611508816034850160208701611245565b91909101603401949350505050565b60008351611529818460208801611245565b83519083019061153d818360208801611245565b01949350505050565b600181811c9082168061155a57607f821691505b60208210810361157a57634e487b7160e01b600052602260045260246000fd5b50919050565b808202811582820484141761148a5761148a611418565b8082018082111561148a5761148a611418565b601f82111561032957806000526020600020601f840160051c810160208510156115d15750805b601f840160051c820191505b818110156115f157600081556001016115dd565b5050505050565b67ffffffffffffffff83111561161057611610611139565b6116248361161e8354611546565b836115aa565b6000601f84116001811461165857600085156116405750838201355b600019600387901b1c1916600186901b1783556115f1565b600083815260209020601f19861690835b828110156116895786850135825560209485019460019092019101611669565b50868210156116a65760001960f88860031b161c19848701351681555b505060018560011b0183555050505050565b63ffffffff8116811461101a57600080fd5b600080600080608085870312156116e057600080fd5b84356116eb816110ad565b9350602085013592506040850135611702816116b8565b9150606085013567ffffffffffffffff81111561171e57600080fd5b61172a878288016111a8565b91505092959194509250565b6000806000806080858703121561174c57600080fd5b8451611757816110ad565b60208601516040870151919550935061176f816116b8565b606086015190925067ffffffffffffffff81111561178c57600080fd5b8501601f8101871361179d57600080fd5b80516117ab6111c782611180565b8181528860208385010111156117c057600080fd5b6117d1826020830160208601611245565b9598949750929550505050565b6000602082840312156117f057600080fd5b5051919050565b60006020828403121561180957600080fd5b815180151581146112d157600080fd5b6000825161182b818460208701611245565b9190910192915050565b6020815260006112d1602083018461126956fea2646970667358221220debfb5c9322353354ac5f925294b468c260d1f7b6643a06bcb3251727f6d13d664736f6c634300081a00330000000000000000000000005ff137d4b0fdcd49dca30c7cf57e578a026d27890000000000000000000000001c64ec0a5e2c58295c3208a63209a2a719df68d8", - "nonce": "0x51", + "nonce": "0x67", "chainId": "0x70d2" }, "additionalContracts": [], "isFixedGasLimit": false }, { - "hash": "0x25b92c88d66cd1571eddc3d01dc00c8ef01e14fb32880da7975615745608f7f4", - "transactionType": "CREATE", - "contractName": "HybridAccount", - "contractAddress": "0xbaf5556baef47de089e87de06f542aba243f61c7", - "function": null, + "hash": "0x998f709cd3ba49b0764c7396731ce596b2091d103149d3a603eb2f740588de83", + "transactionType": "CALL", + "contractName": null, + "contractAddress": "0x3dd6ee2e539ccd7eab881173fb704f766e877848", + "function": "createAccount(address,uint256)", "arguments": [ - "0x5FF137D4b0FDCD49DcA30c7CF57E578a026d2789", - "0x1c64EC0A5E2C58295c3208a63209A2A719dF68D8" + "0xD538DAed647eb02E71a9E810afF855D013FD493C", + "9012365" ], "transaction": { "from": "0xd538daed647eb02e71a9e810aff855d013fd493c", - "gas": "0x2437ea", + "to": "0x3dd6ee2e539ccd7eab881173fb704f766e877848", + "gas": "0x359a2", "value": "0x0", - "input": "0x60e06040523060805234801561001457600080fd5b5060405161218a38038061218a8339810160408190526100339161012c565b6001600160a01b0380831660a052811660c05261004e610055565b5050610166565b600054610100900460ff16156100c15760405162461bcd60e51b815260206004820152602760248201527f496e697469616c697a61626c653a20636f6e747261637420697320696e697469604482015266616c697a696e6760c81b606482015260840160405180910390fd5b60005460ff90811614610112576000805460ff191660ff9081179091556040519081527f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb38474024989060200160405180910390a15b565b6001600160a01b038116811461012957600080fd5b50565b6000806040838503121561013f57600080fd5b825161014a81610114565b602084015190925061015b81610114565b809150509250929050565b60805160a05160c051611f9a6101f0600039600081816103cd015281816109660152610a2b015260008181610348015281816106d50152818161075601528181610bb201528181610c5301528181610cc001528181610f3701526111960152600081816105d801528181610618015281816107e70152818161082701526108ba0152611f9a6000f3fe6080604052600436106101385760003560e01c8063839f8457116100ab578063bd3ff2d71161006f578063bd3ff2d7146103bb578063c399ec88146103ef578063c4d66de814610404578063d087d28814610424578063efae5edc14610439578063f23a6e611461045957600080fd5b8063839f8457146102d35780638da5cb5b14610301578063b0d691fe14610339578063b61d27f61461036c578063bc197c811461038c57600080fd5b80633659cfe6116100fd5780633659cfe6146102355780633a871cdd146102555780634a58db19146102835780634d44560d1461028b5780634f1ef286146102ab57806352d1902d146102be57600080fd5b806223de291461014457806301ffc9a71461016b578063150b7a02146101a057806318dfb3c7146101e55780633122b07e1461020557600080fd5b3661013f57005b600080fd5b34801561015057600080fd5b5061016961015f36600461171d565b5050505050505050565b005b34801561017757600080fd5b5061018b6101863660046117d1565b610486565b60405190151581526020015b60405180910390f35b3480156101ac57600080fd5b506101cc6101bb3660046117fb565b630a85bd0160e11b95945050505050565b6040516001600160e01b03199091168152602001610197565b3480156101f157600080fd5b506101696102003660046118b1565b6104d8565b34801561021157600080fd5b5061018b610220366004611920565b60016020526000908152604090205460ff1681565b34801561024157600080fd5b50610169610250366004611920565b6105ce565b34801561026157600080fd5b5061027561027036600461193d565b6106ad565b604051908152602001610197565b6101696106d3565b34801561029757600080fd5b506101696102a6366004611990565b61074c565b6101696102b9366004611a7f565b6107dd565b3480156102ca57600080fd5b506102756108ad565b3480156102df57600080fd5b506102f36102ee366004611ace565b610960565b604051610197929190611b4e565b34801561030d57600080fd5b50600254610321906001600160a01b031681565b6040516001600160a01b039091168152602001610197565b34801561034557600080fd5b507f0000000000000000000000000000000000000000000000000000000000000000610321565b34801561037857600080fd5b50610169610387366004611b6d565b610b43565b34801561039857600080fd5b506101cc6103a7366004611bbc565b63bc197c8160e01b98975050505050505050565b3480156103c757600080fd5b506103217f000000000000000000000000000000000000000000000000000000000000000081565b3480156103fb57600080fd5b50610275610b92565b34801561041057600080fd5b5061016961041f366004611920565b610c23565b34801561043057600080fd5b50610275610c2c565b34801561044557600080fd5b50610169610454366004611c64565b610c82565b34801561046557600080fd5b506101cc610474366004611ca2565b63f23a6e6160e01b9695505050505050565b60006001600160e01b03198216630a85bd0160e11b14806104b757506001600160e01b03198216630271189760e51b145b806104d257506001600160e01b031982166301ffc9a760e01b145b92915050565b6104e0610cb5565b82811461052a5760405162461bcd60e51b815260206004820152601360248201527277726f6e67206172726179206c656e6774687360681b60448201526064015b60405180910390fd5b60005b838110156105c7576105bf85858381811061054a5761054a611d1d565b905060200201602081019061055f9190611920565b600085858581811061057357610573611d1d565b90506020028101906105859190611d33565b8080601f016020809104026020016040519081016040528093929190818152602001838380828437600092019190915250610d4492505050565b60010161052d565b5050505050565b6001600160a01b037f00000000000000000000000000000000000000000000000000000000000000001630036106165760405162461bcd60e51b815260040161052190611d79565b7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031661065f600080516020611f1e833981519152546001600160a01b031690565b6001600160a01b0316146106855760405162461bcd60e51b815260040161052190611dc5565b61068e81610db4565b604080516000808252602082019092526106aa91839190610dbc565b50565b60006106b7610f2c565b6106c18484610fa4565b90506106cc8261104a565b9392505050565b7f000000000000000000000000000000000000000000000000000000000000000060405163b760faf960e01b81523060048201526001600160a01b03919091169063b760faf99034906024016000604051808303818588803b15801561073857600080fd5b505af11580156105c7573d6000803e3d6000fd5b610754611097565b7f000000000000000000000000000000000000000000000000000000000000000060405163040b850f60e31b81526001600160a01b03848116600483015260248201849052919091169063205c287890604401600060405180830381600087803b1580156107c157600080fd5b505af11580156107d5573d6000803e3d6000fd5b505050505050565b6001600160a01b037f00000000000000000000000000000000000000000000000000000000000000001630036108255760405162461bcd60e51b815260040161052190611d79565b7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031661086e600080516020611f1e833981519152546001600160a01b031690565b6001600160a01b0316146108945760405162461bcd60e51b815260040161052190611dc5565b61089d82610db4565b6108a982826001610dbc565b5050565b6000306001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000161461094d5760405162461bcd60e51b815260206004820152603860248201527f555550535570677261646561626c653a206d757374206e6f742062652063616c60448201527f6c6564207468726f7567682064656c656761746563616c6c00000000000000006064820152608401610521565b50600080516020611f1e83398151915290565b600060607f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03166109d35760405162461bcd60e51b815260206004820152601660248201527512195b1c195c881859191c995cdcc81b9bdd081cd95d60521b6044820152606401610521565b3360009081526001602052604090205460ff16610a265760405162461bcd60e51b815260206004820152601160248201527014195c9b5a5cdcda5bdb8819195b9a5959607a1b6044820152606401610521565b6040517f000000000000000000000000000000000000000000000000000000000000000090610a76908690339060200191825260601b6bffffffffffffffffffffffff1916602082015260340190565b604051602081830303815290604052805190602001209450610ab86040518060400160405280600981526020016803ab9b2b935b2bc9d160bd1b8152506110e8565b610ac18561112b565b604051636868c6b960e01b81526001600160a01b03821690636868c6b990610aef9088908890600401611e11565b6000604051808303816000875af1158015610b0e573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f19168201604052610b369190810190611e2a565b92509250505b9250929050565b610b4b610cb5565b610b8c848484848080601f016020809104026020016040519081016040528093929190818152602001838380828437600092019190915250610d4492505050565b50505050565b6040516370a0823160e01b81523060048201526000906001600160a01b037f000000000000000000000000000000000000000000000000000000000000000016906370a08231906024015b602060405180830381865afa158015610bfa573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610c1e9190611ebf565b905090565b6106aa81611170565b604051631aab3f0d60e11b8152306004820152600060248201819052906001600160a01b037f000000000000000000000000000000000000000000000000000000000000000016906335567e1a90604401610bdd565b610c8a610cb5565b6001600160a01b03919091166000908152600160205260409020805460ff1916911515919091179055565b336001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000161480610cf657506002546001600160a01b031633145b610d425760405162461bcd60e51b815260206004820181905260248201527f6163636f756e743a206e6f74204f776e6572206f7220456e747279506f696e746044820152606401610521565b565b600080846001600160a01b03168484604051610d609190611ed8565b60006040518083038185875af1925050503d8060008114610d9d576040519150601f19603f3d011682016040523d82523d6000602084013e610da2565b606091505b5091509150816105c757805160208201fd5b6106aa611097565b7f4910fdfa16fed3260ed0e7147f7cc6da11a60208b5b9406d12a635614ffd91435460ff1615610df457610def836111e0565b505050565b826001600160a01b03166352d1902d6040518163ffffffff1660e01b8152600401602060405180830381865afa925050508015610e4e575060408051601f3d908101601f19168201909252610e4b91810190611ebf565b60015b610eb15760405162461bcd60e51b815260206004820152602e60248201527f45524331393637557067726164653a206e657720696d706c656d656e7461746960448201526d6f6e206973206e6f74205555505360901b6064820152608401610521565b600080516020611f1e8339815191528114610f205760405162461bcd60e51b815260206004820152602960248201527f45524331393637557067726164653a20756e737570706f727465642070726f786044820152681a58589b195555525160ba1b6064820152608401610521565b50610def83838361127c565b336001600160a01b037f00000000000000000000000000000000000000000000000000000000000000001614610d425760405162461bcd60e51b815260206004820152601c60248201527f6163636f756e743a206e6f742066726f6d20456e747279506f696e74000000006044820152606401610521565b7f19457468657265756d205369676e6564204d6573736167653a0a3332000000006000908152601c829052603c8120611021610fe4610140860186611d33565b8080601f01602080910402602001604051908101604052809392919081815260200183838082843760009201919091525085939250506112a19050565b6002546001600160a01b039081169116146110405760019150506104d2565b5060009392505050565b80156106aa57604051600090339060001990849084818181858888f193505050503d80600081146105c7576040519150601f19603f3d011682016040523d82523d6000602084013e6105c7565b6002546001600160a01b03163314806110af57503330145b610d425760405162461bcd60e51b815260206004820152600a60248201526937b7363c9037bbb732b960b11b6044820152606401610521565b6106aa816040516024016110fc9190611ef4565b60408051601f198184030181529190526020810180516001600160e01b031663104c13eb60e21b1790526112c5565b6106aa8160405160240161114191815260200190565b60408051601f198184030181529190526020810180516001600160e01b03166327b7cf8560e01b1790526112c5565b600280546001600160a01b0319166001600160a01b0383811691821790925560405190917f000000000000000000000000000000000000000000000000000000000000000016907f9b59b00fd640e59bf0e3692231b0a9c9637a5dea0c4b2a681c2987883c65ea9d90600090a350565b6001600160a01b0381163b61124d5760405162461bcd60e51b815260206004820152602d60248201527f455243313936373a206e657720696d706c656d656e746174696f6e206973206e60448201526c1bdd08184818dbdb9d1c9858dd609a1b6064820152608401610521565b600080516020611f1e83398151915280546001600160a01b0319166001600160a01b0392909216919091179055565b611285836112ce565b6000825111806112925750805b15610def57610b8c838361130e565b60008060006112b08585611333565b915091506112bd81611375565b509392505050565b6106aa816114bf565b6112d7816111e0565b6040516001600160a01b038216907fbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b90600090a250565b60606106cc8383604051806060016040528060278152602001611f3e602791396114e0565b60008082516041036113695760208301516040840151606085015160001a61135d87828585611558565b94509450505050610b3c565b50600090506002610b3c565b600081600481111561138957611389611f07565b036113915750565b60018160048111156113a5576113a5611f07565b036113f25760405162461bcd60e51b815260206004820152601860248201527f45434453413a20696e76616c6964207369676e617475726500000000000000006044820152606401610521565b600281600481111561140657611406611f07565b036114535760405162461bcd60e51b815260206004820152601f60248201527f45434453413a20696e76616c6964207369676e6174757265206c656e677468006044820152606401610521565b600381600481111561146757611467611f07565b036106aa5760405162461bcd60e51b815260206004820152602260248201527f45434453413a20696e76616c6964207369676e6174757265202773272076616c604482015261756560f01b6064820152608401610521565b80516a636f6e736f6c652e6c6f67602083016000808483855afa5050505050565b6060600080856001600160a01b0316856040516114fd9190611ed8565b600060405180830381855af49150503d8060008114611538576040519150601f19603f3d011682016040523d82523d6000602084013e61153d565b606091505b509150915061154e8683838761161c565b9695505050505050565b6000807f7fffffffffffffffffffffffffffffff5d576e7357a4501ddfe92f46681b20a083111561158f5750600090506003611613565b6040805160008082526020820180845289905260ff881692820192909252606081018690526080810185905260019060a0016020604051602081039080840390855afa1580156115e3573d6000803e3d6000fd5b5050604051601f1901519150506001600160a01b03811661160c57600060019250925050611613565b9150600090505b94509492505050565b6060831561168b578251600003611684576001600160a01b0385163b6116845760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e74726163740000006044820152606401610521565b5081611695565b611695838361169d565b949350505050565b8151156116ad5781518083602001fd5b8060405162461bcd60e51b81526004016105219190611ef4565b6001600160a01b03811681146106aa57600080fd5b60008083601f8401126116ee57600080fd5b5081356001600160401b0381111561170557600080fd5b602083019150836020828501011115610b3c57600080fd5b60008060008060008060008060c0898b03121561173957600080fd5b8835611744816116c7565b97506020890135611754816116c7565b96506040890135611764816116c7565b95506060890135945060808901356001600160401b0381111561178657600080fd5b6117928b828c016116dc565b90955093505060a08901356001600160401b038111156117b157600080fd5b6117bd8b828c016116dc565b999c989b5096995094979396929594505050565b6000602082840312156117e357600080fd5b81356001600160e01b0319811681146106cc57600080fd5b60008060008060006080868803121561181357600080fd5b853561181e816116c7565b9450602086013561182e816116c7565b93506040860135925060608601356001600160401b0381111561185057600080fd5b61185c888289016116dc565b969995985093965092949392505050565b60008083601f84011261187f57600080fd5b5081356001600160401b0381111561189657600080fd5b6020830191508360208260051b8501011115610b3c57600080fd5b600080600080604085870312156118c757600080fd5b84356001600160401b038111156118dd57600080fd5b6118e98782880161186d565b90955093505060208501356001600160401b0381111561190857600080fd5b6119148782880161186d565b95989497509550505050565b60006020828403121561193257600080fd5b81356106cc816116c7565b60008060006060848603121561195257600080fd5b83356001600160401b0381111561196857600080fd5b8401610160818703121561197b57600080fd5b95602085013595506040909401359392505050565b600080604083850312156119a357600080fd5b82356119ae816116c7565b946020939093013593505050565b634e487b7160e01b600052604160045260246000fd5b604051601f8201601f191681016001600160401b03811182821017156119fa576119fa6119bc565b604052919050565b60006001600160401b03821115611a1b57611a1b6119bc565b50601f01601f191660200190565b600082601f830112611a3a57600080fd5b8135611a4d611a4882611a02565b6119d2565b818152846020838601011115611a6257600080fd5b816020850160208301376000918101602001919091529392505050565b60008060408385031215611a9257600080fd5b8235611a9d816116c7565b915060208301356001600160401b03811115611ab857600080fd5b611ac485828601611a29565b9150509250929050565b60008060408385031215611ae157600080fd5b8235915060208301356001600160401b03811115611ab857600080fd5b60005b83811015611b19578181015183820152602001611b01565b50506000910152565b60008151808452611b3a816020860160208601611afe565b601f01601f19169290920160200192915050565b63ffffffff831681526040602082015260006116956040830184611b22565b60008060008060608587031215611b8357600080fd5b8435611b8e816116c7565b93506020850135925060408501356001600160401b03811115611bb057600080fd5b611914878288016116dc565b60008060008060008060008060a0898b031215611bd857600080fd5b8835611be3816116c7565b97506020890135611bf3816116c7565b965060408901356001600160401b03811115611c0e57600080fd5b611c1a8b828c0161186d565b90975095505060608901356001600160401b03811115611c3957600080fd5b611c458b828c0161186d565b90955093505060808901356001600160401b038111156117b157600080fd5b60008060408385031215611c7757600080fd5b8235611c82816116c7565b915060208301358015158114611c9757600080fd5b809150509250929050565b60008060008060008060a08789031215611cbb57600080fd5b8635611cc6816116c7565b95506020870135611cd6816116c7565b9450604087013593506060870135925060808701356001600160401b03811115611cff57600080fd5b611d0b89828a016116dc565b979a9699509497509295939492505050565b634e487b7160e01b600052603260045260246000fd5b6000808335601e19843603018112611d4a57600080fd5b8301803591506001600160401b03821115611d6457600080fd5b602001915036819003821315610b3c57600080fd5b6020808252602c908201527f46756e6374696f6e206d7573742062652063616c6c6564207468726f7567682060408201526b19195b1959d85d1958d85b1b60a21b606082015260800190565b6020808252602c908201527f46756e6374696f6e206d7573742062652063616c6c6564207468726f7567682060408201526b6163746976652070726f787960a01b606082015260800190565b8281526040602082015260006116956040830184611b22565b60008060408385031215611e3d57600080fd5b825163ffffffff81168114611e5157600080fd5b60208401519092506001600160401b03811115611e6d57600080fd5b8301601f81018513611e7e57600080fd5b8051611e8c611a4882611a02565b818152866020838501011115611ea157600080fd5b611eb2826020830160208601611afe565b8093505050509250929050565b600060208284031215611ed157600080fd5b5051919050565b60008251611eea818460208701611afe565b9190910192915050565b6020815260006106cc6020830184611b22565b634e487b7160e01b600052602160045260246000fdfe360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc416464726573733a206c6f772d6c6576656c2064656c65676174652063616c6c206661696c6564a26469706673582212209949ccf2f9025c66ec42d85cf18f9e7af9175a74216a3d10dc6fef32c76e267464736f6c634300081a00330000000000000000000000005ff137d4b0fdcd49dca30c7cf57e578a026d27890000000000000000000000001c64ec0a5e2c58295c3208a63209a2a719df68d8", - "nonce": "0x52", + "input": "0x5fbfb9cf000000000000000000000000d538daed647eb02e71a9e810aff855d013fd493c000000000000000000000000000000000000000000000000000000000089848d", + "nonce": "0x68", "chainId": "0x70d2" }, - "additionalContracts": [], + "additionalContracts": [ + { + "transactionType": "CREATE2", + "address": "0x19ec35e5d5e26ebbf1ac2611c2efc7acc8f9fab5", + "initCode": "0x60806040526040516104e13803806104e1833981016040819052610022916102de565b61002e82826000610035565b50506103fb565b61003e83610061565b60008251118061004b5750805b1561005c5761005a83836100a1565b505b505050565b61006a816100cd565b6040516001600160a01b038216907fbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b90600090a250565b60606100c683836040518060600160405280602781526020016104ba60279139610180565b9392505050565b6001600160a01b0381163b61013f5760405162461bcd60e51b815260206004820152602d60248201527f455243313936373a206e657720696d706c656d656e746174696f6e206973206e60448201526c1bdd08184818dbdb9d1c9858dd609a1b60648201526084015b60405180910390fd5b7f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc80546001600160a01b0319166001600160a01b0392909216919091179055565b6060600080856001600160a01b03168560405161019d91906103ac565b600060405180830381855af49150503d80600081146101d8576040519150601f19603f3d011682016040523d82523d6000602084013e6101dd565b606091505b5090925090506101ef868383876101f9565b9695505050505050565b60608315610268578251600003610261576001600160a01b0385163b6102615760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e74726163740000006044820152606401610136565b5081610272565b610272838361027a565b949350505050565b81511561028a5781518083602001fd5b8060405162461bcd60e51b815260040161013691906103c8565b634e487b7160e01b600052604160045260246000fd5b60005b838110156102d55781810151838201526020016102bd565b50506000910152565b600080604083850312156102f157600080fd5b82516001600160a01b038116811461030857600080fd5b60208401519092506001600160401b038082111561032557600080fd5b818501915085601f83011261033957600080fd5b81518181111561034b5761034b6102a4565b604051601f8201601f19908116603f01168101908382118183101715610373576103736102a4565b8160405282815288602084870101111561038c57600080fd5b61039d8360208301602088016102ba565b80955050505050509250929050565b600082516103be8184602087016102ba565b9190910192915050565b60208152600082518060208401526103e78160408501602087016102ba565b601f01601f19169190910160400192915050565b60b1806104096000396000f3fe608060405236601057600e6013565b005b600e5b601f601b6021565b6058565b565b600060537f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc546001600160a01b031690565b905090565b3660008037600080366000845af43d6000803e8080156076573d6000f35b3d6000fdfea2646970667358221220b1c2d4337feb913e19cf66a7fdab13832aa3e16dd7abd3391cf09c3011a5a46664736f6c63430008190033416464726573733a206c6f772d6c6576656c2064656c65676174652063616c6c206661696c65640000000000000000000000003d3541c4c0e53c79d849db25d7520cd7d9b4a92400000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000024c4d66de8000000000000000000000000d538daed647eb02e71a9e810aff855d013fd493c00000000000000000000000000000000000000000000000000000000" + } + ], "isFixedGasLimit": false }, { - "hash": "0x82452cf683a3879a0f315682a122f120ad90d9aa9ccb684099504e03fcdb5c90", + "hash": "0xa8f5d56cf6136ff104d88eb56d8233c3351ce17ffafed1b56ee2f38d96bba2f8", "transactionType": "CALL", - "contractName": "HybridAccount", - "contractAddress": "0xbaf5556baef47de089e87de06f542aba243f61c7", - "function": "initialize(address)", + "contractName": null, + "contractAddress": "0x5ff137d4b0fdcd49dca30c7cf57e578a026d2789", + "function": "depositTo(address)", "arguments": [ - "0xD538DAed647eb02E71a9E810afF855D013FD493C" + "0x19EC35e5D5E26ebBf1ac2611C2Efc7Acc8F9Fab5" ], "transaction": { "from": "0xd538daed647eb02e71a9e810aff855d013fd493c", - "to": "0xbaf5556baef47de089e87de06f542aba243f61c7", - "gas": "0xf59f", - "value": "0x0", - "input": "0xc4d66de8000000000000000000000000d538daed647eb02e71a9e810aff855d013fd493c", - "nonce": "0x53", + "to": "0x5ff137d4b0fdcd49dca30c7cf57e578a026d2789", + "gas": "0x10670", + "value": "0x38d7ea4c68000", + "input": "0xb760faf900000000000000000000000019ec35e5d5e26ebbf1ac2611c2efc7acc8f9fab5", + "nonce": "0x69", "chainId": "0x70d2" }, "additionalContracts": [], "isFixedGasLimit": false }, { - "hash": "0x5700c36395b8b8169c6c0c130c96a9de6aa159bcb6984141b4a3af50018be82d", + "hash": "0x71b3b5ac788684d4259729415f5f8f167ae34c4caa8a9465b007b111fb419037", "transactionType": "CALL", "contractName": "HCHelper", - "contractAddress": "0x63a774fefcef04d6e138edbcb9ec85cfb7e2c933", + "contractAddress": "0x446559ce4bfade99c036c43f861af681a10433b9", "function": "AddCredit(address,uint256)", "arguments": [ - "0xbaF5556Baef47de089E87de06f542AbA243f61c7", + "0x19EC35e5D5E26ebBf1ac2611C2Efc7Acc8F9Fab5", "100" ], "transaction": { "from": "0xd538daed647eb02e71a9e810aff855d013fd493c", - "to": "0x63a774fefcef04d6e138edbcb9ec85cfb7e2c933", + "to": "0x446559ce4bfade99c036c43f861af681a10433b9", "gas": "0x108d0", "value": "0x0", - "input": "0x87fc1b25000000000000000000000000baf5556baef47de089e87de06f542aba243f61c70000000000000000000000000000000000000000000000000000000000000064", - "nonce": "0x54", + "input": "0x87fc1b2500000000000000000000000019ec35e5d5e26ebbf1ac2611c2efc7acc8f9fab50000000000000000000000000000000000000000000000000000000000000064", + "nonce": "0x6a", "chainId": "0x70d2" }, "additionalContracts": [], "isFixedGasLimit": false }, { - "hash": "0x5e0dd111d601c3b0e99050ea0a44de27936d08b824e0244c1d611ea9a6cefa49", + "hash": "0x42cb717036f0e8c2d118f7d6a3e9f0593fc1845187f22046e7cee19f29ef1fe9", "transactionType": "CALL", - "contractName": "HybridAccount", - "contractAddress": "0xbaf5556baef47de089e87de06f542aba243f61c7", - "function": "initialize(address)", - "arguments": [ - "0xD538DAed647eb02E71a9E810afF855D013FD493C" - ], + "contractName": "ERC1967Proxy", + "contractAddress": "0x19ec35e5d5e26ebbf1ac2611c2efc7acc8f9fab5", + "function": null, + "arguments": null, "transaction": { "from": "0xd538daed647eb02e71a9e810aff855d013fd493c", - "to": "0xbaf5556baef47de089e87de06f542aba243f61c7", - "gas": "0x8a40", + "to": "0x19ec35e5d5e26ebbf1ac2611c2efc7acc8f9fab5", + "gas": "0xa4a9", "value": "0x0", "input": "0xc4d66de8000000000000000000000000d538daed647eb02e71a9e810aff855d013fd493c", - "nonce": "0x55", + "nonce": "0x6b", "chainId": "0x70d2" }, "additionalContracts": [], @@ -114,156 +119,171 @@ "logs": [], "logsBloom": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", "type": "0x2", - "transactionHash": "0x3b3ce5696b044acfd3342ab7037df109ef2423888ceebf369d702ca74cc03880", + "transactionHash": "0x5c3613b3ac1c593b7d2d653548eeb8cc31e0280b3f60d0dd5b2a00c53429de75", "transactionIndex": "0x1", - "blockHash": "0x57b11e93c9039907ef36fad95bd3b75e7d812e9588d24f96aba611ea4d05e352", - "blockNumber": "0x892907", + "blockHash": "0x65b9bf005c93b8aac61f0c903e483879abe03f53861e3b4569e8f578566eccfb", + "blockNumber": "0x898494", "gasUsed": "0x15dd5f", "effectiveGasPrice": "0xd", "from": "0xd538daed647eb02e71a9e810aff855d013fd493c", "to": null, - "contractAddress": "0x63a774fefcef04d6e138edbcb9ec85cfb7e2c933", + "contractAddress": "0x446559ce4bfade99c036c43f861af681a10433b9", "l1BaseFeeScalar": "0xf4240", "l1BlobBaseFeeScalar": "0x0", - "l1Fee": "0x7b2bdad54315", - "l1GasPrice": "0x877fd348", + "l1Fee": "0x9575a18df386", + "l1GasPrice": "0xa46b2c71", "l1GasUsed": "0xe8b5" }, { "status": "0x1", - "cumulativeGasUsed": "0x3266f1", + "cumulativeGasUsed": "0x18d35a", "logs": [ { - "address": "0xbaf5556baef47de089e87de06f542aba243f61c7", + "address": "0x19ec35e5d5e26ebbf1ac2611c2efc7acc8f9fab5", "topics": [ - "0x7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb3847402498" + "0xbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b", + "0x0000000000000000000000003d3541c4c0e53c79d849db25d7520cd7d9b4a924" ], - "data": "0x00000000000000000000000000000000000000000000000000000000000000ff", - "blockHash": "0x57b11e93c9039907ef36fad95bd3b75e7d812e9588d24f96aba611ea4d05e352", - "blockNumber": "0x892907", - "transactionHash": "0x25b92c88d66cd1571eddc3d01dc00c8ef01e14fb32880da7975615745608f7f4", + "data": "0x", + "blockHash": "0x65b9bf005c93b8aac61f0c903e483879abe03f53861e3b4569e8f578566eccfb", + "blockNumber": "0x898494", + "transactionHash": "0x998f709cd3ba49b0764c7396731ce596b2091d103149d3a603eb2f740588de83", "transactionIndex": "0x2", "logIndex": "0x0", "removed": false + }, + { + "address": "0x19ec35e5d5e26ebbf1ac2611c2efc7acc8f9fab5", + "topics": [ + "0x9b59b00fd640e59bf0e3692231b0a9c9637a5dea0c4b2a681c2987883c65ea9d", + "0x0000000000000000000000005ff137d4b0fdcd49dca30c7cf57e578a026d2789", + "0x000000000000000000000000d538daed647eb02e71a9e810aff855d013fd493c" + ], + "data": "0x", + "blockHash": "0x65b9bf005c93b8aac61f0c903e483879abe03f53861e3b4569e8f578566eccfb", + "blockNumber": "0x898494", + "transactionHash": "0x998f709cd3ba49b0764c7396731ce596b2091d103149d3a603eb2f740588de83", + "transactionIndex": "0x2", + "logIndex": "0x1", + "removed": false } ], - "logsBloom": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000080000000000000000000000000000000000000000000080000000000000000000000000000000000000000000000400000000000000000000008000000000000000000000000400000000000000040000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", + "logsBloom": "0x00000000000000000000000000000000400000000000100000000010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002000008000000000000000000000000000000000000000000000000000000000000000000000000004000820000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000000000000000800000000000000000000002000000080000000020000000000108000000000008000000000000010000000000000000000000000000000000000000000000000000000000000000000008000000000000", "type": "0x2", - "transactionHash": "0x25b92c88d66cd1571eddc3d01dc00c8ef01e14fb32880da7975615745608f7f4", + "transactionHash": "0x998f709cd3ba49b0764c7396731ce596b2091d103149d3a603eb2f740588de83", "transactionIndex": "0x2", - "blockHash": "0x57b11e93c9039907ef36fad95bd3b75e7d812e9588d24f96aba611ea4d05e352", - "blockNumber": "0x892907", - "gasUsed": "0x1bde5c", + "blockHash": "0x65b9bf005c93b8aac61f0c903e483879abe03f53861e3b4569e8f578566eccfb", + "blockNumber": "0x898494", + "gasUsed": "0x24ac5", "effectiveGasPrice": "0xd", "from": "0xd538daed647eb02e71a9e810aff855d013fd493c", - "to": null, - "contractAddress": "0xbaf5556baef47de089e87de06f542aba243f61c7", + "to": "0x3dd6ee2e539ccd7eab881173fb704f766e877848", + "contractAddress": null, "l1BaseFeeScalar": "0xf4240", "l1BlobBaseFeeScalar": "0x0", - "l1Fee": "0x964329b85ff9", - "l1GasPrice": "0x877fd348", - "l1GasUsed": "0x11be4" + "l1Fee": "0x4039dd5c240", + "l1GasPrice": "0xa46b2c71", + "l1GasUsed": "0x640" }, { "status": "0x1", - "cumulativeGasUsed": "0x3318c5", + "cumulativeGasUsed": "0x1986cc", "logs": [ { - "address": "0xbaf5556baef47de089e87de06f542aba243f61c7", + "address": "0x5ff137d4b0fdcd49dca30c7cf57e578a026d2789", "topics": [ - "0x9b59b00fd640e59bf0e3692231b0a9c9637a5dea0c4b2a681c2987883c65ea9d", - "0x0000000000000000000000005ff137d4b0fdcd49dca30c7cf57e578a026d2789", - "0x000000000000000000000000d538daed647eb02e71a9e810aff855d013fd493c" + "0x2da466a7b24304f47e87fa2e1e5a81b9831ce54fec19055ce277ca2f39ba42c4", + "0x00000000000000000000000019ec35e5d5e26ebbf1ac2611c2efc7acc8f9fab5" ], - "data": "0x", - "blockHash": "0x57b11e93c9039907ef36fad95bd3b75e7d812e9588d24f96aba611ea4d05e352", - "blockNumber": "0x892907", - "transactionHash": "0x82452cf683a3879a0f315682a122f120ad90d9aa9ccb684099504e03fcdb5c90", + "data": "0x00000000000000000000000000000000000000000000000000038d7ea4c68000", + "blockHash": "0x65b9bf005c93b8aac61f0c903e483879abe03f53861e3b4569e8f578566eccfb", + "blockNumber": "0x898494", + "transactionHash": "0xa8f5d56cf6136ff104d88eb56d8233c3351ce17ffafed1b56ee2f38d96bba2f8", "transactionIndex": "0x3", - "logIndex": "0x1", + "logIndex": "0x2", "removed": false } ], - "logsBloom": "0x00000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000004000820000000000080000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000800000000000000000008002000000080000000000000400000100000000000008000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", + "logsBloom": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000100000000000000000000000000000000002000000000000000000000000000000000000000000000000000000200000000000080000000000000000000200000000000000000000000000020200000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000", "type": "0x2", - "transactionHash": "0x82452cf683a3879a0f315682a122f120ad90d9aa9ccb684099504e03fcdb5c90", + "transactionHash": "0xa8f5d56cf6136ff104d88eb56d8233c3351ce17ffafed1b56ee2f38d96bba2f8", "transactionIndex": "0x3", - "blockHash": "0x57b11e93c9039907ef36fad95bd3b75e7d812e9588d24f96aba611ea4d05e352", - "blockNumber": "0x892907", - "gasUsed": "0xb1d4", + "blockHash": "0x65b9bf005c93b8aac61f0c903e483879abe03f53861e3b4569e8f578566eccfb", + "blockNumber": "0x898494", + "gasUsed": "0xb372", "effectiveGasPrice": "0xd", "from": "0xd538daed647eb02e71a9e810aff855d013fd493c", - "to": "0xbaf5556baef47de089e87de06f542aba243f61c7", + "to": "0x5ff137d4b0fdcd49dca30c7cf57e578a026d2789", "contractAddress": null, "l1BaseFeeScalar": "0xf4240", "l1BlobBaseFeeScalar": "0x0", - "l1Fee": "0x34edee88200", - "l1GasPrice": "0x877fd348", + "l1Fee": "0x4039dd5c240", + "l1GasPrice": "0xa46b2c71", "l1GasUsed": "0x640" }, { "status": "0x1", - "cumulativeGasUsed": "0x33cdd7", + "cumulativeGasUsed": "0x1a3bde", "logs": [], "logsBloom": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", "type": "0x2", - "transactionHash": "0x5700c36395b8b8169c6c0c130c96a9de6aa159bcb6984141b4a3af50018be82d", + "transactionHash": "0x71b3b5ac788684d4259729415f5f8f167ae34c4caa8a9465b007b111fb419037", "transactionIndex": "0x4", - "blockHash": "0x57b11e93c9039907ef36fad95bd3b75e7d812e9588d24f96aba611ea4d05e352", - "blockNumber": "0x892907", + "blockHash": "0x65b9bf005c93b8aac61f0c903e483879abe03f53861e3b4569e8f578566eccfb", + "blockNumber": "0x898494", "gasUsed": "0xb512", "effectiveGasPrice": "0xd", "from": "0xd538daed647eb02e71a9e810aff855d013fd493c", - "to": "0x63a774fefcef04d6e138edbcb9ec85cfb7e2c933", + "to": "0x446559ce4bfade99c036c43f861af681a10433b9", "contractAddress": null, "l1BaseFeeScalar": "0xf4240", "l1BlobBaseFeeScalar": "0x0", - "l1Fee": "0x34edee88200", - "l1GasPrice": "0x877fd348", + "l1Fee": "0x4039dd5c240", + "l1GasPrice": "0xa46b2c71", "l1GasUsed": "0x640" }, { "status": "0x1", - "cumulativeGasUsed": "0x3431ef", + "cumulativeGasUsed": "0x1ab315", "logs": [ { - "address": "0xbaf5556baef47de089e87de06f542aba243f61c7", + "address": "0x19ec35e5d5e26ebbf1ac2611c2efc7acc8f9fab5", "topics": [ "0x9b59b00fd640e59bf0e3692231b0a9c9637a5dea0c4b2a681c2987883c65ea9d", "0x0000000000000000000000005ff137d4b0fdcd49dca30c7cf57e578a026d2789", "0x000000000000000000000000d538daed647eb02e71a9e810aff855d013fd493c" ], "data": "0x", - "blockHash": "0x57b11e93c9039907ef36fad95bd3b75e7d812e9588d24f96aba611ea4d05e352", - "blockNumber": "0x892907", - "transactionHash": "0x5e0dd111d601c3b0e99050ea0a44de27936d08b824e0244c1d611ea9a6cefa49", + "blockHash": "0x65b9bf005c93b8aac61f0c903e483879abe03f53861e3b4569e8f578566eccfb", + "blockNumber": "0x898494", + "transactionHash": "0x42cb717036f0e8c2d118f7d6a3e9f0593fc1845187f22046e7cee19f29ef1fe9", "transactionIndex": "0x5", - "logIndex": "0x2", + "logIndex": "0x3", "removed": false } ], - "logsBloom": "0x00000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000004000820000000000080000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000800000000000000000008002000000080000000000000400000100000000000008000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", + "logsBloom": "0x00000000000000000000000000000000000000000000100000000010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000004000820000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000800000000000000000000002000000080000000000000000000100000000000008000000000000010000000000000000000000000000000000000000000000000000000000000000000008000000000000", "type": "0x2", - "transactionHash": "0x5e0dd111d601c3b0e99050ea0a44de27936d08b824e0244c1d611ea9a6cefa49", + "transactionHash": "0x42cb717036f0e8c2d118f7d6a3e9f0593fc1845187f22046e7cee19f29ef1fe9", "transactionIndex": "0x5", - "blockHash": "0x57b11e93c9039907ef36fad95bd3b75e7d812e9588d24f96aba611ea4d05e352", - "blockNumber": "0x892907", - "gasUsed": "0x6418", + "blockHash": "0x65b9bf005c93b8aac61f0c903e483879abe03f53861e3b4569e8f578566eccfb", + "blockNumber": "0x898494", + "gasUsed": "0x7737", "effectiveGasPrice": "0xd", "from": "0xd538daed647eb02e71a9e810aff855d013fd493c", - "to": "0xbaf5556baef47de089e87de06f542aba243f61c7", + "to": "0x19ec35e5d5e26ebbf1ac2611c2efc7acc8f9fab5", "contractAddress": null, "l1BaseFeeScalar": "0xf4240", "l1BlobBaseFeeScalar": "0x0", - "l1Fee": "0x34edee88200", - "l1GasPrice": "0x877fd348", + "l1Fee": "0x4039dd5c240", + "l1GasPrice": "0xa46b2c71", "l1GasUsed": "0x640" } ], "libraries": [], "pending": [], "returns": {}, - "timestamp": 1723577641, + "timestamp": 1723624514, "chain": 28882, - "commit": "09d4ff0" + "commit": "86d6e76" } \ No newline at end of file diff --git a/contracts/script/deploy-hybrid-account.s.sol b/contracts/script/deploy-hybrid-account.s.sol index 1c49df9..77a4ec4 100644 --- a/contracts/script/deploy-hybrid-account.s.sol +++ b/contracts/script/deploy-hybrid-account.s.sol @@ -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; @@ -19,6 +24,7 @@ contract DeployExample is Script { function run() public { deployerAddress = vm.addr(deployerPrivateKey); + vm.startBroadcast(deployerPrivateKey); hcHelper = new HCHelper( @@ -26,11 +32,9 @@ contract DeployExample is Script { 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)); @@ -38,7 +42,7 @@ contract DeployExample is Script { // 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(); } } \ No newline at end of file diff --git a/contracts/script/deploy-local.ts b/contracts/script/deploy-local.ts index faac7c6..4ec6eb1 100644 --- a/contracts/script/deploy-local.ts +++ b/contracts/script/deploy-local.ts @@ -1,10 +1,16 @@ import * as fs from "fs"; import * as path from "path"; import * as dotenv from "dotenv"; -import { ethers } from "ethers"; +import {ethers} from "ethers"; import {DEFAULT_SNAP_VERSION, deleteIgnitionDeployments, getLocalIpAddress, isPortInUse} from "./utils"; import {execPromise} from './utils' -import {SimpleAccountFactory__factory, TokenPaymaster__factory, VerifyingPaymaster__factory} from "../typechain-types"; +import { + HybridAccount__factory, + HybridAccountFactory__factory, + SimpleAccountFactory__factory, + TokenPaymaster__factory, + VerifyingPaymaster__factory +} from "../typechain-types"; dotenv.config(); @@ -28,315 +34,275 @@ let aaConfigFile = fs.readFileSync('../snap-account-abstraction-keyring/packages const updateEnvVariable = (key: string, value: string, envPath: string) => { - console.log(`Updating ${key} = ${value}`) - let envFile = fs.readFileSync(envPath, "utf8"); - const regex = new RegExp(`^${key}=.*`, "m"); - if (regex.test(envFile)) { - envFile = envFile.replace(regex, `${key}=${value}`); - } else { - envFile += `\n${key}=${value}`; - } - fs.writeFileSync(envPath, envFile); - dotenv.config(); -}; - -const parseLocalDeployAddresses = () => { - const jsonPath = path.resolve( - __dirname, - "../broadcast/deploy.s.sol/901/run-latest.json" - ); - - try { - const data = fs.readFileSync(jsonPath, "utf8"); - const jsonData = JSON.parse(data); - - const contracts: { contractName: string; address: string }[] = - jsonData.transactions.map((transaction: any) => ({ - contractName: transaction.contractName ?? "", - address: transaction.contractAddress ?? "", - })); - - // const hybridAccount = jsonData.transactions - // .map((transaction: any) => { - // if ( - // transaction.contractName === "HybridAccountFactory" && - // transaction.function === "createAccount(address,uint256)" - // ) { - // return { - // contractName: "HybridAccount", - // address: transaction.additionalContracts[0].address, - // }; - // } - // }) - // .filter((ha: any) => ha); // filter out undefined values - - // contracts.push(...hybridAccount); - - console.log("Parsed JSON data:", contracts); - return contracts; - } catch (err) { - console.error("Error reading or parsing the file:", err); - } -}; - -// TODO: fix .env file loading. Currently .env needs to be in /script directory -async function main() { - try { - if (!isPortInUse(8545) && !isPortInUse(9545)) { - await execPromise( - "pnpm install", - [], - path.resolve(__dirname, "../../boba") - ); - - await execPromise( - "make devnet-hardhat-up", - [], - path.resolve(__dirname, "../../boba") - ); + console.log(`Updating ${key} = ${value}`) + let envFile = fs.readFileSync(envPath, "utf8"); + const regex = new RegExp(`^${key}=.*`, "m"); + if (regex.test(envFile)) { + envFile = envFile.replace(regex, `${key}=${value}`); } else { - console.log("Boba Chain already running, skipping") - } - const fundL2Vars = { - ...process.env, - PRIVATE_KEY: deployKey, - }; - - await execPromise( - "node fundL2.js", - undefined, - path.resolve(__dirname, "../script/"), - fundL2Vars - ); - - console.log("Funding L2 done..."); - - 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.') - } - const baseDeployVars = { - ...process.env, - PRIVATE_KEY: deployKey, - BUNDLER_ADDR: bundlerAddr, - HC_SYS_OWNER: ha1Owner, - DEPLOY_ADDR: deployAddr, - BACKEND_URL, - }; - - await execPromise( - "forge script --json --broadcast --rpc-url http://localhost:9545 deploy.s.sol:DeployExample -vvvvv", - undefined, - path.resolve(__dirname, "./"), - baseDeployVars - ); - - const contracts = parseLocalDeployAddresses(); - const hcHelperAddr = contracts?.find((c) => c.contractName === "HCHelper")?.address; - const hybridAccountAddr = contracts?.find((c) => c.contractName === "HybridAccount")?.address; - - if (!hcHelperAddr || !hybridAccountAddr) { - throw Error("HC Helper not defined!"); + envFile += `\n${key}=${value}`; } + fs.writeFileSync(envPath, envFile); + dotenv.config(); +}; - const entrypoint = contracts?.find((c) => c.contractName === "EntryPoint")?.address - const envVars = { - HC_HELPER_ADDR: contracts?.find((c) => c.contractName === "HCHelper")?.address, - HC_SYS_ACCOUNT: contracts?.find((c) => c.contractName === "HybridAccount")?.address, - HC_SYS_OWNER: ha0Owner, - HC_SYS_PRIVKEY: ha0Privkey, - ENTRY_POINTS: entrypoint, - BUILDER_PRIVKEY: builderPrivkey, - NODE_HTTP: `http://${getLocalIpAddress()}:9545`, - CHAIN_ID: "901", - }; - - await execPromise( - "docker compose up -d --build rundler-hc", - [], - path.resolve(__dirname, "../../rundler-hc/hybrid-compute/"), - { ...process.env, ...envVars } - ); - - deleteIgnitionDeployments(); - - const ignitionOutput = await execPromise( - "npx hardhat ignition deploy ./ignition/modules/TokenPrice.ts --network boba_local", - ["y"], - path.resolve(__dirname, "../"), - { - ...process.env, - HYBRID_ACCOUNT: contracts?.find( - (c) => c.contractName === "HybridAccount" - )?.address, - } +const latestBroadcast = "../broadcast/deploy.s.sol/901/run-latest.json" +const readHybridAccountAddress = () => { + const jsonPath = path.resolve( + __dirname, + latestBroadcast ); - - const tokenPriceMatch = ignitionOutput.match( - /TokenPrice#TokenPrice - (0x[a-fA-F0-9]{40})/ + const jsonContent = JSON.parse(fs.readFileSync(jsonPath, "utf8")); + const transaction = jsonContent.transactions.find( + (tx: any) => tx.transactionType === "CALL" && tx.function === "createAccount(address,uint256)" ); - if (!tokenPriceMatch) { - throw new Error( - "Failed to extract TokenPrice address from Ignition output" - ); + if (!transaction) { + throw new Error("HybridAccount Creation transaction not found in the JSON file"); } - const tokenPriceAddress = tokenPriceMatch[1]; - console.log("TokenPrice Contract deployed to: ", tokenPriceAddress); - console.log('using hybridAcc: ', hybridAccountAddr); - - /** @DEV Permit Caller */ - const abi = ["function PermitCaller(address caller, bool allow) external"]; - const hybridAccount = new ethers.Contract(hybridAccountAddr, abi, l2Wallet); - const tx = await hybridAccount.PermitCaller(tokenPriceAddress, true); - await tx.wait(); - - // Frontend env vars - const frontendEnvPath = path.resolve(__dirname, "../../frontend/.env-local"); - updateEnvVariable( - "VITE_SMART_CONTRACT", - tokenPriceAddress, - frontendEnvPath - ); - updateEnvVariable( - "VITE_RPC_PROVIDER", - "http://localhost:9545", - frontendEnvPath - ); - updateEnvVariable( - "VITE_SNAP_ORIGIN", - "local:http://localhost:8080", - frontendEnvPath - ); - updateEnvVariable( - "VITE_SNAP_VERSION", - DEFAULT_SNAP_VERSION, - frontendEnvPath - ); - - console.log("Frontend ENV vars set..."); - - // Backend env vars - const backendEnvPath = path.resolve(__dirname, "../../backend/.env"); - updateEnvVariable( - "OC_HYBRID_ACCOUNT", - contracts?.find((c) => c.contractName === "HybridAccount")?.address ?? "", - backendEnvPath - ); - - if (!entrypoint) { - throw Error("Entrypoint not defined!") + const create2Tx = transaction.additionalContracts.find((t: any) => { + return t.transactionType === "CREATE2"; + }) + if (!create2Tx) { + throw new Error('Could not find Create2 tx within outer account creation tx: ' + JSON.stringify(transaction)) } + return create2Tx.address; +}; - updateEnvVariable( - "ENTRY_POINTS", - entrypoint, - backendEnvPath - ); - updateEnvVariable("CHAIN_ID", "901", backendEnvPath); - updateEnvVariable("OC_PRIVKEY", deployKey, backendEnvPath); - updateEnvVariable( - "HC_HELPER_ADDR", - hcHelperAddr, - backendEnvPath - ); - - console.log("Backend ENV vars set..."); - - // Contract env vars - const ENTRYPOINT = contracts?.find((c) => c.contractName === "EntryPoint")?.address ?? "" - const contractsEnvPath = path.resolve(__dirname, "../.env"); - updateEnvVariable( - "HYBRID_ACCOUNT", - hybridAccountAddr, - contractsEnvPath - ); - updateEnvVariable( - "ENTRY_POINT", - ENTRYPOINT, - contractsEnvPath - ); - updateEnvVariable( - "TOKEN_PRICE_CONTRACT", - tokenPriceAddress, - contractsEnvPath - ); - updateEnvVariable( - "HC_HELPER_ADDR", - hcHelperAddr, - contractsEnvPath - ); - updateEnvVariable("PRIVATE_KEY", deployKey, contractsEnvPath); - updateEnvVariable( - "CLIENT_ADDR", - contracts?.find((c) => c.contractName === "SimpleAccount")?.address ?? "", - contractsEnvPath - ); - - /** @DEV deploy simple account factory */ - const SimpleAccountFactory = new SimpleAccountFactory__factory(l2Wallet); - const simpleAccountFactoryContract = await SimpleAccountFactory.deploy(entrypoint!); - await simpleAccountFactoryContract.waitForDeployment(); - console.log('SimpleAccountFactory: ', simpleAccountFactoryContract.target) - - /** @DEV deploy verifying paymaster */ - const VerifyingPaymasterFactory = new VerifyingPaymaster__factory(l2Wallet); - const verifyingPaymasterContract = await VerifyingPaymasterFactory.deploy(entrypoint, l2Wallet.address); - await verifyingPaymasterContract.waitForDeployment(); - console.log('Verifying paymaster: ', verifyingPaymasterContract.target) - - /** @DEV deploy the token paymaster */ - const TokenPaymasterFactory = new TokenPaymaster__factory(l2Wallet); - const tokenPaymasterContract = await TokenPaymasterFactory.deploy( - simpleAccountFactoryContract.target, entrypoint, l2Wallet.address); - await tokenPaymasterContract.waitForDeployment(); - console.log('Verifying tokenPaymaster: ', tokenPaymasterContract.target) - - const localConfigRegex = /(\[CHAIN_IDS\.LOCAL\]:\s*{[\s\S]*?entryPoint:\s*')([^']*)(\'[\s\S]*?simpleAccountFactory:\s*')([^']*)(\'[\s\S]*?bobaPaymaster:\s*')([^']*)(\'[\s\S]*?})/; - - aaConfigFile = aaConfigFile.replace(localConfigRegex, (match, before1, oldEntryPoint, middle1, oldSimpleAccountFactory, middle2, oldBobaPaymaster, after) => { - return `${before1}${ENTRYPOINT}${middle1}${simpleAccountFactoryContract.target}${middle2}${tokenPaymasterContract.target}${after}`; - }); - - // Update the AA-config - fs.writeFileSync('../snap-account-abstraction-keyring/packages/snap/src/constants/aa-config.ts', aaConfigFile, 'utf8'); - - // Update LOCAL_ENTRYPOINT - updateEnvVariable( - "LOCAL_ENTRYPOINT", - ENTRYPOINT, - snapEnv +const parseLocalDeployAddresses = () => { + const jsonPath = path.resolve( + __dirname, + latestBroadcast ); - // Update Account Factory - updateEnvVariable( - "LOCAL_SIMPLE_ACCOUNT_FACTORY", - simpleAccountFactoryContract.target.toString(), - snapEnv - ); + try { + const data = fs.readFileSync(jsonPath, "utf8"); + const jsonData = JSON.parse(data); - // Update Account Factory - updateEnvVariable( - "VERIFYING_PAYMASTER_ADDRESS", - verifyingPaymasterContract?.target.toString(), - snapEnv - ); + const contracts: { contractName: string; address: string }[] = + jsonData.transactions.map((transaction: any) => ({ + contractName: transaction.contractName ?? "", + address: transaction.contractAddress ?? "", + })); - // Update Account Factory - updateEnvVariable( - "LOCAL_BOBAPAYMASTER", - tokenPaymasterContract?.target.toString(), - snapEnv - ); + console.log("Parsed JSON data:", contracts); + return contracts; + } catch (err) { + console.error("Error reading or parsing the file:", err); + } +}; - /** @DEV bootstrap frontend, backend and snap */ - await execPromise( - "docker-compose -f docker-compose.local.yml up --build", - [], - path.resolve(__dirname, "../../") - ); - } catch (error) { - console.error(error); - } +// TODO: fix .env file loading. Currently .env needs to be in /script directory +async function main() { + try { + if (!isPortInUse(8545) && !isPortInUse(9545)) { + await execPromise( + "pnpm install", + [], + path.resolve(__dirname, "../../boba") + ); + + await execPromise( + "make devnet-hardhat-up", + [], + path.resolve(__dirname, "../../boba") + ); + } else { + console.log("Boba Chain already running, skipping") + } + const fundL2Vars = { + ...process.env, + PRIVATE_KEY: deployKey, + }; + + await execPromise( + "node fundL2.js", + undefined, + path.resolve(__dirname, "../script/"), + fundL2Vars + ); + + console.log("Funding L2 done..."); + + 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.') + } + const baseDeployVars = { + ...process.env, + PRIVATE_KEY: deployKey, + BUNDLER_ADDR: bundlerAddr, + HC_SYS_OWNER: ha1Owner, + DEPLOY_ADDR: deployAddr, + BACKEND_URL, + }; + + await execPromise( + "forge script --json --broadcast --rpc-url http://localhost:9545 deploy.s.sol:DeployExample -vvvvv", + undefined, + path.resolve(__dirname, "./"), + baseDeployVars + ); + + const contracts = parseLocalDeployAddresses(); + const hcHelperAddr = contracts?.find((c) => c.contractName === "HCHelper")?.address; + const haFactory = contracts?.find((c) => c.contractName === "HybridAccountFactory")?.address; + const saFactory = contracts?.find((c) => c.contractName === "SimpleAccountFactory")?.address; + const tokenPriceAddress = contracts?.find((c) => c.contractName === "TokenPrice")?.address; + const tokenPaymasterAddress = contracts?.find((c) => c.contractName === "TokenPaymaster")?.address; + const verifyingPaymasterContract = contracts?.find((c) => c.contractName === "VerifyingPaymaster")?.address; + const hybridAccountAddr = readHybridAccountAddress(); + + if (!hcHelperAddr || !hybridAccountAddr || !haFactory || !tokenPriceAddress || !tokenPaymasterAddress || !verifyingPaymasterContract || !saFactory) { + throw Error("Some contracts are not defined!"); + } + + const entrypoint = contracts?.find((c) => c.contractName === "EntryPoint")?.address + const envVars = { + HC_HELPER_ADDR: hcHelperAddr, + HC_SYS_ACCOUNT: hybridAccountAddr, + HC_SYS_OWNER: ha0Owner, + HC_SYS_PRIVKEY: ha0Privkey, + ENTRY_POINTS: entrypoint, + BUILDER_PRIVKEY: builderPrivkey, + NODE_HTTP: `http://${getLocalIpAddress()}:9545`, + CHAIN_ID: "901", + }; + + await execPromise( + "docker compose up -d --build rundler-hc", + [], + path.resolve(__dirname, "../../rundler-hc/hybrid-compute/"), + {...process.env, ...envVars} + ); + + // Frontend env vars + const frontendEnvPath = path.resolve(__dirname, "../../frontend/.env-local"); + updateEnvVariable( + "VITE_SMART_CONTRACT", + tokenPriceAddress, + frontendEnvPath + ); + updateEnvVariable( + "VITE_RPC_PROVIDER", + "http://localhost:9545", + frontendEnvPath + ); + updateEnvVariable( + "VITE_SNAP_ORIGIN", + "local:http://localhost:8080", + frontendEnvPath + ); + updateEnvVariable( + "VITE_SNAP_VERSION", + DEFAULT_SNAP_VERSION, + frontendEnvPath + ); + + console.log("Frontend ENV vars set..."); + + // Backend env vars + const backendEnvPath = path.resolve(__dirname, "../../backend/.env"); + updateEnvVariable( + "OC_HYBRID_ACCOUNT", + hybridAccountAddr, + backendEnvPath + ); + + if (!entrypoint) { + throw Error("Entrypoint not defined!") + } + + updateEnvVariable( + "ENTRY_POINTS", + entrypoint, + backendEnvPath + ); + updateEnvVariable("CHAIN_ID", "901", backendEnvPath); + updateEnvVariable("OC_PRIVKEY", deployKey, backendEnvPath); + updateEnvVariable( + "HC_HELPER_ADDR", + hcHelperAddr, + backendEnvPath + ); + + console.log("Backend ENV vars set..."); + + // Contract env vars + const ENTRYPOINT = contracts?.find((c) => c.contractName === "EntryPoint")?.address ?? "" + const contractsEnvPath = path.resolve(__dirname, "../.env"); + updateEnvVariable( + "HYBRID_ACCOUNT", + hybridAccountAddr, + contractsEnvPath + ); + updateEnvVariable( + "ENTRY_POINT", + ENTRYPOINT, + contractsEnvPath + ); + updateEnvVariable( + "TOKEN_PRICE_CONTRACT", + tokenPriceAddress, + contractsEnvPath + ); + updateEnvVariable( + "HC_HELPER_ADDR", + hcHelperAddr, + contractsEnvPath + ); + updateEnvVariable("PRIVATE_KEY", deployKey, contractsEnvPath); + updateEnvVariable( + "CLIENT_ADDR", + contracts?.find((c) => c.contractName === "SimpleAccount")?.address ?? "", + contractsEnvPath + ); + + const localConfigRegex = /(\[CHAIN_IDS\.LOCAL\]:\s*{[\s\S]*?entryPoint:\s*')([^']*)(\'[\s\S]*?simpleAccountFactory:\s*')([^']*)(\'[\s\S]*?bobaPaymaster:\s*')([^']*)(\'[\s\S]*?})/; + + aaConfigFile = aaConfigFile.replace(localConfigRegex, (match, before1, oldEntryPoint, middle1, oldSimpleAccountFactory, middle2, oldBobaPaymaster, after) => { + return `${before1}${ENTRYPOINT}${middle1}${haFactory}${middle2}${tokenPaymasterAddress}${after}`; + }); + + // Update the AA-config + fs.writeFileSync('../snap-account-abstraction-keyring/packages/snap/src/constants/aa-config.ts', aaConfigFile, 'utf8'); + + // Update LOCAL_ENTRYPOINT + updateEnvVariable( + "LOCAL_ENTRYPOINT", + ENTRYPOINT, + snapEnv + ); + + // Update Account Factory + updateEnvVariable( + "LOCAL_SIMPLE_ACCOUNT_FACTORY", + saFactory, // here we actually need the sa factory + snapEnv + ); + + // Update Account Factory + updateEnvVariable( + "VERIFYING_PAYMASTER_ADDRESS", + verifyingPaymasterContract, + snapEnv + ); + + // Update Account Factory + updateEnvVariable( + "LOCAL_BOBAPAYMASTER", + tokenPaymasterAddress, + snapEnv + ); + + /** @DEV bootstrap frontend, backend and snap */ + await execPromise( + "docker-compose -f docker-compose.local.yml up --build", + [], + path.resolve(__dirname, "../../") + ); + } catch (error) { + console.error(error); + } } main(); diff --git a/contracts/script/deploy-sepolia.ts b/contracts/script/deploy-sepolia.ts index 6ffe695..c47421b 100644 --- a/contracts/script/deploy-sepolia.ts +++ b/contracts/script/deploy-sepolia.ts @@ -8,6 +8,7 @@ dotenv.config(); const DEFAULT_BOBA_SEPOLIA = { RPC_URL: 'https://sepolia.boba.network', HC_HELPER_ADDR: '0x1c64EC0A5E2C58295c3208a63209A2A719dF68D8', + ENTRYPOINT_ADDR: '0x5ff137d4b0fdcd49dca30c7cf57e578a026d2789', } const readHybridAccountAddress = () => { @@ -17,12 +18,18 @@ const readHybridAccountAddress = () => { ); const jsonContent = JSON.parse(fs.readFileSync(jsonPath, "utf8")); const transaction = jsonContent.transactions.find( - (tx: any) => tx.transactionType === "CREATE" + (tx: any) => tx.transactionType === "CALL" && tx.function === "createAccount(address,uint256)" ); if (!transaction) { - throw new Error("CREATE transaction not found in the JSON file"); + throw new Error("HybridAccount Creation transaction not found in the JSON file"); } - return transaction.contractAddress; + const create2Tx = transaction.additionalContracts.find((t:any) => { + return t.transactionType === "CREATE2"; + }) + if (!create2Tx) { + throw new Error('Could not find Create2 tx within outer account creation tx: '+JSON.stringify(transaction)) + } + return create2Tx.address; }; const deleteIgnitionDeployments = () => { @@ -39,6 +46,8 @@ const deleteIgnitionDeployments = () => { async function main() { try { + const {HC_HELPER_ADDR, RPC_URL, ENTRYPOINT_ADDR} = DEFAULT_BOBA_SEPOLIA + // Step 1: Compile Hardhat project console.log("Compiling Hardhat project..."); await execPromise("npx hardhat compile"); @@ -46,11 +55,15 @@ async function main() { // Step 2: Deploy Hybrid Account console.log("Deploying Hybrid Account..."); const forgeOutput = await execPromise( - `forge script script/deploy-hybrid-account.s.sol:DeployExample --rpc-url ${DEFAULT_BOBA_SEPOLIA.RPC_URL} --broadcast` + `forge script script/deploy-hybrid-account.s.sol:DeployExample --rpc-url ${RPC_URL} --broadcast` ); console.log("forgeoutput: ", forgeOutput); const hybridAccountAddress = readHybridAccountAddress(); + console.log("Verifying HybridAccount contract..."); + await execPromise( + `cast call --rpc-url=${RPC_URL} ${hybridAccountAddress} "getDeposit()"` + ); // Update HYBRID_ACCOUNT in .env updateEnvVariable("HYBRID_ACCOUNT", hybridAccountAddress); @@ -86,16 +99,17 @@ async function main() { await new Promise((resolve) => setTimeout(resolve, 3000)); + + const {PRIVATE_KEY, BACKEND_URL} = process.env // Step 4: Verify contract console.log("Verifying TokenPrice contract..."); await execPromise( `npx hardhat verify --network boba_sepolia ${tokenPriceAddress} ${hybridAccountAddress}` ); + // Step 5: Run production push script console.log("Running production push script..."); - const {PRIVATE_KEY, BACKEND_URL} = process.env - const {HC_HELPER_ADDR, RPC_URL} = DEFAULT_BOBA_SEPOLIA console.log('HCH = ', HC_HELPER_ADDR) console.log('HA = ', hybridAccountAddress); console.log('TTP = ', tokenPriceAddress); @@ -103,15 +117,19 @@ async function main() { console.log('RPC_URL = ', RPC_URL) console.log('-------------------') + const finalBackendUrl = BACKEND_URL ?? "https://aa-hc-example.onrender.com/hc" + updateEnvVariable("BACKEND_URL", finalBackendUrl) + updateEnvVariable("ENTRY_POINT", ENTRYPOINT_ADDR) + if (!BACKEND_URL) { 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) { + if (!HC_HELPER_ADDR || !hybridAccountAddress || !tokenPriceAddress || !PRIVATE_KEY || !RPC_URL) { throw Error("Configuration missing") } await execPromise( - `node script/pushProduction.js ${RPC_URL} ${PRIVATE_KEY} ${HC_HELPER_ADDR} ${hybridAccountAddress} ${tokenPriceAddress} ${BACKEND_URL}` + `node script/pushProduction.js ${RPC_URL} ${PRIVATE_KEY} ${HC_HELPER_ADDR} ${hybridAccountAddress} ${tokenPriceAddress} ${finalBackendUrl}` ); console.log("Deployment process completed successfully!"); @@ -146,7 +164,7 @@ async function main() { updateEnvVariable( "ENTRY_POINTS", - '0x5ff137d4b0fdcd49dca30c7cf57e578a026d2789', // @dev Official Boba Sepolia Entrypoint: https://docs.boba.network/developer/features/aa-basics/contract-addresses + ENTRYPOINT_ADDR, // @dev Official Boba Sepolia Entrypoint: https://docs.boba.network/developer/features/aa-basics/contract-addresses backendEnvPath ); updateEnvVariable("CHAIN_ID", "901", backendEnvPath); diff --git a/contracts/script/deploy.s.sol b/contracts/script/deploy.s.sol index f4e70db..3e487e1 100644 --- a/contracts/script/deploy.s.sol +++ b/contracts/script/deploy.s.sol @@ -6,9 +6,9 @@ import "../contracts/core/EntryPoint.sol"; import "../contracts/core/HCHelper.sol"; import "../contracts/samples/HybridAccountFactory.sol"; import "../contracts/samples/SimpleAccountFactory.sol"; +import "../contracts/samples/TokenPaymaster.sol"; import "../contracts/TokenPrice.sol"; -//import "openzeppelin-contracts/contracts/mocks/InitializableMock.sol"; -// forge script scripts/deploy.s.sol:DeployExample --rpc-url http://localhost:9545 --broadcast +import "../contracts/samples/VerifyingPaymaster.sol"; contract DeployExample is Script { // Configs @@ -21,8 +21,12 @@ contract DeployExample is Script { EntryPoint public entrypoint; HCHelper public hcHelper; HybridAccount public hybridAccount; + VerifyingPaymaster public verifyingPaymaster; + TokenPaymaster public tokenPaymaster; + TokenPrice public tokenPrice; SimpleAccount public simpleAccount; SimpleAccountFactory public saf; + HybridAccountFactory public haf; function run() public { // Prepare and start Broadcast @@ -47,12 +51,25 @@ contract DeployExample is Script { address(entrypoint), address(0x4200000000000000000000000000000000000023) ); - hybridAccount = new HybridAccount( - IEntryPoint(entrypoint), - address(hcHelper) - ); + saf = new SimpleAccountFactory(entrypoint); - simpleAccount = new SimpleAccount(IEntryPoint(entrypoint)); + haf = new HybridAccountFactory(entrypoint, address(hcHelper)); + + // use block number to always deploy fresh HA & SA + hybridAccount = haf.createAccount(deployerAddress, block.number); + + tokenPrice = new TokenPrice(hybridAccount); + hybridAccount.PermitCaller(address(tokenPrice), true); + + verifyingPaymaster = new VerifyingPaymaster(entrypoint, address(deployerAddress)); + tokenPaymaster = new TokenPaymaster(haf, entrypoint, deployerAddress); + + entrypoint.depositTo{value: 0.1 ether}(address(hybridAccount)); // only needed for HA + entrypoint.depositTo{value: 0.1 ether}(address(verifyingPaymaster)); + entrypoint.depositTo{value: 0.1 ether}(address(tokenPaymaster)); + console.log(address(hybridAccount)); + + simpleAccount = saf.createAccount(deployerAddress, block.number); } function configureContracts() public { @@ -83,6 +100,8 @@ contract DeployExample is Script { console.log("HC_HELPER_ADDR=", address(hcHelper)); console.log("OC_HYBRID_ACCOUNT=", address(hybridAccount)); console.log("SIMPLE_ACCOUNT=", address(simpleAccount)); + console.log("HA_FACTORY=", address(haf)); + console.log("SA_FACTORY=", address(saf)); console.log("CLIENT_PRIVKEY=", deployerPrivateKey); console.log("HC_SYS_OWNER", address(deployerAddress)); } diff --git a/contracts/script/depositHybridAccount.sol b/contracts/script/depositHybridAccount.sol new file mode 100644 index 0000000..19ec331 --- /dev/null +++ b/contracts/script/depositHybridAccount.sol @@ -0,0 +1,33 @@ +// SPDX-License-Identifier: MIT +pragma solidity ^0.8.13; + +import "forge-std/Script.sol"; +import "forge-std/console.sol"; +import "../contracts/samples/HybridAccount.sol"; +import "../contracts/core/HCHelper.sol"; +import {HybridAccountFactory} from "../contracts/samples/HybridAccountFactory.sol"; + +contract RegisterUrl is Script { + // Configs + address public deployerAddress; + uint256 public deployerPrivateKey = vm.envUint("PRIVATE_KEY"); + 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 hybridAccount = vm.envAddress("HYBRID_ACCOUNT"); + address public entrypoint = vm.envAddress("ENTRY_POINT"); // system wide + address public paymaster = address(0x8223388f7aF211d84289783ed97ffC5Fefa14256); // system wide paymaster boba sepolia + + function run() public { + deployerAddress = vm.addr(deployerPrivateKey); + + vm.startBroadcast(deployerPrivateKey); + + IEntryPoint(entrypoint).depositTo{value: 0.001 ether}(hybridAccount); + IEntryPoint(entrypoint).depositTo{value: 0.001 ether}(paymaster); + console.log(IEntryPoint(entrypoint).getDepositInfo(hybridAccount).deposit); + console.log(IEntryPoint(entrypoint).getDepositInfo(paymaster).deposit); + vm.stopBroadcast(); + } +} \ No newline at end of file diff --git a/contracts/script/pushProduction.js b/contracts/script/pushProduction.js index 2bd3d03..1b2b4d7 100644 --- a/contracts/script/pushProduction.js +++ b/contracts/script/pushProduction.js @@ -113,12 +113,16 @@ async function main() { console.log('[Ignore on testnet] failed permitCaller: ', e); } - try { - console.log('Registering URL...') - await registerUrl(HYBRID_ACCOUNT, BACKEND_URL); - console.log('DONE') - } catch (e) { - console.log('[Ignore on testnet] failed registerURL: ', e); + if (RPC_URL.includes('localhost')) { + try { + console.log('Registering URL... (is expected to fail on testnet since you are not owner)') + await registerUrl(HYBRID_ACCOUNT, BACKEND_URL); + console.log('DONE') + } catch (e) { + console.log('[Ignore on testnet] failed registerURL: ', e); + } + } else { + console.log('NOT REGISTERING URL, since you are not deploying locally. Reach out to Boba Foundation to get your backend url registered on your HybridAccount.') } try { diff --git a/contracts/script/registerUrl.s.sol b/contracts/script/registerUrl.s.sol new file mode 100644 index 0000000..77402cb --- /dev/null +++ b/contracts/script/registerUrl.s.sol @@ -0,0 +1,34 @@ +// SPDX-License-Identifier: MIT +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 RegisterUrl is Script { + // Configs + address public deployerAddress; + uint256 public deployerPrivateKey = vm.envUint("PRIVATE_KEY_OWNER"); + 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 hybridAccount = vm.envAddress("HYBRID_ACCOUNT"); + address public entrypoint = vm.envAddress("ENTRY_POINT"); // system wide + + function run() public { + deployerAddress = vm.addr(deployerPrivateKey); + + HCHelper hcHelper = HCHelper(hcHelperAddr); // make sure you don't deploy a new one here + assert(address(hcHelper) == hcHelperAddr); // check if assigned properly + + vm.startBroadcast(deployerPrivateKey); + + assert(hcHelper.owner() == deployerAddress); // Wrong private key + + // register url, only owner - reach out to Boba foundation: + hcHelper.RegisterUrl(hybridAccount, backendURL); + vm.stopBroadcast(); + } +} \ No newline at end of file diff --git a/frontend/.env-boba-sepolia b/frontend/.env-boba-sepolia index fa43e70..d7cfd8a 100644 --- a/frontend/.env-boba-sepolia +++ b/frontend/.env-boba-sepolia @@ -1,4 +1,4 @@ -VITE_SMART_CONTRACT=0x6B62ECe2058a63d3BF77cA0a2124C104c0722008 +VITE_SMART_CONTRACT=0x124ec3EC5C12843aFd62030250a62bC126E93290 VITE_RPC_PROVIDER=https://sepolia.boba.network -VITE_SNAP_ORIGIN=local:http://localhost:8080 +VITE_SNAP_ORIGIN=npm:@bobanetwork/snap-account-abstraction-keyring-hc VITE_SNAP_VERSION=1.1.3 \ No newline at end of file diff --git a/frontend/.env-boba-sepolia-snaplocal b/frontend/.env-boba-sepolia-snaplocal index fa43e70..9b84321 100644 --- a/frontend/.env-boba-sepolia-snaplocal +++ b/frontend/.env-boba-sepolia-snaplocal @@ -1,4 +1,4 @@ -VITE_SMART_CONTRACT=0x6B62ECe2058a63d3BF77cA0a2124C104c0722008 +VITE_SMART_CONTRACT=0x124ec3EC5C12843aFd62030250a62bC126E93290 VITE_RPC_PROVIDER=https://sepolia.boba.network VITE_SNAP_ORIGIN=local:http://localhost:8080 VITE_SNAP_VERSION=1.1.3 \ No newline at end of file diff --git a/frontend/src/components/TokenPriceFetcher.tsx b/frontend/src/components/TokenPriceFetcher.tsx index 3e8235a..b5a78a4 100644 --- a/frontend/src/components/TokenPriceFetcher.tsx +++ b/frontend/src/components/TokenPriceFetcher.tsx @@ -45,11 +45,11 @@ const FormComponent = () => { to: import.meta.env.VITE_SMART_CONTRACT, value: "0", data: txData, - /*overrides: { - callGasLimitReq: 11_000_000, - maxFeePerGasReq: 11_000_000, - maxPriorityFeePerGasReq: 11_000_000, - },*/ + overrides: { + callGasLimitReq: 11_000_000_000_000, + maxFeePerGasReq: 11_000_000_000_000, + maxPriorityFeePerGasReq: 11_000_000_000_000, + }, }, account: state.selectedAcount.id, scope: `eip155:${state.chain}`, @@ -61,7 +61,7 @@ const FormComponent = () => { params: { snapId: defaultSnapOrigin, request: { - method: "eth_sendUserOpBoba", + method: "eth_sendUserOpBobaPM", params: [transactionDetails], id: state.selectedAcount?.id, },