From cfac64e47fbbaeeb59e378da2b8363460d936993 Mon Sep 17 00:00:00 2001 From: Igor Yalovoy Date: Thu, 12 Dec 2024 12:53:56 -0600 Subject: [PATCH] Add SponsorPaymaster integration and fund apps with balance checks and deposits. --- script/actions/fund-faucets.s.sol | 37 +++++++++++++++++++++++++++++-- 1 file changed, 35 insertions(+), 2 deletions(-) diff --git a/script/actions/fund-faucets.s.sol b/script/actions/fund-faucets.s.sol index 79270339..74d81fa1 100644 --- a/script/actions/fund-faucets.s.sol +++ b/script/actions/fund-faucets.s.sol @@ -2,6 +2,7 @@ pragma solidity ^0.8.18; import {KintoWalletFactory} from "@kinto-core/wallet/KintoWalletFactory.sol"; +import {SponsorPaymaster} from "@kinto-core/paymasters/SponsorPaymaster.sol"; import {MigrationHelper} from "@kinto-core-script/utils/MigrationHelper.sol"; import {ArrayHelpers} from "@kinto-core-test/helpers/ArrayHelpers.sol"; import "forge-std/console2.sol"; @@ -14,6 +15,10 @@ contract FundFaucetsScript is MigrationHelper { address public constant FAUCET_CLAIMER = 0x52F09693c9eEaA93A64BA697e3d3e43a1eB65477; address public constant KYC_RELAYER = 0x6E31039abF8d248aBed57E307C9E1b7530c269E4; + address public constant DINARI = 0xB2eEc63Cdc175d6d07B8f69804C0Ab5F66aCC3cb; + address public constant KINTO_CORE = 0xD157904639E89df05e89e0DabeEC99aE3d74F9AA; + address public constant SOCKET_DL = 0x3e9727470C66B1e77034590926CDe0242B5A3dCc; + function run() public override { super.run(); @@ -23,11 +28,15 @@ contract FundFaucetsScript is MigrationHelper { return; } + console2.log(""); + console2.log("Faucets"); + address[4] memory faucets = [FAUCET, WALLET_FUNDER, FAUCET_CLAIMER, KYC_RELAYER]; string[4] memory names = ["FAUCET", "WALLET_FUNDER", "FAUCET_CLAIMER", "KYC_RELAYER"]; uint64[4] memory limits = [0.25 ether, 0.25 ether, 0.25 ether, 0.25 ether]; uint64[4] memory amounts = [0.25 ether, 0.25 ether, 0.25 ether, 0.25 ether]; + KintoWalletFactory factory = KintoWalletFactory(_getChainDeployment("KintoWalletFactory")); for (uint256 index = 0; index < faucets.length; index++) { address faucet = faucets[index]; uint256 balance = faucet.balance; @@ -36,12 +45,36 @@ contract FundFaucetsScript is MigrationHelper { console2.log("Balance: %e", balance); if (balance < limits[index]) { - console2.log("Needs funding. Adding:", amounts[index]); + console2.log("Needs funding. Adding: %e", amounts[index]); - KintoWalletFactory factory = KintoWalletFactory(_getChainDeployment("KintoWalletFactory")); vm.broadcast(deployerPrivateKey); factory.sendMoneyToAccount{value: amounts[index]}(faucet); } } + + console2.log(""); + console2.log("Apps"); + + address[3] memory apps = [KINTO_CORE, DINARI, SOCKET_DL]; + string[3] memory appNames = ["KINTO_CORE", "DINARI", "SOCKET_DL"]; + uint56[3] memory appLimits = [0.02 ether, 0.02 ether, 0.02 ether]; + uint56[3] memory appAmounts = [0.01 ether, 0.01 ether, 0.01 ether]; + + SponsorPaymaster paymaster = SponsorPaymaster(_getChainDeployment("SponsorPaymaster")); + for (uint256 index = 0; index < apps.length; index++) { + address app = apps[index]; + uint256 balance = paymaster.balances(app); + + console2.log("App:", appNames[index]); + console2.log("Address:", app); + console2.log("Balance: %e", balance); + + if (balance < appLimits[index]) { + console2.log("Needs funding. Adding: %e", appAmounts[index]); + + vm.broadcast(deployerPrivateKey); + paymaster.addDepositFor{value: appAmounts[index]}(app); + } + } } }