Skip to content

Commit

Permalink
feat: remove goerli (#554)
Browse files Browse the repository at this point in the history
Signed-off-by: Urban Vidovič <[email protected]>
Co-authored-by: Urban Vidovič <[email protected]>
  • Loading branch information
martines3000 and pseudobun authored Jan 26, 2024
1 parent b688093 commit af204fc
Show file tree
Hide file tree
Showing 28 changed files with 89 additions and 787 deletions.
5 changes: 5 additions & 0 deletions .changeset/five-planets-wave.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@blockchain-lab-um/masca-types': patch
---

Remove support for Goerli.
5 changes: 5 additions & 0 deletions .changeset/light-candles-accept.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@blockchain-lab-um/dapp': patch
---

Remove support for Goerli.
5 changes: 5 additions & 0 deletions .changeset/sixty-ties-relate.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@blockchain-lab-um/masca': patch
---

Remove support for Goerli.
1 change: 0 additions & 1 deletion packages/dapp/.env.example
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ GOOGLE_DRIVE_FILE_NAME=masca-backup-
MAINNET_RPC_URL=
SEPOLIA_RPC_URL=
IPFS_GATEWAY=
GOERLI_RPC_URL=
POLYGON_RPC_URL=
POLYGON_MUMBAI_RPC_URL=

Expand Down
3 changes: 1 addition & 2 deletions packages/dapp/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,9 @@
"start": "next start"
},
"dependencies": {
"@blockchain-lab-um/did-provider-key": "1.0.7",
"@blockchain-lab-um/did-provider-key": "1.0.8-beta.0",
"@blockchain-lab-um/masca-connector": "1.2.2-beta.0",
"@blockchain-lab-um/oidc-types": "0.0.8",
"@ethersproject/providers": "^5.7.2",
"@headlessui/react": "^1.7.17",
"@heroicons/react": "^2.0.18",
"@nextui-org/react": "^2.2.9",
Expand Down
6 changes: 5 additions & 1 deletion packages/dapp/src/components/AppNavbar/NavConnection.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,11 @@ export const NavConnection = () => {
shadow="none"
variant="method"
items={getAvailableNetworksList(currMethod)}
selected={selectedNetwork}
selected={
selectedNetwork === 'Goerli'
? t('unsupported-method')
: selectedNetwork
}
setSelected={setNetwork}
/>
</div>
Expand Down
33 changes: 30 additions & 3 deletions packages/dapp/src/components/MascaProvider/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@

import { useEffect } from 'react';
import { enableMasca, isError } from '@blockchain-lab-um/masca-connector';
import { useAccount, useChainId } from 'wagmi';
import { useTranslations } from 'next-intl';
import { useAccount, useChainId, useSwitchChain } from 'wagmi';

import { useMascaStore } from '@/stores';
import { useMascaStore, useToastStore } from '@/stores';
import { useAuthStore } from '@/stores/authStore';

const snapId =
Expand All @@ -15,6 +16,8 @@ const snapId =
const MascaProvider = () => {
const { address, isConnected } = useAccount();
const chainId = useChainId();
const { switchChainAsync } = useSwitchChain();
const t = useTranslations('MascaProvider');

const {
api,
Expand Down Expand Up @@ -103,7 +106,31 @@ const MascaProvider = () => {

useEffect(() => {
if (!address) return;
enableMascaHandler().catch((err) => {
enableMascaHandler().catch(async (err) => {
// FIXME: this is only a temporary solution
// eslint-disable-next-line @typescript-eslint/no-unsafe-call
if (err.message.toLowerCase().includes('unsupported network')) {
useToastStore.setState({
open: true,
title: t('unsupported-network'),
text: t('unsupported-network-description'),
type: 'error',
loading: false,
link: null,
});
await switchChainAsync({ chainId: 1 });
await enableMascaHandler();
return;
}
setTimeout(() => {
useToastStore.setState({
open: true,
title: t('connection-failed'),
type: 'error',
loading: false,
link: null,
});
}, 200);
console.error(err);
});
}, [isConnected, address]);
Expand Down
5 changes: 2 additions & 3 deletions packages/dapp/src/config/wagmiConfig.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
import { createConfig, http } from 'wagmi';
import { goerli, mainnet, polygon, polygonMumbai, sepolia } from 'wagmi/chains';
import { mainnet, polygon, polygonMumbai, sepolia } from 'wagmi/chains';
import { injected } from 'wagmi/connectors';

export const config = createConfig({
chains: [mainnet, sepolia, goerli, polygon, polygonMumbai],
chains: [mainnet, sepolia, polygon, polygonMumbai],
connectors: [injected({ target: 'metaMask' })],
ssr: true,
transports: {
[mainnet.id]: http(),
[sepolia.id]: http(),
[goerli.id]: http(),
[polygon.id]: http(),
[polygonMumbai.id]: http(),
},
Expand Down
5 changes: 5 additions & 0 deletions packages/dapp/src/messages/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,11 @@
"select-method": "Select a method",
"unsupported-network": "Unsupported network"
},
"MascaProvider": {
"connection-failed": "Failed to connect to Masca",
"unsupported-network": "Unsupported network",
"unsupported-network-description": "Please approve the network switch."
},
"ChooseDeviceView": {
"connect": "Connect Wallet to see more options...",
"primary-has-camera": "This Device can scan/upload QR codes",
Expand Down
5 changes: 2 additions & 3 deletions packages/dapp/src/utils/networks.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
export const NETWORKS: Record<string, string> = {
'0x1': 'Ethereum',
'0xaa36a7': 'Sepolia',
'0x5': 'Goerli Testnet',
'0x89': 'Polygon',
'0x13881': 'Polygon Mumbai',
};
Expand All @@ -10,8 +9,8 @@ export const NETWORKS_BY_DID: Record<string, string[]> = {
'did:ethr': ['*'],
'did:pkh': ['0x1', '0x89'],
'did:ens': ['0x1'],
'did:polygonid': ['0x1', '0x5', '0x89', '0x13881'],
'did:iden3': ['0x1', '0x5', '0x89', '0x13881'],
'did:polygonid': ['0x1', '0x89', '0x13881'],
'did:iden3': ['0x1', '0x89', '0x13881'],
};

export function getAvailableNetworksList(method: string): string[] {
Expand Down
2 changes: 1 addition & 1 deletion packages/docs/docs/integrate-masca/masca-connector.md
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ const payload: MinimalUnsignedCredential = {
type: ['VerifiableCredential', 'Test Certificate'],
credentialSubject: {
accomplishmentType: 'Test Certificate',
id: 'did:ethr:goerli:0x123...321',
id: 'did:ethr:sepolia:0x123...321',
},
credentialSchema: {
id: 'https://beta.api.schemas.serto.id/v1/public/program-completion-certificate/1.0/json-schema.json',
Expand Down
2 changes: 1 addition & 1 deletion packages/docs/docs/integrate-masca/rpc-methods.md
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ const payload: MinimalUnsignedCredential = {
type: ['VerifiableCredential', 'TestCertificate'],
credentialSubject: {
accomplishmentType: 'Test Certificate',
id: 'did:ethr:goerli:0x123...321',
id: 'did:ethr:sepolia:0x123...321',
},
credentialSchema: {
id: 'https://beta.api.schemas.serto.id/v1/public/program-completion-certificate/1.0/json-schema.json',
Expand Down
Loading

0 comments on commit af204fc

Please sign in to comment.