Skip to content

Commit

Permalink
fix shovel integration, add deposit for token paymaster fixture
Browse files Browse the repository at this point in the history
  • Loading branch information
0xBigBoss committed Jun 30, 2024
1 parent 9026041 commit c39226e
Show file tree
Hide file tree
Showing 7 changed files with 106 additions and 28 deletions.
3 changes: 2 additions & 1 deletion packages/contracts/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@
"dev:anvil-add-send-merkle-drop-fixtures": "bun run ./script/anvil-add-send-merkle-drop-fixtures.ts",
"dev:anvil-add-send-account-factory-fixtures": "bun run ./script/anvil-add-send-account-factory-fixtures.ts",
"dev:anvil-add-token-paymaster-fixtures": "bun run ./script/anvil-add-token-paymaster-fixtures.ts",
"dev:anvil-add-send-check-fixtures": "bun run ./script/anvil-add-send-check-fixtures.ts"
"dev:anvil-add-send-check-fixtures": "bun run ./script/anvil-add-send-check-fixtures.ts",
"dev:anvil-token-paymaster-deposit": "bun run ./script/anvil-token-paymaster-deposit.ts"
},
"devDependencies": {
"@my/supabase": "workspace:*",
Expand Down
29 changes: 29 additions & 0 deletions packages/contracts/script/AddTokenPaymasterDeposit.s.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
// SPDX-License-Identifier: GPL-3.0
pragma solidity ^0.8.20;

import {Script, console2} from "forge-std/Script.sol";
import {Helper} from "../src/Helper.sol";
import {IERC20} from "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import {IERC20Metadata} from "@openzeppelin/contracts/token/ERC20/extensions/IERC20Metadata.sol";
import "../src/TokenPaymaster.sol";

contract AddTokenPaymasterDepositScript is Script, Helper {
function setUp() public {
this.labels();
}

function run() public {
address addr = vm.envAddress("PAYMASTER");
uint256 deposit = vm.envUint("DEPOSIT");

require(addr != address(0), "PAYMASTER env variable not set");
require(deposit > 0, "DEPOSIT env variable not set");

TokenPaymaster paymaster = TokenPaymaster(payable(addr));
address entryPoint = 0x0000000071727De22E5E9d8BAf0edAc6f37da032;

vm.startBroadcast();
IEntryPoint(entryPoint).depositTo{value: deposit}(address(paymaster));
vm.stopBroadcast();
}
}
30 changes: 30 additions & 0 deletions packages/contracts/script/anvil-token-paymaster-deposit.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import 'zx/globals'
$.verbose = true
/**
* This script is used to deposit into the Entrypoint for TokenPaymaster
*/

void (async function main() {
console.log(chalk.blue('Enable auto-mining...'))
await $`cast rpc --rpc-url base-local evm_setAutomine true`

// base mainnet fork
$.env.PAYMASTER = '0x592e1224D203Be4214B15e205F6081FbbaCFcD2D'
$.env.DEPOSIT = await $`cast to-wei 100 ether`.then((r) => r.stdout.trim())

console.log(chalk.blue('Adding deposit to paymaster...'), $.env.DEPOSIT)
await $`forge script ./script/AddTokenPaymasterDeposit.s.sol:AddTokenPaymasterDepositScript \
-vvvv \
--fork-url base-local \
--sender 0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266 \
--private-key 0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80 \
--broadcast`

console.log(chalk.blue('Disable auto-mining...'))
await $`cast rpc --rpc-url base-local evm_setAutomine false`

console.log(chalk.blue(`Re-enable interval mining... ${$.env.ANVIL_BLOCK_TIME ?? '2'}`))
await $`cast rpc --rpc-url base-local evm_setIntervalMining ${$.env.ANVIL_BLOCK_TIME ?? '2'}` // mimics Tiltfile default

console.log(chalk.green('Done!'))
})()
25 changes: 12 additions & 13 deletions packages/shovel/etc/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,16 @@
},
{
"name": "log_addr",
"column": "log_addr"
"column": "log_addr",
"filter_op": "contains",
"filter_arg": [
"0x036CbD53842c5426634e7929541eC2318f3dCF7e",
"0x1c7D4B196Cb0C7B01d743Fbc6116a902379C7238",
"0x3f14920c99BEB920Afa163031c4e47a3e03B3e4A",
"0x7cEfbe54c37a35dCdaD29b86373ca8353a2F4680",
"0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913",
"0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48"
]
}
],
"event": {
Expand All @@ -158,23 +167,13 @@
"indexed": true,
"name": "from",
"type": "address",
"column": "f",
"filter_op": "contains",
"filter_ref": {
"integration": "send_account_created",
"column": "account"
}
"column": "f"
},
{
"indexed": true,
"name": "to",
"type": "address",
"column": "t",
"filter_op": "contains",
"filter_ref": {
"integration": "send_account_created",
"column": "account"
}
"column": "t"
},
{
"indexed": false,
Expand Down
15 changes: 11 additions & 4 deletions packages/shovel/src/integrations/send-account-transfers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,11 @@ export const integration: Omit<Integration, 'sources'> = {
{
name: 'log_addr',
column: 'log_addr',
filter_op: 'contains',
filter_arg: [
...new Set(Object.values(sendTokenAddress)),
...new Set(Object.values(usdcAddress)),
].sort(),
},
] as BlockData[],
event: {
Expand All @@ -48,16 +53,18 @@ export const integration: Omit<Integration, 'sources'> = {
name: 'from',
type: 'address',
column: 'f',
filter_op: 'contains',
filter_ref: sendAccountFactorySenderFilterRef,
// wait for this https://github.com/indexsupply/code/issues/262
// filter_op: 'contains',
// filter_ref: sendAccountFactorySenderFilterRef,
},
{
indexed: true,
name: 'to',
type: 'address',
column: 't',
filter_op: 'contains',
filter_ref: sendAccountFactorySenderFilterRef,
// wait for this https://github.com/indexsupply/code/issues/262
// filter_op: 'contains',
// filter_ref: sendAccountFactorySenderFilterRef,
},
{
indexed: false,
Expand Down
19 changes: 9 additions & 10 deletions packages/shovel/test/__snapshots__/index.test.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,15 @@ exports[`shovel config 1`] = `
},
{
"column": "log_addr",
"filter_arg": [
"0x036CbD53842c5426634e7929541eC2318f3dCF7e",
"0x1c7D4B196Cb0C7B01d743Fbc6116a902379C7238",
"0x3f14920c99BEB920Afa163031c4e47a3e03B3e4A",
"0x7cEfbe54c37a35dCdaD29b86373ca8353a2F4680",
"0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913",
"0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48",
],
"filter_op": "contains",
"name": "log_addr",
},
],
Expand All @@ -106,22 +115,12 @@ exports[`shovel config 1`] = `
"inputs": [
{
"column": "f",
"filter_op": "contains",
"filter_ref": {
"column": "account",
"integration": "send_account_created",
},
"indexed": true,
"name": "from",
"type": "address",
},
{
"column": "t",
"filter_op": "contains",
"filter_ref": {
"column": "account",
"integration": "send_account_created",
},
"indexed": true,
"name": "to",
"type": "address",
Expand Down
13 changes: 13 additions & 0 deletions tilt/infra.tiltfile
Original file line number Diff line number Diff line change
Expand Up @@ -182,13 +182,26 @@ local_resource(
trigger_mode = TRIGGER_MODE_MANUAL,
)

local_resource(
"anvil:anvil-token-paymaster-deposit",
"yarn contracts dev:anvil-token-paymaster-deposit",
dir = _prj_root,
labels = labels,
resource_deps = _infra_resource_deps + [
"anvil:mainnet",
"anvil:base",
"contracts:build",
],
)

local_resource(
"anvil:fixtures",
"echo 🥳",
labels = labels,
resource_deps = [
"anvil:mainnet",
"anvil:base",
"anvil:anvil-token-paymaster-deposit",
],
)

Expand Down

0 comments on commit c39226e

Please sign in to comment.