-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #115 from consensusnetworks/feature/ledger-emulator
Add ledger emulator
- Loading branch information
Showing
32 changed files
with
1,083 additions
and
100 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
[submodule "scripts/ledger/resources/app-bitcoin"] | ||
path = scripts/ledger/resources/app-bitcoin | ||
url = https://github.com/LedgerHQ/app-bitcoin-new.git | ||
[submodule "scripts/ledger/resources/app-ethereum"] | ||
path = scripts/ledger/resources/app-ethereum | ||
url = https://github.com/LedgerHQ/app-ethereum.git | ||
[submodule "scripts/ledger/resources/app-solana"] | ||
path = scripts/ledger/resources/app-solana | ||
url = https://github.com/LedgerHQ/app-solana.git | ||
[submodule "scripts/ledger/resources/speculos"] | ||
path = scripts/ledger/resources/speculos | ||
url = https://github.com/LedgerHQ/speculos.git |
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
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,26 @@ | ||
import SpeculosHttpTransport from '@casimir/hw-transport-speculos' | ||
import TransportWebHID from '@ledgerhq/hw-transport-webhid' | ||
import Eth from '@ledgerhq/hw-app-eth' | ||
|
||
export default function useLedger() { | ||
|
||
const bip32Path = '44\'/60\'/0\'/0/0' | ||
|
||
async function getLedgerEthSigner() { | ||
const transport = await _getLedgerTransport() | ||
return new Eth(transport) | ||
} | ||
|
||
async function _getLedgerTransport() { | ||
if (import.meta.env.PUBLIC_SPECULOS_PORT) { | ||
return await SpeculosHttpTransport.open(`http://127.0.0.1:${import.meta.env.PUBLIC_SPECULOS_PORT}`) | ||
} else { | ||
return await TransportWebHID.create() | ||
} | ||
} | ||
|
||
return { | ||
bip32Path, | ||
getLedgerEthSigner | ||
} | ||
} |
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 |
---|---|---|
@@ -1,2 +1,2 @@ | ||
import { BrowserProviders } from '@/interfaces/BrowserProviders' | ||
export type ProviderString = keyof BrowserProviders | 'IoPay' | '' | ||
export type ProviderString = keyof BrowserProviders | 'IoPay' | 'Ledger' |'' |
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,2 @@ | ||
node_modules/ | ||
dist/ |
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,13 @@ | ||
{ | ||
"name": "@casimir/hw-transport-speculos", | ||
"version": "0.0.1", | ||
"main": "src/index.ts", | ||
"dependencies": { | ||
"@ledgerhq/hw-transport": "^6.27.2" | ||
}, | ||
"scripts": { | ||
"dev": "npx esno src/index.ts", | ||
"build": "esbuild src/index.ts --bundle --minify --sourcemap --platform=node --target=esnext --outfile=dist/index.js", | ||
"test": "echo \"Error: no test specified\" && exit 1" | ||
} | ||
} |
Oops, something went wrong.