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