-
Notifications
You must be signed in to change notification settings - Fork 208
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
Create IndyVdrPoolService in AFJ #1108
Comments
@TimoGlastra were you intentional about the code below cus' I assume it is supposed to be an import instead of a require? try {
require("indy-vdr-test-nodejs");
} catch (error) {
throw new Error("Error registering nodejs bindings for Indy VDR");
} |
I don't think you can do conditional imports as we'rs using node modules. So using require is sort of an hack |
@Vickysomtee updated the issue with more details and also made an amendment to a previous step. First it mentioned submitWriteRequest should call |
Should it be the same for submitReadRequest? |
Both should call submitRequest. submitAction is used for some specific calls that we aren't using |
Create an
IndyVdrPoolService
using the indy-vdr library that can be used to write and read objects from the ledger.Create the
@aries-framework/indy-vdr
packageAs the Indy VDR code will be hosted outside of the AFJ core package we need to create a new indy-vdr package first.
General steps to create a new pacakge:
indy-vdr
.indy-vdr-test-shared
package to both thepeerDependencies
anddevDependencies
and set theindy-vdr-test-shared
peer dependency as optional (https://classic.yarnpkg.com/en/docs/package-json#toc-peerdependenciesmeta).shared
library, not the nodejs library.Done!
Create the IndyVdrPool
The
IndyVdrPool
is a class that wraps thePoolCreate
object from the indy-vdr library and allow us to connect to a pool. TheIndyVdrPool
class manages a single pool. TheIndyVdrPoolService
that will be created in the next step will be able to manage multipleIndyVdrPool
instance to achive multi-ledger support.The interface of the IndyVdrPool should look as follows. This doesn't have to be an interface, but just so it's clear which methods should be exposed on the class. You can look at the implementation of
IndyPool
currently present in AFJ ,however do not this is based on Indy SDK which has quite a different api.pool
directory in the src. This shouldn't be exported from the pacakge. Do create an index.ts in thepool
directory to export the files from that directory.IndyVdrPoolConfig
and the logger)PoolCreate
from the indy vdr library, and pass the transactions from the config to it. The pool should be stored as private property in the classclose
on the pool that is stored as private property (if defiend, could be undefined if pool is not created yet)pool.submitRequest
and pass the request to it.pool.submitRequest
and pass the request to it.That's it!
Creating the IndyVdrPoolService
The IndyVdrPoolService is going to manage all pool instances for the different ledgers we want to connect to. The
IndyVdrPoolService
can be based on theIndyPoolService
currently present in AFJ Core.One of the most complex parts of the IndyVdrPoolService is going to handle legacy identifiers that don't specify which ledger an object should be retrieved from. You can copy this for the most part from the IndyPoolService. What is important to know:
New identifier types are structured like this:
did:indy:sovrin:7Tqg6BwSSWapxgUDm9KKgg
Old identifier types are structured like this:
7Tqg6BwSSWapxgUDm9KKgg
The old identifier type doesn't hint at from which ledger (sovrin in this case) we need to get the did. The old service contains complex logic to fetch them from all configured pools and then determine the best ledger.
setPools
call, for now you can hardcode an arrray of IndyVdrPools (will address in next steps / other issue)ledgerWritePool
callgetPoolForDid
to a new privategetPoolForLegacyDid
methodgetPoolForDid
method check if the did starts withdid:indy
, if this is the case parse the did and extract the namespace (https://hyperledger.github.io/indy-did-method/#indy-did-method-identifiers) from it. Then look for a pool where thepool.indyNamespace
matches this namespace. If no pool is found, throw an error. If the did doesn't start withdid:indy
, call thegetPoolForLegacyDid
and return the value.indyNamespace
property required in thegetPoolForNamespace
method. We don't want to take the first pool autmoatically anymore.getDidFromPool
to use the indy vdr librarygetTransactionAuthorAgreement
andappendTaa
methods to the IndyVdrPool class and use them in the submitWriteRequest (like is currently done in the IndyPoolService.submitWriteRequest).submitReadRequest
andsubmitWriteRequest
methods from the IndyVdrPoolService. The user will call pool.submitWriteRequest directly.submitWriteRequest
method from the IndyVdrPool (not service as that is deleted) to sign the request. (after the taa acceptance). This can be done by getting the signing input usingrequest.signatureInput
and passing that toagentContext.wallet.sign
. (TODO: we need to pass the verkey to the wallet, but we only have the did here. We need a way to get the verkey based on a did, but in a generic way. Best way is prob through the did repository created records --this.didRepository.getCreatedDids(this.agentContext, { method })
-- but that won't work for dids that are not created using the did registrar. Should we add a method to get a did from the wallet? It would need to be temporary - TDB)Note on getTaa / appendTaa
to get the taa using the indy-vdr library you can use the
GetTransactionAuthorAgreementRequest
. to get the acceptance mechanism list you can use theGetAcceptanceMechanismsRequest
. to append the TAA is a bit more complex. You can do so using the following code.indyVdr
can be imported fromindy-vdr-test-shared
. The values can be populated based on the TAA and current code.Tests
The text was updated successfully, but these errors were encountered: