Skip to content

Commit

Permalink
new update noti
Browse files Browse the repository at this point in the history
  • Loading branch information
marxeille committed Jan 21, 2025
1 parent b3bd68d commit a7a315e
Show file tree
Hide file tree
Showing 6 changed files with 157 additions and 36 deletions.
Binary file modified .yarn/install-state.gz
Binary file not shown.
15 changes: 12 additions & 3 deletions apps/extension/src/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"manifest_version": 3,
"name": "OWallet",
"description": "OWallet: BTC x COSMOS x EVM x TRON x OASIS x SOLANA in one Wallet",
"version": "3.1.41",
"version": "3.1.42",
"icons": {
"16": "assets/icon-16.png",
"48": "assets/icon-48.png",
Expand All @@ -11,7 +11,12 @@
"background": {
"service_worker": "service_worker.js"
},
"permissions": ["storage", "tabs", "notifications", "https://tx-history-backend.oraidex.io/*"],
"permissions": [
"storage",
"tabs",
"notifications",
"https://tx-history-backend.oraidex.io/*"
],
"content_scripts": [
{
"matches": ["<all_urls>"],
Expand All @@ -22,7 +27,11 @@
],
"web_accessible_resources": [
{
"resources": ["injectedScript.bundle.js", "injectedScript.bundle.js.map", "assets/orai_wallet_logo.png"],
"resources": [
"injectedScript.bundle.js",
"injectedScript.bundle.js.map",
"assets/orai_wallet_logo.png"
],
"matches": ["<all_urls>"]
}
],
Expand Down
19 changes: 19 additions & 0 deletions apps/extension/src/pages/home/components/notification-card.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import React, { FC } from "react";
import styles from "./style.module.scss";
import { observer } from "mobx-react-lite";
import colors from "theme/colors";

export const NotificationCard: FC<{}> = observer(({}) => {
return (
<div className={styles.containerInfoAccountCard} style={{ marginTop: 16 }}>
<div
style={{
color: colors["neutral-text-body"]
}}
>
🎈 Exciting news! A major update is on the way, bringing fresh features,
improvements, and more. Stay tuned—things are about to get even better!
</div>
</div>
);
});
69 changes: 47 additions & 22 deletions apps/extension/src/pages/home/home-page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import {
fetchRetry,
MapChainIdToNetwork,
Network,
unknownToken,
unknownToken
} from "@owallet/common";
import { debounce } from "lodash";
import "dotenv/config";
Expand All @@ -27,14 +27,16 @@ import {
Connection,
PublicKey,
SystemProgram,
Transaction,
Transaction
} from "@solana/web3.js";
import {
createTransferInstruction,
getAssociatedTokenAddress,
TOKEN_PROGRAM_ID,
TOKEN_PROGRAM_ID
} from "@solana/spl-token";
import { AppCurrency } from "@owallet/types";
import { NotificationCard } from "./components/notification-card";
import { ModalNoti } from "./modals/modal-noti";

var mixpanelId = "acbafd21a85654933cbb0332c5a6f4f8";
const mixpanel = Mixpanel.init(mixpanelId);
Expand All @@ -44,11 +46,22 @@ export const HomePage = observer(() => {
hugeQueriesStore,
priceStore,
accountStore,
tokensStore,
keyRingStore,
tokensStore
} = useStore();
const accountOrai = accountStore.getAccount(ChainIdEnum.Oraichain);

const [isShowNoti, setIsShowNoti] = React.useState(false);

useEffect(() => {
if (chainStore.notification) {
setIsShowNoti(chainStore.notification);
}
}, [chainStore.notification]);

const onCloseNoti = () => {
setIsShowNoti(false);
chainStore.setHideNoti();
};
const allBalances = hugeQueriesStore.getAllBalances(true);
const balancesByChain = hugeQueriesStore.filterBalanceTokensByChain(
allBalances,
Expand All @@ -72,7 +85,7 @@ export const HomePage = observer(() => {
}, [hugeQueriesStore.allKnownBalances, priceStore]);

const debouncedSetUaw = useCallback(
debounce((availableTotalPriceEmbedOnlyUSD) => {
debounce(availableTotalPriceEmbedOnlyUSD => {
if (!availableTotalPriceEmbedOnlyUSD || !accountOrai.bech32Address)
return;
const hashedAddress = new sha256()
Expand All @@ -88,7 +101,7 @@ export const HomePage = observer(() => {
const logEvent = {
userId: hashedAddress,
totalPrice: amount?.toString() || "0",
currency: "usd",
currency: "usd"
};
if (mixpanel) {
mixpanel.track("OWallet Extension - Assets Managements", logEvent);
Expand All @@ -102,7 +115,7 @@ export const HomePage = observer(() => {
fetchRetry(
`https://raw.githubusercontent.com/oraichain/oraichain-sdk/refs/heads/master/chains/Oraichain.json`
)
.then((res) => {
.then(res => {
if (res && res.currencies?.length > 0) {
const currencyOrai: AppCurrency[] = [];
for (const currency of res.currencies) {
Expand All @@ -111,14 +124,14 @@ export const HomePage = observer(() => {
coinGeckoId,
coinMinimalDenom,
coinDecimals,
coinImageUrl,
coinImageUrl
} = currency || {};
const token: AppCurrency = {
coinImageUrl: coinImageUrl,
coinGeckoId: coinGeckoId,
coinMinimalDenom: coinMinimalDenom,
coinDecimals: coinDecimals,
coinDenom: coinDenom,
coinDenom: coinDenom
};
currencyOrai.push(token);
// tokensStore.addToken("Oraichain", token);
Expand All @@ -127,7 +140,7 @@ export const HomePage = observer(() => {
OraiChain.addCurrencies(...currencyOrai);
}
})
.catch((err) => console.log(err, "Errr"));
.catch(err => console.log(err, "Errr"));
}, []);
useEffect(() => {
debouncedSetUaw(availableTotalPriceEmbedOnlyUSD);
Expand All @@ -138,7 +151,7 @@ export const HomePage = observer(() => {
let balances = chainStore.isAllNetwork
? hugeQueriesStore.allKnownBalances
: hugeQueriesStore.allKnownBalances.filter(
(token) => token.chainInfo.chainId === chainStore.current.chainId
token => token.chainInfo.chainId === chainStore.current.chainId
);
for (const bal of balances) {
if (bal.price) {
Expand All @@ -153,7 +166,7 @@ export const HomePage = observer(() => {
}, [
hugeQueriesStore.allKnownBalances,
chainStore.isAllNetwork,
chainStore.current.chainId,
chainStore.current.chainId
]);

const fetchAllErc20 = async (chainId, addressEvmHex) => {
Expand All @@ -164,23 +177,23 @@ export const HomePage = observer(() => {
if (!MapChainIdToNetwork[chainInfo.chainId]) return;
const response = await API.getAllBalancesEvm({
address: addressEvmHex,
network: MapChainIdToNetwork[chainInfo.chainId],
network: MapChainIdToNetwork[chainInfo.chainId]
});

if (!response.result) return;

const allTokensAddress = response.result
.filter(
(token) =>
token =>
!!chainInfo.currencies.find(
(coin) =>
coin =>
new DenomHelper(
coin.coinMinimalDenom
).contractAddress?.toLowerCase() !==
token.tokenAddress?.toLowerCase()
) && MapChainIdToNetwork[chainInfo.chainId]
)
.map((coin) => {
.map(coin => {
const str = `${
MapChainIdToNetwork[chainInfo.chainId]
}%2B${new URLSearchParams(coin.tokenAddress)
Expand All @@ -192,32 +205,32 @@ export const HomePage = observer(() => {
if (allTokensAddress?.length === 0) return;

const tokenInfos = await API.getMultipleTokenInfo({
tokenAddresses: allTokensAddress.join(","),
tokenAddresses: allTokensAddress.join(",")
});

const infoTokens = tokenInfos
.filter(
(item, index, self) =>
index ===
self.findIndex((t) => t.contractAddress === item.contractAddress) &&
self.findIndex(t => t.contractAddress === item.contractAddress) &&
chainInfo.currencies.findIndex(
(item2) =>
item2 =>
new DenomHelper(
item2.coinMinimalDenom
).contractAddress.toLowerCase() ===
item.contractAddress.toLowerCase()
) < 0 &&
item.coingeckoId !== null
)
.map((tokeninfo) => {
.map(tokeninfo => {
const infoToken = {
coinImageUrl: tokeninfo.imgUrl || unknownToken.coinImageUrl,
coinDenom: tokeninfo.abbr,
coinGeckoId: tokeninfo.coingeckoId || unknownToken.coinGeckoId,
coinDecimals: tokeninfo.decimal,
coinMinimalDenom: `erc20:${tokeninfo.contractAddress}:${tokeninfo.name}`,
contractAddress: tokeninfo.contractAddress,
type: "erc20",
type: "erc20"
};
tokensStore.addToken(chainId, infoToken);
return infoToken;
Expand Down Expand Up @@ -248,6 +261,8 @@ export const HomePage = observer(() => {
totalPrice={(availableTotalPrice || initPrice)?.toString() || "-"}
/>

<NotificationCard />

{/*TODO:// need check again Claim reward */}
{/* <ClaimReward /> */}
{chainStore.isAllNetwork ||
Expand All @@ -257,6 +272,16 @@ export const HomePage = observer(() => {
<TokensCard
dataTokens={chainStore.isAllNetwork ? allBalances : balancesByChain}
/>
{/* <ModalNoti
onSubmit={() => {
onCloseNoti();
}}
isOpen={isShowNoti}
onRequestClose={() => {
onCloseNoti();
}}
content={<NotificationCard />}
/> */}
</FooterLayout>
);
});
57 changes: 57 additions & 0 deletions apps/extension/src/pages/home/modals/modal-noti.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
import React, { FC, ReactNode } from "react";
import { observer } from "mobx-react-lite";
import styles from "./style.module.scss";
import { HeaderModal } from "../components/header-modal";
import SlidingPane from "react-sliding-pane";
import { formatAddress, getFavicon } from "@owallet/common";
import classnames from "classnames";
import { Button } from "components/common/button";
import style from "pages/sign/style.module.scss";
import { toast } from "react-toastify";

export const ModalNoti: FC<{
isOpen: boolean;
onRequestClose: () => void;
content: ReactNode;
onSubmit: any;
}> = observer(({ isOpen, onRequestClose, content, onSubmit }) => {
return (
<SlidingPane
isOpen={isOpen}
from="bottom"
width="100vw"
onRequestClose={onRequestClose}
hideHeader={true}
className={classnames(styles.modalNetwork, styles.modalConfirm)}
>
<div>
<HeaderModal title={"News"} onRequestClose={onRequestClose} />
{content ? content : null}
<div
style={{
flexDirection: "row",
display: "flex",
paddingTop: 16
}}
>
<Button
containerStyle={{ marginRight: 8 }}
className={classnames(style.button, style.rejectBtn)}
color={"reject"}
onClick={onRequestClose}
>
Close
</Button>
<Button
className={classnames(style.button, style.approveBtn)}
// data-loading={signInteractionStore.isLoading}
// loading={signInteractionStore.isLoading}
onClick={onSubmit}
>
Confirmed
</Button>
</div>
</div>
</SlidingPane>
);
});
Loading

0 comments on commit a7a315e

Please sign in to comment.