metadata.x.data change
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
import {useStore} from "@/store/store.js";
|
||||
import {metadata} from "@/version.js";
|
||||
|
||||
const file_res = ['1m', '3m', '5m', '10m', '15m', '30m', '1H', '2H', '4H', '8H', '12H', '1D', '2D', '3D', '1W',];
|
||||
const supported_res = ['1', '3', '5', '10', '15', '30', '60', '120', '240', '480', '720', '1D', '2D', '3D', '1W',];
|
||||
@@ -81,16 +82,26 @@ export async function jBars (contract, from, to, res) {
|
||||
const mo = String(iDate.getUTCMonth()+1).padStart(2, '0'); // January is month 0 in Date object
|
||||
const date = is_daily_res ? String(iDate.getUTCDate()).padStart(2, '0') : "";
|
||||
const yrmo = !is_single_res ? `-${yr}${mo}` : "";
|
||||
const server = "https://alpha.dexorder.trade"
|
||||
let baseURL = "https://alpha.dexorder.trade/ohlc/"
|
||||
|
||||
// todo use correct chainId not a hardcoded 42161
|
||||
// const chainId = useStore().chainId
|
||||
// let url = `${server}/ohlc/${chainId}/${contract}/${fres}${yrdir}/${contract}-${fres}${yrmo}${date}.json`;
|
||||
let url = `${server}/ohlc/42161/${contract}/${fres}${yrdir}/${contract}-${fres}${yrmo}${date}.json`;
|
||||
let chainId = useStore().chainId
|
||||
// let url = `${server}/${chainId}/${contract}/${fres}${yrdir}/${contract}-${fres}${yrmo}${date}.json`;
|
||||
let inverted = false
|
||||
const meta = metadata[contract]
|
||||
if (meta.x?.data) {
|
||||
baseURL = meta.x.data.uri
|
||||
chainId = meta.x.data.chain
|
||||
contract = meta.x.data.symbol
|
||||
inverted = meta.x.data.inverted
|
||||
}
|
||||
|
||||
let url = `${baseURL}/${chainId}/${contract}/${fres}${yrdir}/${contract}-${fres}${yrmo}${date}.json`;
|
||||
|
||||
let response = await fetch(url);
|
||||
if (response.ok) {
|
||||
ohlc = await response.json();
|
||||
// todo handle inversion
|
||||
console.log(`Fetch: ${ohlc.length} resolution ${res} samples from ${url}`)
|
||||
console.log(`first: ${new Date(ohlc[0][0]*1000).toUTCString()}`)
|
||||
console.log(`last: ${new Date(ohlc[ohlc.length-1][0]*1000).toUTCString()}`)
|
||||
|
||||
Reference in New Issue
Block a user