-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Himalayan Dev <[email protected]>
- Loading branch information
1 parent
70fccd3
commit 0529234
Showing
80 changed files
with
1,592 additions
and
1,858 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -26,30 +26,8 @@ | |
"start": "yarn workspaces foreach --parallel --interlaced --verbose run start", | ||
"test": "yarn workspaces foreach --parallel --interlaced --verbose run test" | ||
}, | ||
"devDependencies": { | ||
"@metamask/eslint-config": "^11.1.0", | ||
"@metamask/eslint-config-jest": "^11.1.0", | ||
"@metamask/eslint-config-nodejs": "^11.1.0", | ||
"@metamask/eslint-config-typescript": "^11.1.0", | ||
"@typescript-eslint/eslint-plugin": "^5.57.1", | ||
"@typescript-eslint/parser": "^5.57.1", | ||
"eslint": "^8.38.0", | ||
"eslint-config-prettier": "^9.0.0", | ||
"eslint-plugin-import": "^2.28.1", | ||
"eslint-plugin-jest": "^27.4.0", | ||
"eslint-plugin-jsdoc": "^46.8.1", | ||
"eslint-plugin-node": "^11.1.0", | ||
"eslint-plugin-prettier": "^4.2.1", | ||
"prettier": "^3.0.3", | ||
"prettier-plugin-packagejson": "^2.4.5", | ||
"typescript": "^5.2.2" | ||
}, | ||
"packageManager": "[email protected]", | ||
"engines": { | ||
"node": ">=18.13.0" | ||
}, | ||
"dependencies": { | ||
"@yarnpkg/plugin-workspace-tools": "^4.1.0", | ||
"protobufjs": "^7.4.0" | ||
} | ||
} |
178 changes: 0 additions & 178 deletions
178
packages/hedera-identify-snap/packages/site/src/components/cards/CreateNewHederaAccount.tsx
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
119 changes: 119 additions & 0 deletions
119
packages/hedera-identify-snap/packages/site/src/components/cards/SwitchDIDMethod.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,119 @@ | ||
/*- | ||
* | ||
* Hedera Identify Snap | ||
* | ||
* Copyright (C) 2024 Hedera Hashgraph, LLC | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
* | ||
*/ | ||
|
||
import { FC, useContext, useState } from 'react'; | ||
import Form from 'react-bootstrap/esm/Form'; | ||
import { | ||
MetaMaskContext, | ||
MetamaskActions, | ||
} from '../../contexts/MetamaskContext'; | ||
import { | ||
getCurrentMetamaskAccount, | ||
getCurrentNetwork, | ||
shouldDisplayReconnectButton, | ||
switchDIDMethod, | ||
} from '../../utils'; | ||
import { Card, SendHelloButton } from '../base'; | ||
|
||
type Props = { | ||
setMetamaskAddress: React.Dispatch<React.SetStateAction<string>>; | ||
setCurrentChainId: React.Dispatch<React.SetStateAction<string>>; | ||
}; | ||
|
||
const SwitchDIDMethod: FC<Props> = ({ | ||
setMetamaskAddress, | ||
setCurrentChainId, | ||
}) => { | ||
const [state, dispatch] = useContext(MetaMaskContext); | ||
const [didMethod, setDidMethod] = useState('did:pkh'); // Default method is 'did:pkh' | ||
const [loading, setLoading] = useState(false); | ||
|
||
const handleswitchDIDMethodClick = async () => { | ||
setLoading(true); | ||
try { | ||
const metamaskAddress = await getCurrentMetamaskAccount(); | ||
setMetamaskAddress(metamaskAddress); | ||
setCurrentChainId(await getCurrentNetwork()); | ||
|
||
const switched = await switchDIDMethod(metamaskAddress, didMethod); | ||
console.log(`DID Method switched : ${switched}`); | ||
} catch (e) { | ||
console.error(e); | ||
dispatch({ type: MetamaskActions.SetError, payload: e }); | ||
} | ||
setLoading(false); | ||
}; | ||
|
||
return ( | ||
<Card | ||
content={{ | ||
title: 'switchDIDMethod', | ||
description: 'Select and switch DID Method to use', | ||
form: ( | ||
<> | ||
<Form.Check | ||
type="radio" | ||
label="did:pkh (default)" | ||
name="didMethod" | ||
value="did:pkh" | ||
checked={didMethod === 'did:pkh'} | ||
onChange={(e) => setDidMethod(e.target.value)} | ||
style={{ marginBottom: 8 }} | ||
/> | ||
<Form.Check | ||
type="radio" | ||
label="did:key" | ||
name="didMethod" | ||
value="did:key" | ||
checked={didMethod === 'did:key'} | ||
onChange={(e) => setDidMethod(e.target.value)} | ||
style={{ marginBottom: 8 }} | ||
/> | ||
<Form.Check | ||
type="radio" | ||
label="did:hedera" | ||
name="didMethod" | ||
value="did:hedera" | ||
checked={didMethod === 'did:hedera'} | ||
onChange={(e) => setDidMethod(e.target.value)} | ||
style={{ marginBottom: 8 }} | ||
/> | ||
</> | ||
), | ||
button: ( | ||
<SendHelloButton | ||
buttonText="Switch DID Method" | ||
onClick={handleswitchDIDMethodClick} | ||
disabled={!state.installedSnap} | ||
loading={loading} | ||
/> | ||
), | ||
}} | ||
disabled={!state.installedSnap} | ||
fullWidth={ | ||
state.isFlask && | ||
Boolean(state.installedSnap) && | ||
!shouldDisplayReconnectButton(state.installedSnap) | ||
} | ||
/> | ||
); | ||
}; | ||
|
||
export { SwitchDIDMethod }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.