git ssb

0+

wanderer🌟 / js-primea-hypervisor



Commit 049bedec5fd1ee9c75b10b89b9254d6d5ecaa39c

Address: support instantiation from Uint8Array (for data coming from WASM)

Alex Beregszaszi committed on 8/16/2016, 11:12:39 PM
Parent: ef9a2818017021a22cd85f062af777205c35969a

Files changed

address.jschanged
address.jsView
@@ -7,18 +7,18 @@
77 this._value = new Buffer(value._value)
88 return
99 }
1010
11- if (typeof value !== 'string') {
11+ if (value instanceof Uint8Array) {
12+ this._value = new Buffer(value)
13+ } else if (typeof value !== 'string') {
1214 throw new Error('Invalid input to address')
13- }
14-
15- if (!ethUtils.isHexPrefixed(value)) {
15+ } else if (!ethUtils.isHexPrefixed(value)) {
1616 throw new Error('Invalid address format')
17+ } else {
18+ this._value = new Buffer(ethUtils.stripHexPrefix(value), 'hex')
1719 }
1820
19- this._value = new Buffer(ethUtils.stripHexPrefix(value), 'hex')
20-
2121 if (this._value.length !== 20) {
2222 throw new Error('Invalid address length')
2323 }
2424 }

Built with git-ssb-web