import { Lux, BinTools, Buffer } from "../../src" import { IndexAPI } from "../../src/apis/index/index" import { GetLastAcceptedResponse } from "../../src/apis/index/interfaces" import { Vertex } from "../../src/apis/xvm" const ip: string = "indexer-demo.lux.network" const port: number = 443 const protocol: string = "https" const networkID: number = 1 const lux: Lux = new Lux(ip, port, protocol, networkID) const index: IndexAPI = lux.Index() const bintools: BinTools = BinTools.getInstance() const main = async (): Promise => { const encoding: string = "cb58" const baseurl: string = "/ext/index/X/vtx" const lastVertex: GetLastAcceptedResponse = await index.getLastAccepted( encoding, baseurl ) console.log(lastVertex) const vertex: Vertex = new Vertex() vertex.fromBuffer(bintools.cb58Decode(lastVertex.bytes)) console.log(vertex) console.log("--------") const buf: Buffer = vertex.toBuffer() const v: Vertex = new Vertex() v.fromBuffer(buf) console.log(v) } main()