From 4b74f98297f41a6915e4101adf241a3fba41f794 Mon Sep 17 00:00:00 2001 From: maelswarm Date: Tue, 27 Apr 2021 19:53:45 -0700 Subject: [PATCH 1/7] * --- package.json | 2 + src/components/App/index.tsx | 75 +++++++++++---------- src/components/common/Header.tsx | 105 ++++++++++++++++++++---------- src/react-app-env.d.ts | 1 + src/reducer/index.ts | 33 +++++++++- src/reducer/slices/collections.ts | 2 +- src/reducer/slices/marketplace.ts | 2 +- src/reducer/slices/system.ts | 15 ++++- yarn.lock | 10 +++ 9 files changed, 168 insertions(+), 77 deletions(-) diff --git a/package.json b/package.json index 94f9aed2..a6ad2fc9 100644 --- a/package.json +++ b/package.json @@ -26,12 +26,14 @@ "immer": "8.0.0", "io-ts": "2.2.16", "joi": "17.3.0", + "jsog": "1.0.7", "react": "16.13.1", "react-dom": "16.13.1", "react-dropzone": "11.2.4", "react-feather": "2.0.9", "react-icons": "4.2.0", "react-redux": "7.2.2", + "redux-persist": "6.0.0", "typescript": "4.1.3", "wouter": "2.5.1" }, diff --git a/src/components/App/index.tsx b/src/components/App/index.tsx index 9da7ff9c..364ce513 100644 --- a/src/components/App/index.tsx +++ b/src/components/App/index.tsx @@ -8,9 +8,10 @@ import MarketplaceCatalog from '../Marketplace/Catalog'; import Header from '../common/Header'; import { Flex } from '@chakra-ui/react'; import Notifications from '../common/Notifications'; -import { useSelector, useDispatch } from '../../reducer'; +import { useSelector, useDispatch, persistor, store } from '../../reducer'; import { reconnectWallet } from '../../reducer/async/wallet'; -// import { getMarketplaceNftsQuery } from '../../reducer/async/queries'; +import { Provider } from 'react-redux'; +import { PersistGate } from 'redux-persist/lib/integration/react'; export default function App() { const dispatch = useDispatch(); @@ -33,38 +34,42 @@ export default function App() { }, [walletReconnectAttempted, dispatch]); return ( - - -
- - - - - - - - - - - - - - - {({ contractAddress }) => ( - - )} - - - {({ contractAddress, tokenId }) => ( - - )} - - - - - + + + + +
+ + + + + + + + + + + + + + + {({ contractAddress }) => ( + + )} + + + {({ contractAddress, tokenId }) => ( + + )} + + + + + + + ); } diff --git a/src/components/common/Header.tsx b/src/components/common/Header.tsx index f2a48417..020c60d8 100644 --- a/src/components/common/Header.tsx +++ b/src/components/common/Header.tsx @@ -15,13 +15,15 @@ import { DrawerContent, DrawerCloseButton, DrawerBody, - Heading + Heading, + MenuItemOption } from '@chakra-ui/react'; -import { Plus, Menu as HamburgerIcon } from 'react-feather'; +import { Plus, Menu as HamburgerIcon, ChevronDown } from 'react-feather'; import { RiStore2Line } from 'react-icons/ri'; import { MdCollections } from 'react-icons/md'; import headerLogo from './assets/header-logo.svg'; import { useSelector, useDispatch } from '../../reducer'; +import { swapConfig } from '../../reducer/slices/system'; import { connectWallet, disconnectWallet } from '../../reducer/async/wallet'; import { MinterButton } from '.'; import logo from './assets/splash-logo.svg'; @@ -121,41 +123,72 @@ function WalletDisplay() { return ( <> {system.status === 'WalletConnected' ? ( - - - - - - - - Network: {system.config.network} - - - { - await dispatch(disconnectWallet()); - setLocation('/'); - }} - > - Disconnect + <> + + + + + + + + Network: {system.config.network} + + + + { + await dispatch(disconnectWallet()); + setLocation('/'); + }} + > + Disconnect - - - + + + + + + + Networks + + + + + Networks + + { await dispatch(disconnectWallet()); swapConfig("mainnet"); dispatch(connectWallet()); }} + > + mainnet + + { await dispatch(disconnectWallet()); swapConfig("edo2net"); dispatch(connectWallet()); }} + > + edo2net + + + + + + + + ) : ( +declare module 'jsog'; \ No newline at end of file diff --git a/src/reducer/index.ts b/src/reducer/index.ts index 03dc4dfe..e8345aa5 100644 --- a/src/reducer/index.ts +++ b/src/reducer/index.ts @@ -9,6 +9,17 @@ import systemSlice from './slices/system'; import statusSlice from './slices/status'; import notificationsSlice from './slices/notifications'; import marketplaceSlice from './slices/marketplace'; +import storage from "redux-persist/lib/storage"; +import { + persistStore, persistReducer, createTransform, + FLUSH, + REHYDRATE, + PAUSE, + PERSIST, + PURGE, + REGISTER +} from 'redux-persist'; +import JSOG from 'jsog'; export const reducer = combineReducers({ collections: collectionsSlice.reducer, @@ -19,8 +30,22 @@ export const reducer = combineReducers({ notifications: notificationsSlice.reducer }); +export const JSOGTransform = createTransform( + (inboundState, key) => JSOG.encode(inboundState), + (outboundState, key) => JSOG.decode(outboundState), +) + +const persistConfig = { + key: "App", + version: 1, + storage, + transforms: [JSOGTransform] +}; + +const persistedReducer = persistReducer(persistConfig, reducer); + export const store = configureStore({ - reducer, + reducer: persistedReducer, middleware: getDefaultMiddleware => getDefaultMiddleware({ immutableCheck: { @@ -31,12 +56,15 @@ export const store = configureStore({ ignoredActions: [ 'wallet/connect/fulfilled', 'wallet/reconnect/fulfilled', - 'wallet/disconnect/fulfilled' + 'wallet/disconnect/fulfilled', + FLUSH, REHYDRATE, PAUSE, PERSIST, PURGE, REGISTER ] } }) }); +export const persistor = persistStore(store); + export type State = ReturnType; export type Dispatch = typeof store.dispatch; export const useDispatch = () => baseUseDispatch(); @@ -47,3 +75,4 @@ export function useSelector( ) { return baseUseSelector(selector, equalityFn); } + diff --git a/src/reducer/slices/collections.ts b/src/reducer/slices/collections.ts index 111a38e1..b7666d6a 100644 --- a/src/reducer/slices/collections.ts +++ b/src/reducer/slices/collections.ts @@ -30,7 +30,7 @@ type Reducer = CaseReducer>; export const initialState: CollectionsState = { selectedCollection: null, - globalCollection: config.contracts.nftFaucet, + globalCollection: config.mainnet.contracts.nftFaucet, collections: {} }; diff --git a/src/reducer/slices/marketplace.ts b/src/reducer/slices/marketplace.ts index 880fbb97..cf24084a 100644 --- a/src/reducer/slices/marketplace.ts +++ b/src/reducer/slices/marketplace.ts @@ -27,7 +27,7 @@ type Reducer = CaseReducer>; // Data -const globalMarketplaceAddress = config.contracts.marketplace.fixedPrice.tez; +const globalMarketplaceAddress = config.mainnet.contracts.marketplace.fixedPrice.tez; export const initialState: MarketplaceState = { marketplace: { diff --git a/src/reducer/slices/system.ts b/src/reducer/slices/system.ts index 7036716d..30a26d87 100644 --- a/src/reducer/slices/system.ts +++ b/src/reducer/slices/system.ts @@ -7,14 +7,24 @@ import { reconnectWallet } from '../async/wallet'; -const initialState = Minter.connectToolkit(Minter.configure(config)) as +const initialState = Minter.connectToolkit(Minter.configure(config.mainnet)) as | SystemWithToolkit | SystemWithWallet; const slice = createSlice({ name: 'system', initialState, - reducers: {}, + reducers: { + swapConfig(state, action) { +console.log(action.payload) + return { + ...state, + config: (config as { + [key: string]: any, + })[action.payload] + } + } + }, extraReducers: ({ addCase }) => { addCase(connectWallet.fulfilled, (_, { payload }) => payload); addCase(disconnectWallet.fulfilled, (_, { payload }) => payload); @@ -22,4 +32,5 @@ const slice = createSlice({ } }); +export const swapConfig = slice.actions.swapConfig; export default slice; diff --git a/yarn.lock b/yarn.lock index 41552070..68bca72c 100644 --- a/yarn.lock +++ b/yarn.lock @@ -7898,6 +7898,11 @@ jsesc@~0.5.0: resolved "https://registry.yarnpkg.com/jsesc/-/jsesc-0.5.0.tgz#e7dee66e35d6fc16f710fe91d5cf69f70f08911d" integrity sha1-597mbjXW/Bb3EP6R1c9p9w8IkR0= +jsog@1.0.7: + version "1.0.7" + resolved "https://registry.yarnpkg.com/jsog/-/jsog-1.0.7.tgz#b99f7331674807a7aecb3eb16f8aefbded27fb22" + integrity sha1-uZ9zMWdIB6euyz6xb4rvve0n+yI= + json-parse-better-errors@^1.0.1, json-parse-better-errors@^1.0.2: version "1.0.2" resolved "https://registry.yarnpkg.com/json-parse-better-errors/-/json-parse-better-errors-1.0.2.tgz#bb867cfb3450e69107c131d1c514bab3dc8bcaa9" @@ -10618,6 +10623,11 @@ redent@^3.0.0: indent-string "^4.0.0" strip-indent "^3.0.0" +redux-persist@6.0.0: + version "6.0.0" + resolved "https://registry.yarnpkg.com/redux-persist/-/redux-persist-6.0.0.tgz#b4d2972f9859597c130d40d4b146fecdab51b3a8" + integrity sha512-71LLMbUq2r02ng2We9S215LtPu3fY0KgaGE0k8WRgl6RkqxtGfl7HUozz1Dftwsb0D/5mZ8dwAaPbtnzfvbEwQ== + redux-thunk@^2.3.0: version "2.3.0" resolved "https://registry.yarnpkg.com/redux-thunk/-/redux-thunk-2.3.0.tgz#51c2c19a185ed5187aaa9a2d08b666d0d6467622" From e14692077afb08d7707a39ef18da385d3169fe67 Mon Sep 17 00:00:00 2001 From: maelswarm Date: Tue, 27 Apr 2021 20:06:41 -0700 Subject: [PATCH 2/7] * --- src/reducer/slices/collections.ts | 2 +- src/reducer/slices/marketplace.ts | 2 +- src/reducer/slices/system.ts | 3 +-- 3 files changed, 3 insertions(+), 4 deletions(-) diff --git a/src/reducer/slices/collections.ts b/src/reducer/slices/collections.ts index b7666d6a..08ba700a 100644 --- a/src/reducer/slices/collections.ts +++ b/src/reducer/slices/collections.ts @@ -30,7 +30,7 @@ type Reducer = CaseReducer>; export const initialState: CollectionsState = { selectedCollection: null, - globalCollection: config.mainnet.contracts.nftFaucet, + globalCollection: (config as any).mainnet.contracts.nftFaucet, collections: {} }; diff --git a/src/reducer/slices/marketplace.ts b/src/reducer/slices/marketplace.ts index cf24084a..2bfa45ee 100644 --- a/src/reducer/slices/marketplace.ts +++ b/src/reducer/slices/marketplace.ts @@ -27,7 +27,7 @@ type Reducer = CaseReducer>; // Data -const globalMarketplaceAddress = config.mainnet.contracts.marketplace.fixedPrice.tez; +const globalMarketplaceAddress = (config as any).mainnet.contracts.marketplace.fixedPrice.tez; export const initialState: MarketplaceState = { marketplace: { diff --git a/src/reducer/slices/system.ts b/src/reducer/slices/system.ts index 30a26d87..f2913526 100644 --- a/src/reducer/slices/system.ts +++ b/src/reducer/slices/system.ts @@ -7,7 +7,7 @@ import { reconnectWallet } from '../async/wallet'; -const initialState = Minter.connectToolkit(Minter.configure(config.mainnet)) as +const initialState = Minter.connectToolkit(Minter.configure((config as any).mainnet)) as | SystemWithToolkit | SystemWithWallet; @@ -16,7 +16,6 @@ const slice = createSlice({ initialState, reducers: { swapConfig(state, action) { -console.log(action.payload) return { ...state, config: (config as { From 8933c63a340962e30a9ca8033dc69bb17efade43 Mon Sep 17 00:00:00 2001 From: maelswarm Date: Tue, 27 Apr 2021 22:45:04 -0700 Subject: [PATCH 3/7] * --- src/components/App/index.tsx | 83 ++++++++++++++------------------ src/components/common/Header.tsx | 6 +-- src/lib/system.ts | 1 + src/reducer/index.ts | 32 +----------- src/reducer/slices/system.ts | 1 + 5 files changed, 42 insertions(+), 81 deletions(-) diff --git a/src/components/App/index.tsx b/src/components/App/index.tsx index 364ce513..c6a08c4a 100644 --- a/src/components/App/index.tsx +++ b/src/components/App/index.tsx @@ -8,10 +8,9 @@ import MarketplaceCatalog from '../Marketplace/Catalog'; import Header from '../common/Header'; import { Flex } from '@chakra-ui/react'; import Notifications from '../common/Notifications'; -import { useSelector, useDispatch, persistor, store } from '../../reducer'; +import { useSelector, useDispatch } from '../../reducer'; import { reconnectWallet } from '../../reducer/async/wallet'; -import { Provider } from 'react-redux'; -import { PersistGate } from 'redux-persist/lib/integration/react'; + export default function App() { const dispatch = useDispatch(); @@ -19,14 +18,6 @@ export default function App() { let walletReconnectAttempted = state.system.walletReconnectAttempted; - // // This causes excessive resource consumption as *all* marketplace data - // // loads when the app is mounted, even if the user has not landed or will - // // not land on the `/marketplace` view - // - // useEffect(() => { - // dispatch(getMarketplaceNftsQuery(state.marketplace.marketplace.address)); - // }, [state.marketplace.marketplace.address, dispatch]); - useEffect(() => { if (!walletReconnectAttempted) { dispatch(reconnectWallet()); @@ -34,42 +25,38 @@ export default function App() { }, [walletReconnectAttempted, dispatch]); return ( - - - - -
- - - - - - - - - - - - - - - {({ contractAddress }) => ( - - )} - - - {({ contractAddress, tokenId }) => ( - - )} - - - - - - - + + +
+ + + + + + + + + + + + + + + {({ contractAddress }) => ( + + )} + + + {({ contractAddress, tokenId }) => ( + + )} + + + + + ); } diff --git a/src/components/common/Header.tsx b/src/components/common/Header.tsx index 020c60d8..41688b98 100644 --- a/src/components/common/Header.tsx +++ b/src/components/common/Header.tsx @@ -172,13 +172,13 @@ function WalletDisplay() { { await dispatch(disconnectWallet()); swapConfig("mainnet"); dispatch(connectWallet()); }} + onClick={ async () => { await dispatch(disconnectWallet()); dispatch(swapConfig("mainnet")); dispatch(connectWallet()); }} > mainnet { await dispatch(disconnectWallet()); swapConfig("edo2net"); dispatch(connectWallet()); }} + value={'testnet'} + onClick={ async () => { await dispatch(disconnectWallet()); dispatch(swapConfig("testnet")); dispatch(connectWallet()); }} > edo2net diff --git a/src/lib/system.ts b/src/lib/system.ts index 6488ff65..79c683ed 100644 --- a/src/lib/system.ts +++ b/src/lib/system.ts @@ -254,6 +254,7 @@ export async function connectWallet( system: SystemWithToolkit, eventHandlers?: DAppClientOptions['eventHandlers'] ): Promise { + console.log(system); await initWallet(system, true, eventHandlers); return await createSystemWithWallet(system); } diff --git a/src/reducer/index.ts b/src/reducer/index.ts index e8345aa5..791269d9 100644 --- a/src/reducer/index.ts +++ b/src/reducer/index.ts @@ -9,17 +9,6 @@ import systemSlice from './slices/system'; import statusSlice from './slices/status'; import notificationsSlice from './slices/notifications'; import marketplaceSlice from './slices/marketplace'; -import storage from "redux-persist/lib/storage"; -import { - persistStore, persistReducer, createTransform, - FLUSH, - REHYDRATE, - PAUSE, - PERSIST, - PURGE, - REGISTER -} from 'redux-persist'; -import JSOG from 'jsog'; export const reducer = combineReducers({ collections: collectionsSlice.reducer, @@ -30,22 +19,8 @@ export const reducer = combineReducers({ notifications: notificationsSlice.reducer }); -export const JSOGTransform = createTransform( - (inboundState, key) => JSOG.encode(inboundState), - (outboundState, key) => JSOG.decode(outboundState), -) - -const persistConfig = { - key: "App", - version: 1, - storage, - transforms: [JSOGTransform] -}; - -const persistedReducer = persistReducer(persistConfig, reducer); - export const store = configureStore({ - reducer: persistedReducer, + reducer: reducer, middleware: getDefaultMiddleware => getDefaultMiddleware({ immutableCheck: { @@ -56,15 +31,12 @@ export const store = configureStore({ ignoredActions: [ 'wallet/connect/fulfilled', 'wallet/reconnect/fulfilled', - 'wallet/disconnect/fulfilled', - FLUSH, REHYDRATE, PAUSE, PERSIST, PURGE, REGISTER + 'wallet/disconnect/fulfilled' ] } }) }); -export const persistor = persistStore(store); - export type State = ReturnType; export type Dispatch = typeof store.dispatch; export const useDispatch = () => baseUseDispatch(); diff --git a/src/reducer/slices/system.ts b/src/reducer/slices/system.ts index f2913526..082e45f7 100644 --- a/src/reducer/slices/system.ts +++ b/src/reducer/slices/system.ts @@ -16,6 +16,7 @@ const slice = createSlice({ initialState, reducers: { swapConfig(state, action) { + console.log(action.payload) return { ...state, config: (config as { From 73c63268d516a4ca1522f41d30e111a01918f324 Mon Sep 17 00:00:00 2001 From: maelswarm Date: Tue, 27 Apr 2021 22:47:43 -0700 Subject: [PATCH 4/7] * --- package.json | 2 -- src/react-app-env.d.ts | 3 +-- yarn.lock | 10 ---------- 3 files changed, 1 insertion(+), 14 deletions(-) diff --git a/package.json b/package.json index a6ad2fc9..94f9aed2 100644 --- a/package.json +++ b/package.json @@ -26,14 +26,12 @@ "immer": "8.0.0", "io-ts": "2.2.16", "joi": "17.3.0", - "jsog": "1.0.7", "react": "16.13.1", "react-dom": "16.13.1", "react-dropzone": "11.2.4", "react-feather": "2.0.9", "react-icons": "4.2.0", "react-redux": "7.2.2", - "redux-persist": "6.0.0", "typescript": "4.1.3", "wouter": "2.5.1" }, diff --git a/src/react-app-env.d.ts b/src/react-app-env.d.ts index 78f4ac2e..6889c6b3 100644 --- a/src/react-app-env.d.ts +++ b/src/react-app-env.d.ts @@ -1,2 +1 @@ -/// -declare module 'jsog'; \ No newline at end of file +/// \ No newline at end of file diff --git a/yarn.lock b/yarn.lock index 68bca72c..41552070 100644 --- a/yarn.lock +++ b/yarn.lock @@ -7898,11 +7898,6 @@ jsesc@~0.5.0: resolved "https://registry.yarnpkg.com/jsesc/-/jsesc-0.5.0.tgz#e7dee66e35d6fc16f710fe91d5cf69f70f08911d" integrity sha1-597mbjXW/Bb3EP6R1c9p9w8IkR0= -jsog@1.0.7: - version "1.0.7" - resolved "https://registry.yarnpkg.com/jsog/-/jsog-1.0.7.tgz#b99f7331674807a7aecb3eb16f8aefbded27fb22" - integrity sha1-uZ9zMWdIB6euyz6xb4rvve0n+yI= - json-parse-better-errors@^1.0.1, json-parse-better-errors@^1.0.2: version "1.0.2" resolved "https://registry.yarnpkg.com/json-parse-better-errors/-/json-parse-better-errors-1.0.2.tgz#bb867cfb3450e69107c131d1c514bab3dc8bcaa9" @@ -10623,11 +10618,6 @@ redent@^3.0.0: indent-string "^4.0.0" strip-indent "^3.0.0" -redux-persist@6.0.0: - version "6.0.0" - resolved "https://registry.yarnpkg.com/redux-persist/-/redux-persist-6.0.0.tgz#b4d2972f9859597c130d40d4b146fecdab51b3a8" - integrity sha512-71LLMbUq2r02ng2We9S215LtPu3fY0KgaGE0k8WRgl6RkqxtGfl7HUozz1Dftwsb0D/5mZ8dwAaPbtnzfvbEwQ== - redux-thunk@^2.3.0: version "2.3.0" resolved "https://registry.yarnpkg.com/redux-thunk/-/redux-thunk-2.3.0.tgz#51c2c19a185ed5187aaa9a2d08b666d0d6467622" From 15aa55991882b61d6f6e0f3d64b6d6651d837705 Mon Sep 17 00:00:00 2001 From: maelswarm Date: Tue, 27 Apr 2021 23:49:34 -0700 Subject: [PATCH 5/7] * --- src/components/Collections/Catalog/index.tsx | 20 ++++++++------------ src/components/Marketplace/Catalog/index.tsx | 14 +++++++------- src/components/common/Header.tsx | 8 ++++---- src/lib/system.ts | 1 - src/reducer/slices/system.ts | 6 +----- 5 files changed, 20 insertions(+), 29 deletions(-) diff --git a/src/components/Collections/Catalog/index.tsx b/src/components/Collections/Catalog/index.tsx index 25240139..c077ceba 100644 --- a/src/components/Collections/Catalog/index.tsx +++ b/src/components/Collections/Catalog/index.tsx @@ -17,24 +17,20 @@ export default function Catalog() { const collections = useSelector(s => s.collections); const dispatch = useDispatch(); - const globalCollection = - collections.collections[collections.globalCollection]; - useEffect(() => { - if (!globalCollection) { - dispatch(getNftAssetContractQuery(collections.globalCollection)); + if (!collections.collections[system.config.contracts.nftFaucet]) { + dispatch(getNftAssetContractQuery(system.config.contracts.nftFaucet)); return; } if (collections.selectedCollection === null) { - dispatch(selectCollection(collections.globalCollection)); + dispatch(selectCollection(system.config.contracts.nftFaucet)); return; } - }, [ - globalCollection, - collections.selectedCollection, - collections.globalCollection, - dispatch - ]); + }, [collections.selectedCollection, dispatch, collections.collections, system.config.contracts.nftFaucet]); + + useEffect(() => { + dispatch(selectCollection(system.config.contracts.nftFaucet)) + }, [dispatch, system.config.contracts.nftFaucet]) useEffect(() => { if (system.status === 'WalletConnected') { diff --git a/src/components/Marketplace/Catalog/index.tsx b/src/components/Marketplace/Catalog/index.tsx index 73ac0b2d..41922566 100644 --- a/src/components/Marketplace/Catalog/index.tsx +++ b/src/components/Marketplace/Catalog/index.tsx @@ -11,19 +11,19 @@ import FeaturedToken from './FeaturedToken'; import { VisibilityTrigger } from '../../common/VisibilityTrigger'; export default function Catalog() { - const { system, marketplace: state } = useSelector(s => s); + const { system, marketplace } = useSelector(s => s); const dispatch = useDispatch(); useEffect(() => { - dispatch(getMarketplaceNftsQuery(state.marketplace.address)); - }, [state.marketplace.address, dispatch]); + dispatch(getMarketplaceNftsQuery(system.config.contracts.marketplace.fixedPrice.tez)); + }, [marketplace.marketplace.address, dispatch, system.config.contracts.marketplace.fixedPrice.tez]); const loadMore = () => { dispatch(loadMoreMarketplaceNftsQuery({})); }; let tokens = - state.marketplace.tokens?.filter(x => x.token).map(x => x.token!) ?? []; + marketplace.marketplace.tokens?.filter(x => x.token).map(x => x.token!) ?? []; return ( - {state.marketplace.loaded && tokens.length > 0 ? ( + {marketplace.marketplace.loaded && tokens.length > 0 ? ( @@ -46,7 +46,7 @@ export default function Catalog() { w="100%" flexDir="column" > - {!state.marketplace.loaded ? ( + {!marketplace.marketplace.loaded ? ( @@ -93,7 +93,7 @@ export default function Catalog() { ); })} diff --git a/src/components/common/Header.tsx b/src/components/common/Header.tsx index 41688b98..9da19753 100644 --- a/src/components/common/Header.tsx +++ b/src/components/common/Header.tsx @@ -161,7 +161,7 @@ function WalletDisplay() { - + Networks @@ -172,15 +172,15 @@ function WalletDisplay() { { await dispatch(disconnectWallet()); dispatch(swapConfig("mainnet")); dispatch(connectWallet()); }} + onClick={async () => { await dispatch(disconnectWallet()); dispatch(swapConfig("mainnet")); await dispatch(connectWallet()); }} > mainnet { await dispatch(disconnectWallet()); dispatch(swapConfig("testnet")); dispatch(connectWallet()); }} + onClick={async () => { await dispatch(disconnectWallet()); dispatch(swapConfig("testnet")); await dispatch(connectWallet());}} > - edo2net + edonet diff --git a/src/lib/system.ts b/src/lib/system.ts index 79c683ed..6488ff65 100644 --- a/src/lib/system.ts +++ b/src/lib/system.ts @@ -254,7 +254,6 @@ export async function connectWallet( system: SystemWithToolkit, eventHandlers?: DAppClientOptions['eventHandlers'] ): Promise { - console.log(system); await initWallet(system, true, eventHandlers); return await createSystemWithWallet(system); } diff --git a/src/reducer/slices/system.ts b/src/reducer/slices/system.ts index 082e45f7..1ed1e48c 100644 --- a/src/reducer/slices/system.ts +++ b/src/reducer/slices/system.ts @@ -16,12 +16,8 @@ const slice = createSlice({ initialState, reducers: { swapConfig(state, action) { - console.log(action.payload) return { - ...state, - config: (config as { - [key: string]: any, - })[action.payload] + ...(Minter.connectToolkit(Minter.configure((config as any)[action.payload])) as SystemWithToolkit | SystemWithWallet) } } }, From cce84cc5023304bfab8bc54730c9d18079f67fa5 Mon Sep 17 00:00:00 2001 From: maelswarm Date: Wed, 28 Apr 2021 07:24:39 -0700 Subject: [PATCH 6/7] * --- src/reducer/index.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/reducer/index.ts b/src/reducer/index.ts index 791269d9..c7383252 100644 --- a/src/reducer/index.ts +++ b/src/reducer/index.ts @@ -20,7 +20,7 @@ export const reducer = combineReducers({ }); export const store = configureStore({ - reducer: reducer, + reducer, middleware: getDefaultMiddleware => getDefaultMiddleware({ immutableCheck: { From 7dd30fbaba5032d83001b9d1d6dbc119122a778b Mon Sep 17 00:00:00 2001 From: maelswarm Date: Wed, 28 Apr 2021 08:46:29 -0700 Subject: [PATCH 7/7] * --- src/components/Collections/Catalog/CollectionsDropdown.tsx | 6 +++--- src/components/Collections/Catalog/index.tsx | 4 ---- src/components/common/Header.tsx | 5 +++-- 3 files changed, 6 insertions(+), 9 deletions(-) diff --git a/src/components/Collections/Catalog/CollectionsDropdown.tsx b/src/components/Collections/Catalog/CollectionsDropdown.tsx index 10907349..490fb739 100644 --- a/src/components/Collections/Catalog/CollectionsDropdown.tsx +++ b/src/components/Collections/Catalog/CollectionsDropdown.tsx @@ -32,7 +32,7 @@ export default function CollectionsDropdown() { {state.selectedCollection - ? state.collections[state.selectedCollection].metadata.name + ? state.collections[state.selectedCollection]?.metadata.name : '-'} @@ -52,7 +52,7 @@ export default function CollectionsDropdown() { dispatch(selectCollection(state.globalCollection)) } > - {state.collections[state.globalCollection].metadata.name} + {state.collections[state.globalCollection]?.metadata.name} Your Collections @@ -66,7 +66,7 @@ export default function CollectionsDropdown() { selected={address === state.selectedCollection} onClick={() => dispatch(selectCollection(address))} > - {state.collections[address].metadata.name} + {state.collections[address]?.metadata.name} ))} diff --git a/src/components/Collections/Catalog/index.tsx b/src/components/Collections/Catalog/index.tsx index c077ceba..47b264f8 100644 --- a/src/components/Collections/Catalog/index.tsx +++ b/src/components/Collections/Catalog/index.tsx @@ -28,10 +28,6 @@ export default function Catalog() { } }, [collections.selectedCollection, dispatch, collections.collections, system.config.contracts.nftFaucet]); - useEffect(() => { - dispatch(selectCollection(system.config.contracts.nftFaucet)) - }, [dispatch, system.config.contracts.nftFaucet]) - useEffect(() => { if (system.status === 'WalletConnected') { dispatch(getWalletAssetContractsQuery()); diff --git a/src/components/common/Header.tsx b/src/components/common/Header.tsx index 9da19753..7f1f910e 100644 --- a/src/components/common/Header.tsx +++ b/src/components/common/Header.tsx @@ -28,6 +28,7 @@ import { connectWallet, disconnectWallet } from '../../reducer/async/wallet'; import { MinterButton } from '.'; import logo from './assets/splash-logo.svg'; import wallet_icon from './assets/wallet.svg'; +import { selectCollection } from '../../reducer/slices/collections'; interface MobileHeaderLinkProps { to: string; @@ -172,13 +173,13 @@ function WalletDisplay() { { await dispatch(disconnectWallet()); dispatch(swapConfig("mainnet")); await dispatch(connectWallet()); }} + onClick={async () => { await dispatch(disconnectWallet()); dispatch(swapConfig("mainnet")); await dispatch(connectWallet()); await dispatch(selectCollection(system.config.contracts.nftFaucet)) }} > mainnet { await dispatch(disconnectWallet()); dispatch(swapConfig("testnet")); await dispatch(connectWallet());}} + onClick={async () => { await dispatch(disconnectWallet()); dispatch(swapConfig("testnet")); await dispatch(connectWallet()); await dispatch(selectCollection(system.config.contracts.nftFaucet))}} > edonet