Allow storage class in Human-Readable ABI (#476).
This commit is contained in:
parent
044554b585
commit
cf39adb090
@ -50,6 +50,7 @@ type ParseNode = {
|
|||||||
components?: Array<ParseNode>
|
components?: Array<ParseNode>
|
||||||
};
|
};
|
||||||
|
|
||||||
|
let storageClasses: { [ name: string ]: boolean } = { calldata: true, memory: true, storage: true };
|
||||||
|
|
||||||
// @TODO: Make sure that children of an indexed tuple are marked with a null indexed
|
// @TODO: Make sure that children of an indexed tuple are marked with a null indexed
|
||||||
function parseParamType(param: string, allowIndexed: boolean): ParseNode {
|
function parseParamType(param: string, allowIndexed: boolean): ParseNode {
|
||||||
@ -82,12 +83,15 @@ function parseParamType(param: string, allowIndexed: boolean): ParseNode {
|
|||||||
|
|
||||||
case ")":
|
case ")":
|
||||||
delete node.state;
|
delete node.state;
|
||||||
if (allowIndexed) {
|
|
||||||
if (node.name === "indexed") {
|
if (node.name === "indexed") {
|
||||||
node.indexed = true;
|
if (!allowIndexed) { throwError(i); }
|
||||||
node.name = "";
|
node.indexed = true;
|
||||||
}
|
node.name = "";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (storageClasses[node.name]) { node.name = ""; }
|
||||||
|
|
||||||
node.type = verifyType(node.type);
|
node.type = verifyType(node.type);
|
||||||
|
|
||||||
let child = node;
|
let child = node;
|
||||||
@ -101,12 +105,15 @@ function parseParamType(param: string, allowIndexed: boolean): ParseNode {
|
|||||||
|
|
||||||
case ",":
|
case ",":
|
||||||
delete node.state;
|
delete node.state;
|
||||||
if (allowIndexed) {
|
|
||||||
if (node.name === "indexed") {
|
if (node.name === "indexed") {
|
||||||
node.indexed = true;
|
if (!allowIndexed) { throwError(i); }
|
||||||
node.name = "";
|
node.indexed = true;
|
||||||
}
|
node.name = "";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (storageClasses[node.name]) { node.name = ""; }
|
||||||
|
|
||||||
node.type = verifyType(node.type);
|
node.type = verifyType(node.type);
|
||||||
|
|
||||||
let sibling: ParseNode = newNode(node.parent);
|
let sibling: ParseNode = newNode(node.parent);
|
||||||
@ -132,12 +139,13 @@ function parseParamType(param: string, allowIndexed: boolean): ParseNode {
|
|||||||
// If reading name, the name is done
|
// If reading name, the name is done
|
||||||
if (node.state.allowName) {
|
if (node.state.allowName) {
|
||||||
if (node.name !== "") {
|
if (node.name !== "") {
|
||||||
if (allowIndexed) {
|
if (node.name === "indexed") {
|
||||||
if (node.name === "indexed") {
|
if (!allowIndexed) { throwError(i); }
|
||||||
if (node.indexed) { throwError(i); }
|
if (node.indexed) { throwError(i); }
|
||||||
node.indexed = true;
|
node.indexed = true;
|
||||||
node.name = "";
|
node.name = "";
|
||||||
}
|
} else if (storageClasses[node.name]) {
|
||||||
|
node.name = "";
|
||||||
} else {
|
} else {
|
||||||
node.state.allowName = false;
|
node.state.allowName = false;
|
||||||
}
|
}
|
||||||
@ -186,13 +194,15 @@ function parseParamType(param: string, allowIndexed: boolean): ParseNode {
|
|||||||
|
|
||||||
delete parent.state;
|
delete parent.state;
|
||||||
|
|
||||||
if (allowIndexed) {
|
if (node.name === "indexed") {
|
||||||
if (node.name === "indexed") {
|
if (!allowIndexed) { throwError(originalParam.length - 7); }
|
||||||
if (node.indexed) { throwError(originalParam.length - 7); }
|
if (node.indexed) { throwError(originalParam.length - 7); }
|
||||||
node.indexed = true;
|
node.indexed = true;
|
||||||
node.name = "";
|
node.name = "";
|
||||||
}
|
} else if (storageClasses[node.name]) {
|
||||||
|
node.name = "";
|
||||||
}
|
}
|
||||||
|
|
||||||
parent.type = verifyType(parent.type);
|
parent.type = verifyType(parent.type);
|
||||||
|
|
||||||
return parent;
|
return parent;
|
||||||
@ -476,7 +486,7 @@ function parseModifiers(value: string, params: any): void {
|
|||||||
params.constant = false;
|
params.constant = false;
|
||||||
params.payable = false;
|
params.payable = false;
|
||||||
// @TODO: Should this be initialized to "nonpayable"?
|
// @TODO: Should this be initialized to "nonpayable"?
|
||||||
params.stateMutability = null;
|
params.stateMutability = "nonpayable";
|
||||||
|
|
||||||
value.split(" ").forEach((modifier) => {
|
value.split(" ").forEach((modifier) => {
|
||||||
switch (modifier.trim()) {
|
switch (modifier.trim()) {
|
||||||
|
Loading…
Reference in New Issue
Block a user