@dcl/shop 1.0.2-31061952187.commit-8d8b09e → 1.0.2-31075138109.commit-b4b8f60

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.
Files changed (190) hide show
  1. package/_assets/{Activity-D_fQdZon.js → Activity-CNizYJay.js} +29 -29
  2. package/_assets/{AnimatedBackground-C9W4RBcZ.js → AnimatedBackground-C1p4psE2.js} +2 -2
  3. package/_assets/Assets-BcQ10xPp.js +892 -0
  4. package/_assets/{Assets.styles-BBWJCcMx.js → Assets.styles-B9PWoIMZ.js} +80 -72
  5. package/_assets/{Authorizations-DVwQ95Ww.js → Authorizations-C_xGdM-p.js} +1 -1
  6. package/_assets/Cart-DYZGi78I.js +706 -0
  7. package/_assets/{CircularProgress-D09608yv.js → CircularProgress-B_hinbN9.js} +1 -1
  8. package/_assets/{Collection-DllncUVv.js → Collection-DTJYViBJ.js} +11 -11
  9. package/_assets/{CollectionCarousel-B9HmGuVb.js → CollectionCarousel-DZxVlfxf.js} +182 -126
  10. package/_assets/{Confetti-Dl6FT7nL.js → Confetti-mgEJ457s.js} +1 -1
  11. package/_assets/Creator-BVn3jG76.js +307 -0
  12. package/_assets/{ErrorNotice-OUNK486K.js → ErrorNotice-CCUuPON0.js} +1 -1
  13. package/_assets/{ExchangeController-Cp3qbfAM.js → ExchangeController-CXuE8lHA.js} +1 -1
  14. package/_assets/{Faq-DXtTtsuA.js → Faq-Bkcjo8OM.js} +1 -1
  15. package/_assets/{GetCredits-BhRNCaTG.js → GetCredits-Bq6LvsYg.js} +19 -12
  16. package/_assets/{Grow-DXdR0gI9.js → Grow-DBDllnzs.js} +1 -1
  17. package/_assets/{HelpersUtil-rQp5uDAx.js → HelpersUtil-CTTzLGBA.js} +1 -1
  18. package/_assets/ItemDetail-CBafDPtx.js +3552 -0
  19. package/_assets/JumpInIcon-CfzbSVBF.js +1 -0
  20. package/_assets/LazyEmoteControls-PQ3Pg2sc.js +2 -0
  21. package/_assets/{LoadMore-jSNRJiwZ.js → LoadMore-DY0yTnWX.js} +1 -1
  22. package/_assets/{ManaPricingBanner.styles-vDUAKLLe.js → ManaPricingBanner.styles-CLzKIrR0.js} +2 -2
  23. package/_assets/MyAssets-BuEVkMOy.js +396 -0
  24. package/_assets/{MyFavorites-BLrz2vwY.js → MyFavorites-5YJaSyop.js} +20 -17
  25. package/_assets/{NotFound-DP4nosOd.js → NotFound-1ks_XjFT.js} +1 -1
  26. package/_assets/{NotificationsBell-ARziPv8W.js → NotificationsBell-CPTnotbb.js} +1 -1
  27. package/_assets/{OutfitDetail-CLmuEgB3.js → OutfitDetail-N4whvhsJ.js} +12 -9
  28. package/_assets/{OutfitPreview-PWdXvCaE.js → OutfitPreview-D7BVurmj.js} +1 -1
  29. package/_assets/{OutfitStudio-Cx3Xm6ff.js → OutfitStudio-WKWXKKDM.js} +46 -46
  30. package/_assets/{StoreSettings-BQtEgWRm.js → StoreSettings-CDOaTUdX.js} +4 -4
  31. package/_assets/Success-CAR1N5YA.js +353 -0
  32. package/_assets/{SwapController-Bf58lQ6b.js → SwapController-DFi1XX34.js} +1 -1
  33. package/_assets/{Tooltip-BDmKiALz.js → Tooltip-Cwe0Yraw.js} +1 -1
  34. package/_assets/{TradeService-Yecm1OxI.js → TradeService-BaPRI5UX.js} +1 -1
  35. package/_assets/{W3MFrameProviderSingleton-BQyeyr-U.js → W3MFrameProviderSingleton-ZccF4Y9V.js} +3 -3
  36. package/_assets/{WebCryptoP256-Ou_F2OJp.js → WebCryptoP256-Jedmnano.js} +1 -1
  37. package/_assets/{authorizations-B3AvOvOm.js → authorizations-CAdQPCMI.js} +1 -1
  38. package/_assets/{basic-DTDRwam-.js → basic-D7xW8zKi.js} +1 -1
  39. package/_assets/{biconomy-DaLi1O64.js → biconomy-DSBuvNuK.js} +1 -1
  40. package/_assets/{builder-DxumJmKw.js → builder-0yNVIzVD.js} +1 -1
  41. package/_assets/{buy-gasless-BfTEWjT9.js → buy-gasless-BqufOfFB.js} +1 -1
  42. package/_assets/{buy-BHkfYJLe.js → buy-p0P2Zs7_.js} +1 -1
  43. package/_assets/{categories-D23W_J-A.js → categories-Q8-sA-ag.js} +73 -58
  44. package/_assets/{ccip-DGVhZCZ4.js → ccip-DARfTvaF.js} +1 -1
  45. package/_assets/{ccip-qhHiv1gU.js → ccip-DsdggBKA.js} +1 -1
  46. package/_assets/collectionPage.styles-DQbgY52P.js +32 -0
  47. package/_assets/{controller-DGtmLk4f.js → controller-Zsb3xV7z.js} +2 -2
  48. package/_assets/{core-BAqS3vu7.js → core-CkqGyNBY.js} +4 -4
  49. package/_assets/{createSvgIcon-Bm9nxGqG.js → createSvgIcon-CZWQfAYI.js} +2 -2
  50. package/_assets/{custom-MaGTnz7S.js → custom-Bxjd11Bv.js} +1 -1
  51. package/_assets/{data-capture-5Vi1cyBa.js → data-capture-C_h8eQxX.js} +1 -1
  52. package/_assets/{email-BG6hRXMo.js → email-CoonlLSw.js} +1 -1
  53. package/_assets/{embedded-wallet-CfnknCH8.js → embedded-wallet-CZSkNi4z.js} +1 -1
  54. package/_assets/{emotion-styled.browser.esm-CoxAZUrJ.js → emotion-styled.browser.esm-BbXohUUc.js} +1 -1
  55. package/_assets/{engine-nQGCV50K.js → engine-C7WUjAl2.js} +1 -1
  56. package/_assets/{errors-DZ_QWsza.js → errors-BUHoc-y5.js} +1 -1
  57. package/_assets/{estimate-l1-fee-CVpJ9ym5.js → estimate-l1-fee-UKT25sin.js} +1 -1
  58. package/_assets/{execute-DFvUDrLY.js → execute-CPTN8FKu.js} +2 -2
  59. package/_assets/{features-BXUedULM.js → features-D6748kEh.js} +1 -1
  60. package/_assets/{fetchTokenMetadata-CkQcnzmO.js → fetchTokenMetadata-CPl8yMoH.js} +2 -2
  61. package/_assets/{field.styles-PE4ZasC2.js → field.styles-dfnZT-br.js} +1 -1
  62. package/_assets/{get-ecosystem-wallet-info-CRLH8I6C.js → get-ecosystem-wallet-info-CUrAtQ3b.js} +1 -1
  63. package/_assets/{getBalance-CiV48JsZ.js → getBalance-CUN1GDsO.js} +1 -1
  64. package/_assets/{getNFT-CV3N9TTA.js → getNFT-BDJqqYqb.js} +1 -1
  65. package/_assets/{getNFT-C3ucNb89.js → getNFT-DFlqYNlO.js} +1 -1
  66. package/_assets/{grid.styles-hOZTJ80g.js → grid.styles-DODm717m.js} +1 -1
  67. package/_assets/{hashTypedData-gTABcRB5.js → hashTypedData-D3XiRshp.js} +1 -1
  68. package/_assets/{hashTypedData-BtF2J233.js → hashTypedData-bAoo1co0.js} +1 -1
  69. package/_assets/identity-icon-C8yAW_Gq.svg +8 -0
  70. package/_assets/{in-app-CSDr4Blb.js → in-app-Dx0lK6d1.js} +1 -1
  71. package/_assets/{in-app-wallet-calls-Crivl9zc.js → in-app-wallet-calls-H4N-BNbO.js} +1 -1
  72. package/_assets/{index-KWEbYeSY.js → index--4i0Lw-m.js} +1 -1
  73. package/_assets/{index-Cf-gi-Qq.js → index-1YcJ_AMk.js} +1 -1
  74. package/_assets/{index-CS27am7J.js → index-4jPZivXl.js} +1 -1
  75. package/_assets/{index-DgOiZShm.js → index-5tC1hlhU.js} +1 -1
  76. package/_assets/{index-HAEoS9R6.js → index-AaJs3SZg.js} +1 -1
  77. package/_assets/{index-BTDIKmoC.js → index-B8xkUObo.js} +1 -1
  78. package/_assets/{index-Bg_gOSx_.js → index-BBYOztfl.js} +1 -1
  79. package/_assets/{index-CGBg3yUz.js → index-BGKTqnNJ.js} +5 -5
  80. package/_assets/{index-Bs4LvV4K.js → index-BPiB7yPn.js} +2 -2
  81. package/_assets/{index-EKmmXx1j.js → index-BTVtZV-4.js} +1 -1
  82. package/_assets/{index-BBbwMaBz.js → index-BY8CUKv-.js} +1 -1
  83. package/_assets/{index-DKHMu0o3.js → index-BhTQhn8o.js} +1 -1
  84. package/_assets/{index-D7LYoLo4.js → index-BiAWEM1Y.js} +1 -1
  85. package/_assets/{index-DXRL-4ld.js → index-BpsSIJDP.js} +1 -1
  86. package/_assets/{index-CHf7lsmp.js → index-BzIFn1gg.js} +1 -1
  87. package/_assets/{index-DLFQdlEW.js → index-C-Qu30M3.js} +1 -1
  88. package/_assets/{index-C5Evg5sh.js → index-C1TeecjZ.js} +1 -1
  89. package/_assets/{index-hKv-BpxY.js → index-C3oB2anL.js} +1 -1
  90. package/_assets/{index-DnJJn52L.js → index-CA_IOkJ5.js} +1 -1
  91. package/_assets/{index-C7hpB9s1.js → index-CEwRybny.js} +3 -3
  92. package/_assets/{index-DoGz07sk.js → index-CKW9ikJj.js} +1 -1
  93. package/_assets/{index-qGMuaBIs.js → index-CLKXx6rf.js} +1 -1
  94. package/_assets/{index-D5eMvKb_.js → index-CPsldIhs.js} +1 -1
  95. package/_assets/{index-CHolIX6U.js → index-CcYSrQZB.js} +1 -1
  96. package/_assets/{index-DwX-9Zo4.js → index-Ci8wltbz.js} +1 -1
  97. package/_assets/{index-D769FdFr.js → index-CkTj0rBr.js} +1 -1
  98. package/_assets/{index-CmY0V0eX.js → index-Cwuc6_4X.js} +1 -1
  99. package/_assets/{index-BNBzDf6z.js → index-CzAnnYNM.js} +1 -1
  100. package/_assets/{index-Dp2641E3.js → index-D0g-gu9R.js} +1 -1
  101. package/_assets/{index-wRmEiTlP.js → index-D2Uzczc0.js} +2 -2
  102. package/_assets/{index-ClUPCoEW.js → index-DAnmGKDS.js} +1 -1
  103. package/_assets/{index-BYP7oMPZ.css → index-DB6GvbxL.css} +1 -1
  104. package/_assets/{index-CvwosU6Y.js → index-DFQi7e3d.js} +1 -1
  105. package/_assets/{index-UyXkCiLs.js → index-DGCl01Aq.js} +1 -1
  106. package/_assets/{index-C23D_vyT.js → index-DLa23Ln5.js} +1 -1
  107. package/_assets/{index-ItjVcw1b.js → index-DPvEn0Us.js} +1 -1
  108. package/_assets/{index-CkGO7qOd.js → index-DQTv184M.js} +1 -1
  109. package/_assets/{index-DSuiX4WG.js → index-DWpfZF5x.js} +1 -1
  110. package/_assets/{index-DKdQUEzy.js → index-Di8inWXw.js} +1 -1
  111. package/_assets/{index-S0X-BG2b.js → index-DidVPhMo.js} +1 -1
  112. package/_assets/{index-9_4ZEs3N.js → index-DmMEC2q9.js} +1 -1
  113. package/_assets/{index-DjTNPtj2.js → index-Ds0rafrR.js} +1 -1
  114. package/_assets/{index-CyRHowbs.js → index-DvCZhQ4M.js} +1 -1
  115. package/_assets/{index-DY1xBku2.js → index-DzcxBj5H.js} +1 -1
  116. package/_assets/{index-CwRTjZPC.js → index-FSR-tXEG.js} +3 -3
  117. package/_assets/{index-CKUuopSw.js → index-H0_FOTS1.js} +526 -451
  118. package/_assets/{index-1oceTWwb.js → index-IiqyrxDp.js} +3 -3
  119. package/_assets/{index-Dh85kccn.js → index-P6CBRm57.js} +1 -1
  120. package/_assets/{index-C0pcaEQl.js → index-bQcvt8Yc.js} +1 -1
  121. package/_assets/{index-DkV5TYom.js → index-eG9hxr4C.js} +1 -1
  122. package/_assets/{index-9x1mGBeU.js → index-gFP2sFjS.js} +1 -1
  123. package/_assets/{index-BniGBCAO.js → index-h6pTnuHR.js} +1 -1
  124. package/_assets/{index-DdmULNRk.js → index-xIqXdiX9.js} +2 -2
  125. package/_assets/{index.es-g_bB-nFv.js → index.es-Bezpyz9G.js} +1 -1
  126. package/_assets/{index.es-wpL2Ycto.js → index.es-C5RZM_Pw.js} +4 -4
  127. package/_assets/{index.es-DnMGDxtr.js → index.es-CfiB2nB-.js} +1 -1
  128. package/_assets/invite-icon-Bz6lCTuB.svg +11 -0
  129. package/_assets/{localBatchGatewayRequest-DtELSHiE.js → localBatchGatewayRequest-BEJ4F0kB.js} +1 -1
  130. package/_assets/{networks-ZmRqsvV6.js → networks-sj6IF-js.js} +1 -1
  131. package/_assets/{onramp-Bffl3qa3.js → onramp-BubqiUY-.js} +1 -1
  132. package/_assets/{openzeppelin-BmH-LNci.js → openzeppelin-Chy7gkut.js} +1 -1
  133. package/_assets/{parseNft-PSjb4qKi.js → parseNft-kgJMEL-I.js} +2 -2
  134. package/_assets/{parseSignature-D947kFfv.js → parseSignature-49G14sv1.js} +3 -3
  135. package/_assets/{parseSignature-IigTmAp7.js → parseSignature-CJ8NsFbD.js} +1 -1
  136. package/_assets/{passkeys-BsJVcpuM.js → passkeys-BvVbeMXS.js} +1 -1
  137. package/_assets/{pay-with-exchange-CU_HZd9F.js → pay-with-exchange-Cc0055L1.js} +1 -1
  138. package/_assets/{qr-overlay-EMShc5uE.js → qr-overlay-D10vlv1f.js} +1 -1
  139. package/_assets/{receive-CO6WElZa.js → receive-Cuwu3mHS.js} +1 -1
  140. package/_assets/{resolveImplementation-CUngPhAv.js → resolveImplementation-Dfj0L4Ai.js} +1 -1
  141. package/_assets/{rpc-BqH_VMy9.js → rpc-CnHNtgxw.js} +1 -1
  142. package/_assets/{secp256k1-CTsmRKJj.js → secp256k1-B3l9Rkyd.js} +1 -1
  143. package/_assets/{secp256k1-DneM3aYG.js → secp256k1-CR-cgYPx.js} +1 -1
  144. package/_assets/{secp256k1-D7kpLshE.js → secp256k1-Cc9GlXlU.js} +1 -1
  145. package/_assets/{send-DnwW2LgN.js → send-CsVYUzzr.js} +1 -1
  146. package/_assets/{send-batch-transaction-BgJnfEM8.js → send-batch-transaction-B6mk0_i_.js} +1 -1
  147. package/_assets/{send-eip712-transaction-Cw3ykz5y.js → send-eip712-transaction-BfUkLu-i.js} +2 -2
  148. package/_assets/{send-gasless-transaction-BjGhnCwR.js → send-gasless-transaction-BlLmbQ26.js} +2 -2
  149. package/_assets/{send-transaction-COKVeGfk.js → send-transaction-D0wENyPk.js} +2 -2
  150. package/_assets/{sendMetaTransaction-Bp3kwdLJ.js → sendMetaTransaction-CnhA6a-k.js} +1 -1
  151. package/_assets/{sendRawTransaction-eVli2oE3.js → sendRawTransaction-BsyxcfGv.js} +3 -3
  152. package/_assets/{serializeTransaction-CIM9i_-w.js → serializeTransaction-DVId8Rs6.js} +1 -1
  153. package/_assets/{session-proposal-KGl_Ah2b.js → session-proposal-DUVy-dyq.js} +1 -1
  154. package/_assets/{session-request-VAEXTksW.js → session-request-DSQfWHt6.js} +2 -2
  155. package/_assets/{signing-Cgx49_1X.js → signing-Bd6C4KXQ.js} +3 -3
  156. package/_assets/{skeleton.styles-BXNXDWEi.js → skeleton.styles-sGub2C43.js} +1 -1
  157. package/_assets/{socials-oKAOeF-k.js → socials-Bx-bKnd9.js} +1 -1
  158. package/_assets/{styled-pD_2hanx.js → styled-B8vpPdOK.js} +1 -1
  159. package/_assets/{swaps-BcAY_D99.js → swaps-BwNRCNkw.js} +1 -1
  160. package/_assets/{thirdweb-ChAqWFCO.js → thirdweb-bDUpez-k.js} +3 -3
  161. package/_assets/{to-serializable-transaction-D9qGbcrS.js → to-serializable-transaction-CrmYGVf0.js} +2 -2
  162. package/_assets/{transactionReceipt-BMw52z-f.js → transactionReceipt-Dwol6pvh.js} +1 -1
  163. package/_assets/{transactions-CeENvGIt.js → transactions-CJMbROug.js} +1 -1
  164. package/_assets/{useCreditPacks-BcavayJ3.js → useCreditPacks-D_gG97Vg.js} +1 -1
  165. package/_assets/{useImportable-CqnIvzif.js → useImportable-G1z46qnF.js} +1 -1
  166. package/_assets/{useInfiniteGrid-BjEQAabI.js → useInfiniteGrid-BHHEAbZ5.js} +1 -1
  167. package/_assets/{useTheme-BnnteKI4.js → useTheme-BxVqPd4e.js} +1 -1
  168. package/_assets/{verifyHash-CuRmy06R.js → verifyHash-BtpuSxEE.js} +1 -1
  169. package/_assets/{w3m-modal-CkBFH4cA.js → w3m-modal-BJMDIvH7.js} +1 -1
  170. package/_assets/{w3m-modal-BvOCJx7k.js → w3m-modal-Co4ZJh9U.js} +1 -1
  171. package/_assets/{wait-for-tx-receipt-B2KaPYJT.js → wait-for-tx-receipt-CKXB2fpc.js} +1 -1
  172. package/_assets/{wallets-CpXU08d2.js → wallets-BNoMqUPP.js} +5 -5
  173. package/_assets/{web-connector-BHRkWbB9.js → web-connector-DxsgtKod.js} +3 -3
  174. package/_assets/world-icon-6xQ-PmmW.svg +7 -0
  175. package/_assets/{writeContract-DNDGvg0r.js → writeContract-PCmQXj1B.js} +1 -1
  176. package/_assets/{zoraTestnet-CCn01jlp.js → zoraTestnet-sfJI3-xK.js} +1 -1
  177. package/index.html +11 -11
  178. package/package.json +2 -2
  179. package/_assets/Assets-CvZql_4R.js +0 -866
  180. package/_assets/Cart-CBLHJRVj.js +0 -706
  181. package/_assets/Creator-BreBnKPX.js +0 -305
  182. package/_assets/ItemDetail-clRbfaLQ.js +0 -3551
  183. package/_assets/LazyEmoteControls-B7UYn8xk.js +0 -2
  184. package/_assets/MyAssets-CsWhc-qa.js +0 -381
  185. package/_assets/Success-BWfI3_Mu.js +0 -280
  186. package/_assets/collectionPage.styles-CoEdrsfq.js +0 -49
  187. package/_assets/governance-DnazlIjy.webp +0 -0
  188. package/_assets/identity-B4DXDuJP.webp +0 -0
  189. package/_assets/invite-BfwIhP2C.webp +0 -0
  190. package/_assets/world-B-9aPlxu.webp +0 -0
@@ -0,0 +1,353 @@
1
+ import{a as P,b as M,j as e,N as W,r as A}from"./react-BYHuwl8r.js";import{t as J,s as t,z as N,J as O,K as _,o as q,x as H,b as n,y as U,C as X,L as D,M as G,c as E,B as K,N as Q}from"./index-H0_FOTS1.js";import{C as Y}from"./Confetti-mgEJ457s.js";import{J as V}from"./JumpInIcon-CfzbSVBF.js";import{w as Z,S as ee}from"./buy-gasless-BqufOfFB.js";import"./dcl-schemas-CmtP3U6y.js";import"./sentry-Dx-KuLV3.js";import"./ethers-BDpbhgX6.js";import"./intl-CBcMB1D2.js";import"./authorizations-CAdQPCMI.js";import"./sendMetaTransaction-CnhA6a-k.js";import"./buy-p0P2Zs7_.js";const{colors:i,radius:b}=J,c="@media (max-width: 600px)",S=t.div`
2
+ /* Its own stacking context, above the confetti layer (z-index 0). Needed because z-index is inert without
3
+ a position, so the content would otherwise sit below the burst regardless of order. */
4
+ position: relative;
5
+ z-index: 1;
6
+ max-width: 895px;
7
+ width: 100%;
8
+ margin: 0 auto;
9
+ /* Grows into the page shell's leftover height so the light band below reaches the footer. Needs
10
+ .page[data-route="/success"] to be a flex column. */
11
+ flex: 1 0 auto;
12
+ padding: 32px 12px 64px;
13
+ min-height: 72vh;
14
+
15
+ /* The confirmation is a LIGHT surface on the shop's purple field — the same full-bleed band the cart
16
+ paints (see pages/Cart.styles.ts Top). The negative top eats .page's own padding so the band starts
17
+ flush under the sub-nav. Its z-index sits alongside the confetti layer's, and ::before paints first,
18
+ so the burst still rains over it. */
19
+ &::before {
20
+ content: '';
21
+ position: absolute;
22
+ top: -28px;
23
+ bottom: 0;
24
+ left: 50%;
25
+ width: 100vw;
26
+ transform: translateX(-50%);
27
+ background: ${i.media};
28
+ z-index: -1;
29
+ }
30
+
31
+ ${c} {
32
+ &::before {
33
+ top: -16px;
34
+ }
35
+ }
36
+ `,te=t.div`
37
+ display: flex;
38
+ flex-direction: column;
39
+ align-items: center;
40
+ text-align: center;
41
+ justify-content: center;
42
+ min-height: 60vh;
43
+ `,ne=t.span`
44
+ margin: 4px auto 8px;
45
+ width: 40px;
46
+ height: 40px;
47
+ `,$=t.h1`
48
+ font-size: clamp(30px, 4vw, 42px);
49
+ font-weight: 800;
50
+ letter-spacing: -0.02em;
51
+ margin: 20px 0 8px;
52
+ `,C=t.p`
53
+ font-size: 18px;
54
+ color: #4b4b57;
55
+ margin: 0 0 22px;
56
+ `,j=t.div`
57
+ display: flex;
58
+ gap: 18px;
59
+ justify-content: center;
60
+ margin: 0 0 20px;
61
+
62
+ &[data-receipt] {
63
+ justify-content: flex-end;
64
+ margin: 0;
65
+ }
66
+ `,ie=t.a`
67
+ display: inline-block;
68
+ margin: 0;
69
+ color: ${i.accent};
70
+ font-weight: 600;
71
+ font-size: 14px;
72
+ text-decoration: none;
73
+ `,T=t.div`
74
+ display: flex;
75
+ gap: 12px;
76
+ flex-wrap: wrap;
77
+ justify-content: center;
78
+ `,se=t.div`
79
+ display: flex;
80
+ flex-direction: column;
81
+ gap: 12px;
82
+ width: 100%;
83
+ `,re=t.div`
84
+ display: flex;
85
+ align-items: center;
86
+ justify-content: center;
87
+ gap: 16px;
88
+ padding: 24px 16px;
89
+ background: ${i.successBg};
90
+ border: 1px solid ${i.successBorder};
91
+ border-radius: 16px;
92
+
93
+ ${c} {
94
+ flex-direction: column;
95
+ border: 0;
96
+ }
97
+ `,oe=t.span`
98
+ flex-shrink: 0;
99
+ width: 60px;
100
+ height: 60px;
101
+ line-height: 0;
102
+ `,ae=t.p`
103
+ margin: 0;
104
+ max-width: 640px;
105
+ text-align: center;
106
+ font-size: 20px;
107
+ line-height: 1.334;
108
+ color: ${i.text2};
109
+
110
+ & b {
111
+ font-weight: 700;
112
+ }
113
+
114
+ ${c} {
115
+ font-size: 17px;
116
+ }
117
+ `,ce=t.div`
118
+ display: flex;
119
+ flex-direction: column;
120
+ padding: 24px;
121
+ background: ${i.white};
122
+ border: 1px solid ${i.gray4};
123
+ border-radius: 16px;
124
+
125
+ ${c} {
126
+ gap: 12px;
127
+ padding: 0;
128
+ background: none;
129
+ border: 0;
130
+ }
131
+ `,de=t.div`
132
+ display: flex;
133
+ flex-direction: column;
134
+
135
+ ${c} {
136
+ padding: 16px;
137
+ background: ${i.white};
138
+ border: 1px solid ${i.gray4};
139
+ border-radius: 16px;
140
+ }
141
+ `,le=t.span`
142
+ display: block;
143
+ height: 1px;
144
+ margin: 12px 0;
145
+ background: ${i.gray4};
146
+
147
+ ${c} {
148
+ display: none;
149
+ }
150
+ `,pe=t.div`
151
+ position: relative;
152
+ display: flex;
153
+ align-items: center;
154
+ justify-content: center;
155
+ gap: 8px;
156
+ min-height: 109px;
157
+ margin-bottom: 12px;
158
+ padding: 8px 24px;
159
+ border-radius: ${b.btn};
160
+ background: ${i.promptLilac};
161
+ color: ${i.text};
162
+
163
+ ${c} {
164
+ margin-bottom: 0;
165
+ }
166
+ `,xe=t(N)`
167
+ width: 30px;
168
+ height: 30px;
169
+ color: ${i.text};
170
+ `,he=t.p`
171
+ display: inline-flex;
172
+ align-items: baseline;
173
+ gap: 6px;
174
+ margin: 0;
175
+ `,ue=t.span`
176
+ font-size: 24px;
177
+ font-weight: 700;
178
+ text-transform: capitalize;
179
+ `,ge=t.span`
180
+ font-size: 14px;
181
+ font-weight: 400;
182
+ `,fe=t.div`
183
+ display: grid;
184
+ grid-template-columns: auto 1fr auto;
185
+ align-items: center;
186
+ gap: 24px;
187
+
188
+ ${c} {
189
+ grid-template-columns: auto 1fr;
190
+ gap: 16px;
191
+
192
+ & [data-thumb] {
193
+ grid-row: 1 / span 2;
194
+ }
195
+ & [data-info] {
196
+ grid-column: 2;
197
+ grid-row: 1;
198
+ align-self: end;
199
+ }
200
+ & [data-price] {
201
+ grid-column: 2;
202
+ grid-row: 2;
203
+ align-self: start;
204
+ margin-top: 4px;
205
+ }
206
+ }
207
+ `,me=t.div`
208
+ position: relative;
209
+ flex-shrink: 0;
210
+ width: 137px;
211
+ height: 137px;
212
+ display: flex;
213
+ align-items: center;
214
+ justify-content: center;
215
+ background: ${i.media};
216
+ border: 0.134px solid ${i.muted2};
217
+ border-radius: ${b.btn};
218
+ overflow: hidden;
219
+
220
+ & img {
221
+ width: 83%;
222
+ height: 83%;
223
+ object-fit: contain;
224
+ filter: drop-shadow(0.56px 2.24px 2.8px rgba(0, 0, 0, 0.1));
225
+ }
226
+
227
+ ${c} {
228
+ width: 96px;
229
+ height: 96px;
230
+ }
231
+ `,B=t.span`
232
+ position: absolute;
233
+ top: 8px;
234
+ left: 8px;
235
+ width: 20px;
236
+ height: 20px;
237
+ display: flex;
238
+ align-items: center;
239
+ justify-content: center;
240
+ background: ${i.dclRed};
241
+ border-radius: ${b.chip};
242
+ line-height: 0;
243
+ `,je=t.div`
244
+ flex: 1;
245
+ min-width: 0;
246
+ display: flex;
247
+ flex-direction: column;
248
+ justify-content: center;
249
+ gap: 4px;
250
+ `,be=t.div`
251
+ font-weight: 700;
252
+ font-size: 20px;
253
+ line-height: 1.3;
254
+ color: ${i.text};
255
+ overflow: hidden;
256
+ text-overflow: ellipsis;
257
+ white-space: nowrap;
258
+
259
+ ${c} {
260
+ font-size: 16px;
261
+ }
262
+ `,we=t.span`
263
+ margin-left: 8px;
264
+ font-weight: 600;
265
+ font-size: 13px;
266
+ color: ${i.muted};
267
+ `,ye=t(O)`
268
+ position: relative;
269
+ z-index: 1;
270
+ color: ${i.muted};
271
+ font-size: 13px;
272
+
273
+ & [data-avatar] {
274
+ display: none;
275
+ }
276
+ `,ve=t.div`
277
+ display: flex;
278
+ align-items: center;
279
+ gap: 6px;
280
+ padding: 8px;
281
+ font-weight: 700;
282
+ font-size: 21px;
283
+ color: ${i.text2};
284
+ white-space: nowrap;
285
+
286
+ ${c} {
287
+ font-size: 18px;
288
+ }
289
+ `,ke=t(N)`
290
+ width: 22px;
291
+ height: 22px;
292
+ background: ${i.text2};
293
+ `,$e=t.div`
294
+ display: flex;
295
+ gap: 12px;
296
+ align-items: center;
297
+ justify-content: flex-end;
298
+ margin-top: 4px;
299
+ `,F=_`
300
+ flex: 1;
301
+ min-width: 0;
302
+ height: 48px;
303
+ display: inline-flex;
304
+ align-items: center;
305
+ justify-content: center;
306
+ gap: 12px;
307
+ padding: 0 24px;
308
+ border-radius: ${b.btn};
309
+ font-weight: 600;
310
+ font-size: 15px;
311
+ letter-spacing: 0.04em;
312
+ text-transform: uppercase;
313
+ text-decoration: none;
314
+ cursor: pointer;
315
+ transition:
316
+ filter 0.15s ease,
317
+ background 0.15s ease;
318
+
319
+ &[data-variant='ghost'] {
320
+ background: ${i.white};
321
+ border: 1px solid ${i.text};
322
+ color: ${i.text};
323
+ }
324
+ &[data-variant='ghost']:hover {
325
+ background: ${i.text2};
326
+ color: ${i.softWhite};
327
+ }
328
+ &[data-variant='ruby'] {
329
+ background: ${i.dclRed};
330
+ border: 0;
331
+ color: ${i.softWhite};
332
+ }
333
+ &[data-variant='ruby']:hover {
334
+ filter: brightness(0.95);
335
+ }
336
+
337
+ ${c} {
338
+ gap: 8px;
339
+ padding: 0 12px;
340
+ font-size: 13px;
341
+ }
342
+ `,Ce=t.button`
343
+ ${F};
344
+ `,ze=t.a`
345
+ ${F};
346
+ `,Re=t.span`
347
+ display: inline-flex;
348
+ flex-shrink: 0;
349
+ line-height: 0;
350
+ `,z=t(K)`
351
+ min-width: 160px;
352
+ text-align: center;
353
+ `;function Ie(p){return null}const Ae=p=>new Promise(d=>setTimeout(d,p)),L=()=>e.jsx("svg",{viewBox:"0 0 18 18",width:"12",height:"12",children:e.jsx("path",{d:"M4 9l3.5 3.5L14 5",fill:"none",stroke:"#fff",strokeWidth:"2.4",strokeLinecap:"round",strokeLinejoin:"round"})});function Se(p,d){const[s,a]=A.useState(p?"pending":"confirmed"),x=d?`${d.owner}-${d.contractAddress}-${d.itemId}`:"";return A.useEffect(()=>{if(!p)return;let l=!1;return(async()=>{let f=!1;for(let r=0;r<20&&!l;r++)try{await Z(p,{timeoutMs:15e3}),f=!0;break}catch(y){if(y instanceof ee)continue;l||a("failed");return}if(!l){if(!f){a("timed-out");return}if(!d){a("confirmed");return}a("indexing");for(let r=0;r<40&&!l;r++){if(await Q(d.owner,d.contractAddress,d.itemId)){l||a("confirmed");return}await Ae(3e3)}l||a("timed-out")}})(),()=>{l=!0}},[p,x]),s}const Te=E.chainId===80002?"https://decentraland.zone/jump":"https://decentraland.org/jump",Be=E.chainId===80002?"https://amoy.polygonscan.com/tx/":"https://polygonscan.com/tx/";function Xe(){var I;const{state:p,search:d}=P(),s=p??Ie(),a=M(),{session:x}=q(),l=s==null?void 0:s.txHash,w=(s==null?void 0:s.items)??[],f=s!=null&&s.creditsAdded&&s.creditsAdded>0?s.creditsAdded:null,r=w[0],y=x!=null&&x.address&&(r!=null&&r.contractAddress)&&(r!=null&&r.itemId)?{owner:x.address,contractAddress:r.contractAddress,itemId:r.itemId}:null,g=Se(s!=null&&s.settled?void 0:l,y);H({title:n("seo.success.title"),noindex:!0});const h=w;if(h.length===0)return e.jsx(W,{to:"/items",replace:!0});const R=h[0],m=(I=s==null?void 0:s.txHashes)!=null&&I.length?s.txHashes:l?[l]:[],u=m.length>0&&U(x==null?void 0:x.providerType)?m.map((o,v)=>e.jsx(ie,{href:`${Be}${o}`,target:"_blank",rel:"noreferrer",children:m.length>1?n("success.viewTransactionNumbered",{n:v+1,total:m.length}):n("success.viewTransaction")},o)):null;return g!=="confirmed"?e.jsx(S,{children:e.jsx(te,{children:g==="pending"||g==="indexing"?e.jsxs(e.Fragment,{children:[e.jsx(ne,{className:"spinner","aria-hidden":!0}),e.jsx($,{children:g==="indexing"?n("success.finalizing"):n("success.processing")}),e.jsx(C,{children:g==="indexing"?e.jsxs(e.Fragment,{children:[n("success.indexingBefore")," ",h.length===1?e.jsx("strong",{children:R.name}):n("success.itemCount",{count:h.length})," ",n("success.indexingAfter")]}):e.jsxs(e.Fragment,{children:[n("success.confirmingBefore")," ",h.length===1?e.jsx("strong",{children:R.name}):n("success.itemCount",{count:h.length})," ",n("success.confirmingAfter")]})}),u?e.jsx(j,{children:u}):null]}):g==="timed-out"?e.jsxs(e.Fragment,{children:[e.jsx($,{children:n("success.stillProcessingTitle")}),e.jsxs(C,{children:[n("success.timedOutBefore")," ",e.jsx("button",{className:"link",onClick:()=>a("/activity"),children:n("nav.activity")})," ",n("success.timedOutAfter")]}),u?e.jsx(j,{children:u}):null,e.jsxs(T,{children:[e.jsx(z,{variant:"purple",onClick:()=>a("/activity"),children:n("success.viewActivity")}),e.jsx(z,{variant:"ghost",onClick:()=>a("/items"),children:n("success.keepShopping")})]})]}):e.jsxs(e.Fragment,{children:[e.jsx($,{children:n("success.failedTitle")}),e.jsx(C,{children:n("success.failedBody")}),u?e.jsx(j,{children:u}):null,e.jsx(T,{children:e.jsx(z,{variant:"purple",onClick:()=>a("/items"),children:n("success.backToShop")})})]})})}):e.jsxs(S,{children:[e.jsx(Y,{}),e.jsxs(se,{children:[e.jsxs(re,{role:"status",children:[e.jsx(oe,{"aria-hidden":!0,children:e.jsxs("svg",{viewBox:"0 0 60 60",width:"60",height:"60",children:[e.jsx("circle",{cx:"30",cy:"30",r:"30",fill:"#34ce77"}),e.jsx("path",{d:"M18 31l8 8 16-18",fill:"none",stroke:"#fff",strokeWidth:"4.5",strokeLinecap:"round",strokeLinejoin:"round"})]})}),e.jsxs(ae,{children:[e.jsx("b",{children:n("success.bannerTitle")})," ",n("success.bannerBody")]})]}),e.jsxs(ce,{children:[f?e.jsxs(pe,{"data-testid":"success-credits",children:[e.jsx(B,{"aria-hidden":!0,children:e.jsx(L,{})}),e.jsx(xe,{}),e.jsxs(he,{children:[e.jsx(ue,{children:n("getCredits.creditsAmount",{credits:f,currency:X.name})})," ",e.jsx(ge,{children:n("getCredits.creditsAdded")})]})]}):null,h.map((o,v)=>{const k=o.quantity??1;return e.jsxs(de,{children:[v>0?e.jsx(le,{"aria-hidden":!0}):null,e.jsxs(fe,{children:[e.jsxs(me,{"data-thumb":!0,children:[o.thumbnail?e.jsx("img",{src:o.thumbnail,alt:""}):null,e.jsx(B,{"aria-hidden":!0,children:e.jsx(L,{})})]}),e.jsxs(je,{"data-info":!0,children:[e.jsxs(be,{title:o.name,children:[o.name||n("buyModal.itemFallback"),k>1?e.jsx(we,{children:n("cartCheckout.qty",{count:k})}):null]}),o.creator?e.jsx(ye,{address:o.creator,linkToProfile:!0}):null]}),e.jsxs(ve,{"data-price":!0,children:[e.jsx(ke,{}),e.jsx("span",{children:D(o.priceCredits*k)})]})]})]},o.id)})]}),u?e.jsx(j,{"data-receipt":!0,children:u}):null,e.jsxs($e,{children:[e.jsx(Ce,{"data-variant":"ghost",onClick:()=>a(G(h.map(o=>o.category))),children:n("success.myAssets")}),e.jsxs(ze,{"data-variant":"ruby",href:Te,target:"_blank",rel:"noreferrer",children:[n("success.tryInWorld"),e.jsx(Re,{"aria-hidden":!0,children:e.jsx(V,{})})]})]})]})]})}export{Xe as Success,Xe 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-BQyeyr-U.js";import{au as C}from"./NetworkUtil-DXqql1Wz.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-ZccF4Y9V.js";import{au as C}from"./NetworkUtil-DXqql1Wz.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 o,j as C,e as T}from"./react-BYHuwl8r.js";import{s as P,t as i}from"./index-CKUuopSw.js";const B=(...t)=>({shouldForwardProp:p=>!t.includes(p)}),A=P("span",B("block"))`
1
+ import{r as o,j as C,e as T}from"./react-BYHuwl8r.js";import{s as P,t as i}from"./index-H0_FOTS1.js";const B=(...t)=>({shouldForwardProp:p=>!t.includes(p)}),A=P("span",B("block"))`
2
2
  display: ${({block:t})=>t?"flex":"inline-flex"};
3
3
  ${({block:t})=>t?"width: 100%;":""}
4
4
  `,I=P("span",B("placement"))`
@@ -1 +1 @@
1
- var ve=Object.defineProperty;var xe=(r,t,e)=>t in r?ve(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e;var p=(r,t,e)=>xe(r,typeof t!="symbol"?t+"":t,e);import{W as ue,a as Q,C as ge,B as Ce,f as X}from"./ethers-BDpbhgX6.js";import{a as Ee,d as B}from"./dcl-schemas-CmtP3U6y.js";import{c as ee}from"./react-BYHuwl8r.js";import{cp as Re,f as te,g as re}from"./index-CKUuopSw.js";import{c as q,e as Ie}from"./index-DdmULNRk.js";import{s as Pe}from"./sendMetaTransaction-Bp3kwdLJ.js";import"./sentry-Dx-KuLV3.js";import"./intl-CBcMB1D2.js";import"./events-DQ172AOg.js";async function be(r){const t=await de();if(t){const e=await new ue(t).getSigner().getChainId();if(r===e)return t}return q.createProvider(Ee.ProviderType.NETWORK,r)}async function de(){try{return await q.getProvider()}catch{try{const{provider:r}=await q.tryPreviousConnection();return r}catch{return null}}}function ne(r){return Math.floor(r/1e3)}function ae(r){switch(r.assetType){case B.TradeAssetType.ERC721:return r.tokenId;case B.TradeAssetType.COLLECTION_ITEM:return r.itemId;case B.TradeAssetType.ERC20:return r.amount;default:return console.error("Invalid asset type:",r),""}}function Ae(r){var t;return{checks:{uses:r.checks.uses,expiration:ne(r.checks.expiration),effective:ne(r.checks.effective),salt:Q(r.checks.salt,32),contractSignatureIndex:r.checks.contractSignatureIndex,signerSignatureIndex:r.checks.signerSignatureIndex,allowedRoot:Q(r.checks.allowedRoot,32),externalChecks:(t=r.checks.externalChecks)==null?void 0:t.map(e=>({contractAddress:e.contractAddress,selector:e.selector,value:e.value?e.value:"0x",required:e.required}))},sent:r.sent.map(e=>({assetType:e.assetType,contractAddress:e.contractAddress,value:ae(e),extra:e.extra?e.extra:"0x"})),received:r.received.map(e=>({assetType:e.assetType,contractAddress:e.contractAddress,value:ae(e),extra:e.extra?e.extra:"0x",beneficiary:e.beneficiary}))}}function se(r,t){const e=Ae(r);return{signer:r.signer,signature:r.signature,...e,checks:{...e.checks,allowedProof:[]},sent:e.sent.map(i=>({...i,beneficiary:t}))}}async function Se(r){const t=await r.request({method:"eth_chainId",params:[]});let e;return typeof t=="string"?e=parseInt(t,16):e=t,e}async function Fe(r){const t=await be(r);return new ue(t)}const S=new Ie.EventEmitter;var C;(function(r){r.ERROR="error",r.SUCCESS="success",r.PROMPT="prompt",r.ACCEPT="accept",r.REJECT="reject"})(C||(C={}));let Le="https://transactions-api.decentraland.org/v1";const ke=()=>Le,Ue=()=>new Promise((r,t)=>{const e=()=>{S.removeAllListeners(C.REJECT),r(!0)},i=()=>{S.removeAllListeners(C.ACCEPT),t(new Error("User rejected transaction"))};S.addListener(C.ACCEPT,e),S.addListener(C.REJECT,i)});async function oe(...r){const[t,e,...i]=r;try{const s=await de();if(!s)throw new Error("Provider not connected");const c=await Se(s),l=await Fe(t.chainId),I=new ge(t.address,t.abi,l),T=await(typeof e=="function"?e(I.populateTransaction):I.populateTransaction[e](...i));if(c===t.chainId){const v=l.getSigner();if(s.isMagic||s.isThirdweb){let U=Ce.from(0);try{const _=await v.getGasPrice(),k=await v.estimateGas(T);U=_.mul(k)}catch{}if(!U.isZero()){const _=Ue(),k=await v.getBalance();S.emit(C.PROMPT,{transactionGasPrice:X(U),userBalance:X(k),chainId:t.chainId}),await _}}const b=await v.sendTransaction(T);return S.emit(C.SUCCESS,{txHash:b.hash}),b.hash}else{const v=await Pe(s,l,T.data,t,{serverURL:ke()});return S.emit(C.SUCCESS,{txHash:v}),v}}catch(s){const c={type:C.ERROR,error:s};throw S.emit(C.ERROR,c),s}}var M={exports:{}};/*! https://mths.be/punycode v1.4.1 by @mathias */var _e=M.exports,ie;function Oe(){return ie||(ie=1,(function(r,t){(function(e){var i=t&&!t.nodeType&&t,s=r&&!r.nodeType&&r,c=typeof ee=="object"&&ee;(c.global===c||c.window===c||c.self===c)&&(e=c);var l,I=2147483647,T=36,v=1,b=26,U=38,_=700,k=72,G=128,J="-",he=/^xn--/,fe=/[^\x20-\x7E]/,pe=/[\x2E\u3002\uFF0E\uFF61]/g,ye={overflow:"Overflow: input needs wider integers to process","not-basic":"Illegal input >= 0x80 (not a basic code point)","invalid-input":"Invalid input"},D=T-v,E=Math.floor,O=String.fromCharCode,N;function F(n){throw new RangeError(ye[n])}function $(n,a){for(var o=n.length,u=[];o--;)u[o]=a(n[o]);return u}function V(n,a){var o=n.split("@"),u="";o.length>1&&(u=o[0]+"@",n=o[1]),n=n.replace(pe,".");var d=n.split("."),y=$(d,a).join(".");return u+y}function H(n){for(var a=[],o=0,u=n.length,d,y;o<u;)d=n.charCodeAt(o++),d>=55296&&d<=56319&&o<u?(y=n.charCodeAt(o++),(y&64512)==56320?a.push(((d&1023)<<10)+(y&1023)+65536):(a.push(d),o--)):a.push(d);return a}function W(n){return $(n,function(a){var o="";return a>65535&&(a-=65536,o+=O(a>>>10&1023|55296),a=56320|a&1023),o+=O(a),o}).join("")}function Te(n){return n-48<10?n-22:n-65<26?n-65:n-97<26?n-97:T}function Y(n,a){return n+22+75*(n<26)-((a!=0)<<5)}function Z(n,a,o){var u=0;for(n=o?E(n/_):n>>1,n+=E(n/a);n>D*b>>1;u+=T)n=E(n/D);return E(u+(D+1)*n/(n+U))}function K(n){var a=[],o=n.length,u,d=0,y=G,h=k,w,x,R,P,f,m,g,A,L;for(w=n.lastIndexOf(J),w<0&&(w=0),x=0;x<w;++x)n.charCodeAt(x)>=128&&F("not-basic"),a.push(n.charCodeAt(x));for(R=w>0?w+1:0;R<o;){for(P=d,f=1,m=T;R>=o&&F("invalid-input"),g=Te(n.charCodeAt(R++)),(g>=T||g>E((I-d)/f))&&F("overflow"),d+=g*f,A=m<=h?v:m>=h+b?b:m-h,!(g<A);m+=T)L=T-A,f>E(I/L)&&F("overflow"),f*=L;u=a.length+1,h=Z(d-P,u,P==0),E(d/u)>I-y&&F("overflow"),y+=E(d/u),d%=u,a.splice(d++,0,y)}return W(a)}function z(n){var a,o,u,d,y,h,w,x,R,P,f,m=[],g,A,L,j;for(n=H(n),g=n.length,a=G,o=0,y=k,h=0;h<g;++h)f=n[h],f<128&&m.push(O(f));for(u=d=m.length,d&&m.push(J);u<g;){for(w=I,h=0;h<g;++h)f=n[h],f>=a&&f<w&&(w=f);for(A=u+1,w-a>E((I-o)/A)&&F("overflow"),o+=(w-a)*A,a=w,h=0;h<g;++h)if(f=n[h],f<a&&++o>I&&F("overflow"),f==a){for(x=o,R=T;P=R<=y?v:R>=y+b?b:R-y,!(x<P);R+=T)j=x-P,L=T-P,m.push(O(Y(P+j%L,0))),x=E(j/L);m.push(O(Y(x,0))),y=Z(o,A,u==d),o=0,++u}++o,++a}return m.join("")}function we(n){return V(n,function(a){return he.test(a)?K(a.slice(4).toLowerCase()):a})}function me(n){return V(n,function(a){return fe.test(a)?"xn--"+z(a):a})}if(l={version:"1.4.1",ucs2:{decode:H,encode:W},decode:K,encode:z,toASCII:me,toUnicode:we},i&&s)if(r.exports==i)s.exports=l;else for(N in l)l.hasOwnProperty(N)&&(i[N]=l[N]);else e.punycode=l})(_e)})(M,M.exports)),M.exports}Oe();var le=(function(r){function t(){var i=this||self;return delete r.prototype.__magic__,i}if(typeof globalThis=="object")return globalThis;if(this)return t();r.defineProperty(r.prototype,"__magic__",{configurable:!0,get:t});var e=__magic__;return e})(Object),Me=le.URL;le.URLSearchParams;var Ne={URL:Me};class ce extends Error{constructor(e,i,s){super(e);p(this,"status");p(this,"data");this.status=i,this.data=s}}const De=3,je=1e3,Be=[400,401,403,404,409,422],qe=(globalThis==null?void 0:globalThis.URL)??Ne.URL;class Ge{constructor(t,e){p(this,"baseUrl");p(this,"retries");p(this,"retryDelay");p(this,"nonRetryableStatuses");p(this,"identity");p(this,"sleep",t=>new Promise(e=>{setTimeout(e,t)}));p(this,"getIdentity",()=>this.identity instanceof Function?this.identity():this.identity);p(this,"rawFetch",(t,e)=>{const i=new qe(t,this.baseUrl),s=(e==null?void 0:e.identity)??this.getIdentity();return Re.signedFetchFactory()(i.toString(),{...e,identity:s})});p(this,"fetch",async(t,e)=>{for(let i=0;i<=this.retries;i++)try{let s,c;try{s=await this.rawFetch(t,e);const l=await s.text();l.length===0?c={ok:!0,data:null}:c=JSON.parse(l)}catch(l){throw new ce(l.message,void 0,null)}if(!s.ok||c.ok===!1){const l=c.message??c.error;throw new ce(l??`Request failed with status code ${s.status}`,s.status,c.data)}return c.ok===!0?c.data:c}catch(s){if(console.error(`[API] HTTP request failed: ${s.message||""}`,s),this.retries===i||s.status&&this.nonRetryableStatuses.includes(s.status))throw s;await this.sleep(this.retryDelay)}throw new Error("Unreachable code")});this.baseUrl=t,this.identity=e==null?void 0:e.identity,this.retries=(e==null?void 0:e.retries)??De,this.retryDelay=(e==null?void 0:e.retryDelay)??je,this.nonRetryableStatuses=(e==null?void 0:e.nonRetryableStatuses)??Be}}class Je extends Ge{constructor(e,i,s){super(i,s);p(this,"signer");p(this,"addTrade",async e=>this.fetch("/v1/trades",{method:"POST",body:JSON.stringify(e),metadata:{signer:this.signer,intent:"dcl:create-trade"},headers:{"Content-Type":"application/json"}}));p(this,"fetchTrade",async e=>this.fetch(`/v1/trades/${e}`,{method:"GET"}));this.signer=e}}class et{constructor(t,e,i){p(this,"tradesAPI");this.tradesAPI=new Je(t,e,{identity:i,retries:0})}async addTrade(t){return this.tradesAPI.addTrade(t)}async fetchTrade(t){return this.tradesAPI.fetchTrade(t)}async accept(t,e){const i=te(t.contract),s=re(i,t.chainId),c=se(t,e);return oe(s,"accept",[c])}async cancel(t,e){const i=te(t.contract),s=re(i,t.chainId),c=se(t,e);return oe(s,"cancelSignature",[c])}}export{et as TradeService};
1
+ var ve=Object.defineProperty;var xe=(r,t,e)=>t in r?ve(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e;var p=(r,t,e)=>xe(r,typeof t!="symbol"?t+"":t,e);import{W as ue,a as Q,C as ge,B as Ce,f as X}from"./ethers-BDpbhgX6.js";import{a as Ee,d as B}from"./dcl-schemas-CmtP3U6y.js";import{c as ee}from"./react-BYHuwl8r.js";import{co as Re,f as te,g as re}from"./index-H0_FOTS1.js";import{c as q,e as Ie}from"./index-xIqXdiX9.js";import{s as Pe}from"./sendMetaTransaction-CnhA6a-k.js";import"./sentry-Dx-KuLV3.js";import"./intl-CBcMB1D2.js";import"./events-DQ172AOg.js";async function be(r){const t=await de();if(t){const e=await new ue(t).getSigner().getChainId();if(r===e)return t}return q.createProvider(Ee.ProviderType.NETWORK,r)}async function de(){try{return await q.getProvider()}catch{try{const{provider:r}=await q.tryPreviousConnection();return r}catch{return null}}}function ne(r){return Math.floor(r/1e3)}function ae(r){switch(r.assetType){case B.TradeAssetType.ERC721:return r.tokenId;case B.TradeAssetType.COLLECTION_ITEM:return r.itemId;case B.TradeAssetType.ERC20:return r.amount;default:return console.error("Invalid asset type:",r),""}}function Ae(r){var t;return{checks:{uses:r.checks.uses,expiration:ne(r.checks.expiration),effective:ne(r.checks.effective),salt:Q(r.checks.salt,32),contractSignatureIndex:r.checks.contractSignatureIndex,signerSignatureIndex:r.checks.signerSignatureIndex,allowedRoot:Q(r.checks.allowedRoot,32),externalChecks:(t=r.checks.externalChecks)==null?void 0:t.map(e=>({contractAddress:e.contractAddress,selector:e.selector,value:e.value?e.value:"0x",required:e.required}))},sent:r.sent.map(e=>({assetType:e.assetType,contractAddress:e.contractAddress,value:ae(e),extra:e.extra?e.extra:"0x"})),received:r.received.map(e=>({assetType:e.assetType,contractAddress:e.contractAddress,value:ae(e),extra:e.extra?e.extra:"0x",beneficiary:e.beneficiary}))}}function se(r,t){const e=Ae(r);return{signer:r.signer,signature:r.signature,...e,checks:{...e.checks,allowedProof:[]},sent:e.sent.map(i=>({...i,beneficiary:t}))}}async function Se(r){const t=await r.request({method:"eth_chainId",params:[]});let e;return typeof t=="string"?e=parseInt(t,16):e=t,e}async function Fe(r){const t=await be(r);return new ue(t)}const S=new Ie.EventEmitter;var C;(function(r){r.ERROR="error",r.SUCCESS="success",r.PROMPT="prompt",r.ACCEPT="accept",r.REJECT="reject"})(C||(C={}));let Le="https://transactions-api.decentraland.org/v1";const ke=()=>Le,Ue=()=>new Promise((r,t)=>{const e=()=>{S.removeAllListeners(C.REJECT),r(!0)},i=()=>{S.removeAllListeners(C.ACCEPT),t(new Error("User rejected transaction"))};S.addListener(C.ACCEPT,e),S.addListener(C.REJECT,i)});async function oe(...r){const[t,e,...i]=r;try{const s=await de();if(!s)throw new Error("Provider not connected");const c=await Se(s),l=await Fe(t.chainId),I=new ge(t.address,t.abi,l),T=await(typeof e=="function"?e(I.populateTransaction):I.populateTransaction[e](...i));if(c===t.chainId){const v=l.getSigner();if(s.isMagic||s.isThirdweb){let U=Ce.from(0);try{const _=await v.getGasPrice(),k=await v.estimateGas(T);U=_.mul(k)}catch{}if(!U.isZero()){const _=Ue(),k=await v.getBalance();S.emit(C.PROMPT,{transactionGasPrice:X(U),userBalance:X(k),chainId:t.chainId}),await _}}const b=await v.sendTransaction(T);return S.emit(C.SUCCESS,{txHash:b.hash}),b.hash}else{const v=await Pe(s,l,T.data,t,{serverURL:ke()});return S.emit(C.SUCCESS,{txHash:v}),v}}catch(s){const c={type:C.ERROR,error:s};throw S.emit(C.ERROR,c),s}}var M={exports:{}};/*! https://mths.be/punycode v1.4.1 by @mathias */var _e=M.exports,ie;function Oe(){return ie||(ie=1,(function(r,t){(function(e){var i=t&&!t.nodeType&&t,s=r&&!r.nodeType&&r,c=typeof ee=="object"&&ee;(c.global===c||c.window===c||c.self===c)&&(e=c);var l,I=2147483647,T=36,v=1,b=26,U=38,_=700,k=72,G=128,J="-",he=/^xn--/,fe=/[^\x20-\x7E]/,pe=/[\x2E\u3002\uFF0E\uFF61]/g,ye={overflow:"Overflow: input needs wider integers to process","not-basic":"Illegal input >= 0x80 (not a basic code point)","invalid-input":"Invalid input"},D=T-v,E=Math.floor,O=String.fromCharCode,N;function F(n){throw new RangeError(ye[n])}function $(n,a){for(var o=n.length,u=[];o--;)u[o]=a(n[o]);return u}function V(n,a){var o=n.split("@"),u="";o.length>1&&(u=o[0]+"@",n=o[1]),n=n.replace(pe,".");var d=n.split("."),y=$(d,a).join(".");return u+y}function H(n){for(var a=[],o=0,u=n.length,d,y;o<u;)d=n.charCodeAt(o++),d>=55296&&d<=56319&&o<u?(y=n.charCodeAt(o++),(y&64512)==56320?a.push(((d&1023)<<10)+(y&1023)+65536):(a.push(d),o--)):a.push(d);return a}function W(n){return $(n,function(a){var o="";return a>65535&&(a-=65536,o+=O(a>>>10&1023|55296),a=56320|a&1023),o+=O(a),o}).join("")}function Te(n){return n-48<10?n-22:n-65<26?n-65:n-97<26?n-97:T}function Y(n,a){return n+22+75*(n<26)-((a!=0)<<5)}function Z(n,a,o){var u=0;for(n=o?E(n/_):n>>1,n+=E(n/a);n>D*b>>1;u+=T)n=E(n/D);return E(u+(D+1)*n/(n+U))}function K(n){var a=[],o=n.length,u,d=0,y=G,h=k,w,x,R,P,f,m,g,A,L;for(w=n.lastIndexOf(J),w<0&&(w=0),x=0;x<w;++x)n.charCodeAt(x)>=128&&F("not-basic"),a.push(n.charCodeAt(x));for(R=w>0?w+1:0;R<o;){for(P=d,f=1,m=T;R>=o&&F("invalid-input"),g=Te(n.charCodeAt(R++)),(g>=T||g>E((I-d)/f))&&F("overflow"),d+=g*f,A=m<=h?v:m>=h+b?b:m-h,!(g<A);m+=T)L=T-A,f>E(I/L)&&F("overflow"),f*=L;u=a.length+1,h=Z(d-P,u,P==0),E(d/u)>I-y&&F("overflow"),y+=E(d/u),d%=u,a.splice(d++,0,y)}return W(a)}function z(n){var a,o,u,d,y,h,w,x,R,P,f,m=[],g,A,L,j;for(n=H(n),g=n.length,a=G,o=0,y=k,h=0;h<g;++h)f=n[h],f<128&&m.push(O(f));for(u=d=m.length,d&&m.push(J);u<g;){for(w=I,h=0;h<g;++h)f=n[h],f>=a&&f<w&&(w=f);for(A=u+1,w-a>E((I-o)/A)&&F("overflow"),o+=(w-a)*A,a=w,h=0;h<g;++h)if(f=n[h],f<a&&++o>I&&F("overflow"),f==a){for(x=o,R=T;P=R<=y?v:R>=y+b?b:R-y,!(x<P);R+=T)j=x-P,L=T-P,m.push(O(Y(P+j%L,0))),x=E(j/L);m.push(O(Y(x,0))),y=Z(o,A,u==d),o=0,++u}++o,++a}return m.join("")}function we(n){return V(n,function(a){return he.test(a)?K(a.slice(4).toLowerCase()):a})}function me(n){return V(n,function(a){return fe.test(a)?"xn--"+z(a):a})}if(l={version:"1.4.1",ucs2:{decode:H,encode:W},decode:K,encode:z,toASCII:me,toUnicode:we},i&&s)if(r.exports==i)s.exports=l;else for(N in l)l.hasOwnProperty(N)&&(i[N]=l[N]);else e.punycode=l})(_e)})(M,M.exports)),M.exports}Oe();var le=(function(r){function t(){var i=this||self;return delete r.prototype.__magic__,i}if(typeof globalThis=="object")return globalThis;if(this)return t();r.defineProperty(r.prototype,"__magic__",{configurable:!0,get:t});var e=__magic__;return e})(Object),Me=le.URL;le.URLSearchParams;var Ne={URL:Me};class ce extends Error{constructor(e,i,s){super(e);p(this,"status");p(this,"data");this.status=i,this.data=s}}const De=3,je=1e3,Be=[400,401,403,404,409,422],qe=(globalThis==null?void 0:globalThis.URL)??Ne.URL;class Ge{constructor(t,e){p(this,"baseUrl");p(this,"retries");p(this,"retryDelay");p(this,"nonRetryableStatuses");p(this,"identity");p(this,"sleep",t=>new Promise(e=>{setTimeout(e,t)}));p(this,"getIdentity",()=>this.identity instanceof Function?this.identity():this.identity);p(this,"rawFetch",(t,e)=>{const i=new qe(t,this.baseUrl),s=(e==null?void 0:e.identity)??this.getIdentity();return Re.signedFetchFactory()(i.toString(),{...e,identity:s})});p(this,"fetch",async(t,e)=>{for(let i=0;i<=this.retries;i++)try{let s,c;try{s=await this.rawFetch(t,e);const l=await s.text();l.length===0?c={ok:!0,data:null}:c=JSON.parse(l)}catch(l){throw new ce(l.message,void 0,null)}if(!s.ok||c.ok===!1){const l=c.message??c.error;throw new ce(l??`Request failed with status code ${s.status}`,s.status,c.data)}return c.ok===!0?c.data:c}catch(s){if(console.error(`[API] HTTP request failed: ${s.message||""}`,s),this.retries===i||s.status&&this.nonRetryableStatuses.includes(s.status))throw s;await this.sleep(this.retryDelay)}throw new Error("Unreachable code")});this.baseUrl=t,this.identity=e==null?void 0:e.identity,this.retries=(e==null?void 0:e.retries)??De,this.retryDelay=(e==null?void 0:e.retryDelay)??je,this.nonRetryableStatuses=(e==null?void 0:e.nonRetryableStatuses)??Be}}class Je extends Ge{constructor(e,i,s){super(i,s);p(this,"signer");p(this,"addTrade",async e=>this.fetch("/v1/trades",{method:"POST",body:JSON.stringify(e),metadata:{signer:this.signer,intent:"dcl:create-trade"},headers:{"Content-Type":"application/json"}}));p(this,"fetchTrade",async e=>this.fetch(`/v1/trades/${e}`,{method:"GET"}));this.signer=e}}class et{constructor(t,e,i){p(this,"tradesAPI");this.tradesAPI=new Je(t,e,{identity:i,retries:0})}async addTrade(t){return this.tradesAPI.addTrade(t)}async fetchTrade(t){return this.tradesAPI.fetchTrade(t)}async accept(t,e){const i=te(t.contract),s=re(i,t.chainId),c=se(t,e);return oe(s,"accept",[c])}async cancel(t,e){const i=te(t.contract),s=re(i,t.chainId),c=se(t,e);return oe(s,"cancelSignature",[c])}}export{et as TradeService};