diff --git a/packages/indy-vdr/src/IndyVdrApi.ts b/packages/indy-vdr/src/IndyVdrApi.ts index 6601729c79..10d9a9af51 100644 --- a/packages/indy-vdr/src/IndyVdrApi.ts +++ b/packages/indy-vdr/src/IndyVdrApi.ts @@ -33,6 +33,21 @@ export class IndyVdrApi { return signRequest(this.agentContext, pool, request, submitterDid) } + /** + * This method refreshes the pool connection and ensures the pool is up to date with the ledger. + */ + public refreshPoolConnections() { + return this.indyVdrPoolService.refreshPoolConnections() + } + + /** + * This method gets the updated transactions of the pool. + * @returns The transactions of the pool ledger + */ + public getAllPoolTransactions() { + return this.indyVdrPoolService.getAllPoolTransactions() + } + /** * This method endorses a transaction. The transaction can be either a string or a JSON object. * If the transaction has a signature, it means the transaction was created by another author and will be endorsed. diff --git a/packages/indy-vdr/src/index.ts b/packages/indy-vdr/src/index.ts index aaa233c56e..ecd29dbc80 100644 --- a/packages/indy-vdr/src/index.ts +++ b/packages/indy-vdr/src/index.ts @@ -5,7 +5,7 @@ export { IndyVdrDidCreateResult, IndyVdrDidCreateOptions, } from './dids' -export { IndyVdrPoolConfig } from './pool' +export { IndyVdrPoolConfig, IndyVdrPoolService } from './pool' export * from './IndyVdrModule' export * from './IndyVdrModuleConfig' export * from './anoncreds' diff --git a/packages/indy-vdr/src/pool/IndyVdrPool.ts b/packages/indy-vdr/src/pool/IndyVdrPool.ts index db3959f070..e90615c306 100644 --- a/packages/indy-vdr/src/pool/IndyVdrPool.ts +++ b/packages/indy-vdr/src/pool/IndyVdrPool.ts @@ -68,6 +68,22 @@ export class IndyVdrPool { }) } + /** + * Refreshes the connection to the pool. + */ + public async refreshConnection(): Promise { + if (this._pool) { + await this._pool.refresh() + } + } + + /** + * Get the transactions for a pool + */ + public get transactions() { + return this.pool.transactions + } + private get pool(): indyVdrPool { if (!this._pool) this.connect() if (!this._pool) throw new IndyVdrError('Pool is not connected.') diff --git a/packages/indy-vdr/src/pool/IndyVdrPoolService.ts b/packages/indy-vdr/src/pool/IndyVdrPoolService.ts index aa0e15b518..ae3f4dc81e 100644 --- a/packages/indy-vdr/src/pool/IndyVdrPoolService.ts +++ b/packages/indy-vdr/src/pool/IndyVdrPoolService.ts @@ -149,6 +149,20 @@ export class IndyVdrPoolService { } } + /** + * Refresh the pool connections asynchronously + */ + public refreshPoolConnections() { + return Promise.allSettled(this.pools.map((pool) => pool.refreshConnection())) + } + + /** + * Get all pool transactions + */ + public getAllPoolTransactions() { + return Promise.allSettled(this.pools.map((pool) => pool.transactions)) + } + /** * Get the most appropriate pool for the given indyNamespace */