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

Payable Feature #2

Open
wants to merge 12 commits into
base: master
Choose a base branch
from
Open

Payable Feature #2

wants to merge 12 commits into from

Conversation

john-b-yang
Copy link
Collaborator

[WIP] Adding payable keyword generation to Solidity generator of compiler. Changes include

  • Fixed point iteration for determining Identity/Address fields that should be payable
  • Single pass iteration for determining Identity/Address parameters that should be payable

To do / push:

  • Handle mapping with key of type identity that should also be payable
  • Handle structs with identity fields that should be payable
  • Handle nested data structures (mapping, structs)

Copy link
Owner

@jhkolb jhkolb left a comment

Choose a reason for hiding this comment

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

Nice to see a start to this! I made a few comments, but I know this is also still a work in progress. This is definitely getting complex enough to warrant a separate Payable object to separate this from the Solidity generation logic.

src/main/scala/edu/berkeley/cs/rise/quartz/Solidity.scala Outdated Show resolved Hide resolved
src/main/scala/edu/berkeley/cs/rise/quartz/Solidity.scala Outdated Show resolved Hide resolved
src/main/scala/edu/berkeley/cs/rise/quartz/Solidity.scala Outdated Show resolved Hide resolved
src/main/scala/edu/berkeley/cs/rise/quartz/Solidity.scala Outdated Show resolved Hide resolved
src/main/scala/edu/berkeley/cs/rise/quartz/Solidity.scala Outdated Show resolved Hide resolved
src/main/scala/edu/berkeley/cs/rise/quartz/Solidity.scala Outdated Show resolved Hide resolved
private def extractPayableParams(statements: Seq[Statement], scope: Set[String] = Set.empty[String], payableFields: Set[String], payableParams: Set[String]): Set[String] = {
val names = statements.foldLeft(payableParams) { (current, statement) =>
statement match {
case Send(destination, _, _) => current.union(extractVarNames(destination))
Copy link
Owner

Choose a reason for hiding this comment

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

If destination includes field references, won't those be added in here as well, not just parameters?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Just to clarify, is this if destination is of type struct? If so, yeah that's correctly, I'll be have to mindful of that when parsing and figuring out which variable within the struct's fields should be payable.

Copy link
Owner

Choose a reason for hiding this comment

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

I was just pointing out that this method is called extractPayableParams but here, when you use extractVarNames on destination, I don't think it would properly distinguish between fields and parameters.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Ohh gotcha, yes yes that makes sense. Before I think the resolution was that I'd just union it with the set of parameters of that transition, but admittedly that's not a very good solution. For the current version, I check for whether the variable is a parameter or field before adding it 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants