Skip to content

Commit

Permalink
refactor out Abandon23Playground from wallet_provider (#481)
Browse files Browse the repository at this point in the history
  • Loading branch information
fuxingloh authored Aug 7, 2021
1 parent e107776 commit 81e26d9
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 17 deletions.
8 changes: 1 addition & 7 deletions app/api/wallet/provider/mnemonic_encrypted.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,11 +71,5 @@ async function toData (mnemonic: string[], network: EnvironmentNetwork, passphra

export const MnemonicEncrypted = {
initProvider,
toData,
/**
* Convenience Abandon23 Art on Playground Network Data
*/
Abandon23Playground: toData([
'abandon', 'abandon', 'abandon', 'abandon', 'abandon', 'abandon', 'abandon', 'abandon', 'abandon', 'abandon', 'abandon', 'abandon', 'abandon', 'abandon', 'abandon', 'abandon', 'abandon', 'abandon', 'abandon', 'abandon', 'abandon', 'abandon', 'abandon', 'art'
], EnvironmentNetwork.LocalPlayground, '123456')
toData
}
6 changes: 5 additions & 1 deletion app/api/wallet/provider/mnemonic_unprotected.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,11 @@ describe('getMnemonicHdNodeProvider', () => {

describe('addMnemonicHdNodeProvider', () => {
it('should set mnemonic (abandon x23)', async () => {
expect(MnemonicUnprotected.Abandon23Playground).toStrictEqual({
const data = MnemonicUnprotected.toData([
'abandon', 'abandon', 'abandon', 'abandon', 'abandon', 'abandon', 'abandon', 'abandon', 'abandon', 'abandon', 'abandon', 'abandon', 'abandon', 'abandon', 'abandon', 'abandon', 'abandon', 'abandon', 'abandon', 'abandon', 'abandon', 'abandon', 'abandon', 'art'
], EnvironmentNetwork.LocalPlayground)

expect(data).toStrictEqual({
version: "v1",
type: WalletType.MNEMONIC_UNPROTECTED,
raw: {
Expand Down
8 changes: 1 addition & 7 deletions app/api/wallet/provider/mnemonic_unprotected.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,5 @@ function toData (mnemonic: string[], network: EnvironmentNetwork): WalletPersist

export const MnemonicUnprotected = {
initProvider,
toData,
/**
* Convenience Abandon23 Art on Playground Network Data
*/
Abandon23Playground: toData([
'abandon', 'abandon', 'abandon', 'abandon', 'abandon', 'abandon', 'abandon', 'abandon', 'abandon', 'abandon', 'abandon', 'abandon', 'abandon', 'abandon', 'abandon', 'abandon', 'abandon', 'abandon', 'abandon', 'abandon', 'abandon', 'abandon', 'abandon', 'art'
], EnvironmentNetwork.LocalPlayground)
toData
}
20 changes: 18 additions & 2 deletions app/screens/PlaygroundNavigator/sections/PlaygroundWallet.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,24 @@ export function PlaygroundWallet (): JSX.Element | null {

<PlaygroundAction
testID='playground_wallet_abandon'
title='Setup wallet with abandon x23 + art as mnemonic seed'
onPress={async () => await setWallet(MnemonicUnprotected.Abandon23Playground)}
title='Setup an unprotected wallet with abandon x23 + art as the 24 word'
onPress={async () => {
const data = await MnemonicUnprotected.toData([
'abandon', 'abandon', 'abandon', 'abandon', 'abandon', 'abandon', 'abandon', 'abandon', 'abandon', 'abandon', 'abandon', 'abandon', 'abandon', 'abandon', 'abandon', 'abandon', 'abandon', 'abandon', 'abandon', 'abandon', 'abandon', 'abandon', 'abandon', 'art'
], network)
await setWallet(data)
}}
/>

<PlaygroundAction
testID='playground_wallet_abandon_encrypted'
title='Setup an encrypted wallet with abandon x23 + art as the 24 word with 000000 passcode'
onPress={async () => {
const data = await MnemonicEncrypted.toData([
'abandon', 'abandon', 'abandon', 'abandon', 'abandon', 'abandon', 'abandon', 'abandon', 'abandon', 'abandon', 'abandon', 'abandon', 'abandon', 'abandon', 'abandon', 'abandon', 'abandon', 'abandon', 'abandon', 'abandon', 'abandon', 'abandon', 'abandon', 'art'
], network, '000000')
await setWallet(data)
}}
/>

<PlaygroundAction
Expand Down

0 comments on commit 81e26d9

Please sign in to comment.