Skip to content

Commit

Permalink
remove credentials V1 fallbacks
Browse files Browse the repository at this point in the history
  • Loading branch information
Mohammed-Mamoun98 committed Dec 3, 2024
1 parent 24c248f commit 2688995
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 40 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -42,17 +42,14 @@ const useFetchCredentials = () => {
.filter((credential) => !credential.original_id)

.map((credential) => {
const { credential_level, credential_status, credential_type, issuer } =
// biome-ignore lint/suspicious/noExplicitAny: // @todo: remove once we have successfully migrated to Credentials 2.0.
credential as any;
const fields = credential.public_notes ? JSON.parse(credential.public_notes) : {};

const public_notes = {
id: fields.id ?? credential.id,
level: fields.level ?? credential_level,
status: fields.status ?? credential_status,
type: fields.type ?? credential_type,
issuer: fields.issuer ?? issuer,
id: fields.id,
level: fields.level,
status: fields.status,
type: fields.type,
issuer: fields.issuer,
};

return {
Expand Down
25 changes: 1 addition & 24 deletions examples/idos-example-dapp/src/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -200,30 +200,7 @@ const connectWallet = {
let credentials = await terminal
.h1("eyes", "User's credentials")
.wait("awaiting signature", cache.get("credentials") || idos.data.list("credentials"));
credentials = credentials
.filter((c) => c.original_id === null)
// @todo: remove once we have successfully migrated to Credentials 2.0.
.map((credential) => {
const { credential_level, credential_status, credential_type, issuer } = credential;
const _fields = credential.public_notes
? typeof credential.public_notes === "string"
? JSON.parse(credential.public_notes)
: credential.public_notes
: {};
const { id, ...public_notes } = {
id: _fields.id ?? credential.id,
level: _fields.level ?? credential_level,
status: _fields.status ?? credential_status,
type: _fields.type ?? credential_type,
issuer: _fields.issuer ?? issuer,
};

return {
...credential,
...public_notes,
public_notes,
};
});
credentials = credentials.filter((c) => c.original_id === null);

cache.set("credentials", credentials);

Expand Down
13 changes: 5 additions & 8 deletions examples/issuer-sdk-demo/src/app/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -60,17 +60,14 @@ export default function Home() {
const _credentials = await _instance.data.list<idOSCredential>("credentials");
setCredentials(
_credentials.map((credential) => {
const { credential_level, credential_status, credential_type, issuer } =
// biome-ignore lint/suspicious/noExplicitAny: // @todo: remove once we have successfully migrated to Credentials 2.0.
credential as any;
const fields = credential.public_notes ? JSON.parse(credential.public_notes) : {};

const public_notes = {
id: fields.id ?? credential.id,
level: fields.level ?? credential_level,
status: fields.status ?? credential_status,
type: fields.type ?? credential_type,
issuer: fields.issuer ?? issuer,
id: fields.id,
level: fields.level,
status: fields.status,
type: fields.type,
issuer: fields.issuer,
};
return {
...credential,
Expand Down

0 comments on commit 2688995

Please sign in to comment.