@mojito-inc/secondary-market
Version:
Mojito secondary market is the platform to purchase NFT.
2 lines (1 loc) • 2.66 kB
JavaScript
;var e=require("ethers"),s=require("../constant/contractABI/ListitemERC115.js"),i=require("../constant/contractABI/ListitemERC721.js"),a=require("../constant/index.js");exports.transferToken=async function({tokenId:n,tokenType:r,contractAddress:d,toAddress:t,signer:o,walletAddress:l,maxFeePerGas:u,maxPriorityFeePerGas:v}){var c,m,E,g,h,R,T,y,f,F,I,p,N,P,S,x,C,U;try{if(r.includes("ERC-721")){const s=new e.ethers.Contract(d,i.default.abi,o),a=await s["safeTransferFrom(address,address,uint256)"](l,t,n,{maxFeePerGas:u,maxPriorityFeePerGas:v});return a.hash?{status:!0,message:a.hash}:{status:!1,message:a.hash}}const a=new e.ethers.Contract(d,s.default.abi,o),c="0x000000000000000000000000",m="1",E=await a["safeTransferFrom(address,address,uint256,uint256,bytes)"](l,t,n,m,c,{maxFeePerGas:u,maxPriorityFeePerGas:v});return E.hash?{status:!0,message:E.hash}:{status:!1,message:E.hash}}catch(e){return(null===(m=null===(c=null==e?void 0:e.data)||void 0===c?void 0:c.message)||void 0===m?void 0:m.includes(a.ErrorsType.USER_REJECTED))||(null===(E=null==e?void 0:e.message)||void 0===E?void 0:E.includes(a.ErrorsType.USER_REJECTED))||(null===(h=null===(g=null==e?void 0:e.data)||void 0===g?void 0:g.message)||void 0===h?void 0:h.includes(a.ErrorsType.USER_DENIED))||(null===(R=null==e?void 0:e.message)||void 0===R?void 0:R.includes(a.ErrorsType.USER_DENIED))?{status:!1,message:"Reject"}:(null===(y=null===(T=null==e?void 0:e.data)||void 0===T?void 0:T.message)||void 0===y?void 0:y.includes(a.ErrorsType.INSUFFICIENT_FUNDS))||(null===(f=null==e?void 0:e.message)||void 0===f?void 0:f.includes(a.ErrorsType.INSUFFICIENT_FUNDS))?{status:!1,message:"There is no sufficient balance in your wallet for this transaction"}:(null===(I=null===(F=null==e?void 0:e.data)||void 0===F?void 0:F.message)||void 0===I?void 0:I.includes(a.ErrorsType.SIGNER_ERROR))||(null===(p=null==e?void 0:e.message)||void 0===p?void 0:p.includes(a.ErrorsType.SIGNER_ERROR))?{status:!1,message:"Please provide a valid signer for this transaction"}:(null===(N=null==e?void 0:e.message)||void 0===N?void 0:N.includes("Invalid ENS name"))||(null===(S=null===(P=e.data)||void 0===P?void 0:P.message)||void 0===S?void 0:S.includes("Invalid ENS name"))?{status:!1,message:"The ENS name is invalid or not configured"}:(null===(x=null==e?void 0:e.message)||void 0===x?void 0:x.includes("Provider initialization failed"))||(null===(U=null===(C=null==e?void 0:e.data)||void 0===C?void 0:C.message)||void 0===U?void 0:U.includes("Provider initialization failed"))?{status:!1,message:"Failed to initialize provider"}:{status:!1,message:"Unable to process the request. Please try again."}}};