@ -1,7 +1,7 @@
'use strict'
import { RefType } from './RefType'
import { normalizeHex } from './util'
import { toBuffer , setLengthLeft , keccak , BN , bufferToHex } from 'ethereumjs-util'
import { toBuffer , setLengthLeft , keccak , BN , bufferToHex , addHexPrefix } from 'ethereumjs-util'
export class Mapping extends RefType {
keyType
@ -64,8 +64,8 @@ function getMappingLocation (key, position) {
// > the value corresponding to a mapping key k is located at keccak256(k . p) where . is concatenation.
// key should be a hex string, and position an int
const mappingK = toBuffer ( '0x' + key )
let mappingP = toBuffer ( position )
const mappingK = toBuffer ( addHexPrefix ( key ) )
let mappingP = toBuffer ( addHexPrefix ( position ) )
mappingP = setLengthLeft ( mappingP , 32 )
const mappingKeyBuf = concatTypedArrays ( mappingK , mappingP )
const mappingStorageLocation : Buffer = keccak ( mappingKeyBuf )