Skip to content

Commit 2cf030e

Browse files
ricmooWoodpile37
authored andcommitted
Fix JSON formatting for tuple arrays (ethers-io#4237).
1 parent ee9e0dd commit 2cf030e

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

src.ts/abi/fragments.ts

+13-2
Original file line numberDiff line numberDiff line change
@@ -612,10 +612,21 @@ export class ParamType {
612612
format(format?: FormatType): string {
613613
if (format == null) { format = "sighash"; }
614614
if (format === "json") {
615-
let result: any = {
615+
const name = this.name || undefined; // @TODO: Make this "" (minor bump)
616+
617+
if (this.isArray()) {
618+
const result = JSON.parse(this.arrayChildren.format("json"));
619+
result.name = name;
620+
result.type += `[${ (this.arrayLength < 0 ? "": String(this.arrayLength)) }]`;
621+
return JSON.stringify(result);
622+
}
623+
624+
const result: any = {
616625
type: ((this.baseType === "tuple") ? "tuple": this.type),
617-
name: (this.name || undefined)
626+
name
618627
};
628+
629+
619630
if (typeof(this.indexed) === "boolean") { result.indexed = this.indexed; }
620631
if (this.isTuple()) {
621632
result.components = this.components.map((c) => JSON.parse(c.format(format)));

0 commit comments

Comments
 (0)