Commit c38dc7f4 authored by yann300's avatar yann300

use lowercase for function

parent a9b3e009
...@@ -18,7 +18,7 @@ var MappingType = require('./types/Mapping') ...@@ -18,7 +18,7 @@ var MappingType = require('./types/Mapping')
* @param {String} type - type given by the AST * @param {String} type - type given by the AST
* @return {Object} returns decoded info about the current type: { storageBytes, typeName} * @return {Object} returns decoded info about the current type: { storageBytes, typeName}
*/ */
function Mapping (type) { function mapping (type) {
return new MappingType() return new MappingType()
} }
...@@ -28,7 +28,7 @@ function Mapping (type) { ...@@ -28,7 +28,7 @@ function Mapping (type) {
* @param {String} type - type given by the AST (e.g uint256, uint32) * @param {String} type - type given by the AST (e.g uint256, uint32)
* @return {Object} returns decoded info about the current type: { storageBytes, typeName} * @return {Object} returns decoded info about the current type: { storageBytes, typeName}
*/ */
function Uint (type) { function uint (type) {
type === 'uint' ? 'uint256' : type type === 'uint' ? 'uint256' : type
var storageBytes = parseInt(type.replace('uint', '')) / 8 var storageBytes = parseInt(type.replace('uint', '')) / 8
return new UintType(storageBytes) return new UintType(storageBytes)
...@@ -40,7 +40,7 @@ function Uint (type) { ...@@ -40,7 +40,7 @@ function Uint (type) {
* @param {String} type - type given by the AST (e.g int256, int32) * @param {String} type - type given by the AST (e.g int256, int32)
* @return {Object} returns decoded info about the current type: { storageBytes, typeName} * @return {Object} returns decoded info about the current type: { storageBytes, typeName}
*/ */
function Int (type) { function int (type) {
type === 'int' ? 'int256' : type type === 'int' ? 'int256' : type
var storageBytes = parseInt(type.replace('int', '')) / 8 var storageBytes = parseInt(type.replace('int', '')) / 8
return new IntType(storageBytes) return new IntType(storageBytes)
...@@ -52,7 +52,7 @@ function Int (type) { ...@@ -52,7 +52,7 @@ function Int (type) {
* @param {String} type - type given by the AST (e.g address) * @param {String} type - type given by the AST (e.g address)
* @return {Object} returns decoded info about the current type: { storageBytes, typeName} * @return {Object} returns decoded info about the current type: { storageBytes, typeName}
*/ */
function Address (type) { function address (type) {
return new AddressType() return new AddressType()
} }
...@@ -62,7 +62,7 @@ function Address (type) { ...@@ -62,7 +62,7 @@ function Address (type) {
* @param {String} type - type given by the AST (e.g bool) * @param {String} type - type given by the AST (e.g bool)
* @return {Object} returns decoded info about the current type: { storageBytes, typeName} * @return {Object} returns decoded info about the current type: { storageBytes, typeName}
*/ */
function Bool (type) { function bool (type) {
return new BoolType() return new BoolType()
} }
...@@ -72,7 +72,7 @@ function Bool (type) { ...@@ -72,7 +72,7 @@ function Bool (type) {
* @param {String} type - type given by the AST (e.g bytes storage ref) * @param {String} type - type given by the AST (e.g bytes storage ref)
* @return {Object} returns decoded info about the current type: { storageBytes, typeName} * @return {Object} returns decoded info about the current type: { storageBytes, typeName}
*/ */
function DynamicByteArray (type) { function dynamicByteArray (type) {
var match = type.match(/( storage ref| storage pointer| memory| calldata)?$/) var match = type.match(/( storage ref| storage pointer| memory| calldata)?$/)
if (match.length > 1) { if (match.length > 1) {
return new BytesType(match[1].trim()) return new BytesType(match[1].trim())
...@@ -87,7 +87,7 @@ function DynamicByteArray (type) { ...@@ -87,7 +87,7 @@ function DynamicByteArray (type) {
* @param {String} type - type given by the AST (e.g bytes16) * @param {String} type - type given by the AST (e.g bytes16)
* @return {Object} returns decoded info about the current type: { storageBytes, typeName} * @return {Object} returns decoded info about the current type: { storageBytes, typeName}
*/ */
function FixedByteArray (type) { function fixedByteArray (type) {
var storageBytes = parseInt(type.replace('bytes', '')) var storageBytes = parseInt(type.replace('bytes', ''))
return new BytesXType(storageBytes) return new BytesXType(storageBytes)
} }
...@@ -98,7 +98,7 @@ function FixedByteArray (type) { ...@@ -98,7 +98,7 @@ function FixedByteArray (type) {
* @param {String} type - type given by the AST (e.g string storage ref) * @param {String} type - type given by the AST (e.g string storage ref)
* @return {Object} returns decoded info about the current type: { storageBytes, typeName} * @return {Object} returns decoded info about the current type: { storageBytes, typeName}
*/ */
function String (type) { function stringType (type) {
var match = type.match(/( storage ref| storage pointer| memory| calldata)?$/) var match = type.match(/( storage ref| storage pointer| memory| calldata)?$/)
if (match.length > 1) { if (match.length > 1) {
return new StringType(match[1].trim()) return new StringType(match[1].trim())
...@@ -115,7 +115,7 @@ function String (type) { ...@@ -115,7 +115,7 @@ function String (type) {
* @param {String} contractName - contract the @args typeName belongs to * @param {String} contractName - contract the @args typeName belongs to
* @return {Object} returns decoded info about the current type: { storageBytes, typeName, arraySize, subArray} * @return {Object} returns decoded info about the current type: { storageBytes, typeName, arraySize, subArray}
*/ */
function Array (type, stateDefinitions, contractName) { function array (type, stateDefinitions, contractName) {
var arraySize var arraySize
var match = type.match(/(.*)\[(.*?)\]( storage ref| storage pointer| memory| calldata)?$/) var match = type.match(/(.*)\[(.*?)\]( storage ref| storage pointer| memory| calldata)?$/)
if (!match || match.length < 3) { if (!match || match.length < 3) {
...@@ -140,7 +140,7 @@ function Array (type, stateDefinitions, contractName) { ...@@ -140,7 +140,7 @@ function Array (type, stateDefinitions, contractName) {
* @param {String} contractName - contract the @args typeName belongs to * @param {String} contractName - contract the @args typeName belongs to
* @return {Object} returns decoded info about the current type: { storageBytes, typeName, enum} * @return {Object} returns decoded info about the current type: { storageBytes, typeName, enum}
*/ */
function Enum (type, stateDefinitions, contractName) { function enumType (type, stateDefinitions, contractName) {
var match = type.match(/enum (.*)/) var match = type.match(/enum (.*)/)
var enumDef = getEnum(match[1], stateDefinitions, contractName) var enumDef = getEnum(match[1], stateDefinitions, contractName)
if (enumDef === null) { if (enumDef === null) {
...@@ -158,7 +158,7 @@ function Enum (type, stateDefinitions, contractName) { ...@@ -158,7 +158,7 @@ function Enum (type, stateDefinitions, contractName) {
* @param {String} contractName - contract the @args typeName belongs to * @param {String} contractName - contract the @args typeName belongs to
* @return {Object} returns decoded info about the current type: { storageBytes, typeName, members} * @return {Object} returns decoded info about the current type: { storageBytes, typeName, members}
*/ */
function Struct (type, stateDefinitions, contractName) { function struct (type, stateDefinitions, contractName) {
var match = type.match(/struct (.*?)( storage ref| storage pointer| memory| calldata)?$/) var match = type.match(/struct (.*?)( storage ref| storage pointer| memory| calldata)?$/)
if (match && match.length > 2) { if (match && match.length > 2) {
var memberDetails = getStructMembers(match[1], stateDefinitions, contractName) // type is used to extract the ast struct definition var memberDetails = getStructMembers(match[1], stateDefinitions, contractName) // type is used to extract the ast struct definition
...@@ -255,17 +255,17 @@ function typeClass (fullType) { ...@@ -255,17 +255,17 @@ function typeClass (fullType) {
*/ */
function parseType (type, stateDefinitions, contractName) { function parseType (type, stateDefinitions, contractName) {
var decodeInfos = { var decodeInfos = {
'address': Address, 'address': address,
'array': Array, 'array': array,
'bool': Bool, 'bool': bool,
'bytes': DynamicByteArray, 'bytes': dynamicByteArray,
'bytesX': FixedByteArray, 'bytesX': fixedByteArray,
'enum': Enum, 'enum': enumType,
'string': String, 'string': stringType,
'struct': Struct, 'struct': struct,
'int': Int, 'int': int,
'uint': Uint, 'uint': uint,
'mapping': Mapping 'mapping': mapping
} }
var currentType = typeClass(type) var currentType = typeClass(type)
if (currentType === null) { if (currentType === null) {
...@@ -327,14 +327,14 @@ function computeOffsets (types, stateDefinitions, contractName) { ...@@ -327,14 +327,14 @@ function computeOffsets (types, stateDefinitions, contractName) {
module.exports = { module.exports = {
parseType: parseType, parseType: parseType,
computeOffsets: computeOffsets, computeOffsets: computeOffsets,
Uint: Uint, Uint: uint,
Address: Address, Address: address,
Bool: Bool, Bool: bool,
DynamicByteArray: DynamicByteArray, DynamicByteArray: dynamicByteArray,
FixedByteArray: FixedByteArray, FixedByteArray: fixedByteArray,
Int: Int, Int: int,
String: String, String: stringType,
Array: Array, Array: array,
Enum: Enum, Enum: enumType,
Struct: Struct Struct: struct
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment