Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add --refill-helper-contract flag #334

Merged
merged 1 commit into from
Oct 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/cli/config/bundler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ export const bundlerArgsSchema = z.object({
(v) => (v === "" ? undefined : v),
addressSchema.optional()
),
"refill-helper-contract": addressSchema.optional(),
"no-profit-bundling": z.boolean(),
"safe-mode": z.boolean(),
"utility-private-key": hexData32Schema
Expand Down
5 changes: 5 additions & 0 deletions src/cli/config/options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,11 @@ export const bundlerOptions: CliCommandOptions<IBundlerArgsInput> = {
require: false,
default: "0xBbe8A301FbDb2a4CD58c4A37c262ecef8f889c47"
},
"refill-helper-contract": {
description: "Address of the Executor refill helper contract",
type: "string",
require: false
},
"executor-private-keys": {
description: "Private keys of the executor accounts split by commas",
type: "string",
Expand Down
18 changes: 15 additions & 3 deletions src/cli/handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,17 +22,17 @@ import { deploySimulationsContract } from "./deploySimulationsContract"

const preFlightChecks = async (config: AltoConfig): Promise<void> => {
for (const entrypoint of config.entrypoints) {
const entryPointCode = await config.publicClient.getBytecode({
const entryPointCode = await config.publicClient.getCode({
address: entrypoint
})
if (entryPointCode === "0x") {
if (entryPointCode === undefined || entryPointCode === "0x") {
throw new Error(`entry point ${entrypoint} does not exist`)
}
}

if (config.entrypointSimulationContract) {
const simulations = config.entrypointSimulationContract
const simulationsCode = await config.publicClient.getBytecode({
const simulationsCode = await config.publicClient.getCode({
address: simulations
})
if (simulationsCode === undefined || simulationsCode === "0x") {
Expand All @@ -41,6 +41,18 @@ const preFlightChecks = async (config: AltoConfig): Promise<void> => {
)
}
}

if (config.refillHelperContract) {
const refillHelper = config.refillHelperContract
const refillHelperCode = await config.publicClient.getCode({
address: refillHelper
})
if (refillHelperCode === undefined || refillHelperCode === "0x") {
throw new Error(
`RefillHelper contract ${refillHelper} does not exist`
)
}
}
}

export async function bundlerHandler(args_: IOptionsInput): Promise<void> {
Expand Down
17 changes: 2 additions & 15 deletions src/executor/senderManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -140,11 +140,7 @@ export class SenderManager {
const { maxFeePerGas, maxPriorityFeePerGas } =
await this.gasPriceManager.getGasPrice()

if (
this.config.walletClient.chain.id === 59140 ||
this.config.walletClient.chain.id === 137 ||
this.config.walletClient.chain.id === 10
) {
if (this.config.refillHelperContract) {
const instructions = []
for (const [address, missingBalance] of Object.entries(
balancesMissing
Expand All @@ -156,18 +152,9 @@ export class SenderManager {
})
}

let refillAddress: `0x${string}`
if (this.config.walletClient.chain.id === 59140) {
refillAddress = "0xEad1aC3DF6F96b91491d6396F4d1610C5638B4Db"
} else if (this.config.walletClient.chain.id === 137) {
refillAddress = "0x3402DB43152dAB9ab72fa805fdD5f391cD3E3822"
} else {
refillAddress = "0x3402DB43152dAB9ab72fa805fdD5f391cD3E3822"
}

const callEngine = getContract({
abi: CallEngineAbi,
address: refillAddress,
address: this.config.refillHelperContract,
client: {
public: this.config.publicClient,
wallet: this.config.walletClient
Expand Down
Loading