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

@ -9,27 +9,27 @@ tape('solidity', function (t) {
var stateDec = index.solidity.astHelper.extractStateVariables('contractUint', output.sources) var stateDec = index.solidity.astHelper.extractStateVariables('contractUint', output.sources)
var decodeInfo = index.solidity.decodeInfo.decode(stateDec[0].attributes.type, stateDec) 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) 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) 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) stateDec = index.solidity.astHelper.extractStateVariables('contractStructAndArray', output.sources)
decodeInfo = index.solidity.decodeInfo.decode(stateDec[1].attributes.type, stateDec) 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) 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) 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) stateDec = index.solidity.astHelper.extractStateVariables('contractArray', output.sources)
decodeInfo = index.solidity.decodeInfo.decode(stateDec[0].attributes.type, stateDec) 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) 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) 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() st.end()
}) })
}) })
@ -38,7 +38,6 @@ function checkDecodeInfo (st, decodeInfo, freeSlot, storageBytes, typeName, name
st.equal(decodeInfo.needsFreeStorageSlot, freeSlot) st.equal(decodeInfo.needsFreeStorageSlot, freeSlot)
st.equal(decodeInfo.storageBytes, storageBytes) st.equal(decodeInfo.storageBytes, storageBytes)
st.equal(decodeInfo.typeName, typeName) st.equal(decodeInfo.typeName, typeName)
st.equal(decodeInfo.name, name)
} }
var contracts = ` var contracts = `

Loading…
Cancel
Save