Skip to content

Commit

Permalink
chore: bump fast auth wallet version
Browse files Browse the repository at this point in the history
  • Loading branch information
benmalcom committed Feb 13, 2024
1 parent 4e5e265 commit e7e2435
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 17 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
"iframe-resizer-react": "^1.1.0",
"local-storage": "^2.0.0",
"lodash": "^4.17.21",
"near-fastauth-wallet": "^0.0.11",
"near-fastauth-wallet": "^0.0.12",
"near-social-vm": "github:NearSocial/VM#use_attr_patch",
"next": "^13.5.6",
"next-pwa": "^5.6.0",
Expand Down
36 changes: 20 additions & 16 deletions src/components/vm/VmInitializer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ export default function VmInitializer() {
networkId === 'testnet'
? 'http://34.70.226.83:3030/relay'
: 'https://near-relayer-mainnet.api.pagoda.co/relay',
walletUrl: 'http://localhost:3000',
}),
setupKeypom({
trialAccountSpecs: {
Expand Down Expand Up @@ -144,22 +145,13 @@ export default function VmInitializer() {
});
}, [idOS, near]);

const handleWalletSelectorMessage = useCallback(
(e: MessageEvent<{ showWalletSelector: boolean }>) => {
if (e.data.showWalletSelector) {
// Show wallet selector
walletModal?.show();
}
},
[walletModal],
);

useEffect(() => {
window.addEventListener('message', handleWalletSelectorMessage, false);
return () => {
window.removeEventListener('message', handleWalletSelectorMessage, false);
};
}, []);
const handleWalletSelectorMessage = (e: MessageEvent<{ showWalletSelector: boolean }>) => {
console.log('e.data ', e.data);
if (e.data.showWalletSelector) {
// Show wallet selector
walletModal?.show();
}
};

const requestSignMessage = useCallback(
async (message: string) => {
Expand Down Expand Up @@ -203,6 +195,18 @@ export default function VmInitializer() {
return false;
}, [saveCurrentUrl, walletModal]);

useEffect(() => {
window.addEventListener(
'message',
(e: MessageEvent<{ showWalletSelector: boolean }>) => {
if (e.data.showWalletSelector) {
requestSignInWithWallet();
}
},
false,
);
}, [requestSignInWithWallet]);

const logOut = useCallback(async () => {
if (!near) {
return;
Expand Down

0 comments on commit e7e2435

Please sign in to comment.