@@ -10,7 +10,7 @@ import {
10
10
import TransportNodeHid from '@ledgerhq/hw-transport-node-hid'
11
11
import Web3 from 'web3'
12
12
import { meetsVersionRequirements } from './ledger-utils'
13
- import { AddressValidation , LedgerWallet } from './ledger-wallet'
13
+ import { AddressValidation , CELO_BASE_DERIVATION_PATH , LedgerWallet } from './ledger-wallet'
14
14
import {
15
15
ACCOUNT_ADDRESS1 ,
16
16
ACCOUNT_ADDRESS2 ,
@@ -226,6 +226,46 @@ describe('LedgerWallet class', () => {
226
226
` )
227
227
expect ( wallet . ledger ! . getAddress ) . toHaveBeenCalledTimes ( 6 )
228
228
} )
229
+ describe ( 'with other ledger apps' , ( ) => {
230
+ describe ( 'with the ethereum-recovery app' , ( ) => {
231
+ beforeEach ( ( ) => {
232
+ wallet = new LedgerWallet ( { } , [ 0 ] , CELO_BASE_DERIVATION_PATH , [ 1 , 2 ] )
233
+ mockLedger ( wallet , mockForceValidation , { name : 'ethereum-recovery' } )
234
+ } )
235
+ it ( 'shows warning on initialization but still initalizes' , async ( ) => {
236
+ const logMock = jest . spyOn ( console , 'error' )
237
+ await wallet . init ( )
238
+ expect ( logMock . mock . calls ) . toMatchInlineSnapshot ( `
239
+ [
240
+ [
241
+ "
242
+ ---
243
+ Beware, you opened the ethereum-recovery app instead of the Celo app. We cannot ensure the safety of using this SDK with ethereum-recovery. USE AT YOUR OWN RISK.
244
+ ---
245
+ ",
246
+ ],
247
+ ]
248
+ ` )
249
+ } )
250
+ } )
251
+ describe ( 'with the ethereum app' , ( ) => {
252
+ beforeEach ( ( ) => {
253
+ wallet = new LedgerWallet ( { } , [ 0 , 1 , 2 , 3 ] , ETHEREUM_DERIVATION_PATH , [ 6 , 7 , 8 ] )
254
+ mockLedger ( wallet , mockForceValidation , { name : 'ethereum' } )
255
+ } )
256
+ it ( 'shows warning on initialization but still initalizes' , async ( ) => {
257
+ const warnMock = jest . spyOn ( console , 'warn' )
258
+ await wallet . init ( )
259
+ expect ( warnMock . mock . calls ) . toMatchInlineSnapshot ( `
260
+ [
261
+ [
262
+ "Beware, you opened the Ethereum app instead of the Celo app. Some features may not work correctly, including token transfers.",
263
+ ],
264
+ ]
265
+ ` )
266
+ } )
267
+ } )
268
+ } )
229
269
} )
230
270
231
271
describe ( 'after initializing' , ( ) => {
0 commit comments