Skip to content

Commit

Permalink
Fix JSON formatting for tuple arrays (#4237).
Browse files Browse the repository at this point in the history
  • Loading branch information
ricmoo committed Jul 24, 2023
1 parent e36b6c3 commit a8bc49b
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions src.ts/abi/fragments.ts
Original file line number Diff line number Diff line change
Expand Up @@ -612,10 +612,21 @@ export class ParamType {
format(format?: FormatType): string {
if (format == null) { format = "sighash"; }
if (format === "json") {
let result: any = {
const name = this.name || undefined; // @TODO: Make this "" (minor bump)

if (this.isArray()) {
const result = JSON.parse(this.arrayChildren.format("json"));
result.name = name;
result.type += `[${ (this.arrayLength < 0 ? "": String(this.arrayLength)) }]`;
return JSON.stringify(result);
}

const result: any = {
type: ((this.baseType === "tuple") ? "tuple": this.type),
name: (this.name || undefined)
name
};


if (typeof(this.indexed) === "boolean") { result.indexed = this.indexed; }
if (this.isTuple()) {
result.components = this.components.map((c) => JSON.parse(c.format(format)));
Expand Down

0 comments on commit a8bc49b

Please # to comment.