diff --git a/packages/snap/snap.manifest.json b/packages/snap/snap.manifest.json index 8561bdc7..d4f1dc17 100644 --- a/packages/snap/snap.manifest.json +++ b/packages/snap/snap.manifest.json @@ -7,7 +7,7 @@ "url": "https://github.com/rarimo/rarime.git" }, "source": { - "shasum": "ABVTZiQu17L4Wp76l5HtJdnF9Oy/QeqaFccW0pLykv0=", + "shasum": "e4iG7z7c2v9nCdOdQB7VLWbReoLvcyiQB7mF5DzAXcY=", "location": { "npm": { "filePath": "dist/bundle.js", @@ -29,6 +29,7 @@ "dapps": true, "snaps": true }, + "endowment:page-home": {}, "snap_manageState": {}, "endowment:network-access": {}, "endowment:webassembly": {}, diff --git a/packages/snap/src/index.ts b/packages/snap/src/index.ts index de90d9b3..2e91bd70 100644 --- a/packages/snap/src/index.ts +++ b/packages/snap/src/index.ts @@ -98,3 +98,5 @@ export const onRpcRequest = async ({ throw new Error('Method not found.'); } }; + +export { onHomePage } from '@/ui'; diff --git a/packages/snap/src/ui/homepage.ts b/packages/snap/src/ui/homepage.ts new file mode 100644 index 00000000..66548ee8 --- /dev/null +++ b/packages/snap/src/ui/homepage.ts @@ -0,0 +1,44 @@ +import type { OnHomePageHandler } from '@metamask/snaps-sdk'; +import { + row, + image, + copyable, + divider, + panel, + text, +} from '@metamask/snaps-sdk'; + +import { StorageKeys } from '@/enums'; +import { snapStorage } from '@/helpers'; +import { VCManager } from '@/zkp/helpers'; + +export const onHomePage: OnHomePageHandler = async () => { + const vcManager = await VCManager.create(); + const creds = await vcManager.getAllDecryptedVCs(); + + const identityStorage = await snapStorage.getItem(StorageKeys.identity); + + return { + content: panel([ + image( + '', + ), + text('RariMe lives right in your MetaMask.'), + text( + 'It’s where you securely store and manage your credentials, attestations, licenses, event tickets, and more — all in one place', + ), + + divider(), + + text('Your DID:'), + copyable({ + value: identityStorage.did || 'Not created yet', + }), + row('Total credentials', text(`${creds.length || 0}`)), + + text( + 'Manage your wallet & Credentials with [Rarime App](https://app.rarime.com)', + ), + ]), + }; +}; diff --git a/packages/snap/src/ui/index.ts b/packages/snap/src/ui/index.ts new file mode 100644 index 00000000..b9cc39d7 --- /dev/null +++ b/packages/snap/src/ui/index.ts @@ -0,0 +1 @@ +export * from './homepage';