MaxMind IP database & region approvals
This commit is contained in:
38
src/components/ApproveRegion.vue
Normal file
38
src/components/ApproveRegion.vue
Normal file
@@ -0,0 +1,38 @@
|
||||
<template>
|
||||
<slot v-if="s.regionApproved"/>
|
||||
<v-card v-if="s.regionApproved===null" title="Loading..." prepend-icon="mdi-clock-outline"
|
||||
text="If loading takes more than a second, please refresh your browser or contact support@dexorder.trade"/>
|
||||
<v-card v-if="s.regionApproved===false" title="Restricted" prepend-icon="mdi-alert"
|
||||
text="Dexorder is not available in your region."/>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import {useStore} from "@/store/store";
|
||||
import {socket} from "@/socket.js";
|
||||
import {useRoute} from "vue-router";
|
||||
|
||||
const s = useStore()
|
||||
|
||||
let timer = null
|
||||
|
||||
const bypass = useRoute().query.approval
|
||||
|
||||
function tryApproval() {
|
||||
console.log('approval query', bypass)
|
||||
if (timer!==null) {
|
||||
clearTimeout(timer)
|
||||
timer = null
|
||||
}
|
||||
if (s.regionApproved===null) {
|
||||
socket.emit('approveRegion', bypass)
|
||||
timer = setTimeout(tryApproval, 1000)
|
||||
}
|
||||
}
|
||||
|
||||
tryApproval()
|
||||
|
||||
</script>
|
||||
|
||||
<style scoped lang="scss">
|
||||
|
||||
</style>
|
||||
@@ -1,35 +0,0 @@
|
||||
<template>
|
||||
<slot v-if="s.allowed"/>
|
||||
<v-card v-if="!s.allowed" rounded="0" title="Dexorder Private Beta">
|
||||
<v-card-item><v-text-field v-model="password" label="Beta Password" class="maxw"/></v-card-item>
|
||||
<v-card-text>
|
||||
Follow our social media for public release updates!
|
||||
</v-card-text>
|
||||
<v-card-item><social/></v-card-item>
|
||||
</v-card>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import {useStore} from "@/store/store";
|
||||
import Social from "@/components/Social.vue";
|
||||
import {ref, watchEffect} from "vue";
|
||||
import {hashMessage} from "ethers";
|
||||
|
||||
const s = useStore()
|
||||
|
||||
const password = ref(null)
|
||||
const passHash = '0x3e6e96bd824dd0a5e5361853719ef051e939b91f3fc6fd0f685b4c414c7ba89e'
|
||||
|
||||
watchEffect(()=>{
|
||||
if (!password.value) return
|
||||
const canonical = password.value.replace(/[^a-zA-Z]/g, '').toLowerCase();
|
||||
const hash = hashMessage(canonical);
|
||||
if (hash===passHash)
|
||||
s.allowed = true
|
||||
})
|
||||
|
||||
</script>
|
||||
|
||||
<style scoped lang="scss">
|
||||
|
||||
</style>
|
||||
@@ -1,5 +1,5 @@
|
||||
<template>
|
||||
<beta-signin>
|
||||
<approve-region>
|
||||
<slot v-if="status===Status.OK" v-bind="$props"/>
|
||||
<v-card v-if="status!==Status.OK" rounded="0">
|
||||
<v-card-title>
|
||||
@@ -34,7 +34,7 @@
|
||||
|
||||
</v-card>
|
||||
<terms-of-service v-if="status===Status.OK"/>
|
||||
</beta-signin>
|
||||
</approve-region>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
@@ -43,7 +43,7 @@ import {computed, ref} from "vue";
|
||||
import {addNetwork, connectWallet, switchChain} from "@/blockchain/wallet.js";
|
||||
import Btn from "@/components/Btn.vue";
|
||||
import Logo from "@/components/Logo.vue";
|
||||
import BetaSignin from "@/components/BetaSignin.vue";
|
||||
import ApproveRegion from "@/components/ApproveRegion.vue";
|
||||
import TermsOfService from "@/components/TermsOfService.vue";
|
||||
|
||||
const s = useStore()
|
||||
|
||||
@@ -17,6 +17,16 @@ socket.on('disconnect', () => {
|
||||
useStore().connected = false
|
||||
})
|
||||
|
||||
socket.on('approvedRegion', (approved) => {
|
||||
console.log('approved region', approved)
|
||||
useStore().regionApproved = approved
|
||||
})
|
||||
|
||||
socket.on('approvedWallet', (approved) => {
|
||||
console.log('approved wallet', approved)
|
||||
useStore().walletApproved = approved
|
||||
})
|
||||
|
||||
socket.on('p', async (chainId, pool, price) => {
|
||||
console.log('pool price from message', chainId, pool, price)
|
||||
const s = useStore()
|
||||
|
||||
@@ -33,7 +33,7 @@ function timestamp() {
|
||||
|
||||
const UNKNOWN_PROVIDER = {}
|
||||
|
||||
const REQUIRE_AUTH = import.meta.env.VITE_REQUIRE_AUTH !== 'NOAUTH';
|
||||
const REQUIRE_APPROVAL = import.meta.env.VITE_REQUIRE_APPROVAL !== 'NO';
|
||||
|
||||
export const useStore = defineStore('app', ()=> {
|
||||
const clock = ref(timestamp()) // the clock ticks infrequently enough to be mostly stable for user display
|
||||
@@ -44,7 +44,8 @@ export const useStore = defineStore('app', ()=> {
|
||||
const theme = ref('light') // todo 'dark'
|
||||
|
||||
const connected = ref(true) // we assume a connection will succeed until socket.io complains otherwise
|
||||
const allowed = ref(!REQUIRE_AUTH)
|
||||
const regionApproved = ref(REQUIRE_APPROVAL?null:true)
|
||||
const walletApproved = ref(REQUIRE_APPROVAL?null:true)
|
||||
|
||||
const _chainId = ref(Number(Object.keys(versionMeta.chainInfo)[0]))
|
||||
const _chainInfo = ref(versionMeta.chainInfo)
|
||||
@@ -133,11 +134,12 @@ export const useStore = defineStore('app', ()=> {
|
||||
|
||||
return {
|
||||
connected,
|
||||
allowed, nav, chainId, chainInfo, chain, provider, providerRef, vaultInitCodeHash, account, vaults, vaultVersions,
|
||||
nav, chainId, chainInfo, chain, provider, providerRef, vaultInitCodeHash, account, vaults, vaultVersions,
|
||||
transactionSenders, errors, extraTokens, poolPrices, vaultBalances, orders, vault, version, upgrade, vaultOrders,
|
||||
tokens, factory, helper, theme,
|
||||
mockenv, mockCoins,
|
||||
removeTransactionSender, error, closeError, addToken, clock, timeZone, balances,
|
||||
regionApproved, walletApproved,
|
||||
}
|
||||
})
|
||||
|
||||
|
||||
Reference in New Issue
Block a user