Skip to content

Commit

Permalink
Snap Wallet Address issue fixed
Browse files Browse the repository at this point in the history
  • Loading branch information
abhishek-01k committed Jan 11, 2024
1 parent daeb9b9 commit 3e92257
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 15 deletions.
16 changes: 8 additions & 8 deletions src/components/PushSnap/PushSnapConfigureModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ const PushSnapConfigureModal = () => {
},
},
});
console.log('res', res);
setToggleStatus(res);
})();
}, [toggleStatus]);
Expand All @@ -67,7 +66,6 @@ const PushSnapConfigureModal = () => {
}

const addWalletAddresses = async () => {
console.log('searchedUser', searchedUser);
const signatureResult = await getSignature(1);
if (signatureResult) {
if (searchedUser) {
Expand All @@ -81,7 +79,8 @@ const PushSnapConfigureModal = () => {
},
},
});
console.log('Added', searchedUser);
setSearchedUser('');
getWalletAddresses();
}
} else {
console.log('Signature Validation Failed');
Expand All @@ -107,6 +106,7 @@ const PushSnapConfigureModal = () => {

const removeWalletAddresses = async (walletSelected: string) => {
const signatureResult = await getSignature(2);
console.log("Ran",signatureResult)
if (signatureResult) {
if (walletSelected) {
await window.ethereum?.request({
Expand All @@ -119,6 +119,7 @@ const PushSnapConfigureModal = () => {
},
},
});
getWalletAddresses();
}
} else {
console.log('Signature Validation Failed');
Expand All @@ -133,7 +134,6 @@ const PushSnapConfigureModal = () => {
request: { method: 'pushproto_getaddresses' },
},
});
console.log('result', result);
setAddresses(result);
}

Expand All @@ -151,8 +151,6 @@ const PushSnapConfigureModal = () => {

return (
<Container >


<ItemVV2
alignItems="baseline"
margin="24px 0 0 0"
Expand Down Expand Up @@ -186,11 +184,11 @@ const PushSnapConfigureModal = () => {
{addresses?.map((wallet) => (
<AddressesSubContainer>
<SpanV2 fontSize='15px' fontWeight='500' color={walletSelected === wallet ? '#D53A94' : theme.default.color}>{shortenText(wallet, 8)}</SpanV2>
<MoreOptions onClick={() => handleWalletSelect(wallet)} color={theme.default.color} />
<MoreOptions onClick={() => handleWalletSelect(wallet)} color={theme.default.color} />

{walletSelected === wallet && <RemoveDiv >
<MinusCircle />
<SpanV2 fontSize='16px' fontWeight='400' color='#657795' onClick={() => removeWalletAddresses(walletSelected)}>Remove</SpanV2>
<SpanV2 fontSize='16px' cursor='pointer' fontWeight='400' color='#657795' onClick={() => removeWalletAddresses(walletSelected)}>Remove</SpanV2>
</RemoveDiv>
}
</AddressesSubContainer>
Expand Down Expand Up @@ -434,12 +432,14 @@ const AddressesSubContainer = styled(ItemHV2)`
const MoreOptions = styled(AiOutlineMore)`
width:24px;
height:24px;
cursor:pointer;
`

const RemoveDiv = styled(ItemHV2)`
border-radius: 12px;
border: 1px solid #BAC4D6;
background: #FFF;
cursor: pointer;
box-shadow: 0px 4px 20px 0px rgba(0, 0, 0, 0.05);
padding: 8px 12px 8px 8px;
align-items: center;
Expand Down
13 changes: 6 additions & 7 deletions src/modules/snap/SnapModule.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,13 @@ const SnapModule = () => {

const { account, provider } = useAccount();

const theme = useTheme();
const navigate = useNavigate();

useEffect(() => {
getInstalledSnaps();
getWalletAddresses();
}, [account, walletConnected]);
}, [account, walletConnected, snapInstalled]);

async function getInstalledSnaps() {
const installedSnaps = await window.ethereum.request({
Expand All @@ -65,10 +68,9 @@ const SnapModule = () => {
},
});

console.log(account);
console.log(walletConnected);
if (result.includes(account)) {
setAddedAddress(true);
setWalletConnected(true);
} else {
setAddedAddress(false);
}
Expand Down Expand Up @@ -142,9 +144,6 @@ const SnapModule = () => {
setSnapState(3);
showMetamaskPushSnap();
};

const theme = useTheme();
const navigate = useNavigate();
return (
<Container>
<AboutPushSnapModalComponent
Expand Down Expand Up @@ -272,7 +271,7 @@ const SnapModule = () => {
/>
) : (
<ConnectButton onClick={() => connectToMetaMask()}>
{!snapInstalled ? 'Connect Snap' : 'Connect Using MetaMask '}
{!snapInstalled ? 'Connect Snap' : 'Connect Using MetaMask'}
</ConnectButton>
)}
</ItemVV2>
Expand Down

0 comments on commit 3e92257

Please sign in to comment.