Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat add wallet package 4 #390

Merged
merged 9 commits into from
Aug 21, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 22 additions & 9 deletions packages/react/src/WalletContext.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -106,23 +106,36 @@ export const WalletContextProvider: React.FC<{ children: React.ReactNode; networ
};


useEffect(() => {


const setupMintbaseWallet = async () => await setupWalletSelector({
const setupMintbaseWallet = async () => {
const res = await setupWalletSelector({
network: network,
debug: mbjs.keys.debugMode,
modules: [
...additionalWallets,
],
});

setWalletMb(res);

if (isMintbaseWallet) {
console.log(res, 'selector')

return res;
};


useEffect(() => {

const mbSelector = setupMintbaseWallet();

setWalletMb(mbSelector);
if (isMintbaseWallet) {

setupMintbaseWallet().catch((err: Error) => {
if (err || err.message.length > 0) {
setErrorMessage((err as Error).message);
}
});

}


Expand All @@ -146,7 +159,7 @@ export const WalletContextProvider: React.FC<{ children: React.ReactNode; networ
return () => {
window.removeEventListener('mbWalletLogin', handleUsernameChange);
};
}, [setup]);
}, []);


// call setup on wallet selector
Expand Down Expand Up @@ -228,7 +241,7 @@ export const WalletContextProvider: React.FC<{ children: React.ReactNode; networ
disconnect,
signMessage,
}),
[selector, modal, accounts, isMintbaseWallet, isConnected, mbWalletUsername],
[selector, modal, accounts, isMintbaseWallet, isConnected, mbWalletUsername, mbWalletSelector],
);

return (
Expand Down
2 changes: 1 addition & 1 deletion packages/wallet/src/wallet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ export class MintbaseWallet {
if (urlParams?.accountId) {
this._initializeWalletState({ accountId: urlParams?.accountId, publicKey: urlParams?.publicKey || '' });

console.log({ accountId: urlParams?.accountId, publicKey: urlParams?.publicKey }, this.getAccounts(), '{publickKey: publicKey, accountId: accountId, active: true}');
console.log({ accountId: urlParams?.accountId, publicKey: urlParams?.publicKey }, '{publickKey: publicKey, accountId: accountId, active: true}');

return [{ accountId: urlParams?.accountId, publicKey: urlParams?.publicKey }]

Expand Down
Loading