Skip to content

Commit 9b29cd7

Browse files
authored
Merge branch 'feat/w3ds-adapters' into fix/post-context-menu
2 parents 919d044 + 32d4e30 commit 9b29cd7

File tree

19 files changed

+250
-176
lines changed

19 files changed

+250
-176
lines changed

infrastructure/evault-provisioner/src/index.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,6 @@ app.post(
100100
const JWKS = jose.createLocalJWKSet(jwksResponse.data);
101101
const { payload } = await jose.jwtVerify(registryEntropy, JWKS);
102102

103-
const evaultId = await new W3IDBuilder().withGlobal(true).build();
104103
const userId = await new W3IDBuilder()
105104
.withNamespace(namespace)
106105
.withEntropy(payload.entropy as string)
@@ -121,7 +120,11 @@ app.post(
121120
"This verification ID has already been used",
122121
);
123122
}
124-
const uri = await provisionEVault(w3id, evaultId.id);
123+
const evaultId = await new W3IDBuilder().withGlobal(true).build();
124+
const uri = await provisionEVault(
125+
w3id,
126+
process.env.PUBLIC_REGISTRY_URL,
127+
);
125128
await axios.post(
126129
new URL(
127130
"/register",

infrastructure/evault-provisioner/src/templates/evault.nomad.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ export function generatePassword(length = 16): string {
3636
*
3737
* @throws {Error} If the service endpoint cannot be determined from the cluster.
3838
*/
39-
export async function provisionEVault(w3id: string, eVaultId: string) {
39+
export async function provisionEVault(w3id: string, registryUrl: string) {
4040
console.log("starting to provision");
4141
const idParts = w3id.split("@");
4242
w3id = idParts[idParts.length - 1];
@@ -107,6 +107,10 @@ export async function provisionEVault(w3id: string, eVaultId: string) {
107107
name: "dbms.connector.bolt.listen_address",
108108
value: "0.0.0.0:7687",
109109
},
110+
{
111+
name: "REGISTRY_URL",
112+
value: registryUrl,
113+
},
110114
],
111115
volumeMounts: [
112116
{ name: "neo4j-data", mountPath: "/data" },

infrastructure/web3-adapter/src/evault/evault.ts

Lines changed: 41 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -122,22 +122,23 @@ export class EVaultClient {
122122
}
123123

124124
async storeMetaEnvelope(envelope: MetaEnvelope): Promise<string> {
125-
const client = await this.ensureClient(envelope.w3id).catch(() => {
126-
return null;
127-
});
128-
if (!client) return v4();
129-
130-
const response = await client
131-
.request<StoreMetaEnvelopeResponse>(STORE_META_ENVELOPE, {
132-
input: {
133-
ontology: envelope.schemaId,
134-
payload: envelope.data,
135-
acl: ["*"],
136-
},
137-
})
138-
.catch(() => null);
139-
if (!response) return v4();
140-
return response.storeMetaEnvelope.metaEnvelope.id;
125+
// const client = await this.ensureClient(envelope.w3id).catch(() => {
126+
// return null;
127+
// });
128+
// if (!client) return v4();
129+
//
130+
// const response = await client
131+
// .request<StoreMetaEnvelopeResponse>(STORE_META_ENVELOPE, {
132+
// input: {
133+
// ontology: envelope.schemaId,
134+
// payload: envelope.data,
135+
// acl: ["*"],
136+
// },
137+
// })
138+
// .catch(() => null);
139+
// if (!response) return v4();
140+
// return response.storeMetaEnvelope.metaEnvelope.id;
141+
return v4();
141142
}
142143

143144
async storeReference(referenceId: string, w3id: string): Promise<void> {
@@ -178,28 +179,29 @@ export class EVaultClient {
178179
async updateMetaEnvelopeById(
179180
id: string,
180181
envelope: MetaEnvelope,
181-
): Promise<StoreMetaEnvelopeResponse["storeMetaEnvelope"]> {
182-
const client = await this.ensureClient(envelope.w3id).catch(() => null);
183-
if (!client) throw new Error();
184-
185-
try {
186-
const variables = {
187-
id,
188-
input: {
189-
ontology: envelope.schemaId,
190-
payload: envelope.data,
191-
acl: ["*"],
192-
},
193-
};
194-
195-
const response = await client.request<StoreMetaEnvelopeResponse>(
196-
UPDATE_META_ENVELOPE,
197-
variables,
198-
);
199-
return response.updateMetaEnvelopeById;
200-
} catch (error) {
201-
console.error("Error updating meta envelope:", error);
202-
throw error;
203-
}
182+
): Promise<void> {
183+
// const client = await this.ensureClient(envelope.w3id).catch(() => null);
184+
// if (!client) throw new Error();
185+
//
186+
// try {
187+
// const variables = {
188+
// id,
189+
// input: {
190+
// ontology: envelope.schemaId,
191+
// payload: envelope.data,
192+
// acl: ["*"],
193+
// },
194+
// };
195+
//
196+
// const response = await client.request<StoreMetaEnvelopeResponse>(
197+
// UPDATE_META_ENVELOPE,
198+
// variables,
199+
// );
200+
// return response.updateMetaEnvelopeById;
201+
// } catch (error) {
202+
// console.error("Error updating meta envelope:", error);
203+
// throw error;
204+
// }
205+
return;
204206
}
205207
}

infrastructure/web3-adapter/src/index.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ export class Web3Adapter {
4646
console.log("Added", this.lockedIds);
4747
setTimeout(() => {
4848
this.lockedIds = this.lockedIds.filter((f) => f !== id);
49-
}, 60_000);
49+
}, 10_000);
5050
}
5151

5252
async handleChange(props: {
@@ -60,6 +60,7 @@ export class Web3Adapter {
6060
localId: data.id as string,
6161
tableName,
6262
});
63+
console.log("localId", data.id, "globalId", existingGlobalId);
6364

6465
// If we already have a mapping, use that global ID
6566
if (existingGlobalId) {

infrastructure/web3-adapter/src/mapper/mapper.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,8 @@ export async function fromGlobal({
5555
}: IMappingConversionOptions): Promise<Omit<IMapperResponse, "ownerEvault">> {
5656
const result: Record<string, unknown> = {};
5757

58+
console.log("data to change", data);
59+
5860
for (let [localKey, globalPathRaw] of Object.entries(
5961
mapping.localToUniversalMap,
6062
)) {
@@ -129,6 +131,8 @@ export async function fromGlobal({
129131
result[localKey] = value;
130132
}
131133

134+
console.log("data changed to global", result);
135+
132136
return {
133137
data: result,
134138
};
@@ -168,6 +172,8 @@ export async function toGlobal({
168172
}: IMappingConversionOptions): Promise<IMapperResponse> {
169173
const result: Record<string, unknown> = {};
170174

175+
console.log("data to change", data);
176+
171177
for (let [localKey, globalPathRaw] of Object.entries(
172178
mapping.localToUniversalMap,
173179
)) {
@@ -277,6 +283,8 @@ export async function toGlobal({
277283
}
278284
const ownerEvault = await extractOwnerEvault(data, mapping.ownerEnamePath);
279285

286+
console.log("changed data to local", result);
287+
280288
return {
281289
ownerEvault,
282290
data: result,

platforms/blabsy-w3ds-auth-api/src/controllers/WebhookController.ts

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,7 @@ export class WebhookController {
100100
});
101101

102102
if (localId) {
103+
console.log("");
103104
adapter.addToLockedIds(localId);
104105
await this.updateRecord(tableName, localId, local.data);
105106
} else {
@@ -148,17 +149,19 @@ export class WebhookController {
148149
const docRef = collection.doc(localId);
149150

150151
adapter.addToLockedIds(docRef.id);
151-
const mappedData = this.mapDataToFirebase(tableName, data);
152-
console.log(mappedData);
152+
const mappedData = await this.mapDataToFirebase(tableName, data);
153153
await docRef.update(mappedData);
154154
}
155155

156156
private mapDataToFirebase(tableName: string, data: any): any {
157157
const now = Timestamp.now();
158+
console.log("MAPPING DATA TO ", tableName);
158159

159160
switch (tableName) {
160161
case "users":
161-
return this.mapUserData(data, now);
162+
const result = this.mapUserData(data, now);
163+
console.log("mappppped", result);
164+
return result;
162165
case "tweets":
163166
return this.mapTweetData(data, now);
164167
case "chats":
@@ -172,13 +175,12 @@ export class WebhookController {
172175

173176
private mapUserData(data: any, now: Timestamp): Partial<User> {
174177
return {
175-
id: data.id,
176178
bio: data.bio || null,
177179
name: data.name,
178180
theme: data.theme || null,
179181
accent: data.accent || null,
180-
website: data.website || null,
181-
location: data.location || null,
182+
website: null,
183+
location: null,
182184
username: data.username,
183185
photoURL: data.photoURL,
184186
verified: data.verified || false,

platforms/blabsy-w3ds-auth-api/src/web3adapter/watchers/firestoreWatcher.ts

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -154,11 +154,14 @@ export class FirestoreWatcher {
154154

155155
const tableName = tableNameRaw.slice(0, tableNameRaw.length - 1);
156156

157-
const envelope = await this.adapter.handleChange({
158-
data: { ...data, id: doc.id },
159-
tableName,
160-
});
161-
157+
const envelope = await this.adapter
158+
.handleChange({
159+
data: { ...data, id: doc.id },
160+
tableName,
161+
})
162+
.catch(() => null);
163+
164+
console.log("sending envelope", envelope);
162165
if (envelope) {
163166
try {
164167
if (

platforms/blabsy/.env.development

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
# Dev URL
22
# NEXT_PUBLIC_URL=http://localhost
3-
# NEXT_PUBLIC_BASE_URL=http://192.168.0.226:4444
3+
NEXT_PUBLIC_BASE_URL=http://192.168.0.226:4444
44

55
NEXT_PUBLIC_URL=https://blabsy.w3ds-prototype.merul.org
6-
NEXT_PUBLIC_BASE_URL=https://blabsy.w3ds-prototype.merul.org
6+
# NEXT_PUBLIC_BASE_URL=https://blabsy.w3ds-prototype.merul.org
77

88
# Emulator
99
NEXT_PUBLIC_USE_EMULATOR=false

platforms/blabsy/src/components/user/user-avatar.tsx

Lines changed: 35 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -3,42 +3,44 @@ import cn from 'clsx';
33
import { NextImage } from '@components/ui/next-image';
44

55
type UserAvatarProps = {
6-
src: string;
7-
alt: string;
8-
size?: number;
9-
username?: string;
10-
className?: string;
6+
src: string;
7+
alt: string;
8+
size?: number;
9+
username?: string;
10+
className?: string;
1111
};
1212

1313
export function UserAvatar({
14-
src,
15-
alt,
16-
size,
17-
username,
18-
className
14+
src,
15+
alt,
16+
size,
17+
username,
18+
className
1919
}: UserAvatarProps): JSX.Element {
20-
const pictureSize = size ?? 48;
20+
const pictureSize = size ?? 48;
2121

22-
return (
23-
<Link href={username ? `/user/${username}` : '#'}>
24-
<a
25-
className={cn(
26-
'blur-picture flex self-start',
27-
!username && 'pointer-events-none',
28-
className
29-
)}
30-
tabIndex={username ? 0 : -1}
31-
>
32-
<NextImage
33-
useSkeleton
34-
imgClassName='rounded-full'
35-
width={pictureSize}
36-
height={pictureSize}
37-
src={src}
38-
alt={alt}
39-
key={src}
40-
/>
41-
</a>
42-
</Link>
43-
);
22+
console.log(typeof src);
23+
24+
return (
25+
<Link href={username ? `/user/${username}` : '#'}>
26+
<a
27+
className={cn(
28+
'blur-picture flex self-start',
29+
!username && 'pointer-events-none',
30+
className
31+
)}
32+
tabIndex={username ? 0 : -1}
33+
>
34+
<NextImage
35+
useSkeleton
36+
imgClassName='rounded-full'
37+
width={pictureSize}
38+
height={pictureSize}
39+
src={src}
40+
alt={alt}
41+
key={src}
42+
/>
43+
</a>
44+
</Link>
45+
);
4446
}

platforms/pictique-api/src/controllers/UserController.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -81,10 +81,12 @@ export class UserController {
8181
return res.status(401).json({ error: "Unauthorized" });
8282
}
8383

84+
const user = await this.userService.findById(userId);
85+
8486
const updatedUser = await this.userService.updateProfile(userId, {
85-
handle,
86-
avatarUrl: avatar,
87-
name
87+
handle: handle ?? user?.handle,
88+
avatarUrl: avatar ?? user?.avatarUrl,
89+
name: name ?? user?.name,
8890
});
8991

9092
res.json(updatedUser);

0 commit comments

Comments
 (0)