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

Split the Issue, Move and Redeem flows into the general and an extra custom flow #47

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

Conversation

IgorWolkov
Copy link

One failed test DiamondWithTokenScenarioTests, potential cause: anonymized parties handled in a wrong way.

@IgorWolkov
Copy link
Author

@illoyd, @kasiastreich, @roger3cev could you please share your thoughts about the approach. If it's the right way, then I'll merge new master into the branch and prepare cleaner pr.
Thanks.

Copy link
Contributor

@illoyd illoyd left a comment

Choose a reason for hiding this comment

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

Thanks for the PR, @IgorWolkov.

Firstly, great use of test driven development. Applying conditions to a token is a good real world scenario.

Secondly, this is a pluggable vs composable design question. In a pluggable design, hooks are added for developers to inject their own behaviours, while in a composable design developers are expected to build their own behaviours around existing building blocks. I believe the token team are keen on the composable model. For a basic example, please see EvolvableTokenHelpers and its use in CreateEvolvableToken and UpdateEvolvableToken.

To take this PR to the next level, I would recommend the following:

  1. Convert Conditions to an [encumbrance](https://docs.corda.r3.com/tutorial-contract.html#encumbrances}. This way you can apply conditions and constraints in a Corda way.
  2. Create new issue, move, and redeem flows that assemble a full transaction, including tokens and commands, along with your new encumbrance. I do not believe the work has been completed on composable tokens yet, so this could be a good entry point to updating the code base - extract out the state and command composition from the existing flows for use in custom flows.

Check out Issue #19 for a conversation on pluggable vs composable.

@roger3cev, @kasiastreich, please step in if any of the above is not within your thinking.

Cheers, Ian

import net.corda.core.flows.ReceiveFinalityFlow
import net.corda.core.flows.StartableByRPC
import net.corda.core.contracts.requireThat
import net.corda.core.flows.*
Copy link
Contributor

Choose a reason for hiding this comment

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

Try not to use * imports

@@ -26,7 +26,7 @@ fun <T : TokenType> StartedMockNode.issueTokens(
issueTo: StartedMockNode,
notary: StartedMockNode,
amount: Amount<T>? = null,
anonymous: Boolean = true
anonymous: Boolean = false
Copy link
Contributor

Choose a reason for hiding this comment

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

Try not to change default values; other tests rely on them to be set a certain way and may impact test states and performance if changed.

@@ -0,0 +1,70 @@
package com.r3.corda.sdk.token.workflow
Copy link
Contributor

Choose a reason for hiding this comment

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

Good test driven design.

@@ -0,0 +1,56 @@
package com.r3.corda.sdk.token.workflow.flows
Copy link
Contributor

Choose a reason for hiding this comment

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

Be careful with file names. This one has a typo.

import javax.persistence.Table

@BelongsToContract(TradeConditionsContract::class)
data class TradeConditions(val owner: AbstractParty,
Copy link
Contributor

Choose a reason for hiding this comment

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

Instead of TradeConditions being a simple string, how about converting it to an encumbrance? This way you can model how an actual state constraint would work in Corda. (Of course, be aware of the caveats of not mixing an encumbrance with a reference state; this will work fine for tokens with a fixed (inline) definition but not for tokens using an EvolvableToken token type.)

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.

None yet

3 participants