Giter Club home page Giter Club logo

Comments (8)

roger-that-dev avatar roger-that-dev commented on July 17, 2024

This isn't a bug. I've checked out out your code and run it. The test is failing because you are not sharing the lender (bank) key with the borrow (agent). Or rather.. the agent is not storing a mapping of the new key generated by the bank node to the bank node's x500name. It was useful to look at your code and see where we can make accounts easier to use. I'll make some changes to the code and maybe it'll be easier for you in the future so you won't run into these mistakes. Cheers

from accounts.

roger-that-dev avatar roger-that-dev commented on July 17, 2024

It's also worth noting that the lender AccountInfo can be found in the first "flow" because the initiator part of the flow where all the logic is being executed, is being run by the lender node. The update flow fails because it is being run by the bank node, which doesn't have the mapping.

from accounts.

opticyclic avatar opticyclic commented on July 17, 2024

Can you clarify in the docs what the ShareAccountInfoWithParty does and doesn't do.

    /**
     * Shares an [AccountInfo] [StateAndRef] with the specified [Party]. The [AccountInfo]is always stored by the
     * recipient using [StatesToRecord.ALL_VISIBLE].
     *
     * @param accountId the account ID of the [AccountInfo] to share.
     * @param party the [Party] to share the [AccountInfo] with.
     */
    fun shareAccountInfoWithParty(accountId: UUID, party: Party): CordaFuture<Unit>

I expected that this would be enough to share the lender with the agent.

I subsequently found this comment in another demo from a few months ago:

    //Share the state and the account with the Bank node so that we can look up by keys
    //TODO: The test will fail if we don't do this. Ideally the framework should do this for us
    banksAccountService.shareStateAndSyncAccounts(signedTx.tx.outRefsOfType<IOUAccountState>().single(), agents.identity()).runAndGet(network)

Quite clearly, it is easy to forget to do this extra flow, so now I am doing this at the end of the issue flow:

        //Notarise and record the transaction in both parties' vaults.
        progressTracker.currentStep = FINALISING
        val transaction = subFlow(FinalityFlow(fullySignedTx, listOf(borrowerSession)))
        val state = transaction.tx.outRefsOfType<IOUAccountState>().single()
        subFlow(ShareStateAndSyncAccounts(state, borrowerAccountInfo.state.data.host))
        return transaction

Is this the right way to do it?
Could this sharing be done automatically?

from accounts.

roger-that-dev avatar roger-that-dev commented on July 17, 2024

You are right - the usability could be improved. However, this is just a V1 so I guess we won't get it 100% right the first time. I'm going to see what I can do to improve this before the release. Thanks

from accounts.

roger-that-dev avatar roger-that-dev commented on July 17, 2024

Thinking about this a little, maybe what we need is a version of the SyncKeyMappingFlow that also adds PublicKey- > Account ID mappings. Maybe could be called sync account keys flow and can be used when a node already has the AccountInfo but they are missing some of the key mappings. The mappings can be extracted from a state/transaction or just provided as a list of pairs, or something. Would that help ?

from accounts.

opticyclic avatar opticyclic commented on July 17, 2024

That sounds like it should work.
Obviously, its hard to tell without implementing it and trying it out!

from accounts.

jquijoy avatar jquijoy commented on July 17, 2024

Hi all, I am also facing this kind of issue with the project I am currently working on. Is there any available solution for this?

from accounts.

roger-that-dev avatar roger-that-dev commented on July 17, 2024

You need to share the account infos

from accounts.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.