Skip to content
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
40 changes: 20 additions & 20 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
},
"dependencies": {
"@inquirer/prompts": "^5.3.8",
"@trustvc/trustvc": "^2.5.0",
"@trustvc/trustvc": "^2.6.0",
"@types/yargs": "^17.0.32",
"chalk": "^4.1.2",
"ethers": "^6.16.0",
Expand Down
20 changes: 16 additions & 4 deletions src/commands/verify.ts
Original file line number Diff line number Diff line change
Expand Up @@ -146,21 +146,33 @@ export const getResultFromFragment = (
fragmentType: FragmentType,
resultFragments: VerificationFragment[],
): VerificationFragmentWithData => {
const fragment = resultFragments.find(
const candidates = resultFragments.filter(
(fragment: VerificationFragment) =>
fragment.type === fragmentType && fragment.status !== 'SKIPPED',
);
if (!fragment) {

if (candidates.length === 0) {
throw new Error(`${fragmentType} could not be verified.`);
}
return fragment as VerificationFragmentWithData;

const findByStatus = (status: string) =>
candidates.find((fragment: VerificationFragment) => fragment.status === status);

const preferred =
findByStatus('VALID') || findByStatus('INVALID') || findByStatus('ERROR') || candidates[0];

return preferred as VerificationFragmentWithData;
};

export const logResultStatus = (fragment: VerificationFragmentWithData): void => {
if (fragment.status === 'VALID') {
signale.success(`${fragment.type}: ${fragment.status}`);
} else if (fragment.status === 'ERROR') {
signale.error(`${fragment.type}: ${fragment.status} - An error has occurred.`);
} else {
signale.warn(`${fragment.type}: ${fragment.status} [${fragment.reason.message}]`);
const reasonMessage = (fragment as any)?.reason?.message;
const message = reasonMessage ? reasonMessage : 'Verification failed.';
signale.warn(`${fragment.type}: ${fragment.status} - ${message}`);
}
};

Expand Down
Loading