UNPKG

zc-ripple-binary-codec

Version:
41 lines (29 loc) 1.14 kB
'use strict';var makeClass = require('../utils/make-class');var _require = require('ripple-address-codec');var decodeAccountID = _require.decodeAccountID;var encodeAccountID = _require.encodeAccountID;var _require2 = require('./hash-160');var Hash160 = _require2.Hash160; var AccountID = makeClass({ AccountID: function AccountID(bytes) { Hash160.call(this, bytes);}, inherits: Hash160, statics: { from: function from(value) { return value instanceof this ? value : /^r/.test(value) ? this.fromBase58(value) : new this(value);}, cache: {}, fromCache: function fromCache(base58) { var cached = this.cache[base58]; if (!cached) { cached = this.cache[base58] = this.fromBase58(base58);} return cached;}, fromBase58: function fromBase58(value) { var acc = new this(decodeAccountID(value)); acc._toBase58 = value; return acc;} }, toJSON: function toJSON() { return this.toBase58();}, cached: { toBase58: function toBase58() { return encodeAccountID(this._bytes);} } }); module.exports = { AccountID: AccountID };