diff --git a/generate-static.sh b/generate-static.sh index dde67c6..77efa2a 100755 --- a/generate-static.sh +++ b/generate-static.sh @@ -6,4 +6,5 @@ mkdir liquity && cp index.html liquity mkdir faq && cp index.html faq mkdir risk && cp index.html risk mkdir terms && cp index.html terms -mkdir farm-info && cp index.html farm-info \ No newline at end of file +mkdir farm-info && cp index.html farm-info +mkdir vesta && cp index.html vesta \ No newline at end of file diff --git a/package.json b/package.json index d0c37d0..0719b7a 100644 --- a/package.json +++ b/package.json @@ -1,5 +1,6 @@ { "name": "bprotocol-react-client", + "version": "1.0.29", "version": "1.0.27", "private": true, "dependencies": { diff --git a/src/App.js b/src/App.js index 3a993af..fccb37b 100644 --- a/src/App.js +++ b/src/App.js @@ -20,6 +20,7 @@ const Dashboard = React.lazy(() => import("./containers/Dashboard")); const Compound = React.lazy(() => import("./containers/Compound")); const Liquity = React.lazy(() => import("./containers/Liquity")); const LiquityLegacy = React.lazy(() => import("./containers/LiquityLegacy")); +const Vesta = React.lazy(() => import("./containers/Vesta")); const Risk = React.lazy(() => import("./containers/Risk")); const TermsOfUse = React.lazy(() => import("./containers/Terms")); const FAQ = React.lazy(() => import("./containers/FAQ")); @@ -55,6 +56,7 @@ const App = observer(() => { (renderPage(props, Compound))} /> (renderPage(props, Liquity))} /> (renderPage(props, LiquityLegacy))} /> + (renderPage(props, Vesta))} /> (renderPage(props, FAQ))} /> (renderPage(props, TermsOfUse))} /> (renderPage(props, Risk))} /> diff --git a/src/assets/vesta-logo.svg b/src/assets/vesta-logo.svg new file mode 100644 index 0000000..3c0fd39 --- /dev/null +++ b/src/assets/vesta-logo.svg @@ -0,0 +1,72 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/components/Sidebar.js b/src/components/Sidebar.js index 9918a89..8261757 100644 --- a/src/components/Sidebar.js +++ b/src/components/Sidebar.js @@ -7,6 +7,7 @@ import Discord from "../assets/discord.svg"; import AAVELogo from "../assets/aav-ewhite-logo.svg"; import CompoundLogo from "../assets/compound-logo.svg"; import LiquityLogo from "../assets/liquity-logo.svg"; +import VestaLogo from "../assets/vesta-logo.svg"; import MakerLogo from "../assets/logo-maker-white.svg"; import HundredLogo from "../assets/hundred-logo.svg"; import MigrationModal from "./modals/MigrationModal"; @@ -76,8 +77,9 @@ class Sidebar extends Component { ?
-
{ !params.export && userInfo && userInfo.makerdaoCdpInfo.hasCdp && ( + +
{makerStoreNames.map(makerCollType => )} @@ -101,6 +103,7 @@ class Sidebar extends Component {
+ )} {params.export &&
@@ -132,7 +135,16 @@ class Sidebar extends Component { }`} onClick={() => this.handleItemSelect("liquity")}> - {false && (Testnet)} + {false && (test)} +
+
this.handleItemSelect("vesta")}> + + Arbitrum
diff --git a/src/components/modals/BproClaimModal.js b/src/components/modals/BproClaimModal.js index ce9ab0f..604f494 100644 --- a/src/components/modals/BproClaimModal.js +++ b/src/components/modals/BproClaimModal.js @@ -14,6 +14,7 @@ import XIcon from "../../assets/red-x-icon.svg" import TermsAndConditionsModal from "./TermsAndConditionsModal" import AnimateNumericalString from "../../components/style-components/AnimateNumericalString" import {stringToFixed} from '../../lib/Utils' +import userStore from "../../stores/user.store" const Container = styled.div` @@ -177,7 +178,7 @@ class BproClaimModal extends Component { const {actionState} = this.state const claimed = actionState == "done" const balance = stringToFixed(totalBproNotInWallet, 9) - const agreed = bproStore.userAgreesToTerms + const agreed = userStore.userAgreesToTerms const disabled = claimable == "0" return ( diff --git a/src/components/modals/TermsAndConditionsModal.js b/src/components/modals/TermsAndConditionsModal.js index 0b003e1..7facc40 100644 --- a/src/components/modals/TermsAndConditionsModal.js +++ b/src/components/modals/TermsAndConditionsModal.js @@ -10,7 +10,7 @@ import {device} from "../../screenSizes" import LoadingRing from "../LoadingRing" import BpLoader from "../../components/style-components/BpLoader" import VIcon from "../../assets/v-icon.svg" -import bproStore, {uBproStore} from "../../stores/bpro.store" +import userStore from "../../stores/user.store" import TermsAndConditionsContent from "./TermsAndConditionContent" import BproClaimModal from "./BproClaimModal" @@ -102,9 +102,7 @@ class TermsAndConditionsModal extends Component { } iAgree = () => { - // todo: - bproStore.iAgree() - uBproStore.iAgree() + userStore.iAgree() const noWrapper = true EventBus.$emit('show-modal', , noWrapper); } diff --git a/src/containers/FarmInfo.js b/src/containers/FarmInfo.js index 733b98f..29384f1 100644 --- a/src/containers/FarmInfo.js +++ b/src/containers/FarmInfo.js @@ -15,7 +15,7 @@ import mainCompStore from "../stores/main.comp.store" import liquityStore from "../stores/main.liquity.store" import mainHundredStore from "../stores/main.hundred.store" import userStore from "../stores/user.store" -import instaStore, {bproInstaStores} from "../stores/insta.store" +import instaStore from "../stores/insta.store" import BproClaimModal from "../components/modals/BproClaimModal" import EventBus from "../lib/EventBus" import ConnectButton from "../components/ConnectButton"; @@ -112,11 +112,11 @@ export const Cell = styled(Text)` } ` -export const ANS = props => { +export const ANS = observer((props) => { return ( ) -} +}) export const Button = styled.div` transition: all 0.3s ease-in-out; @@ -180,6 +180,7 @@ class FarmInfo extends Component { const params = qs.parse(search, { ignoreQueryPrefix: true }) const { tvlNumeric: compTvl } = mainCompStore const { tvlUsdNumeric: makerTvl } = mainStore + const { liquityTvlNumeric: liquityTvl } = liquityStore const tvl = parseInt((compTvl + makerTvl + liquityTvl + mainHundredStore.TVL) / 1000000) const instaAccounts = instaStore.accounts @@ -236,26 +237,26 @@ class FarmInfo extends Component {
-
+ {Object.entries(instaStore.bproInstaStores).map(([account, store]) =>
- INSTADAPP account {instaAccount} + INSTADAPP account {account} Claimable uBPRO-BIP4 - + - -
+
)}
<a target="_blank" href="https://forum.bprotocol.org/t/bip-1-bpro-tokenomics-change-reward-liquidity-providers-on-sushiswap-and-uniswap/82"> diff --git a/src/containers/Vesta.js b/src/containers/Vesta.js new file mode 100644 index 0000000..294df74 --- /dev/null +++ b/src/containers/Vesta.js @@ -0,0 +1,27 @@ +import React, { Component } from "react"; +import {observer} from "mobx-react" +import routerStore from "../stores/router.store" + +class Vesta extends Component { + + constructor(props) { + super(props); + } + + componentDidMount() { + routerStore.setRouteProps(this.props.history) + } + + render() { + return ( + <iframe + src="/vesta-app/" + width="100%" + height="100%" + frameBorder="0" + /> + ); + } +} + +export default observer(Vesta) diff --git a/src/stores/bpro.store.js b/src/stores/bpro.store.js index a5fac9f..09a0192 100644 --- a/src/stores/bpro.store.js +++ b/src/stores/bpro.store.js @@ -17,7 +17,6 @@ const {toBN, toWei, fromWei} = Web3.utils export class BproStore { - userAgreesToTerms = false smartContractScore = null claimed = "0" claimable = "0" @@ -41,12 +40,11 @@ export class BproStore { this.bproType = type this.instaUser = instaUser makeAutoObservable(this) - this.init() } onUserConnect = async () => { try{ - await !this.smartContractScore ? this.init() : Promise.resolve(this.smartContractScore) + await this.init() await Promise.all([ this.getClaimableAmount(), this.getUnclaimableAmount(), @@ -80,7 +78,7 @@ export class BproStore { let {user, web3} = userStore user = this.instaUser || user const claimed = await getClaimedAmount(web3, user, this.bproType) - + console.log(claimed) const {amount} = this.smartContractScore.userData[user.toLowerCase()] || {} if(amount){ @@ -128,29 +126,29 @@ export class BproStore { user = this.instaUser || user const {cycle, index, amount, proof} = this.smartContractScore.userData[user.toLowerCase()] const tx = claimBpro(web3, user, cycle, index.toString(), amount, proof, this.bproType) - await ApiAction(tx, user, web3, 0) + await ApiAction(tx, userStore.user, web3, 0) await this.onUserConnect() // refresh state } init = async () => { let url try{ + if(this.smartContractScore && this.smartContractScore.userData){ + return Promise.resolve(this.smartContractScore) + } const web3 = new Web3(BP_API) // todo fetch data const {contentHash} = await getBproDistribution(web3, this.bproType) url = "https://cloudflare-ipfs.com/ipfs/" + contentHash const res = await fetch(url) this.smartContractScore = await res.json() + return this.smartContractScore } catch (err) { console.error("failed to fetch score data from: ", url) console.error(err) } } - iAgree = () => { - this.userAgreesToTerms = true - } - showClaimBproPopup = () => { if(!userStore.loggedIn){ userStore.showConnect() diff --git a/src/stores/insta.store.js b/src/stores/insta.store.js index 345456d..3d4c56c 100644 --- a/src/stores/insta.store.js +++ b/src/stores/insta.store.js @@ -7,10 +7,8 @@ import userStore from "./user.store" import { BproStore } from './bpro.store' import { ApyStore } from './apy.store' -export const bproInstaStores = {} - class InstaStore { - accounts = [] + bproInstaStores = {} constructor (){ makeAutoObservable(this) @@ -28,14 +26,12 @@ class InstaStore { const { web3, networkType, user } = userStore const accounts = await getAccounts(web3, networkType, user) accounts.forEach(account => { - bproInstaStores[account] = new BproStore('uBPRO-BIP4', account) - bproInstaStores[account].onUserConnect() - }) - runInAction(()=> { - this.accounts = accounts + const store = new BproStore('uBPRO-BIP4', account) + store.onUserConnect() + this.bproInstaStores[account] = store }) } - -} +} + export default new InstaStore() \ No newline at end of file diff --git a/src/stores/main.hundred.store.js b/src/stores/main.hundred.store.js index 6840c20..0226d03 100644 --- a/src/stores/main.hundred.store.js +++ b/src/stores/main.hundred.store.js @@ -30,7 +30,6 @@ class MainHundredStore { try{ const {data} = await axios.get('https://api.llama.fi/protocol/b.protocol') const {currentChainTvls} = data - debugger this.hundredTvlArbitrum = currentChainTvls.Arbitrum this.hundredTvlFantom = currentChainTvls.Fantom } catch (err) { diff --git a/src/stores/user.store.js b/src/stores/user.store.js index 4e50b30..785360a 100644 --- a/src/stores/user.store.js +++ b/src/stores/user.store.js @@ -15,6 +15,12 @@ import WalletConnectProvider from "@walletconnect/web3-provider"; import {walletTypes, getMetaMask, getWalletConnect} from "../wallets/Wallets" import WalletSelectionModal from "../components/modals/WalletSelectionModal" +const supportedNetworks = { + "1": "Mainnet", + "42": "Kovan", + "1137": "Hardhat" +} + class UserStore { loggedIn = false @@ -26,11 +32,16 @@ class UserStore { walletType = null provider connecting = false + userAgreesToTerms = false constructor (){ makeAutoObservable(this) } + iAgree = () => { + this.userAgreesToTerms = true + } + selectWallet = async () => { return new Promise((resolve, reject) =>{ this.walletSelectionResult = null @@ -100,8 +111,11 @@ class UserStore { // save connection data to local storage window.localStorage.setItem("walletType", this.walletType) const networkType = await this.web3.eth.net.getId() - if (parseInt(networkType) !== parseInt(0x2a) && parseInt(networkType) !== parseInt(0x1) && parseInt(networkType) !== 1337) { - EventBus.$emit("app-error", "Only Mainnet and Kovan testnet are supported"); + if (!supportedNetworks[networkType.toString()]) { + const path = window.location.pathname + if(path == "/compound" || path == "/maker" || path == "/app"){ + EventBus.$emit("app-error", "Only Mainnet and Kovan testnet are supported"); + } return false; } runInAction(()=> { @@ -134,6 +148,10 @@ class UserStore { connectionWarning = () => { this.loggedIn = false + if(window.location.pathname != "/compound"){ + this.removeConnectionWarning() + return + } EventBus.$emit('app-alert', "something went wrong please try to reconnect", "reconnect", this.connect) }