Skip to content

Commit

Permalink
Release/v0.5.1 (#699)
Browse files Browse the repository at this point in the history
* [AA] tests: add integrations tests for AA bundler, wallets, paymaster (#562)

* add AA tests

* add boba as fee token test

* add alt fee token payment test

* rem unused file

* fix: sdk counterfactual address issue

* add sponsor tx integ test

* drop tags

* split tests into multiple assertions

* merge master

* fix depcheck

* build bunlder packages

* move SampleRecipient to integ tests

* fix: lint

* remove unused deps

* update integ tests and bundler

* add sdk

* use bundlerURL through env

* use new account for test

* fix get log index

* run boba monitor tests on ci

* revert change to alt-l2

* fix:lint

* split into multiple steps

* refactor tests

(cherry picked from commit 97ed0d0)

* Adding Banxa Bridge (#666)

* Adding Banxa Bridge

* remove default amount on bridging

* available Bridges

* change: moved url to const, clean console, lint
:

---------

Co-authored-by: Sahil K <[email protected]>
Co-authored-by: Sahil Kashetwar <[email protected]>
(cherry picked from commit 16ad5c1)

* bump aa contracts with 0.5.0 changes (#676)

* bump aa contracts with 0.5.0 changes

* disable bundler

* disable bundler 2

* add deploy task

* add deploy task

(cherry picked from commit 6fb695a)

* List all supported network tokens  (#681)

(cherry picked from commit fd0853c)

* Fix/674 mm keeps popping up (#691)

(cherry picked from commit 1bb8305)

* Performance updates (#692)

* implement deep import

* Remplacing momentJs with Dayjs

* moving lodash to utils/lodash

* clean up unused reducer and selector + added yarn.lock

* refactored time change for history page

---------

Co-authored-by: Sahil Kashetwar <[email protected]>
(cherry picked from commit 03612fa)

* Fix light mode buttons design (#680)

(cherry picked from commit f58e467)

* Enabled Bridge page for all chains along with Fixes, Url Query Params changes (#697)

(cherry picked from commit b8ed9a3)

* remove boba chains from onegateway (#695)

(cherry picked from commit 19f2eb6)

---------

Co-authored-by: Souradeep Das <[email protected]>
Co-authored-by: alvaro-ricotta <[email protected]>
Co-authored-by: Sahil K <[email protected]>
  • Loading branch information
4 people authored Apr 10, 2023
1 parent bce7e2d commit 41cd50c
Show file tree
Hide file tree
Showing 192 changed files with 4,625 additions and 2,577 deletions.
4 changes: 2 additions & 2 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ commands:
- run:
name: Bring up services
command: |
docker-compose -f <<parameters.docker_compose_file>> -f docker-compose-side.yml up -d bobalink aa_deployer bundler
docker-compose -f <<parameters.docker_compose_file>> -f docker-compose-side.yml up -d bobalink aa_deployer
working_directory: ops
- run:
name: Start background logging
Expand Down Expand Up @@ -254,5 +254,5 @@ workflows:
name: proxyd-tests
binary_name: proxyd
working_directory: go/proxyd
- test_flow_bundler_and_depcheck
# - test_flow_bundler_and_depcheck

20 changes: 20 additions & 0 deletions integration-tests/contracts/SampleRecipient.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
//SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

import "@boba/accountabstraction/contracts/samples/SimpleAccount.sol";

contract SampleRecipient {

SimpleAccount account;

event Sender(address txOrigin, address msgSender, string message);

function something(string memory message) public {
emit Sender(tx.origin, msg.sender, message);
}

// solhint-disable-next-line
function reverting() public {
revert( "test revert");
}
}
11 changes: 11 additions & 0 deletions integration-tests/hardhat.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,17 @@ const config: HardhatUserConfig = {
},
},
},
{
version: '0.8.12', // Required for WETH9
settings: {
optimizer: { enabled: true, runs: 10_000 },
outputSelection: {
'*': {
'*': ['storageLayout'],
},
},
},
},
],
},
}
Expand Down
220 changes: 220 additions & 0 deletions integration-tests/test/eth-l2/boba_aa_fee_alt_token.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,220 @@
// import chai from 'chai'
// import chaiAsPromised from 'chai-as-promised'
// chai.use(chaiAsPromised)
// const expect = chai.expect

// import { Contract, ContractFactory, utils, constants, BigNumber } from 'ethers'

// import { getFilteredLogIndex } from './shared/utils'

// import { OptimismEnv } from './shared/env'
// import { hexConcat, hexZeroPad, parseEther } from 'ethers/lib/utils'
// // use local sdk
// import { SimpleAccountAPI } from '@boba/bundler_sdk'
// import SimpleAccountJson from '@boba/accountabstraction/artifacts/contracts/samples/SimpleAccount.sol/SimpleAccount.json'
// import L2StandardERC20Json from '@eth-optimism/contracts/artifacts/contracts/standards/L2StandardERC20.sol/L2StandardERC20.json'
// import EntryPointJson from '@boba/accountabstraction/artifacts/contracts/core/EntryPoint.sol/EntryPoint.json'
// import SampleRecipientJson from '../../artifacts/contracts/SampleRecipient.sol/SampleRecipient.json'
// import { HttpRpcClient } from '@boba/bundler_sdk/dist/src/HttpRpcClient'

// import ManualDepositPaymasterJson from '@boba/accountabstraction/artifacts/contracts/samples/ManualDepositPaymaster.sol/ManualDepositPaymaster.json'

// describe('AA Alt Fee Token Test\n', async () => {
// let env: OptimismEnv
// let SimpleAccount__factory: ContractFactory
// let recipient: Contract

// let bundlerProvider: HttpRpcClient
// let entryPointAddress: string

// let L2ERC20Token__factory: ContractFactory
// let L2ERC20Token: Contract

// let ManualDepositPaymaster__factory: ContractFactory
// let ManualDepositPaymaster: Contract

// let SampleRecipient__factory: ContractFactory

// let EntryPoint: Contract

// const priceRatio = 100
// const priceRatioDecimals = 2
// const minRatio = 1
// const maxRatio = 500

// before(async () => {
// env = await OptimismEnv.new()
// entryPointAddress = env.addressesAABOBA.L2_BOBA_EntryPoint

// SampleRecipient__factory = new ContractFactory(
// SampleRecipientJson.abi,
// SampleRecipientJson.bytecode,
// env.l2Wallet
// )

// recipient = await SampleRecipient__factory.deploy()

// L2ERC20Token__factory = new ContractFactory(
// L2StandardERC20Json.abi,
// L2StandardERC20Json.bytecode,
// env.l2Wallet
// )

// // set bridge as wallet_2 to easily mint
// L2ERC20Token = await L2ERC20Token__factory.deploy(env.l2Wallet_2.address, env.l2Wallet_2.address, 'PEARL', 'PEARL', 18)
// // mint tokens to wallet
// await L2ERC20Token.connect(env.l2Wallet_2).mint(env.l2Wallet.address, utils.parseEther('500'))

// bundlerProvider = new HttpRpcClient(
// env.bundlerUrl,
// entryPointAddress,
// await env.l2Wallet.provider.getNetwork().then((net) => net.chainId)
// )

// ManualDepositPaymaster__factory = new ContractFactory(
// ManualDepositPaymasterJson.abi,
// ManualDepositPaymasterJson.bytecode,
// env.l2Wallet
// )

// ManualDepositPaymaster = await ManualDepositPaymaster__factory.deploy(
// entryPointAddress,
// )

// // add alt erc20 token
// await ManualDepositPaymaster.addToken(
// L2ERC20Token.address,
// // token decimals
// await L2ERC20Token.decimals(),
// priceRatio,
// priceRatioDecimals,
// minRatio,
// maxRatio
// )

// EntryPoint = new Contract(
// entryPointAddress,
// EntryPointJson.abi,
// env.l2Wallet
// )
// })
// describe('A user without native token pays for a tx using an alt token through a paymaster', async () => {
// let accountAPI: SimpleAccountAPI
// let account
// let preApproveTokenBalance
// let preApproveDepositAmount
// let preApproveEtherBalance
// let postApproveTokenBalance
// let postApproveDepositAmount
// let postApproveEtherBalance
// let signedOp

// before('the paymaster operator sets up the paymaster by staking and adding deposits', async () => {
// await ManualDepositPaymaster.addStake(1, { value: utils.parseEther('2') })
// await EntryPoint.depositTo(ManualDepositPaymaster.address, {
// value: utils.parseEther('1')
// })
// })

// before('the user approves the paymaster to spend their $BOBA token', async () => {
// // deploy a 4337 Wallet and send operation to this wallet
// SimpleAccount__factory = new ContractFactory(
// SimpleAccountJson.abi,
// SimpleAccountJson.bytecode,
// env.l2Wallet
// )
// account = await SimpleAccount__factory.deploy(
// entryPointAddress,
// env.l2Wallet.address
// )
// await account.deployed()

// await L2ERC20Token.transfer(account.address, utils.parseEther('1'))

// await L2ERC20Token.approve(ManualDepositPaymaster.address, constants.MaxUint256)
// await ManualDepositPaymaster.addDepositFor(L2ERC20Token.address, account.address, utils.parseEther('2'))

// await env.l2Wallet.sendTransaction({
// value: utils.parseEther('2'),
// to: account.address,
// })

// accountAPI = new SimpleAccountAPI({
// provider: env.l2Provider,
// entryPointAddress,
// owner: env.l2Wallet,
// walletAddress: account.address,
// })

// const approveOp = await accountAPI.createSignedUserOp({
// target: L2ERC20Token.address,
// data: L2ERC20Token.interface.encodeFunctionData('approve', [ManualDepositPaymaster.address, constants.MaxUint256]),
// })

// preApproveTokenBalance = await L2ERC20Token.balanceOf(account.address)
// preApproveDepositAmount = (await ManualDepositPaymaster.depositInfo(L2ERC20Token.address, account.address)).amount
// preApproveEtherBalance = await env.l2Provider.getBalance(account.address)

// const requestId = await bundlerProvider.sendUserOpToBundler(approveOp)
// const txid = await accountAPI.getUserOpReceipt(requestId)
// console.log('reqId', requestId, 'txid=', txid)

// postApproveTokenBalance = await L2ERC20Token.balanceOf(account.address)
// postApproveDepositAmount = (await ManualDepositPaymaster.depositInfo(L2ERC20Token.address, account.address)).amount
// postApproveEtherBalance = await env.l2Provider.getBalance(account.address)
// })

// it('should be able to submit a userOp including the paymaster to the bundler and trigger tx', async () => {
// const op = await accountAPI.createUnsignedUserOp({
// target: recipient.address,
// data: recipient.interface.encodeFunctionData('something', ['hello']),
// })


// op.paymasterAndData = hexConcat([ManualDepositPaymaster.address, hexZeroPad(L2ERC20Token.address, 20)])
// op.preVerificationGas = await accountAPI.getPreVerificationGas(op)

// signedOp = await accountAPI.signUserOp(op)

// const requestId = await bundlerProvider.sendUserOpToBundler(signedOp)
// const txid = await accountAPI.getUserOpReceipt(requestId)
// console.log('reqId', requestId, 'txid=', txid)
// const receipt = await env.l2Provider.getTransactionReceipt(txid)
// const returnedlogIndex = await getFilteredLogIndex(
// receipt,
// SampleRecipientJson.abi,
// recipient.address,
// 'Sender'
// )
// const log = recipient.interface.parseLog(receipt.logs[returnedlogIndex])
// // tx.origin is the bundler
// expect(log.args.txOrigin).to.eq(env.l2Wallet.address)
// // msg.sender is the 4337 wallet
// expect(log.args.msgSender).to.eq(account.address)
// // message is received and emitted
// expect(log.args.message).to.eq('hello')
// const postCallTokenBalance = await L2ERC20Token.balanceOf(account.address)
// const postCallDepositAmount = (await ManualDepositPaymaster.depositInfo(L2ERC20Token.address, account.address)).amount
// const postCallEtherBalance = await env.l2Provider.getBalance(account.address)

// const returnedEPlogIndex = await getFilteredLogIndex(
// receipt,
// EntryPointJson.abi,
// entryPointAddress,
// 'UserOperationEvent'
// )
// const logEP = EntryPoint.interface.parseLog(receipt.logs[returnedEPlogIndex])

// // no token is used when approving, ether balance is used to pay approval fees
// expect(preApproveTokenBalance).to.eq(postApproveTokenBalance)
// expect(preApproveEtherBalance).to.gt(postApproveEtherBalance)
// // users deposit amount on paymaster remains constant and is unused throughout
// expect(preApproveDepositAmount).to.eq(postApproveDepositAmount)
// expect(postApproveDepositAmount).to.eq(postCallDepositAmount)
// // no ether is used when calling the recipient with the help of the paymaster, users boba token is used to pay
// expect(postApproveEtherBalance).to.eq(postCallEtherBalance)
// expect(postApproveTokenBalance).to.gt(postCallTokenBalance)
// expect(BigNumber.from(postCallTokenBalance).add(logEP.args.actualGasCost)).to.closeTo(BigNumber.from(postApproveTokenBalance), utils.parseEther('0.0001'))
// })
// })
// })
Loading

0 comments on commit 41cd50c

Please sign in to comment.