-
Notifications
You must be signed in to change notification settings - Fork 200
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
refactor: remove dependency on indy ledger service from sov did resolver/registrar #1086
refactor: remove dependency on indy ledger service from sov did resolver/registrar #1086
Conversation
Signed-off-by: Sai Ranjit Tummalapalli <[email protected]>
Codecov Report
@@ Coverage Diff @@
## main #1086 +/- ##
==========================================
- Coverage 88.44% 88.28% -0.16%
==========================================
Files 706 706
Lines 16342 16397 +55
Branches 2640 2652 +12
==========================================
+ Hits 14453 14476 +23
- Misses 1882 1914 +32
Partials 7 7
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. |
Signed-off-by: Sai Ranjit Tummalapalli <[email protected]>
…ver/registrar Signed-off-by: Sai Ranjit Tummalapalli <[email protected]>
Signed-off-by: Sai Ranjit Tummalapalli <[email protected]>
Signed-off-by: Sai Ranjit Tummalapalli <[email protected]>
Will put in a thorough review soon, but this is awesome! Thanks @sairanjit! |
There was a problem hiding this 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 @sairanjit, left some comments
alias: string, | ||
role?: Indy.NymRole | ||
) { | ||
const pool = this.indyPoolService.ledgerWritePool |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This takes the pool from the ledgerWritePool, however you also added a config option to set the indyNamespace. I think we should get the pool based on the indyNamespace from the indyPoolService and use that as the pool to write to the ledger instead.
did: string, | ||
endpoints: IndyEndpointAttrib | ||
): Promise<void> { | ||
const pool = this.indyPoolService.ledgerWritePool |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same here, should use pool based on the indyNamespace variable. I think for both methods we can pass the pool as an argument to this method.
@@ -178,6 +240,7 @@ export interface SovDidCreateOptions extends DidCreateOptions { | |||
// As did:sov is so limited, we require everything needed to construct the did document to be passed | |||
// through the options object. Once we support did:indy we can allow the didDocument property. | |||
didDocument?: never | |||
indyNamespace?: string |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The indyNamespace
property should be added to the options object
@@ -102,7 +98,8 @@ export class SovDidRegistrar implements DidRegistrar { | |||
// Build did document. | |||
const didDocument = didDocumentBuilder.build() | |||
|
|||
const didIndyNamespace = this.indyPoolService.ledgerWritePool.config.indyNamespace | |||
const pool = this.indyPoolService.getPoolForNamespace(options.indyNamespace) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can pass this pool to the registerPublicDid
and setEndpointsForDid
methods
return didResponse | ||
} | ||
|
||
public async getEndpointsForDid(agentContext: AgentContext, did: string) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
public async getEndpointsForDid(agentContext: AgentContext, did: string) { | |
private async getEndpointsForDid(agentContext: AgentContext, did: string) { |
indySdkSovDidResolver = new IndySdkSovDidResolver( | ||
indyPoolServiceMock, | ||
agentConfig.agentDependencies, | ||
new LoggerMock() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
agentConfig.logger
@@ -55,6 +55,9 @@ export class LedgerApi { | |||
await this.ledgerService.connectToPools() | |||
} | |||
|
|||
/** | |||
* @deprecated use agent.dids.create instead |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nice 👍
@@ -131,6 +140,9 @@ export class IndyLedgerService { | |||
} | |||
} | |||
|
|||
/** | |||
* @deprecated | |||
*/ | |||
public async getEndpointsForDid(agentContext: AgentContext, did: string) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see you moved some methods to the indy pool service. Can we update all methods in the indy ledger service to call those new methods instead? As they're private in this class we can migrate them (instead of duplicate) without any issues
@@ -59,6 +59,9 @@ export class IndyLedgerService { | |||
return this.indyPoolService.connectToPools() | |||
} | |||
|
|||
/** | |||
* @deprecated |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you also mark getDidIndyWriteNamespace
as deprecated?
@@ -14,6 +14,7 @@ import { FileSystem } from '../../../storage/FileSystem' | |||
import { isSelfCertifiedDid } from '../../../utils/did' | |||
import { isIndyError } from '../../../utils/indyError' | |||
import { allSettled, onlyFulfilled, onlyRejected } from '../../../utils/promises' | |||
import { assertIndyWallet } from '../../../wallet/util/assertIndyWallet' | |||
import { IndyPool } from '../IndyPool' | |||
import { LedgerError } from '../error/LedgerError' | |||
import { LedgerNotConfiguredError } from '../error/LedgerNotConfiguredError' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you also mark get ledgerWritePool
as deprecated?
…gerService Signed-off-by: Sai Ranjit Tummalapalli <[email protected]>
…sairanjit/aries-framework-javascript into feat/getPoolForNamespace-method
Signed-off-by: Sai Ranjit Tummalapalli <[email protected]>
jest | ||
.spyOn(poolService, 'submitWriteRequest') | ||
.mockRejectedValue( | ||
new Error( | ||
'Unable to satisfy matching TAA with mechanism "accept" and version "1.0" in pool.\n Found ["accept"] and version 2.0 in pool.' | ||
) | ||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We're not actually testing anymore that it throws an error if the config version does not match, we're just throwing a mocked error now. Can we move these tests to the pool service tests? (As that's where the logic is moved to right?)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So, Can I keep the same tests in both IndyLedgerService.test.ts and IndyPoolService.test.ts ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What do you mean exactly? What we're testing here doesn't really test anything, but I do think we should have this test in the indy pool service. Doest hat answer your question?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay, I will update the test to catch the actual error from the function instead of mocking it and move the tests from IndyLedgerService.test.ts to IndyPoolService.test.ts. Is It right now?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
After moving the tests to IndyPoolService.test.ts there are no tests left in the IndyLedgerService.test.ts file. So, Can I delete the IndyLedgerService.test.ts file?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes if there's no tests left that's fine 👍
Signed-off-by: Sai Ranjit Tummalapalli <[email protected]>
…sairanjit/aries-framework-javascript into feat/getPoolForNamespace-method
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
…ver/registrar (openwallet-foundation#1086) Signed-off-by: Sai Ranjit Tummalapalli <[email protected]>
resolves: #1066 and #1067
Signed-off-by: Sai Ranjit Tummalapalli [email protected]