From f0a268674dd0dffc6f1f4858fc8a49da31237be7 Mon Sep 17 00:00:00 2001 From: Leonardo Zizzamia Date: Mon, 11 Mar 2024 16:37:42 -0700 Subject: [PATCH] play around --- src/wallet/create.ts | 42 ++++++++++++++++++++++++++++++++++++++++++ src/wallet/index.ts | 2 ++ 2 files changed, 44 insertions(+) create mode 100644 src/wallet/create.ts create mode 100644 src/wallet/index.ts diff --git a/src/wallet/create.ts b/src/wallet/create.ts new file mode 100644 index 0000000000..91d9d28953 --- /dev/null +++ b/src/wallet/create.ts @@ -0,0 +1,42 @@ + +const initSmartWallet = (options: CreateOptions) => { + return { + init: async () => Promise.resolve(), + getPrivateKey: () => 'private-key' + } +}; + +const initEmbeddedWallet = (options: CreateOptions) => { + return { + init: async () => Promise.resolve(), + getPrivateKey: () => 'private-key' + } +}; + +type CreateOptions = { + mnemonic?: string; + network: string; + privateKey?: string; + typeOfWallet: 'smart-wallet' | 'embedded-wallet'; +}; + +type Wallet = { + init: () => Promise; + getPrivateKey: () => string; +} | { + init: () => Promise; + getPrivateKey: () => string; +}; + +export const create = async (options: CreateOptions): Promise => { + if (options.typeOfWallet === 'smart-wallet') { + const wallet = initSmartWallet(options); + await wallet.init(); + return wallet; + } else if (options.typeOfWallet === 'embedded-wallet') { + const wallet = initEmbeddedWallet(options); + await wallet.init(); + return wallet; + } + throw new Error('Invalid wallet type'); +} diff --git a/src/wallet/index.ts b/src/wallet/index.ts new file mode 100644 index 0000000000..d21640337f --- /dev/null +++ b/src/wallet/index.ts @@ -0,0 +1,2 @@ +// 🌲☀️🌲 +export { create } from './create';