import { LevelUp } from 'levelup' ; import bn128 from 'rustbn.js' ; import { Address } from 'web3x/address' ; import { Trie } from '../../trie' ; import { EvmContext } from '../../vm' ; import { EvmAccount } from '../evm-account' ; export class EcAddAccount extends EvmAccount { constructor ( address , nonce , balance , storage , code ) { super ( address , nonce , balance , storage , code ) ; } public static fromDb ( db ) { return new EcAddAccount ( Address . fromString ( '0x0000000000000000000000000000000000000006' ) , BigInt ( 0 ) , BigInt ( 0 ) , new Trie ( db ) , Buffer . of ( ) ) ; } public async run ( callContext ) { const { calldata } = callContext ; const result = bn128 . add ( calldata ) ; callContext . halt = true ; if ( result . length !== 64 ) { callContext . reverted = true ; callContext . returned = Buffer . of ( ) ; } else { callContext . returned = result ; } return callContext ; } }