Skip to content

Commit

Permalink
app up and running. Phunkkkkkkkkkkkkkkkk YESSSSSSSSSSS
Browse files Browse the repository at this point in the history
  • Loading branch information
mutahhirkhan committed Mar 22, 2022
1 parent c6c9a88 commit aff67fc
Showing 7 changed files with 1,864 additions and 1,943 deletions.
8 changes: 1 addition & 7 deletions src/Layout/Layout.js
Original file line number Diff line number Diff line change
@@ -46,7 +46,6 @@ export const Layout = () => {
dispatch(signOut());
}
});

//enable metamask
const isEnabled = await enable(dispatch);
if (isEnabled) {
@@ -66,18 +65,13 @@ export const Layout = () => {
setupApp(dispatch);
listenNetworkChange(dispatch);
}, []);
useEffect(() => {
console.log("appState.isAppLoaded");
console.log(appState.isAppLoaded);
},[appState.isAppLoaded])


useEffect(() => {
//listen account changed event
listenAccountChange(user.address, dispatch);

dispatch(setIsUserAccountSelected(appState.currentAccount === user.address));
console.log("user")
console.log(user)
}, [user]);


2 changes: 1 addition & 1 deletion src/components/NavigationBar/NavigationBar.js
Original file line number Diff line number Diff line change
@@ -41,7 +41,7 @@ export const NavigationBar = () => {
}
id="basic-nav-dropdown">
<NavDropdown.Item as={Link} to='/profile' href='#profile'>Profile</NavDropdown.Item>
<NavDropdown.Item as={Link} href='#signout' onClick={signOutHandler}>Sign Out</NavDropdown.Item>
<NavDropdown.Item as={Link} to="" href='#signout' onClick={signOutHandler}>Sign Out</NavDropdown.Item>
</NavDropdown>;

if (auth.loading) {
2 changes: 1 addition & 1 deletion src/containers/Campaigns/Campaigns.js
Original file line number Diff line number Diff line change
@@ -7,7 +7,7 @@ import * as ethService from '../../services/ethereum/ethService';
export const Campaigns = () => {
const [campaigns, setCampaigns] = useState([]);
const [count, setCount] = useState(0);
const [isLoading, setIsLoading] = useState(false)
// const [isLoading, setIsLoading] = useState(false)

const loadCampaigns = useCallback(async () => {
//get campaign count
3,766 changes: 1,843 additions & 1,923 deletions src/contract/CampaignFactory.json

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions src/services/ethereum/ethService.js
Original file line number Diff line number Diff line change
@@ -43,6 +43,7 @@ export const listenNetworkChange = (dispatch) => {
export const enable = async (dispatch) => {
//get campagin factory address from firebase
factoryAddress = await getCampaginFactoryAddress();

factory = new Contract(CAMPAIGN_FACTORY_ABI, factoryAddress);

if (web3.givenProvider) {
@@ -122,6 +123,7 @@ export const getCampaign = async (campaignAddress, userAddress) => {

export const getCampaignsCount = async () => {
let count = await factory.methods.getCampaignsCount().call();
console.log("count",count);
return count;
}

19 changes: 10 additions & 9 deletions src/services/firebase/config.js
Original file line number Diff line number Diff line change
@@ -2,22 +2,23 @@ import firebase from 'firebase';
import 'firebase/auth';
import 'firebase/storage';
import 'firebase/database';
import 'firebase/firestore';

// Set the configuration for your app
// TODO: Replace with your app's config object
const firebaseConfig = {
apiKey: "AIzaSyC3LNbwxHFGGPl5jKXG3CjBVBrER350fR8",
authDomain: "de-care-11445.firebaseapp.com",
databaseURL: "https://de-care-11445.firebaseio.com",
projectId: "de-care-11445",
storageBucket: "de-care-11445.appspot.com",
messagingSenderId: "1080234101368",
appId: "1:1080234101368:web:83946f7ea4a35d12077b8d",
measurementId: "G-KJ4Z9S3NFC"
};
apiKey: "AIzaSyB8cMdUj1VTodhe85kwwJ_g3jMJyHa_e6k",
authDomain: "fypdecare.firebaseapp.com",
projectId: "fypdecare",
storageBucket: "fypdecare.appspot.com",
messagingSenderId: "199245709655",
appId: "1:199245709655:web:e1b321a748ede6c535fe12",
measurementId: "G-WP7GCMCDLT"
};

firebase.initializeApp(firebaseConfig);

export const database = firebase.database();
export const firestore = firebase.firestore();
export const storage = firebase.storage();
export const auth = firebase.auth();
8 changes: 6 additions & 2 deletions src/services/firebase/databaseService.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { database } from './config';
import { database, firestore } from './config';

const write = async (node, jsonData) => {
await database.ref(node).set(jsonData);
@@ -49,7 +49,11 @@ export const getUserDonations = async (userAddress) => {
}

export const getCampaginFactoryAddress = async () => {
return await read('campaignFactoryAddress');
const res = await firestore.collection("campaignFactoryAddress").get();
const address = res.docs.find(doc => {
if(doc.data().value !== "") return doc.data().value;
} )
return address.data().value;
}
//donations structure
// const donations = {

0 comments on commit aff67fc

Please sign in to comment.