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

chore: merge develop #605

Merged
4 commits merged into from
Mar 21, 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
6 changes: 6 additions & 0 deletions .changeset/clever-wasps-explain.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"@blockchain-lab-um/masca-types": patch
"@blockchain-lab-um/masca": patch
---

Resolve issue with importing old state.
5 changes: 5 additions & 0 deletions .changeset/fast-cats-scream.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@blockchain-lab-um/dapp": patch
---

Format addresses and DIDs uniformly.
7 changes: 5 additions & 2 deletions .changeset/pre.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,8 @@
"@blockchain-lab-um/masca": "1.2.1",
"@blockchain-lab-um/masca-types": "1.3.1"
},
"changesets": []
}
"changesets": [
"clever-wasps-explain",
"fast-cats-scream"
]
}
7 changes: 7 additions & 0 deletions libs/extended-verification/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
# @blockchain-lab-um/extended-verification

## 0.1.2-beta.0

### Patch Changes

- Updated dependencies [[`ce8a6d5`](https://github.com/blockchain-lab-um/masca/commit/ce8a6d58aa7986e6b2064cc754cada5956f89c0d)]:
- @blockchain-lab-um/masca-types@1.3.2-beta.0

## 0.1.1

### Patch Changes
Expand Down
4 changes: 2 additions & 2 deletions libs/extended-verification/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@blockchain-lab-um/extended-verification",
"version": "0.1.1",
"version": "0.1.2-beta.0",
"private": false,
"description": "",
"keywords": [],
Expand Down Expand Up @@ -36,7 +36,7 @@
},
"dependencies": {
"@blockchain-lab-um/did-provider-key": "1.0.8",
"@blockchain-lab-um/masca-types": "1.3.1",
"@blockchain-lab-um/masca-types": "1.3.2-beta.0",
"@blockchain-lab-um/utils": "1.3.8",
"@veramo/core": "5.6.0",
"@veramo/credential-eip712": "5.6.0",
Expand Down
7 changes: 7 additions & 0 deletions packages/connector/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
# Changelog

## 1.3.2-beta.0

### Patch Changes

- Updated dependencies [[`ce8a6d5`](https://github.com/blockchain-lab-um/masca/commit/ce8a6d58aa7986e6b2064cc754cada5956f89c0d)]:
- @blockchain-lab-um/masca-types@1.3.2-beta.0

## 1.3.1

### Patch Changes
Expand Down
4 changes: 2 additions & 2 deletions packages/connector/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@blockchain-lab-um/masca-connector",
"version": "1.3.1",
"version": "1.3.2-beta.0",
"description": "Library for using Masca on the frontend",
"keywords": [
"MetaMask",
Expand Down Expand Up @@ -40,7 +40,7 @@
"prepack": "pnpm build"
},
"dependencies": {
"@blockchain-lab-um/masca-types": "1.3.1",
"@blockchain-lab-um/masca-types": "1.3.2-beta.0",
"@blockchain-lab-um/utils": "1.3.8",
"@didtools/pkh-ethereum": "0.4.0",
"@veramo/core": "5.6.1-next.57",
Expand Down
13 changes: 13 additions & 0 deletions packages/dapp/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,18 @@
# @blockchain-lab-um/dapp

## 1.3.1-beta.1

### Patch Changes

- [#602](https://github.com/blockchain-lab-um/masca/pull/602) [`34321c6`](https://github.com/blockchain-lab-um/masca/commit/34321c662c08138d778d3c8000179f9e94d2eb6e) Thanks [@pseudobun](https://github.com/pseudobun)! - Format addresses and DIDs uniformly.

## 1.3.1-beta.0

### Patch Changes

- Updated dependencies []:
- @blockchain-lab-um/masca-connector@1.3.2-beta.0

## 1.3.0

### Minor Changes
Expand Down
4 changes: 2 additions & 2 deletions packages/dapp/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@blockchain-lab-um/dapp",
"version": "1.3.0",
"version": "1.3.1-beta.1",
"private": true,
"license": "(Apache-2.0 AND MIT)",
"type": "commonjs",
Expand All @@ -20,7 +20,7 @@
},
"dependencies": {
"@blockchain-lab-um/did-provider-key": "1.0.8",
"@blockchain-lab-um/masca-connector": "1.3.1",
"@blockchain-lab-um/masca-connector": "1.3.2-beta.0",
"@blockchain-lab-um/oidc-types": "0.0.8",
"@headlessui/react": "^1.7.18",
"@heroicons/react": "^2.1.1",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import { Fragment, useMemo, useState } from 'react';

import { DIDDisplay } from '@/components/DIDDisplay';
import JsonModal from '@/components/JsonModal';
import { getFirstWord } from '@/utils/format';
import { formatAddress, getFirstWord } from '@/utils/format';
import { convertTypes, copyToClipboard } from '@/utils/string';
import { ImageLink } from '@/components/ImageLink';

Expand All @@ -40,7 +40,7 @@ const AddressDisplay = ({ address }: { address: string }) => {
rel="noopener noreferrer"
className="text-md animated-transition dark:text-navy-blue-300 cursor-pointer font-normal text-gray-700 underline underline-offset-2"
>
{`${address.slice(0, 8)}...${address.slice(-8)}`}
{formatAddress(address)}
</a>
</Tooltip>
<button
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import { useMemo, useState } from 'react';
import { VerificationInfoModal } from '@/components/VerificationInfoModal';
import { copyToClipboard } from '@/utils/string';
import CredentialPanel from './CredentialPanel';
import { formatDid } from '@/utils/format';

export const FormattedView = ({
credential,
Expand Down Expand Up @@ -72,15 +73,7 @@ export const FormattedView = ({
rel="noreferrer"
className="font-ubuntu dark:text-orange-accent-dark text-left text-lg font-medium text-pink-500 underline sm:text-xl md:text-2xl lg:truncate"
>
{`${holder.substring(
0,
holder.lastIndexOf(':')
)}:${holder
.split(':')
[holder.split(':').length - 1].slice(
0,
6
)}...${holder.slice(-4)}`}
{formatDid(holder)}
</a>
</Tooltip>
<button
Expand Down
19 changes: 8 additions & 11 deletions packages/dapp/src/components/AddressPopover/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import { useAccount, useEnsAvatar, useEnsName } from 'wagmi';

import { copyToClipboard } from '@/utils/string';
import { TextSkeleton } from '../Skeletons/TextSkeleton';
import { formatAddress, formatDid } from '@/utils/format';

interface AddressPopoverProps {
did: string;
Expand Down Expand Up @@ -51,7 +52,7 @@ const AddressPopover = ({ did, disconnect }: AddressPopoverProps) => {
className="mr-2 inline-block rounded-full"
/>
)}
{ensName ?? `${address?.slice(0, 5)}...${address?.slice(-4)}`}
{ensName ?? formatAddress(address as string)}
<ChevronDownIcon
className={`animated-transition -mr-1 ml-2 h-3 w-3 md:h-4 md:w-4 lg:h-5 lg:w-5 ${
open ? 'rotate-180' : ''
Expand Down Expand Up @@ -81,12 +82,9 @@ const AddressPopover = ({ did, disconnect }: AddressPopoverProps) => {
target="_blank"
rel="noreferrer"
className="animated-transition cursor-pointer text-2xl text-gray-800 underline hover:text-gray-700 dark:text-white dark:hover:text-gray-100"
>{`${did.substring(0, did.lastIndexOf(':'))}:${did
.split(':')
[did.split(':').length - 1].slice(
0,
5
)}...${did.slice(-4)}`}</a>
>
{formatDid(did)}
</a>
) : (
<TextSkeleton className="h-6 w-52" />
)}
Expand All @@ -108,10 +106,9 @@ const AddressPopover = ({ did, disconnect }: AddressPopoverProps) => {
<div className="mr-1 mt-0.5">
<div className="h-2.5 w-2.5 rounded-full bg-green-500" />
</div>
<div className="text-lg text-gray-800 dark:text-white">{`${address?.slice(
0,
5
)}...${address?.slice(-4)}`}</div>
<div className="text-lg text-gray-800 dark:text-white">
{formatAddress(address as string)}
</div>
<button
type="button"
onClick={() => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import { Fragment, useMemo, useState } from 'react';

import { DIDDisplay } from '@/components/DIDDisplay';
import JsonModal from '@/components/JsonModal';
import { getFirstWord } from '@/utils/format';
import { formatAddress, getFirstWord } from '@/utils/format';
import {
camelToTitleCase,
convertTypes,
Expand All @@ -42,7 +42,7 @@ const AddressDisplay = ({ address }: { address: string }) => {
rel="noopener noreferrer"
className="text-md animated-transition dark:text-navy-blue-300 cursor-pointer font-normal text-gray-700 underline underline-offset-2"
>
{`${address.slice(0, 8)}...${address.slice(-8)}`}
{formatAddress(address)}
</a>
</Tooltip>
<button
Expand Down
3 changes: 2 additions & 1 deletion packages/dapp/src/components/DIDDisplay/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { Tooltip } from '@nextui-org/react';
import { useTranslations } from 'next-intl';

import { copyToClipboard } from '@/utils/string';
import { formatDid } from '@/utils/format';

export const DIDDisplay = ({ did }: { did: string }) => {
const t = useTranslations('DIDDisplay');
Expand All @@ -23,7 +24,7 @@ export const DIDDisplay = ({ did }: { did: string }) => {
rel="noopener noreferrer"
className="text-md animated-transition dark:text-navy-blue-300 cursor-pointer font-normal text-gray-700 underline underline-offset-2"
>
{did.length <= 32 ? did : `${did.slice(0, 16)}...${did.slice(-4)}`}
{formatDid(did)}
</a>
</Tooltip>
<button
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import { useTranslations } from 'next-intl';
import Link from 'next/link';

import { convertTypes } from '@/utils/string';
import { formatDid } from '@/utils/format';

interface CredentialCardProps {
vc: QueryCredentialsRequestResult;
Expand Down Expand Up @@ -47,7 +48,9 @@ const CredentialCard = ({ vc, selected }: CredentialCardProps) => {
target="_blank"
rel="noreferrer"
className="underline"
>{`${issuer.slice(0, 8)}....${issuer.slice(-4)}`}</a>
>
{formatDid(issuer)}
</a>
</Tooltip>
);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import React, { useEffect, useMemo, useState } from 'react';
import DeleteModal from '@/components/DeleteModal';
import StoreIcon from '@/components/StoreIcon';
import { useTableStore, useAuthStore, useShareModalStore } from '@/stores';
import { removeCredentialSubjectFilterString } from '@/utils/format';
import { formatDid, removeCredentialSubjectFilterString } from '@/utils/format';
import { convertTypes } from '@/utils/string';
import { LastFetched } from '../LastFetched';
import { sortCredentialList } from '../utils';
Expand Down Expand Up @@ -56,7 +56,9 @@ const IssuerCell = ({ vc }: { vc: QueryCredentialsRequestResult }) => {
target="_blank"
rel="noreferrer"
className="dark:text-orange-accent-dark dark:hover:text-orange-accent-dark/80 flex items-center justify-start text-pink-400 underline hover:text-pink-500"
>{`${issuer.slice(0, 8)}....${issuer.slice(-4)}`}</a>
>
{formatDid(issuer)}
</a>
</Tooltip>
);
};
Expand Down Expand Up @@ -164,7 +166,9 @@ const CredentialTable = ({ vcs }: CredentialTableProps) => {
target="_blank"
rel="noreferrer"
className="dark:text-orange-accent-dark dark:hover:text-orange-accent-dark/80 flex items-center justify-start text-pink-400 underline hover:text-pink-500"
>{`${subject.slice(0, 8)}....${subject.slice(-4)}`}</a>
>
{formatDid(subject)}
</a>
</Tooltip>
);
}
Expand Down
2 changes: 1 addition & 1 deletion packages/dapp/src/components/ImageLink/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export const ImageLink = ({ value }: { value: string }) => {
rel="noopener noreferrer"
className="text-md animated-transition dark:text-navy-blue-300 cursor-pointer font-normal text-gray-700 underline underline-offset-2"
>
{value.length > 32 ? value.slice('ipfs://'.length, 32) : value}
{value.length >= 32 ? value.slice('ipfs://'.length, 32) : value}
</a>
</div>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import { useTranslations } from 'next-intl';
import Link from 'next/link';

import { isPolygonVC } from '@/utils/credential';
import { formatDid } from '@/utils/format';

interface SelectedVCsTableRowProps {
vc: QueryCredentialsRequestResult;
Expand Down Expand Up @@ -71,9 +72,7 @@ const SelectedVCsTableRow = ({
rel="noreferrer"
className="dark:text-orange-accent-dark dark:hover:text-orange-accent text-pink-500 underline hover:text-pink-400"
>
{issuer.length > 20
? `${issuer.slice(0, 8)}...${issuer.slice(-4)}`
: issuer}
{formatDid(issuer)}
</a>
</Tooltip>
}
Expand Down
19 changes: 19 additions & 0 deletions packages/dapp/src/utils/format.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,3 +46,22 @@ export const removeCredentialSubjectFilterString = (

return modifiedQueryCredentialsRequestResult;
};

export const formatDid = (issuer: string) => {
if (issuer.startsWith('did:ens')) {
return issuer.split(':').slice(-1);
}
const parts = issuer.split(':');
const didMethod = parts.slice(0, -1).join(':');
const identifier = parts.slice(-1)[0];
const formattedIdentifier = identifier.startsWith('0x')
? formatAddress(identifier)
: identifier.length <= 8
? identifier
: `${identifier.slice(0, 4)}...${identifier.slice(-4)}`;
return `${didMethod}:${formattedIdentifier}`;
};

export const formatAddress = (address: string) => {
return `${address.slice(0, 5)}...${address.slice(-4)}`;
};
9 changes: 9 additions & 0 deletions packages/snap/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
# Changelog

## 1.2.2-beta.0

### Patch Changes

- [#600](https://github.com/blockchain-lab-um/masca/pull/600) [`ce8a6d5`](https://github.com/blockchain-lab-um/masca/commit/ce8a6d58aa7986e6b2064cc754cada5956f89c0d) Thanks [@martines3000](https://github.com/martines3000)! - Resolve issue with importing old state.

- Updated dependencies [[`ce8a6d5`](https://github.com/blockchain-lab-um/masca/commit/ce8a6d58aa7986e6b2064cc754cada5956f89c0d)]:
- @blockchain-lab-um/masca-types@1.3.2-beta.0

## 1.2.1

### Patch Changes
Expand Down
4 changes: 2 additions & 2 deletions packages/snap/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@blockchain-lab-um/masca",
"version": "1.2.1",
"version": "1.2.2-beta.0",
"description": "Snap for managing VCs and VPs in MetaMask",
"keywords": [
"MetaMask",
Expand Down Expand Up @@ -56,7 +56,7 @@
"dependencies": {
"@0xpolygonid/js-sdk": "1.0.3",
"@blockchain-lab-um/did-provider-key": "1.0.8",
"@blockchain-lab-um/masca-types": "1.3.1",
"@blockchain-lab-um/masca-types": "1.3.2-beta.0",
"@blockchain-lab-um/oidc-client-plugin": "0.3.1",
"@blockchain-lab-um/oidc-types": "0.0.8",
"@blockchain-lab-um/utils": "1.3.8",
Expand Down
4 changes: 2 additions & 2 deletions packages/snap/snap.manifest.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"version": "1.2.1",
"version": "1.2.2-beta.0",
"description": "Snap for managing VCs and VPs in MetaMask",
"proposedName": "Masca",
"repository": {
Expand All @@ -26,7 +26,7 @@
"./files/circuits/credentialAtomicQuerySigV2/circuit_final.zkey",
"./files/circuits/credentialAtomicQuerySigV2/verification_key.json"
],
"shasum": "Mzhh6mjzfRBIjHzxXJCbQP6pWvWEvSXgMuRIdonGvkQ="
"shasum": "eNUSDM+FIRe65Nd48dXam1yJhTxHo9x2gHiPm5JrsDU="
},
"initialPermissions": {
"endowment:ethereum-provider": {},
Expand Down
Loading
Loading