diff --git a/.eslintrc.cjs b/.eslintrc.cjs index 359753745..7c71768a1 100644 --- a/.eslintrc.cjs +++ b/.eslintrc.cjs @@ -77,7 +77,6 @@ module.exports = { ignorePatterns: [ '**/node_modules/**', '**/dist/**', - '**/!.eslintrc.js', '**/!.eslintrc.cjs', '**/coverage/**', '**/build/**', diff --git a/.github/workflows/deploy_dapp.yml b/.github/workflows/deploy_dapp.yml deleted file mode 100644 index 3bc70e2de..000000000 --- a/.github/workflows/deploy_dapp.yml +++ /dev/null @@ -1,106 +0,0 @@ -name: Dapp deploy/build action - -on: - pull_request: - branches: [master, develop] - types: [opened, synchronize, reopened] - paths: - - 'packages/dapp/**' - - 'Dockerfile' - push: - branches: [master, develop] - paths: - - 'packages/dapp/**' - - 'Dockerfile' - -jobs: - test-build: - # Test build on every PR to DEVELOP - if: ${{ github.event_name == 'pull_request' }} - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v3 - with: - fetch-depth: 0 - - uses: nrwl/nx-set-shas@v3 - with: - main-branch-name: 'develop' - - name: Install pnpm - uses: pnpm/action-setup@v2 - with: - version: 7.30.0 - - uses: actions/setup-node@v3 - with: - node-version: 18.15.0 - cache: pnpm - - name: Install dependencies - run: pnpm install --frozen-lockfile - - name: Lint - run: pnpm nx run @blockchain-lab-um/dapp:lint - env: - NX_CLOUD_ACCESS_TOKEN: ${{ secrets.NX_CLOUD_ACCESS_TOKEN }} - - name: Test build dapp - run: pnpm nx run @blockchain-lab-um/dapp:build - env: - NX_CLOUD_ACCESS_TOKEN: ${{ secrets.NX_CLOUD_ACCESS_TOKEN }} - - test-deploy: - # Test deploy when we PUSH to DEVELOP - if: ${{ (github.ref == 'refs/heads/develop') && (github.event_name == 'push') }} - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v3 - with: - fetch-depth: 0 - - name: Create nx-cloud.env - run: echo "NX_CLOUD_ACCESS_TOKEN=$NX_CLOUD_ACCESS_TOKEN" > nx-cloud.env - env: - NX_CLOUD_ACCESS_TOKEN: ${{ secrets.NX_CLOUD_ACCESS_TOKEN }} - - name: Build blockchain-lab-um/ssi-snap - run: docker build . -t blockchain-lab-um/ssi-snap - - name: Build blockchain-lab-um/dapp - run: docker build ./packages/dapp -t blockchain-lab-um/dapp - - name: Change image tag - run: docker tag blockchain-lab-um/dapp:latest bclabum.informatika.uni-mb.si/registry/dapp:latest - - name: Login to Docker Hub - uses: docker/login-action@v2 - with: - registry: bclabum.informatika.uni-mb.si/registry - username: ${{ secrets.DOCKERHUB_USERNAME }} - password: ${{ secrets.DOCKERHUB_TOKEN }} - - name: Push to private docker registry - run: docker push bclabum.informatika.uni-mb.si/registry/dapp:latest - deploy: - # Deploy only when we PUSH to MASTER - if: ${{ (github.ref == 'refs/heads/master') && (github.event_name == 'push') }} - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v3 - with: - fetch-depth: 0 - - uses: nrwl/nx-set-shas@v3 - with: - main-branch-name: 'develop' - - name: Install pnpm - uses: pnpm/action-setup@v2 - with: - version: 7.30.0 - - uses: actions/setup-node@v3 - with: - node-version: 18.15.0 - cache: pnpm - - name: Install dependencies - run: pnpm install --frozen-lockfile - - name: Lint - run: pnpm nx run @blockchain-lab-um/dapp:lint - env: - NX_CLOUD_ACCESS_TOKEN: ${{ secrets.NX_CLOUD_ACCESS_TOKEN }} - - name: Test build dapp - run: pnpm nx run @blockchain-lab-um/dapp:build - env: - NX_CLOUD_ACCESS_TOKEN: ${{ secrets.NX_CLOUD_ACCESS_TOKEN }} - - name: Deploy to GitHub Pages - uses: peaceiris/actions-gh-pages@v3 - with: - github_token: ${{ secrets.GITHUB_TOKEN }} - publish_dir: ./packages/dapp/.next diff --git a/.github/workflows/deploy_docs.yml b/.github/workflows/deploy_docs.yml deleted file mode 100644 index b3e363ec0..000000000 --- a/.github/workflows/deploy_docs.yml +++ /dev/null @@ -1,98 +0,0 @@ -name: Docs deploy/build action - -on: - pull_request: - branches: [master, develop] - types: [opened, synchronize, reopened] - paths: - - 'packages/docs/**' - - 'Dockerfile' - push: - branches: [master, develop] - paths: - - 'packages/docs/**' - - 'Dockerfile' - -jobs: - test-build: - # Test build on every PR to DEVELOP and MASTER - if: ${{ github.event_name == 'pull_request' }} - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v3 - with: - fetch-depth: 0 - - uses: nrwl/nx-set-shas@v3 - with: - main-branch-name: 'develop' - - name: Install pnpm - uses: pnpm/action-setup@v2 - with: - version: 7.30.0 - - uses: actions/setup-node@v3 - with: - node-version: 18.15.0 - cache: pnpm - - name: Install dependencies - run: pnpm install --frozen-lockfile - - name: Lint - run: pnpm nx run @blockchain-lab-um/ssi-snap-docs:lint - env: - NX_CLOUD_ACCESS_TOKEN: ${{ secrets.NX_CLOUD_ACCESS_TOKEN }} - - name: Test build docs - run: pnpm nx run @blockchain-lab-um/ssi-snap-docs:build - env: - NX_CLOUD_ACCESS_TOKEN: ${{ secrets.NX_CLOUD_ACCESS_TOKEN }} - - test-deploy: - # Test deploy when we PUSH to DEVELOP - if: ${{ (github.ref == 'refs/heads/develop') && (github.event_name == 'push') }} - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v3 - with: - fetch-depth: 0 - - name: Create nx-cloud.env - run: echo "NX_CLOUD_ACCESS_TOKEN=$NX_CLOUD_ACCESS_TOKEN" > nx-cloud.env - env: - NX_CLOUD_ACCESS_TOKEN: ${{ secrets.NX_CLOUD_ACCESS_TOKEN }} - - name: Build blockchain-lab-um/ssi-snap - run: docker build . -t blockchain-lab-um/ssi-snap - - name: Build blockchain-lab-um/ssi-snap-docs - run: docker build ./packages/docs -t blockchain-lab-um/ssi-snap-docs - - name: Change image tag - run: docker tag blockchain-lab-um/ssi-snap-docs:latest bclabum.informatika.uni-mb.si/registry/ssi-snap-docs:latest - - name: Login to Docker Hub - uses: docker/login-action@v2 - with: - registry: bclabum.informatika.uni-mb.si/registry - username: ${{ secrets.DOCKERHUB_USERNAME }} - password: ${{ secrets.DOCKERHUB_TOKEN }} - - name: Push to private docker registry - run: docker push bclabum.informatika.uni-mb.si/registry/ssi-snap-docs:latest - - deploy: - # Deploy only when we PUSH to MASTER - if: ${{ (github.ref == 'refs/heads/master') && (github.event_name == 'push') }} - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v3 - - name: Install pnpm - uses: pnpm/action-setup@v2 - with: - version: 7.30.0 - - uses: actions/setup-node@v3 - with: - node-version: 18.15.0 - cache: pnpm - - uses: webfactory/ssh-agent@v0.6.0 - with: - ssh-private-key: ${{ secrets.GH_PAGES_DEPLOY }} - - name: Deploy to GitHub Pages - env: - USE_SSH: true - run: | - git config --global user.email "andraz.vrecko@gmail.com" - git config --global user.name "andyv09" - pnpm install --frozen-lockfile - pnpm deploy:docs diff --git a/.github/workflows/publish_core.yaml b/.github/workflows/publish_core.yaml index 65367cd84..63440c477 100644 --- a/.github/workflows/publish_core.yaml +++ b/.github/workflows/publish_core.yaml @@ -26,6 +26,6 @@ jobs: env: NX_CLOUD_ACCESS_TOKEN: ${{ secrets.NX_CLOUD_ACCESS_TOKEN }} - name: Publish - run: npm publish -w @blockchain-lab-um/ssi-snap -w @blockchain-lab-um/ssi-snap-connector -w @blockchain-lab-um/veramo-vc-manager -w @blockchain-lab-um/ssi-snap-types + run: npm publish -w @blockchain-lab-um/masca -w @blockchain-lab-um/masca-connector -w @blockchain-lab-um/veramo-vc-manager -w @blockchain-lab-um/masca-types env: NODE_AUTH_TOKEN: ${{secrets.NPM_AUTH_TOKEN}} diff --git a/.github/workflows/sonarcloud.yml b/.github/workflows/sonarcloud.yml index f7c6eada7..5bd8a886a 100644 --- a/.github/workflows/sonarcloud.yml +++ b/.github/workflows/sonarcloud.yml @@ -31,7 +31,7 @@ jobs: - name: Install dependencies run: pnpm install --frozen-lockfile - name: Test snap - run: pnpm nx test:ci @blockchain-lab-um/ssi-snap + run: pnpm nx test:ci @blockchain-lab-um/masca env: NX_CLOUD_ACCESS_TOKEN: ${{ secrets.NX_CLOUD_ACCESS_TOKEN }} - name: Scan snap diff --git a/Dockerfile b/Dockerfile index 8dd923aa7..d53a55bf8 100644 --- a/Dockerfile +++ b/Dockerfile @@ -27,7 +27,5 @@ RUN pnpm install # Copy all other files COPY . . -ENV NODE_ENV=production - # Build affected projects RUN pnpm build:docker diff --git a/README.md b/README.md index ab36bdd74..a2efd24a2 100644 --- a/README.md +++ b/README.md @@ -1,34 +1,42 @@ -# SSI Snap · [![npm version](https://img.shields.io/npm/v/@blockchain-lab-um/ssi-snap.svg?style=flat)](https://www.npmjs.com/package/@blockchain-lab-um/ssi-snap) + -The SSI Snap enables everyone to build their **decentralized and self-sovereign identity by enhancing MetaMask with functionalities to manage DIDs, VCs, and VPs.** Any dApp can connect it to access identity data, and dApp developers can already start with the integration! +## [![npm version](https://img.shields.io/npm/v/@blockchain-lab-um/masca.svg?style=flat)](https://www.npmjs.com/package/@blockchain-lab-um/masca) -- [Website](https://blockchain-lab-um.github.io/ssi-snap/) +Masca enables everyone to build their **decentralized and self-sovereign identity by enhancing MetaMask with functionalities to manage DIDs, VCs, and VPs.** Any dApp can connect it to access identity data, and dApp developers can already start with the integration! + +- [Website](https://blockchain-lab-um.github.io/masca/) - [Demo](https://blockchain-lab-um.github.io/course-dapp/) -- [Docs](https://blockchain-lab-um.github.io/ssi-snap-docs/) +- [Docs](https://blockchain-lab-um.github.io/masca-docs/) - [Blog post](https://medium.com/@blockchainlabum/open-sourcing-ssi-snap-for-metamask-aaa176775be2) # Features -The SSI Snap is built agnostic, leaving the user to choose his preferred **blockchain, DID method, and data storage provider.** Everything is configurable, just like selecting the network in MetaMask. Currently supported technologies: +Masca is built agnostic, leaving the user to choose his preferred **blockchain, DID method, and data storage provider.** Everything is configurable, just like selecting the network in MetaMask. Currently supported technologies: - **Blockchains:** Any EVM-based blockchain that is supported by DID methods -- **DID methods:** `did:ethr`, `did:key`, `did:pkh` +- **DID methods:** `did:ethr`, `did:key`, `did:pkh`, `did:jwk` - **Data storage providers:** Local MetaMask Snap state, Ceramic Network -Many new features are already in the works. For more information, please check the [roadmap](https://blockchain-lab-um.github.io/ssi-snap-docs/docs/roadmap) on the documentation. +Many new features are already in the works. For more information, please check the [roadmap](https://blockchain-lab-um.github.io/masca-docs/docs/roadmap) on the documentation. # Development ### Versions -Every version of SSI Snap does NOT work with every version of MetaMask Flask! Here is a table of compatible versions: +Every version of Masca does NOT work with every version of MetaMask Flask! Here is a table of compatible versions: -| SSI Snap Version | Flask Version | -| ---------------- | ------------- | -| 1.2.2 | up to 10.19.0 | -| 1.3.0 | 10.24.0 | -| 1.4.0 | 10.25.0 | -| 1.5.0 | 10.26.1 | +| Masca version | MetaMask Flask version | +| ------------- | ---------------------- | +| 1.2.2 | up to 10.19.0 | +| 1.3.0 | 10.24.0 | +| 1.4.0 | 10.25.0 | +| 1.5.0 | 10.26.1 | ### Prerequisites @@ -44,7 +52,7 @@ Every version of SSI Snap does NOT work with every version of MetaMask Flask! He ### Snap - To start the Snap run `pnpm start:snap` -- Snap can be tested on `localhost:8081/` or on SSI Snap Website +- Snap can be tested on `localhost:8081/` or on Masca website ### Website @@ -56,7 +64,11 @@ Every version of SSI Snap does NOT work with every version of MetaMask Flask! He # Feature requests -Is SSI Snap missing some crucial features? For new features and other enhancements, please open a new issue. If you are unsure if it fits in the Snap, start a new discussion under the Discussions tab. +Is Masca missing some crucial features? For new features and other enhancements, please open a new issue. If you are unsure if it fits in the Snap, start a new discussion under the Discussions tab. + +# Rebrand + +Masca was previously called SSI Snap; thus, the old name can still appear in some places. You can also find earlier versions of the Snap under the SSI Snap packages. # Licenses diff --git a/assets/masca_logo_dark.svg b/assets/masca_logo_dark.svg new file mode 100644 index 000000000..35a0148e0 --- /dev/null +++ b/assets/masca_logo_dark.svg @@ -0,0 +1,15 @@ + + + + + + + + + + + + + + + diff --git a/assets/masca_logo_light.svg b/assets/masca_logo_light.svg new file mode 100644 index 000000000..7a4afe936 --- /dev/null +++ b/assets/masca_logo_light.svg @@ -0,0 +1,15 @@ + + + + + + + + + + + + + + + diff --git a/libs/utils/package.json b/libs/utils/package.json index 19eb9ab8d..8012e5178 100644 --- a/libs/utils/package.json +++ b/libs/utils/package.json @@ -6,7 +6,7 @@ "keywords": [], "repository": { "type": "git", - "url": "https://github.com/blockchain-lab-um/ssi-snap.git" + "url": "https://github.com/blockchain-lab-um/masca.git" }, "license": "(Apache-2.0 AND MIT)", "author": { diff --git a/package.json b/package.json index 39e9d6938..97401e931 100644 --- a/package.json +++ b/package.json @@ -13,10 +13,10 @@ "DID:ETHR", "Veramo" ], - "homepage": "https://github.com/blockchain-lab-um/SSISnap", + "homepage": "https://github.com/blockchain-lab-um/Masca", "repository": { "type": "git", - "url": "https://github.com/blockchain-lab-um/ssi-snap.git" + "url": "https://github.com/blockchain-lab-um/masca.git" }, "license": "(Apache-2.0 AND MIT)", "author": { @@ -31,22 +31,21 @@ "scripts": { "build": "pnpm nx affected --target=build", "build:all": "pnpm nx run-many --target=build --all", - "build:connector": "pnpm nx build @blockchain-lab-um/ssi-snap-connector", - "build:docker": "pnpm nx run-many --target=build --projects=@blockchain-lab-um/ssi-snap-docs && pnpm nx run @blockchain-lab-um/dapp:build:docker", - "build:docs": "pnpm nx build @blockchain-lab-um/ssi-snap-docs", + "build:connector": "pnpm nx build @blockchain-lab-um/masca-connector", + "build:docker": "pnpm nx run-many --target=build --projects=@blockchain-lab-um/masca-docs,@blockchain-lab-um/dapp", + "build:docs": "pnpm nx build @blockchain-lab-um/masca-docs", "build:vcmanager": "pnpm nx build @blockchain-lab-um/veramo-vc-manager", - "deploy:docs": "pnpm nx deploy @blockchain-lab-um/ssi-snap-docs", - "docker:build": "docker build . -t blockchain-lab-um/ssi-snap", + "deploy:docs": "pnpm nx deploy @blockchain-lab-um/masca-docs", + "docker:build": "docker build . -t blockchain-lab-um/masca", "lint": "pnpm prettier && pnpm nx affected --target=lint", "lint:all": "pnpm prettier && pnpm nx run-many --target=lint --all", "prepare": "is-ci || husky install", "prettier": "prettier --write .", - "release-build:core": "pnpm nx run-many --target=build --projects=@blockchain-lab-um/ssi-snap,@blockchain-lab-um/ssi-snap-connector,@blockchain-lab-um/veramo-vc-manager", - "release-build:utils": "pnpm nx build @blockchain-lab-um/utils", + "release-build:core": "pnpm nx run-many --target=build --projects=@blockchain-lab-um/masca,@blockchain-lab-um/masca-connector,@blockchain-lab-um/veramo-vc-manager", "start": "pnpm nx run-many --target=start --all", "start:dapp": "pnpm nx start @blockchain-lab-um/dapp", - "start:docs": "pnpm nx start @blockchain-lab-um/ssi-snap-docs", - "start:snap": "pnpm nx start @blockchain-lab-um/ssi-snap", + "start:docs": "pnpm nx start @blockchain-lab-um/masca-docs", + "start:snap": "pnpm nx start @blockchain-lab-um/masca", "test": "pnpm nx affected --target=test", "test:all": "pnpm nx run-many --target=test --all", "test:ci": "pnpm nx affected --target=test:ci" diff --git a/packages/connector/README.md b/packages/connector/README.md index 6a1fc3362..ebd9a41d7 100644 --- a/packages/connector/README.md +++ b/packages/connector/README.md @@ -2,7 +2,7 @@ SSI Snap connector is used to install SSI snap and expose API toward snap on dApps and other applications. -For more details on SSI snap itself see [snap repo](https://github.com/blockchain-lab-um/ssi-snap) or read full [SSI Snap documentation](https://blockchain-lab-um.github.io/ssi-snap-docs/). +For more details on SSI snap itself see [snap repo](https://github.com/blockchain-lab-um/masca) or read full [SSI Snap documentation](https://blockchain-lab-um.github.io/masca-docs/). ## License diff --git a/packages/connector/package.json b/packages/connector/package.json index a75c3c30b..3dc5fcdcb 100644 --- a/packages/connector/package.json +++ b/packages/connector/package.json @@ -1,7 +1,7 @@ { - "name": "@blockchain-lab-um/ssi-snap-connector", + "name": "@blockchain-lab-um/masca-connector", "version": "1.5.0", - "description": "Library for using the SSI Snap on frontend", + "description": "Library for using the Masca on frontend", "keywords": [ "MetaMask", "Snaps", @@ -39,7 +39,7 @@ "prepack": "pnpm build" }, "dependencies": { - "@blockchain-lab-um/ssi-snap-types": "*", + "@blockchain-lab-um/masca-types": "*", "@blockchain-lab-um/utils": "*", "@metamask/detect-provider": "^2.0.0", "@veramo/core": "5.1.2" diff --git a/packages/connector/src/index.ts b/packages/connector/src/index.ts index 6903f2df6..648d96c64 100644 --- a/packages/connector/src/index.ts +++ b/packages/connector/src/index.ts @@ -1,13 +1,13 @@ import { AvailableMethods, isAvailableMethods, -} from '@blockchain-lab-um/ssi-snap-types'; +} from '@blockchain-lab-um/masca-types'; import { Result, ResultObject, isError } from '@blockchain-lab-um/utils'; import detectEthereumProvider from '@metamask/detect-provider'; -import { MetaMaskSSISnap } from './snap.js'; +import { Masca } from './snap.js'; -export { MetaMaskSSISnap } from './snap.js'; +export { Masca } from './snap.js'; export { isSnapInstalled } from './utils.js'; export type SnapInstallationParams = { @@ -16,20 +16,20 @@ export type SnapInstallationParams = { supportedMethods?: Array; }; -const defaultSnapOrigin = 'npm:@blockchain-lab-um/ssi-snap'; +const defaultSnapOrigin = 'npm:@blockchain-lab-um/masca'; /** - * Install and enable SSI Snap + * Install and enable Masca * - * Checks for existence of MetaMask Flask and installs SSI Snap if not installed + * Checks for existence of MetaMask Flask and installs Masca if not installed * * @param snapInstallationParams - set snapID, version and a list of supported methods * - * @return MetaMaskSSISnap - adapter object that exposes snap API + * @return Masca - adapter object that exposes snap API */ -export async function enableSSISnap( +export async function enableMasca( snapInstallationParams: SnapInstallationParams = {} -): Promise> { +): Promise> { const { snapId = defaultSnapOrigin, version = '^1.5.0', @@ -62,11 +62,11 @@ export async function enableSSISnap( }, }); - const snap = new MetaMaskSSISnap(snapId, supportedMethods); + const snap = new Masca(snapId, supportedMethods); - const snapApi = snap.getSSISnapApi(); + const api = snap.getMascaApi(); - const selectedMethodsResult = await snapApi.getSelectedMethod(); + const selectedMethodsResult = await api.getSelectedMethod(); if (isError(selectedMethodsResult)) { return ResultObject.error(selectedMethodsResult.error); @@ -75,9 +75,7 @@ export async function enableSSISnap( const method = selectedMethodsResult.data; if (!isAvailableMethods(method)) { - const switchResult = await snapApi.switchDIDMethod( - snap.supportedMethods[0] - ); + const switchResult = await api.switchDIDMethod(snap.supportedMethods[0]); if (isError(switchResult)) { return ResultObject.error(switchResult.error); diff --git a/packages/connector/src/snap.ts b/packages/connector/src/snap.ts index 301699855..3b9d8caef 100644 --- a/packages/connector/src/snap.ts +++ b/packages/connector/src/snap.ts @@ -4,15 +4,16 @@ import { CreateVCRequestParams, CreateVPRequestParams, DeleteVCsOptions, - MetaMaskSSISnapRPCRequest, + MascaAccountConfig, + MascaApi, + MascaConfig, + MascaRPCRequest, QueryVCsRequestParams, QueryVCsRequestResult, - SSIAccountConfig, - SSISnapApi, - SSISnapConfig, SaveVCOptions, SaveVCRequestResult, -} from '@blockchain-lab-um/ssi-snap-types'; + SetCurrentAccountRequestParams, +} from '@blockchain-lab-um/masca-types'; import { Result } from '@blockchain-lab-um/utils'; import { DIDResolutionResult, @@ -22,7 +23,7 @@ import { } from '@veramo/core'; async function sendSnapMethod( - request: MetaMaskSSISnapRPCRequest, + request: MascaRPCRequest, snapId: string ): Promise { return window.ethereum.request({ @@ -35,14 +36,14 @@ async function sendSnapMethod( } /** - * Get a list of VCs stored in SSI Snap under the currently selected MetaMask account + * Get a list of VCs stored in Masca under the currently selected MetaMask account * * @param params - optional parameters for querying VCs * * @return Result - list of VCs */ export async function queryVCs( - this: MetaMaskSSISnap, + this: Masca, params?: QueryVCsRequestParams ): Promise> { return sendSnapMethod( @@ -52,14 +53,14 @@ export async function queryVCs( } /** - * Create a VP from a list of VCs stored in SSI Snap under the currently selected MetaMask account + * Create a VP from a list of VCs stored in Masca under the currently selected MetaMask account * * @param params - parameters for creating a VP * * @return Result - VP */ export async function createVP( - this: MetaMaskSSISnap, + this: Masca, params: CreateVPRequestParams ): Promise> { return sendSnapMethod( @@ -72,7 +73,7 @@ export async function createVP( } /** - * Save a VC in SSI Snap under the currently selected MetaMask account + * Save a VC in Masca under the currently selected MetaMask account * * @param vc - VC to be saved * @param options - optional parameters for saving a VC @@ -80,7 +81,7 @@ export async function createVP( * @return Result - list of saved VCs */ export async function saveVC( - this: MetaMaskSSISnap, + this: Masca, vc: W3CVerifiableCredential, options?: SaveVCOptions ): Promise> { @@ -97,7 +98,7 @@ export async function saveVC( } /** - * Delete a VC from SSI Snap under the currently selected MetaMask account + * Delete a VC from Masca under the currently selected MetaMask account * * @param id - ID of the VC to be deleted * @param options - optional parameters for deleting a VC @@ -105,7 +106,7 @@ export async function saveVC( * @return Result - list of results for each VC */ export async function deleteVC( - this: MetaMaskSSISnap, + this: Masca, id: string, options?: DeleteVCsOptions ): Promise> { @@ -126,7 +127,7 @@ export async function deleteVC( * * @return Result - DID */ -export async function getDID(this: MetaMaskSSISnap): Promise> { +export async function getDID(this: Masca): Promise> { return sendSnapMethod({ method: 'getDID' }, this.snapId); } @@ -135,9 +136,7 @@ export async function getDID(this: MetaMaskSSISnap): Promise> { * * @return Result - DID method */ -export async function getSelectedMethod( - this: MetaMaskSSISnap -): Promise> { +export async function getSelectedMethod(this: Masca): Promise> { return sendSnapMethod({ method: 'getSelectedMethod' }, this.snapId); } @@ -147,7 +146,7 @@ export async function getSelectedMethod( * @return Result - list of available DID methods */ export async function getAvailableMethods( - this: MetaMaskSSISnap + this: Masca ): Promise> { return sendSnapMethod({ method: 'getAvailableMethods' }, this.snapId); } @@ -160,7 +159,7 @@ export async function getAvailableMethods( * @return Result - true if the switch was successful */ export async function switchDIDMethod( - this: MetaMaskSSISnap, + this: Masca, method: AvailableMethods ): Promise> { return sendSnapMethod( @@ -174,9 +173,7 @@ export async function switchDIDMethod( * * @return Result - true if the switch was successful */ -export async function togglePopups( - this: MetaMaskSSISnap -): Promise> { +export async function togglePopups(this: Masca): Promise> { return sendSnapMethod({ method: 'togglePopups' }, this.snapId); } @@ -186,7 +183,7 @@ export async function togglePopups( * @return Result> - status of available VC stores */ export async function getVCStore( - this: MetaMaskSSISnap + this: Masca ): Promise>> { return sendSnapMethod({ method: 'getVCStore' }, this.snapId); } @@ -197,7 +194,7 @@ export async function getVCStore( * @return Result - list of available VC stores */ export async function getAvailableVCStores( - this: MetaMaskSSISnap + this: Masca ): Promise> { return sendSnapMethod({ method: 'getAvailableVCStores' }, this.snapId); } @@ -211,7 +208,7 @@ export async function getAvailableVCStores( * @return Result - true if the switch was successful */ export async function setVCStore( - this: MetaMaskSSISnap, + this: Masca, store: AvailableVCStores, value: boolean ): Promise> { @@ -224,22 +221,22 @@ export async function setVCStore( /** * Get account settings (i.e. DID method, VC stores,...) * - * @return Result - account settings + * @return Result - account settings */ export async function getAccountSettings( - this: MetaMaskSSISnap -): Promise> { + this: Masca +): Promise> { return sendSnapMethod({ method: 'getAccountSettings' }, this.snapId); } /** - * Get SSI Snap settings + * Get Masca settings * - * @return Result - SSI Snap settings + * @return Result - Masca settings */ export async function getSnapSettings( - this: MetaMaskSSISnap -): Promise> { + this: Masca +): Promise> { return sendSnapMethod({ method: 'getSnapSettings' }, this.snapId); } @@ -251,7 +248,7 @@ export async function getSnapSettings( * @return Result - DID resolution result */ export async function resolveDID( - this: MetaMaskSSISnap, + this: Masca, did: string ): Promise> { return sendSnapMethod({ method: 'resolveDID', params: { did } }, this.snapId); @@ -261,7 +258,7 @@ export async function resolveDID( * Create a Verifiable Presentation */ export async function createVC( - this: MetaMaskSSISnap, + this: Masca, params: CreateVCRequestParams ): Promise> { return sendSnapMethod( @@ -273,7 +270,23 @@ export async function createVC( ); } -export class MetaMaskSSISnap { +/** + * Set the currently selected MetaMask account + */ +export async function setCurrentAccount( + this: Masca, + params: SetCurrentAccountRequestParams +): Promise> { + return sendSnapMethod( + { + method: 'setCurrentAccount', + params, + }, + this.snapId + ); +} + +export class Masca { protected readonly snapId: string; public readonly supportedMethods: Array; @@ -286,7 +299,7 @@ export class MetaMaskSSISnap { this.supportedMethods = supportedMethods; } - public getSSISnapApi = (): SSISnapApi => { + public getMascaApi = (): MascaApi => { return { saveVC: saveVC.bind(this), queryVCs: queryVCs.bind(this), @@ -304,6 +317,7 @@ export class MetaMaskSSISnap { getAccountSettings: getAccountSettings.bind(this), resolveDID: resolveDID.bind(this), createVC: createVC.bind(this), + setCurrentAccount: setCurrentAccount.bind(this), }; }; } diff --git a/packages/dapp/Dockerfile b/packages/dapp/Dockerfile index 9497eba2a..4c0b7b134 100644 --- a/packages/dapp/Dockerfile +++ b/packages/dapp/Dockerfile @@ -1,30 +1,28 @@ -FROM blockchain-lab-um/ssi-snap:latest as builder +FROM blockchain-lab-um/masca:latest as builder -FROM nginx:1.23.3-alpine +FROM node:18.15-alpine # Create app directory RUN mkdir -p /app WORKDIR /app -# Change file ownership -RUN chown -R nginx:nginx /app && \ - chmod -R 755 /app && \ - chown -R nginx:nginx /var/cache/nginx && \ - chown -R nginx:nginx /var/log/nginx && \ - chown -R nginx:nginx /etc/nginx/conf.d && \ - touch /var/run/nginx.pid && \ - chown -R nginx:nginx /var/run/nginx.pid +ENV NODE_ENV production -USER nginx +RUN addgroup --system --gid 1001 nodejs +RUN adduser --system --uid 1001 nextjs -# Copy build artifacts -COPY --from=builder /app/packages/dapp/out /app/ssi-snap +# Automatically leverage output traces to reduce image size +# https://nextjs.org/docs/advanced-features/output-file-tracing +COPY --from=builder --chown=nextjs:nodejs /app/packages/dapp/.next/standalone ./ +COPY --from=builder --chown=nextjs:nodejs /app/packages/dapp/.next/static ./packages/dapp/.next/static +COPY --from=builder --chown=nextjs:nodejs /app/packages/dapp/public ./packages/dapp/public -# Copy nginx config -COPY --from=builder /app/packages/dapp/nginx.conf /etc/nginx/nginx.conf +USER nextjs -# Expose port 80 -EXPOSE 80 +EXPOSE 3000 -# Start nginx -CMD ["nginx", "-g", "daemon off;"] +ENV PORT 3000 + +WORKDIR /app/packages/dapp + +CMD ["node", "server.js"] diff --git a/packages/dapp/README.md b/packages/dapp/README.md index 022dc3e16..3caae1cf8 100644 --- a/packages/dapp/README.md +++ b/packages/dapp/README.md @@ -1,4 +1,4 @@ -# Dapp for SSI-Snap +# Dapp for masca ## Technologies used @@ -14,7 +14,7 @@ First, run the development server: pnpm dev ``` -Open [http://localhost:3000/ssi-snap](http://localhost:3000/ssi-snap) with your browser to see the result. +Open [http://localhost:3000/masca](http://localhost:3000/masca) with your browser to see the result. This project uses [`next/font`](https://nextjs.org/docs/basic-features/font-optimization) to automatically optimize and load Inter, a custom Google Font. diff --git a/packages/dapp/next.config.js b/packages/dapp/next.config.js index f21b97f0c..8d28252f8 100644 --- a/packages/dapp/next.config.js +++ b/packages/dapp/next.config.js @@ -17,17 +17,14 @@ const isProd = process.env.NODE_ENV === 'production'; * @type {import('next').NextConfig} */ const nextConfig = { - // FIXME: On release change to /masca - basePath: '/ssi-snap', reactStrictMode: true, swcMinify: true, // https://nextjs.org/docs/advanced-features/output-file-tracing#automatically-copying-traced-files output: 'standalone', // https://nextjs.org/docs/messages/next-image-unconfigured-host images: { - // Disable image optimization - unoptimized: true, - domains: [], + domains: ['localhost'], + loader: 'default', }, experimental: { fontLoaders: [ diff --git a/packages/dapp/nginx.conf b/packages/dapp/nginx.conf deleted file mode 100644 index 1372bd69a..000000000 --- a/packages/dapp/nginx.conf +++ /dev/null @@ -1,52 +0,0 @@ -worker_processes auto; - -error_log /var/log/nginx/error.log warn; - -events { - worker_connections 1024; -} - -http { - include /etc/nginx/mime.types; - default_type application/octet-stream; - sendfile on; - access_log /var/log/nginx/access.log; - keepalive_timeout 80; - - server { - listen 80; - root /app; - index index.html; - error_page 404 /ssi-snap/404.html; - absolute_redirect off; - rewrite ^/(.*)/$ /$1 permanent; - - # Media: images, icons, video, audio - location ~* \.(?:jpg|jpeg|gif|png|ico|ttf|cur|gz|svg|svgz|mp4|ogg|ogv|webm)$ { - expires 1y; - access_log off; - add_header Cache-Control "public"; - } - - # JavaScript and CSS files (incl. .map files) - location ~* \.(?:css|js|map)$ { - gzip_static on; - try_files $uri =404; - expires 1y; - access_log off; - add_header Cache-Control "public"; - } - - location = /ssi-snap { - gzip_static on; - try_files /ssi-snap/index.html =404; - } - - location /ssi-snap/ { - gzip_static on; - try_files $uri $uri.html $uri/index.html $uri/ =404; - } - - include /etc/nginx/extra-conf.d/*.conf; - } -} diff --git a/packages/dapp/package.json b/packages/dapp/package.json index cf745cced..51b0ab4b2 100644 --- a/packages/dapp/package.json +++ b/packages/dapp/package.json @@ -17,8 +17,8 @@ "start": "next start" }, "dependencies": { - "@blockchain-lab-um/ssi-snap-connector": "*", - "@blockchain-lab-um/ssi-snap-types": "*", + "@blockchain-lab-um/masca-connector": "*", + "@blockchain-lab-um/masca-types": "*", "@blockchain-lab-um/utils": "*", "@headlessui/react": "^1.7.7", "@heroicons/react": "^2.0.13", @@ -35,6 +35,7 @@ "prop-types": "^15.8.1", "react": "18.2.0", "react-dom": "18.2.0", + "sharp": "^0.32.0", "tailwind-scrollbar": "^3.0.0", "zustand": "^4.3.2" }, @@ -88,13 +89,6 @@ "{projectRoot}/.next" ] }, - "build:docker": { - "inputs": [], - "dependsOn": [ - "build" - ], - "outputs": [] - }, "start": { "inputs": [ "production", diff --git a/packages/dapp/src/components/Controlbar/Controlbar.tsx b/packages/dapp/src/components/Controlbar/Controlbar.tsx index b99fdbb27..013d141dc 100644 --- a/packages/dapp/src/components/Controlbar/Controlbar.tsx +++ b/packages/dapp/src/components/Controlbar/Controlbar.tsx @@ -2,7 +2,7 @@ import React, { useState } from 'react'; import { AvailableVCStores, QueryVCsRequestResult, -} from '@blockchain-lab-um/ssi-snap-types'; +} from '@blockchain-lab-um/masca-types'; import { isError } from '@blockchain-lab-um/utils'; import { ArrowPathIcon, PlusIcon } from '@heroicons/react/24/outline'; import { W3CVerifiableCredential } from '@veramo/core'; @@ -12,7 +12,7 @@ import ImportModal from '@/components/ImportModal'; import DataStoreCombobox from '@/components/VCTable/DataStoreCombobox'; import GlobalFilter from '@/components/VCTable/GlobalFilter'; import ViewTabs from '@/components/VCTable/ViewTabs'; -import { useSnapStore, useToastStore } from '@/stores'; +import { useMascaStore, useToastStore } from '@/stores'; type ControlbarProps = { vcs: QueryVCsRequestResult[]; @@ -32,9 +32,9 @@ const Controlbar = ({ vcs, isConnected }: ControlbarProps) => { }), shallow ); - const { api, changeVcs } = useSnapStore( + const { api, changeVcs } = useMascaStore( (state) => ({ - api: state.snapApi, + api: state.mascaApi, changeVcs: state.changeVcs, }), shallow diff --git a/packages/dapp/src/components/DeleteModal/index.tsx b/packages/dapp/src/components/DeleteModal/index.tsx index 3d8915fdf..610e02b4a 100644 --- a/packages/dapp/src/components/DeleteModal/index.tsx +++ b/packages/dapp/src/components/DeleteModal/index.tsx @@ -2,14 +2,14 @@ import { Fragment } from 'react'; import { AvailableVCStores, QueryVCsRequestResult, -} from '@blockchain-lab-um/ssi-snap-types'; +} from '@blockchain-lab-um/masca-types'; import { isError } from '@blockchain-lab-um/utils'; import { Dialog, Transition } from '@headlessui/react'; import { useTranslations } from 'next-intl'; import { shallow } from 'zustand/shallow'; import Button from '@/components/Button'; -import { useSnapStore, useToastStore } from '@/stores'; +import { useMascaStore, useToastStore } from '@/stores'; interface DeleteModalProps { open: boolean; @@ -20,7 +20,13 @@ interface DeleteModalProps { function DeleteModal({ open, setOpen, vc, store }: DeleteModalProps) { const t = useTranslations('DeleteVC'); - const api = useSnapStore((state) => state.snapApi); + const { api, changeVcs } = useMascaStore( + (state) => ({ + api: state.mascaApi, + changeVcs: state.changeVcs, + }), + shallow + ); const { setTitle, setLoading, setToastOpen, setType } = useToastStore( (state) => ({ setTitle: state.setTitle, @@ -47,11 +53,11 @@ function DeleteModal({ open, setOpen, vc, store }: DeleteModalProps) { if (store) { deleteReqOptions = { store, - }; + } as { store: AvailableVCStores }; } else if (vc.metadata.store) { deleteReqOptions = { - store: vc.metadata.store as AvailableVCStores | AvailableVCStores[], - }; + store: vc.metadata.store, + } as { store: AvailableVCStores[] }; } const res = await api.deleteVC(vc.metadata.id, deleteReqOptions); @@ -88,7 +94,7 @@ function DeleteModal({ open, setOpen, vc, store }: DeleteModalProps) { setLoading(false); setToastOpen(true); }, 100); - useSnapStore.getState().changeVcs(vcs.data); + changeVcs(vcs.data); } } }; diff --git a/packages/dapp/src/components/DropdownMultiselect/index.tsx b/packages/dapp/src/components/DropdownMultiselect/index.tsx index 993cfc272..00ab558d5 100644 --- a/packages/dapp/src/components/DropdownMultiselect/index.tsx +++ b/packages/dapp/src/components/DropdownMultiselect/index.tsx @@ -1,5 +1,5 @@ import React, { Fragment } from 'react'; -import { AvailableVCStores } from '@blockchain-lab-um/ssi-snap-types'; +import { AvailableVCStores } from '@blockchain-lab-um/masca-types'; import { Listbox, Transition } from '@headlessui/react'; import { CheckIcon, ChevronDownIcon } from '@heroicons/react/20/solid'; import clsx from 'clsx'; diff --git a/packages/dapp/src/components/ImportModal/index.tsx b/packages/dapp/src/components/ImportModal/index.tsx index c4974f574..a50829a0c 100644 --- a/packages/dapp/src/components/ImportModal/index.tsx +++ b/packages/dapp/src/components/ImportModal/index.tsx @@ -1,11 +1,11 @@ import { Fragment, useState } from 'react'; -import { AvailableVCStores } from '@blockchain-lab-um/ssi-snap-types'; +import { AvailableVCStores } from '@blockchain-lab-um/masca-types'; import { Dialog, Transition } from '@headlessui/react'; import Button from '@/components/Button'; import DropdownMultiselect from '@/components/DropdownMultiselect'; import InfoIcon from '@/components/InfoIcon'; -import { useSnapStore } from '@/stores'; +import { useMascaStore } from '@/stores'; interface ImportModalProps { open: boolean; @@ -16,7 +16,7 @@ interface ImportModalProps { function ImportModal({ open, setOpen, importVC }: ImportModalProps) { const [loading, setLoading] = useState(false); const [vc, setVC] = useState(''); - const VCStores = useSnapStore((state) => state.availableVCStores); + const VCStores = useMascaStore((state) => state.availableVCStores); const availableStores = Object.keys(VCStores).filter( (key) => VCStores[key] === true ); diff --git a/packages/dapp/src/components/Layout/ToastWrapper.tsx b/packages/dapp/src/components/Layout/ToastWrapper.tsx index 1d188d22f..f0c234eff 100644 --- a/packages/dapp/src/components/Layout/ToastWrapper.tsx +++ b/packages/dapp/src/components/Layout/ToastWrapper.tsx @@ -18,12 +18,11 @@ export const ToastWrapper = ({ children }: { children: JSX.Element }) => { return () => clearTimeout(timerRef.current); }, []); - const { open, setOpen, loading, text, type, title } = useToastStore( + const { open, setOpen, loading, type, title } = useToastStore( (state) => ({ open: state.open, setOpen: state.setOpen, loading: state.loading, - text: state.text, title: state.title, type: state.type, }), @@ -64,7 +63,7 @@ export const ToastWrapper = ({ children }: { children: JSX.Element }) => { {children} diff --git a/packages/dapp/src/components/MenuPopover/index.tsx b/packages/dapp/src/components/MenuPopover/index.tsx index e3a8df57a..88d613485 100644 --- a/packages/dapp/src/components/MenuPopover/index.tsx +++ b/packages/dapp/src/components/MenuPopover/index.tsx @@ -4,8 +4,6 @@ import { Popover, Transition } from '@headlessui/react'; import { ChevronDownIcon } from '@heroicons/react/20/solid'; import { useTranslations } from 'next-intl'; -import { BASE_PATH } from '@/utils/constants'; - function IconOne() { return ( { return (
discord logo
{ ); const { - changeSnapApi, + changeMascaApi, changeDID, changeAvailableMethods, changeCurrMethod, changeAvailableVCStores, - } = useSnapStore((state) => ({ - snapApi: state.snapApi, - changeSnapApi: state.changeSnapApi, - changeDID: state.changeCurrDID, - changeAvailableMethods: state.changeAvailableMethods, - changeCurrMethod: state.changeCurrDIDMethod, - changeAvailableVCStores: state.changeAvailableVCStores, - })); + } = useMascaStore( + (state) => ({ + changeMascaApi: state.changeMascaApi, + changeDID: state.changeCurrDID, + changeAvailableMethods: state.changeAvailableMethods, + changeCurrMethod: state.changeCurrDIDMethod, + changeAvailableVCStores: state.changeAvailableVCStores, + }), + shallow + ); const router = useRouter(); @@ -88,8 +90,8 @@ const MetaMaskProvider = ({ children }: MetaMaskProviderProps) => { changeIsFlask(true); }; - const enableSSISnapHandler = async () => { - const enableResult = await enableSSISnap({ snapId }); + const enableMascaHandler = async () => { + const enableResult = await enableMasca({ snapId }); console.log(snapId); console.log(process.env.NODE_ENV); if (isError(enableResult)) { @@ -98,9 +100,21 @@ const MetaMaskProvider = ({ children }: MetaMaskProviderProps) => { return; } - const api = enableResult.data.getSSISnapApi(); + const api = enableResult.data.getMascaApi(); + + changeMascaApi(api); - changeSnapApi(api); + // Set currently connected address + const setAccountRes = await api.setCurrentAccount({ + currentAccount: address, + }); + + if (isError(setAccountRes)) { + console.log("Couldn't set current account"); + console.error(setAccountRes.error); + changeIsConnecting(false); + return; + } const did = await api.getDID(); if (isError(did)) { @@ -166,7 +180,7 @@ const MetaMaskProvider = ({ children }: MetaMaskProviderProps) => { useEffect(() => { if (!hasMM || !hasFlask || !address) return; console.log('Address changed to', address); - enableSSISnapHandler().catch((err) => { + enableMascaHandler().catch((err) => { console.error(err); changeIsConnecting(false); }); diff --git a/packages/dapp/src/components/MethodDropdownMenu/index.tsx b/packages/dapp/src/components/MethodDropdownMenu/index.tsx index c26af37eb..ce3d87c07 100644 --- a/packages/dapp/src/components/MethodDropdownMenu/index.tsx +++ b/packages/dapp/src/components/MethodDropdownMenu/index.tsx @@ -1,18 +1,18 @@ import { Fragment } from 'react'; -import { AvailableMethods } from '@blockchain-lab-um/ssi-snap-types'; +import { AvailableMethods } from '@blockchain-lab-um/masca-types'; import { isError } from '@blockchain-lab-um/utils'; import { Menu, Transition } from '@headlessui/react'; import { ChevronDownIcon } from '@heroicons/react/20/solid'; import { shallow } from 'zustand/shallow'; -import { useSnapStore, useToastStore } from '@/stores'; +import { useMascaStore, useToastStore } from '@/stores'; import { DropdownButton } from './MethodDropdownButton'; export default function MethodDropdownMenu() { const { api, currMethod, methods, changeCurrDIDMethod, changeDID } = - useSnapStore( + useMascaStore( (state) => ({ - api: state.snapApi, + api: state.mascaApi, currMethod: state.currDIDMethod, methods: state.availableMethods, changeCurrDIDMethod: state.changeCurrDIDMethod, diff --git a/packages/dapp/src/components/ModifyDSModal/index.tsx b/packages/dapp/src/components/ModifyDSModal/index.tsx index 8e0d00fb5..0147cf9aa 100644 --- a/packages/dapp/src/components/ModifyDSModal/index.tsx +++ b/packages/dapp/src/components/ModifyDSModal/index.tsx @@ -2,13 +2,13 @@ import { Fragment, useState } from 'react'; import { AvailableVCStores, QueryVCsRequestResult, -} from '@blockchain-lab-um/ssi-snap-types'; +} from '@blockchain-lab-um/masca-types'; import { isError } from '@blockchain-lab-um/utils'; import { Dialog, Transition } from '@headlessui/react'; import { useTranslations } from 'next-intl'; import { shallow } from 'zustand/shallow'; -import { useSnapStore, useToastStore } from '@/stores'; +import { useMascaStore, useToastStore } from '@/stores'; import Button from '../Button'; import DeleteModal from '../DeleteModal'; import ToggleSwitch from '../Switch'; @@ -35,10 +35,11 @@ function ModifyDSModal({ open, setOpen, vc }: ModifyDSModalProps) { const [deleteModalStore, setDeleteModalStore] = useState< AvailableVCStores | undefined >(undefined); - const { enabledStores, snapApi } = useSnapStore( + const { enabledStores, api, changeVcs } = useMascaStore( (state) => ({ enabledStores: state.availableVCStores, - snapApi: state.snapApi, + api: state.mascaApi, + changeVcs: state.changeVcs, }), shallow ); @@ -72,7 +73,7 @@ function ModifyDSModal({ open, setOpen, vc }: ModifyDSModalProps) { }); const handleDSChange = async (store: AvailableVCStores, enabled: boolean) => { - if (!snapApi) return; + if (!api) return; if (!enabled) { setDeleteModalStore(store); @@ -86,7 +87,7 @@ function ModifyDSModal({ open, setOpen, vc }: ModifyDSModalProps) { setToastOpen(true); setOpen(false); - const res = await snapApi.saveVC(vc.data, { store }); + const res = await api.saveVC(vc.data, { store }); if (isError(res)) { setToastOpen(false); @@ -109,14 +110,14 @@ function ModifyDSModal({ open, setOpen, vc }: ModifyDSModalProps) { setToastOpen(true); }, 100); - const vcs = await snapApi.queryVCs(); + const vcs = await api.queryVCs(); if (isError(vcs)) { console.log(vcs.error); return; } - useSnapStore.getState().changeVcs(vcs.data); + changeVcs(vcs.data); }; return ( diff --git a/packages/dapp/src/components/Navbar/NavConnection.tsx b/packages/dapp/src/components/Navbar/NavConnection.tsx index ca2d087b9..4c42fbe5c 100644 --- a/packages/dapp/src/components/Navbar/NavConnection.tsx +++ b/packages/dapp/src/components/Navbar/NavConnection.tsx @@ -1,12 +1,15 @@ import { shallow } from 'zustand/shallow'; import MethodDropdownMenu from '@/components/MethodDropdownMenu'; -import { useGeneralStore, useSnapStore } from '@/stores'; +import { useGeneralStore, useMascaStore } from '@/stores'; import AddressPopover from '../AddressPopover'; import ConnectButton from '../ConnectButton'; export const NavConnection = () => { - const did = useSnapStore((state) => state.currDID); + const { did, changeVcs } = useMascaStore( + (state) => ({ did: state.currDID, changeVcs: state.changeVcs }), + shallow + ); const { isConnected, @@ -29,10 +32,8 @@ export const NavConnection = () => { shallow ); - const setVcs = useSnapStore((state) => state.changeVcs); - const disconnect = () => { - setVcs([]); + changeVcs([]); changeIsConnected(false); changeAddres(''); changeDid(''); diff --git a/packages/dapp/src/components/Navbar/index.tsx b/packages/dapp/src/components/Navbar/index.tsx index 715e59e2c..aa847b704 100644 --- a/packages/dapp/src/components/Navbar/index.tsx +++ b/packages/dapp/src/components/Navbar/index.tsx @@ -6,7 +6,6 @@ import { useTranslations } from 'next-intl'; import MenuPopover from '@/components/MenuPopover'; import ToggleTheme from '@/components/ToggleTheme'; -import { BASE_PATH } from '@/utils/constants'; import { NavBtn } from './NavBtn'; import { NavConnection } from './NavConnection'; @@ -22,13 +21,13 @@ export default function Navbar() {
Masca Logo Masca Logo diff --git a/packages/dapp/src/components/SelectedVCsTableRow/SelectedVCsTableRow.tsx b/packages/dapp/src/components/SelectedVCsTableRow/SelectedVCsTableRow.tsx index 682e0498b..4dd1ad6b8 100644 --- a/packages/dapp/src/components/SelectedVCsTableRow/SelectedVCsTableRow.tsx +++ b/packages/dapp/src/components/SelectedVCsTableRow/SelectedVCsTableRow.tsx @@ -1,6 +1,6 @@ import React from 'react'; import Link from 'next/link'; -import { QueryVCsRequestResult } from '@blockchain-lab-um/ssi-snap-types'; +import { QueryVCsRequestResult } from '@blockchain-lab-um/masca-types'; import { ArrowsPointingOutIcon } from '@heroicons/react/24/outline'; import { CheckCircleIcon, XCircleIcon } from '@heroicons/react/24/solid'; diff --git a/packages/dapp/src/components/StoreIcon/index.tsx b/packages/dapp/src/components/StoreIcon/index.tsx index c74c03185..3e861470b 100644 --- a/packages/dapp/src/components/StoreIcon/index.tsx +++ b/packages/dapp/src/components/StoreIcon/index.tsx @@ -1,8 +1,6 @@ import React from 'react'; import Image from 'next/image'; -import { BASE_PATH } from '@/utils/constants'; - type StoreIconProps = { store: string; }; @@ -15,11 +13,7 @@ const logo: Record = { const StoreIcon = ({ store }: StoreIconProps) => { return (
- {store} + {store}
); }; diff --git a/packages/dapp/src/components/Tooltip/index.tsx b/packages/dapp/src/components/Tooltip/index.tsx index 632d215d0..dd9cf3987 100644 --- a/packages/dapp/src/components/Tooltip/index.tsx +++ b/packages/dapp/src/components/Tooltip/index.tsx @@ -14,7 +14,7 @@ const Tooltip = ({ children, tooltip, position = 'top' }: TooltipProps) => {
diff --git a/packages/dapp/src/components/VC/tabs/JsonTab.tsx b/packages/dapp/src/components/VC/tabs/JsonTab.tsx index 2f1980a90..7f4eca3a6 100644 --- a/packages/dapp/src/components/VC/tabs/JsonTab.tsx +++ b/packages/dapp/src/components/VC/tabs/JsonTab.tsx @@ -1,5 +1,5 @@ import React from 'react'; -import { QueryVCsRequestResult } from '@blockchain-lab-um/ssi-snap-types'; +import { QueryVCsRequestResult } from '@blockchain-lab-um/masca-types'; import { DocumentDuplicateIcon } from '@heroicons/react/24/solid'; import DeleteModal from '@/components/DeleteModal'; diff --git a/packages/dapp/src/components/VC/tabs/QRTab.tsx b/packages/dapp/src/components/VC/tabs/QRTab.tsx index 8bb9ea404..a2de6c07d 100644 --- a/packages/dapp/src/components/VC/tabs/QRTab.tsx +++ b/packages/dapp/src/components/VC/tabs/QRTab.tsx @@ -1,5 +1,5 @@ import React from 'react'; -import { QueryVCsRequestResult } from '@blockchain-lab-um/ssi-snap-types'; +import { QueryVCsRequestResult } from '@blockchain-lab-um/masca-types'; interface QRTabProps { vc: QueryVCsRequestResult; diff --git a/packages/dapp/src/components/VCTable/DataStoreCombobox/index.tsx b/packages/dapp/src/components/VCTable/DataStoreCombobox/index.tsx index 9c8a3c572..ef0bc14a3 100644 --- a/packages/dapp/src/components/VCTable/DataStoreCombobox/index.tsx +++ b/packages/dapp/src/components/VCTable/DataStoreCombobox/index.tsx @@ -1,5 +1,5 @@ import React, { Fragment, useEffect, useState } from 'react'; -import { QueryVCsRequestResult } from '@blockchain-lab-um/ssi-snap-types'; +import { QueryVCsRequestResult } from '@blockchain-lab-um/masca-types'; import { Combobox, Transition } from '@headlessui/react'; import { CheckIcon, ChevronDownIcon } from '@heroicons/react/20/solid'; import clsx from 'clsx'; diff --git a/packages/dapp/src/components/VCTable/GlobalFilter/index.tsx b/packages/dapp/src/components/VCTable/GlobalFilter/index.tsx index 15d38d19e..24b786c6a 100644 --- a/packages/dapp/src/components/VCTable/GlobalFilter/index.tsx +++ b/packages/dapp/src/components/VCTable/GlobalFilter/index.tsx @@ -1,5 +1,5 @@ import React from 'react'; -import { QueryVCsRequestResult } from '@blockchain-lab-um/ssi-snap-types'; +import { QueryVCsRequestResult } from '@blockchain-lab-um/masca-types'; import { MagnifyingGlassIcon } from '@heroicons/react/20/solid'; import { useTranslations } from 'next-intl'; import { shallow } from 'zustand/shallow'; diff --git a/packages/dapp/src/components/VCTable/TablePagination/index.tsx b/packages/dapp/src/components/VCTable/TablePagination/index.tsx index dee882b7d..401212ec7 100644 --- a/packages/dapp/src/components/VCTable/TablePagination/index.tsx +++ b/packages/dapp/src/components/VCTable/TablePagination/index.tsx @@ -1,5 +1,5 @@ import React from 'react'; -import { QueryVCsRequestResult } from '@blockchain-lab-um/ssi-snap-types'; +import { QueryVCsRequestResult } from '@blockchain-lab-um/masca-types'; import { Table } from '@tanstack/react-table'; import { useTranslations } from 'next-intl'; diff --git a/packages/dapp/src/components/VCTable/VCCard/index.tsx b/packages/dapp/src/components/VCTable/VCCard/index.tsx index a272cd677..58bde0def 100644 --- a/packages/dapp/src/components/VCTable/VCCard/index.tsx +++ b/packages/dapp/src/components/VCTable/VCCard/index.tsx @@ -1,7 +1,7 @@ import React from 'react'; import Link from 'next/link'; -import { QueryVCsRequestResult } from '@blockchain-lab-um/ssi-snap-types'; -import { CheckCircleIcon, XCircleIcon } from '@heroicons/react/24/outline'; +import { QueryVCsRequestResult } from '@blockchain-lab-um/masca-types'; +import { CheckCircleIcon, XCircleIcon } from '@heroicons/react/24/solid'; import { Row } from '@tanstack/react-table'; import clsx from 'clsx'; import { useTranslations } from 'next-intl'; diff --git a/packages/dapp/src/components/VCTable/index.tsx b/packages/dapp/src/components/VCTable/index.tsx index 4fe1acee0..4a2fc70fa 100644 --- a/packages/dapp/src/components/VCTable/index.tsx +++ b/packages/dapp/src/components/VCTable/index.tsx @@ -1,7 +1,7 @@ import React, { useEffect, useState } from 'react'; import Link from 'next/link'; import { useRouter } from 'next/router'; -import { QueryVCsRequestResult } from '@blockchain-lab-um/ssi-snap-types'; +import { QueryVCsRequestResult } from '@blockchain-lab-um/masca-types'; import { isError } from '@blockchain-lab-um/utils'; import { CheckCircleIcon, @@ -37,7 +37,7 @@ import InfoIcon from '@/components/InfoIcon'; import StoreIcon from '@/components/StoreIcon'; import Tooltip from '@/components/Tooltip'; import { convertTypes } from '@/utils/string'; -import { useSnapStore, useTableStore } from '@/stores'; +import { useMascaStore, useTableStore } from '@/stores'; import TablePagination from './TablePagination'; import VCCard from './VCCard'; import { includesDataStore, selectRows } from './tableUtils'; @@ -47,11 +47,11 @@ const Table = () => { const t = useTranslations('Dashboard'); const [loading, setLoading] = useState(false); const [sorting, setSorting] = useState([]); - const { vcs, changeVcs, api } = useSnapStore( + const { api, vcs, changeVcs } = useMascaStore( (state) => ({ + api: state.mascaApi, vcs: state.vcs, changeVcs: state.changeVcs, - api: state.snapApi, }), shallow ); @@ -225,7 +225,7 @@ const Table = () => { ), columnHelper.display({ id: 'select', - header: ({ table }) => <>{t('table.select')}, + header: () => <>{t('table.select')}, cell: ({ row }) => (