UNPKG

@ocap/statedb-fs

Version:
21 lines (16 loc) 646 B
const { ensureChecksumAddress } = require('@ocap/state/lib/states/account'); const FsTable = require('./base'); class AccountTable extends FsTable { async _get(address, { traceMigration = true } = {}) { const current = await super._get(ensureChecksumAddress(address)); if (current && traceMigration && Array.isArray(current.migratedTo) && current.migratedTo.length) { return this._get(current.migratedTo[0]); } return current; } _create(key, attrs = {}, ctx = {}) { const address = ensureChecksumAddress(key); return super._create(address, { ...attrs, address }, ctx); } } module.exports = AccountTable;