Skip to content

Commit bfc0c61

Browse files
committed
chore: fixed the format of eidwallet
1 parent 24a0f53 commit bfc0c61

File tree

6 files changed

+509
-524
lines changed

6 files changed

+509
-524
lines changed

infrastructure/eid-wallet/src/lib/global/controllers/evault.ts

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -63,9 +63,11 @@ export class VaultController {
6363
/**
6464
* Set the profile creation status
6565
*/
66-
set profileCreationStatus(
67-
status: "idle" | "loading" | "success" | "failed"
68-
) {
66+
set profileCreationStatus(status:
67+
| "idle"
68+
| "loading"
69+
| "success"
70+
| "failed") {
6971
this.#profileCreationStatus = status;
7072
}
7173

@@ -87,14 +89,14 @@ export class VaultController {
8789
await this.createUserProfileInEVault(
8890
vault.ename,
8991
displayName,
90-
vault.ename
92+
vault.ename,
9193
);
9294

9395
this.profileCreationStatus = "success";
9496
} catch (error) {
9597
console.error(
9698
"Failed to create UserProfile in eVault (retry):",
97-
error
99+
error,
98100
);
99101
this.profileCreationStatus = "failed";
100102
throw error;
@@ -107,7 +109,7 @@ export class VaultController {
107109
private async resolveEndpoint(w3id: string): Promise<string> {
108110
try {
109111
const response = await axios.get(
110-
new URL(`resolve?w3id=${w3id}`, PUBLIC_REGISTRY_URL).toString()
112+
new URL(`resolve?w3id=${w3id}`, PUBLIC_REGISTRY_URL).toString(),
111113
);
112114
return new URL("/graphql", response.data.uri).toString();
113115
} catch (error) {
@@ -134,7 +136,7 @@ export class VaultController {
134136
ename: string,
135137
displayName: string,
136138
w3id: string,
137-
maxRetries = 10
139+
maxRetries = 10,
138140
): Promise<void> {
139141
console.log("attempting");
140142
const username = ename.replace("@", "");
@@ -159,7 +161,7 @@ export class VaultController {
159161
const client = await this.ensureClient(w3id);
160162

161163
console.log(
162-
`Attempting to create UserProfile in eVault (attempt ${attempt}/${maxRetries})`
164+
`Attempting to create UserProfile in eVault (attempt ${attempt}/${maxRetries})`,
163165
);
164166

165167
const response = await client.request<MetaEnvelopeResponse>(
@@ -170,23 +172,23 @@ export class VaultController {
170172
payload: userProfile,
171173
acl: ["*"],
172174
},
173-
}
175+
},
174176
);
175177

176178
console.log(
177179
"UserProfile created successfully in eVault:",
178-
response.storeMetaEnvelope.metaEnvelope.id
180+
response.storeMetaEnvelope.metaEnvelope.id,
179181
);
180182
return;
181183
} catch (error) {
182184
console.error(
183185
`Failed to create UserProfile in eVault (attempt ${attempt}/${maxRetries}):`,
184-
error
186+
error,
185187
);
186188

187189
if (attempt === maxRetries) {
188190
console.error(
189-
"Max retries reached, giving up on UserProfile creation"
191+
"Max retries reached, giving up on UserProfile creation",
190192
);
191193
throw error;
192194
}
@@ -199,12 +201,10 @@ export class VaultController {
199201
}
200202
}
201203

202-
set vault(
203-
vault:
204-
| Promise<Record<string, string> | undefined>
205-
| Record<string, string>
206-
| undefined
207-
) {
204+
set vault(vault:
205+
| Promise<Record<string, string> | undefined>
206+
| Record<string, string>
207+
| undefined) {
208208
if (vault instanceof Promise)
209209
vault
210210
.then(async (resolvedUser) => {
@@ -221,13 +221,13 @@ export class VaultController {
221221
await this.createUserProfileInEVault(
222222
resolvedUser?.ename as string,
223223
displayName as string,
224-
resolvedUser?.ename as string
224+
resolvedUser?.ename as string,
225225
);
226226
this.profileCreationStatus = "success";
227227
} catch (error) {
228228
console.error(
229229
"Failed to create UserProfile in eVault:",
230-
error
230+
error,
231231
);
232232
this.profileCreationStatus = "failed";
233233
}
@@ -252,26 +252,26 @@ export class VaultController {
252252
await this.createUserProfileInEVault(
253253
vault.ename,
254254
displayName,
255-
vault.ename
255+
vault.ename,
256256
);
257257
this.profileCreationStatus = "success";
258258
} catch (error) {
259259
console.error(
260260
"Failed to get user data or create UserProfile:",
261-
error
261+
error,
262262
);
263263
// Fallback to using ename as display name
264264
try {
265265
await this.createUserProfileInEVault(
266266
vault.ename,
267267
vault.ename,
268-
vault.ename
268+
vault.ename,
269269
);
270270
this.profileCreationStatus = "success";
271271
} catch (fallbackError) {
272272
console.error(
273273
"Failed to create UserProfile in eVault (fallback):",
274-
fallbackError
274+
fallbackError,
275275
);
276276
this.profileCreationStatus = "failed";
277277
}

infrastructure/eid-wallet/src/routes/(app)/main/+page.svelte

Lines changed: 66 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -1,78 +1,77 @@
11
<script lang="ts">
2-
import { goto } from "$app/navigation";
3-
import { Hero, IdentityCard } from "$lib/fragments";
4-
import type { GlobalState } from "$lib/global";
5-
import { Drawer } from "$lib/ui";
6-
import * as Button from "$lib/ui/Button";
7-
import { QrCodeIcon, Settings02Icon } from "@hugeicons/core-free-icons";
8-
import { HugeiconsIcon } from "@hugeicons/svelte";
9-
import { type Snippet, getContext, onMount } from "svelte";
10-
import { onDestroy } from "svelte";
11-
import { Shadow } from "svelte-loading-spinners";
12-
import QrCode from "svelte-qrcode";
13-
14-
let userData: Record<string, unknown> | undefined = $state(undefined);
15-
let greeting: string | undefined = $state(undefined);
16-
let ename: string | undefined = $state(undefined);
17-
let profileCreationStatus: "idle" | "loading" | "success" | "failed" =
18-
$state("idle");
19-
20-
let shareQRdrawerOpen = $state(false);
21-
let statusInterval: ReturnType<typeof setInterval> | undefined =
22-
$state(undefined);
23-
24-
function shareQR() {
25-
alert("QR Code shared!");
26-
shareQRdrawerOpen = false;
2+
import { goto } from "$app/navigation";
3+
import { Hero, IdentityCard } from "$lib/fragments";
4+
import type { GlobalState } from "$lib/global";
5+
import { Drawer } from "$lib/ui";
6+
import * as Button from "$lib/ui/Button";
7+
import { QrCodeIcon, Settings02Icon } from "@hugeicons/core-free-icons";
8+
import { HugeiconsIcon } from "@hugeicons/svelte";
9+
import { type Snippet, getContext, onMount } from "svelte";
10+
import { onDestroy } from "svelte";
11+
import { Shadow } from "svelte-loading-spinners";
12+
import QrCode from "svelte-qrcode";
13+
14+
let userData: Record<string, unknown> | undefined = $state(undefined);
15+
let greeting: string | undefined = $state(undefined);
16+
let ename: string | undefined = $state(undefined);
17+
let profileCreationStatus: "idle" | "loading" | "success" | "failed" =
18+
$state("idle");
19+
20+
let shareQRdrawerOpen = $state(false);
21+
let statusInterval: ReturnType<typeof setInterval> | undefined =
22+
$state(undefined);
23+
24+
function shareQR() {
25+
alert("QR Code shared!");
26+
shareQRdrawerOpen = false;
27+
}
28+
29+
async function retryProfileCreation() {
30+
try {
31+
await globalState.vaultController.retryProfileCreation();
32+
} catch (error) {
33+
console.error("Retry failed:", error);
2734
}
35+
}
2836
29-
async function retryProfileCreation() {
30-
try {
31-
await globalState.vaultController.retryProfileCreation();
32-
} catch (error) {
33-
console.error("Retry failed:", error);
34-
}
35-
}
37+
const globalState = getContext<() => GlobalState>("globalState")();
3638
37-
const globalState = getContext<() => GlobalState>("globalState")();
39+
onMount(() => {
40+
// Load initial data
41+
(async () => {
42+
const userInfo = await globalState.userController.user;
43+
const isFake = await globalState.userController.isFake;
44+
userData = { ...userInfo, isFake };
45+
const vaultData = await globalState.vaultController.vault;
46+
ename = vaultData?.ename;
47+
})();
3848
39-
onMount(() => {
40-
// Load initial data
41-
(async () => {
42-
const userInfo = await globalState.userController.user;
43-
const isFake = await globalState.userController.isFake;
44-
userData = { ...userInfo, isFake };
45-
const vaultData = await globalState.vaultController.vault;
46-
ename = vaultData?.ename;
47-
})();
49+
// Get initial profile creation status
50+
profileCreationStatus = globalState.vaultController.profileCreationStatus;
4851
49-
// Get initial profile creation status
52+
// Set up a watcher for profile creation status changes
53+
const checkStatus = () => {
5054
profileCreationStatus =
5155
globalState.vaultController.profileCreationStatus;
52-
53-
// Set up a watcher for profile creation status changes
54-
const checkStatus = () => {
55-
profileCreationStatus =
56-
globalState.vaultController.profileCreationStatus;
57-
};
58-
59-
// Check status periodically
60-
statusInterval = setInterval(checkStatus, 1000);
61-
62-
const currentHour = new Date().getHours();
63-
greeting =
64-
currentHour > 17
65-
? "Good Evening"
66-
: currentHour > 12
67-
? "Good Afternoon"
68-
: "Good Morning";
69-
});
70-
71-
onDestroy(() => {
72-
if (statusInterval) {
73-
clearInterval(statusInterval);
74-
}
75-
});
56+
};
57+
58+
// Check status periodically
59+
statusInterval = setInterval(checkStatus, 1000);
60+
61+
const currentHour = new Date().getHours();
62+
greeting =
63+
currentHour > 17
64+
? "Good Evening"
65+
: currentHour > 12
66+
? "Good Afternoon"
67+
: "Good Morning";
68+
});
69+
70+
onDestroy(() => {
71+
if (statusInterval) {
72+
clearInterval(statusInterval);
73+
}
74+
});
7675
</script>
7776

7877
{#if profileCreationStatus === "loading"}

0 commit comments

Comments
 (0)