Skip to content

Commit

Permalink
prettier
Browse files Browse the repository at this point in the history
  • Loading branch information
PatrickDinh committed Dec 3, 2024
1 parent 8bbca2d commit b37ceff
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 6 deletions.
2 changes: 1 addition & 1 deletion packages/use-wallet/src/__tests__/wallets/kmd.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -428,7 +428,7 @@ describe('KmdWallet', () => {

it('should handle null from cancelled prompt', async () => {
// Mock prompt to return null (user cancelled)
global.prompt = vi.fn().mockReturnValue(null)
global.prompt = vi.fn().mockReturnValue(null)

mockKmd.listKeys.mockResolvedValueOnce({ addresses: [account1.address] })
await wallet.connect()
Expand Down
13 changes: 10 additions & 3 deletions packages/use-wallet/src/__tests__/wallets/mnemonic.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -363,12 +363,16 @@ describe('MnemonicWallet', () => {
})

describe('custom prompt for mnemonic', () => {
const MOCK_ACCOUNT_MNEMONIC = 'just aim reveal time update elegant column reunion lazy ritual room unusual notice camera forward couple quantum gym laundry absurd drill pyramid tip able outdoor'
const MOCK_ACCOUNT_MNEMONIC =
'just aim reveal time update elegant column reunion lazy ritual room unusual notice camera forward couple quantum gym laundry absurd drill pyramid tip able outdoor'

beforeEach(() => {
wallet = new MnemonicWallet({
id: WalletId.MNEMONIC,
options: { promptForMnemonic: () => Promise.resolve(MOCK_ACCOUNT_MNEMONIC), persistToStorage: true },
options: {
promptForMnemonic: () => Promise.resolve(MOCK_ACCOUNT_MNEMONIC),
persistToStorage: true
},
metadata: {},
getAlgodClient: {} as any,
store,
Expand All @@ -384,7 +388,10 @@ describe('MnemonicWallet', () => {
await wallet.connect()

expect(global.prompt).toHaveBeenCalledTimes(0)
expect(storageSetItemSpy).toHaveBeenCalledWith(LOCAL_STORAGE_MNEMONIC_KEY, MOCK_ACCOUNT_MNEMONIC)
expect(storageSetItemSpy).toHaveBeenCalledWith(
LOCAL_STORAGE_MNEMONIC_KEY,
MOCK_ACCOUNT_MNEMONIC
)
})
})
})
6 changes: 4 additions & 2 deletions packages/use-wallet/src/wallets/mnemonic.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ interface MnemonicConstructor {
export type MnemonicOptions = Partial<Pick<MnemonicConstructor, 'promptForMnemonic'>> &
Omit<MnemonicConstructor, 'promptForMnemonic'>


export const LOCAL_STORAGE_MNEMONIC_KEY = `${LOCAL_STORAGE_KEY}_mnemonic`

const ICON = `data:image/svg+xml;base64,${btoa(`
Expand All @@ -41,7 +40,10 @@ export class MnemonicWallet extends BaseWallet {
}: WalletConstructor<WalletId.MNEMONIC>) {
super({ id, metadata, getAlgodClient, store, subscribe })

const { persistToStorage = false, promptForMnemonic = () => Promise.resolve(prompt('Enter 25-word mnemonic passphrase:')) } = options || {}
const {
persistToStorage = false,
promptForMnemonic = () => Promise.resolve(prompt('Enter 25-word mnemonic passphrase:'))
} = options || {}
this.options = { persistToStorage, promptForMnemonic }

this.store = store
Expand Down

0 comments on commit b37ceff

Please sign in to comment.