Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main' into fix/standardize-creat…
Browse files Browse the repository at this point in the history
…ed-by
  • Loading branch information
hthieu1110 committed Aug 10, 2023
2 parents 5e3d312 + 548ac4b commit c4bba90
Show file tree
Hide file tree
Showing 9 changed files with 58 additions and 18 deletions.
30 changes: 27 additions & 3 deletions App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { NavigationContainer } from "@react-navigation/native";
import { QueryClient, QueryClientProvider } from "@tanstack/react-query";
import { StatusBar } from "expo-status-bar";
import { MetaMaskProvider } from "metamask-react";
import React from "react";
import React, { memo, useEffect } from "react";
import { useForm, FormProvider } from "react-hook-form";
import { Platform, View } from "react-native";
import { MenuProvider } from "react-native-popup-menu";
Expand All @@ -23,8 +23,14 @@ import { SearchBarContextProvider } from "./packages/context/SearchBarProvider";
import { TNSMetaDataListContextProvider } from "./packages/context/TNSMetaDataListProvider";
import { TNSContextProvider } from "./packages/context/TNSProvider";
import { TransactionModalsProvider } from "./packages/context/TransactionModalsProvider";
import { WalletsProvider } from "./packages/context/WalletsProvider";
import { store } from "./packages/store/store";
import {
WalletsProvider,
useWallets,
} from "./packages/context/WalletsProvider";
import { useSelectedNetworkId } from "./packages/hooks/useSelectedNetwork";
import useSelectedWallet from "./packages/hooks/useSelectedWallet";
import { setSelectedWalletId } from "./packages/store/slices/settings";
import { store, useAppDispatch } from "./packages/store/store";
import { linking } from "./packages/utils/navigation";

const queryClient = new QueryClient();
Expand Down Expand Up @@ -58,6 +64,7 @@ export default function App() {
<FeedbacksContextProvider>
<DropdownsContextProvider>
<WalletsProvider>
<WalletSyncer />
<SearchBarContextProvider>
<TransactionModalsProvider>
<TNSContextProvider>
Expand Down Expand Up @@ -125,3 +132,20 @@ class ErrorBoundary extends React.Component {
return this.props.children;
}
}

const WalletSyncer: React.FC = memo(() => {
const selectedWallet = useSelectedWallet();
const selectedNetworkId = useSelectedNetworkId();
const { wallets } = useWallets();
const dispatch = useAppDispatch();
useEffect(() => {
if (!selectedWallet || selectedWallet.networkId !== selectedNetworkId) {
dispatch(
setSelectedWalletId(
wallets.find((w) => w.networkId === selectedNetworkId)?.id
)
);
}
}, [dispatch, selectedNetworkId, selectedWallet, wallets]);
return null;
});
12 changes: 8 additions & 4 deletions networks.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@
"features": [
"NFTMarketplace",
"Organizations",
"SocialFeed"
"SocialFeed",
"UPP"
],
"walletUrlForStaking": "https://explorer.teritori.com/teritori/staking",
"currencies": [
Expand Down Expand Up @@ -134,7 +135,8 @@
"features": [
"NFTMarketplace",
"Organizations",
"SocialFeed"
"SocialFeed",
"UPP"
],
"currencies": [
{
Expand Down Expand Up @@ -570,7 +572,8 @@
"icon": "icons/networks/gno.svg",
"features": [
"Organizations",
"SocialFeed"
"SocialFeed",
"UPP"
],
"currencies": [
{
Expand Down Expand Up @@ -604,7 +607,8 @@
"icon": "icons/networks/gno.svg",
"features": [
"Organizations",
"SocialFeed"
"SocialFeed",
"UPP"
],
"currencies": [
{
Expand Down
15 changes: 8 additions & 7 deletions packages/components/navigation/Sidebar.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { useRoute } from "@react-navigation/native";
import React from "react";
import { View, StyleSheet, Pressable, FlatList } from "react-native";
import { FlatList, Pressable, StyleSheet, View } from "react-native";
import Animated, {
useAnimatedStyle,
withSpring,
Expand All @@ -17,17 +17,17 @@ import addSVG from "../../../assets/icons/add-circle.svg";
import chevronRightSVG from "../../../assets/icons/chevron-right.svg";
import { useSidebar } from "../../context/SidebarProvider";
import { useNSUserInfo } from "../../hooks/useNSUserInfo";
import { useSelectedNetworkKind } from "../../hooks/useSelectedNetwork";
import { useSelectedNetworkInfo } from "../../hooks/useSelectedNetwork";
import useSelectedWallet from "../../hooks/useSelectedWallet";
import { NetworkKind } from "../../networks";
import { NetworkFeature, NetworkKind } from "../../networks";
import { useAppNavigation } from "../../utils/navigation";
import { neutral17, neutral33 } from "../../utils/style/colors";
import { fontBold16, fontBold9 } from "../../utils/style/fonts";
import {
smallSidebarWidth,
fullSidebarWidth,
layout,
headerHeight,
layout,
smallSidebarWidth,
} from "../../utils/style/layout";
import { SVG } from "../SVG";
import { Separator } from "../Separator";
Expand Down Expand Up @@ -55,7 +55,8 @@ const SidebarSeparator: React.FC = () => {
export const Sidebar: React.FC = () => {
const selectedWallet = useSelectedWallet();
const userInfo = useNSUserInfo(selectedWallet?.userId);
const selectedNetworkKind = useSelectedNetworkKind();
const selectedNetworkInfo = useSelectedNetworkInfo();
const selectedNetworkKind = selectedNetworkInfo?.kind;
const connected = selectedWallet?.connected;
const navigation = useAppNavigation();
const { name: currentRouteName } = useRoute();
Expand Down Expand Up @@ -153,7 +154,7 @@ export const Sidebar: React.FC = () => {
/>
<SidebarSeparator />

{selectedNetworkKind === NetworkKind.Cosmos &&
{selectedNetworkInfo?.features.includes(NetworkFeature.UPP) &&
connected &&
userInfo.metadata && (
<SidebarProfileButton
Expand Down
6 changes: 5 additions & 1 deletion packages/networks/gno-dev/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,11 @@ export const gnoDevNetwork: GnoNetworkInfo = {
kind: NetworkKind.Gno,
displayName: "Gno Dev",
icon: "icons/networks/gno.svg",
features: [NetworkFeature.Organizations, NetworkFeature.SocialFeed],
features: [
NetworkFeature.Organizations,
NetworkFeature.SocialFeed,
NetworkFeature.UPP,
],
currencies: gnoCurrencies,
stakeCurrency: "ugnot",
idPrefix: "gnodev",
Expand Down
6 changes: 5 additions & 1 deletion packages/networks/gno-teritori/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,11 @@ export const gnoTeritoriNetwork: GnoNetworkInfo = {
kind: NetworkKind.Gno,
displayName: "Gno Teritori",
icon: "icons/networks/gno.svg",
features: [NetworkFeature.Organizations, NetworkFeature.SocialFeed],
features: [
NetworkFeature.Organizations,
NetworkFeature.SocialFeed,
NetworkFeature.UPP,
],
currencies: gnoCurrencies,
stakeCurrency: "ugnot",
idPrefix: "gnotori",
Expand Down
1 change: 1 addition & 0 deletions packages/networks/teritori-testnet/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ export const teritoriTestnetNetwork: NetworkInfo = {
NetworkFeature.NFTMarketplace,
NetworkFeature.Organizations,
NetworkFeature.SocialFeed,
NetworkFeature.UPP,
],
currencies: teritoriTestnetCurrencies,
txExplorer: "https://explorer.teritori.com/teritori-testnet/tx/$hash",
Expand Down
1 change: 1 addition & 0 deletions packages/networks/teritori/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ export const teritoriNetwork: CosmosNetworkInfo = {
NetworkFeature.NFTMarketplace,
NetworkFeature.Organizations,
NetworkFeature.SocialFeed,
NetworkFeature.UPP,
],
walletUrlForStaking: "https://explorer.teritori.com/teritori/staking",
currencies: teritoriCurrencies,
Expand Down
1 change: 1 addition & 0 deletions packages/networks/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -129,4 +129,5 @@ export enum NetworkFeature {
Swap = "Swap",
Organizations = "Organizations",
SocialFeed = "SocialFeed",
UPP = "UPP",
}
4 changes: 2 additions & 2 deletions packages/store/slices/settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { RootState } from "../store";

interface Settings {
selectedNetworkId: string;
selectedWalletId: string;
selectedWalletId: string | undefined;
NFTStorageAPI: string;
isKeplrConnected: boolean;
isAdenaConnected: boolean;
Expand Down Expand Up @@ -52,7 +52,7 @@ const settingsSlice = createSlice({
setSelectedNetworkId: (state, action: PayloadAction<string>) => {
state.selectedNetworkId = action.payload;
},
setSelectedWalletId: (state, action: PayloadAction<string>) => {
setSelectedWalletId: (state, action: PayloadAction<string | undefined>) => {
state.selectedWalletId = action.payload;
},
setIsKeplrConnected: (state, action: PayloadAction<boolean>) => {
Expand Down

0 comments on commit c4bba90

Please sign in to comment.