PageSourceSearch

https://oyster-773ce.web.app/assets/multiwrap-623c1cd6.browser.esm-eO9MNvvJ.js

js oyster-773ce.web.app collected 2026-10-03 12:32:42 UTC 4,980 bytes, 19 lines download raw bytes

1var A=Object.defineProperty;var f=(i,c,r)=>c in i?A(i,c,{enumerable:!0,configurable:!0,writable:!0,value:r}):i[c]=r;var p=(i,c,r)=>(f(i,typeof c!="symbol"?c+"":c,r),r);import{Y as W,m as C,A as T,Z as v,o as y,G as I,H as E,r as m,x as k,T as h,y as R}from"./index-rFJxABne.js";import{h as $}from"./hasERC20Allowance-d3a3b829.browser.esm-zu4jrsZe.js";import{i as w}from"./marketplace-5fd92910.browser.esm-zHYgmspf.js";import{u as b}from"./QueryParams-86b5bbc0.browser.esm-c7Xy1rxN.js";import{C as S,a as P,G as q,b as F}from"./contract-appuri-7ca2192f.browser.esm-q8GIvadM.js";import{C as L,a as O}from"./contract-owner-fef93be6.browser.esm-MolelQT1.js";import{C as x}from"./contract-roles-bd76ee50.browser.esm-6lLJNlrv.js";import{S as U}from"./erc-721-standard-9c3e7ac2.browser.esm-VNCG5hzk.js";import"./setErc20Allowance-5cdb760b.browser.esm--u6FLJJF.js";import"./index-EPOMsIeQ.js";import"./assertEnabled-c7de2a13.browser.esm-Tz7zzs_v.js";import"./erc-721-3e2f7b8b.browser.esm-5h1X-wBJ.js";import"./drop-claim-conditions-33b4da26.browser.esm-mkQ2jwoc.js";const d=class d extends U{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 C(r,e,t,o,n);super(s,n,a);p(this,"wrap",m(async(r,e,n)=>{const[o,t,a]=await Promise.all([b(e,this.storage),this.toTokenStructList(r),k(n||await this.contractWrapper.getSignerAddress())]);return h.fromContractWrapper({contractWrapper:this.contractWrapper,method:"wrap",args:[t,o,a],parse:s=>{const u=this.contractWrapper.parseLogs("TokensWrapped",s==null?void 0:s.logs);if(u.length===0)throw new Error("TokensWrapped event not found");const l=u[0].args.tokenIdOfWrappedToken;return{id:l,receipt:s,data:()=>this.get(l)}}})}));p(this,"unwrap",m(async(r,e)=>{const n=await k(e||await this.contractWrapper.getSignerAddress());return h.fromContractWrapper({contractWrapper:this.contractWrapper,method:"unwrap",args:[r,n]})}));this.abi=T.parse(t||[]),this.metadata=new S(this.contractWrapper,v,this.storage),this.app=new P(this.contractWrapper,this.metadata,this.storage),this.roles=new x(this.contractWrapper,d.contractRoles),this.encoder=new y(this.contractWrapper),this.estimator=new q(this.contractWrapper),this.events=new F(this.contractWrapper),this.royalties=new L(this.contractWrapper,this.metadata),this.owner=new O(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 I(this.contractWrapper.getProvider(),a.assetContract);n.push({contractAddress:a.assetContract,quantity:E(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}}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 R(n,t.quantity,t.contractAddress);if(!await $(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 w(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 w(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 h.fromContractWrapper({contractWrapper:this.contractWrapper,method:r,args:e,overrides:n})}async call(r,e,n){return this.contractWrapper.call(r,e,n)}};p(d,"contractRoles",W);let g=d;export{g 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.