remove name attribute from decoderinfo

pull/7/head
yann300 8 years ago
parent 51ed62b480
commit 0e39252222
  1. 30
      src/solidity/decodeInfo.js
  2. 19
      test/decodeInfo.js

@ -13,8 +13,7 @@ function Uint (type) {
return {
needsFreeStorageSlot: false,
storageBytes: parseInt(type.replace('uint', '')) / 8,
typeName: type,
name: 'uint'
typeName: type
}
}
@ -28,8 +27,7 @@ function Address (type) {
return {
needsFreeStorageSlot: false,
storageBytes: 20,
typeName: 'address',
name: 'address'
typeName: 'address'
}
}
@ -43,8 +41,7 @@ function Bool (type) {
return {
needsFreeStorageSlot: false,
storageBytes: 1,
typeName: 'bool',
name: 'bool'
typeName: 'bool'
}
}
@ -58,8 +55,7 @@ function DynamicByteArray (type) {
return {
needsFreeStorageSlot: true,
storageBytes: 32,
typeName: 'bytes',
name: 'dynamicByteArray'
typeName: 'bytes'
}
}
@ -76,8 +72,7 @@ function FixedByteArray (type) {
return {
needsFreeStorageSlot: false,
storageBytes: parseInt(type.replace('bytes', '')),
typeName: type.split(' ')[0],
name: 'fixedByteArray'
typeName: type.split(' ')[0]
}
}
@ -94,8 +89,7 @@ function Int (type) {
return {
needsFreeStorageSlot: false,
storageBytes: parseInt(type.replace('int', '')) / 8,
typeName: type,
name: 'int'
typeName: type
}
}
@ -109,8 +103,7 @@ function StringType (type) {
return {
needsFreeStorageSlot: true,
storageBytes: 32,
typeName: 'string',
name: 'stringType'
typeName: 'string'
}
}
@ -153,8 +146,7 @@ function ArrayType (type, stateDefinitions) {
storageBytes: storageBytes,
typeName: type,
arraySize: arraySize,
subArray: subArray,
name: 'arrayType'
subArray: subArray
}
}
@ -170,8 +162,7 @@ function Enum (type, stateDefinitions) {
needsFreeStorageSlot: false,
storageBytes: 1,
typeName: extracted[0] + ' ' + extracted[1],
enum: getEnum(type, stateDefinitions),
name: 'enum'
enum: getEnum(type, stateDefinitions)
}
}
@ -189,8 +180,7 @@ function Struct (type, stateDefinitions) {
needsFreeStorageSlot: true,
storageBytes: membersDetails.storageBytes,
typeName: type,
members: membersDetails.members,
name: 'struct'
members: membersDetails.members
}
}

@ -9,27 +9,27 @@ tape('solidity', function (t) {
var stateDec = index.solidity.astHelper.extractStateVariables('contractUint', output.sources)
var decodeInfo = index.solidity.decodeInfo.decode(stateDec[0].attributes.type, stateDec)
checkDecodeInfo(st, decodeInfo, false, 1, 'uint8', 'uint')
checkDecodeInfo(st, decodeInfo, false, 1, 'uint8')
decodeInfo = index.solidity.decodeInfo.decode(stateDec[2].attributes.type, stateDec)
checkDecodeInfo(st, decodeInfo, false, 32, 'uint256', 'uint')
checkDecodeInfo(st, decodeInfo, false, 32, 'uint256')
decodeInfo = index.solidity.decodeInfo.decode(stateDec[3].attributes.type, stateDec)
checkDecodeInfo(st, decodeInfo, false, 32, 'uint256', 'uint')
checkDecodeInfo(st, decodeInfo, false, 32, 'uint256')
stateDec = index.solidity.astHelper.extractStateVariables('contractStructAndArray', output.sources)
decodeInfo = index.solidity.decodeInfo.decode(stateDec[1].attributes.type, stateDec)
checkDecodeInfo(st, decodeInfo, true, 64, 'struct structDef', 'struct')
checkDecodeInfo(st, decodeInfo, true, 64, 'struct structDef')
decodeInfo = index.solidity.decodeInfo.decode(stateDec[2].attributes.type, stateDec)
checkDecodeInfo(st, decodeInfo, true, 192, 'struct structDef[3]', 'arrayType')
checkDecodeInfo(st, decodeInfo, true, 192, 'struct structDef[3]')
decodeInfo = index.solidity.decodeInfo.decode(stateDec[3].attributes.type, stateDec)
checkDecodeInfo(st, decodeInfo, true, 48, 'bytes12[4]', 'arrayType')
checkDecodeInfo(st, decodeInfo, true, 48, 'bytes12[4]')
stateDec = index.solidity.astHelper.extractStateVariables('contractArray', output.sources)
decodeInfo = index.solidity.decodeInfo.decode(stateDec[0].attributes.type, stateDec)
checkDecodeInfo(st, decodeInfo, true, 4 * 5, 'uint32[5]', 'arrayType')
checkDecodeInfo(st, decodeInfo, true, 4 * 5, 'uint32[5]')
decodeInfo = index.solidity.decodeInfo.decode(stateDec[1].attributes.type, stateDec)
checkDecodeInfo(st, decodeInfo, true, 32, 'int8[]', 'arrayType')
checkDecodeInfo(st, decodeInfo, true, 32, 'int8[]')
decodeInfo = index.solidity.decodeInfo.decode(stateDec[2].attributes.type, stateDec)
checkDecodeInfo(st, decodeInfo, true, 4 * 32, 'int16[][3][][4]', 'arrayType')
checkDecodeInfo(st, decodeInfo, true, 4 * 32, 'int16[][3][][4]')
st.end()
})
})
@ -38,7 +38,6 @@ function checkDecodeInfo (st, decodeInfo, freeSlot, storageBytes, typeName, name
st.equal(decodeInfo.needsFreeStorageSlot, freeSlot)
st.equal(decodeInfo.storageBytes, storageBytes)
st.equal(decodeInfo.typeName, typeName)
st.equal(decodeInfo.name, name)
}
var contracts = `

Loading…
Cancel
Save