Skip to content
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
9 changes: 9 additions & 0 deletions packages/rollup-full-node/src/app/web3-rpc-handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,10 @@ export class DefaultWeb3Handler
args = this.assertParameters(params, 2)
response = await this.getBlockByHash(args[0], args[1])
break
case Web3RpcMethods.getBalance:
this.assertParameters(params, 2, latestBlock)
response = await this.getBalance()
break
case Web3RpcMethods.getCode:
args = this.assertParameters(params, 2, latestBlock)
response = await this.getCode(args[0], args[1])
Expand Down Expand Up @@ -284,6 +288,11 @@ export class DefaultWeb3Handler
return '0x0'
}

public async getBalance(): Promise<string> {
// Balances are always zero
return '0x0'
}

public async getBlockByNumber(
defaultBlock: string,
fullObjects: boolean
Expand Down
1 change: 1 addition & 0 deletions packages/rollup-full-node/src/types/web3-rpc-handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ export enum Web3RpcMethods {
gasPrice = 'eth_gasPrice',
getBlockByNumber = 'eth_getBlockByNumber',
getBlockByHash = 'eth_getBlockByHash',
getBalance = 'eth_getBalance',
getCode = 'eth_getCode',
getExecutionManagerAddress = 'ovm_getExecutionManagerAddress',
getLogs = 'eth_getLogs',
Expand Down
11 changes: 10 additions & 1 deletion packages/rollup-full-node/test/app/web-rpc-handler.spec.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import '../setup'
/* External Imports */
import { getLogger } from '@eth-optimism/core-utils'
import { getLogger, numberToHexString } from '@eth-optimism/core-utils'
import { ethers, ContractFactory, Wallet, Contract } from 'ethers'
import { resolve } from 'path'
import * as rimraf from 'rimraf'
Expand Down Expand Up @@ -133,6 +133,15 @@ describe('Web3Handler', () => {
})

describe('ephemeral node', () => {
describe('the getBalance endpoint', () => {
it('should return zero for all accounts', async () => {
const wallet = getWallet(httpProvider)
const balance = await httpProvider.getBalance(wallet.address)

balance.toNumber().should.eq(0)
})
})

describe('the getBlockByNumber endpoint', () => {
it('should return a block with the correct timestamp', async () => {
const block = await httpProvider.getBlock('latest')
Expand Down