@mojito-inc/secondary-market
Version:
Mojito secondary market is the platform to purchase NFT.
2 lines (1 loc) • 872 B
JavaScript
;var e=require("@solana/web3.js"),r=require("buffer"),t=require("./getEtherScanURL.utils.js");exports.getTotalVin=async(n,i,o)=>{try{const s=t.getSolanaEnvByChainId(i),d=new e.Connection(o||e.clusterApiUrl(s)),l=new e.PublicKey("Zv2vv8roKtLuqQTFT14NpbhhjWVmu3qhqgiwaG8RrpF"),f=new e.PublicKey(n),[g]=(c=l,u=f,e.PublicKey.findProgramAddressSync([r.Buffer.from("dvin"),r.Buffer.from("dc"),u.toBuffer()],c)),h=await d.getAccountInfo(g);if(!h)return console.error("Failed to fetch account data"),0;const{soldierVin:V,soldierOnGuestVin:v,guestVin:y,maxTT:B}={soldierVin:+(a=h.data).readBigUInt64LE(72).toString(),soldierOnGuestVin:+a.readBigUInt64LE(80).toString(),guestVin:+a.readBigUInt64LE(88).toString(),maxTT:a.readUInt16LE(96)},T=(V+B*(v+y))/10**9;return null!=T?T:0}catch(e){return console.error("Failed to fetch or decode dcConfigAccount:",e),0}var a,c,u};