Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: remove credential v1 fallback #372

Merged
merged 5 commits into from
Dec 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion apps/idos-data-dashboard/src/main.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ ReactDOM.createRoot(document.getElementById("root") as HTMLElement).render(
<React.StrictMode>
<ChakraBaseProvider theme={theme}>
<WalletSelectorContextProvider>
{/* @ts-expect-error: TODO: fix wagmi types */}
{/* @ts-ignore: TODO: fix wagmi types */}
<WagmiProvider config={wagmiConfig}>
<QueryClientProvider client={queryClient}>
<IDOSProvider>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,29 +37,7 @@ const useFetchCredentials = () => {
.map((c) => c.id),
})) as idOSCredentialWithShares[]; // @todo: remove once we have more type safety in the SDK.
},
select: (credentials) =>
credentials
.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,
};

return {
...credential,
public_notes: JSON.stringify(public_notes),
};
}),
select: (credentials) => credentials.filter((credential) => !credential.original_id),
});
};

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
21 changes: 1 addition & 20 deletions examples/issuer-sdk-demo/src/app/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -58,26 +58,7 @@ export default function Home() {
// @ts-expect-error: types in the SDK are a bit messy.
await _instance.setSigner("EVM", signer);
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,
};
return {
...credential,
public_notes: JSON.stringify(public_notes),
};
}),
);
setCredentials(_credentials);
}

setHasProfile(_hasProfile);
Expand Down
Loading