metadata has chainId as first key
This commit is contained in:
@@ -143,10 +143,16 @@ function addSymbol(p, base, quote, inverted) {
|
||||
|
||||
async function getAllSymbols() {
|
||||
if (_symbols===null) {
|
||||
const chainId = useStore().chainId.value;
|
||||
const md = metadata[chainId]
|
||||
if(!md) {
|
||||
console.log('could not get metadata for chain', chainId)
|
||||
return []
|
||||
}
|
||||
_symbols = {}
|
||||
for (const t of metadata.t)
|
||||
for (const t of md.t)
|
||||
tokenMap[t.a] = t
|
||||
metadata.p.forEach((p)=>{
|
||||
md.p.forEach((p)=>{
|
||||
poolMap[p.a] = p
|
||||
const base = tokenMap[p.b];
|
||||
const quote = tokenMap[p.q];
|
||||
@@ -173,24 +179,24 @@ export function lookupSymbol(key) { // lookup by fullname
|
||||
}
|
||||
|
||||
export function lookupBaseQuote(baseAddr, quoteAddr) {
|
||||
|
||||
return _symbols[key]
|
||||
return _symbols[`${baseAddr}${quoteAddr}`]
|
||||
}
|
||||
|
||||
function poolIsInverted(pool) {
|
||||
const chainId = useStore().chainId.value
|
||||
let p
|
||||
for (p of metadata.p) {
|
||||
if (p.a==pool.substr(0,42)) {
|
||||
for (p of metadata[chainId].p) {
|
||||
if (p.a===pool.substr(0,42)) {
|
||||
let fullname = `${p.q}${p.b}`
|
||||
let symbol = lookupSymbol(fullname)
|
||||
if (symbol in [undefined, null]) {
|
||||
throw error(`poolIsInverted: pool fullname not found: ${fullname}`)
|
||||
throw Error(`poolIsInverted: pool fullname not found: ${fullname}`)
|
||||
}
|
||||
return symbol.inverted
|
||||
// return p.x.data.inverted ^ symbol.inverted
|
||||
}
|
||||
}
|
||||
throw error(`poolIsInverted: pool not found in metadata.json: ${pool}`)
|
||||
throw Error(`poolIsInverted: pool not found in metadata.json: ${pool}`)
|
||||
}
|
||||
|
||||
export function maybeInvertBar (pool, bar) {
|
||||
|
||||
Reference in New Issue
Block a user