Skip to content

Commit

Permalink
play around
Browse files Browse the repository at this point in the history
  • Loading branch information
Zizzamia committed Mar 11, 2024
1 parent fdfc3ba commit f0a2686
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 0 deletions.
42 changes: 42 additions & 0 deletions src/wallet/create.ts
Original file line number Diff line number Diff line change
@@ -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<void>;
getPrivateKey: () => string;
} | {
init: () => Promise<void>;
getPrivateKey: () => string;
};

export const create = async (options: CreateOptions): Promise<Wallet> => {
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');
}
2 changes: 2 additions & 0 deletions src/wallet/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
// 🌲☀️🌲
export { create } from './create';

0 comments on commit f0a2686

Please sign in to comment.