Skip to content
This repository has been archived by the owner on Mar 5, 2025. It is now read-only.

Contract call with tuple is missing param names #5613

Merged
merged 14 commits into from
Nov 30, 2022

Conversation

avkos
Copy link
Contributor

@avkos avkos commented Nov 14, 2022

Description

#5504

Checklist for 4.x:

  • I have selected the correct 4.x base branch.
  • Within the description, the feature or issue is discussed in detail or an issue is linked.
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas.
  • I have added any required tests for the changes I made
  • I have made corresponding changes to the documentation
  • Any dependent changes have been merged and published in downstream modules.
  • I ran yarn successfully
  • I ran yarn lint successfully
  • I ran yarn build:web successfully
  • I ran yarn test:unit successfully
  • I ran yarn test:integration successfully
  • I ran compile:contracts successfully
  • I have tested my code.
  • I have updated the corresponding CHANGELOG.md file in the packages I have edited.

@render
Copy link

render bot commented Nov 14, 2022

Copy link
Contributor

@mpetrunic mpetrunic left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This works sort of, I was hoping you would solve this: https://github.com/web3/web3.js/blob/4.x/packages/web3-eth-abi/src/types.ts#L193 😜

@avkos
Copy link
Contributor Author

avkos commented Nov 14, 2022

This works sort of, I was hoping you would solve this: https://github.com/web3/web3.js/blob/4.x/packages/web3-eth-abi/src/types.ts#L193 😜

I've tried to figure it out but seems typescript not supporting dynamic names for the tuples right now.

@avkos avkos requested a review from mpetrunic November 14, 2022 17:13
@mpetrunic
Copy link
Contributor

@avkos Here is an idea #5624 ^^

@avkos
Copy link
Contributor Author

avkos commented Nov 17, 2022

@avkos Here is an idea #5624 ^^

Thanks a lot. I'll investigate it.

Copy link
Contributor

@jdevcs jdevcs left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Its causing many tests to fail in https://github.com/web3/web3.js/actions/runs/3490219406/jobs/5841458348#step:4:176 all these tests should be passing before merging PR.

@Muhammad-Altabba Muhammad-Altabba self-requested a review November 20, 2022 21:30
@Muhammad-Altabba Muhammad-Altabba dismissed their stale review November 20, 2022 21:32

Tests are not passing

@mpetrunic
Copy link
Contributor

Its causing many tests to fail in https://github.com/web3/web3.js/actions/runs/3490219406/jobs/5841458348#step:4:176 all these tests should be passing before merging PR.

Even though types should be fixed to support that, it makes more sense to use output param name instead of array index in those tests as it's much more type safer.

It might make sense to introduce type only tests for web3-eth-abi package: https://medium.com/front-end-weekly/testing-typescript-types-1595c641d7c7^^

@mpetrunic
Copy link
Contributor

@avkos #5647 adds type tests and support for single output tuple

@avkos
Copy link
Contributor Author

avkos commented Nov 22, 2022

  • add the possibility to see types in the output types

image

  • if single output returns exactly one type

image

  • for overloaded functions shows all variants of input parameters

image

@mpetrunic
Copy link
Contributor

  • add the possibility to see types in the output types
image
  • if single output returns exactly one type
image
  • for overloaded functions shows all variants of input parameters
image

Think you should check my PR as I've extended tests so you can cover all this cases with tests to make sure everything works^^

@avkos
Copy link
Contributor Author

avkos commented Nov 24, 2022

I've fixed the types. Now they work in both ways by index and by name. Also, type tests were added. @mpetrunic

@avkos avkos requested a review from jdevcs November 24, 2022 22:38
@mpetrunic
Copy link
Contributor

I've fixed the types. Now they work in both ways by index and by name. Also, type tests were added. @mpetrunic

@jdevcs @mconnelly8 Would it make sense to open an issue to create a guide for users explaining how to extract result types from abi (as they will probably need to do something with the result)? Like type GetBalanceResult = SomethingSomething<typeof abi[1]>

Copy link
Contributor

@spacesailor24 spacesailor24 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add CHANGELOG.md entries (for root, web3-eth-abi, and web3-eth-contract)

@avkos avkos requested a review from spacesailor24 November 30, 2022 02:31
@avkos
Copy link
Contributor Author

avkos commented Nov 30, 2022

Please add CHANGELOG.md entries (for root, web3-eth-abi, and web3-eth-contract)

Changelogs were added

@avkos avkos merged commit 19269ae into 4.x Nov 30, 2022
@avkos avkos deleted the ok/5504-Contract-call-with-tuple-is-missing-param-names branch November 30, 2022 03:29
jdevcs added a commit that referenced this pull request Dec 8, 2022
* Update CHANGELOG version headers

* Contract call with tuple is missing param names (#5613)

* call special output type

* fix

* fix: enable outputs to have param names (#5624)

* hot fix

* add type if only one param

* overloaded inputs types

* fix resolver tests

* add type tests

* simplify types

* revert registry unit test

* test firefox

* revert firefox test

* update changelogs

Co-authored-by: Marin Petrunić <[email protected]>

* Fix `isHex` and `isHexStrict` for some edge cases and enrich their tests (#5655)

* Change `isHex` to return true for negative numbers (for example `-123`)
* Change both `isHex` and `isHexStrict` to return `false` for `-0x`
* Change `isHex` to return `false` for empty strings ''.

* Remove erroneous set provider code for Contract constructor (#5669)

* Remove erroneous set provider code for Contract constructor. Add Contract constructor provider set test

* Update CHANGELOGs

* Debugging failing integration tests

* Apply suggestions from code review

* Use getSystemTestProvider instead of hardcoded string

* Refactor ternaries in Contract constructor to if statements

* Correct CHANGELOG entries

* Remove unneeded checks in if statements

* Test with injected external providers (#5652)

* fix: sending tx with injected provider (#5651)

Co-authored-by: Marin Petrunic <[email protected]>

* adding a test for using `ganache` provider

* enable the jsonrpc `id` to optionally be incremented starting from a number
 (Inspired by: #5373 (comment) and needed as a work around for blockchainsllc/in3#46)

* test with `in3` as a provider & skip `in3` test if it takes too long

* increase integration test timeout at web3 package

* add a test for using `hardhat` provider

* improve how legacy providers, such as hardhat, is used

* implement `isPromise` that works in the browsers

* refactor external providers tests

* update CHANGELOG.md

* Use Error ABI to parse errors when sending a transaction (#5662)

* use Error ABI when sending a transaction

* update CHANGELOG.md for #5587

* Remove merge conflict marker

Co-authored-by: Oleksii Kosynskyi <[email protected]>
Co-authored-by: Marin Petrunić <[email protected]>
Co-authored-by: Muhammad Altabba <[email protected]>
Co-authored-by: jdevcs <[email protected]>
spacesailor24 added a commit that referenced this pull request Dec 8, 2022
* Version bump and build for v4.0.1-alpha.2

* Release/4.0.1 alpha.2 changelog update 3 (#5689)

* Update CHANGELOG version headers

* Update CHANGELOGs

* Revert package version bump for web3-packagetemplate

* Release/4.0.1 alpha.2 merge conflicts (#5692)

* Update CHANGELOG version headers

* Contract call with tuple is missing param names (#5613)

* call special output type

* fix

* fix: enable outputs to have param names (#5624)

* hot fix

* add type if only one param

* overloaded inputs types

* fix resolver tests

* add type tests

* simplify types

* revert registry unit test

* test firefox

* revert firefox test

* update changelogs

Co-authored-by: Marin Petrunić <[email protected]>

* Fix `isHex` and `isHexStrict` for some edge cases and enrich their tests (#5655)

* Change `isHex` to return true for negative numbers (for example `-123`)
* Change both `isHex` and `isHexStrict` to return `false` for `-0x`
* Change `isHex` to return `false` for empty strings ''.

* Remove erroneous set provider code for Contract constructor (#5669)

* Remove erroneous set provider code for Contract constructor. Add Contract constructor provider set test

* Update CHANGELOGs

* Debugging failing integration tests

* Apply suggestions from code review

* Use getSystemTestProvider instead of hardcoded string

* Refactor ternaries in Contract constructor to if statements

* Correct CHANGELOG entries

* Remove unneeded checks in if statements

* Test with injected external providers (#5652)

* fix: sending tx with injected provider (#5651)

Co-authored-by: Marin Petrunic <[email protected]>

* adding a test for using `ganache` provider

* enable the jsonrpc `id` to optionally be incremented starting from a number
 (Inspired by: #5373 (comment) and needed as a work around for blockchainsllc/in3#46)

* test with `in3` as a provider & skip `in3` test if it takes too long

* increase integration test timeout at web3 package

* add a test for using `hardhat` provider

* improve how legacy providers, such as hardhat, is used

* implement `isPromise` that works in the browsers

* refactor external providers tests

* update CHANGELOG.md

* Use Error ABI to parse errors when sending a transaction (#5662)

* use Error ABI when sending a transaction

* update CHANGELOG.md for #5587

* Remove merge conflict marker

Co-authored-by: Oleksii Kosynskyi <[email protected]>
Co-authored-by: Marin Petrunić <[email protected]>
Co-authored-by: Muhammad Altabba <[email protected]>
Co-authored-by: jdevcs <[email protected]>

* Release patch/4.0.1 alpha.2/solve merge conflicts (#5697)

* Update CHANGELOG version headers

* Remove merge conflict markers

* Remove double CHANGELOG entry

Co-authored-by: Oleksii Kosynskyi <[email protected]>
Co-authored-by: Marin Petrunić <[email protected]>
Co-authored-by: Muhammad Altabba <[email protected]>
Co-authored-by: jdevcs <[email protected]>
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants