Skip to content

Commit

Permalink
tslint
Browse files Browse the repository at this point in the history
  • Loading branch information
nvonpentz committed Aug 5, 2022
1 parent 55dc962 commit aefca33
Show file tree
Hide file tree
Showing 7 changed files with 16 additions and 26 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ export type EthSignPersonalMessageCommand = CommandMessage & {
}

// SignEip712Message command
export type EthSignEip712MessageResponsePayload = EthSignPersonalMessageResponsePayload;
export type EthSignEip712MessageResponsePayload = EthSignPersonalMessageResponsePayload

export type EthSignEip712MessageResponse = CommandMessage & {
payload: EthSignEip712MessageResponsePayload | LedgerError
Expand All @@ -76,4 +76,4 @@ export type EthSignEip712MessageCommand = CommandMessage & {
}

export type EthLedgerFrameCommand = EthGetAccountCommand | EthSignTransactionCommand | EthSignPersonalMessageCommand | EthSignEip712MessageCommand
export type EthLedgerFrameResponse = EthGetAccountResponse | EthSignTransactionResponse | EthSignPersonalMessageResponse | EthSignEip712MessageResponse
export type EthLedgerFrameResponse = EthGetAccountResponse | EthSignTransactionResponse | EthSignPersonalMessageResponse | EthSignEip712MessageResponse
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ export class EthereumLedgerUntrustedMessagingTransport extends LedgerUntrustedMe
success: true,
publicKey: result.publicKey,
address: result.address,
chainCode: result.chainCode,
chainCode: result.chainCode
}
const response: EthGetAccountResponse = {
id: command.id,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { BraveWallet } from '../../../constants/types'

let uuid = 0
window.crypto = {
randomUUID (): string {
randomUUID (): string {
return uuid++
}
}
Expand Down Expand Up @@ -232,7 +232,7 @@ test('signTransaction success', async () => {
success: true,
v: 'v',
r: 'r',
s: 's',
s: 's'
}
}
keyring.transport.addSendCommandResponse(signTransactionResponse)
Expand All @@ -246,7 +246,7 @@ test('signTransaction success', async () => {
payload: {
v: signTransactionResponse.payload.v,
r: signTransactionResponse.payload.r,
s: signTransactionResponse.payload.s,
s: signTransactionResponse.payload.s
}
}
expect(result).toEqual(expectedResult)
Expand Down Expand Up @@ -302,10 +302,7 @@ test('signPersonalMessage success with padding v<27', async () => {
}
keyring.transport.addSendCommandResponse(unlockSuccessReponse)
const responsePayload: SignTransactionResponsePayload = {
payload: {
success: true,
v: 0, r: 'b68983', s: 'r68983'
}
payload: { success: true, v: 0, r: 'b68983', s: 'r68983' }
}
keyring.transport.addSendCommandResponse(responsePayload)
const result: SignHardwareOperationResult = await keyring.signPersonalMessage(
Expand All @@ -324,18 +321,15 @@ test('signPersonalMessage success with padding v>=27', async () => {
}
keyring.transport.addSendCommandResponse(unlockSuccessReponse)
const responsePayload: SignTransactionResponsePayload = {
payload: {
success: true,
v: 28, r: 'b68983', s: 'r68983'
}
payload: { success: true, v: 28, r: 'b68983', s: 'r68983' }
}
keyring.transport.addSendCommandResponse(responsePayload)
const result: SignHardwareOperationResult = await keyring.signPersonalMessage(
"m/44'/60'/0'/0/0",
'message'
)

const expectedResult = { payload: '0xb68983r6898301', success: true }
const expectedResult = { payload: '0xb68983r6898301', success: true }
expect(result).toEqual(expectedResult)
})

Expand Down Expand Up @@ -389,18 +383,15 @@ test('signEip712Message success', async () => {
keyring.transport.addSendCommandResponse(unlockSuccessReponse)

const responsePayload: SignTransactionResponsePayload = {
payload: {
success: true,
v: 28, r: 'b68983', s: 'r68983'
}
payload: { success: true, v: 28, r: 'b68983', s: 'r68983' }
}
keyring.transport.addSendCommandResponse(responsePayload)
const result: SignHardwareOperationResult = await keyring.signPersonalMessage(
"m/44'/60'/0'/0/0",
'message'
)

const expectedResult = { payload: '0xb68983r6898301', success: true }
const expectedResult = { payload: '0xb68983r6898301', success: true }
expect(result).toEqual(expectedResult)
})

Expand Down Expand Up @@ -428,4 +419,3 @@ test('signEip712Message failure after successful unlock', async () => {
}
expect(result).toEqual(expectedResult)
})

Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ export default class EthereumLedgerBridgeKeyring extends LedgerBridgeKeyring imp
return { success: true, payload: signature }
}

signEip712Message = async (path: string, domainSeparatorHex: string, hashStructMessageHex: string): Promise<SignHardwareOperationResult>=> {
signEip712Message = async (path: string, domainSeparatorHex: string, hashStructMessageHex: string): Promise<SignHardwareOperationResult> => {
const result = await this.unlock()
if (!result.success) {
return result
Expand Down Expand Up @@ -158,7 +158,7 @@ export default class EthereumLedgerBridgeKeyring extends LedgerBridgeKeyring imp
const signature = `0x${result.r}${result.s}${v}`
return signature
}

private readonly getAccountsFromDevice = async (paths: string[], skipZeroPath: boolean, scheme: string): Promise<GetAccountsHardwareOperationResult> => {
let accounts = []
const zeroPath = this.getPathForIndex(0, scheme)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export enum LedgerCommand {
AuthorizationSuccess = 'authorization-success' // Sent by the frame to the parent context
}

// LedgerBrigeErrorCodes are errors related to the configuring
// LedgerBrigeErrorCodes are errors related to the configuring
// and running of postMessages between window objects
export enum LedgerBridgeErrorCodes {
BridgeNotReady = 0,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,4 @@ export type SolSignTransactionCommand = CommandMessage & {
}

export type SolLedgerFrameCommand = SolGetAccountCommand | SolSignTransactionCommand
export type SolLedgerFrameResponse = SolGetAccountResponse | SolSignTransactionResponse
export type SolLedgerFrameResponse = SolGetAccountResponse | SolSignTransactionResponse
2 changes: 1 addition & 1 deletion components/brave_wallet_ui/ledger/ledger.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ const setUpAuthorizeButtonListner = (targetUrl: string, coinType: BraveWallet.Co
}

const getUntrustedMessagingTransport = (coinType: BraveWallet.CoinType, targetUrl: string): LedgerUntrustedMessagingTransport => {
switch(coinType) {
switch (coinType) {
case BraveWallet.CoinType.SOL:
return new SolanaLedgerUntrustedMessagingTransport(window.parent, targetUrl)
case BraveWallet.CoinType.ETH:
Expand Down

0 comments on commit aefca33

Please sign in to comment.