UNPKG

@sofaws/dapp-core

Version:

A library to hold the main logic for a dapp on the Elrond Network

3 lines (2 loc) 973 B
import{a as u}from"./chunk-XAPH7V6V.js";import{a as m,b as T}from"./chunk-N7MHQ6JT.js";import{k as p}from"./chunk-P6M5SGWP.js";import{k as a,m as d}from"./chunk-HBP5N4FR.js";d();p();import{Address as f}from"@elrondnetwork/erdjs";import g from"bignumber.js";T();var s={tokenId:"",amount:""},I=t=>t.split("@").map((n,r)=>[2,3].includes(r)?n:m(n));function E(t){if(!t)return s;let c=t.startsWith("ESDTTransfer"),i=t.startsWith("ESDTNFTTransfer")&&t.includes("@");if(c){let[,e,o]=t.split("@");try{let n=a.Buffer.from(e,"hex").toString("ascii");if(!n)return s;let r=new g("0x"+o.replace("0x","")).toString(10);return{tokenId:n,amount:r}}catch(n){console.error("Error getting token from transaction data",n)}}if(i)try{let[,e,o,n,r]=I(t);if([e,o,n,r].every(l=>Boolean(l))&&u(new f(r).bech32()))return{tokenId:`${e}-${o}`,amount:new g(n,16).toString(10),collection:e,nonce:o,receiver:new f(r).bech32()}}catch(e){}return s}export{E as a}; //# sourceMappingURL=chunk-44GMLLSU.js.map