git ssb

0+

wanderer🌟 / js-primea-hypervisor



Commit ef9a2818017021a22cd85f062af777205c35969a

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

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

Files changed

u256.jschanged
u256.jsView
@@ -2,9 +2,12 @@
22 const ethUtils = require('ethereumjs-util')
33
44 module.exports = class U256 {
55 constructor (value) {
6- if ((typeof value === 'string') && ethUtils.isHexPrefixed(value)) {
6+ // This is the case when data is copied from WASM
7+ if (value instanceof Uint8Array) {
8+ this._value = new BN(value, 16, 'le')
9+ } else if ((typeof value === 'string') && ethUtils.isHexPrefixed(value)) {
710 this._value = new BN(value, 16)
811 } else {
912 this._value = new BN(value, 10)
1013 }

Built with git-ssb-web