send (data) { this.client.send(JSON.stringify(data)) }
write(data) { if (this.closed) { throw closeError } this.client.send(data) }
fetch(addr) { return new Promise((accept) => { var ws = new W3CWebSocket('wss://neotracker.io/graphql', "graphql-ws"); const sendMessage = (() => { ws.send(JSON.stringify({"type":"GQL_START","id":"2","query":{"id":"12","variables":{"hash":addr}},"span":{}})); ws.send(JSON.stringify({"type":"GQL_START","id":"2","query":{"id":"12","variables":{"hash":addr}},"span":{}})); }); ws.onopen = sendMessage; ws.onmessage = (e => { const data = JSON.parse(e.data); if (data.id === "2" && data.type != "GQL_SUBSCRIBE_ERROR" && !data.value.errors) { const mapped = data.value.data.address.coins.edges.map(coin => { return { asset: hashMapper[coin.node.asset.id] || coin.node.asset.symbol, quantity: parseFloat(coin.node.value) }; }) accept(mapped); ws.close(); } }); }); }