@dcl/shop 0.1.0-29942574523.commit-573f25e → 0.1.0-29942650568.commit-3cdb6da
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/assets/{AnimatedBackground-CzCwcFdY.js → AnimatedBackground-CysLhvvU.js} +3 -3
- package/assets/{Assets-BTdyC00C.js → Assets-DsvJ5f0v.js} +1 -1
- package/assets/{Assets.styles-eeqx94WS.js → Assets.styles-CA7lhkqC.js} +26 -27
- package/assets/{Authorizations-BZhmfDD4.js → Authorizations-vnz0r2Ax.js} +3 -3
- package/assets/{Cart-BicSZMzV.js → Cart-CTQAeaCb.js} +2 -2
- package/assets/{CircularProgress-BivMeg1W.js → CircularProgress-BoWkcKSM.js} +3 -3
- package/assets/{Collection-DQAOAaC9.js → Collection-DFg8H4cI.js} +1 -1
- package/assets/{CollectionCarousel-D_udpdxX.js → CollectionCarousel-BgmGp9gP.js} +1 -1
- package/assets/{Creator-X75Qvpr4.js → Creator-DpJL7xsg.js} +1 -1
- package/assets/{CssVarsProvider-C0ny30E-.js → CssVarsProvider-CVkDPUQi.js} +1 -1
- package/assets/{ExchangeController-D0l6M3tj.js → ExchangeController-XYLG0Onl.js} +1 -1
- package/assets/{GetCredits-CMdoboQp.js → GetCredits-C41Akzju.js} +1 -1
- package/assets/{HelpersUtil-hamZLlhX.js → HelpersUtil-CXmyL-9f.js} +1 -1
- package/assets/{ImportListings-BFIpuuBM.js → ImportListings-DL4qvnkm.js} +1 -1
- package/assets/ItemDetail-8kxMVjol.js +78 -0
- package/assets/{LoadMore-BLy9p9ul.js → LoadMore-DwH_uJJ9.js} +1 -1
- package/assets/{MarketCheckout-DSl7Bl-M.js → MarketCheckout-0NCiBi_9.js} +1 -1
- package/assets/MyAssets-ChdfSyve.js +258 -0
- package/assets/{MyFavorites-Dul-WC6l.js → MyFavorites-BAgv7K26.js} +1 -1
- package/assets/{MyPurchases-DI0zzNTZ.js → MyPurchases-DlfJ7xtX.js} +4 -4
- package/assets/{NotFound-Bdg_iIpB.js → NotFound-uK-Ostnl.js} +1 -1
- package/assets/PrimaryListModal-Bm7Lx1a1.js +1 -0
- package/assets/{StoreSettings-2cViRT0c.js → StoreSettings-jeamoHJO.js} +5 -5
- package/assets/{Success-D9l7pr2K.js → Success-IAIc5xBC.js} +1 -1
- package/assets/{SwapController-DKBIcDPA.js → SwapController-B81AJRRn.js} +1 -1
- package/assets/{Tooltip-DJ7HtAmB.js → Tooltip-CYItdKnL.js} +1 -1
- package/assets/{TradeService-BpWgN8zg.js → TradeService-BxBTy4_C.js} +1 -1
- package/assets/{W3MFrameProviderSingleton-B40OWK0h.js → W3MFrameProviderSingleton-WHc1zToo.js} +3 -3
- package/assets/{WebCryptoP256-Ccr1DsYO.js → WebCryptoP256-BQQeByzz.js} +1 -1
- package/assets/{authorizations-sU14ILrd.js → authorizations-C600xDT9.js} +1 -1
- package/assets/{basic-DaSuNoEa.js → basic-CaSER4PW.js} +1 -1
- package/assets/{biconomy-DmmBzkXG.js → biconomy-nsDuvr1X.js} +1 -1
- package/assets/{buy-BRLq1STf.js → buy-C5J6mAtx.js} +1 -1
- package/assets/{buy-gasless-hR2bH0iR.js → buy-gasless-Sy6Gurph.js} +1 -1
- package/assets/{cart-checkout-CifIjL1z.js → cart-checkout-BwJruvi6.js} +1 -1
- package/assets/{categories-BPU8ySTe.js → categories-CQMvcQ_A.js} +1 -1
- package/assets/{ccip-C1DhAmlP.js → ccip-CVFd9-T6.js} +1 -1
- package/assets/{ccip-pv6qu637.js → ccip-C_DKTuDg.js} +1 -1
- package/assets/{collection-DhudRI2A.js → collection-BButATLz.js} +1 -1
- package/assets/{controller-DBPpBNi9.js → controller-C4IlqRFi.js} +2 -2
- package/assets/{core-CftjJZSY.js → core-Bsb1vtZ6.js} +4 -4
- package/assets/{custom-CLjHEVcz.js → custom-B2_bVLxh.js} +1 -1
- package/assets/{data-capture-ClKTWWBL.js → data-capture-CeCg7Ckv.js} +1 -1
- package/assets/{email-Dx9BSTtw.js → email-DGWqulOs.js} +1 -1
- package/assets/{embedded-wallet-CCKNmFwm.js → embedded-wallet-BDA__pmu.js} +1 -1
- package/assets/emotion-styled.browser.esm-Of0yAmXP.js +1 -0
- package/assets/{engine-1UaDNb6s.js → engine-COT4y3N6.js} +1 -1
- package/assets/{errors-DKFg2ql0.js → errors-B2rT3Gvo.js} +1 -1
- package/assets/{estimate-l1-fee-cQM6_GVS.js → estimate-l1-fee-DSG403IA.js} +1 -1
- package/assets/{execute-BuVfiwvM.js → execute-zpOqUNic.js} +2 -2
- package/assets/{features-ieqkL6m1.js → features-CMZ-QMXf.js} +1 -1
- package/assets/{fetchTokenMetadata-D8OWz4cP.js → fetchTokenMetadata-CZyR6DMv.js} +2 -2
- package/assets/{get-ecosystem-wallet-info-LZLHBFVZ.js → get-ecosystem-wallet-info-Cll7wRD7.js} +1 -1
- package/assets/{getBalance-Ck1YHbUL.js → getBalance-BlSTzNnh.js} +1 -1
- package/assets/{getNFT-DYxVn0Et.js → getNFT-bAbPTgKN.js} +1 -1
- package/assets/{getNFT-DnYNAiji.js → getNFT-yZahXefO.js} +1 -1
- package/assets/{getOverlayAlpha-Jb_9sPPd.js → getOverlayAlpha-CH1E19pc.js} +1 -1
- package/assets/{hashTypedData-Bqz6FRnB.js → hashTypedData-BjKHZJt2.js} +1 -1
- package/assets/{hashTypedData-BHOeb4kN.js → hashTypedData-CoI7qham.js} +1 -1
- package/assets/{import-CyzZeEcP.js → import-B-7LIWfg.js} +1 -1
- package/assets/{in-app-yMA-tvKO.js → in-app-DuAkMaop.js} +1 -1
- package/assets/{in-app-wallet-calls-BJRqCE4k.js → in-app-wallet-calls-VVaW7dWC.js} +1 -1
- package/assets/{index-BgMPhDEY.js → index-2LZVA_H9.js} +1 -1
- package/assets/{index-C0MEN305.js → index-B14E9dDt.js} +1 -1
- package/assets/{index-DwFc8v1Z.js → index-B5bMVqc5.js} +1 -1
- package/assets/{index-CstoEHiD.js → index-BC--wvbP.js} +1 -1
- package/assets/{index-D0tMQ_oG.js → index-BCa080Jk.js} +1 -1
- package/assets/{index-mc7xea6T.js → index-BEL4KhCu.js} +1 -1
- package/assets/{index-Bxu_HZv7.js → index-BSSPgvD1.js} +1 -1
- package/assets/{index-DSbcS8Gm.js → index-BaDAgjcA.js} +1 -1
- package/assets/{index-nmCuLAGG.js → index-BlnhiyW1.js} +1 -1
- package/assets/{index-KyO7a8ne.js → index-BmwayVyG.js} +3 -3
- package/assets/{index-D18uHh6f.js → index-BsY45tr2.js} +1 -1
- package/assets/{index-CWcMLN9O.js → index-Bwtbao7B.js} +1 -1
- package/assets/{index-0Z5nkscP.js → index-Bzlo07t4.js} +1 -1
- package/assets/{index-DPjEYQhJ.js → index-C0_U8Amn.js} +1 -1
- package/assets/{index-DJEb_i4T.js → index-C0utXQ6l.js} +1 -1
- package/assets/{index-B55KertC.js → index-C2JrnQDe.js} +1 -1
- package/assets/{index-Chx72aoA.js → index-C4vAJ3fL.js} +1 -1
- package/assets/{index-B7YJ2-NC.js → index-CBhum_yI.js} +1 -1
- package/assets/{index-DPm2T7me.js → index-CJs5gUNJ.js} +3 -3
- package/assets/{index-B8PSEU0f.js → index-CRZSv11U.js} +1 -1
- package/assets/{index-Cenx9VIL.js → index-CUV4Rf3F.js} +1 -1
- package/assets/{index-Dil5ESgb.js → index-ChF-gCVV.js} +1 -1
- package/assets/{index-BVjayAtf.js → index-CiH0W5Hj.js} +1 -1
- package/assets/{index-LQPmlKJw.js → index-Cj8JMZ6F.js} +1 -1
- package/assets/{index-0C8jHF02.js → index-CjnhvTx0.js} +1 -1
- package/assets/{index-BlKccc7B.js → index-CkTptFnK.js} +2 -2
- package/assets/{index-CVG4mg1H.js → index-ClDUuLhd.js} +1 -1
- package/assets/{index-zfsFyt-v.js → index-Cok_sFK3.js} +1 -1
- package/assets/{index-BLpc0PAw.js → index-CyMsSal1.js} +1 -1
- package/assets/{index-WrHr3vKs.js → index-CzOo8tvO.js} +2 -2
- package/assets/{index-Df4qngsG.js → index-D2i7N7FD.js} +1 -1
- package/assets/{index-Dx4oKUoK.js → index-D4mGcEtB.js} +1 -1
- package/assets/{index-CCr2J09y.js → index-D7J0TuHz.js} +2 -2
- package/assets/{index-CqYieDft.js → index-DIZEbKwM.js} +1 -1
- package/assets/{index-CO9CUrPm.js → index-DIusB22U.js} +2 -2
- package/assets/{index-Dc1nvyn9.js → index-DJCp8uIp.js} +1 -1
- package/assets/index-DYDor-ZM.css +1 -0
- package/assets/{index-B_fPkyQt.js → index-DcAG03_T.js} +1 -1
- package/assets/{index-fvb_2ePt.js → index-DeO2Srep.js} +2 -2
- package/assets/{index-DM6cwvvh.js → index-Dfv7PJQh.js} +1 -1
- package/assets/{index-BEOJi3Jo.js → index-DmSOW0PY.js} +1 -1
- package/assets/{index-LMkzNUyd.js → index-Dp2XIou0.js} +1 -1
- package/assets/{index-Bc63dzBj.js → index-DsttSp14.js} +3 -3
- package/assets/{index-YX1mo09T.js → index-DuM3vKAV.js} +1 -1
- package/assets/{index-uESxdvPf.js → index-DvbuNJKq.js} +1 -1
- package/assets/{index-O1MAeCt1.js → index-DxHb67V2.js} +1 -1
- package/assets/index-Q9d0V8TZ.js +289 -0
- package/assets/{index-3c-o1deN.js → index-VrPb_Zz5.js} +1 -1
- package/assets/{index-DHzasbYL.js → index-ZjDtH0Hr.js} +1 -1
- package/assets/{index-a_8ZLAR0.js → index-gcnUvFrd.js} +1 -1
- package/assets/{index-xFOezD9a.js → index-tAmGgcla.js} +1 -1
- package/assets/{index-B6Hb0r15.js → index-uk-CfnlL.js} +1 -1
- package/assets/{index-Dszgr0BR.js → index-zvLgVYhW.js} +1 -1
- package/assets/{index.es-Dy8PEmK4.js → index.es-BzMx-nup.js} +4 -4
- package/assets/{index.es-CP2cNM9F.js → index.es-DAd9yxMt.js} +1 -1
- package/assets/{index.es-B-uJmNhd.js → index.es-fI5nPWfV.js} +1 -1
- package/assets/{localBatchGatewayRequest-Dg8trW1f.js → localBatchGatewayRequest-BIFDJTSD.js} +1 -1
- package/assets/{mana-rate-DtQ8WpoI.js → mana-rate-CC-yyhWK.js} +1 -1
- package/assets/{networks-BaSDToU0.js → networks-DkdE2sZd.js} +1 -1
- package/assets/{onramp-D6REu-OE.js → onramp-C_i59kJR.js} +1 -1
- package/assets/{openzeppelin-DsZ0ZpWh.js → openzeppelin-BMNh5qua.js} +1 -1
- package/assets/{parseNft-BrwItloF.js → parseNft-CW-hWGBI.js} +2 -2
- package/assets/{parseSignature-CtBPNsAi.js → parseSignature-C3GhRBL-.js} +3 -3
- package/assets/{parseSignature-C67g8Ikn.js → parseSignature-NZopg6IG.js} +1 -1
- package/assets/{passkeys-CkVvpC6F.js → passkeys-DuQQbJhZ.js} +1 -1
- package/assets/{pay-with-exchange-DDftQXGa.js → pay-with-exchange-DH6Kt6OD.js} +1 -1
- package/assets/{qr-overlay-CHyDfEfF.js → qr-overlay-u2BzHEzf.js} +1 -1
- package/assets/{receive-BqeMp3_k.js → receive-D2V6X2tA.js} +1 -1
- package/assets/{resolveImplementation-D6GNwvZn.js → resolveImplementation-BsuIKFkz.js} +1 -1
- package/assets/{rpc-D1wZc4pd.js → rpc-BIhelmqB.js} +1 -1
- package/assets/{secp256k1-Cu8gqKOi.js → secp256k1-BHmvTUzO.js} +1 -1
- package/assets/{secp256k1-DKdkwurr.js → secp256k1-BtgeD6jy.js} +1 -1
- package/assets/{secp256k1-tM-HU4Wb.js → secp256k1-hNsXkUex.js} +1 -1
- package/assets/{send-C5LlTSZw.js → send-DkPpjCf1.js} +1 -1
- package/assets/{send-batch-transaction-2M20mpyd.js → send-batch-transaction-Bt9-Q0FO.js} +1 -1
- package/assets/{send-eip712-transaction-DxCA-Uwd.js → send-eip712-transaction-CJ8Dr-eb.js} +2 -2
- package/assets/{send-gasless-transaction-VjwN2uQK.js → send-gasless-transaction-D5eQ85CY.js} +2 -2
- package/assets/{send-transaction-Bb0Q9hmN.js → send-transaction-BK1KmPMR.js} +2 -2
- package/assets/{sendRawTransaction-CED77ONZ.js → sendRawTransaction-Ddh_tSjE.js} +3 -3
- package/assets/{serializeTransaction-7yAEy3FU.js → serializeTransaction-f04zsBlb.js} +1 -1
- package/assets/{session-proposal-DGrkZ9Ix.js → session-proposal-r1mPrmCX.js} +1 -1
- package/assets/{session-request-Dg8cFRll.js → session-request-Cfr7jp2h.js} +2 -2
- package/assets/{signing-DuUwyfpZ.js → signing-C-mKTJFW.js} +3 -3
- package/assets/{socials-cbGvEEpM.js → socials-pmAt6WyL.js} +1 -1
- package/assets/{swaps-EURvYFti.js → swaps-XKJYQXAz.js} +1 -1
- package/assets/{thirdweb-D4Tt3SPK.js → thirdweb-B_kKfwse.js} +3 -3
- package/assets/{to-serializable-transaction-Dh5bAtyQ.js → to-serializable-transaction-rhTmQPEU.js} +2 -2
- package/assets/{trade-encoding-0IFZ39Tk.js → trade-encoding-CaZYjVNs.js} +1 -1
- package/assets/{transactionReceipt-DIw9ApVw.js → transactionReceipt-BcU054L-.js} +1 -1
- package/assets/{transactions-xAqHSp91.js → transactions-lrp4i700.js} +1 -1
- package/assets/useCreditPacks-Be9cG5vr.js +1 -0
- package/assets/{useInfiniteGrid-BbeLTVdN.js → useInfiniteGrid-8c-8xSTi.js} +1 -1
- package/assets/{useStore-PWA7dbNJ.js → useStore-Ccbed9Z-.js} +1 -1
- package/assets/useTheme-7-Mr4FFJ.js +1 -0
- package/assets/useTheme-C3YHg0O0.js +1 -0
- package/assets/{verifyHash-sv4aRvH_.js → verifyHash-z4q1c5J1.js} +1 -1
- package/assets/{w3m-modal-D1RMqW5z.js → w3m-modal-2GWsHPDh.js} +1 -1
- package/assets/{w3m-modal-BoTSPCYe.js → w3m-modal-DUSXSzQv.js} +1 -1
- package/assets/{wait-for-tx-receipt-CnoUxMtV.js → wait-for-tx-receipt-CAc2Bmoi.js} +1 -1
- package/assets/{wallets-Cuqbvnoy.js → wallets-BD_QGCV9.js} +5 -5
- package/assets/{web-connector-0FomZsHS.js → web-connector-Da5xZh52.js} +3 -3
- package/assets/{writeContract-Bicvfabo.js → writeContract-zNHMPW7R.js} +1 -1
- package/assets/{zoraTestnet-4QPNkDlh.js → zoraTestnet-Csb8JMNL.js} +1 -1
- package/index.html +11 -11
- package/package.json +2 -2
- package/assets/ItemDetail-C0Sm18Me.js +0 -78
- package/assets/MyAssets-UFPrjPwu.js +0 -258
- package/assets/PrimaryListModal-CnlMOkG5.js +0 -1
- package/assets/emotion-styled.browser.esm-B6FBNgF3.js +0 -1
- package/assets/index-CJ4mXolB.js +0 -289
- package/assets/index-CqYr0ABc.css +0 -1
- package/assets/useCreditPacks-DO-uyk4N.js +0 -1
- package/assets/useTheme-BHtz4hyG.js +0 -1
- package/assets/useTheme-Ciqd957r.js +0 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{j as e,L as y}from"./react-BrLDncxD.js";import{s as i,B as w,F as r,
|
|
1
|
+
import{j as e,L as y}from"./react-BrLDncxD.js";import{s as i,B as w,F as r,N as k,u as $,t as d,d as v,I as x,a7 as I,h as j,m as P,a8 as L}from"./index-Q9d0V8TZ.js";import{L as N}from"./LoadMore-DwH_uJJ9.js";import{u as E}from"./useInfiniteGrid-8c-8xSTi.js";import"./dcl-schemas-BICTSpB5.js";import"./sentry-DYZXk5O5.js";import"./ethers-CLB2z3On.js";import"./intl-CBcMB1D2.js";const T=15e3;function C(t,n){return t.txHash&&n.txHash?t.txHash===n.txHash:t.txHash||n.txHash?!1:t.status===n.status&&Math.abs(t.createdAt-n.createdAt)<=T}function D(t){const n=[...t].sort((s,o)=>o.createdAt-s.createdAt),a=[];for(const s of n){const o=a[a.length-1];o&&C(o[o.length-1],s)?o.push(s):a.push([s])}return a.map(s=>{var o;return{id:((o=s.find(c=>c.txHash))==null?void 0:o.txHash)??s[s.length-1].id,createdAt:Math.max(...s.map(c=>c.createdAt)),status:s.some(c=>c.status==="PENDING")?"PENDING":"SETTLED",totalCredits:s.reduce((c,u)=>c+u.credits,0),lines:s}})}function H(t){const n=[],a=new Map;for(const s of t)if(s.tradeId){const o=a.get(s.tradeId);if(o){o.quantity+=1,o.credits+=s.credits;continue}const c={key:s.tradeId,tradeId:s.tradeId,quantity:1,credits:s.credits};a.set(s.tradeId,c),n.push(c)}else n.push({key:s.id,tradeId:null,quantity:1,credits:s.credits});return n}const m=k`
|
|
2
2
|
0% { background-position: 200% 0; }
|
|
3
3
|
100% { background-position: -200% 0; }
|
|
4
4
|
`,z=i.section`
|
|
@@ -15,12 +15,12 @@ import{j as e,L as y}from"./react-BrLDncxD.js";import{s as i,B as w,F as r,M as
|
|
|
15
15
|
`,q=i.span`
|
|
16
16
|
color: ${r.colors.muted};
|
|
17
17
|
font-size: 14px;
|
|
18
|
-
`,
|
|
18
|
+
`,F=i.div`
|
|
19
19
|
display: flex;
|
|
20
20
|
flex-direction: column;
|
|
21
21
|
gap: 16px;
|
|
22
22
|
max-width: 760px;
|
|
23
|
-
`,
|
|
23
|
+
`,M=i.div`
|
|
24
24
|
background: ${r.colors.white};
|
|
25
25
|
border: 1px solid ${r.colors.line};
|
|
26
26
|
border-radius: 16px;
|
|
@@ -197,4 +197,4 @@ import{j as e,L as y}from"./react-BrLDncxD.js";import{s as i,B as w,F as r,M as
|
|
|
197
197
|
margin: 6px 0 0;
|
|
198
198
|
`,te=i(w)`
|
|
199
199
|
margin-top: 12px;
|
|
200
|
-
`,ne=b.withComponent(y),se=24;function re(t){try{return new Date(t).toLocaleDateString(void 0,{year:"numeric",month:"short",day:"numeric"})}catch{return""}}function ie({item:t}){const{data:n,isLoading:a}=P({queryKey:["trade-display",t.tradeId],queryFn:()=>L(t.tradeId),enabled:!!t.tradeId,staleTime:3e5}),s=!!t.tradeId&&a,o=(n==null?void 0:n.name)??d("myPurchases.itemFallback"),c=(n==null?void 0:n.thumbnail)??"",u=(n==null?void 0:n.tokenId)??(n==null?void 0:n.itemId)??"",l=n!=null&&n.contractAddress&&u?`/item/${n.contractAddress}/${u}`:void 0,p=e.jsxs(e.Fragment,{children:[s?e.jsx(X,{}):e.jsx(Q,{children:c?e.jsx("img",{src:c,alt:o}):e.jsx(x,{name:"cart",size:20})}),e.jsxs(Z,{children:[s?e.jsx(V,{}):e.jsx(J,{title:o,children:o}),t.quantity>1?e.jsx(Y,{children:d("myPurchases.quantity",{count:t.quantity})}):null]}),e.jsxs(ee,{children:[e.jsx(j,{className:"ccy-mark"})," ",t.credits]})]});return l?e.jsx(ne,{to:l,"data-link":"true",children:p}):e.jsx(b,{children:p})}function oe({order:t}){const n=H(t.lines),a=n.reduce((s,o)=>s+o.quantity,0);return e.jsxs(
|
|
200
|
+
`,ne=b.withComponent(y),se=24;function re(t){try{return new Date(t).toLocaleDateString(void 0,{year:"numeric",month:"short",day:"numeric"})}catch{return""}}function ie({item:t}){const{data:n,isLoading:a}=P({queryKey:["trade-display",t.tradeId],queryFn:()=>L(t.tradeId),enabled:!!t.tradeId,staleTime:3e5}),s=!!t.tradeId&&a,o=(n==null?void 0:n.name)??d("myPurchases.itemFallback"),c=(n==null?void 0:n.thumbnail)??"",u=(n==null?void 0:n.tokenId)??(n==null?void 0:n.itemId)??"",l=n!=null&&n.contractAddress&&u?`/item/${n.contractAddress}/${u}`:void 0,p=e.jsxs(e.Fragment,{children:[s?e.jsx(X,{}):e.jsx(Q,{children:c?e.jsx("img",{src:c,alt:o}):e.jsx(x,{name:"cart",size:20})}),e.jsxs(Z,{children:[s?e.jsx(V,{}):e.jsx(J,{title:o,children:o}),t.quantity>1?e.jsx(Y,{children:d("myPurchases.quantity",{count:t.quantity})}):null]}),e.jsxs(ee,{children:[e.jsx(j,{className:"ccy-mark"})," ",t.credits]})]});return l?e.jsx(ne,{to:l,"data-link":"true",children:p}):e.jsx(b,{children:p})}function oe({order:t}){const n=H(t.lines),a=n.reduce((s,o)=>s+o.quantity,0);return e.jsxs(M,{"data-testid":"purchase-order",children:[e.jsxs(G,{children:[e.jsxs(O,{children:[e.jsx(B,{children:re(t.createdAt)}),e.jsx(R,{children:d("myPurchases.itemCount",{count:a})})]}),e.jsxs(W,{children:[e.jsx(_,{"data-status":t.status,children:t.status==="PENDING"?d("myPurchases.processing"):d("myPurchases.completed")}),e.jsxs(U,{children:[e.jsx(j,{className:"ccy-mark"})," ",t.totalCredits]})]})]}),e.jsx(K,{children:n.map(s=>e.jsx(ie,{item:s},s.key))})]})}function he(){$({title:d("nav.myPurchases"),noindex:!0});const{session:t}=v(),{items:n,isLoading:a,hasNextPage:s,isFetchingNextPage:o,fetchNextPage:c}=E(["purchases",t==null?void 0:t.address],l=>I(t.address,t.identity,{first:se,skip:l}),{enabled:!!t});if(!t)return e.jsxs(g,{children:[e.jsx(x,{name:"cart",size:40,color:"var(--muted-2)"}),e.jsx(f,{children:d("myPurchases.signInTitle")}),e.jsx("p",{className:"muted",children:d("myPurchases.signInBody")})]});const u=D(n.filter(l=>l.status!=="EXPIRED"));return!a&&u.length===0?e.jsxs(g,{children:[e.jsx(x,{name:"cart",size:40,color:"var(--muted-2)"}),e.jsx(f,{children:d("myPurchases.emptyTitle")}),e.jsx("p",{className:"muted",children:d("myPurchases.emptyBody")}),e.jsx(te,{as:y,to:"/assets",variant:"purple",children:d("notFound.cta")})]}):e.jsxs(z,{children:[e.jsxs(A,{children:[e.jsx(S,{children:d("nav.myPurchases")}),a?null:e.jsx(q,{children:d("myPurchases.orderCount",{count:u.length})})]}),e.jsx(F,{children:a?Array.from({length:3}).map((l,p)=>e.jsx(h,{},p)):e.jsxs(e.Fragment,{children:[u.map(l=>e.jsx(oe,{order:l},l.id)),o?e.jsx(h,{}):null]})}),e.jsx(N,{hasNextPage:s,isFetching:o,onLoadMore:()=>void c()})]})}export{he as MyPurchases};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{j as t,L as n}from"./react-BrLDncxD.js";import{u as s,t as o,I as e,B as a}from"./index-
|
|
1
|
+
import{j as t,L as n}from"./react-BrLDncxD.js";import{u as s,t as o,I as e,B as a}from"./index-Q9d0V8TZ.js";import"./dcl-schemas-BICTSpB5.js";import"./sentry-DYZXk5O5.js";import"./ethers-CLB2z3On.js";import"./intl-CBcMB1D2.js";function c(){return s({title:o("seo.notFound.title"),noindex:!0}),t.jsxs("div",{className:"notfound","data-testid":"notfound",children:[t.jsx(e,{name:"cart",className:"notfound__ico"}),t.jsx("h1",{className:"notfound__title",children:o("notFound.title")}),t.jsx("p",{className:"muted",children:o("notFound.body")}),t.jsx(a,{as:n,to:"/assets",variant:"purple",children:o("notFound.cta")})]})}export{c as NotFound,c as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{c as A,L as O,o as U,e as B,t as a,h as F,B as _,C as v,p as Q,x as k,J as q,E as W,y as D}from"./index-Q9d0V8TZ.js";import{d as w}from"./dcl-schemas-BICTSpB5.js";import{a as G,r as m,j as s}from"./react-BrLDncxD.js";import{i as J,e as K,c as H}from"./trade-encoding-CaZYjVNs.js";import{f as V}from"./errors-B2rT3Gvo.js";import{E as X}from"./ErrorNotice-BDH9xoG4.js";const N=()=>`${A.builderServerUrl}/v1`;function P(e){return Array.isArray(e)?e:"results"in e&&Array.isArray(e.results)?e.results:"data"in e&&Array.isArray(e.data)?e.data:[]}async function E(e,r){const t=await O(e,{method:"GET",identity:r,metadata:{}});if(!t.ok)throw new Error(`builder-server ${t.status}: ${await t.text()}`);const n=await t.json();return n.data??n}function Y(e,r){const t=r-e;return t>0?t:0}function z(e){var r,t,n,i,l;return((t=(r=e.data)==null?void 0:r.wearable)==null?void 0:t.category)??((i=(n=e.data)==null?void 0:n.emote)==null?void 0:i.category)??((l=e.data)==null?void 0:l.category)??e.type??"wearable"}function I(e){return`${N()}/storage/contents/${e}`}function f(e,r){if(!e)return"";if(/^https?:\/\//.test(e))return e;const t=r==null?void 0:r[e];return t?I(t):/^(ba|Qm)/.test(e)?I(e):""}async function Z(e,r){try{const t=await fetch(`${N()}/items/${e}/${r}/contents`);if(!t.ok)return{};const n=await t.json();return n.data??n}catch{return{}}}async function ee(e,r,t){const n=f(e.thumbnail,e.contents)||f("thumbnail.png",e.contents);if(n)return n;if(r&&t){const i=await Z(r,t);return f(e.thumbnail,i)||f("thumbnail.png",i)||f("image.png",i)}return""}async function te(e,r){const t=`${N()}/${e.toLowerCase()}/collections?is_published=true`,n=await E(t,r);return P(n).filter(i=>i.is_published&&!!i.contract_address).map(i=>({id:i.id,name:i.name,contractAddress:i.contract_address.toLowerCase(),isPublished:i.is_published,isApproved:i.is_approved,minters:(i.minters??[]).map(l=>l.toLowerCase())}))}async function se(e,r){const t=`${N()}/collections/${e.id}/items`,n=await E(t,r);return(await Promise.all(P(n).map(async l=>{const b=l.rarity??"common",y=Number(l.total_supply??0)||0;let o;try{o=w.Rarity.getMaxSupply(b)}catch{o=0}const g=(l.contract_address??e.contractAddress).toLowerCase(),p=l.blockchain_item_id??"";return{id:l.id,collectionId:e.id,collectionName:e.name,contractAddress:g,blockchainItemId:p,name:l.name,category:z(l),rarity:b,thumbnail:await ee(l,g,p),type:l.type??"wearable",isPublished:l.is_published??e.isPublished,isApproved:l.is_approved??e.isApproved,totalSupply:y,maxSupply:o,remainingSupply:Y(y,o),minters:e.minters}}))).filter(re)}function re(e){return e.isPublished&&e.isApproved&&e.blockchainItemId!==""&&e.blockchainItemId!=null&&e.remainingSupply>0}async function ue(e,r){const t=await te(e,r);return(await Promise.all(t.map(async i=>{try{return await se(i,r)}catch{return[]}}))).flat()}const ae=1e3*60*60*24*182;function me({item:e,session:r,onClose:t}){const n=U(),i=G(),[l,b]=m.useState("10"),[y,o]=m.useState(null),[g,p]=m.useState(null),[d,L]=m.useState(!1),[h,j]=m.useState(null),[C,$]=m.useState(null),x=A.chainId,S=B(r.providerType);m.useEffect(()=>{let c=!1;return(async()=>{try{const u=await J({contractAddress:e.contractAddress,chainId:x});c||j(u)}catch{c||j(!1)}})(),()=>{c=!0}},[e.contractAddress,x]);async function M(){p(null);const c=Number(l);if(!Number.isInteger(c)||c<=0){p(a("primaryList.errorWholeNumber"));return}L(!0);try{h||(o(a("primaryList.statusEnabling")),await K({signer:r.signer,contractAddress:e.contractAddress,chainId:x}),j(!0)),o(a("primaryList.statusPublishing"));const u=await H({signer:r.signer,item:{contractAddress:e.contractAddress,itemId:e.blockchainItemId,network:w.Network.MATIC,chainId:x},usdPrice:c/10,uses:e.remainingSupply,expiresAtMs:Date.now()+ae});o(a("primaryList.statusFinishing")),await Q(u,r.identity),o(null),$(c),k("Shop Listed Item",{item_id:e.blockchainItemId,contract_address:e.contractAddress,price_credits:c,price_usd:c/10,listing_type:"primary",is_primary:!0}),q.success(a("primaryList.toastOnSale",{name:e.name})),n.invalidateQueries({queryKey:["publishable-items"]}),n.invalidateQueries({queryKey:["collection-sale-state"]})}catch(u){W(u,{flow:"list_primary"}),k("Shop Listing Failed",{listing_type:"primary",error_code:D(u)}),p(V(u,a("primaryList.errorGeneric"))),o(null)}finally{L(!1)}}function T(){t(),i(`/item/${e.contractAddress}/${e.blockchainItemId}`)}const R=d?a("primaryList.listing"):h===!1?a("primaryList.enableAndPutOnSale"):a("primaryList.putOnSale");return C!==null?s.jsx("div",{className:"modal-backdrop",onClick:t,role:"presentation",children:s.jsxs("div",{className:"modal modal--success",onClick:c=>c.stopPropagation(),role:"dialog","aria-modal":"true",children:[s.jsx("div",{className:"modal-success__check","aria-hidden":!0,children:"✓"}),s.jsx("h2",{className:"modal__title",children:a("primaryList.successTitle")}),e.thumbnail?s.jsx("img",{className:"modal__img",src:e.thumbnail,alt:e.name}):null,s.jsx("p",{className:"modal-success__name",children:e.name}),s.jsxs("p",{className:"muted small",children:[a("primaryList.listedFor")," ",s.jsxs("strong",{children:[s.jsx(F,{className:"ccy-mark"})," ",C]})," ",a("primaryList.dotAvailable",{count:e.remainingSupply})]}),s.jsxs("div",{className:"modal__actions",children:[s.jsx(_,{variant:"ghost",onClick:t,children:a("getCredits.done")}),s.jsx(_,{variant:"purple",onClick:T,children:a("primaryList.viewInShop")})]})]})}):s.jsx("div",{className:"modal-backdrop",onClick:t,role:"presentation",children:s.jsxs("div",{className:"modal","data-testid":"modal",onClick:c=>c.stopPropagation(),role:"dialog","aria-modal":"true",children:[s.jsx("h2",{className:"modal__title",children:a("primaryList.publishTitle",{name:e.name})}),e.thumbnail?s.jsx("img",{className:"modal__img",src:e.thumbnail,alt:e.name}):null,s.jsx("p",{className:"muted small",children:a("primaryList.fromCollection",{collectionName:e.collectionName,count:e.remainingSupply})}),s.jsxs("label",{className:"field",children:[s.jsx("span",{children:a("primaryList.priceLabel",{currency:v.name})}),s.jsx("input",{type:"number",min:"1",step:"1",value:l,onChange:c=>b(c.target.value),disabled:d})]}),s.jsx("p",{className:"muted small",children:a("primaryList.pricedInWhole",{currency:v.name,currencySingular:v.nameSingular})}),h===!1&&!d?S?s.jsx("p",{className:"muted small primary-note",children:a("primaryList.firstTimeConfirm",{collectionName:e.collectionName})}):s.jsx("p",{className:"muted small primary-note",children:a("primaryList.firstTimeManaged",{collectionName:e.collectionName})}):h===!0&&!d?S?s.jsx("p",{className:"muted small primary-note",children:a("primaryList.readyConfirm")}):s.jsx("p",{className:"muted small primary-note",children:a("primaryList.readyManaged")}):null,y?s.jsx("p",{className:"muted",children:y}):null,s.jsx(X,{message:g}),s.jsxs("div",{className:"modal__actions",children:[s.jsx(_,{variant:"ghost",onClick:t,disabled:d,children:a("primaryList.cancel")}),s.jsx(_,{onClick:()=>void M(),disabled:d||h===null,children:h===null?a("primaryList.checking"):R})]})]})})}export{me as P,ue as f};
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import{j as s,a as se,r as n,L as te}from"./react-BrLDncxD.js";import{t as a,F as C,s as _,
|
|
1
|
+
import{j as s,a as se,r as n,L as te}from"./react-BrLDncxD.js";import{t as a,F as C,s as _,N as ae,u as ie,d as re,o as ne,I as E,B as F,J as R}from"./index-Q9d0V8TZ.js";import{u as oe,d as le,t as ce,L as de,i as B,a as v,s as me}from"./useStore-Ccbed9Z-.js";import{E as M}from"./ErrorNotice-BDH9xoG4.js";import"./dcl-schemas-BICTSpB5.js";import"./sentry-DYZXk5O5.js";import"./ethers-CLB2z3On.js";import"./intl-CBcMB1D2.js";const ue="https://cdn.decentraland.org/@dcl/shop/0.1.0-29942650568.commit-3cdb6da/assets/template-cover-1-BETekfHg.jpeg",pe="https://cdn.decentraland.org/@dcl/shop/0.1.0-29942650568.commit-3cdb6da/assets/template-cover-2-Dni9s0i_.jpeg",ge=Object.assign({"../assets/creator-covers/template-cover-1.jpeg":ue,"../assets/creator-covers/template-cover-2.jpeg":pe}),h=Object.entries(ge).sort(([i],[d])=>i.localeCompare(d)).map(([i,d])=>({name:i.split("/").pop(),url:d})),ve=ae`
|
|
2
2
|
to {
|
|
3
3
|
transform: rotate(360deg);
|
|
4
4
|
}
|
|
5
|
-
`,
|
|
5
|
+
`,he=_.div`
|
|
6
6
|
display: flex;
|
|
7
7
|
align-items: center;
|
|
8
8
|
justify-content: center;
|
|
@@ -16,7 +16,7 @@ import{j as s,a as se,r as n,L as te}from"./react-BrLDncxD.js";import{t as a,F a
|
|
|
16
16
|
flex-direction: column;
|
|
17
17
|
text-align: center;
|
|
18
18
|
}
|
|
19
|
-
`,
|
|
19
|
+
`,fe=_.span`
|
|
20
20
|
flex: none;
|
|
21
21
|
border-radius: 50%;
|
|
22
22
|
border-style: solid;
|
|
@@ -46,8 +46,8 @@ import{j as s,a as se,r as n,L as te}from"./react-BrLDncxD.js";import{t as a,F a
|
|
|
46
46
|
`,xe=_.span`
|
|
47
47
|
font-size: 14px;
|
|
48
48
|
font-weight: 600;
|
|
49
|
-
`;function _e({label:i,size:d="medium",direction:b="column",className:j}){return s.jsxs(
|
|
49
|
+
`;function _e({label:i,size:d="medium",direction:b="column",className:j}){return s.jsxs(he,{className:j,"data-testid":"spinner-box","data-direction":b,role:"status","aria-live":"polite","aria-label":i?void 0:a("spinner.loading"),children:[s.jsx(fe,{"data-testid":"spinner-box-ring","data-size":d,"aria-hidden":!0}),i?s.jsx(xe,{children:i}):null]})}const be=_(F)`
|
|
50
50
|
align-self: center;
|
|
51
51
|
min-width: 200px;
|
|
52
52
|
margin-top: 8px;
|
|
53
|
-
`,O=1e6,A={cover:"",coverName:"",coverHash:"",description:"",links:{website:"",twitter:"",discord:"",facebook:""}};function D(i){return`${(i/1e6).toLocaleString(void 0,{maximumFractionDigits:2})}MB`}function ye(){ie({title:a("seo.storeSettings.title"),noindex:!0});const{session:i,signIn:d}=re(),b=se(),j=ne(),c=i==null?void 0:i.address,{data:S,isLoading:P}=oe(c),[r,m]=n.useState(A),[L,y]=n.useState(A),[k,p]=n.useState(),[g,$]=n.useState(!1),[o,N]=n.useState(null),[
|
|
53
|
+
`,O=1e6,A={cover:"",coverName:"",coverHash:"",description:"",links:{website:"",twitter:"",discord:"",facebook:""}};function D(i){return`${(i/1e6).toLocaleString(void 0,{maximumFractionDigits:2})}MB`}function ye(){ie({title:a("seo.storeSettings.title"),noindex:!0});const{session:i,signIn:d}=re(),b=se(),j=ne(),c=i==null?void 0:i.address,{data:S,isLoading:P}=oe(c),[r,m]=n.useState(A),[L,y]=n.useState(A),[k,p]=n.useState(),[g,$]=n.useState(!1),[o,N]=n.useState(null),[f,V]=n.useState({}),z=n.useRef(null);n.useEffect(()=>{if(S){const e=le(S);m(e),y(e),p(void 0),N(e.cover?{url:e.cover,name:e.coverName,hash:e.coverHash}:null)}},[S]),n.useEffect(()=>{let e=!1;return Promise.all(h.map(async t=>[t.name,await ce(t.url)])).then(t=>{e||V(Object.fromEntries(t))}).catch(()=>{}),()=>{e=!0}},[]);const x=n.useMemo(()=>{const e=h.find(l=>r.coverName===`cover/${l.name}`);if(e)return e.name;const t=r.coverHash?h.find(l=>f[l.name]===r.coverHash):void 0;return t==null?void 0:t.name},[r.coverName,r.coverHash,f]);n.useEffect(()=>{o!=null&&o.hash&&h.some(e=>f[e.name]===o.hash)&&N(null)},[f,o]);const I=k!==void 0&&k>O,Y=n.useMemo(()=>de.filter(e=>!B(e,r.links[e])),[r.links]),J=I||Y.length>0,w=n.useMemo(()=>JSON.stringify(r)!==JSON.stringify(L),[r,L]),K=w&&!J&&!g;if(n.useEffect(()=>{if(!w)return;const e=t=>{t.preventDefault()};return window.addEventListener("beforeunload",e),()=>window.removeEventListener("beforeunload",e)},[w]),!i)return s.jsxs("section",{className:"store-settings store-settings--signin","aria-label":a("storeSettings.title"),children:[s.jsx("h1",{className:"store-settings__title",children:a("storeSettings.title")}),s.jsx("p",{className:"muted",children:a("storeSettings.signInPrompt")}),s.jsx(be,{variant:"purple",onClick:d,children:a("storeSettings.signIn")})]});function q(e,t){p(void 0),m(l=>({...l,cover:t,coverName:`cover/${e}`,coverHash:""}))}const G=["image/png","image/jpeg","image/webp"];function Q(e){var H;const t=(H=e.target.files)==null?void 0:H[0];if(!t||!G.includes(t.type))return;p(t.size);const l=`cover/${t.name}`,u=new FileReader;u.onload=()=>{const T=u.result;N({url:T,name:l,hash:""}),m(ee=>({...ee,cover:T,coverName:l,coverHash:""}))},u.readAsDataURL(t)}function U(){o&&(p(void 0),m(e=>({...e,cover:o.url,coverName:o.name,coverHash:o.hash})))}function W(e,t){const l=t?(v[e]+t).replace(/\s/g,""):"";m(u=>({...u,links:{...u.links,[e]:l}}))}function X(e){const t=r.links[e];return e==="website"?t:t.replace(v[e],"")}async function Z(){if(!(!c||!i)){$(!0);try{await me(c,r,i.identity),y(r),p(void 0),await j.invalidateQueries({queryKey:["store",c.toLowerCase()]}),R.success(a("storeSettings.saved")),b(`/assets/creator/${c}`)}catch{R.error(a("storeSettings.saveError"))}finally{$(!1)}}}return s.jsxs("section",{className:"store-settings","aria-label":a("storeSettings.title"),children:[s.jsxs("div",{className:"store-settings__head",children:[s.jsxs("div",{className:"store-settings__heading",children:[c?s.jsx(te,{className:"store-settings__back",to:`/assets/creator/${c}`,title:a("storeSettings.back"),"aria-label":a("storeSettings.back"),children:s.jsx(E,{name:"arrow-left"})}):null,s.jsx("h1",{className:"store-settings__title",children:a("storeSettings.title")})]}),c?s.jsxs("a",{className:"store-settings__guest",href:`/assets/creator/${c}`,target:"_blank",rel:"noopener noreferrer",children:[a("storeSettings.seeAsGuest"),s.jsx(E,{name:"external-link"})]}):null]}),P?s.jsx(_e,{size:"large",label:a("storeSettings.loading"),className:"store-settings__loading"}):s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"field",children:[s.jsx("span",{className:"field__label",children:a("storeSettings.cover")}),s.jsxs("div",{className:"cover-picker",role:"group","aria-label":a("storeSettings.cover"),children:[h.map(e=>{const t=x===e.name;return s.jsx("button",{type:"button",className:`cover-picker__tile${t?" is-selected":""}`,"data-testid":"cover-picker-tile","data-selected":t,"aria-pressed":t,onClick:()=>q(e.name,e.url),children:s.jsx("img",{src:e.url,alt:"",loading:"lazy"})},e.name)}),o?s.jsx("button",{type:"button",className:`cover-picker__tile cover-picker__tile--custom${x?"":" is-selected"}`,"data-testid":"cover-picker-tile","data-variant":"custom","data-selected":!x,"aria-pressed":!x,onClick:U,children:s.jsx("img",{src:o.url,alt:""})}):null,s.jsxs("button",{type:"button",className:"cover-picker__tile cover-picker__upload","data-testid":"cover-picker-tile","data-variant":"upload",onClick:()=>{var e;return(e=z.current)==null?void 0:e.click()},children:[s.jsx(E,{name:"upload"}),s.jsx("span",{children:a("storeSettings.upload")})]}),s.jsx("input",{ref:z,type:"file",accept:"image/png, image/jpeg, image/webp",className:"cover-picker__input","data-testid":"cover-picker-input",onChange:Q})]}),I?s.jsx(M,{message:a("storeSettings.sizeError",{max:D(O),current:D(k)})}):null]}),s.jsxs("label",{className:"field",children:[s.jsx("span",{className:"field__label",children:a("storeSettings.description")}),s.jsx("textarea",{value:r.description,rows:4,disabled:g,onChange:e=>m(t=>({...t,description:e.target.value}))})]}),s.jsxs("label",{className:"field",children:[s.jsx("span",{className:"field__label",children:a("storeSettings.website")}),s.jsx("input",{type:"url",value:r.links.website,placeholder:v.website,disabled:g,onChange:e=>m(t=>({...t,links:{...t.links,website:e.target.value.replace(/\s/g,"")}}))}),B("website",r.links.website)?null:s.jsx(M,{message:a("storeSettings.linkError",{value:v.website})})]}),["twitter","discord","facebook"].map(e=>s.jsxs("label",{className:"field",children:[s.jsx("span",{className:"field__label",children:a(`storeSettings.${e}`)}),s.jsxs("div",{className:"field__prefixed",children:[s.jsx("span",{className:"field__prefix",children:v[e]}),s.jsx("input",{type:"text",value:X(e),disabled:g,onChange:t=>W(e,t.target.value)})]})]},e)),s.jsx("div",{className:"store-settings__actions",children:s.jsx(F,{variant:"purple",className:"store-settings__save","data-testid":"store-settings-save",onClick:()=>void Z(),disabled:!K,children:g?a("storeSettings.saving"):a("storeSettings.save")})})]})]})}export{ye as StoreSettings,ye as default};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{u as g,a as N,j as s,N as v,r as p}from"./react-BrLDncxD.js";import{d as k,u as w,t as e,e as y,g as b,h as C,j as S,c as _,s as B,B as I,k as L}from"./index-
|
|
1
|
+
import{u as g,a as N,j as s,N as v,r as p}from"./react-BrLDncxD.js";import{d as k,u as w,t as e,e as y,g as b,h as C,j as S,c as _,s as B,B as I,k as L}from"./index-Q9d0V8TZ.js";import{w as A,S as T}from"./buy-gasless-Sy6Gurph.js";import"./dcl-schemas-BICTSpB5.js";import"./sentry-DYZXk5O5.js";import"./ethers-CLB2z3On.js";import"./intl-CBcMB1D2.js";import"./trade-encoding-CaZYjVNs.js";import"./authorizations-C600xDT9.js";import"./index-HN6Rk25C.js";const x=B(I)`
|
|
2
2
|
min-width: 160px;
|
|
3
3
|
text-align: center;
|
|
4
4
|
`,E=c=>new Promise(n=>setTimeout(n,c));function M(c,n){const[a,i]=p.useState(c?"pending":"confirmed"),u=n?`${n.owner}-${n.contractAddress}-${n.itemId}`:"";return p.useEffect(()=>{if(!c)return;let t=!1;return(async()=>{let l=!1;for(let r=0;r<20&&!t;r++)try{await A(c,{timeoutMs:15e3}),l=!0;break}catch(m){if(m instanceof T)continue;t||i("failed");return}if(!t){if(!l){i("timed-out");return}if(!n){i("confirmed");return}i("indexing");for(let r=0;r<40&&!t;r++){if(await L(n.owner,n.contractAddress,n.itemId)){t||i("confirmed");return}await E(3e3)}t||i("timed-out")}})(),()=>{t=!0}},[c,u]),a}const P=_.chainId===80002?"https://decentraland.zone/jump":"https://decentraland.org/jump",F=_.chainId===80002?"https://amoy.polygonscan.com/tx/":"https://polygonscan.com/tx/";function G(){const{state:c}=g(),n=N(),{session:a}=k(),i=c==null?void 0:c.txHash,u=(c==null?void 0:c.items)??[],t=u[0],j=a!=null&&a.address&&(t!=null&&t.contractAddress)&&(t!=null&&t.itemId)?{owner:a.address,contractAddress:t.contractAddress,itemId:t.itemId}:null,l=M(c!=null&&c.settled?void 0:i,j);w({title:e("seo.success.title"),noindex:!0});const r=u;if(r.length===0)return s.jsx(v,{to:"/assets",replace:!0});const m=r[0],d=!!i&&y(a==null?void 0:a.providerType)?s.jsx("a",{className:"success__receipt",href:`${F}${i}`,target:"_blank",rel:"noreferrer",children:e("success.viewTransaction")}):null;return l!=="confirmed"?s.jsx("div",{className:"success",children:s.jsx("div",{className:"success__status",children:l==="pending"||l==="indexing"?s.jsxs(s.Fragment,{children:[s.jsx("span",{className:"spinner success__spinner","aria-hidden":!0}),s.jsx("h1",{className:"success__title",children:l==="indexing"?e("success.finalizing"):e("success.processing")}),s.jsx("p",{className:"success__sub",children:l==="indexing"?s.jsxs(s.Fragment,{children:[e("success.indexingBefore")," ",r.length===1?s.jsx("strong",{children:m.name}):e("success.itemCount",{count:r.length})," ",e("success.indexingAfter")]}):s.jsxs(s.Fragment,{children:[e("success.confirmingBefore")," ",r.length===1?s.jsx("strong",{children:m.name}):e("success.itemCount",{count:r.length})," ",e("success.confirmingAfter")]})}),d?s.jsx("div",{className:"success__links",children:d}):null]}):l==="timed-out"?s.jsxs(s.Fragment,{children:[s.jsx("h1",{className:"success__title",children:e("success.stillProcessingTitle")}),s.jsxs("p",{className:"success__sub",children:[e("success.timedOutBefore")," ",s.jsx("button",{className:"link",onClick:()=>n("/my-purchases"),children:e("nav.myPurchases")})," ",e("success.timedOutAfter")]}),d?s.jsx("div",{className:"success__links",children:d}):null,s.jsxs("div",{className:"success__actions",children:[s.jsx(x,{variant:"purple",onClick:()=>n("/my-purchases"),children:e("success.viewMyPurchases")}),s.jsx(x,{variant:"ghost",onClick:()=>n("/assets"),children:e("success.keepShopping")})]})]}):s.jsxs(s.Fragment,{children:[s.jsx("h1",{className:"success__title",children:e("success.failedTitle")}),s.jsx("p",{className:"success__sub",children:e("success.failedBody")}),d?s.jsx("div",{className:"success__links",children:d}):null,s.jsx("div",{className:"success__actions",children:s.jsx(x,{variant:"purple",onClick:()=>n("/assets"),children:e("success.backToShop")})})]})})}):s.jsx("div",{className:"success",children:s.jsxs("div",{className:"success-done",children:[s.jsxs("div",{className:"success-banner",role:"status",children:[s.jsx("span",{className:"success-banner__check","aria-hidden":!0,children:s.jsxs("svg",{viewBox:"0 0 60 60",width:"60",height:"60",children:[s.jsx("circle",{cx:"30",cy:"30",r:"30",fill:"#34ce77"}),s.jsx("path",{d:"M18 31l8 8 16-18",fill:"none",stroke:"#fff",strokeWidth:"4.5",strokeLinecap:"round",strokeLinejoin:"round"})]})}),s.jsxs("p",{className:"success-banner__text",children:[s.jsx("b",{children:e("success.bannerTitle")})," ",e("success.bannerBody")]})]}),s.jsx("div",{className:"success-list",children:r.map((o,f)=>{const h=o.quantity??1;return s.jsxs("div",{className:"success-list__row",children:[f>0?s.jsx("span",{className:"success-list__divider","aria-hidden":!0}):null,s.jsxs("div",{className:"success-row",children:[s.jsxs("div",{className:"success-row__thumb",children:[o.thumbnail?s.jsx("img",{src:o.thumbnail,alt:""}):null,s.jsx("span",{className:"success-row__check","aria-hidden":!0,children:s.jsx("svg",{viewBox:"0 0 18 18",width:"12",height:"12",children:s.jsx("path",{d:"M4 9l3.5 3.5L14 5",fill:"none",stroke:"#fff",strokeWidth:"2.4",strokeLinecap:"round",strokeLinejoin:"round"})})})]}),s.jsxs("div",{className:"success-row__info",children:[s.jsxs("div",{className:"success-row__name",title:o.name,children:[o.name||e("buyModal.itemFallback"),h>1?s.jsx("span",{className:"success-row__qty",children:e("cartCheckout.qty",{count:h})}):null]}),o.creator?s.jsx(b,{address:o.creator,className:"success-row__creator",linkToProfile:!0}):null]}),s.jsxs("div",{className:"success-row__price",children:[s.jsx(C,{className:"success-row__price-ico"}),s.jsx("span",{children:S(o.priceCredits*h)})]})]})]},o.id)})}),d?s.jsx("div",{className:"success__links success-done__receipt",children:d}):null,s.jsxs("div",{className:"success-ctas",children:[s.jsx("button",{className:"success-cta success-cta--ghost",onClick:()=>n("/my-assets"),children:e("success.myAssets")}),s.jsxs("a",{className:"success-cta success-cta--ruby",href:P,target:"_blank",rel:"noreferrer",children:[e("success.tryInWorld"),s.jsx("span",{className:"success-cta__jump","aria-hidden":!0,children:s.jsx("svg",{viewBox:"0 0 24 24",width:"20",height:"20",children:s.jsx("path",{d:"M5 12h12M13 7l5 5-5 5",fill:"none",stroke:"#fcfcfc",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})})})]})]})]})})}export{G as Success,G as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{N as T,j as G,R as I,S as f,k as B,E as M,l as F,W as L,C as g,B as N,b as W,m as E,A as O,n as z,d as _,g as R,o as H,e as V,i as q,p as $}from"./W3MFrameProviderSingleton-B40OWK0h.js";import{au as C}from"./NetworkUtil-BGlQiKvg.js";const b={getGasPriceInEther(n,o){const t=o*n;return Number(t)/1e18},getGasPriceInUSD(n,o,t){const s=b.getGasPriceInEther(o,t);return T.bigNumber(n).times(s).toNumber()},getPriceImpact({sourceTokenAmount:n,sourceTokenPriceInUSD:o,toTokenPriceInUSD:t,toTokenAmount:s}){const c=T.bigNumber(n).times(o),r=T.bigNumber(s).times(t);return c.minus(r).div(c).times(100).toNumber()},getMaxSlippage(n,o){const t=T.bigNumber(n).div(100);return T.multiply(o,t).toNumber()},getProviderFee(n,o=.0085){return T.bigNumber(n).times(o).toString()},isInsufficientNetworkTokenForGas(n,o){const t=o||"0";return T.bigNumber(n).eq(0)?!0:T.bigNumber(T.bigNumber(t)).gt(n)},isInsufficientSourceTokenForSwap(n,o,t){var r,d;const s=(d=(r=t==null?void 0:t.find(l=>l.address===o))==null?void 0:r.quantity)==null?void 0:d.numeric;return T.bigNumber(s||"0").lt(n)}},x=15e4,Q=6,m={initializing:!1,initialized:!1,loadingPrices:!1,loadingQuote:!1,loadingApprovalTransaction:!1,loadingBuildTransaction:!1,loadingTransaction:!1,switchingTokens:!1,fetchError:!1,approvalTransaction:void 0,swapTransaction:void 0,transactionError:void 0,sourceToken:void 0,sourceTokenAmount:"",sourceTokenPriceInUSD:0,toToken:void 0,toTokenAmount:"",toTokenPriceInUSD:0,networkPrice:"0",networkBalanceInUSD:"0",networkTokenSymbol:"",inputError:void 0,slippage:_.CONVERT_SLIPPAGE_TOLERANCE,tokens:void 0,popularTokens:void 0,suggestedTokens:void 0,foundTokens:void 0,myTokensWithBalance:void 0,tokensPriceMap:{},gasFee:"0",gasPriceInUSD:0,priceImpact:void 0,maxSlippage:void 0,providerFee:void 0},e=$({...m}),D={state:e,subscribe(n){return q(e,()=>n(e))},subscribeKey(n,o){return V(e,n,o)},getParams(){var i,u,p,w,h,y,A,S,P;const n=g.state.activeChain,o=((i=g.getAccountData(n))==null?void 0:i.caipAddress)??g.state.activeCaipAddress,t=W.getPlainAddress(o),s=R(),c=H.getConnectorId(g.state.activeChain);if(!t)throw new Error("No address found to swap the tokens from.");const r=!((u=e.toToken)!=null&&u.address)||!((p=e.toToken)!=null&&p.decimals),d=!((w=e.sourceToken)!=null&&w.address)||!((h=e.sourceToken)!=null&&h.decimals)||!T.bigNumber(e.sourceTokenAmount).gt(0),l=!e.sourceTokenAmount;return{networkAddress:s,fromAddress:t,fromCaipAddress:o,sourceTokenAddress:(y=e.sourceToken)==null?void 0:y.address,toTokenAddress:(A=e.toToken)==null?void 0:A.address,toTokenAmount:e.toTokenAmount,toTokenDecimals:(S=e.toToken)==null?void 0:S.decimals,sourceTokenAmount:e.sourceTokenAmount,sourceTokenDecimals:(P=e.sourceToken)==null?void 0:P.decimals,invalidToToken:r,invalidSourceToken:d,invalidSourceTokenAmount:l,availableToSwap:o&&!r&&!d&&!l,isAuthConnector:c===C.CONNECTOR_ID.AUTH}},async setSourceToken(n){if(!n){e.sourceToken=n,e.sourceTokenAmount="",e.sourceTokenPriceInUSD=0;return}e.sourceToken=n,await a.setTokenPrice(n.address,"sourceToken")},setSourceTokenAmount(n){e.sourceTokenAmount=n},async setToToken(n){if(!n){e.toToken=n,e.toTokenAmount="",e.toTokenPriceInUSD=0;return}e.toToken=n,await a.setTokenPrice(n.address,"toToken")},setToTokenAmount(n){e.toTokenAmount=n?T.toFixed(n,Q):""},async setTokenPrice(n,o){let t=e.tokensPriceMap[n]||0;t||(e.loadingPrices=!0,t=await a.getAddressPrice(n)),o==="sourceToken"?e.sourceTokenPriceInUSD=t:o==="toToken"&&(e.toTokenPriceInUSD=t),e.loadingPrices&&(e.loadingPrices=!1),a.getParams().availableToSwap&&!e.switchingTokens&&a.swapTokens()},async switchTokens(){if(!(e.initializing||!e.initialized||e.switchingTokens)){e.switchingTokens=!0;try{const n=e.toToken?{...e.toToken}:void 0,o=e.sourceToken?{...e.sourceToken}:void 0,t=n&&e.toTokenAmount===""?"1":e.toTokenAmount;a.setSourceTokenAmount(t),a.setToTokenAmount(""),await a.setSourceToken(n),await a.setToToken(o),e.switchingTokens=!1,a.swapTokens()}catch(n){throw e.switchingTokens=!1,n}}},resetState(){e.myTokensWithBalance=m.myTokensWithBalance,e.tokensPriceMap=m.tokensPriceMap,e.initialized=m.initialized,e.initializing=m.initializing,e.switchingTokens=m.switchingTokens,e.sourceToken=m.sourceToken,e.sourceTokenAmount=m.sourceTokenAmount,e.sourceTokenPriceInUSD=m.sourceTokenPriceInUSD,e.toToken=m.toToken,e.toTokenAmount=m.toTokenAmount,e.toTokenPriceInUSD=m.toTokenPriceInUSD,e.networkPrice=m.networkPrice,e.networkTokenSymbol=m.networkTokenSymbol,e.networkBalanceInUSD=m.networkBalanceInUSD,e.inputError=m.inputError},resetValues(){var t;const{networkAddress:n}=a.getParams(),o=(t=e.tokens)==null?void 0:t.find(s=>s.address===n);a.setSourceToken(o),a.setToToken(void 0)},getApprovalLoadingState(){return e.loadingApprovalTransaction},clearError(){e.transactionError=void 0},async initializeState(){if(!e.initializing){if(e.initializing=!0,!e.initialized)try{await a.fetchTokens(),e.initialized=!0}catch{e.initialized=!1,f.showError("Failed to initialize swap"),I.goBack()}e.initializing=!1}},async fetchTokens(){var t;const{networkAddress:n}=a.getParams();await a.getNetworkTokenPrice(),await a.getMyTokensWithBalance();const o=(t=e.myTokensWithBalance)==null?void 0:t.find(s=>s.address===n);o&&(e.networkTokenSymbol=o.symbol,a.setSourceToken(o),a.setSourceTokenAmount("0"))},async getTokenList(){var o,t;const n=(o=g.state.activeCaipNetwork)==null?void 0:o.caipNetworkId;if(!(e.caipNetworkId===n&&e.tokens))try{e.tokensLoading=!0;const s=await E.getTokenList(n);e.tokens=s,e.caipNetworkId=n,e.popularTokens=s.sort((i,u)=>i.symbol<u.symbol?-1:i.symbol>u.symbol?1:0);const r=(n&&((t=_.SUGGESTED_TOKENS_BY_CHAIN)==null?void 0:t[n])||[]).map(i=>s.find(u=>u.symbol===i)).filter(i=>!!i),l=(_.SWAP_SUGGESTED_TOKENS||[]).map(i=>s.find(u=>u.symbol===i)).filter(i=>!!i).filter(i=>!r.some(u=>u.address===i.address));e.suggestedTokens=[...r,...l]}catch{e.tokens=[],e.popularTokens=[],e.suggestedTokens=[]}finally{e.tokensLoading=!1}},async getAddressPrice(n){var i,u;const o=e.tokensPriceMap[n];if(o)return o;const t=await N.fetchTokenPrice({addresses:[n]}),s=(t==null?void 0:t.fungibles)||[],c=[...e.tokens||[],...e.myTokensWithBalance||[]],r=(i=c==null?void 0:c.find(p=>p.address===n))==null?void 0:i.symbol,d=((u=s.find(p=>p.symbol.toLowerCase()===(r==null?void 0:r.toLowerCase())))==null?void 0:u.price)||0,l=parseFloat(d.toString());return e.tokensPriceMap[n]=l,l},async getNetworkTokenPrice(){var c;const{networkAddress:n}=a.getParams(),t=(c=(await N.fetchTokenPrice({addresses:[n]}).catch(()=>(f.showError("Failed to fetch network token price"),{fungibles:[]}))).fungibles)==null?void 0:c[0],s=(t==null?void 0:t.price.toString())||"0";e.tokensPriceMap[n]=parseFloat(s),e.networkTokenSymbol=(t==null?void 0:t.symbol)||"",e.networkPrice=s},async getMyTokensWithBalance(n){var s;const o=await z.getMyTokensWithBalance({forceUpdate:n,caipNetwork:g.state.activeCaipNetwork,address:(s=g.getAccountData())==null?void 0:s.address}),t=E.mapBalancesToSwapTokens(o);t&&(await a.getInitialGasPrice(),a.setBalances(t))},setBalances(n){const{networkAddress:o}=a.getParams(),t=g.state.activeCaipNetwork;if(!t)return;const s=n.find(c=>c.address===o);n.forEach(c=>{e.tokensPriceMap[c.address]=c.price||0}),e.myTokensWithBalance=n.filter(c=>c.address.startsWith(t.caipNetworkId)),e.networkBalanceInUSD=s?T.multiply(s.quantity.numeric,s.price).toString():"0"},async getInitialGasPrice(){var o,t;const n=await E.fetchGasPrice();if(!n)return{gasPrice:null,gasPriceInUSD:null};switch((t=(o=g.state)==null?void 0:o.activeCaipNetwork)==null?void 0:t.chainNamespace){case C.CHAIN.SOLANA:return e.gasFee=n.standard??"0",e.gasPriceInUSD=T.multiply(n.standard,e.networkPrice).div(1e9).toNumber(),{gasPrice:BigInt(e.gasFee),gasPriceInUSD:Number(e.gasPriceInUSD)};case C.CHAIN.EVM:default:const s=n.standard??"0",c=BigInt(s),r=BigInt(x),d=b.getGasPriceInUSD(e.networkPrice,r,c);return e.gasFee=s,e.gasPriceInUSD=d,{gasPrice:c,gasPriceInUSD:d}}},async swapTokens(){var r,d,l;const n=(r=g.getAccountData())==null?void 0:r.address,o=e.sourceToken,t=e.toToken,s=T.bigNumber(e.sourceTokenAmount).gt(0);if(s||a.setToTokenAmount(""),!t||!o||e.loadingPrices||!s||!n)return;e.loadingQuote=!0;const c=T.bigNumber(e.sourceTokenAmount).times(10**o.decimals).round(0).toFixed(0);try{const i=await N.fetchSwapQuote({userAddress:n,from:o.address,to:t.address,gasPrice:e.gasFee,amount:c.toString()});e.loadingQuote=!1;const u=(l=(d=i==null?void 0:i.quotes)==null?void 0:d[0])==null?void 0:l.toAmount;if(!u){O.open({displayMessage:"Incorrect amount",debugMessage:"Please enter a valid amount"},"error");return}const p=T.bigNumber(u).div(10**t.decimals).toString();a.setToTokenAmount(p),a.hasInsufficientToken(e.sourceTokenAmount,o.address)?e.inputError="Insufficient balance":(e.inputError=void 0,a.setTransactionDetails())}catch(i){const u=await E.handleSwapError(i);e.loadingQuote=!1,e.inputError=u||"Insufficient balance"}},async getTransaction(){const{fromCaipAddress:n,availableToSwap:o}=a.getParams(),t=e.sourceToken,s=e.toToken;if(!(!n||!o||!t||!s||e.loadingQuote))try{e.loadingBuildTransaction=!0;const c=await E.fetchSwapAllowance({userAddress:n,tokenAddress:t.address,sourceTokenAmount:e.sourceTokenAmount,sourceTokenDecimals:t.decimals});let r;return c?r=await a.createSwapTransaction():r=await a.createAllowanceTransaction(),e.loadingBuildTransaction=!1,e.fetchError=!1,r}catch{I.goBack(),f.showError("Failed to check allowance"),e.loadingBuildTransaction=!1,e.approvalTransaction=void 0,e.swapTransaction=void 0,e.fetchError=!0;return}},async createAllowanceTransaction(){const{fromCaipAddress:n,sourceTokenAddress:o,toTokenAddress:t}=a.getParams();if(!(!n||!t)){if(!o)throw new Error("createAllowanceTransaction - No source token address found.");try{const s=await N.generateApproveCalldata({from:o,to:t,userAddress:n}),c=W.getPlainAddress(s.tx.from);if(!c)throw new Error("SwapController:createAllowanceTransaction - address is required");const r={data:s.tx.data,to:c,gasPrice:BigInt(s.tx.eip155.gasPrice),value:BigInt(s.tx.value),toAmount:e.toTokenAmount};return e.swapTransaction=void 0,e.approvalTransaction={data:r.data,to:r.to,gasPrice:r.gasPrice,value:r.value,toAmount:r.toAmount},{data:r.data,to:r.to,gasPrice:r.gasPrice,value:r.value,toAmount:r.toAmount}}catch{I.goBack(),f.showError("Failed to create approval transaction"),e.approvalTransaction=void 0,e.swapTransaction=void 0,e.fetchError=!0;return}}},async createSwapTransaction(){var d,l;const{networkAddress:n,fromCaipAddress:o,sourceTokenAmount:t}=a.getParams(),s=e.sourceToken,c=e.toToken;if(!o||!t||!s||!c)return;let r=(d=B.parseUnits(t,s.decimals))==null?void 0:d.toString();try{const i=s.address===n;let u=await N.generateSwapCalldata({userAddress:o,from:s.address,to:c.address,amount:r,disableEstimate:!0}),p=BigInt(u.tx.eip155.gas),w=BigInt(u.tx.eip155.gasPrice);if(i&&r){const A=(l=e.myTokensWithBalance)==null?void 0:l.find(S=>S.address===n);if(A){const S=parseInt(A.quantity.decimals,10),P=B.parseUnits(A.quantity.numeric,S)??0n,v=p*w;if(BigInt(r)+v>P){const k=P>v?P-v:0n;k>0n&&(u=await N.generateSwapCalldata({userAddress:o,from:s.address,to:c.address,amount:k.toString(),disableEstimate:!0}),r=k.toString(),p=BigInt(u.tx.eip155.gas),w=BigInt(u.tx.eip155.gasPrice))}}}const h=W.getPlainAddress(u.tx.to);if(!h)throw new Error("SwapController:createSwapTransaction - address is required");const y={data:u.tx.data,to:h,gas:p,gasPrice:w,value:BigInt(i?r??"0":"0"),toAmount:e.toTokenAmount};return e.gasPriceInUSD=b.getGasPriceInUSD(e.networkPrice,p,w),e.approvalTransaction=void 0,e.swapTransaction=y,y}catch{I.goBack(),f.showError("Failed to create transaction"),e.approvalTransaction=void 0,e.swapTransaction=void 0,e.fetchError=!0;return}},onEmbeddedWalletApprovalSuccess(){f.showLoading("Approve limit increase in your wallet"),I.replace("SwapPreview")},async sendTransactionForApproval(n){var c,r,d;const{fromAddress:o,isAuthConnector:t}=a.getParams();e.loadingApprovalTransaction=!0,t?I.pushTransactionStack({onSuccess:a.onEmbeddedWalletApprovalSuccess}):f.showLoading("Approve limit increase in your wallet");try{await B.sendTransaction({address:o,to:n.to,data:n.data,value:n.value,chainNamespace:C.CHAIN.EVM}),await a.swapTokens(),await a.getTransaction(),e.approvalTransaction=void 0,e.loadingApprovalTransaction=!1}catch(l){const i=l;e.transactionError=i==null?void 0:i.displayMessage,e.loadingApprovalTransaction=!1,f.showError((i==null?void 0:i.displayMessage)||"Transaction error"),M.sendEvent({type:"track",event:"SWAP_APPROVAL_ERROR",properties:{message:(i==null?void 0:i.displayMessage)||(i==null?void 0:i.message)||"Unknown",network:((c=g.state.activeCaipNetwork)==null?void 0:c.caipNetworkId)||"",swapFromToken:((r=a.state.sourceToken)==null?void 0:r.symbol)||"",swapToToken:((d=a.state.toToken)==null?void 0:d.symbol)||"",swapFromAmount:a.state.sourceTokenAmount||"",swapToAmount:a.state.toTokenAmount||"",isSmartAccount:F(C.CHAIN.EVM)===L.ACCOUNT_TYPES.SMART_ACCOUNT}})}},async sendTransactionForSwap(n){var d,l,i,u,p,w,h,y,A,S,P,v;if(!n)return;const{fromAddress:o,toTokenAmount:t,isAuthConnector:s}=a.getParams();e.loadingTransaction=!0;const c=`Swapping ${(d=e.sourceToken)==null?void 0:d.symbol} to ${T.formatNumberToLocalString(t,3)} ${(l=e.toToken)==null?void 0:l.symbol}`,r=`Swapped ${(i=e.sourceToken)==null?void 0:i.symbol} to ${T.formatNumberToLocalString(t,3)} ${(u=e.toToken)==null?void 0:u.symbol}`;s?I.pushTransactionStack({onSuccess(){I.replace("Account"),f.showLoading(c),D.resetState()}}):f.showLoading("Confirm transaction in your wallet");try{const U=[(p=e.sourceToken)==null?void 0:p.address,(w=e.toToken)==null?void 0:w.address].join(","),k=await B.sendTransaction({address:o,to:n.to,data:n.data,value:n.value,chainNamespace:C.CHAIN.EVM});return e.loadingTransaction=!1,f.showSuccess(r),M.sendEvent({type:"track",event:"SWAP_SUCCESS",properties:{network:((h=g.state.activeCaipNetwork)==null?void 0:h.caipNetworkId)||"",swapFromToken:((y=a.state.sourceToken)==null?void 0:y.symbol)||"",swapToToken:((A=a.state.toToken)==null?void 0:A.symbol)||"",swapFromAmount:a.state.sourceTokenAmount||"",swapToAmount:a.state.toTokenAmount||"",isSmartAccount:F(C.CHAIN.EVM)===L.ACCOUNT_TYPES.SMART_ACCOUNT}}),D.resetState(),s||I.replace("Account"),D.getMyTokensWithBalance(U),k}catch(U){const k=U;e.transactionError=k==null?void 0:k.displayMessage,e.loadingTransaction=!1,f.showError((k==null?void 0:k.displayMessage)||"Transaction error"),M.sendEvent({type:"track",event:"SWAP_ERROR",properties:{message:(k==null?void 0:k.displayMessage)||(k==null?void 0:k.message)||"Unknown",network:((S=g.state.activeCaipNetwork)==null?void 0:S.caipNetworkId)||"",swapFromToken:((P=a.state.sourceToken)==null?void 0:P.symbol)||"",swapToToken:((v=a.state.toToken)==null?void 0:v.symbol)||"",swapFromAmount:a.state.sourceTokenAmount||"",swapToAmount:a.state.toTokenAmount||"",isSmartAccount:F(C.CHAIN.EVM)===L.ACCOUNT_TYPES.SMART_ACCOUNT}});return}},hasInsufficientToken(n,o){return b.isInsufficientSourceTokenForSwap(n,o,e.myTokensWithBalance)},setTransactionDetails(){const{toTokenAddress:n,toTokenDecimals:o}=a.getParams();!n||!o||(e.gasPriceInUSD=b.getGasPriceInUSD(e.networkPrice,BigInt(e.gasFee),BigInt(x)),e.priceImpact=b.getPriceImpact({sourceTokenAmount:e.sourceTokenAmount,sourceTokenPriceInUSD:e.sourceTokenPriceInUSD,toTokenPriceInUSD:e.toTokenPriceInUSD,toTokenAmount:e.toTokenAmount}),e.maxSlippage=b.getMaxSlippage(e.slippage,e.toTokenAmount),e.providerFee=b.getProviderFee(e.sourceTokenAmount))}},a=G(D);export{a as S};
|
|
1
|
+
import{N as T,j as G,R as I,S as f,k as B,E as M,l as F,W as L,C as g,B as N,b as W,m as E,A as O,n as z,d as _,g as R,o as H,e as V,i as q,p as $}from"./W3MFrameProviderSingleton-WHc1zToo.js";import{au as C}from"./NetworkUtil-BGlQiKvg.js";const b={getGasPriceInEther(n,o){const t=o*n;return Number(t)/1e18},getGasPriceInUSD(n,o,t){const s=b.getGasPriceInEther(o,t);return T.bigNumber(n).times(s).toNumber()},getPriceImpact({sourceTokenAmount:n,sourceTokenPriceInUSD:o,toTokenPriceInUSD:t,toTokenAmount:s}){const c=T.bigNumber(n).times(o),r=T.bigNumber(s).times(t);return c.minus(r).div(c).times(100).toNumber()},getMaxSlippage(n,o){const t=T.bigNumber(n).div(100);return T.multiply(o,t).toNumber()},getProviderFee(n,o=.0085){return T.bigNumber(n).times(o).toString()},isInsufficientNetworkTokenForGas(n,o){const t=o||"0";return T.bigNumber(n).eq(0)?!0:T.bigNumber(T.bigNumber(t)).gt(n)},isInsufficientSourceTokenForSwap(n,o,t){var r,d;const s=(d=(r=t==null?void 0:t.find(l=>l.address===o))==null?void 0:r.quantity)==null?void 0:d.numeric;return T.bigNumber(s||"0").lt(n)}},x=15e4,Q=6,m={initializing:!1,initialized:!1,loadingPrices:!1,loadingQuote:!1,loadingApprovalTransaction:!1,loadingBuildTransaction:!1,loadingTransaction:!1,switchingTokens:!1,fetchError:!1,approvalTransaction:void 0,swapTransaction:void 0,transactionError:void 0,sourceToken:void 0,sourceTokenAmount:"",sourceTokenPriceInUSD:0,toToken:void 0,toTokenAmount:"",toTokenPriceInUSD:0,networkPrice:"0",networkBalanceInUSD:"0",networkTokenSymbol:"",inputError:void 0,slippage:_.CONVERT_SLIPPAGE_TOLERANCE,tokens:void 0,popularTokens:void 0,suggestedTokens:void 0,foundTokens:void 0,myTokensWithBalance:void 0,tokensPriceMap:{},gasFee:"0",gasPriceInUSD:0,priceImpact:void 0,maxSlippage:void 0,providerFee:void 0},e=$({...m}),D={state:e,subscribe(n){return q(e,()=>n(e))},subscribeKey(n,o){return V(e,n,o)},getParams(){var i,u,p,w,h,y,A,S,P;const n=g.state.activeChain,o=((i=g.getAccountData(n))==null?void 0:i.caipAddress)??g.state.activeCaipAddress,t=W.getPlainAddress(o),s=R(),c=H.getConnectorId(g.state.activeChain);if(!t)throw new Error("No address found to swap the tokens from.");const r=!((u=e.toToken)!=null&&u.address)||!((p=e.toToken)!=null&&p.decimals),d=!((w=e.sourceToken)!=null&&w.address)||!((h=e.sourceToken)!=null&&h.decimals)||!T.bigNumber(e.sourceTokenAmount).gt(0),l=!e.sourceTokenAmount;return{networkAddress:s,fromAddress:t,fromCaipAddress:o,sourceTokenAddress:(y=e.sourceToken)==null?void 0:y.address,toTokenAddress:(A=e.toToken)==null?void 0:A.address,toTokenAmount:e.toTokenAmount,toTokenDecimals:(S=e.toToken)==null?void 0:S.decimals,sourceTokenAmount:e.sourceTokenAmount,sourceTokenDecimals:(P=e.sourceToken)==null?void 0:P.decimals,invalidToToken:r,invalidSourceToken:d,invalidSourceTokenAmount:l,availableToSwap:o&&!r&&!d&&!l,isAuthConnector:c===C.CONNECTOR_ID.AUTH}},async setSourceToken(n){if(!n){e.sourceToken=n,e.sourceTokenAmount="",e.sourceTokenPriceInUSD=0;return}e.sourceToken=n,await a.setTokenPrice(n.address,"sourceToken")},setSourceTokenAmount(n){e.sourceTokenAmount=n},async setToToken(n){if(!n){e.toToken=n,e.toTokenAmount="",e.toTokenPriceInUSD=0;return}e.toToken=n,await a.setTokenPrice(n.address,"toToken")},setToTokenAmount(n){e.toTokenAmount=n?T.toFixed(n,Q):""},async setTokenPrice(n,o){let t=e.tokensPriceMap[n]||0;t||(e.loadingPrices=!0,t=await a.getAddressPrice(n)),o==="sourceToken"?e.sourceTokenPriceInUSD=t:o==="toToken"&&(e.toTokenPriceInUSD=t),e.loadingPrices&&(e.loadingPrices=!1),a.getParams().availableToSwap&&!e.switchingTokens&&a.swapTokens()},async switchTokens(){if(!(e.initializing||!e.initialized||e.switchingTokens)){e.switchingTokens=!0;try{const n=e.toToken?{...e.toToken}:void 0,o=e.sourceToken?{...e.sourceToken}:void 0,t=n&&e.toTokenAmount===""?"1":e.toTokenAmount;a.setSourceTokenAmount(t),a.setToTokenAmount(""),await a.setSourceToken(n),await a.setToToken(o),e.switchingTokens=!1,a.swapTokens()}catch(n){throw e.switchingTokens=!1,n}}},resetState(){e.myTokensWithBalance=m.myTokensWithBalance,e.tokensPriceMap=m.tokensPriceMap,e.initialized=m.initialized,e.initializing=m.initializing,e.switchingTokens=m.switchingTokens,e.sourceToken=m.sourceToken,e.sourceTokenAmount=m.sourceTokenAmount,e.sourceTokenPriceInUSD=m.sourceTokenPriceInUSD,e.toToken=m.toToken,e.toTokenAmount=m.toTokenAmount,e.toTokenPriceInUSD=m.toTokenPriceInUSD,e.networkPrice=m.networkPrice,e.networkTokenSymbol=m.networkTokenSymbol,e.networkBalanceInUSD=m.networkBalanceInUSD,e.inputError=m.inputError},resetValues(){var t;const{networkAddress:n}=a.getParams(),o=(t=e.tokens)==null?void 0:t.find(s=>s.address===n);a.setSourceToken(o),a.setToToken(void 0)},getApprovalLoadingState(){return e.loadingApprovalTransaction},clearError(){e.transactionError=void 0},async initializeState(){if(!e.initializing){if(e.initializing=!0,!e.initialized)try{await a.fetchTokens(),e.initialized=!0}catch{e.initialized=!1,f.showError("Failed to initialize swap"),I.goBack()}e.initializing=!1}},async fetchTokens(){var t;const{networkAddress:n}=a.getParams();await a.getNetworkTokenPrice(),await a.getMyTokensWithBalance();const o=(t=e.myTokensWithBalance)==null?void 0:t.find(s=>s.address===n);o&&(e.networkTokenSymbol=o.symbol,a.setSourceToken(o),a.setSourceTokenAmount("0"))},async getTokenList(){var o,t;const n=(o=g.state.activeCaipNetwork)==null?void 0:o.caipNetworkId;if(!(e.caipNetworkId===n&&e.tokens))try{e.tokensLoading=!0;const s=await E.getTokenList(n);e.tokens=s,e.caipNetworkId=n,e.popularTokens=s.sort((i,u)=>i.symbol<u.symbol?-1:i.symbol>u.symbol?1:0);const r=(n&&((t=_.SUGGESTED_TOKENS_BY_CHAIN)==null?void 0:t[n])||[]).map(i=>s.find(u=>u.symbol===i)).filter(i=>!!i),l=(_.SWAP_SUGGESTED_TOKENS||[]).map(i=>s.find(u=>u.symbol===i)).filter(i=>!!i).filter(i=>!r.some(u=>u.address===i.address));e.suggestedTokens=[...r,...l]}catch{e.tokens=[],e.popularTokens=[],e.suggestedTokens=[]}finally{e.tokensLoading=!1}},async getAddressPrice(n){var i,u;const o=e.tokensPriceMap[n];if(o)return o;const t=await N.fetchTokenPrice({addresses:[n]}),s=(t==null?void 0:t.fungibles)||[],c=[...e.tokens||[],...e.myTokensWithBalance||[]],r=(i=c==null?void 0:c.find(p=>p.address===n))==null?void 0:i.symbol,d=((u=s.find(p=>p.symbol.toLowerCase()===(r==null?void 0:r.toLowerCase())))==null?void 0:u.price)||0,l=parseFloat(d.toString());return e.tokensPriceMap[n]=l,l},async getNetworkTokenPrice(){var c;const{networkAddress:n}=a.getParams(),t=(c=(await N.fetchTokenPrice({addresses:[n]}).catch(()=>(f.showError("Failed to fetch network token price"),{fungibles:[]}))).fungibles)==null?void 0:c[0],s=(t==null?void 0:t.price.toString())||"0";e.tokensPriceMap[n]=parseFloat(s),e.networkTokenSymbol=(t==null?void 0:t.symbol)||"",e.networkPrice=s},async getMyTokensWithBalance(n){var s;const o=await z.getMyTokensWithBalance({forceUpdate:n,caipNetwork:g.state.activeCaipNetwork,address:(s=g.getAccountData())==null?void 0:s.address}),t=E.mapBalancesToSwapTokens(o);t&&(await a.getInitialGasPrice(),a.setBalances(t))},setBalances(n){const{networkAddress:o}=a.getParams(),t=g.state.activeCaipNetwork;if(!t)return;const s=n.find(c=>c.address===o);n.forEach(c=>{e.tokensPriceMap[c.address]=c.price||0}),e.myTokensWithBalance=n.filter(c=>c.address.startsWith(t.caipNetworkId)),e.networkBalanceInUSD=s?T.multiply(s.quantity.numeric,s.price).toString():"0"},async getInitialGasPrice(){var o,t;const n=await E.fetchGasPrice();if(!n)return{gasPrice:null,gasPriceInUSD:null};switch((t=(o=g.state)==null?void 0:o.activeCaipNetwork)==null?void 0:t.chainNamespace){case C.CHAIN.SOLANA:return e.gasFee=n.standard??"0",e.gasPriceInUSD=T.multiply(n.standard,e.networkPrice).div(1e9).toNumber(),{gasPrice:BigInt(e.gasFee),gasPriceInUSD:Number(e.gasPriceInUSD)};case C.CHAIN.EVM:default:const s=n.standard??"0",c=BigInt(s),r=BigInt(x),d=b.getGasPriceInUSD(e.networkPrice,r,c);return e.gasFee=s,e.gasPriceInUSD=d,{gasPrice:c,gasPriceInUSD:d}}},async swapTokens(){var r,d,l;const n=(r=g.getAccountData())==null?void 0:r.address,o=e.sourceToken,t=e.toToken,s=T.bigNumber(e.sourceTokenAmount).gt(0);if(s||a.setToTokenAmount(""),!t||!o||e.loadingPrices||!s||!n)return;e.loadingQuote=!0;const c=T.bigNumber(e.sourceTokenAmount).times(10**o.decimals).round(0).toFixed(0);try{const i=await N.fetchSwapQuote({userAddress:n,from:o.address,to:t.address,gasPrice:e.gasFee,amount:c.toString()});e.loadingQuote=!1;const u=(l=(d=i==null?void 0:i.quotes)==null?void 0:d[0])==null?void 0:l.toAmount;if(!u){O.open({displayMessage:"Incorrect amount",debugMessage:"Please enter a valid amount"},"error");return}const p=T.bigNumber(u).div(10**t.decimals).toString();a.setToTokenAmount(p),a.hasInsufficientToken(e.sourceTokenAmount,o.address)?e.inputError="Insufficient balance":(e.inputError=void 0,a.setTransactionDetails())}catch(i){const u=await E.handleSwapError(i);e.loadingQuote=!1,e.inputError=u||"Insufficient balance"}},async getTransaction(){const{fromCaipAddress:n,availableToSwap:o}=a.getParams(),t=e.sourceToken,s=e.toToken;if(!(!n||!o||!t||!s||e.loadingQuote))try{e.loadingBuildTransaction=!0;const c=await E.fetchSwapAllowance({userAddress:n,tokenAddress:t.address,sourceTokenAmount:e.sourceTokenAmount,sourceTokenDecimals:t.decimals});let r;return c?r=await a.createSwapTransaction():r=await a.createAllowanceTransaction(),e.loadingBuildTransaction=!1,e.fetchError=!1,r}catch{I.goBack(),f.showError("Failed to check allowance"),e.loadingBuildTransaction=!1,e.approvalTransaction=void 0,e.swapTransaction=void 0,e.fetchError=!0;return}},async createAllowanceTransaction(){const{fromCaipAddress:n,sourceTokenAddress:o,toTokenAddress:t}=a.getParams();if(!(!n||!t)){if(!o)throw new Error("createAllowanceTransaction - No source token address found.");try{const s=await N.generateApproveCalldata({from:o,to:t,userAddress:n}),c=W.getPlainAddress(s.tx.from);if(!c)throw new Error("SwapController:createAllowanceTransaction - address is required");const r={data:s.tx.data,to:c,gasPrice:BigInt(s.tx.eip155.gasPrice),value:BigInt(s.tx.value),toAmount:e.toTokenAmount};return e.swapTransaction=void 0,e.approvalTransaction={data:r.data,to:r.to,gasPrice:r.gasPrice,value:r.value,toAmount:r.toAmount},{data:r.data,to:r.to,gasPrice:r.gasPrice,value:r.value,toAmount:r.toAmount}}catch{I.goBack(),f.showError("Failed to create approval transaction"),e.approvalTransaction=void 0,e.swapTransaction=void 0,e.fetchError=!0;return}}},async createSwapTransaction(){var d,l;const{networkAddress:n,fromCaipAddress:o,sourceTokenAmount:t}=a.getParams(),s=e.sourceToken,c=e.toToken;if(!o||!t||!s||!c)return;let r=(d=B.parseUnits(t,s.decimals))==null?void 0:d.toString();try{const i=s.address===n;let u=await N.generateSwapCalldata({userAddress:o,from:s.address,to:c.address,amount:r,disableEstimate:!0}),p=BigInt(u.tx.eip155.gas),w=BigInt(u.tx.eip155.gasPrice);if(i&&r){const A=(l=e.myTokensWithBalance)==null?void 0:l.find(S=>S.address===n);if(A){const S=parseInt(A.quantity.decimals,10),P=B.parseUnits(A.quantity.numeric,S)??0n,v=p*w;if(BigInt(r)+v>P){const k=P>v?P-v:0n;k>0n&&(u=await N.generateSwapCalldata({userAddress:o,from:s.address,to:c.address,amount:k.toString(),disableEstimate:!0}),r=k.toString(),p=BigInt(u.tx.eip155.gas),w=BigInt(u.tx.eip155.gasPrice))}}}const h=W.getPlainAddress(u.tx.to);if(!h)throw new Error("SwapController:createSwapTransaction - address is required");const y={data:u.tx.data,to:h,gas:p,gasPrice:w,value:BigInt(i?r??"0":"0"),toAmount:e.toTokenAmount};return e.gasPriceInUSD=b.getGasPriceInUSD(e.networkPrice,p,w),e.approvalTransaction=void 0,e.swapTransaction=y,y}catch{I.goBack(),f.showError("Failed to create transaction"),e.approvalTransaction=void 0,e.swapTransaction=void 0,e.fetchError=!0;return}},onEmbeddedWalletApprovalSuccess(){f.showLoading("Approve limit increase in your wallet"),I.replace("SwapPreview")},async sendTransactionForApproval(n){var c,r,d;const{fromAddress:o,isAuthConnector:t}=a.getParams();e.loadingApprovalTransaction=!0,t?I.pushTransactionStack({onSuccess:a.onEmbeddedWalletApprovalSuccess}):f.showLoading("Approve limit increase in your wallet");try{await B.sendTransaction({address:o,to:n.to,data:n.data,value:n.value,chainNamespace:C.CHAIN.EVM}),await a.swapTokens(),await a.getTransaction(),e.approvalTransaction=void 0,e.loadingApprovalTransaction=!1}catch(l){const i=l;e.transactionError=i==null?void 0:i.displayMessage,e.loadingApprovalTransaction=!1,f.showError((i==null?void 0:i.displayMessage)||"Transaction error"),M.sendEvent({type:"track",event:"SWAP_APPROVAL_ERROR",properties:{message:(i==null?void 0:i.displayMessage)||(i==null?void 0:i.message)||"Unknown",network:((c=g.state.activeCaipNetwork)==null?void 0:c.caipNetworkId)||"",swapFromToken:((r=a.state.sourceToken)==null?void 0:r.symbol)||"",swapToToken:((d=a.state.toToken)==null?void 0:d.symbol)||"",swapFromAmount:a.state.sourceTokenAmount||"",swapToAmount:a.state.toTokenAmount||"",isSmartAccount:F(C.CHAIN.EVM)===L.ACCOUNT_TYPES.SMART_ACCOUNT}})}},async sendTransactionForSwap(n){var d,l,i,u,p,w,h,y,A,S,P,v;if(!n)return;const{fromAddress:o,toTokenAmount:t,isAuthConnector:s}=a.getParams();e.loadingTransaction=!0;const c=`Swapping ${(d=e.sourceToken)==null?void 0:d.symbol} to ${T.formatNumberToLocalString(t,3)} ${(l=e.toToken)==null?void 0:l.symbol}`,r=`Swapped ${(i=e.sourceToken)==null?void 0:i.symbol} to ${T.formatNumberToLocalString(t,3)} ${(u=e.toToken)==null?void 0:u.symbol}`;s?I.pushTransactionStack({onSuccess(){I.replace("Account"),f.showLoading(c),D.resetState()}}):f.showLoading("Confirm transaction in your wallet");try{const U=[(p=e.sourceToken)==null?void 0:p.address,(w=e.toToken)==null?void 0:w.address].join(","),k=await B.sendTransaction({address:o,to:n.to,data:n.data,value:n.value,chainNamespace:C.CHAIN.EVM});return e.loadingTransaction=!1,f.showSuccess(r),M.sendEvent({type:"track",event:"SWAP_SUCCESS",properties:{network:((h=g.state.activeCaipNetwork)==null?void 0:h.caipNetworkId)||"",swapFromToken:((y=a.state.sourceToken)==null?void 0:y.symbol)||"",swapToToken:((A=a.state.toToken)==null?void 0:A.symbol)||"",swapFromAmount:a.state.sourceTokenAmount||"",swapToAmount:a.state.toTokenAmount||"",isSmartAccount:F(C.CHAIN.EVM)===L.ACCOUNT_TYPES.SMART_ACCOUNT}}),D.resetState(),s||I.replace("Account"),D.getMyTokensWithBalance(U),k}catch(U){const k=U;e.transactionError=k==null?void 0:k.displayMessage,e.loadingTransaction=!1,f.showError((k==null?void 0:k.displayMessage)||"Transaction error"),M.sendEvent({type:"track",event:"SWAP_ERROR",properties:{message:(k==null?void 0:k.displayMessage)||(k==null?void 0:k.message)||"Unknown",network:((S=g.state.activeCaipNetwork)==null?void 0:S.caipNetworkId)||"",swapFromToken:((P=a.state.sourceToken)==null?void 0:P.symbol)||"",swapToToken:((v=a.state.toToken)==null?void 0:v.symbol)||"",swapFromAmount:a.state.sourceTokenAmount||"",swapToAmount:a.state.toTokenAmount||"",isSmartAccount:F(C.CHAIN.EVM)===L.ACCOUNT_TYPES.SMART_ACCOUNT}});return}},hasInsufficientToken(n,o){return b.isInsufficientSourceTokenForSwap(n,o,e.myTokensWithBalance)},setTransactionDetails(){const{toTokenAddress:n,toTokenDecimals:o}=a.getParams();!n||!o||(e.gasPriceInUSD=b.getGasPriceInUSD(e.networkPrice,BigInt(e.gasFee),BigInt(x)),e.priceImpact=b.getPriceImpact({sourceTokenAmount:e.sourceTokenAmount,sourceTokenPriceInUSD:e.sourceTokenPriceInUSD,toTokenPriceInUSD:e.toTokenPriceInUSD,toTokenAmount:e.toTokenAmount}),e.maxSlippage=b.getMaxSlippage(e.slippage,e.toTokenAmount),e.providerFee=b.getProviderFee(e.sourceTokenAmount))}},a=G(D);export{a as S};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{r as e,j as c}from"./react-BrLDncxD.js";import{s as d,F as r}from"./index-
|
|
1
|
+
import{r as e,j as c}from"./react-BrLDncxD.js";import{s as d,F as r}from"./index-Q9d0V8TZ.js";import{n as x}from"./emotion-CSxEP8yM.js";const h=d("span",x("block"))`
|
|
2
2
|
position: relative;
|
|
3
3
|
display: ${({block:t})=>t?"flex":"inline-flex"};
|
|
4
4
|
${({block:t})=>t?"width: 100%;":""}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
var Ce=Object.defineProperty;var Ie=(e,t,n)=>t in e?Ce(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var T=(e,t,n)=>Ie(e,typeof t!="symbol"?t+"":t,n);import{W as we,b as oe,C as Se,B as ve,f as ie}from"./ethers-CLB2z3On.js";import{p as Re,d as X}from"./dcl-schemas-BICTSpB5.js";import{c as ce}from"./react-BrLDncxD.js";import{b6 as Ne}from"./index-CJ4mXolB.js";import{O as Oe,M as Pe,D as be,a as ue,g as de}from"./index-HN6Rk25C.js";import{c as K,e as De}from"./index-CCr2J09y.js";import"./sentry-DYZXk5O5.js";import"./intl-CBcMB1D2.js";import"./events-DQ172AOg.js";const Le="2d0335ab",Ue="0c53c51c",Fe="d8ed1acc",Me=ye("0x");let ke=0;async function je(e){let t=[];try{t=await q(e,"eth_requestAccounts",[])}catch{t=await q(e,"eth_accounts",[])}if(t.length===0)throw new Error("Could not find a valid connected account");return t[0]}async function $e(e,t,n){return q(e,"eth_signTypedData_v4",[t,n])}function He(e,t,n){const r=t.replace("0x",""),s=r.substring(0,64),i=r.substring(64,128),u=Ge(r.substring(128,130)),d=n.replace("0x",""),f=(d.length/2).toString(16),w=Math.ceil(d.length/64);return["0x",Ue,m(e),m("a0"),s,i,m(u),m(f),d.padEnd(64*w,"0")].join("")}function qe(e,t,n){const r=n.replace("0x",""),s=t.replace("0x",""),u=96+32+r.length/2,d=Math.ceil(s.length/64);return["0x",Fe,m(e),m("60"),m(u.toString(16)),m((r.length/2).toString(16)),r,m((s.length/2).toString(16)),s.padEnd(64*d,"0")].join("")}function Ge(e){let t=parseInt(e,16);if(t<27&&(t+=27),t!==27&&t!==28)throw Error(`Invalid signature version "${e}" (parsed: ${t})`);return t.toString(16)}async function Be(e,t,n){const r=m(t),s=await q(e,"eth_call",[{data:`0x${Le}${r}`,to:n},"latest"]);return m(s)}function Ve(e){return typeof e=="number"?`0x${m(e.toString(16))}`:`0x${m(e)}`}function Je(e,t){return q(e,"eth_getCode",[t.toLowerCase(),"latest"])}const We="0xef01";async function Ye(e,t){const n=await Je(e,t);return n.toLowerCase().startsWith(We)?!1:!Ze(n)}function ye(e){if(!/^0x[0-9a-f]*$/gi.test(e))throw new Error(`Not a valid hex string "${e}"`);let t=e.slice(2);for(;t.length<40;)t="0"+t;return"0x"+t}function Ze(e){return ye(e.toLowerCase())===Me}function m(e){return e.toString().replace("0x","").padStart(64,"0")}async function q(e,t,n){let r,s={jsonrpc:"2.0",id:++ke,method:t,params:n};if(e.request!==void 0?r=await e.request(s):e.sendAsync!==void 0?r=await e.sendAsync(s):e.send!==void 0&&(r=await e.send(t,n)),r)return r.result||r;throw new Error(`Could not send the transaction correcty. Either the provider does not support the method "${t}" or is missing a proper send/request.`)}function Xe(){return{serverURL:"https://transactions-api.decentraland.io/v1"}}var k;(function(e){e.UNKNOWN="unknown",e.DAPP_LIMIT_REACHED="dapp_limit_reached",e.USER_LIMIT_REACHED="user_limit_reached",e.API_LIMIT_REACHED="api_limit_reached",e.GAS_LIMIT_REACHED="gas_limit_reached",e.EXPECTATION_FAILED="expectation_failed",e.INVALID_TRANSACTION="invalid_transaction",e.INVALID_SCHEMA="invalid_schema",e.INVALID_CONTRACT_ADDRESS="invalid_contract_address",e.INVALID_ADDRESS="invalid_address",e.SALE_PRICE_TOO_LOW="sale_price_too_low",e.QUOTA_REACHED="quota_reached",e.CONTRACT_ACCOUNT="contract_account",e.HIGH_CONGESTION="high_congestion",e.USER_DENIED="user_denied"})(k||(k={}));class P extends Error{constructor(n,r){super(n);T(this,"code");this.code=r,Object.setPrototypeOf(this,P.prototype)}}async function Ke(e,t,n,r,s={}){const i={...Xe(),...s};if(!r.address.trim())throw new P(`The contract address for ${r.name} is empty. You're probably trying to get a proxy contract. Try adding an address to the result of getContract`,k.INVALID_ADDRESS);try{const u=await je(e);if(await Ye(e,u))throw new P("Contract accounts are not supported",k.CONTRACT_ACCOUNT);const d=r.abi.some(B=>{var V;return B.name==="executeMetaTransaction"&&((V=B.inputs)==null?void 0:V.some(W=>W.name==="_functionData"))}),f=await Be(t,u,r.address),w=Ve(r.chainId),I=Qe(w,r),D=ze(u,f,n,I,d),L=await $e(e,u,JSON.stringify(D)),G=(d?qe:He)(u,L,n),j=await fetch(`${i.serverURL}/transactions`,{headers:{"Content-Type":"application/json"},body:JSON.stringify({transactionData:{from:u,params:[r.address,G]}}),method:"POST"}),N=await j.json();if(N.ok===!1)throw N.message&&N.code?new P(N.message,N.code):new Error(`HTTP Error. Status: ${j.status}.`);return N.txHash}catch(u){const d=u;throw d instanceof P?d:d.message.indexOf("User denied message signature")!==-1?new P(d.message,k.USER_DENIED):(console.warn("An error occurred trying to send the meta transaction. Error:",d.message),new P(d.message,k.UNKNOWN))}}function ze(e,t,n,r,s=!1){return{types:{EIP712Domain:be,MetaTransaction:s?Oe:Pe},domain:r,primaryType:"MetaTransaction",message:{nonce:parseInt(t,16),from:e,...s?{functionData:n}:{functionSignature:n}}}}function Qe(e,t){return{name:t.name,version:t.version,verifyingContract:t.address,salt:e}}async function et(e){const t=await Ee();if(t){const n=await new we(t).getSigner().getChainId();if(e===n)return t}return K.createProvider(Re.ProviderType.NETWORK,e)}async function Ee(){try{return await K.getProvider()}catch{try{const{provider:e}=await K.tryPreviousConnection();return e}catch{return null}}}function le(e){return Math.floor(e/1e3)}function he(e){switch(e.assetType){case X.TradeAssetType.ERC721:return e.tokenId;case X.TradeAssetType.COLLECTION_ITEM:return e.itemId;case X.TradeAssetType.ERC20:return e.amount;default:return console.error("Invalid asset type:",e),""}}function tt(e){var t;return{checks:{uses:e.checks.uses,expiration:le(e.checks.expiration),effective:le(e.checks.effective),salt:oe(e.checks.salt,32),contractSignatureIndex:e.checks.contractSignatureIndex,signerSignatureIndex:e.checks.signerSignatureIndex,allowedRoot:oe(e.checks.allowedRoot,32),externalChecks:(t=e.checks.externalChecks)==null?void 0:t.map(n=>({contractAddress:n.contractAddress,selector:n.selector,value:n.value?n.value:"0x",required:n.required}))},sent:e.sent.map(n=>({assetType:n.assetType,contractAddress:n.contractAddress,value:he(n),extra:n.extra?n.extra:"0x"})),received:e.received.map(n=>({assetType:n.assetType,contractAddress:n.contractAddress,value:he(n),extra:n.extra?n.extra:"0x",beneficiary:n.beneficiary}))}}function fe(e,t){const n=tt(e);return{signer:e.signer,signature:e.signature,...n,checks:{...n.checks,allowedProof:[]},sent:n.sent.map(r=>({...r,beneficiary:t}))}}async function nt(e){const t=await e.request({method:"eth_chainId",params:[]});let n;return typeof t=="string"?n=parseInt(t,16):n=t,n}async function rt(e){const t=await et(e);return new we(t)}const b=new De.EventEmitter;var C;(function(e){e.ERROR="error",e.SUCCESS="success",e.PROMPT="prompt",e.ACCEPT="accept",e.REJECT="reject"})(C||(C={}));let at="https://transactions-api.decentraland.org/v1";const st=()=>at,ot=()=>new Promise((e,t)=>{const n=()=>{b.removeAllListeners(C.REJECT),e(!0)},r=()=>{b.removeAllListeners(C.ACCEPT),t(new Error("User rejected transaction"))};b.addListener(C.ACCEPT,n),b.addListener(C.REJECT,r)});async function pe(...e){const[t,n,...r]=e;try{const s=await Ee();if(!s)throw new Error("Provider not connected");const i=await nt(s),u=await rt(t.chainId),d=new Se(t.address,t.abi,u),f=await(typeof n=="function"?n(d.populateTransaction):d.populateTransaction[n](...r));if(i===t.chainId){const w=u.getSigner();if(s.isMagic||s.isThirdweb){let D=ve.from(0);try{const L=await w.getGasPrice(),U=await w.estimateGas(f);D=L.mul(U)}catch{}if(!D.isZero()){const L=ot(),U=await w.getBalance();b.emit(C.PROMPT,{transactionGasPrice:ie(D),userBalance:ie(U),chainId:t.chainId}),await L}}const I=await w.sendTransaction(f);return b.emit(C.SUCCESS,{txHash:I.hash}),I.hash}else{const w=await Ke(s,u,f.data,t,{serverURL:st()});return b.emit(C.SUCCESS,{txHash:w}),w}}catch(s){const i={type:C.ERROR,error:s};throw b.emit(C.ERROR,i),s}}var H={exports:{}};/*! https://mths.be/punycode v1.4.1 by @mathias */var it=H.exports,Te;function ct(){return Te||(Te=1,(function(e,t){(function(n){var r=t&&!t.nodeType&&t,s=e&&!e.nodeType&&e,i=typeof ce=="object"&&ce;(i.global===i||i.window===i||i.self===i)&&(n=i);var u,d=2147483647,f=36,w=1,I=26,D=38,L=700,U=72,G=128,j="-",N=/^xn--/,B=/[^\x20-\x7E]/,V=/[\x2E\u3002\uFF0E\uFF61]/g,W={overflow:"Overflow: input needs wider integers to process","not-basic":"Illegal input >= 0x80 (not a basic code point)","invalid-input":"Invalid input"},Y=f-w,S=Math.floor,$=String.fromCharCode,J;function F(a){throw new RangeError(W[a])}function z(a,o){for(var c=a.length,l=[];c--;)l[c]=o(a[c]);return l}function Q(a,o){var c=a.split("@"),l="";c.length>1&&(l=c[0]+"@",a=c[1]),a=a.replace(V,".");var h=a.split("."),y=z(h,o).join(".");return l+y}function ee(a){for(var o=[],c=0,l=a.length,h,y;c<l;)h=a.charCodeAt(c++),h>=55296&&h<=56319&&c<l?(y=a.charCodeAt(c++),(y&64512)==56320?o.push(((h&1023)<<10)+(y&1023)+65536):(o.push(h),c--)):o.push(h);return o}function te(a){return z(a,function(o){var c="";return o>65535&&(o-=65536,c+=$(o>>>10&1023|55296),o=56320|o&1023),c+=$(o),c}).join("")}function _e(a){return a-48<10?a-22:a-65<26?a-65:a-97<26?a-97:f}function ne(a,o){return a+22+75*(a<26)-((o!=0)<<5)}function re(a,o,c){var l=0;for(a=c?S(a/L):a>>1,a+=S(a/o);a>Y*I>>1;l+=f)a=S(a/Y);return S(l+(Y+1)*a/(a+D))}function ae(a){var o=[],c=a.length,l,h=0,y=G,p=U,E,A,v,R,g,_,x,O,M;for(E=a.lastIndexOf(j),E<0&&(E=0),A=0;A<E;++A)a.charCodeAt(A)>=128&&F("not-basic"),o.push(a.charCodeAt(A));for(v=E>0?E+1:0;v<c;){for(R=h,g=1,_=f;v>=c&&F("invalid-input"),x=_e(a.charCodeAt(v++)),(x>=f||x>S((d-h)/g))&&F("overflow"),h+=x*g,O=_<=p?w:_>=p+I?I:_-p,!(x<O);_+=f)M=f-O,g>S(d/M)&&F("overflow"),g*=M;l=o.length+1,p=re(h-R,l,R==0),S(h/l)>d-y&&F("overflow"),y+=S(h/l),h%=l,o.splice(h++,0,y)}return te(o)}function se(a){var o,c,l,h,y,p,E,A,v,R,g,_=[],x,O,M,Z;for(a=ee(a),x=a.length,o=G,c=0,y=U,p=0;p<x;++p)g=a[p],g<128&&_.push($(g));for(l=h=_.length,h&&_.push(j);l<x;){for(E=d,p=0;p<x;++p)g=a[p],g>=o&&g<E&&(E=g);for(O=l+1,E-o>S((d-c)/O)&&F("overflow"),c+=(E-o)*O,o=E,p=0;p<x;++p)if(g=a[p],g<o&&++c>d&&F("overflow"),g==o){for(A=c,v=f;R=v<=y?w:v>=y+I?I:v-y,!(A<R);v+=f)Z=A-R,M=f-R,_.push($(ne(R+Z%M,0))),A=S(Z/M);_.push($(ne(A,0))),y=re(c,O,l==h),c=0,++l}++c,++o}return _.join("")}function Ae(a){return Q(a,function(o){return N.test(o)?ae(o.slice(4).toLowerCase()):o})}function xe(a){return Q(a,function(o){return B.test(o)?"xn--"+se(o):o})}if(u={version:"1.4.1",ucs2:{decode:ee,encode:te},decode:ae,encode:se,toASCII:xe,toUnicode:Ae},r&&s)if(e.exports==r)s.exports=u;else for(J in u)u.hasOwnProperty(J)&&(r[J]=u[J]);else n.punycode=u})(it)})(H,H.exports)),H.exports}ct();var me=(function(e){function t(){var r=this||self;return delete e.prototype.__magic__,r}if(typeof globalThis=="object")return globalThis;if(this)return t();e.defineProperty(e.prototype,"__magic__",{configurable:!0,get:t});var n=__magic__;return n})(Object),ut=me.URL;me.URLSearchParams;var dt={URL:ut};class ge extends Error{constructor(n,r,s){super(n);T(this,"status");T(this,"data");this.status=r,this.data=s}}const lt=3,ht=1e3,ft=[400,401,403,404,409,422],pt=(globalThis==null?void 0:globalThis.URL)??dt.URL;class Tt{constructor(t,n){T(this,"baseUrl");T(this,"retries");T(this,"retryDelay");T(this,"nonRetryableStatuses");T(this,"identity");T(this,"sleep",t=>new Promise(n=>{setTimeout(n,t)}));T(this,"getIdentity",()=>this.identity instanceof Function?this.identity():this.identity);T(this,"rawFetch",(t,n)=>{const r=new pt(t,this.baseUrl),s=(n==null?void 0:n.identity)??this.getIdentity();return Ne.signedFetchFactory()(r.toString(),{...n,identity:s})});T(this,"fetch",async(t,n)=>{for(let r=0;r<=this.retries;r++)try{let s,i;try{s=await this.rawFetch(t,n);const u=await s.text();u.length===0?i={ok:!0,data:null}:i=JSON.parse(u)}catch(u){throw new ge(u.message,void 0,null)}if(!s.ok||i.ok===!1){const u=i.message??i.error;throw new ge(u??`Request failed with status code ${s.status}`,s.status,i.data)}return i.ok===!0?i.data:i}catch(s){if(console.error(`[API] HTTP request failed: ${s.message||""}`,s),this.retries===r||s.status&&this.nonRetryableStatuses.includes(s.status))throw s;await this.sleep(this.retryDelay)}throw new Error("Unreachable code")});this.baseUrl=t,this.identity=n==null?void 0:n.identity,this.retries=(n==null?void 0:n.retries)??lt,this.retryDelay=(n==null?void 0:n.retryDelay)??ht,this.nonRetryableStatuses=(n==null?void 0:n.nonRetryableStatuses)??ft}}class gt extends Tt{constructor(n,r,s){super(r,s);T(this,"signer");T(this,"addTrade",async n=>this.fetch("/v1/trades",{method:"POST",body:JSON.stringify(n),metadata:{signer:this.signer,intent:"dcl:create-trade"},headers:{"Content-Type":"application/json"}}));T(this,"fetchTrade",async n=>this.fetch(`/v1/trades/${n}`,{method:"GET"}));this.signer=n}}class vt{constructor(t,n,r){T(this,"tradesAPI");this.tradesAPI=new gt(t,n,{identity:r,retries:0})}async addTrade(t){return this.tradesAPI.addTrade(t)}async fetchTrade(t){return this.tradesAPI.fetchTrade(t)}async accept(t,n){const r=ue(t.contract),s=de(r,t.chainId),i=fe(t,n);return pe(s,"accept",[i])}async cancel(t,n){const r=ue(t.contract),s=de(r,t.chainId),i=fe(t,n);return pe(s,"cancelSignature",[i])}}export{vt as TradeService};
|
|
1
|
+
var Ce=Object.defineProperty;var Ie=(e,t,n)=>t in e?Ce(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var T=(e,t,n)=>Ie(e,typeof t!="symbol"?t+"":t,n);import{W as we,b as oe,C as Se,B as ve,f as ie}from"./ethers-CLB2z3On.js";import{p as Re,d as X}from"./dcl-schemas-BICTSpB5.js";import{c as ce}from"./react-BrLDncxD.js";import{b6 as Ne}from"./index-Q9d0V8TZ.js";import{O as Oe,M as Pe,D as be,a as ue,g as de}from"./index-HN6Rk25C.js";import{c as K,e as De}from"./index-D7J0TuHz.js";import"./sentry-DYZXk5O5.js";import"./intl-CBcMB1D2.js";import"./events-DQ172AOg.js";const Le="2d0335ab",Ue="0c53c51c",Fe="d8ed1acc",Me=ye("0x");let ke=0;async function je(e){let t=[];try{t=await q(e,"eth_requestAccounts",[])}catch{t=await q(e,"eth_accounts",[])}if(t.length===0)throw new Error("Could not find a valid connected account");return t[0]}async function $e(e,t,n){return q(e,"eth_signTypedData_v4",[t,n])}function He(e,t,n){const r=t.replace("0x",""),s=r.substring(0,64),i=r.substring(64,128),u=Ge(r.substring(128,130)),d=n.replace("0x",""),f=(d.length/2).toString(16),w=Math.ceil(d.length/64);return["0x",Ue,m(e),m("a0"),s,i,m(u),m(f),d.padEnd(64*w,"0")].join("")}function qe(e,t,n){const r=n.replace("0x",""),s=t.replace("0x",""),u=96+32+r.length/2,d=Math.ceil(s.length/64);return["0x",Fe,m(e),m("60"),m(u.toString(16)),m((r.length/2).toString(16)),r,m((s.length/2).toString(16)),s.padEnd(64*d,"0")].join("")}function Ge(e){let t=parseInt(e,16);if(t<27&&(t+=27),t!==27&&t!==28)throw Error(`Invalid signature version "${e}" (parsed: ${t})`);return t.toString(16)}async function Be(e,t,n){const r=m(t),s=await q(e,"eth_call",[{data:`0x${Le}${r}`,to:n},"latest"]);return m(s)}function Ve(e){return typeof e=="number"?`0x${m(e.toString(16))}`:`0x${m(e)}`}function Je(e,t){return q(e,"eth_getCode",[t.toLowerCase(),"latest"])}const We="0xef01";async function Ye(e,t){const n=await Je(e,t);return n.toLowerCase().startsWith(We)?!1:!Ze(n)}function ye(e){if(!/^0x[0-9a-f]*$/gi.test(e))throw new Error(`Not a valid hex string "${e}"`);let t=e.slice(2);for(;t.length<40;)t="0"+t;return"0x"+t}function Ze(e){return ye(e.toLowerCase())===Me}function m(e){return e.toString().replace("0x","").padStart(64,"0")}async function q(e,t,n){let r,s={jsonrpc:"2.0",id:++ke,method:t,params:n};if(e.request!==void 0?r=await e.request(s):e.sendAsync!==void 0?r=await e.sendAsync(s):e.send!==void 0&&(r=await e.send(t,n)),r)return r.result||r;throw new Error(`Could not send the transaction correcty. Either the provider does not support the method "${t}" or is missing a proper send/request.`)}function Xe(){return{serverURL:"https://transactions-api.decentraland.io/v1"}}var k;(function(e){e.UNKNOWN="unknown",e.DAPP_LIMIT_REACHED="dapp_limit_reached",e.USER_LIMIT_REACHED="user_limit_reached",e.API_LIMIT_REACHED="api_limit_reached",e.GAS_LIMIT_REACHED="gas_limit_reached",e.EXPECTATION_FAILED="expectation_failed",e.INVALID_TRANSACTION="invalid_transaction",e.INVALID_SCHEMA="invalid_schema",e.INVALID_CONTRACT_ADDRESS="invalid_contract_address",e.INVALID_ADDRESS="invalid_address",e.SALE_PRICE_TOO_LOW="sale_price_too_low",e.QUOTA_REACHED="quota_reached",e.CONTRACT_ACCOUNT="contract_account",e.HIGH_CONGESTION="high_congestion",e.USER_DENIED="user_denied"})(k||(k={}));class P extends Error{constructor(n,r){super(n);T(this,"code");this.code=r,Object.setPrototypeOf(this,P.prototype)}}async function Ke(e,t,n,r,s={}){const i={...Xe(),...s};if(!r.address.trim())throw new P(`The contract address for ${r.name} is empty. You're probably trying to get a proxy contract. Try adding an address to the result of getContract`,k.INVALID_ADDRESS);try{const u=await je(e);if(await Ye(e,u))throw new P("Contract accounts are not supported",k.CONTRACT_ACCOUNT);const d=r.abi.some(B=>{var V;return B.name==="executeMetaTransaction"&&((V=B.inputs)==null?void 0:V.some(W=>W.name==="_functionData"))}),f=await Be(t,u,r.address),w=Ve(r.chainId),I=Qe(w,r),D=ze(u,f,n,I,d),L=await $e(e,u,JSON.stringify(D)),G=(d?qe:He)(u,L,n),j=await fetch(`${i.serverURL}/transactions`,{headers:{"Content-Type":"application/json"},body:JSON.stringify({transactionData:{from:u,params:[r.address,G]}}),method:"POST"}),N=await j.json();if(N.ok===!1)throw N.message&&N.code?new P(N.message,N.code):new Error(`HTTP Error. Status: ${j.status}.`);return N.txHash}catch(u){const d=u;throw d instanceof P?d:d.message.indexOf("User denied message signature")!==-1?new P(d.message,k.USER_DENIED):(console.warn("An error occurred trying to send the meta transaction. Error:",d.message),new P(d.message,k.UNKNOWN))}}function ze(e,t,n,r,s=!1){return{types:{EIP712Domain:be,MetaTransaction:s?Oe:Pe},domain:r,primaryType:"MetaTransaction",message:{nonce:parseInt(t,16),from:e,...s?{functionData:n}:{functionSignature:n}}}}function Qe(e,t){return{name:t.name,version:t.version,verifyingContract:t.address,salt:e}}async function et(e){const t=await Ee();if(t){const n=await new we(t).getSigner().getChainId();if(e===n)return t}return K.createProvider(Re.ProviderType.NETWORK,e)}async function Ee(){try{return await K.getProvider()}catch{try{const{provider:e}=await K.tryPreviousConnection();return e}catch{return null}}}function le(e){return Math.floor(e/1e3)}function he(e){switch(e.assetType){case X.TradeAssetType.ERC721:return e.tokenId;case X.TradeAssetType.COLLECTION_ITEM:return e.itemId;case X.TradeAssetType.ERC20:return e.amount;default:return console.error("Invalid asset type:",e),""}}function tt(e){var t;return{checks:{uses:e.checks.uses,expiration:le(e.checks.expiration),effective:le(e.checks.effective),salt:oe(e.checks.salt,32),contractSignatureIndex:e.checks.contractSignatureIndex,signerSignatureIndex:e.checks.signerSignatureIndex,allowedRoot:oe(e.checks.allowedRoot,32),externalChecks:(t=e.checks.externalChecks)==null?void 0:t.map(n=>({contractAddress:n.contractAddress,selector:n.selector,value:n.value?n.value:"0x",required:n.required}))},sent:e.sent.map(n=>({assetType:n.assetType,contractAddress:n.contractAddress,value:he(n),extra:n.extra?n.extra:"0x"})),received:e.received.map(n=>({assetType:n.assetType,contractAddress:n.contractAddress,value:he(n),extra:n.extra?n.extra:"0x",beneficiary:n.beneficiary}))}}function fe(e,t){const n=tt(e);return{signer:e.signer,signature:e.signature,...n,checks:{...n.checks,allowedProof:[]},sent:n.sent.map(r=>({...r,beneficiary:t}))}}async function nt(e){const t=await e.request({method:"eth_chainId",params:[]});let n;return typeof t=="string"?n=parseInt(t,16):n=t,n}async function rt(e){const t=await et(e);return new we(t)}const b=new De.EventEmitter;var C;(function(e){e.ERROR="error",e.SUCCESS="success",e.PROMPT="prompt",e.ACCEPT="accept",e.REJECT="reject"})(C||(C={}));let at="https://transactions-api.decentraland.org/v1";const st=()=>at,ot=()=>new Promise((e,t)=>{const n=()=>{b.removeAllListeners(C.REJECT),e(!0)},r=()=>{b.removeAllListeners(C.ACCEPT),t(new Error("User rejected transaction"))};b.addListener(C.ACCEPT,n),b.addListener(C.REJECT,r)});async function pe(...e){const[t,n,...r]=e;try{const s=await Ee();if(!s)throw new Error("Provider not connected");const i=await nt(s),u=await rt(t.chainId),d=new Se(t.address,t.abi,u),f=await(typeof n=="function"?n(d.populateTransaction):d.populateTransaction[n](...r));if(i===t.chainId){const w=u.getSigner();if(s.isMagic||s.isThirdweb){let D=ve.from(0);try{const L=await w.getGasPrice(),U=await w.estimateGas(f);D=L.mul(U)}catch{}if(!D.isZero()){const L=ot(),U=await w.getBalance();b.emit(C.PROMPT,{transactionGasPrice:ie(D),userBalance:ie(U),chainId:t.chainId}),await L}}const I=await w.sendTransaction(f);return b.emit(C.SUCCESS,{txHash:I.hash}),I.hash}else{const w=await Ke(s,u,f.data,t,{serverURL:st()});return b.emit(C.SUCCESS,{txHash:w}),w}}catch(s){const i={type:C.ERROR,error:s};throw b.emit(C.ERROR,i),s}}var H={exports:{}};/*! https://mths.be/punycode v1.4.1 by @mathias */var it=H.exports,Te;function ct(){return Te||(Te=1,(function(e,t){(function(n){var r=t&&!t.nodeType&&t,s=e&&!e.nodeType&&e,i=typeof ce=="object"&&ce;(i.global===i||i.window===i||i.self===i)&&(n=i);var u,d=2147483647,f=36,w=1,I=26,D=38,L=700,U=72,G=128,j="-",N=/^xn--/,B=/[^\x20-\x7E]/,V=/[\x2E\u3002\uFF0E\uFF61]/g,W={overflow:"Overflow: input needs wider integers to process","not-basic":"Illegal input >= 0x80 (not a basic code point)","invalid-input":"Invalid input"},Y=f-w,S=Math.floor,$=String.fromCharCode,J;function F(a){throw new RangeError(W[a])}function z(a,o){for(var c=a.length,l=[];c--;)l[c]=o(a[c]);return l}function Q(a,o){var c=a.split("@"),l="";c.length>1&&(l=c[0]+"@",a=c[1]),a=a.replace(V,".");var h=a.split("."),y=z(h,o).join(".");return l+y}function ee(a){for(var o=[],c=0,l=a.length,h,y;c<l;)h=a.charCodeAt(c++),h>=55296&&h<=56319&&c<l?(y=a.charCodeAt(c++),(y&64512)==56320?o.push(((h&1023)<<10)+(y&1023)+65536):(o.push(h),c--)):o.push(h);return o}function te(a){return z(a,function(o){var c="";return o>65535&&(o-=65536,c+=$(o>>>10&1023|55296),o=56320|o&1023),c+=$(o),c}).join("")}function _e(a){return a-48<10?a-22:a-65<26?a-65:a-97<26?a-97:f}function ne(a,o){return a+22+75*(a<26)-((o!=0)<<5)}function re(a,o,c){var l=0;for(a=c?S(a/L):a>>1,a+=S(a/o);a>Y*I>>1;l+=f)a=S(a/Y);return S(l+(Y+1)*a/(a+D))}function ae(a){var o=[],c=a.length,l,h=0,y=G,p=U,E,A,v,R,g,_,x,O,M;for(E=a.lastIndexOf(j),E<0&&(E=0),A=0;A<E;++A)a.charCodeAt(A)>=128&&F("not-basic"),o.push(a.charCodeAt(A));for(v=E>0?E+1:0;v<c;){for(R=h,g=1,_=f;v>=c&&F("invalid-input"),x=_e(a.charCodeAt(v++)),(x>=f||x>S((d-h)/g))&&F("overflow"),h+=x*g,O=_<=p?w:_>=p+I?I:_-p,!(x<O);_+=f)M=f-O,g>S(d/M)&&F("overflow"),g*=M;l=o.length+1,p=re(h-R,l,R==0),S(h/l)>d-y&&F("overflow"),y+=S(h/l),h%=l,o.splice(h++,0,y)}return te(o)}function se(a){var o,c,l,h,y,p,E,A,v,R,g,_=[],x,O,M,Z;for(a=ee(a),x=a.length,o=G,c=0,y=U,p=0;p<x;++p)g=a[p],g<128&&_.push($(g));for(l=h=_.length,h&&_.push(j);l<x;){for(E=d,p=0;p<x;++p)g=a[p],g>=o&&g<E&&(E=g);for(O=l+1,E-o>S((d-c)/O)&&F("overflow"),c+=(E-o)*O,o=E,p=0;p<x;++p)if(g=a[p],g<o&&++c>d&&F("overflow"),g==o){for(A=c,v=f;R=v<=y?w:v>=y+I?I:v-y,!(A<R);v+=f)Z=A-R,M=f-R,_.push($(ne(R+Z%M,0))),A=S(Z/M);_.push($(ne(A,0))),y=re(c,O,l==h),c=0,++l}++c,++o}return _.join("")}function Ae(a){return Q(a,function(o){return N.test(o)?ae(o.slice(4).toLowerCase()):o})}function xe(a){return Q(a,function(o){return B.test(o)?"xn--"+se(o):o})}if(u={version:"1.4.1",ucs2:{decode:ee,encode:te},decode:ae,encode:se,toASCII:xe,toUnicode:Ae},r&&s)if(e.exports==r)s.exports=u;else for(J in u)u.hasOwnProperty(J)&&(r[J]=u[J]);else n.punycode=u})(it)})(H,H.exports)),H.exports}ct();var me=(function(e){function t(){var r=this||self;return delete e.prototype.__magic__,r}if(typeof globalThis=="object")return globalThis;if(this)return t();e.defineProperty(e.prototype,"__magic__",{configurable:!0,get:t});var n=__magic__;return n})(Object),ut=me.URL;me.URLSearchParams;var dt={URL:ut};class ge extends Error{constructor(n,r,s){super(n);T(this,"status");T(this,"data");this.status=r,this.data=s}}const lt=3,ht=1e3,ft=[400,401,403,404,409,422],pt=(globalThis==null?void 0:globalThis.URL)??dt.URL;class Tt{constructor(t,n){T(this,"baseUrl");T(this,"retries");T(this,"retryDelay");T(this,"nonRetryableStatuses");T(this,"identity");T(this,"sleep",t=>new Promise(n=>{setTimeout(n,t)}));T(this,"getIdentity",()=>this.identity instanceof Function?this.identity():this.identity);T(this,"rawFetch",(t,n)=>{const r=new pt(t,this.baseUrl),s=(n==null?void 0:n.identity)??this.getIdentity();return Ne.signedFetchFactory()(r.toString(),{...n,identity:s})});T(this,"fetch",async(t,n)=>{for(let r=0;r<=this.retries;r++)try{let s,i;try{s=await this.rawFetch(t,n);const u=await s.text();u.length===0?i={ok:!0,data:null}:i=JSON.parse(u)}catch(u){throw new ge(u.message,void 0,null)}if(!s.ok||i.ok===!1){const u=i.message??i.error;throw new ge(u??`Request failed with status code ${s.status}`,s.status,i.data)}return i.ok===!0?i.data:i}catch(s){if(console.error(`[API] HTTP request failed: ${s.message||""}`,s),this.retries===r||s.status&&this.nonRetryableStatuses.includes(s.status))throw s;await this.sleep(this.retryDelay)}throw new Error("Unreachable code")});this.baseUrl=t,this.identity=n==null?void 0:n.identity,this.retries=(n==null?void 0:n.retries)??lt,this.retryDelay=(n==null?void 0:n.retryDelay)??ht,this.nonRetryableStatuses=(n==null?void 0:n.nonRetryableStatuses)??ft}}class gt extends Tt{constructor(n,r,s){super(r,s);T(this,"signer");T(this,"addTrade",async n=>this.fetch("/v1/trades",{method:"POST",body:JSON.stringify(n),metadata:{signer:this.signer,intent:"dcl:create-trade"},headers:{"Content-Type":"application/json"}}));T(this,"fetchTrade",async n=>this.fetch(`/v1/trades/${n}`,{method:"GET"}));this.signer=n}}class vt{constructor(t,n,r){T(this,"tradesAPI");this.tradesAPI=new gt(t,n,{identity:r,retries:0})}async addTrade(t){return this.tradesAPI.addTrade(t)}async fetchTrade(t){return this.tradesAPI.fetchTrade(t)}async accept(t,n){const r=ue(t.contract),s=de(r,t.chainId),i=fe(t,n);return pe(s,"accept",[i])}async cancel(t,n){const r=ue(t.contract),s=de(r,t.chainId),i=fe(t,n);return pe(s,"cancelSignature",[i])}}export{vt as TradeService};
|