@procivis/one-react-native-components 0.3.106 → 0.3.112
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/commonjs/components/backup/preview-credentials.js.map +1 -1
- package/lib/commonjs/components/credential/credential.js.map +1 -1
- package/lib/commonjs/components/entity/EntityButtons.js.map +1 -1
- package/lib/commonjs/components/entity/entity-attributes.js.map +1 -1
- package/lib/commonjs/components/entity/entity-details-with-buttons.js +2 -2
- package/lib/commonjs/components/entity/entity-details-with-buttons.js.map +1 -1
- package/lib/commonjs/components/entity/entity-details.js +3 -3
- package/lib/commonjs/components/entity/entity-details.js.map +1 -1
- package/lib/commonjs/components/history/history-details-screen.js +10 -10
- package/lib/commonjs/components/history/history-details-screen.js.map +1 -1
- package/lib/commonjs/components/history/history-list-item-icon.js +10 -7
- package/lib/commonjs/components/history/history-list-item-icon.js.map +1 -1
- package/lib/commonjs/components/history/history-list-item.js.map +1 -1
- package/lib/commonjs/components/history/history-list-screen.js.map +1 -1
- package/lib/commonjs/components/history/history-list-section-header.js +1 -1
- package/lib/commonjs/components/history/history-list-section-header.js.map +1 -1
- package/lib/commonjs/components/history/history-list.js.map +1 -1
- package/lib/commonjs/components/proof-request/v1/select-credential.js.map +1 -1
- package/lib/commonjs/components/proof-request/v1/share-credential.js +1 -1
- package/lib/commonjs/components/proof-request/v1/share-credential.js.map +1 -1
- package/lib/commonjs/components/proof-request/v2/select-credential-v2.js.map +1 -1
- package/lib/commonjs/components/proof-request/v2/share-credential-v2-group.js.map +1 -1
- package/lib/commonjs/components/proof-request/v2/share-credential-v2.js.map +1 -1
- package/lib/commonjs/ui-components/control/checkbox.js +1 -1
- package/lib/commonjs/ui-components/control/checkbox.js.map +1 -1
- package/lib/commonjs/ui-components/control/switch.js +2 -2
- package/lib/commonjs/ui-components/control/switch.js.map +1 -1
- package/lib/commonjs/ui-components/history/history-section-header.js +1 -1
- package/lib/commonjs/ui-components/history/history-section-header.js.map +1 -1
- package/lib/commonjs/ui-components/history/history-section-list-item.js +1 -1
- package/lib/commonjs/ui-components/history/history-section-list-item.js.map +1 -1
- package/lib/commonjs/ui-components/screens/nerd-mode-screen.js.map +1 -1
- package/lib/commonjs/utils/history.js.map +1 -1
- package/lib/commonjs/utils/hooks/core/backup.js +2 -2
- package/lib/commonjs/utils/hooks/core/backup.js.map +1 -1
- package/lib/commonjs/utils/hooks/core/cache.js +10 -10
- package/lib/commonjs/utils/hooks/core/cache.js.map +1 -1
- package/lib/commonjs/utils/hooks/core/core-config.js.map +1 -1
- package/lib/commonjs/utils/hooks/core/credential-schemas.js +1 -1
- package/lib/commonjs/utils/hooks/core/credential-schemas.js.map +1 -1
- package/lib/commonjs/utils/hooks/core/credentials.js +4 -4
- package/lib/commonjs/utils/hooks/core/credentials.js.map +1 -1
- package/lib/commonjs/utils/hooks/core/dids.js +2 -2
- package/lib/commonjs/utils/hooks/core/dids.js.map +1 -1
- package/lib/commonjs/utils/hooks/core/history.js +1 -1
- package/lib/commonjs/utils/hooks/core/history.js.map +1 -1
- package/lib/commonjs/utils/hooks/core/identifiers.js +2 -2
- package/lib/commonjs/utils/hooks/core/identifiers.js.map +1 -1
- package/lib/commonjs/utils/hooks/core/index.js +11 -0
- package/lib/commonjs/utils/hooks/core/index.js.map +1 -1
- package/lib/commonjs/utils/hooks/core/proof-schemas.js +1 -1
- package/lib/commonjs/utils/hooks/core/proof-schemas.js.map +1 -1
- package/lib/commonjs/utils/hooks/core/proofs.js +11 -11
- package/lib/commonjs/utils/hooks/core/proofs.js.map +1 -1
- package/lib/commonjs/utils/hooks/core/trust-entity.js +1 -1
- package/lib/commonjs/utils/hooks/core/trust-entity.js.map +1 -1
- package/lib/commonjs/utils/hooks/core/trust-list.js +32 -0
- package/lib/commonjs/utils/hooks/core/trust-list.js.map +1 -0
- package/lib/commonjs/utils/hooks/core/wallet-unit.js +30 -2
- package/lib/commonjs/utils/hooks/core/wallet-unit.js.map +1 -1
- package/lib/commonjs/utils/hooks/revocation/credential-status.js +1 -1
- package/lib/commonjs/utils/hooks/revocation/credential-status.js.map +1 -1
- package/lib/commonjs/utils/parsers/credential-images.js +3 -3
- package/lib/commonjs/utils/parsers/credential-images.js.map +1 -1
- package/lib/commonjs/utils/parsers/credential-sharing-v2.js.map +1 -1
- package/lib/commonjs/utils/parsers/credential-sharing.js.map +1 -1
- package/lib/commonjs/utils/parsers/credential.js +9 -9
- package/lib/commonjs/utils/parsers/credential.js.map +1 -1
- package/lib/commonjs/utils/parsers/query.js.map +1 -1
- package/lib/module/components/backup/preview-credentials.js.map +1 -1
- package/lib/module/components/credential/credential.js.map +1 -1
- package/lib/module/components/entity/EntityButtons.js.map +1 -1
- package/lib/module/components/entity/entity-attributes.js.map +1 -1
- package/lib/module/components/entity/entity-details-with-buttons.js +3 -3
- package/lib/module/components/entity/entity-details-with-buttons.js.map +1 -1
- package/lib/module/components/entity/entity-details.js +4 -4
- package/lib/module/components/entity/entity-details.js.map +1 -1
- package/lib/module/components/history/history-details-screen.js +11 -11
- package/lib/module/components/history/history-details-screen.js.map +1 -1
- package/lib/module/components/history/history-list-item-icon.js +11 -8
- package/lib/module/components/history/history-list-item-icon.js.map +1 -1
- package/lib/module/components/history/history-list-item.js.map +1 -1
- package/lib/module/components/history/history-list-screen.js.map +1 -1
- package/lib/module/components/history/history-list-section-header.js +1 -1
- package/lib/module/components/history/history-list-section-header.js.map +1 -1
- package/lib/module/components/history/history-list.js.map +1 -1
- package/lib/module/components/proof-request/v1/select-credential.js.map +1 -1
- package/lib/module/components/proof-request/v1/share-credential.js +2 -2
- package/lib/module/components/proof-request/v1/share-credential.js.map +1 -1
- package/lib/module/components/proof-request/v2/select-credential-v2.js.map +1 -1
- package/lib/module/components/proof-request/v2/share-credential-v2-group.js.map +1 -1
- package/lib/module/components/proof-request/v2/share-credential-v2.js.map +1 -1
- package/lib/module/ui-components/control/checkbox.js +1 -1
- package/lib/module/ui-components/control/checkbox.js.map +1 -1
- package/lib/module/ui-components/control/switch.js +3 -3
- package/lib/module/ui-components/control/switch.js.map +1 -1
- package/lib/module/ui-components/history/history-section-header.js +1 -1
- package/lib/module/ui-components/history/history-section-header.js.map +1 -1
- package/lib/module/ui-components/history/history-section-list-item.js +1 -1
- package/lib/module/ui-components/history/history-section-list-item.js.map +1 -1
- package/lib/module/ui-components/screens/nerd-mode-screen.js.map +1 -1
- package/lib/module/utils/history.js.map +1 -1
- package/lib/module/utils/hooks/core/backup.js +3 -3
- package/lib/module/utils/hooks/core/backup.js.map +1 -1
- package/lib/module/utils/hooks/core/cache.js +11 -11
- package/lib/module/utils/hooks/core/cache.js.map +1 -1
- package/lib/module/utils/hooks/core/core-config.js.map +1 -1
- package/lib/module/utils/hooks/core/credential-schemas.js +1 -1
- package/lib/module/utils/hooks/core/credential-schemas.js.map +1 -1
- package/lib/module/utils/hooks/core/credentials.js +5 -5
- package/lib/module/utils/hooks/core/credentials.js.map +1 -1
- package/lib/module/utils/hooks/core/dids.js +3 -3
- package/lib/module/utils/hooks/core/dids.js.map +1 -1
- package/lib/module/utils/hooks/core/history.js +1 -1
- package/lib/module/utils/hooks/core/history.js.map +1 -1
- package/lib/module/utils/hooks/core/identifiers.js +3 -3
- package/lib/module/utils/hooks/core/identifiers.js.map +1 -1
- package/lib/module/utils/hooks/core/index.js +1 -0
- package/lib/module/utils/hooks/core/index.js.map +1 -1
- package/lib/module/utils/hooks/core/proof-schemas.js +1 -1
- package/lib/module/utils/hooks/core/proof-schemas.js.map +1 -1
- package/lib/module/utils/hooks/core/proofs.js +12 -12
- package/lib/module/utils/hooks/core/proofs.js.map +1 -1
- package/lib/module/utils/hooks/core/trust-entity.js +2 -2
- package/lib/module/utils/hooks/core/trust-entity.js.map +1 -1
- package/lib/module/utils/hooks/core/trust-list.js +24 -0
- package/lib/module/utils/hooks/core/trust-list.js.map +1 -0
- package/lib/module/utils/hooks/core/wallet-unit.js +28 -2
- package/lib/module/utils/hooks/core/wallet-unit.js.map +1 -1
- package/lib/module/utils/hooks/revocation/credential-status.js +2 -2
- package/lib/module/utils/hooks/revocation/credential-status.js.map +1 -1
- package/lib/module/utils/parsers/credential-images.js +4 -4
- package/lib/module/utils/parsers/credential-images.js.map +1 -1
- package/lib/module/utils/parsers/credential-sharing-v2.js.map +1 -1
- package/lib/module/utils/parsers/credential-sharing.js.map +1 -1
- package/lib/module/utils/parsers/credential.js +10 -10
- package/lib/module/utils/parsers/credential.js.map +1 -1
- package/lib/module/utils/parsers/query.js.map +1 -1
- package/lib/typescript/components/backup/preview-credentials.d.ts +2 -2
- package/lib/typescript/components/credential/credential.d.ts +2 -2
- package/lib/typescript/components/entity/EntityButtons.d.ts +2 -2
- package/lib/typescript/components/entity/entity-attributes.d.ts +2 -2
- package/lib/typescript/components/entity/entity-details-with-buttons.d.ts +3 -3
- package/lib/typescript/components/entity/entity-details.d.ts +5 -5
- package/lib/typescript/components/history/history-details-screen.d.ts +2 -2
- package/lib/typescript/components/history/history-list-item-icon.d.ts +3 -3
- package/lib/typescript/components/history/history-list-item.d.ts +5 -5
- package/lib/typescript/components/history/history-list-screen.d.ts +4 -4
- package/lib/typescript/components/history/history-list.d.ts +5 -5
- package/lib/typescript/components/proof-request/v1/select-credential.d.ts +2 -2
- package/lib/typescript/components/proof-request/v1/share-credential.d.ts +6 -6
- package/lib/typescript/components/proof-request/v2/select-credential-v2.d.ts +3 -3
- package/lib/typescript/components/proof-request/v2/share-credential-v2-group.d.ts +4 -4
- package/lib/typescript/components/proof-request/v2/share-credential-v2.d.ts +5 -5
- package/lib/typescript/ui-components/control/checkbox.d.ts +1 -1
- package/lib/typescript/ui-components/screens/nerd-mode-screen.d.ts +2 -2
- package/lib/typescript/utils/history.d.ts +3 -3
- package/lib/typescript/utils/hooks/core/backup.d.ts +3 -3
- package/lib/typescript/utils/hooks/core/cache.d.ts +2 -2
- package/lib/typescript/utils/hooks/core/core-config.d.ts +4 -4
- package/lib/typescript/utils/hooks/core/credential-schemas.d.ts +6 -6
- package/lib/typescript/utils/hooks/core/credentials.d.ts +8 -8
- package/lib/typescript/utils/hooks/core/dids.d.ts +2 -2
- package/lib/typescript/utils/hooks/core/history.d.ts +2 -2
- package/lib/typescript/utils/hooks/core/identifiers.d.ts +3 -3
- package/lib/typescript/utils/hooks/core/index.d.ts +1 -0
- package/lib/typescript/utils/hooks/core/proof-schemas.d.ts +7 -7
- package/lib/typescript/utils/hooks/core/proofs.d.ts +9 -9
- package/lib/typescript/utils/hooks/core/trust-entity.d.ts +5 -5
- package/lib/typescript/utils/hooks/core/trust-list.d.ts +5 -0
- package/lib/typescript/utils/hooks/core/wallet-unit.d.ts +11 -5
- package/lib/typescript/utils/parsers/credential-images.d.ts +2 -2
- package/lib/typescript/utils/parsers/credential-sharing-v2.d.ts +7 -7
- package/lib/typescript/utils/parsers/credential-sharing.d.ts +8 -8
- package/lib/typescript/utils/parsers/credential.d.ts +11 -11
- package/lib/typescript/utils/parsers/query.d.ts +8 -8
- package/package.json +3 -3
- package/src/components/backup/preview-credentials.tsx +2 -2
- package/src/components/credential/credential.tsx +2 -2
- package/src/components/entity/EntityButtons.tsx +2 -2
- package/src/components/entity/entity-attributes.tsx +2 -2
- package/src/components/entity/entity-details-with-buttons.tsx +6 -11
- package/src/components/entity/entity-details.tsx +16 -17
- package/src/components/history/history-details-screen.tsx +13 -13
- package/src/components/history/history-list-item-icon.tsx +14 -15
- package/src/components/history/history-list-item.tsx +5 -9
- package/src/components/history/history-list-screen.tsx +4 -4
- package/src/components/history/history-list-section-header.tsx +1 -1
- package/src/components/history/history-list.tsx +6 -6
- package/src/components/proof-request/v1/select-credential.tsx +2 -2
- package/src/components/proof-request/v1/share-credential.tsx +11 -13
- package/src/components/proof-request/v2/select-credential-v2.tsx +3 -6
- package/src/components/proof-request/v2/share-credential-v2-group.tsx +10 -10
- package/src/components/proof-request/v2/share-credential-v2.tsx +9 -9
- package/src/ui-components/control/checkbox.tsx +12 -10
- package/src/ui-components/control/switch.tsx +23 -21
- package/src/ui-components/detail/detail.stories.tsx +1 -1
- package/src/ui-components/history/history-section-header.tsx +1 -1
- package/src/ui-components/history/history-section-list-item.tsx +1 -1
- package/src/ui-components/screens/nerd-mode-screen.tsx +2 -2
- package/src/utils/history.ts +4 -4
- package/src/utils/hooks/core/backup.ts +3 -3
- package/src/utils/hooks/core/cache.ts +13 -13
- package/src/utils/hooks/core/core-config.ts +3 -3
- package/src/utils/hooks/core/credential-schemas.ts +5 -8
- package/src/utils/hooks/core/credentials.ts +14 -22
- package/src/utils/hooks/core/dids.ts +4 -4
- package/src/utils/hooks/core/history.ts +3 -3
- package/src/utils/hooks/core/identifiers.ts +4 -8
- package/src/utils/hooks/core/index.ts +1 -0
- package/src/utils/hooks/core/proof-schemas.ts +16 -22
- package/src/utils/hooks/core/proofs.ts +33 -34
- package/src/utils/hooks/core/trust-entity.ts +8 -10
- package/src/utils/hooks/core/trust-list.ts +29 -0
- package/src/utils/hooks/core/wallet-unit.ts +38 -12
- package/src/utils/hooks/revocation/credential-status.ts +2 -2
- package/src/utils/parsers/credential-images.tsx +6 -10
- package/src/utils/parsers/credential-sharing-v2.tsx +20 -22
- package/src/utils/parsers/credential-sharing.tsx +28 -28
- package/src/utils/parsers/credential.ts +43 -43
- package/src/utils/parsers/query.ts +14 -16
|
@@ -1,7 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
CredentialSchemaListQueryBindingDto,
|
|
3
|
-
ImportCredentialSchemaRequestSchemaBindingDto,
|
|
4
|
-
} from '@procivis/react-native-one-core';
|
|
1
|
+
import { CredentialSchemaListQuery, ImportCredentialSchemaRequestSchema } from '@procivis/react-native-one-core';
|
|
5
2
|
import { useInfiniteQuery, useMutation, useQuery, useQueryClient } from 'react-query';
|
|
6
3
|
|
|
7
4
|
import { getQueryKeyFromCredentialSchemaListQueryParams } from '../../parsers/query';
|
|
@@ -15,14 +12,14 @@ export const CREDENTIAL_SCHEMA_DETAIL_QUERY_KEY = 'credential-schema-detail';
|
|
|
15
12
|
export const CREDENTIAL_SCHEMA_PREVIEW_QUERY_KEY = 'credential-schema-preview';
|
|
16
13
|
export const CREDENTIAL_SCHEMA_SHARE_QUERY_KEY = 'credential-schema-share';
|
|
17
14
|
|
|
18
|
-
export const useCredentialSchemas = (queryParams?: Partial<
|
|
15
|
+
export const useCredentialSchemas = (queryParams?: Partial<CredentialSchemaListQuery>) => {
|
|
19
16
|
const { core, organisationId } = useONECore();
|
|
20
17
|
|
|
21
18
|
return useInfiniteQuery(
|
|
22
19
|
[CREDENTIAL_SCHEMA_LIST_QUERY_KEY, ...getQueryKeyFromCredentialSchemaListQueryParams(queryParams)],
|
|
23
20
|
({ pageParam = 0 }) =>
|
|
24
21
|
core
|
|
25
|
-
.
|
|
22
|
+
.listCredentialSchemas({
|
|
26
23
|
organisationId,
|
|
27
24
|
page: pageParam,
|
|
28
25
|
pageSize: PAGE_SIZE,
|
|
@@ -46,7 +43,7 @@ export const useCredentialSchemaPreview = (url: string) => {
|
|
|
46
43
|
if (!response.ok) {
|
|
47
44
|
throw response.originalError;
|
|
48
45
|
}
|
|
49
|
-
return response.data as
|
|
46
|
+
return response.data as ImportCredentialSchemaRequestSchema;
|
|
50
47
|
}),
|
|
51
48
|
{
|
|
52
49
|
keepPreviousData: true,
|
|
@@ -59,7 +56,7 @@ export const useCredentialSchemaAccept = () => {
|
|
|
59
56
|
const { core, organisationId } = useONECore();
|
|
60
57
|
|
|
61
58
|
return useMutation(
|
|
62
|
-
async (schema:
|
|
59
|
+
async (schema: ImportCredentialSchemaRequestSchema) =>
|
|
63
60
|
core.importCredentialSchema({
|
|
64
61
|
organisationId,
|
|
65
62
|
schema,
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
2
|
+
CredentialListQuery,
|
|
3
|
+
CredentialState,
|
|
4
|
+
HandleInvitationRequest,
|
|
5
|
+
HandleInvitationResponse,
|
|
6
|
+
InitiateIssuanceRequest,
|
|
7
7
|
OneError,
|
|
8
8
|
} from '@procivis/react-native-one-core';
|
|
9
9
|
import { useInfiniteQuery, useMutation, useQuery, useQueryClient } from 'react-query';
|
|
@@ -20,22 +20,18 @@ export const CREDENTIAL_LIST_QUERY_KEY = 'credential-list';
|
|
|
20
20
|
export const CREDENTIAL_LIST_PAGED_QUERY_KEY = 'credential-list-paged';
|
|
21
21
|
export const CREDENTIAL_DETAIL_QUERY_KEY = 'credential-detail';
|
|
22
22
|
|
|
23
|
-
export const useCredentials = (queryParams?: Partial<
|
|
23
|
+
export const useCredentials = (queryParams?: Partial<CredentialListQuery>) => {
|
|
24
24
|
const { core, organisationId } = useONECore();
|
|
25
25
|
|
|
26
26
|
return useQuery(
|
|
27
27
|
[CREDENTIAL_LIST_QUERY_KEY, ...getQueryKeyFromCredentialListQueryParams(queryParams)],
|
|
28
28
|
async () => {
|
|
29
|
-
const { values } = await core.
|
|
29
|
+
const { values } = await core.listCredentials({
|
|
30
30
|
organisationId,
|
|
31
31
|
page: 0,
|
|
32
32
|
// TODO: workaround pagination for now, until it's supported by UI
|
|
33
33
|
pageSize: 10000,
|
|
34
|
-
states: [
|
|
35
|
-
CredentialStateBindingEnum.ACCEPTED,
|
|
36
|
-
CredentialStateBindingEnum.SUSPENDED,
|
|
37
|
-
CredentialStateBindingEnum.REVOKED,
|
|
38
|
-
],
|
|
34
|
+
states: [CredentialState.ACCEPTED, CredentialState.SUSPENDED, CredentialState.REVOKED],
|
|
39
35
|
...queryParams,
|
|
40
36
|
});
|
|
41
37
|
return values;
|
|
@@ -46,7 +42,7 @@ export const useCredentials = (queryParams?: Partial<CredentialListQueryBindingD
|
|
|
46
42
|
);
|
|
47
43
|
};
|
|
48
44
|
|
|
49
|
-
export const usePagedCredentials = (queryParams?: Partial<
|
|
45
|
+
export const usePagedCredentials = (queryParams?: Partial<CredentialListQuery>) => {
|
|
50
46
|
const { core, organisationId } = useONECore();
|
|
51
47
|
|
|
52
48
|
return useInfiniteQuery(
|
|
@@ -56,15 +52,11 @@ export const usePagedCredentials = (queryParams?: Partial<CredentialListQueryBin
|
|
|
56
52
|
...getQueryKeyFromCredentialListQueryParams(queryParams),
|
|
57
53
|
],
|
|
58
54
|
({ pageParam = 0 }) =>
|
|
59
|
-
core.
|
|
55
|
+
core.listCredentials({
|
|
60
56
|
organisationId,
|
|
61
57
|
page: pageParam,
|
|
62
58
|
pageSize: PAGE_SIZE,
|
|
63
|
-
states: [
|
|
64
|
-
CredentialStateBindingEnum.ACCEPTED,
|
|
65
|
-
CredentialStateBindingEnum.SUSPENDED,
|
|
66
|
-
CredentialStateBindingEnum.REVOKED,
|
|
67
|
-
],
|
|
59
|
+
states: [CredentialState.ACCEPTED, CredentialState.SUSPENDED, CredentialState.REVOKED],
|
|
68
60
|
...queryParams,
|
|
69
61
|
}),
|
|
70
62
|
{
|
|
@@ -92,10 +84,10 @@ export const useInvitationHandler = () => {
|
|
|
92
84
|
const { core, organisationId } = useONECore();
|
|
93
85
|
|
|
94
86
|
return useMutation(
|
|
95
|
-
async (request: Omit<
|
|
87
|
+
async (request: Omit<HandleInvitationRequest, 'organisationId'>) =>
|
|
96
88
|
core.handleInvitation({ organisationId, ...request }),
|
|
97
89
|
{
|
|
98
|
-
onSuccess: async (result:
|
|
90
|
+
onSuccess: async (result: HandleInvitationResponse) => {
|
|
99
91
|
if (result.type_ === 'PROOF_REQUEST') {
|
|
100
92
|
await queryClient.invalidateQueries(PROOF_LIST_QUERY_KEY);
|
|
101
93
|
} else {
|
|
@@ -197,7 +189,7 @@ export const useInitiateIssuance = () => {
|
|
|
197
189
|
const { core, organisationId } = useONECore();
|
|
198
190
|
|
|
199
191
|
return useMutation(
|
|
200
|
-
async (request: Omit<
|
|
192
|
+
async (request: Omit<InitiateIssuanceRequest, 'organisationId'>) =>
|
|
201
193
|
core.initiateIssuance({ organisationId, ...request }),
|
|
202
194
|
{
|
|
203
195
|
onSuccess: async () => {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { DidListQuery, DidType } from '@procivis/react-native-one-core';
|
|
2
2
|
import { useQuery } from 'react-query';
|
|
3
3
|
|
|
4
4
|
import { getQueryKeyFromDidListQueryParams } from '../../parsers/query';
|
|
@@ -7,18 +7,18 @@ import { useONECore } from './core-context';
|
|
|
7
7
|
const PAGE_SIZE = 20;
|
|
8
8
|
export const DID_LIST_QUERY_KEY = 'did-list';
|
|
9
9
|
|
|
10
|
-
export const useDids = (queryParams?: Partial<
|
|
10
|
+
export const useDids = (queryParams?: Partial<DidListQuery>) => {
|
|
11
11
|
const { core, organisationId } = useONECore();
|
|
12
12
|
|
|
13
13
|
return useQuery(
|
|
14
14
|
[DID_LIST_QUERY_KEY, ...getQueryKeyFromDidListQueryParams(queryParams)],
|
|
15
15
|
async ({ pageParam = 0 }) => {
|
|
16
|
-
const dids = await core.
|
|
16
|
+
const dids = await core.listDids({
|
|
17
17
|
deactivated: false,
|
|
18
18
|
organisationId,
|
|
19
19
|
page: pageParam,
|
|
20
20
|
pageSize: PAGE_SIZE,
|
|
21
|
-
type:
|
|
21
|
+
type: DidType.LOCAL,
|
|
22
22
|
...queryParams,
|
|
23
23
|
});
|
|
24
24
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { HistoryListQuery } from '@procivis/react-native-one-core';
|
|
2
2
|
import { useInfiniteQuery } from 'react-query';
|
|
3
3
|
|
|
4
4
|
import { getQueryKeyFromHistoryListQueryParams } from '../../parsers/query';
|
|
@@ -7,13 +7,13 @@ import { useONECore } from './core-context';
|
|
|
7
7
|
const PAGE_SIZE = 20;
|
|
8
8
|
export const HISTORY_LIST_QUERY_KEY = 'history-list';
|
|
9
9
|
|
|
10
|
-
export const useHistory = (queryParams?: Partial<
|
|
10
|
+
export const useHistory = (queryParams?: Partial<HistoryListQuery>) => {
|
|
11
11
|
const { core, organisationId } = useONECore();
|
|
12
12
|
|
|
13
13
|
return useInfiniteQuery(
|
|
14
14
|
[HISTORY_LIST_QUERY_KEY, ...getQueryKeyFromHistoryListQueryParams(queryParams)],
|
|
15
15
|
async ({ pageParam = 0 }) => {
|
|
16
|
-
const historyPage = await core.
|
|
16
|
+
const historyPage = await core.listHistory({
|
|
17
17
|
organisationId,
|
|
18
18
|
page: pageParam,
|
|
19
19
|
pageSize: PAGE_SIZE,
|
|
@@ -1,8 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
IdentifierListQueryBindingDto,
|
|
3
|
-
IdentifierStateBindingEnum,
|
|
4
|
-
IdentifierTypeBindingEnum,
|
|
5
|
-
} from '@procivis/react-native-one-core';
|
|
1
|
+
import { IdentifierListQuery, IdentifierState, IdentifierType } from '@procivis/react-native-one-core';
|
|
6
2
|
import { useQuery } from 'react-query';
|
|
7
3
|
|
|
8
4
|
import { getQueryKeyFromIdentifierListQueryParams } from '../../parsers';
|
|
@@ -25,17 +21,17 @@ export const useIdentifierDetails = (identifierId: string | undefined) => {
|
|
|
25
21
|
);
|
|
26
22
|
};
|
|
27
23
|
|
|
28
|
-
export const useIdentifiers = (identifierFilter?: Partial<
|
|
24
|
+
export const useIdentifiers = (identifierFilter?: Partial<IdentifierListQuery>) => {
|
|
29
25
|
const { core, organisationId } = useONECore();
|
|
30
26
|
|
|
31
27
|
return useQuery(
|
|
32
28
|
[IDENTIFIER_LIST_QUERY_KEY, ...getQueryKeyFromIdentifierListQueryParams(identifierFilter)],
|
|
33
29
|
({ pageParam = 0 }) =>
|
|
34
30
|
core.listIdentifiers({
|
|
35
|
-
types: [
|
|
31
|
+
types: [IdentifierType.DID],
|
|
36
32
|
isRemote: false,
|
|
37
33
|
page: pageParam,
|
|
38
|
-
states: [
|
|
34
|
+
states: [IdentifierState.ACTIVE],
|
|
39
35
|
organisationId: organisationId,
|
|
40
36
|
pageSize: PAGE_SIZE,
|
|
41
37
|
...identifierFilter,
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
2
|
+
CreateProofSchemaRequest,
|
|
3
|
+
ImportProofSchema,
|
|
4
|
+
ProofSchemaListItem,
|
|
5
|
+
ProofSchemaListQuery,
|
|
6
6
|
} from '@procivis/react-native-one-core';
|
|
7
7
|
import { useInfiniteQuery, useMutation, useQuery, useQueryClient } from 'react-query';
|
|
8
8
|
|
|
@@ -18,14 +18,14 @@ export const PROOF_SCHEMA_IMPORT_DETAIL_QUERY_KEY = 'proof-schema-import';
|
|
|
18
18
|
export const PROOF_SCHEMA_DETAIL_QUERY_KEY = 'proof-schema-detail';
|
|
19
19
|
export const PROOF_SCHEMA_SHARE_QUERY_KEY = 'proof-schema-share';
|
|
20
20
|
|
|
21
|
-
export const useProofSchemas = (queryParams?: Partial<
|
|
21
|
+
export const useProofSchemas = (queryParams?: Partial<ProofSchemaListQuery>, keepPreviousData = true) => {
|
|
22
22
|
const { core, organisationId } = useONECore();
|
|
23
23
|
|
|
24
24
|
return useInfiniteQuery(
|
|
25
25
|
[PROOF_SCHEMA_LIST_QUERY_KEY, ...getQueryKeyFromProofSchemaListQueryParams(queryParams)],
|
|
26
26
|
({ pageParam = 0 }) =>
|
|
27
27
|
core
|
|
28
|
-
.
|
|
28
|
+
.listProofSchemas({
|
|
29
29
|
organisationId,
|
|
30
30
|
page: pageParam,
|
|
31
31
|
pageSize: PAGE_SIZE,
|
|
@@ -39,10 +39,7 @@ export const useProofSchemas = (queryParams?: Partial<ListProofSchemasFiltersBin
|
|
|
39
39
|
);
|
|
40
40
|
};
|
|
41
41
|
|
|
42
|
-
export const useProofSchemaDetail = (
|
|
43
|
-
proofSchemaId: GetProofSchemaListItemBindingDto['id'] | undefined,
|
|
44
|
-
active = true,
|
|
45
|
-
) => {
|
|
42
|
+
export const useProofSchemaDetail = (proofSchemaId: ProofSchemaListItem['id'] | undefined, active = true) => {
|
|
46
43
|
const { core } = useONECore();
|
|
47
44
|
|
|
48
45
|
return useQuery(
|
|
@@ -65,7 +62,7 @@ export const useProofSchemaImportDetail = (url: string) => {
|
|
|
65
62
|
if (!response.ok) {
|
|
66
63
|
throw response.originalError;
|
|
67
64
|
}
|
|
68
|
-
return response.data as
|
|
65
|
+
return response.data as ImportProofSchema;
|
|
69
66
|
}),
|
|
70
67
|
{
|
|
71
68
|
keepPreviousData: true,
|
|
@@ -78,7 +75,7 @@ export const useProofSchemaAccept = () => {
|
|
|
78
75
|
const { core, organisationId } = useONECore();
|
|
79
76
|
|
|
80
77
|
return useMutation(
|
|
81
|
-
async ({ schema }: { schema:
|
|
78
|
+
async ({ schema }: { schema: ImportProofSchema }) =>
|
|
82
79
|
core.importProofSchema({
|
|
83
80
|
organisationId,
|
|
84
81
|
schema,
|
|
@@ -97,7 +94,7 @@ export const useProofSchemaCreate = () => {
|
|
|
97
94
|
const queryClient = useQueryClient();
|
|
98
95
|
const { core } = useONECore();
|
|
99
96
|
|
|
100
|
-
return useMutation(async (proofSchema:
|
|
97
|
+
return useMutation(async (proofSchema: CreateProofSchemaRequest) => core.createProofSchema(proofSchema), {
|
|
101
98
|
onSuccess: async () => {
|
|
102
99
|
await queryClient.invalidateQueries(PROOF_SCHEMA_LIST_QUERY_KEY);
|
|
103
100
|
await queryClient.invalidateQueries(HISTORY_LIST_QUERY_KEY);
|
|
@@ -109,16 +106,13 @@ export const useProofSchemaDelete = () => {
|
|
|
109
106
|
const queryClient = useQueryClient();
|
|
110
107
|
const { core } = useONECore();
|
|
111
108
|
|
|
112
|
-
return useMutation(
|
|
113
|
-
async (proofSchemaId
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
await queryClient.invalidateQueries(HISTORY_LIST_QUERY_KEY);
|
|
118
|
-
await queryClient.removeQueries([PROOF_SCHEMA_DETAIL_QUERY_KEY, proofSchemaId]);
|
|
119
|
-
},
|
|
109
|
+
return useMutation(async (proofSchemaId: ProofSchemaListItem['id']) => core.deleteProofSchema(proofSchemaId), {
|
|
110
|
+
onSuccess: async (_, proofSchemaId) => {
|
|
111
|
+
await queryClient.invalidateQueries(PROOF_SCHEMA_LIST_QUERY_KEY);
|
|
112
|
+
await queryClient.invalidateQueries(HISTORY_LIST_QUERY_KEY);
|
|
113
|
+
await queryClient.removeQueries([PROOF_SCHEMA_DETAIL_QUERY_KEY, proofSchemaId]);
|
|
120
114
|
},
|
|
121
|
-
);
|
|
115
|
+
});
|
|
122
116
|
};
|
|
123
117
|
|
|
124
118
|
export const useShareProofSchema = (schemaId?: string) => {
|
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
IdentifierListQueryBindingDto,
|
|
2
|
+
CoreConfig,
|
|
3
|
+
CreateProofRequest,
|
|
4
|
+
HistoryAction,
|
|
5
|
+
HistoryEntityType,
|
|
6
|
+
HistoryErrorMetadata,
|
|
7
|
+
IdentifierListQuery,
|
|
9
8
|
OneError,
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
9
|
+
PresentationSubmitCredentialRequest,
|
|
10
|
+
ProofListQuery,
|
|
11
|
+
ProofSchemaDetail,
|
|
12
|
+
ProofState,
|
|
13
|
+
ProposeProofRequest,
|
|
14
|
+
ShareProofRequest,
|
|
15
15
|
} from '@procivis/react-native-one-core';
|
|
16
16
|
import { useCallback, useEffect, useMemo, useRef, useState } from 'react';
|
|
17
17
|
import { useMutation, useQuery, useQueryClient } from 'react-query';
|
|
@@ -51,18 +51,18 @@ export const useProofState = (proofId: string | undefined, isPolling: boolean) =
|
|
|
51
51
|
}
|
|
52
52
|
|
|
53
53
|
const state = await core.getProof(proofId).then((proof) => proof.state);
|
|
54
|
-
let metadata:
|
|
55
|
-
if (state ===
|
|
54
|
+
let metadata: HistoryErrorMetadata | undefined;
|
|
55
|
+
if (state === ProofState.ERROR) {
|
|
56
56
|
metadata = await core
|
|
57
|
-
.
|
|
57
|
+
.listHistory({
|
|
58
58
|
organisationId,
|
|
59
59
|
page: 0,
|
|
60
60
|
pageSize: 1,
|
|
61
61
|
entityIds: [proofId],
|
|
62
|
-
entityTypes: [
|
|
63
|
-
actions: [
|
|
62
|
+
entityTypes: [HistoryEntityType.PROOF],
|
|
63
|
+
actions: [HistoryAction.ERRORED],
|
|
64
64
|
})
|
|
65
|
-
.then((result) => result.values[0]?.metadata?.value as
|
|
65
|
+
.then((result) => result.values[0]?.metadata?.value as HistoryErrorMetadata);
|
|
66
66
|
}
|
|
67
67
|
return { state, metadata };
|
|
68
68
|
},
|
|
@@ -73,7 +73,7 @@ export const useProofState = (proofId: string | undefined, isPolling: boolean) =
|
|
|
73
73
|
);
|
|
74
74
|
};
|
|
75
75
|
|
|
76
|
-
type ProofUrlHookParams = { proofId: string; request?:
|
|
76
|
+
type ProofUrlHookParams = { proofId: string; request?: ShareProofRequest };
|
|
77
77
|
|
|
78
78
|
export const useProofUrl = () => {
|
|
79
79
|
const queryClient = useQueryClient();
|
|
@@ -101,7 +101,7 @@ export const useProofAccept = () => {
|
|
|
101
101
|
interactionId,
|
|
102
102
|
credentials,
|
|
103
103
|
}: {
|
|
104
|
-
credentials: Record<string,
|
|
104
|
+
credentials: Record<string, PresentationSubmitCredentialRequest[]>;
|
|
105
105
|
interactionId: string;
|
|
106
106
|
}) => core.holderSubmitProof(interactionId, credentials),
|
|
107
107
|
{
|
|
@@ -163,8 +163,7 @@ export const useProposeProof = () => {
|
|
|
163
163
|
const { core, organisationId } = useONECore();
|
|
164
164
|
|
|
165
165
|
return useMutation(
|
|
166
|
-
async (request: Omit<
|
|
167
|
-
core.proposeProof({ organisationId, ...request }),
|
|
166
|
+
async (request: Omit<ProposeProofRequest, 'organisationId'>) => core.proposeProof({ organisationId, ...request }),
|
|
168
167
|
{
|
|
169
168
|
onSuccess: async () => {
|
|
170
169
|
await queryClient.invalidateQueries(PROOF_LIST_QUERY_KEY);
|
|
@@ -198,7 +197,7 @@ export const useProofDelete = () => {
|
|
|
198
197
|
);
|
|
199
198
|
};
|
|
200
199
|
|
|
201
|
-
export const useProofs = (queryParams?: Partial<
|
|
200
|
+
export const useProofs = (queryParams?: Partial<ProofListQuery>) => {
|
|
202
201
|
const { core, organisationId } = useONECore();
|
|
203
202
|
|
|
204
203
|
const queryKey = [PROOF_LIST_QUERY_KEY, ...getQueryKeyFromProofListQueryParams(queryParams)];
|
|
@@ -206,7 +205,7 @@ export const useProofs = (queryParams?: Partial<ProofListQueryBindingDto>) => {
|
|
|
206
205
|
return useQuery(
|
|
207
206
|
queryKey,
|
|
208
207
|
({ pageParam = 0 }) =>
|
|
209
|
-
core.
|
|
208
|
+
core.listProofs({
|
|
210
209
|
organisationId,
|
|
211
210
|
page: pageParam,
|
|
212
211
|
pageSize: PAGE_SIZE,
|
|
@@ -223,7 +222,7 @@ export const useProofCreate = () => {
|
|
|
223
222
|
|
|
224
223
|
const { core } = useONECore();
|
|
225
224
|
|
|
226
|
-
return useMutation(async (data:
|
|
225
|
+
return useMutation(async (data: CreateProofRequest) => core.createProof(data), {
|
|
227
226
|
onSuccess: async () => {
|
|
228
227
|
await queryClient.invalidateQueries(PROOF_LIST_QUERY_KEY);
|
|
229
228
|
await queryClient.invalidateQueries(HISTORY_LIST_QUERY_KEY);
|
|
@@ -232,9 +231,9 @@ export const useProofCreate = () => {
|
|
|
232
231
|
};
|
|
233
232
|
|
|
234
233
|
const getIdentifierFilterForProofSchema = (
|
|
235
|
-
proofSchema:
|
|
236
|
-
config:
|
|
237
|
-
): Partial<
|
|
234
|
+
proofSchema: ProofSchemaDetail,
|
|
235
|
+
config: CoreConfig,
|
|
236
|
+
): Partial<IdentifierListQuery> => {
|
|
238
237
|
const requestedFormats = proofSchema.proofInputSchemas.map((schema) => schema.credentialSchema.format);
|
|
239
238
|
const requestedFormatsCapabilities = requestedFormats
|
|
240
239
|
.map((format) => config.format[format]?.capabilities)
|
|
@@ -310,7 +309,7 @@ export const useProofForSchemaIdWithTransport = (
|
|
|
310
309
|
return;
|
|
311
310
|
}
|
|
312
311
|
|
|
313
|
-
if (proofState?.state !==
|
|
312
|
+
if (proofState?.state !== ProofState.CREATED && proofState?.state !== ProofState.PENDING) {
|
|
314
313
|
setProofId(undefined);
|
|
315
314
|
} else {
|
|
316
315
|
setDeleting(true);
|
|
@@ -357,7 +356,7 @@ export const useCleanupUnusedProofs = () => {
|
|
|
357
356
|
const { data: proofs } = useProofs({
|
|
358
357
|
page: 0,
|
|
359
358
|
pageSize: 100,
|
|
360
|
-
proofStates: [
|
|
359
|
+
proofStates: [ProofState.CREATED, ProofState.PENDING],
|
|
361
360
|
});
|
|
362
361
|
const [cleaned, setCleaned] = useState(false);
|
|
363
362
|
|
|
@@ -382,7 +381,7 @@ export const useShareProof = (proofUrlProps: ProofUrlHookParams | undefined, ena
|
|
|
382
381
|
|
|
383
382
|
// reset when proofId changes or the proof was retracted
|
|
384
383
|
useEffect(() => {
|
|
385
|
-
if (!proofUrlProps?.proofId || proofState?.state ===
|
|
384
|
+
if (!proofUrlProps?.proofId || proofState?.state === ProofState.CREATED) {
|
|
386
385
|
setSharedProof(undefined);
|
|
387
386
|
}
|
|
388
387
|
}, [proofUrlProps?.proofId, proofState]);
|
|
@@ -418,7 +417,7 @@ export const useRetainProofCheck = (proofId?: string) => {
|
|
|
418
417
|
|
|
419
418
|
const { core } = useONECore();
|
|
420
419
|
|
|
421
|
-
return useMutation(async () => core.runTask('RETAIN_PROOF_CHECK'), {
|
|
420
|
+
return useMutation(async () => core.runTask('RETAIN_PROOF_CHECK', undefined), {
|
|
422
421
|
onSuccess: async () => {
|
|
423
422
|
if (proofId) {
|
|
424
423
|
await queryClient.removeQueries([PROOF_DETAIL_QUERY_KEY, proofId]);
|
|
@@ -449,12 +448,12 @@ export const useDeleteAllProofsData = (schemaId: string) => {
|
|
|
449
448
|
return useMutation(
|
|
450
449
|
async () =>
|
|
451
450
|
core
|
|
452
|
-
.
|
|
451
|
+
.listProofs({
|
|
453
452
|
organisationId,
|
|
454
453
|
page: 0,
|
|
455
454
|
pageSize: 1000,
|
|
456
455
|
proofSchemaIds: [schemaId],
|
|
457
|
-
proofStates: [
|
|
456
|
+
proofStates: [ProofState.ACCEPTED],
|
|
458
457
|
})
|
|
459
458
|
.then((result) => Promise.all(result.values.reverse().map((proof) => core.deleteProofClaims(proof.id)))),
|
|
460
459
|
{
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
IdentifierTypeBindingEnum,
|
|
2
|
+
CreateRemoteTrustEntityRequest,
|
|
3
|
+
IdentifierType,
|
|
5
4
|
ONECore,
|
|
6
5
|
OneError,
|
|
7
|
-
|
|
6
|
+
TrustAnchorDetail,
|
|
7
|
+
UpdateRemoteTrustEntityRequest,
|
|
8
8
|
} from '@procivis/react-native-one-core';
|
|
9
9
|
import { useCallback } from 'react';
|
|
10
10
|
import { useMutation, useQuery, useQueryClient } from 'react-query';
|
|
@@ -31,7 +31,7 @@ export const useCreateTrustAnchor = () => {
|
|
|
31
31
|
if (trustAnchors.values.length > 0) {
|
|
32
32
|
return;
|
|
33
33
|
}
|
|
34
|
-
const response = await httpClient.get<
|
|
34
|
+
const response = await httpClient.get<TrustAnchorDetail>(publisherReference);
|
|
35
35
|
if (!response.ok || !response.data) {
|
|
36
36
|
return;
|
|
37
37
|
}
|
|
@@ -66,7 +66,7 @@ export const useTrustEntity = (identifierId: string | undefined) => {
|
|
|
66
66
|
identifiers: [
|
|
67
67
|
{
|
|
68
68
|
certificateId:
|
|
69
|
-
identifierDetail?.type ===
|
|
69
|
+
identifierDetail?.type === IdentifierType.CERTIFICATE
|
|
70
70
|
? identifierDetail.certificates?.[0]?.id
|
|
71
71
|
: undefined,
|
|
72
72
|
id: identifierId,
|
|
@@ -110,9 +110,7 @@ export const useCreateRemoteTrustEntity = () => {
|
|
|
110
110
|
const { core } = useONECore();
|
|
111
111
|
|
|
112
112
|
return useMutation(
|
|
113
|
-
async (
|
|
114
|
-
request: Omit<CreateRemoteTrustEntityRequestBindingDto, 'didId'> & { identifierId?: string; didId?: string },
|
|
115
|
-
) => {
|
|
113
|
+
async (request: Omit<CreateRemoteTrustEntityRequest, 'didId'> & { identifierId?: string; didId?: string }) => {
|
|
116
114
|
const { identifierId, didId } = request;
|
|
117
115
|
|
|
118
116
|
let entityDidId = didId;
|
|
@@ -142,7 +140,7 @@ export const useUpdateRemoteTrustEntity = () => {
|
|
|
142
140
|
|
|
143
141
|
return useMutation(
|
|
144
142
|
async (
|
|
145
|
-
request: Omit<
|
|
143
|
+
request: Omit<UpdateRemoteTrustEntityRequest, 'didId'> & {
|
|
146
144
|
identifierId?: string;
|
|
147
145
|
didId?: string;
|
|
148
146
|
},
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { useMutation } from 'react-query';
|
|
2
|
+
|
|
3
|
+
import { reportException } from '../../reporting';
|
|
4
|
+
import { useONECore } from './core-context';
|
|
5
|
+
import { HolderWalletUnit } from '@procivis/react-native-one-core';
|
|
6
|
+
|
|
7
|
+
export const useTrustCollectionSync = () => {
|
|
8
|
+
const { core } = useONECore();
|
|
9
|
+
|
|
10
|
+
return useMutation(
|
|
11
|
+
async (params: { holderWalletUnitId?: HolderWalletUnit['id']; verifierInstanceId?: string }) =>
|
|
12
|
+
core.runTask('TRUST_COLLECTION_SYNC', JSON.stringify(params)),
|
|
13
|
+
{
|
|
14
|
+
onError: (err) => {
|
|
15
|
+
reportException(err, 'TRUST_COLLECTION_SYNC error');
|
|
16
|
+
},
|
|
17
|
+
},
|
|
18
|
+
);
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
export const useTrustListSubscriptionUpdate = () => {
|
|
22
|
+
const { core } = useONECore();
|
|
23
|
+
|
|
24
|
+
return useMutation(async () => core.runTask('TRUST_LIST_SUBSCRIPTION_UPDATE', undefined), {
|
|
25
|
+
onError: (err) => {
|
|
26
|
+
reportException(err, 'TRUST_LIST_SUBSCRIPTION_UPDATE error');
|
|
27
|
+
},
|
|
28
|
+
});
|
|
29
|
+
};
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
2
|
+
HolderWalletUnit,
|
|
3
|
+
HolderWalletUnitUpdateRequest,
|
|
4
|
+
WalletProvider,
|
|
5
|
+
WalletUnitStatus,
|
|
5
6
|
} from '@procivis/react-native-one-core';
|
|
6
7
|
import { useEffect } from 'react';
|
|
7
8
|
import { useMutation, useQuery, useQueryClient } from 'react-query';
|
|
@@ -10,11 +11,9 @@ import { reportException } from '../../reporting';
|
|
|
10
11
|
import { useONECore } from './core-context';
|
|
11
12
|
|
|
12
13
|
export const WALLET_UNIT_QUERY_KEY = 'wallet-unit';
|
|
14
|
+
export const WALLET_UNIT_TRUST_COLLECTIONS_QUERY_KEY = 'wallet-unit-trust-collections';
|
|
13
15
|
|
|
14
|
-
export const useWalletUnitDetail = (
|
|
15
|
-
walletUnitId: HolderWalletUnitResponseBindingDto['id'] | undefined,
|
|
16
|
-
active = true,
|
|
17
|
-
) => {
|
|
16
|
+
export const useWalletUnitDetail = (walletUnitId: HolderWalletUnit['id'] | undefined, active = true) => {
|
|
18
17
|
const { core } = useONECore();
|
|
19
18
|
|
|
20
19
|
return useQuery(
|
|
@@ -27,12 +26,25 @@ export const useWalletUnitDetail = (
|
|
|
27
26
|
);
|
|
28
27
|
};
|
|
29
28
|
|
|
29
|
+
export const useWalletUnitTrustCollections = (walletUnitId: HolderWalletUnit['id'] | undefined, active = true) => {
|
|
30
|
+
const { core } = useONECore();
|
|
31
|
+
|
|
32
|
+
return useQuery(
|
|
33
|
+
[WALLET_UNIT_TRUST_COLLECTIONS_QUERY_KEY, walletUnitId],
|
|
34
|
+
() => (walletUnitId ? core.holderGetWalletUnitTrustCollections(walletUnitId) : undefined),
|
|
35
|
+
{
|
|
36
|
+
enabled: active && Boolean(walletUnitId),
|
|
37
|
+
keepPreviousData: true,
|
|
38
|
+
},
|
|
39
|
+
);
|
|
40
|
+
};
|
|
41
|
+
|
|
30
42
|
export const useRegisterWalletUnit = () => {
|
|
31
43
|
const queryClient = useQueryClient();
|
|
32
44
|
const { core, organisationId } = useONECore();
|
|
33
45
|
|
|
34
46
|
return useMutation(
|
|
35
|
-
async (walletProvider:
|
|
47
|
+
async (walletProvider: WalletProvider) =>
|
|
36
48
|
core.holderRegisterWalletUnit({
|
|
37
49
|
keyType: 'ECDSA',
|
|
38
50
|
organisationId,
|
|
@@ -49,11 +61,25 @@ export const useWalletUnitStatus = () => {
|
|
|
49
61
|
const queryClient = useQueryClient();
|
|
50
62
|
const { core } = useONECore();
|
|
51
63
|
|
|
64
|
+
return useMutation(async (walletUnitId: HolderWalletUnit['id']) => core.holderWalletUnitStatus(walletUnitId), {
|
|
65
|
+
onError: async (err) => {
|
|
66
|
+
reportException(err, 'Refresh wallet unit failure');
|
|
67
|
+
await queryClient.invalidateQueries(WALLET_UNIT_QUERY_KEY);
|
|
68
|
+
},
|
|
69
|
+
onSuccess: () => queryClient.invalidateQueries(WALLET_UNIT_QUERY_KEY),
|
|
70
|
+
});
|
|
71
|
+
};
|
|
72
|
+
|
|
73
|
+
export const useWalletUnitUpdate = () => {
|
|
74
|
+
const queryClient = useQueryClient();
|
|
75
|
+
const { core } = useONECore();
|
|
76
|
+
|
|
52
77
|
return useMutation(
|
|
53
|
-
async (walletUnitId:
|
|
78
|
+
async ({ walletUnitId, update }: { walletUnitId: HolderWalletUnit['id']; update: HolderWalletUnitUpdateRequest }) =>
|
|
79
|
+
core.holderWalletUnitUpdate(walletUnitId, update),
|
|
54
80
|
{
|
|
55
81
|
onError: async (err) => {
|
|
56
|
-
reportException(err, '
|
|
82
|
+
reportException(err, 'Update wallet unit failure');
|
|
57
83
|
await queryClient.invalidateQueries(WALLET_UNIT_QUERY_KEY);
|
|
58
84
|
},
|
|
59
85
|
onSuccess: () => queryClient.invalidateQueries(WALLET_UNIT_QUERY_KEY),
|
|
@@ -61,7 +87,7 @@ export const useWalletUnitStatus = () => {
|
|
|
61
87
|
);
|
|
62
88
|
};
|
|
63
89
|
|
|
64
|
-
export const useWalletUnitCheck = (walletUnitId:
|
|
90
|
+
export const useWalletUnitCheck = (walletUnitId: HolderWalletUnit['id'] | undefined) => {
|
|
65
91
|
const { data: walletUnitDetail, isLoading } = useWalletUnitDetail(walletUnitId);
|
|
66
92
|
const { mutateAsync: refreshWalletUnit, isLoading: isRefreshing, status: refreshStatus } = useWalletUnitStatus();
|
|
67
93
|
|
|
@@ -69,7 +95,7 @@ export const useWalletUnitCheck = (walletUnitId: HolderWalletUnitResponseBinding
|
|
|
69
95
|
if (isLoading || refreshStatus !== 'idle') {
|
|
70
96
|
return;
|
|
71
97
|
}
|
|
72
|
-
if (walletUnitId && walletUnitDetail?.status ===
|
|
98
|
+
if (walletUnitId && walletUnitDetail?.status === WalletUnitStatus.ACTIVE) {
|
|
73
99
|
void refreshWalletUnit(walletUnitId);
|
|
74
100
|
}
|
|
75
101
|
}, [isLoading, refreshStatus, walletUnitDetail, refreshWalletUnit, walletUnitId]);
|