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

Add support for generating functions with structs as parameters. #368

Open
iikirilov opened this issue Feb 19, 2018 · 42 comments · May be fixed by #775

Comments

@iikirilov
Copy link
Member

commented Feb 19, 2018

Generate inner classes from struct parameters in the contract wrapper.

https://github.com/web3j/web3j/blob/master/codegen/src/main/java/org/web3j/codegen/SolidityFunctionWrapper.java

"inputs":[  
     {  
        "components":[ {  
              "name":"var1",
              "type":"string"
           },
           {  
              "name":"var2",
              "type":"uint32"
           }, 
           {...},
           ... ],
        "name":"_myStruct",
        "type":"tuple"
     }, 
     {...}, 
     ...
  ]
@mushketyk

This comment has been minimized.

Copy link
Contributor

commented Mar 22, 2018

@iikirilov Do you have any contract in mind for integration testing? I think it would be nice to generate a contract that has a structure with a struct as an input and test how it works.

@iikirilov iikirilov referenced this issue Mar 26, 2018
@iikirilov

This comment has been minimized.

Copy link
Member Author

commented Mar 26, 2018

@mushketyk I have created a PR with an example contract called ComplexStrorage for this purpose

@gitcoinbot

This comment has been minimized.

Copy link

commented Jun 20, 2018

Issue Status: 1. Open 2. Started 3. Submitted 4. Done


This issue now has a funding of 150.0 DAI (150.0 USD @ $1.0/DAI) attached to it.

@conor10 conor10 added the funded label Jun 24, 2018

@lonehacker

This comment has been minimized.

Copy link

commented Jul 8, 2018

Hey, I'm interested in working on this, I'm not extremely familiar with this codebase, but I've worked on solidity in the past and also on a code-gen project in another context. Any pointers on where I can start? Maybe some part of the implementation that already handles struct types

@conor10

This comment has been minimized.

Copy link
Collaborator

commented Jul 9, 2018

@lonehacker, the referenced PR should help.
@iikirilov please can you also provide your thoughts on @lonehacker's approach?

@lonehacker

This comment has been minimized.

Copy link

commented Jul 9, 2018

Thanks for the tip @conor10 that PR should help me get my hands dirty

@lonehacker

This comment has been minimized.

Copy link

commented Jul 10, 2018

So I've gone through the code a bit more now and I think a good way to go forward would be to generate final classes for each struct. So in the example given here - we will generate new classes Foo and Bar and pass the datatype Foo (or Bar as appropriate) to the generated functions. However, this will require some structural changes as currently only the type name is passed to buildTypeName, instead we'll need to pass the name of the struct to this function somehow. i.e. "tuple-Foo" instead of tuple.
AFAIK it's possible to get the classname for a class that's not generated yet, as mentioned here so we can decouple the function code generation from the code generation for the struct classes. I'm not sure where to generate the struct classes, but I don't think that'll be a big issue

@gitcoinbot

This comment has been minimized.

Copy link

commented Jul 15, 2018

@lonehacker Hello from Gitcoin Core - are you still working on this issue? Please submit a WIP PR or comment back within the next 3 days or you will be removed from this ticket and it will be returned to an ‘Open’ status. Please let us know if you have questions!

  • warning (3 days)
  • escalation to mods (6 days)

Funders only: Snooze warnings for 1 day | 3 days | 5 days | 10 days | 100 days

@gitcoinbot

This comment has been minimized.

Copy link

commented Jul 18, 2018

Issue Status: 1. Open 2. Started 3. Submitted 4. Done


@lonehacker due to inactivity, we have escalated this issue to Gitcoin's moderation team. Let us know if you believe this has been done in error!

  • warning (3 days)
  • escalation to mods (6 days)

Funders only: Snooze warnings for 1 day | 3 days | 5 days | 10 days | 100 days

@vs77bb

This comment has been minimized.

Copy link

commented Jul 20, 2018

Hi @iikirilov @conor10 Any thoughts on @lonehacker's approach here? Not sure where this is, but just wanted to poke in from Gitcoin and see what the latest is 👍

@iikirilov

This comment has been minimized.

Copy link
Member Author

commented Jul 23, 2018

@lonehacker your suggested method is the correct way to go about it. You will need to create a class for each struct, however, note that we cannot be certain of the name of the struct, which causes the following: you cannot tell the difference between two different structs which hold the same field types. However, as the solidity metadata file does not have extra information, it is fine to map two different structs (in the context of Solidity) to the same class (in the context of Java). So each class you create will have a unique combination of field types.
Essentially you need to check each input parameter of the constructor and each input and output parameter of each function, then match each struct to a class (which you may need to create or may have created when meeting a previous struct).

@mkosowsk

This comment has been minimized.

Copy link

commented Jul 26, 2018

@lonehacker just a friendly check-in here 😀 does @iikirilov's approach make sense? Thanks!

@Ugo

This comment has been minimized.

Copy link
Member

commented Oct 24, 2018

@iikirilov Can't we use a Tuple for each struct since we cannot tell the difference between different structs with the same field types? Wouldn't that be easier?

@iikirilov

This comment has been minimized.

Copy link
Member Author

commented Oct 24, 2018

@iikirilov Can't we use a Tuple for each struct since we cannot tell the difference between different structs with the same field types? Wouldn't that be easier?

Yes, it would be a valid solution. Just having a thought though - we do have consistent information of the name of the fields in the struct which would want to expose in the smart contract wrapper. With tuples, the names of the elements are ambiguous.

@gitcoinbot

This comment has been minimized.

Copy link

commented Jan 13, 2019

@hespoz Hello from Gitcoin Core - are you still working on this issue? Please submit a WIP PR or comment back within the next 3 days or you will be removed from this ticket and it will be returned to an ‘Open’ status. Please let us know if you have questions!

  • reminder (3 days)
  • escalation to mods (6 days)

Funders only: Snooze warnings for 1 day | 3 days | 5 days | 10 days | 100 days

8 similar comments
@gitcoinbot

This comment has been minimized.

Copy link

commented Jan 16, 2019

@hespoz Hello from Gitcoin Core - are you still working on this issue? Please submit a WIP PR or comment back within the next 3 days or you will be removed from this ticket and it will be returned to an ‘Open’ status. Please let us know if you have questions!

  • reminder (3 days)
  • escalation to mods (6 days)

Funders only: Snooze warnings for 1 day | 3 days | 5 days | 10 days | 100 days

@gitcoinbot

This comment has been minimized.

Copy link

commented Jan 16, 2019

@hespoz Hello from Gitcoin Core - are you still working on this issue? Please submit a WIP PR or comment back within the next 3 days or you will be removed from this ticket and it will be returned to an ‘Open’ status. Please let us know if you have questions!

  • reminder (3 days)
  • escalation to mods (6 days)

Funders only: Snooze warnings for 1 day | 3 days | 5 days | 10 days | 100 days

@gitcoinbot

This comment has been minimized.

Copy link

commented Jan 19, 2019

@hespoz Hello from Gitcoin Core - are you still working on this issue? Please submit a WIP PR or comment back within the next 3 days or you will be removed from this ticket and it will be returned to an ‘Open’ status. Please let us know if you have questions!

  • reminder (3 days)
  • escalation to mods (6 days)

Funders only: Snooze warnings for 1 day | 3 days | 5 days | 10 days | 100 days

@gitcoinbot

This comment has been minimized.

Copy link

commented Jan 19, 2019

@hespoz Hello from Gitcoin Core - are you still working on this issue? Please submit a WIP PR or comment back within the next 3 days or you will be removed from this ticket and it will be returned to an ‘Open’ status. Please let us know if you have questions!

  • reminder (3 days)
  • escalation to mods (6 days)

Funders only: Snooze warnings for 1 day | 3 days | 5 days | 10 days | 100 days

@gitcoinbot

This comment has been minimized.

Copy link

commented Jan 22, 2019

@hespoz Hello from Gitcoin Core - are you still working on this issue? Please submit a WIP PR or comment back within the next 3 days or you will be removed from this ticket and it will be returned to an ‘Open’ status. Please let us know if you have questions!

  • reminder (3 days)
  • escalation to mods (6 days)

Funders only: Snooze warnings for 1 day | 3 days | 5 days | 10 days | 100 days

@gitcoinbot

This comment has been minimized.

Copy link

commented Jan 22, 2019

@hespoz Hello from Gitcoin Core - are you still working on this issue? Please submit a WIP PR or comment back within the next 3 days or you will be removed from this ticket and it will be returned to an ‘Open’ status. Please let us know if you have questions!

  • reminder (3 days)
  • escalation to mods (6 days)

Funders only: Snooze warnings for 1 day | 3 days | 5 days | 10 days | 100 days

@gitcoinbot

This comment has been minimized.

Copy link

commented Jan 25, 2019

@hespoz Hello from Gitcoin Core - are you still working on this issue? Please submit a WIP PR or comment back within the next 3 days or you will be removed from this ticket and it will be returned to an ‘Open’ status. Please let us know if you have questions!

  • reminder (3 days)
  • escalation to mods (6 days)

Funders only: Snooze warnings for 1 day | 3 days | 5 days | 10 days | 100 days

@gitcoinbot

This comment has been minimized.

Copy link

commented Jan 25, 2019

@hespoz Hello from Gitcoin Core - are you still working on this issue? Please submit a WIP PR or comment back within the next 3 days or you will be removed from this ticket and it will be returned to an ‘Open’ status. Please let us know if you have questions!

  • reminder (3 days)
  • escalation to mods (6 days)

Funders only: Snooze warnings for 1 day | 3 days | 5 days | 10 days | 100 days

@gitcoinbot

This comment has been minimized.

Copy link

commented Jan 28, 2019

@hespoz Hello from Gitcoin Core - are you still working on this issue? Please submit a WIP PR or comment back within the next 3 days or you will be removed from this ticket and it will be returned to an ‘Open’ status. Please let us know if you have questions!

  • reminder (3 days)
  • escalation to mods (6 days)

Funders only: Snooze warnings for 1 day | 3 days | 5 days | 10 days | 100 days

17 similar comments
@gitcoinbot

This comment has been minimized.

Copy link

commented Jan 28, 2019

@hespoz Hello from Gitcoin Core - are you still working on this issue? Please submit a WIP PR or comment back within the next 3 days or you will be removed from this ticket and it will be returned to an ‘Open’ status. Please let us know if you have questions!

  • reminder (3 days)
  • escalation to mods (6 days)

Funders only: Snooze warnings for 1 day | 3 days | 5 days | 10 days | 100 days

@gitcoinbot

This comment has been minimized.

Copy link

commented Jan 31, 2019

@hespoz Hello from Gitcoin Core - are you still working on this issue? Please submit a WIP PR or comment back within the next 3 days or you will be removed from this ticket and it will be returned to an ‘Open’ status. Please let us know if you have questions!

  • reminder (3 days)
  • escalation to mods (6 days)

Funders only: Snooze warnings for 1 day | 3 days | 5 days | 10 days | 100 days

@gitcoinbot

This comment has been minimized.

Copy link

commented Jan 31, 2019

@hespoz Hello from Gitcoin Core - are you still working on this issue? Please submit a WIP PR or comment back within the next 3 days or you will be removed from this ticket and it will be returned to an ‘Open’ status. Please let us know if you have questions!

  • reminder (3 days)
  • escalation to mods (6 days)

Funders only: Snooze warnings for 1 day | 3 days | 5 days | 10 days | 100 days

@gitcoinbot

This comment has been minimized.

Copy link

commented Feb 3, 2019

@hespoz Hello from Gitcoin Core - are you still working on this issue? Please submit a WIP PR or comment back within the next 3 days or you will be removed from this ticket and it will be returned to an ‘Open’ status. Please let us know if you have questions!

  • reminder (3 days)
  • escalation to mods (6 days)

Funders only: Snooze warnings for 1 day | 3 days | 5 days | 10 days | 100 days

@gitcoinbot

This comment has been minimized.

Copy link

commented Feb 3, 2019

@hespoz Hello from Gitcoin Core - are you still working on this issue? Please submit a WIP PR or comment back within the next 3 days or you will be removed from this ticket and it will be returned to an ‘Open’ status. Please let us know if you have questions!

  • reminder (3 days)
  • escalation to mods (6 days)

Funders only: Snooze warnings for 1 day | 3 days | 5 days | 10 days | 100 days

@gitcoinbot

This comment has been minimized.

Copy link

commented Feb 6, 2019

@hespoz Hello from Gitcoin Core - are you still working on this issue? Please submit a WIP PR or comment back within the next 3 days or you will be removed from this ticket and it will be returned to an ‘Open’ status. Please let us know if you have questions!

  • reminder (3 days)
  • escalation to mods (6 days)

Funders only: Snooze warnings for 1 day | 3 days | 5 days | 10 days | 100 days

@gitcoinbot

This comment has been minimized.

Copy link

commented Feb 6, 2019

@hespoz Hello from Gitcoin Core - are you still working on this issue? Please submit a WIP PR or comment back within the next 3 days or you will be removed from this ticket and it will be returned to an ‘Open’ status. Please let us know if you have questions!

  • reminder (3 days)
  • escalation to mods (6 days)

Funders only: Snooze warnings for 1 day | 3 days | 5 days | 10 days | 100 days

@gitcoinbot

This comment has been minimized.

Copy link

commented Feb 9, 2019

@hespoz Hello from Gitcoin Core - are you still working on this issue? Please submit a WIP PR or comment back within the next 3 days or you will be removed from this ticket and it will be returned to an ‘Open’ status. Please let us know if you have questions!

  • reminder (3 days)
  • escalation to mods (6 days)

Funders only: Snooze warnings for 1 day | 3 days | 5 days | 10 days | 100 days

@gitcoinbot

This comment has been minimized.

Copy link

commented Feb 9, 2019

@hespoz Hello from Gitcoin Core - are you still working on this issue? Please submit a WIP PR or comment back within the next 3 days or you will be removed from this ticket and it will be returned to an ‘Open’ status. Please let us know if you have questions!

  • reminder (3 days)
  • escalation to mods (6 days)

Funders only: Snooze warnings for 1 day | 3 days | 5 days | 10 days | 100 days

@gitcoinbot

This comment has been minimized.

Copy link

commented Feb 12, 2019

@hespoz Hello from Gitcoin Core - are you still working on this issue? Please submit a WIP PR or comment back within the next 3 days or you will be removed from this ticket and it will be returned to an ‘Open’ status. Please let us know if you have questions!

  • reminder (3 days)
  • escalation to mods (6 days)

Funders only: Snooze warnings for 1 day | 3 days | 5 days | 10 days | 100 days

@gitcoinbot

This comment has been minimized.

Copy link

commented Feb 12, 2019

@hespoz Hello from Gitcoin Core - are you still working on this issue? Please submit a WIP PR or comment back within the next 3 days or you will be removed from this ticket and it will be returned to an ‘Open’ status. Please let us know if you have questions!

  • reminder (3 days)
  • escalation to mods (6 days)

Funders only: Snooze warnings for 1 day | 3 days | 5 days | 10 days | 100 days

@gitcoinbot

This comment has been minimized.

Copy link

commented Feb 15, 2019

@hespoz Hello from Gitcoin Core - are you still working on this issue? Please submit a WIP PR or comment back within the next 3 days or you will be removed from this ticket and it will be returned to an ‘Open’ status. Please let us know if you have questions!

  • reminder (3 days)
  • escalation to mods (6 days)

Funders only: Snooze warnings for 1 day | 3 days | 5 days | 10 days | 100 days

@gitcoinbot

This comment has been minimized.

Copy link

commented Feb 15, 2019

@hespoz Hello from Gitcoin Core - are you still working on this issue? Please submit a WIP PR or comment back within the next 3 days or you will be removed from this ticket and it will be returned to an ‘Open’ status. Please let us know if you have questions!

  • reminder (3 days)
  • escalation to mods (6 days)

Funders only: Snooze warnings for 1 day | 3 days | 5 days | 10 days | 100 days

@gitcoinbot

This comment has been minimized.

Copy link

commented Feb 18, 2019

@hespoz Hello from Gitcoin Core - are you still working on this issue? Please submit a WIP PR or comment back within the next 3 days or you will be removed from this ticket and it will be returned to an ‘Open’ status. Please let us know if you have questions!

  • reminder (3 days)
  • escalation to mods (6 days)

Funders only: Snooze warnings for 1 day | 3 days | 5 days | 10 days | 100 days

@gitcoinbot

This comment has been minimized.

Copy link

commented Feb 18, 2019

@hespoz Hello from Gitcoin Core - are you still working on this issue? Please submit a WIP PR or comment back within the next 3 days or you will be removed from this ticket and it will be returned to an ‘Open’ status. Please let us know if you have questions!

  • reminder (3 days)
  • escalation to mods (6 days)

Funders only: Snooze warnings for 1 day | 3 days | 5 days | 10 days | 100 days

@gitcoinbot

This comment has been minimized.

Copy link

commented Feb 21, 2019

@hespoz Hello from Gitcoin Core - are you still working on this issue? Please submit a WIP PR or comment back within the next 3 days or you will be removed from this ticket and it will be returned to an ‘Open’ status. Please let us know if you have questions!

  • reminder (3 days)
  • escalation to mods (6 days)

Funders only: Snooze warnings for 1 day | 3 days | 5 days | 10 days | 100 days

@gitcoinbot

This comment has been minimized.

Copy link

commented Feb 21, 2019

@hespoz Hello from Gitcoin Core - are you still working on this issue? Please submit a WIP PR or comment back within the next 3 days or you will be removed from this ticket and it will be returned to an ‘Open’ status. Please let us know if you have questions!

  • reminder (3 days)
  • escalation to mods (6 days)

Funders only: Snooze warnings for 1 day | 3 days | 5 days | 10 days | 100 days

@gitcoinbot

This comment has been minimized.

Copy link

commented Feb 24, 2019

@hespoz Hello from Gitcoin Core - are you still working on this issue? Please submit a WIP PR or comment back within the next 3 days or you will be removed from this ticket and it will be returned to an ‘Open’ status. Please let us know if you have questions!

  • reminder (3 days)
  • escalation to mods (6 days)

Funders only: Snooze warnings for 1 day | 3 days | 5 days | 10 days | 100 days

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
8 participants
You can’t perform that action at this time.