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

Allow the Issuer to Record Token States #207

Open
mplatt opened this issue Aug 11, 2020 · 8 comments
Open

Allow the Issuer to Record Token States #207

mplatt opened this issue Aug 11, 2020 · 8 comments

Comments

@mplatt
Copy link

mplatt commented Aug 11, 2020

It appears to be impossible to record a FungibleToken inside the issuers vault during issuance or redemption.
This appears to be due to the role selection mechanism in ObserverAwareFinalityFlow.

That means that, even if I pass the issuer as observer on issuance, no state will be recorded in their vault:

@Test
fun `issuer can observe issuance`() {
	val token = 7.GBP issuedBy nodeA.legalIdentity() heldBy nodeB.legalIdentity()
	nodeA.startFlow(IssueTokens(listOf(token), listOf(nodeA.legalIdentity())))
	network.runNetwork()
	val criteria = QueryCriteria.VaultQueryCriteria(
		status = Vault.StateStatus.ALL,
		relevancyStatus = Vault.RelevancyStatus.ALL
	)
	assertThat(nodeB.services.vaultService.queryBy<FungibleToken>(criteria).states, hasSize(equalTo(1)))
	assertThat(nodeA.services.vaultService.queryBy<FungibleToken>(criteria).states, hasSize(equalTo(1))) // FAILS
}

Similarly, on redemption:

@Test
fun `issuer can observe redemption`() {
	val token = 7.GBP issuedBy nodeA.legalIdentity() heldBy nodeB.legalIdentity()
	nodeA.startFlow(IssueTokens(listOf(token), listOf(nodeA.legalIdentity())))
	network.runNetwork()
	nodeB.startFlow(RedeemFungibleTokens(1.GBP, nodeA.legalIdentity(), listOf(nodeA.legalIdentity())))
	network.runNetwork()
	val criteria = QueryCriteria.VaultQueryCriteria(
		status = Vault.StateStatus.ALL,
		relevancyStatus = Vault.RelevancyStatus.ALL
	)
	assertThat(nodeB.services.vaultService.queryBy<FungibleToken>(criteria).states, hasSize(equalTo(2)))
	assertThat(nodeA.services.vaultService.queryBy<FungibleToken>(criteria).states, hasSize(equalTo(2))) // FAILS
}
@arsalankhalid
Copy link

Is this ever going to be addressed?

@rach-id
Copy link

rach-id commented Jul 13, 2021

I had this same issue lately :(
The way I solved it is via sharing the transaction with the issuer and asking it to record all visible states (via a responder):

  • On the node starting the flow:
 if (!serviceHub.myInfo.isLegalIdentity(issuerParty))
         subFlow(FinalityFlow(signedTx, listOf(session), StatesToRecord.ALL_VISIBLE))
  • On the issuing node:
subFlow(ReceiveFinalityFlow(otherSideSession = flowSession, statesToRecord = StatesToRecord.ALL_VISIBLE))

Then, to get the balance, you should query ALL states instead of RELEVANT ones.

@manosbatsis
Copy link

Is this the right way for parties to keep tabs on tokens they have issued though? Seems like additional room for a junior/careless dev to mess up in some way or other with e.g. token selection.

Never saw a need for someting like this tbh, always used separate, custom states to support processes resulting in issuance/transfer/redemption, easier to work with in most cases. Curious about what requirements might have a real need for this.

@rach-id
Copy link

rach-id commented Jul 14, 2021

Agreed, it is hacky :D
What do you mean by custom states to support processes resulting in issuance/transfer/redemption? Keeping track of the results in states you manage manually ? and share them if some other party needs to know ?

@manosbatsis
Copy link

E.g. an IssueRequestState used to accommodate interactivity/negotiations between parties around an issuance request/offer.

@rach-id
Copy link

rach-id commented Jul 14, 2021

Wouldn't that be redoing a part of what the tokens SDK is doing ? Since they already handle parts of keeping the issuance stored and others...

@manosbatsis
Copy link

Custom transaction items support the functional scope. A purchase order provides more context that a couple of balance updates. This is one of the reasons the SDK is layered in flows, inline flows and TX item adding functions - it's about what some definition of "atomic" TX is supposed to include.

@rach-id
Copy link

rach-id commented Jul 16, 2021

Sorry for the late reply.
Makes sense this way. Agreed. Thanks a lot for the insights

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

No branches or pull requests

4 participants