Skip to content

Commit 060c8fd

Browse files
cleanup
Signed-off-by: rukmini-basu-da <[email protected]>
1 parent 2abe06e commit 060c8fd

File tree

1 file changed

+81
-40
lines changed

1 file changed

+81
-40
lines changed

core/ledger-client/src/ledger-client.ts

Lines changed: 81 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -526,6 +526,79 @@ export class LedgerClient {
526526
}
527527
}
528528

529+
// async activeContracts(options: {
530+
// offset: number
531+
// templateIds?: string[]
532+
// parties?: string[] //TODO: Figure out if this should use this.partyId by default and not allow cross party filtering
533+
// filterByParty?: boolean
534+
// interfaceIds?: string[]
535+
// limit?: number
536+
// }): Promise<Array<Types['JsGetActiveContractsResponse']>> {
537+
// const {
538+
// offset,
539+
// templateIds,
540+
// parties,
541+
// filterByParty,
542+
// interfaceIds,
543+
// limit,
544+
// } = options
545+
546+
// this.logger.debug(options, 'options for active contracts')
547+
548+
// if (
549+
// templateIds &&
550+
// templateIds.length > 0 &&
551+
// parties &&
552+
// parties.length > 0
553+
// ) {
554+
// return this.acsHelper.activeContractsForTemplates(
555+
// offset,
556+
// parties,
557+
// templateIds
558+
// )
559+
// }
560+
561+
// if (
562+
// interfaceIds &&
563+
// interfaceIds.length > 0 &&
564+
// parties &&
565+
// parties.length > 0
566+
// ) {
567+
// return this.acsHelper.activeContractsForInterfaces(
568+
// offset,
569+
// parties,
570+
// interfaceIds
571+
// )
572+
// }
573+
574+
// if (
575+
// filterByParty &&
576+
// !templateIds?.length &&
577+
// !interfaceIds?.length &&
578+
// parties?.length === 1
579+
// ) {
580+
// const party = parties[0]
581+
// const r = this.acsHelper.activeContractsForInterface(
582+
// offset,
583+
// party,
584+
// ''
585+
// )
586+
// return r
587+
// }
588+
589+
// const filter = this.buildActiveContractFilter(options)
590+
// this.logger.debug('falling back to post request')
591+
592+
// return await this.postWithRetry(
593+
// '/v2/state/active-contracts',
594+
// filter,
595+
// defaultRetryableOptions,
596+
// {
597+
// query: limit ? { limit: limit.toString() } : {},
598+
// }
599+
// )
600+
// }
601+
529602
async activeContracts(options: {
530603
offset: number
531604
templateIds?: string[]
@@ -543,57 +616,25 @@ export class LedgerClient {
543616
limit,
544617
} = options
545618

619+
this.logger.debug(filterByParty)
546620
this.logger.debug(options, 'options for active contracts')
547621

548-
if (interfaceIds?.length === 1 && parties?.length === 1) {
549-
const party = parties[0]
550-
const interfaceId = interfaceIds[0]
551-
return this.acsHelper.activeContractsForInterface(
552-
offset,
553-
party,
554-
interfaceId
555-
)
556-
}
622+
const hasParties = Array.isArray(parties) && parties.length > 0
557623

558-
if (
559-
templateIds &&
560-
templateIds.length > 0 &&
561-
parties &&
562-
parties.length > 0
563-
) {
624+
if (templateIds?.length && hasParties) {
564625
return this.acsHelper.activeContractsForTemplates(
565626
offset,
566-
parties,
567-
templateIds
627+
parties!,
628+
templateIds!
568629
)
569630
}
570631

571-
if (
572-
interfaceIds &&
573-
interfaceIds.length > 0 &&
574-
parties &&
575-
parties.length > 0
576-
) {
632+
if (interfaceIds?.length && hasParties) {
577633
return this.acsHelper.activeContractsForInterfaces(
578634
offset,
579-
parties,
580-
interfaceIds
581-
)
582-
}
583-
584-
if (
585-
filterByParty &&
586-
!templateIds?.length &&
587-
!interfaceIds?.length &&
588-
parties?.length === 1
589-
) {
590-
const party = parties[0]
591-
const r = this.acsHelper.activeContractsForInterface(
592-
offset,
593-
party,
594-
''
635+
parties!,
636+
interfaceIds!
595637
)
596-
return r
597638
}
598639

599640
const filter = this.buildActiveContractFilter(options)

0 commit comments

Comments
 (0)