-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Feat: There were no ledger demo in Toolshed Solution: Add Ledger connection example in Toolshed
- Loading branch information
Showing
6 changed files
with
76 additions
and
21 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
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
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,38 @@ | ||
import { ethereum } from '../../../../src/accounts/providers/Ledger' | ||
import { HardwareChains } from '../model/chains' | ||
import { dispatchAndConsume } from '../model/componentProps' | ||
import { Actions } from '../reducer' | ||
|
||
|
||
function HardwareConfig({ dispatch, state } : dispatchAndConsume) { | ||
const getAccountClass = () => ( | ||
state.selectedChain === HardwareChains.Ethereum ? [ethereum, null] | ||
: [null, null] | ||
) | ||
|
||
const connectToHardware = async () => { | ||
const [_account, provider] = getAccountClass(); | ||
|
||
if(_account === null) | ||
return | ||
|
||
try{ | ||
const account = await _account.GetAccountFromLedger() | ||
dispatch({ | ||
type: Actions.SET_ACCOUNT, | ||
payload: account | ||
}) | ||
} | ||
catch(err){ | ||
alert(err) | ||
} | ||
} | ||
|
||
return ( | ||
<div> | ||
<button onClick={connectToHardware}>Connect to Hardware</button> | ||
</div> | ||
) | ||
} | ||
|
||
export default HardwareConfig |
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
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
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