token metadata fixes for vault and orders view; faucet fix
This commit is contained in:
@@ -2,6 +2,7 @@ import {socket} from "@/socket.js";
|
||||
import {useStore} from "@/store/store.js";
|
||||
import {erc20Abi} from "@/blockchain/abi.js";
|
||||
import {ethers} from "ethers";
|
||||
import {metadata, metadataMap} from "@/version.js";
|
||||
|
||||
|
||||
// synchronous version may return null but will trigger a lookup
|
||||
@@ -24,19 +25,31 @@ export function token(addr) {
|
||||
|
||||
|
||||
// async version doesnt return until it has a token value
|
||||
export async function getToken(addr) {
|
||||
export async function getToken(chainId, addr) {
|
||||
// todo deprecated. use metadataMap[chainId][addr]
|
||||
console.warn('getToken() is deprecated')
|
||||
const s = useStore()
|
||||
if (addr===undefined) {
|
||||
console.warn('getToken(addr) is deprecated. use getToken(chainId,addr)')
|
||||
addr = chainId
|
||||
chainId = s.chainId
|
||||
}
|
||||
let found = metadataMap[chainId][addr]
|
||||
if (found)
|
||||
return found
|
||||
if (!(addr in s.tokens))
|
||||
await addExtraToken(addr)
|
||||
await addExtraToken(chainId, addr)
|
||||
return s.tokens[addr]
|
||||
}
|
||||
|
||||
|
||||
const _inFlightLookups = {}
|
||||
|
||||
export async function addExtraToken(addr) {
|
||||
export async function addExtraToken(chainId, addr) {
|
||||
if (addr===undefined) {
|
||||
console.warn('addExtraToken(addr) is deprecated. use addExtraToken(chainId,addr)')
|
||||
addr = chainId
|
||||
chainId = s.chainId
|
||||
}
|
||||
if( !addr ) {
|
||||
console.log('ignoring call to add extra token', addr)
|
||||
return
|
||||
@@ -45,7 +58,6 @@ export async function addExtraToken(addr) {
|
||||
_inFlightLookups[addr] = true
|
||||
const prom = new Promise((resolve) => {
|
||||
const s = useStore()
|
||||
const chainId = s.chainId
|
||||
console.log('querying token', addr)
|
||||
socket.emit('lookupToken', chainId, addr, (info) => {
|
||||
console.log('server token info', addr, info)
|
||||
|
||||
Reference in New Issue
Block a user