Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix fragment json formatting object keys #1245

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions packages/abi/lib.esm/fragments.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion packages/abi/lib.esm/fragments.js.map

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions packages/abi/lib/fragments.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion packages/abi/lib/fragments.js.map

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions packages/abi/src.ts/fragments.ts
Original file line number Diff line number Diff line change
Expand Up @@ -817,10 +817,10 @@ export class FunctionFragment extends ConstructorFragment {
name: this.name,
constant: this.constant,
stateMutability: ((this.stateMutability !== "nonpayable") ? this.stateMutability: undefined),
payble: this.payable,
payable: this.payable,
gas: (this.gas ? this.gas.toNumber(): undefined),
inputs: this.inputs.map((input) => JSON.parse(input.format(format))),
ouputs: this.outputs.map((output) => JSON.parse(output.format(format))),
outputs: this.outputs.map((output) => JSON.parse(output.format(format))),
});
}

Expand Down
4 changes: 2 additions & 2 deletions packages/ethers/dist/ethers.esm.js
Original file line number Diff line number Diff line change
Expand Up @@ -5536,10 +5536,10 @@ class FunctionFragment extends ConstructorFragment {
name: this.name,
constant: this.constant,
stateMutability: ((this.stateMutability !== "nonpayable") ? this.stateMutability : undefined),
payble: this.payable,
payable: this.payable,
gas: (this.gas ? this.gas.toNumber() : undefined),
inputs: this.inputs.map((input) => JSON.parse(input.format(format))),
ouputs: this.outputs.map((output) => JSON.parse(output.format(format))),
outputs: this.outputs.map((output) => JSON.parse(output.format(format))),
});
}
let result = "";
Expand Down
2 changes: 1 addition & 1 deletion packages/ethers/dist/ethers.esm.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion packages/ethers/dist/ethers.esm.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion packages/ethers/dist/ethers.esm.min.js.map

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions packages/ethers/dist/ethers.umd.js
Original file line number Diff line number Diff line change
Expand Up @@ -5774,10 +5774,10 @@
name: this.name,
constant: this.constant,
stateMutability: ((this.stateMutability !== "nonpayable") ? this.stateMutability : undefined),
payble: this.payable,
payable: this.payable,
gas: (this.gas ? this.gas.toNumber() : undefined),
inputs: this.inputs.map(function (input) { return JSON.parse(input.format(format)); }),
ouputs: this.outputs.map(function (output) { return JSON.parse(output.format(format)); }),
outputs: this.outputs.map(function (output) { return JSON.parse(output.format(format)); }),
});
}
var result = "";
Expand Down
2 changes: 1 addition & 1 deletion packages/ethers/dist/ethers.umd.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion packages/ethers/dist/ethers.umd.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion packages/ethers/dist/ethers.umd.min.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion packages/testcases/lib/browser-data.json

Large diffs are not rendered by default.

7 changes: 7 additions & 0 deletions packages/tests/lib.esm/test-contract-interface.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion packages/tests/lib.esm/test-contract-interface.js.map

Large diffs are not rendered by default.

7 changes: 7 additions & 0 deletions packages/tests/lib/test-contract-interface.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion packages/tests/lib/test-contract-interface.js.map

Large diffs are not rendered by default.

8 changes: 8 additions & 0 deletions packages/tests/src.ts/test-contract-interface.ts
Original file line number Diff line number Diff line change
Expand Up @@ -270,6 +270,14 @@ describe('Test Interface Signatures', function() {
})
});

it('formatted json output should contain correct keys', function() {
let iface = new ethers.utils.Interface([ "function balanceOf(address) view returns (uint256)" ])
let parsed = JSON.parse(iface.format('json') as string)[0];
['type', 'name', 'constant', 'stateMutability', 'payable', 'inputs', 'outputs'].forEach(function(key) {
assert.ok(parsed.hasOwnProperty(key), "json output has key - " + key);
})
});

it('derives correct description for human-readable ABI', function() {
let iface = new ethers.utils.Interface([ "function transfer(address from, uint amount)" ]);
[
Expand Down