From 81e26d95b1a69fb3cde38fc5d9f72a821cef9e0c Mon Sep 17 00:00:00 2001 From: Fuxing Loh <4266087+fuxingloh@users.noreply.github.com> Date: Sat, 7 Aug 2021 18:10:44 +0800 Subject: [PATCH] refactor out `Abandon23Playground` from wallet_provider (#481) --- app/api/wallet/provider/mnemonic_encrypted.ts | 8 +------- .../provider/mnemonic_unprotected.test.ts | 6 +++++- .../wallet/provider/mnemonic_unprotected.ts | 8 +------- .../sections/PlaygroundWallet.tsx | 20 +++++++++++++++++-- 4 files changed, 25 insertions(+), 17 deletions(-) diff --git a/app/api/wallet/provider/mnemonic_encrypted.ts b/app/api/wallet/provider/mnemonic_encrypted.ts index a9cab2d114..0bd77fd5bb 100644 --- a/app/api/wallet/provider/mnemonic_encrypted.ts +++ b/app/api/wallet/provider/mnemonic_encrypted.ts @@ -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 } diff --git a/app/api/wallet/provider/mnemonic_unprotected.test.ts b/app/api/wallet/provider/mnemonic_unprotected.test.ts index b7b418785a..28bf6896f5 100644 --- a/app/api/wallet/provider/mnemonic_unprotected.test.ts +++ b/app/api/wallet/provider/mnemonic_unprotected.test.ts @@ -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: { diff --git a/app/api/wallet/provider/mnemonic_unprotected.ts b/app/api/wallet/provider/mnemonic_unprotected.ts index 8e159c2cad..46c44ebad1 100644 --- a/app/api/wallet/provider/mnemonic_unprotected.ts +++ b/app/api/wallet/provider/mnemonic_unprotected.ts @@ -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 } diff --git a/app/screens/PlaygroundNavigator/sections/PlaygroundWallet.tsx b/app/screens/PlaygroundNavigator/sections/PlaygroundWallet.tsx index d812e0011c..55fad71e0b 100644 --- a/app/screens/PlaygroundNavigator/sections/PlaygroundWallet.tsx +++ b/app/screens/PlaygroundNavigator/sections/PlaygroundWallet.tsx @@ -34,8 +34,24 @@ export function PlaygroundWallet (): JSX.Element | null { 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) + }} + /> + + { + 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) + }} />