Skip to content

Commit d513f5b

Browse files
Merge upstream develop
2 parents 4fc0d5d + 3152bb2 commit d513f5b

19 files changed

Lines changed: 986 additions & 19 deletions

File tree

apps/polycentric/src/features/verifications/hooks/useClaimActions.ts

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,7 @@ export default function useClaimActions(claim: DecodedClaim) {
2929
console.warn('Failed to push claim deletion to servers:', e);
3030
}
3131

32-
invalidateQuery(client, [
33-
'claims-list',
34-
String(COLLECTION.VERIFICATIONS),
35-
claim.identity,
36-
]);
32+
invalidateQuery(client, ['claims-list', claim.identity]);
3733

3834
if (router.canGoBack()) router.back();
3935
};

apps/polycentric/src/features/verifications/hooks/useClaimsList.ts

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
import { useQuery } from '@/src/common/query/hooks/useQuery';
2-
import { COLLECTION, Query, v2 } from '@polycentric/react-native';
2+
import { Query, v2 } from '@polycentric/react-native';
33
import { useMemo } from 'react';
44
import { DecodedClaim, decodeClaimBundle } from './useClaimById';
55

66
/**
77
* List the verification claims created by an identity, newest first.
8+
* Backed by the dedicated `VerificationsService.ListClaims` RPC.
89
*/
910
export function useClaimsList(identity: string | undefined): {
1011
claims: DecodedClaim[];
@@ -14,11 +15,9 @@ export function useClaimsList(identity: string | undefined): {
1415
const enabled = !!identity;
1516

1617
const query = useQuery(
17-
['claims-list', String(COLLECTION.VERIFICATIONS), identity ?? ''],
18-
new Query.ListEvents({
19-
identity: identity ?? '',
20-
collection: COLLECTION.VERIFICATIONS,
21-
size: 100,
18+
['claims-list', identity ?? ''],
19+
new Query.ListClaims({
20+
claimedByIdentity: identity ?? '',
2221
}),
2322
undefined,
2423
enabled,
@@ -27,7 +26,7 @@ export function useClaimsList(identity: string | undefined): {
2726
const claims = useMemo<DecodedClaim[]>(() => {
2827
if (!enabled || !query.data || query.data.byteLength === 0) return [];
2928
try {
30-
const response = v2.ListEventsResponse.fromBinary(
29+
const response = v2.ListClaimsResponse.fromBinary(
3130
new Uint8Array(query.data),
3231
);
3332
return response.eventBundles

apps/polycentric/src/features/verifications/hooks/useCreateClaim.ts

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -80,11 +80,7 @@ export default function useCreateClaim() {
8080

8181
// Refresh the creator's claim list so the new claim shows up.
8282
if (identityKey) {
83-
invalidateQuery(client, [
84-
'claims-list',
85-
String(COLLECTION.VERIFICATIONS),
86-
identityKey,
87-
]);
83+
invalidateQuery(client, ['claims-list', identityKey]);
8884
}
8985

9086
const key = event.key;
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
// @generated by protobuf-ts 2.11.1
2+
// @generated from protobuf file "polycentric/v2/verifications_service.proto" (package "polycentric.v2", syntax proto3)
3+
// tslint:disable
4+
import type { RpcTransport } from "@protobuf-ts/runtime-rpc";
5+
import type { ServiceInfo } from "@protobuf-ts/runtime-rpc";
6+
import { VerificationsService } from "./verifications_service";
7+
import { stackIntercept } from "@protobuf-ts/runtime-rpc";
8+
import type { ListClaimsResponse } from "./verifications_service";
9+
import type { ListClaimsRequest } from "./verifications_service";
10+
import type { UnaryCall } from "@protobuf-ts/runtime-rpc";
11+
import type { RpcOptions } from "@protobuf-ts/runtime-rpc";
12+
/**
13+
* @generated from protobuf service polycentric.v2.VerificationsService
14+
*/
15+
export interface IVerificationsServiceClient {
16+
/**
17+
* List the verification claims created by an identity.
18+
*
19+
* @generated from protobuf rpc: ListClaims
20+
*/
21+
listClaims(input: ListClaimsRequest, options?: RpcOptions): UnaryCall<ListClaimsRequest, ListClaimsResponse>;
22+
}
23+
/**
24+
* @generated from protobuf service polycentric.v2.VerificationsService
25+
*/
26+
export class VerificationsServiceClient implements IVerificationsServiceClient, ServiceInfo {
27+
typeName = VerificationsService.typeName;
28+
methods = VerificationsService.methods;
29+
options = VerificationsService.options;
30+
constructor(private readonly _transport: RpcTransport) {
31+
}
32+
/**
33+
* List the verification claims created by an identity.
34+
*
35+
* @generated from protobuf rpc: ListClaims
36+
*/
37+
listClaims(input: ListClaimsRequest, options?: RpcOptions): UnaryCall<ListClaimsRequest, ListClaimsResponse> {
38+
const method = this.methods[0], opt = this._transport.mergeOptions(options);
39+
return stackIntercept<ListClaimsRequest, ListClaimsResponse>("unary", this._transport, method, opt, input);
40+
}
41+
}
Lines changed: 142 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,142 @@
1+
// @generated by protobuf-ts 2.11.1
2+
// @generated from protobuf file "polycentric/v2/verifications_service.proto" (package "polycentric.v2", syntax proto3)
3+
// tslint:disable
4+
import { ServiceType } from "@protobuf-ts/runtime-rpc";
5+
import type { BinaryWriteOptions } from "@protobuf-ts/runtime";
6+
import type { IBinaryWriter } from "@protobuf-ts/runtime";
7+
import { WireType } from "@protobuf-ts/runtime";
8+
import type { BinaryReadOptions } from "@protobuf-ts/runtime";
9+
import type { IBinaryReader } from "@protobuf-ts/runtime";
10+
import { UnknownFieldHandler } from "@protobuf-ts/runtime";
11+
import type { PartialMessage } from "@protobuf-ts/runtime";
12+
import { reflectionMergePartial } from "@protobuf-ts/runtime";
13+
import { MessageType } from "@protobuf-ts/runtime";
14+
import { EventBundle } from "./events";
15+
// RPC surface for verification claims. Kept separate from
16+
// verifications.proto because the response references EventBundle
17+
// (events.proto), and events.proto -> content.proto -> verifications.proto
18+
// already form a chain; importing events.proto from verifications.proto
19+
// would create a cyclic import.
20+
21+
/**
22+
* @generated from protobuf message polycentric.v2.ListClaimsRequest
23+
*/
24+
export interface ListClaimsRequest {
25+
/**
26+
* Identity whose verification claims to list.
27+
*
28+
* @generated from protobuf field: string claimed_by_identity = 1
29+
*/
30+
claimedByIdentity: string;
31+
}
32+
/**
33+
* @generated from protobuf message polycentric.v2.ListClaimsResponse
34+
*/
35+
export interface ListClaimsResponse {
36+
/**
37+
* Claim events created by the identity, newest first.
38+
*
39+
* @generated from protobuf field: repeated polycentric.v2.EventBundle event_bundles = 1
40+
*/
41+
eventBundles: EventBundle[];
42+
}
43+
// @generated message type with reflection information, may provide speed optimized methods
44+
class ListClaimsRequest$Type extends MessageType<ListClaimsRequest> {
45+
constructor() {
46+
super("polycentric.v2.ListClaimsRequest", [
47+
{ no: 1, name: "claimed_by_identity", kind: "scalar", T: 9 /*ScalarType.STRING*/ }
48+
]);
49+
}
50+
create(value?: PartialMessage<ListClaimsRequest>): ListClaimsRequest {
51+
const message = globalThis.Object.create((this.messagePrototype!));
52+
message.claimedByIdentity = "";
53+
if (value !== undefined)
54+
reflectionMergePartial<ListClaimsRequest>(this, message, value);
55+
return message;
56+
}
57+
internalBinaryRead(reader: IBinaryReader, length: number, options: BinaryReadOptions, target?: ListClaimsRequest): ListClaimsRequest {
58+
let message = target ?? this.create(), end = reader.pos + length;
59+
while (reader.pos < end) {
60+
let [fieldNo, wireType] = reader.tag();
61+
switch (fieldNo) {
62+
case /* string claimed_by_identity */ 1:
63+
message.claimedByIdentity = reader.string();
64+
break;
65+
default:
66+
let u = options.readUnknownField;
67+
if (u === "throw")
68+
throw new globalThis.Error(`Unknown field ${fieldNo} (wire type ${wireType}) for ${this.typeName}`);
69+
let d = reader.skip(wireType);
70+
if (u !== false)
71+
(u === true ? UnknownFieldHandler.onRead : u)(this.typeName, message, fieldNo, wireType, d);
72+
}
73+
}
74+
return message;
75+
}
76+
internalBinaryWrite(message: ListClaimsRequest, writer: IBinaryWriter, options: BinaryWriteOptions): IBinaryWriter {
77+
/* string claimed_by_identity = 1; */
78+
if (message.claimedByIdentity !== "")
79+
writer.tag(1, WireType.LengthDelimited).string(message.claimedByIdentity);
80+
let u = options.writeUnknownFields;
81+
if (u !== false)
82+
(u == true ? UnknownFieldHandler.onWrite : u)(this.typeName, message, writer);
83+
return writer;
84+
}
85+
}
86+
/**
87+
* @generated MessageType for protobuf message polycentric.v2.ListClaimsRequest
88+
*/
89+
export const ListClaimsRequest = new ListClaimsRequest$Type();
90+
// @generated message type with reflection information, may provide speed optimized methods
91+
class ListClaimsResponse$Type extends MessageType<ListClaimsResponse> {
92+
constructor() {
93+
super("polycentric.v2.ListClaimsResponse", [
94+
{ no: 1, name: "event_bundles", kind: "message", repeat: 2 /*RepeatType.UNPACKED*/, T: () => EventBundle }
95+
]);
96+
}
97+
create(value?: PartialMessage<ListClaimsResponse>): ListClaimsResponse {
98+
const message = globalThis.Object.create((this.messagePrototype!));
99+
message.eventBundles = [];
100+
if (value !== undefined)
101+
reflectionMergePartial<ListClaimsResponse>(this, message, value);
102+
return message;
103+
}
104+
internalBinaryRead(reader: IBinaryReader, length: number, options: BinaryReadOptions, target?: ListClaimsResponse): ListClaimsResponse {
105+
let message = target ?? this.create(), end = reader.pos + length;
106+
while (reader.pos < end) {
107+
let [fieldNo, wireType] = reader.tag();
108+
switch (fieldNo) {
109+
case /* repeated polycentric.v2.EventBundle event_bundles */ 1:
110+
message.eventBundles.push(EventBundle.internalBinaryRead(reader, reader.uint32(), options));
111+
break;
112+
default:
113+
let u = options.readUnknownField;
114+
if (u === "throw")
115+
throw new globalThis.Error(`Unknown field ${fieldNo} (wire type ${wireType}) for ${this.typeName}`);
116+
let d = reader.skip(wireType);
117+
if (u !== false)
118+
(u === true ? UnknownFieldHandler.onRead : u)(this.typeName, message, fieldNo, wireType, d);
119+
}
120+
}
121+
return message;
122+
}
123+
internalBinaryWrite(message: ListClaimsResponse, writer: IBinaryWriter, options: BinaryWriteOptions): IBinaryWriter {
124+
/* repeated polycentric.v2.EventBundle event_bundles = 1; */
125+
for (let i = 0; i < message.eventBundles.length; i++)
126+
EventBundle.internalBinaryWrite(message.eventBundles[i], writer.tag(1, WireType.LengthDelimited).fork(), options).join();
127+
let u = options.writeUnknownFields;
128+
if (u !== false)
129+
(u == true ? UnknownFieldHandler.onWrite : u)(this.typeName, message, writer);
130+
return writer;
131+
}
132+
}
133+
/**
134+
* @generated MessageType for protobuf message polycentric.v2.ListClaimsResponse
135+
*/
136+
export const ListClaimsResponse = new ListClaimsResponse$Type();
137+
/**
138+
* @generated ServiceType for protobuf service polycentric.v2.VerificationsService
139+
*/
140+
export const VerificationsService = new ServiceType("polycentric.v2.VerificationsService", [
141+
{ name: "ListClaims", options: {}, I: ListClaimsRequest, O: ListClaimsResponse }
142+
]);

packages/js-core/src/proto/v2.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,3 +18,5 @@ export * from './polycentric/v2/pairing_service.client';
1818
export * from './polycentric/v2/server';
1919
export * from './polycentric/v2/server.client';
2020
export * from './polycentric/v2/verifications';
21+
export * from './polycentric/v2/verifications_service';
22+
export * from './polycentric/v2/verifications_service.client';

0 commit comments

Comments
 (0)