return value of address (unpad)

pull/7/head
yann300 8 years ago
parent 4603a41e3e
commit ec9cb8056f
  1. 4
      src/solidity/types/Address.js
  2. 4
      test/solidity/storageDecoder.js

@ -1,5 +1,6 @@
'use strict'
var util = require('./util')
var utileth = require('ethereumjs-util')
function Address () {
this.storageSlots = 1
@ -8,7 +9,8 @@ function Address () {
}
Address.prototype.decodeFromStorage = function (location, storageContent) {
return '0x' + util.extractHexByte(location, storageContent, this.storageBytes)
var value = util.extractHexByte(location, storageContent, this.storageBytes)
return '0x' + utileth.unpad(value).toUpperCase()
}
module.exports = Address

@ -57,7 +57,7 @@ function testByteStorage (st) {
for (var storage of [byteStorage.storage, shrinkStorage(byteStorage.storage)]) {
var decoded = stateDecoder.solidityState(storage, output.sources, 'byteStorage')
st.equal(decoded['b1'], false)
st.equal(decoded['a1'], '0xfe350f199f244ac9a79038d254400b632a633225')
st.equal(decoded['a1'], '0xFE350F199F244AC9A79038D254400B632A633225')
st.equal(decoded['b2'], true)
st.equal(decoded['dynb1'], '0x64796e616d69636279746573')
st.equal(decoded['stab'], '0x1')
@ -100,7 +100,7 @@ function testByteStorage (st) {
decoded = stateDecoder.solidityState({}, output.sources, 'byteStorage')
st.equal(decoded['b1'], false)
st.equal(decoded['a1'], '0x0000000000000000000000000000000000000000')
st.equal(decoded['a1'], '0x')
st.equal(decoded['b2'], false)
st.equal(decoded['dynb1'], '0x')
st.equal(decoded['stab'], '0x')

Loading…
Cancel
Save