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

Make Accounts Easier To Use #80

Open
opticyclic opened this issue Dec 11, 2019 · 7 comments
Open

Make Accounts Easier To Use #80

opticyclic opened this issue Dec 11, 2019 · 7 comments
Labels
enhancement New feature or request

Comments

@opticyclic
Copy link
Contributor

Discussion before adding a pull request:

In my test code I have a few extension functions to make using the accounts SDK easier.
e.g. this:

val StateAndRef<AccountInfo>.uuid: UUID get() = state.data.linearId.id

fun VaultService.accountStates(accountId:UUID): List<StateAndRef<ContractState>> {
    return this.queryBy<ContractState>(QueryCriteria.VaultQueryCriteria(externalIds = listOf(accountId))).states
}

allows me to do this:

banks.services.vaultService.accountStates(bank1.uuid)

Instead of this:

banks.services.vaultService.queryBy<ContractState>(QueryCriteria.VaultQueryCriteria(externalIds = listOf(bank1.state.data.linearId.id))).states

However, calling kotlin extension functions from Java is tricky.

Would this and other similar helper functions be better in AccountService/KeyManagementBackedAccountService?

See also #37

@roger-that-dev roger-that-dev added the enhancement New feature or request label Dec 19, 2019
@roger-that-dev
Copy link

Seems like a good idea - thanks!

@dezzeus
Copy link

dezzeus commented Jan 15, 2020

I'm questioning if we can also let the accountService.accountInfo(...) helpers just return the AccountInfo object instead of StateAndRef

@roger-that-dev
Copy link

We can't change them as it would break backwards compatibility but we can add new methods that do what you describe.

@dezzeus
Copy link

dezzeus commented Jan 15, 2020

Good point. It's not really needed, but promotes cleaner code (IMHO); maybe we can break that behaviour with v2.0 :P (and introduce new methods for those who may need the stateAndRef)

@roger-that-dev
Copy link

Yeah fair point. Reason for returning StateAndRef was that then you can then build transactions with it. With just the AccountInfo you can't use it as an input or reference in a transaction.

@dezzeus
Copy link

dezzeus commented Jan 15, 2020

Makes sense to have such an helper, even thought I'm not sure about the direct use of AccountInfo in transactions (i.e. accounts are handled with flows, while states refers to AnonymousParty, not LinearPointer of AccountInfo)

@dezzeus
Copy link

dezzeus commented Jan 15, 2020

Another idea for an helper: something to use in the SignTransactionFlow::checkTransaction that, given an AnonymousParty / PublicKey, throws an exception if:

  • It's not associated to an account.
  • The node is not the host of the associated account.
  • Something else that I may haven't thinked about…

Again, it's not needed, but can by handy. :)

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

No branches or pull requests

3 participants