@dcl/shop 0.1.0-29994103056.commit-191afbc → 0.1.0-29996672089.commit-ce4d282
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/Activity-ji9z26-b.js +243 -0
- package/assets/{AnimatedBackground-CwVmQoMy.js → AnimatedBackground-dlJZeXOs.js} +3 -3
- package/assets/Assets-DHtvK9gi.js +758 -0
- package/assets/{Assets.styles-BmY0qPN-.js → Assets.styles-DBA9HXW7.js} +1 -1
- package/assets/Authorizations-BNMCiOdB.js +163 -0
- package/assets/Cart-BlShrWP_.js +3 -0
- package/assets/{CircularProgress-BmaY3soK.js → CircularProgress-DvTkhDvC.js} +1 -1
- package/assets/{Collection-BlMV8rIO.js → Collection-DFIFsgYQ.js} +2 -2
- package/assets/CollectionCarousel-DMwkzkYf.js +1 -0
- package/assets/{ConstantsUtil-DO6FyoSW.js → ConstantsUtil-CJUlyS7R.js} +1 -1
- package/assets/{ContentClient-eS-Purid.js → ContentClient-DtuNqgIp.js} +1 -1
- package/assets/{Creator-CVsany2p.js → Creator-BzYX40qE.js} +1 -1
- package/assets/{CssVarsProvider-D03-j1T8.js → CssVarsProvider-D82yS8Ds.js} +1 -1
- package/assets/{DeploymentBuilder-mzKF7T6P.js → DeploymentBuilder-Bt5zjBVh.js} +1 -1
- package/assets/{ErrorNotice-BDH9xoG4.js → ErrorNotice-C7soUjRV.js} +1 -1
- package/assets/{ExchangeController-BKklF67w.js → ExchangeController-CiGVwKQf.js} +1 -1
- package/assets/{GetCredits-l0W_kkUA.js → GetCredits-eVhxGnMo.js} +1 -1
- package/assets/{HelpersUtil-1AJlaO39.js → HelpersUtil-C32FavmO.js} +1 -1
- package/assets/{ImportListings-CaC4hXkS.js → ImportListings-BiGwtdUn.js} +2 -2
- package/assets/ItemDetail-6dC_vNLF.css +1 -0
- package/assets/ItemDetail-DQOBDAhC.js +78 -0
- package/assets/{LoadMore-DCZi1YY-.js → LoadMore-BjvEi3Wj.js} +1 -1
- package/assets/MarketCheckout-BB0_ss_n.js +3 -0
- package/assets/{MyAssets-Gc_o5t9O.js → MyAssets-cbSiEx2B.js} +2 -2
- package/assets/{MyFavorites-CTtHG-tK.js → MyFavorites-DxWrJSpf.js} +2 -2
- package/assets/{NetworkUtil-BGlQiKvg.js → NetworkUtil-Xp0fNa8X.js} +1 -1
- package/assets/{NotFound-0kATSaSv.js → NotFound-Cj4SIl5T.js} +1 -1
- package/assets/{PrimaryListModal-QH5JEih2.js → PrimaryListModal-CdZJXblc.js} +1 -1
- package/assets/{StoreSettings-D97bWmhq.js → StoreSettings-LdrMcuVr.js} +5 -5
- package/assets/Success-BRT1MWds.js +4 -0
- package/assets/{SwapController-C8nP5wvc.js → SwapController-CXQ00xts.js} +1 -1
- package/assets/{Tooltip-BaUllE5E.js → Tooltip-BZ57TVaP.js} +1 -1
- package/assets/TradeService-SfkC7zHZ.js +1 -0
- package/assets/{W3MFrameProviderSingleton-B-iMukUt.js → W3MFrameProviderSingleton-B8RM0-JJ.js} +3 -3
- package/assets/{WebCryptoP256-BN2oUA6b.js → WebCryptoP256-D_33Dvnx.js} +1 -1
- package/assets/authorizations-D44lw00X.js +1 -0
- package/assets/{basic-BAZBRGQf.js → basic-CtFzqtOx.js} +1 -1
- package/assets/{biconomy-Bnx-4bDS.js → biconomy-BaeM1SCU.js} +1 -1
- package/assets/{browser-Cad_aDY9.js → browser-9oFjBwrz.js} +1 -1
- package/assets/{browser-ponyfill-CQ0GHmxr.js → browser-ponyfill-DMgE6PM5.js} +1 -1
- package/assets/browser-ponyfill-Djb5Py6a.js +1 -0
- package/assets/buy-Dszi8UeF.js +1 -0
- package/assets/buy-gasless-Nfp6cMbQ.js +1 -0
- package/assets/{cart-checkout-CUI-WqEI.js → cart-checkout-Ba3nMBI0.js} +1 -1
- package/assets/{categories-BGNx7jfw.js → categories-D0iwhqs_.js} +1 -1
- package/assets/{ccip-CPI8_6cL.js → ccip-CaKFUjmD.js} +1 -1
- package/assets/{ccip-s5BQ-vNw.js → ccip-DGnj8pvI.js} +1 -1
- package/assets/{chains-C1bwVnfj.js → chains-Bzau33xB.js} +1 -1
- package/assets/collection-DSysxaCY.js +1 -0
- package/assets/{common-yfho93wI.js → common-BaN-pXG4.js} +1 -1
- package/assets/{controller-CL9wipr5.js → controller-DqW_a2vQ.js} +2 -2
- package/assets/{core-gCo9rRyh.js → core-BfFj7IDN.js} +4 -4
- package/assets/{custom-BIAxnPyV.js → custom-CyKMgWLF.js} +1 -1
- package/assets/{data-capture-D_IuhqRX.js → data-capture-DyJzM655.js} +1 -1
- package/assets/{decimals-B36bI5dA.js → decimals-DaU_ek4_.js} +1 -1
- package/assets/decimals-HChuNAkm.js +1 -0
- package/assets/{detectExtension-CKplVZ9K.js → detectExtension-C2ped1rb.js} +1 -1
- package/assets/{email-BCklj9Js.js → email-B1LVTurO.js} +1 -1
- package/assets/{embedded-wallet-B6X4cZQC.js → embedded-wallet-DbH1O4GQ.js} +1 -1
- package/assets/{emotion-styled.browser.esm-D40Lt8fm.js → emotion-styled.browser.esm-CMXzhKww.js} +1 -1
- package/assets/{engine-skvS20px.js → engine-BNiIRF8k.js} +1 -1
- package/assets/{errors-DmdGTuzI.js → errors-DUo56sGG.js} +1 -1
- package/assets/estimate-l1-fee-DbEUBk2I.js +1 -0
- package/assets/eth_estimateGas-DcV1bi0C.js +1 -0
- package/assets/{eth_getStorageAt-C0E8Vng5.js → eth_getStorageAt-CvOhghFe.js} +1 -1
- package/assets/eth_getTransactionCount-BNyI69eR.js +1 -0
- package/assets/{ethereum-C5kfwN9D.js → ethereum-B_IIMsg0.js} +1 -1
- package/assets/{ethers-BIvjmL85.js → ethers-w5dOkonM.js} +1 -1
- package/assets/{execute-B_XUV-t5.js → execute-CzNqLgfO.js} +2 -2
- package/assets/{extractIPFS-CsawLTu6.js → extractIPFS-mhjpSq1K.js} +1 -1
- package/assets/{features-D1q967sn.js → features-D_R5E38-.js} +1 -1
- package/assets/{fetchTokenMetadata-Bgs6k1N5.js → fetchTokenMetadata-BZsN957Y.js} +2 -2
- package/assets/{fortmatic-DwISA9k4.js → fortmatic-DhmlcDbL.js} +1 -1
- package/assets/{get-bytecode-nwWHW248.js → get-bytecode-D38h1G96.js} +1 -1
- package/assets/get-ecosystem-wallet-info-BIlu2xkX.js +1 -0
- package/assets/{getBalance-D2FG5QKV.js → getBalance-BD5xADMR.js} +2 -2
- package/assets/{getInstalledModules-fBSGgSis.js → getInstalledModules-3Q5HYxkN.js} +1 -1
- package/assets/getNFT-B7e2uNF-.js +1 -0
- package/assets/{getNFT-BHzS5Cs2.js → getNFT-DjEJIHB0.js} +2 -2
- package/assets/{getOverlayAlpha-B90Fo_-m.js → getOverlayAlpha-Ho14PJoT.js} +1 -1
- package/assets/{hashTypedData-Cetq1UOK.js → hashTypedData-CC4Umz6j.js} +1 -1
- package/assets/{hashTypedData-DwlPS8MG.js → hashTypedData-DE2iuKMA.js} +1 -1
- package/assets/{import-DLMm_P8-.js → import-BPLVQmln.js} +1 -1
- package/assets/{in-app-CL2vGnrW.js → in-app-qD4m50Nn.js} +1 -1
- package/assets/{in-app-wallet-calls-CQYLsbwB.js → in-app-wallet-calls-BcFExuty.js} +1 -1
- package/assets/{index-DYAXJBpy.js → index--PWwvcNI.js} +1 -1
- package/assets/{index-Che81lrU.js → index-0syK5-Ww.js} +1 -1
- package/assets/{index-Chep4cKH.js → index-2Q-POj3l.js} +3 -3
- package/assets/{index-Ctbl3gOg.js → index-5RDpMwKv.js} +1 -1
- package/assets/{index-BptsdzIZ.js → index-Aw0QE_Br.js} +1 -1
- package/assets/{index-DcsKpVUb.js → index-B9U21JU-.js} +1 -1
- package/assets/{index-BrG8RI5z.js → index-B9n-6xCt.js} +1 -1
- package/assets/{index-DOyivP0c.js → index-BAKqn_lj.js} +2 -2
- package/assets/{index-D5zi_XmR.js → index-BBLW_jFO.js} +1 -1
- package/assets/{index-DAhYJ23_.js → index-BFydxC8W.js} +1 -1
- package/assets/{index-CMZ-l1j1.js → index-BGbFLGJH.js} +1 -1
- package/assets/{index-CwlKjFOG.js → index-BNa7Mf2M.js} +1 -1
- package/assets/{index-BEYHZcex.js → index-BW1vsFdc.js} +1 -1
- package/assets/{index-BBg2vZhG.js → index-B_AeYsKa.js} +1 -1
- package/assets/{index-CnFuk6fK.js → index-BfnFZQqu.js} +1 -1
- package/assets/{index-BXIq_1Tg.js → index-Bi7dtaTz.js} +1 -1
- package/assets/{index-Bn-EvtCB.js → index-Bk6ayCIs.js} +1 -1
- package/assets/{index-Dzy3N4vA.js → index-BnrQ0KXT.js} +1 -1
- package/assets/{index-Cx9CeoZH.js → index-Bt55wXtx.js} +1 -1
- package/assets/{index-BywohlL7.js → index-BuXSM1De.js} +1 -1
- package/assets/{index-B65D0iv0.js → index-ByOIX4VW.js} +1 -1
- package/assets/{index-CVPd9k0D.js → index-C4111GJ-.js} +2 -2
- package/assets/{index-DexIqMzn.js → index-C8P6BHpY.js} +3 -3
- package/assets/{index-D6Thjy9g.js → index-CA73t5p4.js} +1 -1
- package/assets/{index-Zev_LSPI.js → index-CDkTFenk.js} +2 -2
- package/assets/index-CGNquv7o.js +289 -0
- package/assets/{index-B-wT7-Au.js → index-CPvKfkxC.js} +1 -1
- package/assets/{index-C6-1JAkG.js → index-CXMHgbT-.js} +1 -1
- package/assets/{index-CrqgaFmq.js → index-Ck1Cgm82.js} +1 -1
- package/assets/{index-D2F7-1mk.js → index-Cl3G53Lb.js} +1 -1
- package/assets/{index-BGuUm-N-.js → index-CqYbCFw1.js} +1 -1
- package/assets/index-CrKaGnrK.css +1 -0
- package/assets/{index-C5t2d1JX.js → index-CrhtLjWe.js} +1 -1
- package/assets/{index-CHspULa1.js → index-CuA9C-j1.js} +1 -1
- package/assets/{index-BedvNbsM.js → index-CwFsoF5e.js} +1 -1
- package/assets/{index-DTJ6mS_J.js → index-CwKIaxXt.js} +1 -1
- package/assets/{index-B-3QmCY1.js → index-Cx9QgWtN.js} +1 -1
- package/assets/{index-C97CPhyL.js → index-D2bdndwX.js} +1 -1
- package/assets/{index-K0TqdX33.js → index-D7KDT9M9.js} +1 -1
- package/assets/{index-nTA1Tk1a.js → index-DD8leihn.js} +1 -1
- package/assets/{index-DjQcD_Sm.js → index-DGOaB47n.js} +1 -1
- package/assets/index-DH3Yzbz3.js +1 -0
- package/assets/{index-CSRkaTCL.js → index-DRB-gQiu.js} +1 -1
- package/assets/{index-ChbyDwUh.js → index-DUx_udvr.js} +1 -1
- package/assets/{index-DLJwIINa.js → index-DVl2fB76.js} +1 -1
- package/assets/{index-CyrfWYlv.js → index-DWj03ICg.js} +1 -1
- package/assets/{index-BZk7RUfM.js → index-D_jFC223.js} +1 -1
- package/assets/{index-C0wsNojR.js → index-D_xn82-1.js} +1 -1
- package/assets/{index-DnxELmkR.js → index-DcVvVcVQ.js} +1 -1
- package/assets/{index-C2te_xAY.js → index-Dg2IevmK.js} +2 -2
- package/assets/{index-CjBPO58E.js → index-Dp3Py-Ws.js} +1 -1
- package/assets/{index-d3ZKkcaA.js → index-Dv2SQ_eL.js} +1 -1
- package/assets/{index-o_m2wFAn.js → index-DxFC7t5T.js} +1 -1
- package/assets/{index-C2N-AU8j.js → index-Dzj-nA_x.js} +3 -3
- package/assets/index-HN6Rk25C.js +1 -0
- package/assets/{index-BkQHYnhC.js → index-I5rJvbQ1.js} +1 -1
- package/assets/{index-CWfnhYLp.js → index-OGdy2qbx.js} +1 -1
- package/assets/{index-CvIOskBU.js → index-QMzB_9kT.js} +1 -1
- package/assets/{index-B6gcmiqs.js → index-VUv3xRHQ.js} +1 -1
- package/assets/{index-DyhpH4px.js → index-grzzP9n9.js} +1 -1
- package/assets/{index-D3iIxnX6.js → index-hDcHuSsT.js} +1 -1
- package/assets/{index-D-i0A7WQ.js → index-hmML8Yn6.js} +2 -2
- package/assets/{index-0F8nhLaF.js → index-lVvjFIjk.js} +1 -1
- package/assets/{index-uK7qM9c7.js → index-w4_5Aj8T.js} +1 -1
- package/assets/{index-CW9ug21x.js → index-yRQsdAyS.js} +3 -3
- package/assets/{index-yr9vyS0z.js → index-z9bgkHOn.js} +1 -1
- package/assets/{index.es-DnNvUOrT.js → index.es-CMAy1XDw.js} +1 -1
- package/assets/{index.es-CZtQ8FVb.js → index.es-CMyspuf3.js} +4 -4
- package/assets/{index.es-DlHsAJbI.js → index.es-DLt1eklQ.js} +1 -1
- package/assets/{linkAccount-DKoZKguc.js → linkAccount-e50lqdUE.js} +1 -1
- package/assets/{localBatchGatewayRequest-DiUucTH0.js → localBatchGatewayRequest-Da4arsJr.js} +1 -1
- package/assets/mana-rate-BM11zYcS.js +1 -0
- package/assets/{native-t1vLKS11.js → native-BMBZUPnx.js} +1 -1
- package/assets/{networks-D5rFr4Uy.js → networks-CP5ZxOS7.js} +1 -1
- package/assets/{onramp-RD8o9zW8.js → onramp-DEaPwD93.js} +1 -1
- package/assets/{openzeppelin-GzHB2W1P.js → openzeppelin-ubglQWTS.js} +1 -1
- package/assets/{ownerOf-Cl_sRHvA.js → ownerOf-dLmWQ3QZ.js} +1 -1
- package/assets/{parseNft-CbgJiXpe.js → parseNft-nhS1PzrY.js} +2 -2
- package/assets/{parseSignature-DGB4v4W-.js → parseSignature-DIaDPyGA.js} +1 -1
- package/assets/{parseSignature-DZazOabU.js → parseSignature-DtIw2rXo.js} +3 -3
- package/assets/{passkeys-BDOXnD26.js → passkeys-l4VrwtfF.js} +1 -1
- package/assets/{pay-with-exchange-ChCNzNHg.js → pay-with-exchange-yIOka8rX.js} +1 -1
- package/assets/{prepare-contract-call-DmYPUPWz.js → prepare-contract-call-aT1l2NVg.js} +1 -1
- package/assets/{qr-overlay-BIPzfQds.js → qr-overlay-BC6wsExf.js} +3 -3
- package/assets/{react-BrLDncxD.js → react-C51i12iP.js} +1 -1
- package/assets/{receive-CsWO80gl.js → receive-DGr9WBJt.js} +1 -1
- package/assets/{resolveImplementation-CInkT_I9.js → resolveImplementation-CgWwbjqg.js} +1 -1
- package/assets/{rpc-DOR15RcJ.js → rpc-2WnfD84R.js} +1 -1
- package/assets/{secp256k1-DUaLgTGJ.js → secp256k1-BzEjkNEy.js} +1 -1
- package/assets/{secp256k1-C8pkcGJ3.js → secp256k1-C2nawWfp.js} +1 -1
- package/assets/{secp256k1-N7sx_maT.js → secp256k1-C3Ly2cZR.js} +1 -1
- package/assets/{send-BEnX8iHn.js → send-DaMmaBKd.js} +1 -1
- package/assets/{send-batch-transaction-Cl-WR4dD.js → send-batch-transaction-BJnHeeX4.js} +1 -1
- package/assets/{send-eip712-transaction-BnpCutKi.js → send-eip712-transaction-lGbfEAzA.js} +2 -2
- package/assets/send-gasless-transaction-GytT3EN0.js +2 -0
- package/assets/{send-transaction-BcThrsCr.js → send-transaction-wju-H3Cn.js} +2 -2
- package/assets/sendMetaTransaction-CiO3jI6F.js +1 -0
- package/assets/{sendRawTransaction-BJLeMhAd.js → sendRawTransaction-B7gRnaFv.js} +3 -3
- package/assets/{sentry-DYZXk5O5.js → sentry-DKBoGDXH.js} +1 -1
- package/assets/{serializeTransaction-BMgHZkKp.js → serializeTransaction-K8-WLWnl.js} +1 -1
- package/assets/{session-proposal-Ds2RY-CA.js → session-proposal-eLNEKDfD.js} +1 -1
- package/assets/{session-request-CLTybC5q.js → session-request-D0qpm2ew.js} +2 -2
- package/assets/{sha256-DM_yyL1v.js → sha256-BcAs0Y4r.js} +1 -1
- package/assets/{signing-Dr9d33yf.js → signing-gBX9gJ32.js} +3 -3
- package/assets/{socials-CaYP6kJa.js → socials-CD_j_07F.js} +1 -1
- package/assets/{swaps-BHrutsbS.js → swaps-Bzm1G8N4.js} +1 -1
- package/assets/{thirdweb-DIAnaqbp.js → thirdweb-DCMx7j1D.js} +3 -3
- package/assets/{to-serializable-transaction-DqNZm-Zy.js → to-serializable-transaction-BZAI7BsG.js} +2 -2
- package/assets/{totalSupply-DKYveUeg.js → totalSupply-BCBM6uY2.js} +1 -1
- package/assets/trade-encoding-2LKm-Goy.js +1 -0
- package/assets/{transaction-HL8b44XJ.js → transaction-Db6pntE5.js} +1 -1
- package/assets/{transactionReceipt-iA2axmC8.js → transactionReceipt-CRyPQK5a.js} +1 -1
- package/assets/{transactions-DAq9dNVo.js → transactions-I7lCf2CM.js} +1 -1
- package/assets/useCreditPacks-DYrmYjK5.js +1 -0
- package/assets/{useInfiniteGrid-Dh1-HUF4.js → useInfiniteGrid-CDzsfZBu.js} +1 -1
- package/assets/useManaRate-BEdT5IGm.js +1 -0
- package/assets/{useStore-DBh7zwbY.js → useStore-D1gCXOP_.js} +2 -2
- package/assets/{useTheme-ddXkiCRZ.js → useTheme-CUwz5NUH.js} +1 -1
- package/assets/useTheme-hvTZJoGa.js +1 -0
- package/assets/{utils-5mrprTVL.js → utils-DBnU1jhd.js} +1 -1
- package/assets/{verifyHash-C62BfpA_.js → verifyHash-DGsbtWAk.js} +1 -1
- package/assets/{w3m-modal-Bxbo8T_Z.js → w3m-modal-C4axQEqk.js} +1 -1
- package/assets/{w3m-modal-BT8yrl74.js → w3m-modal-DJ_LdfUD.js} +1 -1
- package/assets/{wait-for-tx-receipt-D_og-NhE.js → wait-for-tx-receipt-JPXzoKCu.js} +1 -1
- package/assets/{wallets-B72ZtlfA.js → wallets-CkR7yrP_.js} +5 -5
- package/assets/{web-connector-DBmok4eN.js → web-connector-HjRYE3VT.js} +3 -3
- package/assets/{writeContract-CLiFKioV.js → writeContract-DSPOgOMV.js} +1 -1
- package/assets/{zora-sepolia-Bef01XwU.js → zora-sepolia-Bwjy_6bk.js} +1 -1
- package/assets/{zoraTestnet-Bfnpd26p.js → zoraTestnet-2TguyOvD.js} +1 -1
- package/index.html +11 -11
- package/package.json +2 -2
- package/assets/Assets-DqZw3BZv.js +0 -758
- package/assets/Authorizations-BxmoVEl_.js +0 -163
- package/assets/Cart-DA1J5Be_.js +0 -3
- package/assets/CollectionCarousel-B2cDWt_o.js +0 -1
- package/assets/ItemDetail-BiAHzfHh.css +0 -1
- package/assets/ItemDetail-DHaOvIrD.js +0 -78
- package/assets/MarketCheckout-BrvEzX8j.js +0 -3
- package/assets/MyPurchases-DLOdIHUA.js +0 -200
- package/assets/Success-DRMy6BRe.js +0 -4
- package/assets/TradeService-ZNznSjPX.js +0 -1
- package/assets/authorizations-QONJAQC4.js +0 -1
- package/assets/browser-ponyfill-vZOvKb_B.js +0 -1
- package/assets/buy-CE5I6jg2.js +0 -1
- package/assets/buy-gasless-DPcBjPtZ.js +0 -1
- package/assets/collection-Bm8Org8q.js +0 -1
- package/assets/decimals-BPDUTKfa.js +0 -1
- package/assets/estimate-l1-fee-J0AI4VGA.js +0 -1
- package/assets/eth_estimateGas-BeErQaun.js +0 -1
- package/assets/eth_getTransactionCount-kFIWL36y.js +0 -1
- package/assets/get-ecosystem-wallet-info-BRMexyn8.js +0 -1
- package/assets/getNFT-DrLPmHpk.js +0 -1
- package/assets/index-Bw9Y53F1.css +0 -1
- package/assets/index-CD_HpB6P.js +0 -1
- package/assets/index-DaOu_NHP.js +0 -289
- package/assets/mana-rate-BX_VjspN.js +0 -1
- package/assets/send-gasless-transaction-CGxm_r0E.js +0 -2
- package/assets/sendMetaTransaction-iOoE_Tw3.js +0 -1
- package/assets/trade-encoding-DqhxC9n7.js +0 -1
- package/assets/useCreditPacks-CV1PhThV.js +0 -1
- package/assets/useTheme--bd6Ub02.js +0 -1
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import{a as v,u as k,j as s,N as w,r as p}from"./react-C51i12iP.js";import{u as y,m as b,t as e,v as C,C as f,w as A,x as S,p as g,s as B,B as I,y as L,e as E}from"./index-CGNquv7o.js";import{w as T,S as F}from"./buy-gasless-Nfp6cMbQ.js";import"./dcl-schemas-BICTSpB5.js";import"./sentry-DKBoGDXH.js";import"./ethers-w5dOkonM.js";import"./intl-CBcMB1D2.js";import"./authorizations-D44lw00X.js";import"./index-HN6Rk25C.js";import"./sendMetaTransaction-CiO3jI6F.js";import"./trade-encoding-2LKm-Goy.js";const j=B(I)`
|
|
2
|
+
min-width: 160px;
|
|
3
|
+
text-align: center;
|
|
4
|
+
`,M=c=>new Promise(t=>setTimeout(t,c));function P(c,t){const[a,i]=p.useState(c?"pending":"confirmed"),m=t?`${t.owner}-${t.contractAddress}-${t.itemId}`:"";return p.useEffect(()=>{if(!c)return;let r=!1;return(async()=>{let h=!1;for(let n=0;n<20&&!r;n++)try{await T(c,{timeoutMs:15e3}),h=!0;break}catch(d){if(d instanceof F)continue;r||i("failed");return}if(!r){if(!h){i("timed-out");return}if(!t){i("confirmed");return}i("indexing");for(let n=0;n<40&&!r;n++){if(await L(t.owner,t.contractAddress,t.itemId)){r||i("confirmed");return}await M(3e3)}r||i("timed-out")}})(),()=>{r=!0}},[c,m]),a}const R=g.chainId===80002?"https://decentraland.zone/jump":"https://decentraland.org/jump",W=g.chainId===80002?"https://amoy.polygonscan.com/tx/":"https://polygonscan.com/tx/";function V(){const{state:c}=v(),t=k(),{session:a}=y(),i=c==null?void 0:c.txHash,m=(c==null?void 0:c.items)??[],r=c!=null&&c.creditsAdded&&c.creditsAdded>0?c.creditsAdded:null,l=m[0],h=a!=null&&a.address&&(l!=null&&l.contractAddress)&&(l!=null&&l.itemId)?{owner:a.address,contractAddress:l.contractAddress,itemId:l.itemId}:null,n=P(c!=null&&c.settled?void 0:i,h);b({title:e("seo.success.title"),noindex:!0});const d=m;if(d.length===0)return s.jsx(w,{to:"/assets",replace:!0});const _=d[0],u=!!i&&C(a==null?void 0:a.providerType)?s.jsx("a",{className:"success__receipt",href:`${W}${i}`,target:"_blank",rel:"noreferrer",children:e("success.viewTransaction")}):null;return n!=="confirmed"?s.jsx("div",{className:"success",children:s.jsx("div",{className:"success__status",children:n==="pending"||n==="indexing"?s.jsxs(s.Fragment,{children:[s.jsx("span",{className:"spinner success__spinner","aria-hidden":!0}),s.jsx("h1",{className:"success__title",children:n==="indexing"?e("success.finalizing"):e("success.processing")}),s.jsx("p",{className:"success__sub",children:n==="indexing"?s.jsxs(s.Fragment,{children:[e("success.indexingBefore")," ",d.length===1?s.jsx("strong",{children:_.name}):e("success.itemCount",{count:d.length})," ",e("success.indexingAfter")]}):s.jsxs(s.Fragment,{children:[e("success.confirmingBefore")," ",d.length===1?s.jsx("strong",{children:_.name}):e("success.itemCount",{count:d.length})," ",e("success.confirmingAfter")]})}),u?s.jsx("div",{className:"success__links",children:u}):null]}):n==="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:()=>t("/activity"),children:e("nav.activity")})," ",e("success.timedOutAfter")]}),u?s.jsx("div",{className:"success__links",children:u}):null,s.jsxs("div",{className:"success__actions",children:[s.jsx(j,{variant:"purple",onClick:()=>t("/activity"),children:e("success.viewActivity")}),s.jsx(j,{variant:"ghost",onClick:()=>t("/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")}),u?s.jsx("div",{className:"success__links",children:u}):null,s.jsx("div",{className:"success__actions",children:s.jsx(j,{variant:"purple",onClick:()=>t("/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.jsxs("div",{className:"success-list",children:[r?s.jsxs("div",{className:"success-credits","data-testid":"success-credits",children:[s.jsx(f,{className:"success-credits__ico"}),s.jsxs("p",{className:"success-credits__text",children:[s.jsx("span",{className:"success-credits__amount",children:e("getCredits.creditsAmount",{credits:r,currency:E.name})})," ",s.jsx("span",{className:"success-credits__added",children:e("getCredits.creditsAdded")})]})]}):null,d.map((o,N)=>{const x=o.quantity??1;return s.jsxs("div",{className:"success-list__row",children:[N>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"),x>1?s.jsx("span",{className:"success-row__qty",children:e("cartCheckout.qty",{count:x})}):null]}),o.creator?s.jsx(A,{address:o.creator,className:"success-row__creator",linkToProfile:!0}):null]}),s.jsxs("div",{className:"success-row__price",children:[s.jsx(f,{className:"success-row__price-ico"}),s.jsx("span",{children:S(o.priceCredits*x)})]})]})]},o.id)})]}),u?s.jsx("div",{className:"success__links success-done__receipt",children:u}):null,s.jsxs("div",{className:"success-ctas",children:[s.jsx("button",{className:"success-cta success-cta--ghost",onClick:()=>t("/my-assets"),children:e("success.myAssets")}),s.jsxs("a",{className:"success-cta success-cta--ruby",href:R,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{V as Success,V 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-B-iMukUt.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-B8RM0-JJ.js";import{au as C}from"./NetworkUtil-Xp0fNa8X.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-
|
|
1
|
+
import{r as e,j as c}from"./react-C51i12iP.js";import{s as d,F as r}from"./index-CGNquv7o.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%;":""}
|
|
@@ -0,0 +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-w5dOkonM.js";import{p as Ee,d as B}from"./dcl-schemas-BICTSpB5.js";import{c as ee}from"./react-C51i12iP.js";import{bd as Re}from"./index-CGNquv7o.js";import{a as te,g as re}from"./index-HN6Rk25C.js";import{c as q,e as be}from"./index-CDkTFenk.js";import{s as Ie}from"./sendMetaTransaction-CiO3jI6F.js";import"./sentry-DKBoGDXH.js";import"./intl-CBcMB1D2.js";import"./events-DQ172AOg.js";async function Pe(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 Pe(r);return new ue(t)}const S=new be.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),b=new ge(t.address,t.abi,l),T=await(typeof e=="function"?e(b.populateTransaction):b.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 P=await v.sendTransaction(T);return S.emit(C.SUCCESS,{txHash:P.hash}),P.hash}else{const v=await Ie(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"&ⅇ(c.global===c||c.window===c||c.self===c)&&(e=c);var l,b=2147483647,T=36,v=1,P=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*P>>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,I,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(I=d,f=1,m=T;R>=o&&F("invalid-input"),g=Te(n.charCodeAt(R++)),(g>=T||g>E((b-d)/f))&&F("overflow"),d+=g*f,A=m<=h?v:m>=h+P?P:m-h,!(g<A);m+=T)L=T-A,f>E(b/L)&&F("overflow"),f*=L;u=a.length+1,h=Z(d-I,u,I==0),E(d/u)>b-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,I,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=b,h=0;h<g;++h)f=n[h],f>=a&&f<w&&(w=f);for(A=u+1,w-a>E((b-o)/A)&&F("overflow"),o+=(w-a)*A,a=w,h=0;h<g;++h)if(f=n[h],f<a&&++o>b&&F("overflow"),f==a){for(x=o,R=T;I=R<=y?v:R>=y+P?P:R-y,!(x<I);R+=T)j=x-I,L=T-I,m.push(O(Y(I+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 tt{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{tt as TradeService};
|