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

Replace account package with ethereumjs-util Account #911

Merged
merged 4 commits into from
Oct 15, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
10 changes: 7 additions & 3 deletions packages/vm/examples/run-transactions-complete/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import VM from '../..'
async function main() {
const vm = new VM()

// import the key pair
// Import the key pair,
// used to sign transactions and generate addresses
const keyPair = require('./key-pair')
const privateKey = toBuffer(keyPair.secretKey)
Expand All @@ -16,8 +16,12 @@ async function main() {
console.log('---------------------')
console.log('Sender address: ', bufferToHex(address))

// create a new account
const account = new Account(new BN(0), new BN(100).pow(new BN(18)))
// Create a new account
const acctData = {
nonce: 0,
balance: new BN(10).pow(new BN(19)), // 10 eth
}
const account = Account.fromAccountData(acctData)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! 🙂


// Save the account
await vm.stateManager.putAccount(address, account)
Expand Down
7 changes: 4 additions & 3 deletions packages/vm/lib/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -210,9 +210,10 @@ export default class VM extends AsyncEventEmitter {
await Promise.all(
Object.keys(precompiles)
.map((k: string): Buffer => Buffer.from(k, 'hex'))
.map((address: Buffer) =>
this.stateManager.putAccount(address, new Account(new BN(0), new BN(1))),
),
.map((address: Buffer) => {
const account = Account.fromAccountData({ balance: 1 })
this.stateManager.putAccount(address, account)
}),
)
await this.stateManager.commit()
}
Expand Down