1import{c0 as m,bb as k,bW as w,c1 as g,Y as A,aE as f,J as W,M as d,$ as h,T as c,a4 as C}from"./index-eVFI_Xo7.js";import{h as T}from"./hasERC20Allowance-654a940b.browser.esm-CJKppivH.js";import{i as u}from"./marketplace-e3129e2f.browser.esm-BeDcaais.js";import{b as v}from"./QueryParams-32a56510.browser.esm-DWLEYWUb.js";import{C as y,b as I,G as E,a as b}from"./contract-appuri-5c40af52.browser.esm-DXpEwjyB.js";import{C as $,a as R}from"./contract-owner-49e75547.browser.esm-RocrC81T.js";import{C as S}from"./contract-roles-71988d2e.browser.esm-CnDkVmp6.js";import{S as P}from"./erc-721-standard-4c4125d2.browser.esm-BcfwmakF.js";import"./index-C4jyffgC.js";import"./setErc20Allowance-7f76f677.browser.esm-B72Td35Z.js";import"./erc-721-27306550.browser.esm-DGJ2YMgE.js";import"./assertEnabled-d1700f0b.browser.esm-tFW-izjr.js";import"./drop-claim-conditions-e6f2abbf.browser.esm-AuagIAbD.js";import"./treeify-8BhC4AfR.js";class l extends P{static contractRoles=m;constructor(r,e,n){let o=arguments.length>3&&arguments[3]!==void 0?arguments[3]:{},t=arguments.length>4?arguments[4]:void 0,a=arguments.length>5?arguments[5]:void 0,s=arguments.length>6&&arguments[6]!==void 0?arguments[6]:new k(r,e,t,o,n);super(s,n,a),this.abi=w.parse(t||[]),this.metadata=new y(this.contractWrapper,g,this.storage),this.app=new I(this.contractWrapper,this.metadata,this.storage),this.roles=new S(this.contractWrapper,l.contractRoles),this.encoder=new A(this.contractWrapper),this.estimator=new E(this.contractWrapper),this.events=new b(this.contractWrapper),this.royalties=new $(this.contractWrapper,this.metadata),this.owner=new R(this.contractWrapper)}async getWrappedContents(r){const e=await this.contractWrapper.read("getWrappedContents",[r]),n=[],o=[],t=[];for(const a of e)switch(a.tokenType){case 0:{const s=await f(this.contractWrapper.getProvider(),a.assetContract);n.push({contractAddress:a.assetContract,quantity:W(a.totalAmount,s.decimals)});break}case 1:{o.push({contractAddress:a.assetContract,tokenId:a.tokenId});break}case 2:{t.push({contractAddress:a.assetContract,tokenId:a.tokenId,quantity:a.totalAmount.toString()});break}}return{erc20Tokens:n,erc721Tokens:o,erc1155Tokens:t}}wrap=d(async(r,e,n)=>{const[o,t,a]=await Promise.all([v(e,this.storage),this.toTokenStructList(r),h(n||await this.contractWrapper.getSignerAddress())]);return c.fromContractWrapper({contractWrapper:this.contractWrapper,method:"wrap",args:[t,o,a],parse:s=>{const i=this.contractWrapper.parseLogs("TokensWrapped",s?.logs);if(i.length===0)throw new Error("TokensWrapped event not found");const p=i[0].args.tokenIdOfWrappedToken;return{id:p,receipt:s,data:()=>this.get(p)}}})});unwrap=d(async(r,e)=>{const n=await h(e||await this.contractWrapper.getSignerAddress());return c.fromContractWrapper({contractWrapper:this.contractWrapper,method:"unwrap",args:[r,n]})});async toTokenStructList(r){const e=[],n=this.contractWrapper.getProvider(),o=await this.contractWrapper.getSignerAddress();if(r.erc20Tokens)for(const t of r.erc20Tokens){const a=await C(n,t.quantity,t.contractAddress);if(!await T(this.contractWrapper,t.contractAddress,a))throw new Error(`ERC20 token with contract address "${t.contractAddress}" does not have enough allowance to transfer. 2 3You can set allowance to the multiwrap contract to transfer these tokens by running: 4 5await sdk.getToken("${t.contractAddress}").setAllowance("${this.getAddress()}", ${t.quantity}); 6 7`);e.push({assetContract:t.contractAddress,totalAmount:a,tokenId:0,tokenType:0})}if(r.erc721Tokens)for(const t of r.erc721Tokens){if(!await u(this.contractWrapper.getProvider(),this.getAddress(),t.contractAddress,t.tokenId,o))throw new Error(`ERC721 token "${t.tokenId}" with contract address "${t.contractAddress}" is not approved for transfer. 8 9You can give approval the multiwrap contract to transfer this token by running: 10 11await sdk.getNFTCollection("${t.contractAddress}").setApprovalForToken("${this.getAddress()}", ${t.tokenId}); 12 13`);e.push({assetContract:t.contractAddress,totalAmount:0,tokenId:t.tokenId,tokenType:1})}if(r.erc1155Tokens)for(const t of r.erc1155Tokens){if(!await u(this.contractWrapper.getProvider(),this.getAddress(),t.contractAddress,t.tokenId,o))throw new Error(`ERC1155 token "${t.tokenId}" with contract address "${t.contractAddress}" is not approved for transfer. 14 15You can give approval the multiwrap contract to transfer this token by running: 16 17await sdk.getEdition("${t.contractAddress}").setApprovalForAll("${this.getAddress()}", true); 18 19`);e.push({assetContract:t.contractAddress,totalAmount:t.quantity,tokenId:t.tokenId,tokenType:2})}return e}async prepare(r,e,n){return c.fromContractWrapper({contractWrapper:this.contractWrapper,method:r,args:e,overrides:n})}async call(r,e,n){return this.contractWrapper.call(r,e,n)}}export{l as Multiwrap};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.