From be6656235353fad4dc2faf8f35e62ec8846c1fc9 Mon Sep 17 00:00:00 2001 From: shmuel Date: Mon, 27 Dec 2021 19:20:39 +0200 Subject: [PATCH 1/2] fixed terms and conditions --- src/components/modals/BproClaimModal.js | 3 ++- src/components/modals/TermsAndConditionsModal.js | 6 ++---- src/stores/user.store.js | 5 +++++ 3 files changed, 9 insertions(+), 5 deletions(-) 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/stores/user.store.js b/src/stores/user.store.js index 4e50b30..81d0a40 100644 --- a/src/stores/user.store.js +++ b/src/stores/user.store.js @@ -26,6 +26,11 @@ class UserStore { walletType = null provider connecting = false + userAgreesToTerms = false + + iAgree = () => { + this.userAgreesToTerms = true + } constructor (){ makeAutoObservable(this) From 5c43dbed24911cb6446c6ebd6b3ce962ac428638 Mon Sep 17 00:00:00 2001 From: shmuel Date: Mon, 27 Dec 2021 20:45:01 +0200 Subject: [PATCH 2/2] fixed calim u-BPRO BIP4 --- src/containers/FarmInfo.js | 20 +++++++++----------- src/stores/bpro.store.js | 16 +++++++--------- src/stores/insta.store.js | 16 ++++++---------- src/stores/user.store.js | 8 ++++---- 4 files changed, 26 insertions(+), 34 deletions(-) diff --git a/src/containers/FarmInfo.js b/src/containers/FarmInfo.js index 3b5b5ee..d77dee8 100644 --- a/src/containers/FarmInfo.js +++ b/src/containers/FarmInfo.js @@ -14,7 +14,7 @@ import mainStore from "../stores/main.store" import mainCompStore from "../stores/main.comp.store" import liquityStore from "../stores/main.liquity.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"; @@ -111,11 +111,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; @@ -181,9 +181,7 @@ class FarmInfo extends Component { const { tvlUsdNumeric: makerTvl } = mainStore const { liquityTvlNumeric: liquityTvl, othersTvlNumeric } = liquityStore const tvl = parseInt((compTvl + makerTvl + liquityTvl + othersTvlNumeric) / 1000000) - const instaAccount = instaStore.accounts[0] - const instaBproStore = bproInstaStores[instaAccount] - + if(params.inIframe){ return ( @@ -236,26 +234,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/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/user.store.js b/src/stores/user.store.js index 81d0a40..f6b4cbd 100644 --- a/src/stores/user.store.js +++ b/src/stores/user.store.js @@ -28,14 +28,14 @@ class UserStore { connecting = false userAgreesToTerms = false - iAgree = () => { - this.userAgreesToTerms = true - } - constructor (){ makeAutoObservable(this) } + iAgree = () => { + this.userAgreesToTerms = true + } + selectWallet = async () => { return new Promise((resolve, reject) =>{ this.walletSelectionResult = null