Skip to content

Commit

Permalink
Add SponsorPaymaster integration and fund apps with balance checks an…
Browse files Browse the repository at this point in the history
…d deposits.
  • Loading branch information
ylv-io committed Dec 12, 2024
1 parent 89786bb commit cfac64e
Showing 1 changed file with 35 additions and 2 deletions.
37 changes: 35 additions & 2 deletions script/actions/fund-faucets.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand All @@ -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();

Expand All @@ -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;
Expand All @@ -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);
}
}
}
}

0 comments on commit cfac64e

Please sign in to comment.