From a6ce24a12350e83284c597ad504b546b3f517b04 Mon Sep 17 00:00:00 2001 From: yann300 Date: Thu, 15 Dec 2016 11:25:30 +0100 Subject: [PATCH] add mapping type --- src/solidity/decodeInfo.js | 17 ++++++++++++++++- src/solidity/types/Mapping.js | 13 +++++++++++++ 2 files changed, 29 insertions(+), 1 deletion(-) create mode 100644 src/solidity/types/Mapping.js diff --git a/src/solidity/decodeInfo.js b/src/solidity/decodeInfo.js index 65b7582097..3246a1cf36 100644 --- a/src/solidity/decodeInfo.js +++ b/src/solidity/decodeInfo.js @@ -10,6 +10,17 @@ var StringType = require('./types/StringType') var StructType = require('./types/Struct') var IntType = require('./types/Int') var UintType = require('./types/Uint') +var MappingType = require('./types/Mapping') + +/** + * mapping decode the given @arg type + * + * @param {String} type - type given by the AST + * @return {Object} returns decoded info about the current type: { storageBytes, typeName} + */ +function Mapping (type) { + return new MappingType() +} /** * Uint decode the given @arg type @@ -212,6 +223,9 @@ function typeClass (fullType) { if (fullType.indexOf(']') !== -1) { return 'array' } + if (fullType.indexOf('mapping') === 0) { + return 'mapping' + } if (fullType.indexOf(' ') !== -1) { fullType = fullType.split(' ')[0] } @@ -238,7 +252,8 @@ function parseType (type, stateDefinitions, contractName) { 'string': String, 'struct': Struct, 'int': Int, - 'uint': Uint + 'uint': Uint, + 'mapping': Mapping } var currentType = typeClass(type) if (currentType === null) { diff --git a/src/solidity/types/Mapping.js b/src/solidity/types/Mapping.js new file mode 100644 index 0000000000..fc34101793 --- /dev/null +++ b/src/solidity/types/Mapping.js @@ -0,0 +1,13 @@ +'use strict' + +function Mapping () { + this.storageSlots = 1 + this.storageBytes = 32 + this.typeName = 'mapping' +} + +Mapping.prototype.decodeFromStorage = function (location, storageContent) { + return '' +} + +module.exports = Mapping