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';