gridplus-sdk
Advanced tools
Comparing version 0.7.23 to 0.7.24
{ | ||
"name": "gridplus-sdk", | ||
"version": "0.7.23", | ||
"version": "0.7.24", | ||
"description": "SDK to interact with GridPlus Lattice1 device", | ||
@@ -5,0 +5,0 @@ "scripts": { |
@@ -50,3 +50,3 @@ const Buffer = require('buffer/').Buffer | ||
def.params.forEach((param) => { | ||
if (!param.name || !param.latticeTypeIdx || param.isArray === undefined || param.arraySz === undefined) | ||
if (param.name === undefined || param.latticeTypeIdx === undefined || param.isArray === undefined || param.arraySz === undefined) | ||
throw new Error('name, latticeTypeIdx, isArray, and arraySz must be defined for all ABI params.'); | ||
@@ -137,28 +137,33 @@ Buffer.from(param.name).slice(0, 20).copy(b, off); off += 20; | ||
const closeBracketIdx = typeName.indexOf(']'); | ||
if (openBracketIdx > -1 && closeBracketIdx > -1) { | ||
if (openBracketIdx >= closeBracketIdx) { | ||
; // not a valid param -- skip it | ||
} else if ((openBracketIdx + 1) === closeBracketIdx) { | ||
d.isArray = true; | ||
} else { | ||
// Parse the array size if applicable | ||
const number = parseInt(typeName.slice(openBracketIdx, closeBracketIdx)) | ||
if (isNaN(number)) { | ||
return d; | ||
const isMultiDim = typeName.split('[').length > 2; | ||
if (isMultiDim) { | ||
throw new Error('Skipping function with unsupported multidimensional array type') | ||
} else { | ||
if (openBracketIdx > -1 && closeBracketIdx > -1) { | ||
if (openBracketIdx >= closeBracketIdx) { | ||
; // not a valid param -- skip it | ||
} else if ((openBracketIdx + 1) === closeBracketIdx) { | ||
d.isArray = true; | ||
} else { | ||
// Parse the array size if applicable | ||
const number = parseInt(typeName.slice(openBracketIdx, closeBracketIdx)) | ||
if (isNaN(number)) { | ||
return d; | ||
} | ||
d.isArray = true; | ||
d.arraySz = number; | ||
} | ||
d.isArray = true; | ||
d.arraySz = number; | ||
} | ||
let singularTypeName = openBracketIdx > -1 ? typeName.slice(0, openBracketIdx) : typeName; | ||
if (singularTypeName === 'tuple') { | ||
if (isNestedTuple === true) | ||
throw new Error('Nested tuples are not supported') | ||
singularTypeName = `tuple${input.components.length}`; | ||
tupleParams = parseEtherscanAbiInputs(input.components, tupleParams, true); | ||
} | ||
d.latticeTypeIdx = getTypeIdxLatticeFw(singularTypeName) | ||
if (!d.latticeTypeIdx) | ||
throw new Error(`Unsupported type: ${typeName}`) | ||
data.push(d) | ||
} | ||
let singularTypeName = openBracketIdx > -1 ? typeName.slice(0, openBracketIdx) : typeName; | ||
if (singularTypeName === 'tuple') { | ||
if (isNestedTuple === true) | ||
throw new Error('Nested tuples are not supported') | ||
singularTypeName = `tuple${input.components.length}`; | ||
tupleParams = parseEtherscanAbiInputs(input.components, tupleParams, true); | ||
} | ||
d.latticeTypeIdx = getTypeIdxLatticeFw(singularTypeName) | ||
if (!d.latticeTypeIdx) | ||
throw new Error(`Unsupported type: ${typeName}`) | ||
data.push(d) | ||
}) | ||
@@ -165,0 +170,0 @@ const params = data.concat(tupleParams) |
105650
2408