Skip to content

Commit

Permalink
chore: playground (#244)
Browse files Browse the repository at this point in the history
  • Loading branch information
Zizzamia authored Mar 12, 2024
1 parent 1f18656 commit fe74842
Show file tree
Hide file tree
Showing 3 changed files with 55 additions and 0 deletions.
10 changes: 10 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,16 @@
"default": "./lib/xmtp/index.js"
},
"default": "./lib/xmtp/index.js"
},
"./wallet": {
"types": "./lib/wallet/index.d.ts",
"browser": {
"types": "./esm/wallet/index.d.ts",
"module": "./esm/wallet/index.js",
"import": "./esm/wallet/index.js",
"default": "./lib/wallet/index.js"
},
"default": "./lib/wallet/index.js"
}
}
}
43 changes: 43 additions & 0 deletions src/wallet/create.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
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 fe74842

Please sign in to comment.