Skip to content

Commit

Permalink
feat: inject TransportWebHID, add unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
dawidsowardx committed Apr 19, 2023
1 parent 1842c3c commit 7509193
Show file tree
Hide file tree
Showing 10 changed files with 570 additions and 191 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,4 @@ dist-ssr
*.sw?

.nvmrc
coverage/
12 changes: 6 additions & 6 deletions src/chrome/dev-tools/components/LedgerSimulator.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ export const LedgerSimulator = () => {
const [seed, setSeed] = useState<string>(
'equip will roof matter pink blind book anxiety banner elbow sun young'
)
const [message, setMessage] = useState()
const [derivationPaths, setDerivationPaths] = useState<string[]>()
const [interactionId, setInteractionId] = useState<string>(
crypto.randomUUID()
Expand All @@ -42,15 +41,16 @@ export const LedgerSimulator = () => {
const onMessage = (message: any) => {
if (message?.discriminator !== 'walletToLedger') return

setMessage(message)
if (message?.data?.interactionId) {
setInteractionId(message.data.interactionId)
}

switch (message.data.discriminator) {
case 'importOlympiaDevice':
setDerivationPaths(message.data.derivationPaths.map((path: string) => path.split('H').join(`'`)))
return
if (message?.data?.discriminator === 'importOlympiaDevice') {
setDerivationPaths(
message.data.derivationPaths.map((path: string) =>
path.split('H').join(`'`)
)
)
}
}

Expand Down
8 changes: 4 additions & 4 deletions src/chrome/dev-tools/example.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ export const getDerivePublicKeyPayload = () => ({
},
ledgerDevice: {
name: 'My Ledger Device',
model: '',
model: 'nanoS',
id: '305495ba0fdfd3c400568ce7a2f4e4d446f3cd8b305a9d7b43f4e4257d71a248',
},
})
Expand All @@ -48,11 +48,11 @@ export const getSignTransactionPayload = () => ({
},
ledgerDevice: {
name: 'My Ledger Device',
model: '',
model: 'nanoS',
id: '305495ba0fdfd3c400568ce7a2f4e4d446f3cd8b305a9d7b43f4e4257d71a248',
},
compiledTransactionIntent: compiledTxHex.createAccount,
mode: 'verbose | summary',
mode: 'verbose',
})

export const getSignChallengePayload = () => ({
Expand All @@ -64,7 +64,7 @@ export const getSignChallengePayload = () => ({
},
ledgerDevice: {
name: 'My Ledger Device',
model: '',
model: 'nanoS',
id: '305495ba0fdfd3c400568ce7a2f4e4d446f3cd8b305a9d7b43f4e4257d71a248',
},
challenge: '',
Expand Down
Loading

0 comments on commit 7509193

Please sign in to comment.