Skip to content

Commit

Permalink
fix suave example; make buildEthBlock work on all eth providers (requ…
Browse files Browse the repository at this point in the history
…ires suave-std upgrade)
  • Loading branch information
zeroXbrock committed Jun 18, 2024
1 parent bd3aec5 commit 6ba9315
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 5 deletions.
2 changes: 1 addition & 1 deletion examples/suave/contracts/lib/suave-std
2 changes: 1 addition & 1 deletion examples/suave/contracts/src/OFA.sol
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ contract OFAPrivate is Suapp {
// Retrieve the bundle data from the confidential inputs
bytes memory bundleData = Suave.confidentialInputs();
Bundle.BundleObj memory bundle = abi.decode(bundleData, (Bundle.BundleObj));
bundleData = Bundle.encodeBundle(bundle).body;
bundleData = Bundle.encodeBundleParams(bundle);

// Simulate the bundle and extract its score.
uint64 egp = Suave.simulateBundle(bundleData);
Expand Down
16 changes: 13 additions & 3 deletions examples/suave/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ const PRIVATE_KEY: Hex = process.env.PRIVATE_KEY as Hex
const SUAVE_RPC_URL_HTTP: string =
process.env.SUAVE_RPC_URL_HTTP || 'http://localhost:8545'
const L1_RPC_URL_HTTP: string =
process.env.L1_RPC_URL_HTTP || 'http://localhost:8545'
process.env.L1_RPC_URL_HTTP || 'http://localhost:8555'

if (!BidContractDeployment.address) {
console.error(
Expand All @@ -53,7 +53,7 @@ const adminWallet: SuaveWallet<HttpTransport> = getSuaveWallet({
})
const wallet = getSuaveWallet({
transport: http(SUAVE_RPC_URL_HTTP),
privateKey: '0x01000070530220062104600650003002001814120800043ff33603df10300012',
privateKey: "0x6c45335a22461ccdb978b78ab61b238bad2fae4544fb55c14eb096c875ccfc52",
})
console.log('admin', adminWallet.account.address)
console.log('wallet', wallet.account.address)
Expand Down Expand Up @@ -91,10 +91,19 @@ const fundAccount = async (wallet: Address, amount: bigint) => {
}
return await adminWallet.sendTransaction(tx)
} else {
console.log(`wallet balance: ${formatEther(balance)} ETH`)
console.log(`SUAVE wallet balance: ${formatEther(balance)} ETH`)
}
}

async function checkL1Balance(minBalance?: bigint) {
const balance = await l1Provider.getBalance({ address: wallet.account.address })
const absoluteMin = minBalance || 1n
if (balance < absoluteMin) {
throw new Error(`L1 balance too low: ${formatEther(balance)} ETH (needed ${formatEther(absoluteMin)}).\nPlease fund this account: ${wallet.account.address}`)
}
console.log(`L1 balance: ${formatEther(balance)} ETH`)
}

/** MEV-Share implementation on SUAVE.
*
* To run this, you'll need to deploy the contract first.
Expand All @@ -116,6 +125,7 @@ async function testSuaveBids() {
gasPrice: 10000000000n,
chainId: 17000,
}
checkL1Balance(testTx.gas * testTx.gasPrice)
const signedTx = await wallet.signTransaction(testTx)

console.log("signed tx", signedTx)
Expand Down

0 comments on commit 6ba9315

Please sign in to comment.