@@ -34,12 +34,14 @@ import {
3434import { claimsQuery } from '~/middleware/queries/claims' ;
3535import { heartbeatQuery , metadataQuery } from '~/middleware/queries/common' ;
3636import { polyxTransactionsQuery } from '~/middleware/queries/polyxTransactions' ;
37- import { ClaimTypeEnum , Query } from '~/middleware/types' ;
37+ import { Query } from '~/middleware/types' ;
3838import {
3939 AccountBalance ,
4040 ClaimData ,
4141 ClaimType ,
42+ ClaimTypeInput ,
4243 CorporateActionParams ,
44+ CustomClaimWithTypeId ,
4345 DistributionWithDetails ,
4446 ErrorCode ,
4547 MiddlewareMetadata ,
@@ -67,6 +69,7 @@ import {
6769 balanceToBigNumber ,
6870 bigNumberToU32 ,
6971 boolToBoolean ,
72+ claimTypeInputToMiddlewareClaimTypeDetails ,
7073 claimTypeToMeshClaimType ,
7174 corporateActionIdentifierToCaId ,
7275 distributionToDividendDistributionParams ,
@@ -868,7 +871,7 @@ export class Context {
868871 */
869872 public async getIdentityClaimsFromChain ( args : {
870873 targets : ( string | Identity ) [ ] ;
871- claimTypes ?: ClaimType [ ] | undefined ;
874+ claimTypes ?: ClaimTypeInput [ ] | undefined ;
872875 trustedClaimIssuers ?: ( string | Identity ) [ ] | undefined ;
873876 includeExpired : boolean ;
874877 } ) : Promise < ClaimData [ ] > {
@@ -878,15 +881,27 @@ export class Context {
878881 } ,
879882 } = this ;
880883
881- const {
882- targets,
883- claimTypes = Object . values ( ClaimType ) ,
884- trustedClaimIssuers,
885- includeExpired,
886- } = args ;
884+ const { targets, claimTypes, trustedClaimIssuers, includeExpired } = args ;
885+
886+ let claimTypesInput : ClaimTypeInput [ ] ;
887+
888+ if ( claimTypes ) {
889+ claimTypesInput = claimTypes ;
890+ } else {
891+ const customClaimTypes = await identity . customClaims . entries ( ) ;
892+ claimTypesInput = [
893+ ...Object . values ( ClaimType ) . filter ( claimType => claimType !== ClaimType . Custom ) ,
894+ ...customClaimTypes . map ( entry => {
895+ return {
896+ type : ClaimType . Custom ,
897+ customClaimTypeId : u32ToBigNumber ( entry [ 0 ] . args [ 0 ] ) ,
898+ } as CustomClaimWithTypeId ;
899+ } ) ,
900+ ] ;
901+ }
887902
888903 const claim1stKeys = targets . flatMap ( target =>
889- claimTypes . map ( claimType => {
904+ claimTypesInput . map ( claimType => {
890905 return {
891906 target : signerToString ( target ) ,
892907 claimType : claimTypeToMeshClaimType ( claimType , this ) ,
@@ -939,7 +954,7 @@ export class Context {
939954 public async getIdentityClaimsFromMiddleware ( args : {
940955 targets ?: ( string | Identity ) [ ] | undefined ;
941956 trustedClaimIssuers ?: ( string | Identity ) [ ] | undefined ;
942- claimTypes ?: ClaimType [ ] | undefined ;
957+ claimTypes ?: ClaimTypeInput [ ] | undefined ;
943958 includeExpired ?: boolean | undefined ;
944959 size ?: BigNumber | undefined ;
945960 start ?: BigNumber | undefined ;
@@ -965,7 +980,7 @@ export class Context {
965980 trustedClaimIssuers : trustedClaimIssuers ?. map ( trustedClaimIssuer =>
966981 signerToString ( trustedClaimIssuer )
967982 ) ,
968- claimTypes : claimTypes ?. map ( ct => ClaimTypeEnum [ ct ] ) ,
983+ ... claimTypeInputToMiddlewareClaimTypeDetails ( claimTypes ) ,
969984 includeExpired,
970985 } ,
971986 size ,
@@ -1004,7 +1019,7 @@ export class Context {
10041019 opts : {
10051020 targets ?: ( string | Identity ) [ ] ;
10061021 trustedClaimIssuers ?: ( string | Identity ) [ ] ;
1007- claimTypes ?: ClaimType [ ] ;
1022+ claimTypes ?: ClaimTypeInput [ ] ;
10081023 includeExpired ?: boolean ;
10091024 size ?: BigNumber ;
10101025 start ?: BigNumber ;
0 commit comments