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

Object literal may only specify known properties, and '"internalType"' does not exist in type 'ParamType'. #728

Closed
aakilfernandes opened this issue Feb 12, 2020 · 19 comments
Labels
enhancement New feature or improvement. fixed/complete This Bug is fixed or Enhancement is complete and published.

Comments

@aakilfernandes
Copy link

This is a typescript compile issue, so should be able to fix this by just JSON.stringifying it and then passing it along. Making an issue here since ParamType should be able to hanlde internalType

[{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"previousOwner","type":"address"},{"indexed":true,"internalType":"address","name":"newOwner","type":"address"}],"name":"OwnershipTransferred","type":"event"},{"constant":true,"inputs":[{"internalType":"address","name":"","type":"address"},{"internalType":"address","name":"","type":"address"}],"name":"balances","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"internalType":"address","name":"to","type":"address"},{"internalType":"address","name":"token","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"deposit","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"internalType":"bytes32","name":"prevBlockHash","type":"bytes32"},{"components":[{"internalType":"address","name":"originator","type":"address"},{"internalType":"address","name":"quotToken","type":"address"},{"internalType":"address","name":"variToken","type":"address"},{"internalType":"uint256","name":"priceNumer","type":"uint256"},{"internalType":"uint256","name":"priceDenom","type":"uint256"},{"internalType":"uint256","name":"tokenLimit","type":"uint256"},{"internalType":"uint8","name":"signatureV","type":"uint8"},{"internalType":"bytes32","name":"signatureR","type":"bytes32"},{"internalType":"bytes32","name":"signatureS","type":"bytes32"}],"internalType":"struct Engine.Order[]","name":"buyyOrders","type":"tuple[]"},{"components":[{"internalType":"address","name":"originator","type":"address"},{"internalType":"address","name":"quotToken","type":"address"},{"internalType":"address","name":"variToken","type":"address"},{"internalType":"uint256","name":"priceNumer","type":"uint256"},{"internalType":"uint256","name":"priceDenom","type":"uint256"},{"internalType":"uint256","name":"tokenLimit","type":"uint256"},{"internalType":"uint8","name":"signatureV","type":"uint8"},{"internalType":"bytes32","name":"signatureR","type":"bytes32"},{"internalType":"bytes32","name":"signatureS","type":"bytes32"}],"internalType":"struct Engine.Order[]","name":"sellOrders","type":"tuple[]"},{"components":[{"internalType":"uint16","name":"buyyOrderIndex","type":"uint16"},{"internalType":"uint16","name":"sellOrderIndex","type":"uint16"},{"internalType":"uint256","name":"quotTokenTrans","type":"uint256"},{"internalType":"uint256","name":"variTokenTrans","type":"uint256"},{"internalType":"uint256","name":"quotTokenArbit","type":"uint256"}],"internalType":"struct Engine.Exchange[]","name":"exchanges","type":"tuple[]"}],"name":"execute","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"executorOracle","outputs":[{"internalType":"address","name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"isOwner","outputs":[{"internalType":"bool","name":"","type":"bool"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[],"name":"renounceOwnership","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"internalType":"address","name":"_executorOracle","type":"address"}],"name":"setExecutorOracle","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"internalType":"address","name":"newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"internalType":"address","name":"to","type":"address"},{"internalType":"address","name":"token","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"withdraw","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"}]
@ricmoo
Copy link
Member

ricmoo commented Feb 12, 2020

What is internalType? Is this in v4 or v5?

In v5, does this not match JsonFragment?

I get confused by how TypeScript sometimes chooses to allow additional properties and other times, not... does this need to extend any or { [ key: string ]: any } maybe?

@ricmoo ricmoo added the discussion Questions, feedback and general information. label Feb 12, 2020
@aakilfernandes
Copy link
Author

I'm actually not sure what internalType is. Not sure what you mean by v4 vs v5. Is there a versioned spec for solc ABIs?

does this need to extend any or { [ key: string ]: any } maybe

Yup, that would work. But its for JsonFragmentType, not JsonFragment.

@ricmoo
Copy link
Member

ricmoo commented Feb 12, 2020

Oh, I mean what version of ethers are you using? The v4 branch (current master) or v5 (@ next).

@aakilfernandes
Copy link
Author

4.0.42

@ricmoo
Copy link
Member

ricmoo commented Feb 12, 2020

Can you try upgrading the 4.0.44 and see if you still have the problem? (There were some typing issues introduced that were fixed after 4.0.43; it may or may not help, just checking)

@ricmoo
Copy link
Member

ricmoo commented Feb 12, 2020

Oh, can you also include a code snippet of what you are trying to do that causes that error?

@ricmoo
Copy link
Member

ricmoo commented Feb 16, 2020

@aakilfernandes Did you try out 4.0.44 and still have the same problem?

@ricmoo
Copy link
Member

ricmoo commented Mar 13, 2020

I think this has been addressed? If not, please reopen.

Thanks! :)

@ricmoo ricmoo closed this as completed Mar 13, 2020
@varunsrin
Copy link

varunsrin commented May 25, 2021

Typescript is still unhappy about this in v5.2.0, have to JSON.stringify() it to appease the compiler. The change happened here: https://github.com/ethereum/solidity/releases/tag/v0.5.11.

Adding it to fragments might solve the issue.

Happy to drop a PR if you agree.

@ricmoo
Copy link
Member

ricmoo commented May 25, 2021

Can you include the error?

@varunsrin
Copy link

Type '{ indexed: false; internalType: string; name: string; type: string; }' is not assignable to type 'JsonFragmentType'.
  Object literal may only specify known properties, and 'internalType' does not exist in type 'JsonFragmentType'.

@varunsrin
Copy link

varunsrin commented May 25, 2021

interestingly, the error is thrown with this:

import { ContractInterface } from 'ethers';

export const CONTRACT_ABI: ContractInterface = [
  {
    anonymous: false,
    inputs: [
      {
        indexed: false,
        internalType: 'address',
        name: 'previousAdmin',
        type: 'address',
      },
  .....
];

but not this:

import { ContractInterface } from 'ethers';

const CONTRACT_ABI_RAW = [
  {
    anonymous: false,
    inputs: [
      {
        indexed: false,
        internalType: 'address',
        name: 'previousAdmin',
        type: 'address',
      },
  .....
];

export const CONTRACT_ABI: ContractInterface = CONTRACT_ABI_RAW;

@zemse
Copy link
Collaborator

zemse commented May 26, 2021

I can confirm the problem exists. internalType is not listed in JsonFragmentType.

@zemse zemse reopened this May 26, 2021
@varunsrin
Copy link

@ricmoo any objections to me opening a PR to address?

@ricmoo
Copy link
Member

ricmoo commented May 30, 2021

Sorry, I’ve been busy with the EIP-1559 changes.

I will look into this (and a few other issues) early this week. I suspect it will be an easy change, I mainly am interested in why this changed; it used to be TS didn’t care about extra properties, only missing ones.

I wonder if they changed how types vs. interfaces work regarding object literals. I just need to look into it to find the best solution; ideally solidity adding new keys shouldn’t break JsonFragments. :)

@ricmoo ricmoo added investigate Under investigation and may be a bug. on-deck This Enhancement or Bug is currently being worked on. and removed discussion Questions, feedback and general information. labels May 30, 2021
@varunsrin
Copy link

From the interfaces docs:

Object literals get special treatment and undergo excess property checking when assigning them to other variables, or passing them as arguments. If an object literal has any properties that the “target type” doesn’t have, you’ll get an error:

I think it's been around for a while, looks like since v3.

It's just that in most cases you'd end up assigning it to the type Fragment vs declaring the object as as a Fragment. The former doesn't do excess checks, so it would work fine.

@ricmoo
Copy link
Member

ricmoo commented Jun 22, 2021

Coolio. I've tested and added readonly internalType?: any to minimize the impact on backwards compatibility. The property isn't used by ethers, but in v6 I'll compare to the schema and make sure the field types match up.

@ricmoo
Copy link
Member

ricmoo commented Jun 26, 2021

This has been fixed in 5.4.0. Sorry for the delay. Try it out and let me know how it works for you. :)

@ricmoo ricmoo added enhancement New feature or improvement. fixed/complete This Bug is fixed or Enhancement is complete and published. and removed investigate Under investigation and may be a bug. on-deck This Enhancement or Bug is currently being worked on. labels Jun 26, 2021
@ricmoo
Copy link
Member

ricmoo commented Aug 24, 2021

I think this is taken care of, so I'm going to close this issue. If you have any problems, feel free to re-open or start a new issue.

Thanks! :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or improvement. fixed/complete This Bug is fixed or Enhancement is complete and published.
Projects
None yet
Development

No branches or pull requests

4 participants