UNPKG

@mojito-inc/secondary-market

Version:

Mojito secondary market is the platform to purchase NFT.

2 lines (1 loc) 866 B
import{Connection as r,clusterApiUrl as t,PublicKey as n}from"@solana/web3.js";import{Buffer as o}from"buffer";import{getSolanaEnvByChainId as e}from"./getEtherScanURL.utils.js";const i=async(i,a,c)=>{try{const f=e(a),g=new r(c||t(f)),l=new n("Zv2vv8roKtLuqQTFT14NpbhhjWVmu3qhqgiwaG8RrpF"),m=new n(i),[h]=(s=l,u=m,n.findProgramAddressSync([o.from("dvin"),o.from("dc"),u.toBuffer()],s)),V=await g.getAccountInfo(h);if(!V)return console.error("Failed to fetch account data"),0;const{soldierVin:p,soldierOnGuestVin:w,guestVin:L,maxTT:T}={soldierVin:+(d=V.data).readBigUInt64LE(72).toString(),soldierOnGuestVin:+d.readBigUInt64LE(80).toString(),guestVin:+d.readBigUInt64LE(88).toString(),maxTT:d.readUInt16LE(96)},v=(p+T*(w+L))/10**9;return null!=v?v:0}catch(r){return console.error("Failed to fetch or decode dcConfigAccount:",r),0}var d,s,u};export{i as getTotalVin};