Skip to content

Commit

Permalink
Support hedera did (#852)
Browse files Browse the repository at this point in the history
Signed-off-by: Himalayan Dev <[email protected]>
  • Loading branch information
himalayan-dev authored Dec 12, 2024
1 parent f8a9584 commit 1831acd
Show file tree
Hide file tree
Showing 151 changed files with 6,033 additions and 7,862 deletions.
1 change: 1 addition & 0 deletions packages/hedera-identify-snap/.eslintignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
node_modules
.eslintrc.js
packages/snap/**
packages/site/**
1 change: 1 addition & 0 deletions packages/hedera-identify-snap/packages/site/.env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
GATSBY_GOOGLE_DRIVE_CLIENT_ID=""
8 changes: 7 additions & 1 deletion packages/hedera-identify-snap/packages/site/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,12 @@ This project was bootstrapped with [Gatsby](https://www.gatsbyjs.com/).

## Available Scripts

Copy the .env.example file and update the value of `GATSBY_GOOGLE_DRIVE_CLIENT_ID` if you're testing `Configure Google Account API` from the example site:

```sh
cp .env.example .env.development
```

In the project directory, you can run:

### `yarn start`
Expand Down Expand Up @@ -40,4 +46,4 @@ To learn more visit [Gatsby documentation](https://www.gatsbyjs.com/docs/how-to/

You can learn more in the [Gatsby documentation](https://www.gatsbyjs.com/docs/).

To learn React, check out the [React documentation](https://reactjs.org/).
To learn React, check out the [React documentation](https://reactjs.org/).
2 changes: 1 addition & 1 deletion packages/hedera-identify-snap/packages/site/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
},
"dependencies": {
"@metamask/providers": "^17.2.0",
"@react-oauth/google": "^0.7.0",
"@react-oauth/google": "^0.12.1",
"@veramo/core": "5.1.2",
"axios": "^1.2.4",
"bootstrap": "^5.3.3",
Expand Down
5 changes: 5 additions & 0 deletions packages/hedera-identify-snap/packages/site/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,11 @@ export type AppProps = {
export const App: FunctionComponent<AppProps> = ({ children }) => {
const toggleTheme = useContext(ToggleThemeContext);

console.log(
'process.env.GATSBY_GOOGLE_DRIVE_CLIENT_ID',
process.env.GATSBY_GOOGLE_DRIVE_CLIENT_ID,
);

return (
<>
<GlobalStyle />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -138,15 +138,11 @@ type ButtonProps = ComponentProps<typeof Button> & {
buttonText: string;
};

export const SendHelloButton = ({
loading,
buttonText,
...props
}: ButtonProps) => {
export const SendHelloButton = ({ loading, ...props }: ButtonProps) => {
return (
<Button {...props}>
{loading && <Spinner animation="border" style={{ marginRight: 8 }} />}
{buttonText}
{props.buttonText}
</Button>
);
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ export const Card = ({ content, disabled = false, fullWidth }: CardProps) => {
const { title, description, button, form } = content;
return (
<CardWrapper fullWidth={fullWidth} disabled={disabled}>
<Title>{title}</Title>
{title && <Title>{title}</Title>}
<Description>{description}</Description>
{form}
{button}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,9 @@ import {
MetamaskActions,
MetaMaskContext,
} from '../../contexts/MetamaskContext';
import { connectSnap, getSnap, getThemePreference } from '../../utils';
import { connectSnap, getSnap } from '../../utils';
import { HeaderButtons } from './Buttons';
import { SnapLogo } from './SnapLogo';
import { Toggle } from './Toggle';

const HeaderWrapper = styled.header`
display: flex;
Expand Down Expand Up @@ -88,13 +87,15 @@ export const Header = ({
<HeaderWrapper>
<LogoWrapper>
<SnapLogo color={theme.colors.icon.default} size={36} />
<Title>identify-snap</Title>
<Title>hedera-identify-snap</Title>
</LogoWrapper>
<RightContainer>
<Toggle
onToggle={handleToggleClick}
defaultChecked={getThemePreference()}
/>
{/* {
<Toggle
onToggle={handleToggleClick}
defaultChecked={getThemePreference()}
/>
} */}
<HeaderButtons state={state} onConnectClick={handleConnectClick} />
</RightContainer>
</HeaderWrapper>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,6 @@ const ConfigureGoogleAccount: FC<Props> = ({
externalAccountRef.current?.handleGetAccountParams();

const configured = await configureGoogleAccount(
metamaskAddress,
tokenResponse.access_token,
externalAccountParams,
);
Expand Down Expand Up @@ -91,7 +90,7 @@ const ConfigureGoogleAccount: FC<Props> = ({
button: (
<SendHelloButton
buttonText="Configure Google Account"
onClick={handleConfigureGoogleAccount}
onClick={() => handleConfigureGoogleAccount()}
disabled={!state.installedSnap}
loading={loading}
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,6 @@ const CreateVC: FC<Props> = ({ setMetamaskAddress, setCurrentChainId }) => {
};
const credTypes = ['ProfileNamesCredential'];
const saved: CreateVCResponseResult = (await createVC(
metamaskAddress,
vcKey,
vcValue,
options,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,10 @@ import {
} from '../../contexts/MetamaskContext';
import { VcContext } from '../../contexts/VcContext';
import useModal from '../../hooks/useModal';
import { IDataManagerClearResult } from '../../types/veramo';
import {
IDataManagerClearArgs,
IDataManagerClearResult,
} from '../../types/veramo';
import {
deleteAllVCs,
getCurrentMetamaskAccount,
Expand Down Expand Up @@ -72,9 +75,8 @@ const DeleteAllVCs: FC<Props> = ({ setMetamaskAddress, setCurrentChainId }) => {
// If you want to remove the VCs from multiple stores, you can pass an array like so:
// store: ['snap', 'googleDrive'],
...(selectedStore.length ? { store: selectedStore } : {}),
};
} as IDataManagerClearArgs;
const isRemoved = (await deleteAllVCs(
metamaskAddress,
options,
externalAccountParams,
)) as IDataManagerClearResult[];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,10 +63,7 @@ const GetAccountInfo: FC<Props> = ({
const externalAccountParams =
externalAccountRef.current?.handleGetAccountParams();

const accountInfo = await getAccountInfo(
metamaskAddress,
externalAccountParams,
);
const accountInfo = await getAccountInfo(externalAccountParams);
console.log(`Your account info:`, accountInfo);
setAccountInfo(accountInfo as PublicAccountInfo);
showModal({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,6 @@ const GetAllVCs: FC<Props> = ({ setMetamaskAddress, setCurrentChainId }) => {
returnStore: true,
};
const vcs = (await getVCs(
metamaskAddress,
undefined,
options,
externalAccountParams,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,6 @@ const GetSpecificVC: FC<Props> = ({
returnStore: true,
};
const vcs = (await getVCs(
metamaskAddress,
filter,
options,
externalAccountParams,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,6 @@ const GetVP: FC<Props> = ({ setMetamaskAddress, setCurrentChainId }) => {
console.log('vcIds: ', vcId);
// console.log('vc: ', vc);
const vp = (await createVP(
metamaskAddress,
{
// vcIds: vcId.trim().split(','),
vcs: [vc as W3CVerifiableCredential],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,6 @@ const RemoveVC: FC<Props> = ({ setMetamaskAddress, setCurrentChainId }) => {
} as IDataManagerDeleteArgs;
console.log('vcIdsToBeRemoved: ', vcIdsToBeRemoved);
const isRemoved = (await removeVC(
metamaskAddress,
id,
options,
externalAccountParams,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ const ResolveDID: FC<Props> = ({ setMetamaskAddress, setCurrentChainId }) => {
const externalAccountParams =
externalAccountRef.current?.handleGetAccountParams();

const doc = await resolveDID(metamaskAddress, did, externalAccountParams);
const doc = await resolveDID(did, externalAccountParams);
console.log(`Your DID document is : ${JSON.stringify(doc, null, 4)}`);
showModal({
title: 'Resolve DID',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ const SendHelloHessage: FC<Props> = ({
setMetamaskAddress(metamaskAddress);
setCurrentChainId(await getCurrentNetwork());

await sendHello(metamaskAddress);
await sendHello();
} catch (e) {
console.error(e);
dispatch({ type: MetamaskActions.SetError, payload: e });
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ const SwitchDIDMethod: FC<Props> = ({
setMetamaskAddress(metamaskAddress);
setCurrentChainId(await getCurrentNetwork());

const switched = await switchDIDMethod(metamaskAddress, didMethod);
const switched = await switchDIDMethod(didMethod);
console.log(`DID Method switched : ${switched}`);
} catch (e) {
console.error(e);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ const SyncGoogleVCs: FC<Props> = ({
const externalAccountParams =
externalAccountRef.current?.handleGetAccountParams();

const resp = await syncGoogleVCs(metamaskAddress, externalAccountParams);
const resp = await syncGoogleVCs(externalAccountParams);
console.log('Synced with google drive: ', resp);
} catch (e) {
console.error(e);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ const ToggleMetamaskPopups: FC<Props> = ({
setMetamaskAddress(metamaskAddress);
setCurrentChainId(await getCurrentNetwork());

await togglePopups(metamaskAddress);
await togglePopups();
} catch (e) {
console.error(e);
dispatch({ type: MetamaskActions.SetError, payload: e });
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ const VerifyVC: FC<Props> = ({ setMetamaskAddress, setCurrentChainId }) => {
setMetamaskAddress(metamaskAddress);
setCurrentChainId(await getCurrentNetwork());

const verified = await verifyVC(metamaskAddress, vc);
const verified = await verifyVC(vc);
console.log('VC Verified: ', verified);
showModal({ title: 'Verify VC', content: `VC Verified: ${verified}` });
} catch (e) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ const VerifyVP: FC<Props> = ({ setMetamaskAddress, setCurrentChainId }) => {
setMetamaskAddress(metamaskAddress);
setCurrentChainId(await getCurrentNetwork());

const verified = await verifyVP(metamaskAddress, vp);
const verified = await verifyVP(vp);
console.log('VP Verified: ', verified);
showModal({
title: 'Verify VP',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
*/

export { ConfigureGoogleAccount } from './ConfigureGoogleAccount';
export { ConnectIdentitySnap } from './ConnectIdentitySnap';
export { ConnectIdentitySnap } from './ConnectIdentifySnap';
export { CreateVC } from './CreateVC';
export { DeleteAllVCs } from './DeleteAllVCs';
export { GetAccountInfo } from './GetAccountInfo';
Expand Down
Loading

0 comments on commit 1831acd

Please sign in to comment.