new ohlc; beta signin; elaborated order status (not working yet)
This commit is contained in:
@@ -118,6 +118,15 @@ export function isOpen(state) {
|
||||
return state >= 1 && state < 3
|
||||
}
|
||||
|
||||
|
||||
export function parseElaboratedOrderStatus(chainId, status) {
|
||||
const [txId, ...remaining] = status
|
||||
const result = parseOrderStatus(chainId, remaining)
|
||||
result.txId = txId
|
||||
return result
|
||||
}
|
||||
|
||||
|
||||
export function parseOrderStatus(chainId, status) {
|
||||
let [
|
||||
order,
|
||||
|
||||
@@ -90,7 +90,7 @@ const seriesStarts = {}
|
||||
async function getUrl(url) {
|
||||
try {
|
||||
const response = await fetch(url)
|
||||
console.log('got response', response)
|
||||
// console.log('got response', response)
|
||||
if (response.ok)
|
||||
return await response.text()
|
||||
else
|
||||
@@ -104,7 +104,7 @@ async function getUrl(url) {
|
||||
|
||||
|
||||
export async function loadOHLC (symbol, contract, from, to, tvRes) {
|
||||
console.log('loadOHLC', tvRes, new Date(1000*from), new Date(1000*to), symbol, contract);
|
||||
// console.log('loadOHLC', tvRes, new Date(1000*from), new Date(1000*to), symbol, contract);
|
||||
let chainId
|
||||
let bars = [];
|
||||
let inverted = symbol.inverted;
|
||||
@@ -130,8 +130,6 @@ export async function loadOHLC (symbol, contract, from, to, tvRes) {
|
||||
}
|
||||
baseURL += `${chainId}/${contract}/`
|
||||
|
||||
console.log('baseURL', baseURL)
|
||||
|
||||
const res = resMap[tvRes]
|
||||
const fetches = []
|
||||
let start = from
|
||||
@@ -140,7 +138,7 @@ export async function loadOHLC (symbol, contract, from, to, tvRes) {
|
||||
const response = await getUrl(baseURL+'quote.csv')
|
||||
if (response.length) {
|
||||
seriesStarts[baseURL] = parseInt(response.split(',')[0])
|
||||
console.log(`Series ${baseURL} starts at ${new Date(start*1000)}`)
|
||||
// console.log(`Series ${baseURL} starts at ${new Date(start*1000)}`)
|
||||
}
|
||||
else {
|
||||
console.error(`Bad response while fetching ${baseURL+'quote.csv'}`)
|
||||
@@ -155,7 +153,7 @@ export async function loadOHLC (symbol, contract, from, to, tvRes) {
|
||||
|
||||
for(let now = start; now < to; now = res.nextStart(now)) {
|
||||
const url = baseURL + res.filename(contract, now);
|
||||
console.log('fetching', url)
|
||||
// console.log('fetching', url)
|
||||
const prom = getUrl(url)
|
||||
fetches.push(prom);
|
||||
}
|
||||
@@ -166,7 +164,7 @@ export async function loadOHLC (symbol, contract, from, to, tvRes) {
|
||||
let lineNum = 0
|
||||
response.split('\n').forEach((line) => {
|
||||
lineNum++
|
||||
console.log(`processing line ${lineNum}`, line)
|
||||
// console.log(`processing line ${lineNum}`, line)
|
||||
const row = line.split(',')
|
||||
let time, open, high, low, close=null
|
||||
switch (row.length) {
|
||||
@@ -216,17 +214,17 @@ export async function loadOHLC (symbol, contract, from, to, tvRes) {
|
||||
break
|
||||
}
|
||||
if (close!==null) {
|
||||
console.log(`filling up to ${time}`)
|
||||
// console.log(`filling up to ${time}`)
|
||||
fill(time, res.period)
|
||||
const bar = {time:time*1000, open, high, low, close};
|
||||
console.log('pushing bar', bar)
|
||||
// console.log('pushing bar', bar)
|
||||
bars.push(bar)
|
||||
latest = [time, close]
|
||||
}
|
||||
})
|
||||
console.log(`processed ${lineNum} lines`)
|
||||
// console.log(`processed ${lineNum} lines`)
|
||||
}
|
||||
else { console.log('response was empty') }
|
||||
// else { console.log('response was empty') }
|
||||
}
|
||||
|
||||
fill(to, res.period)
|
||||
@@ -241,7 +239,7 @@ export async function loadOHLC (symbol, contract, from, to, tvRes) {
|
||||
// backward to find beginning of history. How far to search?
|
||||
|
||||
let noData = bars.length === 0;
|
||||
if (noData) console.log("noData == true!");
|
||||
console.log('bars', bars)
|
||||
// if (noData) console.log("noData == true!");
|
||||
// console.log('bars', bars)
|
||||
return [bars, {noData}];
|
||||
}
|
||||
|
||||
@@ -53,7 +53,7 @@ export function buildMetadataMap(metadata) {
|
||||
map[tokenMeta.a] = tokenMeta
|
||||
metadataMap[Number(chain)] = map
|
||||
}
|
||||
console.log('metadataMap', metadataMap)
|
||||
// console.log('metadataMap', metadataMap)
|
||||
return metadataMap
|
||||
}
|
||||
|
||||
|
||||
35
src/components/BetaSignin.vue
Normal file
35
src/components/BetaSignin.vue
Normal file
@@ -0,0 +1,35 @@
|
||||
<template>
|
||||
<slot v-if="s.allowed"/>
|
||||
<v-card v-if="!s.allowed" rounded="0" title="Dexorder Closed 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,4 +1,5 @@
|
||||
<template>
|
||||
<beta-signin>
|
||||
<slot v-if="status===Status.OK" v-bind="$props"/>
|
||||
<v-card v-if="status!==Status.OK" rounded="0">
|
||||
<v-card-title>
|
||||
@@ -35,6 +36,7 @@
|
||||
</v-card-actions>
|
||||
|
||||
</v-card>
|
||||
</beta-signin>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
@@ -42,8 +44,8 @@ import {useStore} from "@/store/store";
|
||||
import {computed, ref} from "vue";
|
||||
import {connectWallet, switchChain} from "@/blockchain/wallet.js";
|
||||
import Btn from "@/components/Btn.vue";
|
||||
import CopyButton from "@/components/CopyButton.vue";
|
||||
import Logo from "@/components/Logo.vue";
|
||||
import BetaSignin from "@/components/BetaSignin.vue";
|
||||
|
||||
const s = useStore()
|
||||
const disabled = ref(false)
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import {io} from "socket.io-client";
|
||||
import {useStore} from "@/store/store.js";
|
||||
import {flushOrders} from "@/blockchain/wallet.js";
|
||||
import {parseOrderStatus} from "@/blockchain/orderlib.js";
|
||||
import {parseElaboratedOrderStatus} from "@/blockchain/orderlib.js";
|
||||
import { DataFeed } from "./charts/datafeed";
|
||||
|
||||
export const socket = io(import.meta.env.VITE_WS_URL || undefined, {transports: ["websocket"]})
|
||||
@@ -61,7 +61,7 @@ function handleOrderStatus(chainId, vault, orderIndex, status) {
|
||||
if( s.chainId !== chainId )
|
||||
return
|
||||
// message 'o' is a single order status
|
||||
const parsed = parseOrderStatus(chainId, status);
|
||||
const parsed = parseElaboratedOrderStatus(chainId, status);
|
||||
console.log('o', chainId, vault, orderIndex, status, parsed)
|
||||
if( !(vault in s.orders) )
|
||||
s.orders[vault] = {}
|
||||
|
||||
@@ -31,9 +31,9 @@ function timestamp() {
|
||||
return Math.round(new Date().getTime() / 1000)
|
||||
}
|
||||
|
||||
|
||||
const UNKNOWN_PROVIDER = {}
|
||||
|
||||
const REQUIRE_AUTH = import.meta.env.VITE_REQUIRE_AUTH !== 'NOAUTH';
|
||||
|
||||
export const useStore = defineStore('app', ()=> {
|
||||
const clock = ref(timestamp()) // the clock ticks infrequently enough to be mostly stable for user display
|
||||
@@ -42,6 +42,8 @@ export const useStore = defineStore('app', ()=> {
|
||||
|
||||
const nav = ref(false) // controls opening navigation drawer
|
||||
|
||||
const allowed = ref(!REQUIRE_AUTH)
|
||||
|
||||
const _chainId = ref(Number(Object.keys(versionMeta.chainInfo)[0]))
|
||||
const _chainInfo = ref(versionMeta.chainInfo)
|
||||
|
||||
@@ -128,7 +130,7 @@ export const useStore = defineStore('app', ()=> {
|
||||
}
|
||||
|
||||
return {
|
||||
nav, chainId, chainInfo, chain, provider, providerRef, vaultInitCodeHash, account, vaults, vaultVersions,
|
||||
allowed, nav, chainId, chainInfo, chain, provider, providerRef, vaultInitCodeHash, account, vaults, vaultVersions,
|
||||
transactionSenders, errors, extraTokens, poolPrices, vaultBalances, orders, vault, version, upgrade, vaultOrders,
|
||||
tokens, factory, helper,
|
||||
mockenv, mockCoins,
|
||||
|
||||
Reference in New Issue
Block a user