I have currently set up a truffle project with react, redux and react-router. I just finished writing my first implementation of the smart contract, and now want redux to connect with the smart contract. I have tried reading up on several pages, including this: https://truffleframework.com/docs/drizzle/getting-started/using-an-existing-redux-store
However, I cant seem to figure this out. I have now set up my store as follows:
import { createStore, applyMiddleware } from 'redux';
import thunk from 'redux-thunk';
import rootReducer from './reducers/rootReducer';
import ItemList from "./utils/getItems";
//drizzle
import { generateContractsInitialState } from "drizzle";
import ItemOwnershipContract from "./contracts/ItemOwnership.json";
export default function configureStore() {
const options = {
contracts: [
ItemOwnershipContract
]
}
const initialState = {
contracts: generateContractsInitialState(options),
account: "1",
items: new ItemList().itemList,
equipSelector: "0",
raritySelector: "0",
chosenItems: [-1, -1, -1]
}
const enhancers = applyMiddleware(thunk) &&
(window.__REDUX_DEVTOOLS_EXTENSION__ && window.__REDUX_DEVTOOLS_EXTENSION__());
return createStore(
rootReducer,
initialState,
enhancers
);
}
(appologies for the indentation).
How do I now do the following:
Get account address from current user?
Do I still need to use web3 to see if I have connection with the given blockchain?
Will this automatically update the store whenever the content of the smart contract gets updated? Or do I need to force update it?
In that article, they simply call generateContractsInitialState() on "./drizzleOptions", but never shows us the file. What will it contain? A way struct with the contracts array field, and passed in a json file?
do drizzle store my current account address, or do I need to use web3 to fetch that?
I am aware there is a lot of questions here, but I am not very familiar with any of these tools, so I dont quite understand it. Thank you in advance!