@multiversx/sdk-dapp 5.0.0 → 5.0.2-alpha.1
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/README.md +26 -18
- package/out/__chunks__/{chunk-I6BXGQLQ.mjs → chunk-2D4DUCY4.mjs} +2 -2
- package/out/__chunks__/chunk-2HSERTN3.mjs +2 -0
- package/out/__chunks__/{chunk-LJ5JGAYL.mjs → chunk-2ONA7QPD.mjs} +2 -2
- package/out/__chunks__/chunk-2RRXUGLI.mjs +2 -0
- package/out/__chunks__/{chunk-3NFKZZ7W.mjs → chunk-33D26THL.mjs} +2 -2
- package/out/__chunks__/{chunk-VXLJWKLG.mjs → chunk-3AC72XDZ.mjs} +2 -2
- package/out/__chunks__/{chunk-CJQAA4EP.mjs → chunk-3HHV6IM7.mjs} +2 -2
- package/out/__chunks__/chunk-53X3CO6E.mjs +2 -0
- package/out/__chunks__/{chunk-4QDHGYT4.mjs → chunk-5MC44CTJ.mjs} +2 -2
- package/out/__chunks__/{chunk-XPYJSDNF.mjs → chunk-5TVRGEID.mjs} +2 -2
- package/out/__chunks__/{chunk-BOAJJ4FX.mjs → chunk-5VEB2Q3E.mjs} +2 -2
- package/out/__chunks__/{chunk-CVPP4HQE.mjs → chunk-6FGDARXH.mjs} +2 -2
- package/out/__chunks__/{chunk-BQ2I655N.mjs → chunk-6XOHFAL4.mjs} +2 -2
- package/out/__chunks__/{chunk-IXUYZYD2.mjs → chunk-AK44E24X.mjs} +2 -2
- package/out/__chunks__/{chunk-U34BNBOX.mjs → chunk-APRKCU5W.mjs} +2 -2
- package/out/__chunks__/{chunk-2SIHYJET.mjs → chunk-ATOIEDNS.mjs} +2 -2
- package/out/__chunks__/{chunk-FZFKEGPM.mjs → chunk-B6UQJ7RN.mjs} +2 -2
- package/out/__chunks__/chunk-BT27ZSJC.mjs +2 -0
- package/out/__chunks__/{chunk-JZ7434LN.mjs → chunk-BU6PLF6D.mjs} +2 -2
- package/out/__chunks__/{chunk-PHNC5JMP.mjs → chunk-C43MOZMC.mjs} +2 -2
- package/out/__chunks__/chunk-C43MOZMC.mjs.map +7 -0
- package/out/__chunks__/{chunk-6G7ATMU7.mjs → chunk-CBKDKXYT.mjs} +2 -2
- package/out/__chunks__/{chunk-INWUHEQN.mjs → chunk-CWENDDPJ.mjs} +2 -2
- package/out/__chunks__/chunk-DLWDO7M6.mjs +2 -0
- package/out/__chunks__/chunk-DLWDO7M6.mjs.map +7 -0
- package/out/__chunks__/chunk-DRETVXSY.mjs +2 -0
- package/out/__chunks__/{chunk-RBUHL65H.mjs → chunk-E53QIC6C.mjs} +2 -2
- package/out/__chunks__/{chunk-KSMSBTTQ.mjs → chunk-EFUXCZER.mjs} +2 -2
- package/out/__chunks__/{chunk-AF2QSDSV.mjs → chunk-FAOTAY77.mjs} +2 -2
- package/out/__chunks__/{chunk-NPZ5PO2W.mjs → chunk-FRPCFHSV.mjs} +2 -2
- package/out/__chunks__/{chunk-2EFXW7IG.mjs → chunk-HCROEWHT.mjs} +2 -2
- package/out/__chunks__/{chunk-4YU2DWHA.mjs → chunk-HTG5MOLD.mjs} +2 -2
- package/out/__chunks__/{chunk-ZWVYAOKB.mjs → chunk-ICDD7V53.mjs} +2 -2
- package/out/__chunks__/{chunk-NQ6SJRHZ.mjs → chunk-IKVKOGWF.mjs} +2 -2
- package/out/__chunks__/{chunk-P32DZ2CO.mjs → chunk-JEB6OIJ7.mjs} +2 -2
- package/out/__chunks__/chunk-JHG3QIDR.mjs +2 -0
- package/out/__chunks__/{chunk-H7BJSM6C.mjs → chunk-JLVWBFTU.mjs} +2 -2
- package/out/__chunks__/{chunk-MRV6OG7P.mjs → chunk-K4O6NCSM.mjs} +2 -2
- package/out/__chunks__/{chunk-O2DO3WJJ.mjs → chunk-KARM6PTO.mjs} +2 -2
- package/out/__chunks__/{chunk-V2C7APME.mjs → chunk-KEE42WYL.mjs} +2 -2
- package/out/__chunks__/{chunk-42LFLNPA.mjs → chunk-KT7RICHS.mjs} +2 -2
- package/out/__chunks__/chunk-LN5BGLT5.mjs +2 -0
- package/out/__chunks__/{chunk-GFTTAANM.mjs → chunk-MC23BEFI.mjs} +2 -2
- package/out/__chunks__/chunk-MFBGRZPB.mjs +2 -0
- package/out/__chunks__/{chunk-QSYQIJEO.mjs → chunk-MGF5WOBM.mjs} +2 -2
- package/out/__chunks__/{chunk-RFKBUN7S.mjs → chunk-MMJFQNPX.mjs} +2 -2
- package/out/__chunks__/{chunk-GT2HLNE7.mjs → chunk-MPLLWF75.mjs} +2 -2
- package/out/__chunks__/{chunk-254WMLVS.mjs → chunk-NCVIHQO4.mjs} +2 -2
- package/out/__chunks__/{chunk-VQAKIVIO.mjs → chunk-NEPD4C5Y.mjs} +2 -2
- package/out/__chunks__/{chunk-4TZC3NF3.mjs → chunk-NGHOVWEO.mjs} +2 -2
- package/out/__chunks__/{chunk-FAOCLLIW.mjs → chunk-NXJJ2A6Q.mjs} +2 -2
- package/out/__chunks__/{chunk-SLH6IQJJ.mjs → chunk-OWBEAOLJ.mjs} +2 -2
- package/out/__chunks__/{chunk-BHAZ2W52.mjs → chunk-OWZ7T4JN.mjs} +2 -2
- package/out/__chunks__/chunk-PBBTJFMG.mjs +2 -0
- package/out/__chunks__/chunk-PHEK22HL.mjs +2 -0
- package/out/__chunks__/{chunk-2S5FRZJR.mjs → chunk-PL7G674F.mjs} +2 -2
- package/out/__chunks__/{chunk-HXXZKQRJ.mjs → chunk-PQUTSIC4.mjs} +2 -2
- package/out/__chunks__/{chunk-BVLXVOIC.mjs → chunk-PYQHSRH3.mjs} +2 -2
- package/out/__chunks__/chunk-QMEKXQAU.mjs +2 -0
- package/out/__chunks__/chunk-R35LPX6Q.mjs +2 -0
- package/out/__chunks__/{chunk-L4QPPHVR.mjs.map → chunk-R35LPX6Q.mjs.map} +1 -1
- package/out/__chunks__/chunk-R725UMBR.mjs +2 -0
- package/out/__chunks__/{chunk-ISPOZQQO.mjs → chunk-RGBXTDJ7.mjs} +2 -2
- package/out/__chunks__/chunk-RWNPPIFD.mjs +2 -0
- package/out/__chunks__/{chunk-6P7EXGAB.mjs → chunk-SCRYMTTV.mjs} +2 -2
- package/out/__chunks__/{chunk-ID7WYMJZ.mjs → chunk-T5KTF5Z5.mjs} +2 -2
- package/out/__chunks__/{chunk-FSCOQWQN.mjs → chunk-UBINPM6F.mjs} +2 -2
- package/out/__chunks__/{chunk-745QCLQC.mjs → chunk-UC4MBL7R.mjs} +2 -2
- package/out/__chunks__/{chunk-B7ZKW5ML.mjs → chunk-UFMXBWCD.mjs} +2 -2
- package/out/__chunks__/{chunk-NJPTQNCT.mjs → chunk-UFRAVF3S.mjs} +2 -2
- package/out/__chunks__/{chunk-BG6QTPZ4.mjs → chunk-UGI3S542.mjs} +2 -2
- package/out/__chunks__/{chunk-4XP7BVJD.mjs → chunk-UPZSSHAY.mjs} +2 -2
- package/out/__chunks__/chunk-UX6FJB7S.mjs +2 -0
- package/out/__chunks__/{chunk-6RGWVDNQ.mjs → chunk-VJJT22PO.mjs} +2 -2
- package/out/__chunks__/chunk-VN3A7GN4.mjs +2 -0
- package/out/__chunks__/{chunk-WPXNKIUP.mjs.map → chunk-VN3A7GN4.mjs.map} +3 -3
- package/out/__chunks__/chunk-VO7TNUQ6.mjs +2 -0
- package/out/__chunks__/chunk-VO7TNUQ6.mjs.map +7 -0
- package/out/__chunks__/chunk-VSPA6MX4.mjs +2 -0
- package/out/__chunks__/{chunk-6D2RBTVV.mjs → chunk-VU3NDTLL.mjs} +2 -2
- package/out/__chunks__/{chunk-HUITKXBO.mjs → chunk-W77E3MVG.mjs} +2 -2
- package/out/__chunks__/chunk-WPFFITFH.mjs +2 -0
- package/out/__chunks__/chunk-XNPGQK42.mjs +2 -0
- package/out/__chunks__/{chunk-VFAKQ7NM.mjs → chunk-XRBOH3AB.mjs} +2 -2
- package/out/__chunks__/{chunk-D5SD7UPB.mjs → chunk-Y3FER7B6.mjs} +2 -2
- package/out/__chunks__/{chunk-S4WKQEYF.mjs → chunk-YLJTXHF4.mjs} +2 -2
- package/out/__chunks__/{chunk-YO3ATAA6.mjs → chunk-YQEOOE3H.mjs} +2 -2
- package/out/__chunks__/{chunk-YKRSCVRE.mjs → chunk-ZHAYVRGH.mjs} +2 -2
- package/out/__mocks__/data/index.mjs +1 -1
- package/out/__mocks__/index.mjs +1 -1
- package/out/__mocks__/server.mjs +1 -1
- package/out/apiCalls/account/getScamAddressData.mjs +1 -1
- package/out/apiCalls/configuration/getCleanApiAddress.mjs +1 -1
- package/out/apiCalls/configuration/getGasStationMetadata.mjs +1 -1
- package/out/apiCalls/index.mjs +1 -1
- package/out/apiCalls/tokens/getPersistedTokenDetails.mjs +1 -1
- package/out/apiCalls/tokens/getTokenDetails.mjs +1 -1
- package/out/apiCalls/tokens/index.mjs +1 -1
- package/out/apiCalls/transactions/getServerTransactionsByHashes.mjs +1 -1
- package/out/apiCalls/transactions/getTransactionByHash.mjs +1 -1
- package/out/apiCalls/transactions/getTransactionsByHashes.mjs +1 -1
- package/out/constants/browser.constants.mjs +1 -1
- package/out/constants/index.mjs +1 -1
- package/out/constants/storage.constants.mjs +1 -1
- package/out/constants/window.constants.mjs +1 -1
- package/out/controllers/TransactionsHistoryController/TransactionsHistoryController.mjs +1 -1
- package/out/controllers/TransactionsHistoryController/index.mjs +1 -1
- package/out/controllers/TransactionsTableController/TransactionsTableController.mjs +1 -1
- package/out/controllers/TransactionsTableController/index.mjs +1 -1
- package/out/index.mjs +1 -1
- package/out/lib/sdkWebviewProvider.d.ts +1 -0
- package/out/lib/sdkWebviewProvider.js +6 -0
- package/out/lib/sdkWebviewProvider.js.map +1 -0
- package/out/lib/sdkWebviewProvider.mjs +2 -0
- package/out/lib/sdkWebviewProvider.mjs.map +7 -0
- package/out/managers/LogoutManager/LogoutManager.mjs +1 -1
- package/out/managers/NotificationsFeedManager/NotificationsFeedManager.mjs +1 -1
- package/out/managers/NotificationsFeedManager/index.mjs +1 -1
- package/out/managers/TransactionManager/TransactionManager.js +15 -5
- package/out/managers/TransactionManager/TransactionManager.js.map +1 -1
- package/out/managers/TransactionManager/TransactionManager.mjs +1 -1
- package/out/managers/TransactionManager/helpers/getAreTransactionsCorssShards.mjs +1 -1
- package/out/managers/TransactionManager/helpers/getToastDuration.mjs +1 -1
- package/out/managers/TransactionManager/index.mjs +1 -1
- package/out/managers/UnlockPanelManager/UnlockPanelManager.mjs +1 -1
- package/out/managers/UnlockPanelManager/index.mjs +1 -1
- package/out/managers/index.mjs +1 -1
- package/out/managers/internal/LedgerConnectStateManager/LedgerConnectStateManager.mjs +1 -1
- package/out/managers/internal/LedgerConnectStateManager/index.mjs +1 -1
- package/out/managers/internal/LedgerIdleStateManager/LedgerIdleStateManager.mjs +1 -1
- package/out/managers/internal/PendingTransactionsStateManager/PendingTransactionsStateManager.mjs +1 -1
- package/out/managers/internal/PendingTransactionsStateManager/index.mjs +1 -1
- package/out/managers/internal/SidePanelBaseManager/SidePanelBaseManager.mjs +1 -1
- package/out/managers/internal/SidePanelBaseManager/index.mjs +1 -1
- package/out/managers/internal/SignTransactionsStateManager/SignTransactionsStateManager.mjs +1 -1
- package/out/managers/internal/SignTransactionsStateManager/index.mjs +1 -1
- package/out/managers/internal/ToastManager/ToastManager.mjs +1 -1
- package/out/managers/internal/ToastManager/helpers/LifetimeManager.mjs +1 -1
- package/out/managers/internal/ToastManager/helpers/createToastsFromTransactions.mjs +1 -1
- package/out/managers/internal/UIBaseManager/UIBaseManager.mjs +1 -1
- package/out/managers/internal/WalletConnectStateManager/WalletConnectStateManager.mjs +1 -1
- package/out/managers/internal/WalletConnectStateManager/index.mjs +1 -1
- package/out/managers/internal/index.mjs +1 -1
- package/out/methods/account/getAccount.mjs +1 -1
- package/out/methods/account/getAccountInfo.mjs +1 -1
- package/out/methods/account/getAddress.mjs +1 -1
- package/out/methods/account/getIsLoggedIn.mjs +1 -1
- package/out/methods/account/getLatestNonce.mjs +1 -1
- package/out/methods/initApp/gastStationMetadata/setGasStationMetadata.mjs +1 -1
- package/out/methods/initApp/initApp.mjs +1 -1
- package/out/methods/initApp/initApp.mjs.map +1 -1
- package/out/methods/initApp/websocket/initializeWebsocketConnection.mjs +1 -1
- package/out/methods/initApp/websocket/registerWebsocket.mjs +1 -1
- package/out/methods/loginInfo/getLoginInfo.mjs +1 -1
- package/out/methods/network/getEgldLabel.mjs +1 -1
- package/out/methods/network/getExplorerAddress.mjs +1 -1
- package/out/methods/network/getNetworkConfig.mjs +1 -1
- package/out/methods/trackTransactions/helpers/checkTransactionStatus/checkBatch.mjs +1 -1
- package/out/methods/trackTransactions/helpers/checkTransactionStatus/checkTransactionStatus.mjs +1 -1
- package/out/methods/trackTransactions/helpers/checkTransactionStatus/index.mjs +1 -1
- package/out/methods/trackTransactions/helpers/checkTransactionStatus/manageFailedTransactions.mjs +1 -1
- package/out/methods/trackTransactions/helpers/getPollingInterval.mjs +1 -1
- package/out/methods/trackTransactions/trackTransactions.mjs +1 -1
- package/out/methods/transactions/getFailedTransactions.mjs +1 -1
- package/out/methods/transactions/getFailedTransactionsSessions.mjs +1 -1
- package/out/methods/transactions/getPendingTransactions.mjs +1 -1
- package/out/methods/transactions/getPendingTransactionsSessions.mjs +1 -1
- package/out/methods/transactions/getSuccessfulTransactions.mjs +1 -1
- package/out/methods/transactions/getSuccessfulTransactionsSessions.mjs +1 -1
- package/out/methods/transactions/getTransactionSessions.mjs +1 -1
- package/out/providers/DappProvider/DappProvider.mjs +1 -1
- package/out/providers/DappProvider/helpers/login/helpers/accountLogin.mjs +1 -1
- package/out/providers/DappProvider/helpers/login/helpers/extractAddressFromToken.mjs +1 -1
- package/out/providers/DappProvider/helpers/login/helpers/getAccountFromToken.mjs +1 -1
- package/out/providers/DappProvider/helpers/login/helpers/getModifiedLoginToken.mjs +1 -1
- package/out/providers/DappProvider/helpers/login/login.mjs +1 -1
- package/out/providers/DappProvider/helpers/logout/logout.mjs +1 -1
- package/out/providers/DappProvider/helpers/signErrors/handleSignError.mjs +1 -1
- package/out/providers/DappProvider/helpers/signMessage/signMessageWithProvider.mjs +1 -1
- package/out/providers/DappProvider/helpers/signTransactions/signTransactionsWithProvider.mjs +1 -1
- package/out/providers/DappProvider/index.mjs +1 -1
- package/out/providers/ProviderFactory.js +1 -5
- package/out/providers/ProviderFactory.js.map +1 -1
- package/out/providers/ProviderFactory.mjs +1 -1
- package/out/providers/helpers/accountProvider.mjs +1 -1
- package/out/providers/helpers/cancelCrossWindowAction.mjs +1 -1
- package/out/providers/helpers/restoreProvider.js +5 -2
- package/out/providers/helpers/restoreProvider.js.map +1 -1
- package/out/providers/helpers/restoreProvider.mjs +1 -1
- package/out/providers/index.mjs +1 -1
- package/out/providers/strategies/BaseProviderStrategy/BaseProviderStrategy.mjs +1 -1
- package/out/providers/strategies/CrossWindowProviderStrategy/CrossWindowProviderStrategy.mjs +1 -1
- package/out/providers/strategies/CrossWindowProviderStrategy/index.mjs +1 -1
- package/out/providers/strategies/ExtensionProviderStrategy/ExtensionProviderStrategy.mjs +1 -1
- package/out/providers/strategies/ExtensionProviderStrategy/index.mjs +1 -1
- package/out/providers/strategies/IframeProviderStrategy/IframeProviderStrategy.mjs +1 -1
- package/out/providers/strategies/IframeProviderStrategy/index.mjs +1 -1
- package/out/providers/strategies/LedgerProviderStrategy/LedgerProviderStrategy.mjs +1 -1
- package/out/providers/strategies/LedgerProviderStrategy/helpers/authenticateLedgerAccount.mjs +1 -1
- package/out/providers/strategies/LedgerProviderStrategy/helpers/getAuthTokenText.mjs +1 -1
- package/out/providers/strategies/LedgerProviderStrategy/helpers/getLedgerConfiguration.mjs +1 -1
- package/out/providers/strategies/LedgerProviderStrategy/helpers/getLedgerProvider.mjs +1 -1
- package/out/providers/strategies/LedgerProviderStrategy/helpers/getLedgerVersionOptions.mjs +1 -1
- package/out/providers/strategies/LedgerProviderStrategy/helpers/index.mjs +1 -1
- package/out/providers/strategies/LedgerProviderStrategy/helpers/initializeLedgerProvider.mjs +1 -1
- package/out/providers/strategies/LedgerProviderStrategy/helpers/signLedgerMessage.mjs +1 -1
- package/out/providers/strategies/LedgerProviderStrategy/helpers/updateAccountsList/index.mjs +1 -1
- package/out/providers/strategies/LedgerProviderStrategy/helpers/updateAccountsList/updateAccountsList.mjs +1 -1
- package/out/providers/strategies/LedgerProviderStrategy/index.mjs +1 -1
- package/out/providers/strategies/WalletConnectProviderStrategy/WalletConnectProviderStrategy.mjs +1 -1
- package/out/providers/strategies/WalletConnectProviderStrategy/index.mjs +1 -1
- package/out/providers/strategies/WebviewProviderStrategy/WebviewClient/WebviewClient.mjs +1 -1
- package/out/providers/strategies/WebviewProviderStrategy/WebviewClient/index.mjs +1 -1
- package/out/providers/strategies/WebviewProviderStrategy/WebviewProviderStrategy.mjs +1 -1
- package/out/providers/strategies/WebviewProviderStrategy/index.mjs +1 -1
- package/out/providers/strategies/helpers/getPendingTransactionsHandlers.mjs +1 -1
- package/out/providers/strategies/helpers/index.mjs +1 -1
- package/out/providers/strategies/helpers/signMessage/signMessage.mjs +1 -1
- package/out/providers/strategies/helpers/signTransactions/helpers/calculateFeeLimit.mjs +1 -1
- package/out/providers/strategies/helpers/signTransactions/helpers/getCommonData/getCommonData.mjs +1 -1
- package/out/providers/strategies/helpers/signTransactions/helpers/getCommonData/helpers/getExtractTransactionsInfo.mjs +1 -1
- package/out/providers/strategies/helpers/signTransactions/helpers/getFeeData.mjs +1 -1
- package/out/providers/strategies/helpers/signTransactions/helpers/guardTransactions/guardTransactions.mjs +1 -1
- package/out/providers/strategies/helpers/signTransactions/signTransactions.mjs +1 -1
- package/out/providers/strategies/index.mjs +1 -1
- package/out/react/account/useGetAccount.mjs +1 -1
- package/out/react/account/useGetAccountInfo.mjs +1 -1
- package/out/react/account/useGetIsLoggedIn.mjs +1 -1
- package/out/react/account/useGetLatestNonce.mjs +1 -1
- package/out/react/index.mjs +1 -1
- package/out/react/loginInfo/useGetLoginInfo.mjs +1 -1
- package/out/react/network/useGetNetworkConfig.mjs +1 -1
- package/out/react/store/getReactStore.mjs +1 -1
- package/out/react/store/useSelector.mjs +1 -1
- package/out/react/transactions/useGetFailedTransactions.mjs +1 -1
- package/out/react/transactions/useGetFailedTransactionsSessions.mjs +1 -1
- package/out/react/transactions/useGetPendingTransactions.mjs +1 -1
- package/out/react/transactions/useGetPendingTransactionsSessions.mjs +1 -1
- package/out/react/transactions/useGetSuccessfulTransactions.mjs +1 -1
- package/out/react/transactions/useGetSuccessfulTransactionsSessions.mjs +1 -1
- package/out/react/transactions/useGetTransactionSessions.mjs +1 -1
- package/out/services/index.mjs +1 -1
- package/out/services/nativeAuth/index.mjs +1 -1
- package/out/services/nativeAuth/methods/buildNativeAuthConfig.mjs +1 -1
- package/out/services/nativeAuth/methods/getDefaultNativeAuthConfig.mjs +1 -1
- package/out/services/nativeAuth/methods/index.mjs +1 -1
- package/out/services/nativeAuth/nativeAuth.mjs +1 -1
- package/out/store/actions/account/accountActions.mjs +1 -1
- package/out/store/actions/account/index.mjs +1 -1
- package/out/store/actions/cache/cacheActions.mjs +1 -1
- package/out/store/actions/cache/index.mjs +1 -1
- package/out/store/actions/config/configActions.mjs +1 -1
- package/out/store/actions/config/index.mjs +1 -1
- package/out/store/actions/index.mjs +1 -1
- package/out/store/actions/loginInfo/loginInfoActions.mjs +1 -1
- package/out/store/actions/network/index.mjs +1 -1
- package/out/store/actions/network/initializeNetwork.mjs +1 -1
- package/out/store/actions/network/networkActions.mjs +1 -1
- package/out/store/actions/sharedActions/index.mjs +1 -1
- package/out/store/actions/sharedActions/sharedActions.mjs +1 -1
- package/out/store/actions/toasts/index.mjs +1 -1
- package/out/store/actions/toasts/toastsActions.mjs +1 -1
- package/out/store/actions/transactions/transactionsActions.mjs +1 -1
- package/out/store/actions/ui/index.mjs +1 -1
- package/out/store/actions/ui/uiActions.mjs +1 -1
- package/out/store/middleware/applyMiddlewares.mjs +1 -1
- package/out/store/middleware/index.mjs +1 -1
- package/out/store/middleware/logoutMiddleware.mjs +1 -1
- package/out/store/storage/index.mjs +1 -1
- package/out/store/storage/storageCallback.mjs +1 -1
- package/out/store/store.mjs +1 -1
- package/out/utils/ComponentFactory.mjs +1 -1
- package/out/utils/account/index.mjs +1 -1
- package/out/utils/account/refreshAccount.mjs +1 -1
- package/out/utils/account/refreshNativeAuthTokenLogin.mjs +1 -1
- package/out/utils/index.mjs +1 -1
- package/out/utils/transactions/getActiveTransactionsStatus.mjs +1 -1
- package/out/utils/transactions/getInterpretedTransaction/getInterpretedTransaction.mjs +1 -1
- package/out/utils/transactions/getInterpretedTransaction/helpers/getLockedAccountName.mjs +1 -1
- package/out/utils/transactions/getInterpretedTransaction/helpers/getReceiptMessage.mjs +1 -1
- package/out/utils/transactions/getInterpretedTransaction/helpers/getShardText.mjs +1 -1
- package/out/utils/transactions/getInterpretedTransaction/helpers/getTransactionIconInfo.mjs +1 -1
- package/out/utils/transactions/getInterpretedTransaction/helpers/getTransactionMessages.mjs +1 -1
- package/out/utils/transactions/getInterpretedTransaction/helpers/index.mjs +1 -1
- package/out/utils/transactions/getInterpretedTransaction/index.mjs +1 -1
- package/out/utils/transactions/getTransactionsHistory/getTransactionsHistory.mjs +1 -1
- package/out/utils/transactions/getTransactionsHistory/helpers/getCachedTransactionListItem.mjs +1 -1
- package/out/utils/transactions/getTransactionsHistory/helpers/index.mjs +1 -1
- package/out/utils/transactions/getTransactionsHistory/helpers/mapServerTransactionsToListItems.mjs +1 -1
- package/out/utils/transactions/getTransactionsHistory/index.mjs +1 -1
- package/out/utils/transactions/index.mjs +1 -1
- package/out/utils/visual/index.mjs +1 -1
- package/out/utils/visual/switchTheme.mjs +1 -1
- package/out/utils/window/getIsInIframe.mjs +1 -1
- package/out/utils/window/getWindowParentOrigin.mjs +1 -1
- package/out/utils/window/index.mjs +1 -1
- package/package.json +2 -2
- package/out/__chunks__/chunk-4AKPP7B3.mjs +0 -2
- package/out/__chunks__/chunk-4YZQBDUE.mjs +0 -2
- package/out/__chunks__/chunk-4ZZJX7E7.mjs +0 -2
- package/out/__chunks__/chunk-5LB2KNTP.mjs +0 -2
- package/out/__chunks__/chunk-5OM6KD5S.mjs +0 -2
- package/out/__chunks__/chunk-6GNNYFMN.mjs +0 -2
- package/out/__chunks__/chunk-6ZL2QC74.mjs +0 -2
- package/out/__chunks__/chunk-CBF72LQF.mjs +0 -2
- package/out/__chunks__/chunk-CIY7IH2N.mjs +0 -2
- package/out/__chunks__/chunk-DGYPNF4O.mjs +0 -2
- package/out/__chunks__/chunk-E7BYYSVM.mjs +0 -2
- package/out/__chunks__/chunk-I37JLMZH.mjs +0 -2
- package/out/__chunks__/chunk-IBSC2B7Q.mjs +0 -2
- package/out/__chunks__/chunk-L4QPPHVR.mjs +0 -2
- package/out/__chunks__/chunk-N2RYRHHL.mjs +0 -2
- package/out/__chunks__/chunk-PHNC5JMP.mjs.map +0 -7
- package/out/__chunks__/chunk-RSUHZ7IH.mjs +0 -2
- package/out/__chunks__/chunk-TNXSVX5O.mjs +0 -2
- package/out/__chunks__/chunk-TNXSVX5O.mjs.map +0 -7
- package/out/__chunks__/chunk-WPXNKIUP.mjs +0 -2
- package/out/__chunks__/chunk-YA5U6YEL.mjs +0 -2
- package/out/__chunks__/chunk-Z4OHB36I.mjs +0 -2
- /package/out/__chunks__/{chunk-I6BXGQLQ.mjs.map → chunk-2D4DUCY4.mjs.map} +0 -0
- /package/out/__chunks__/{chunk-6GNNYFMN.mjs.map → chunk-2HSERTN3.mjs.map} +0 -0
- /package/out/__chunks__/{chunk-LJ5JGAYL.mjs.map → chunk-2ONA7QPD.mjs.map} +0 -0
- /package/out/__chunks__/{chunk-IBSC2B7Q.mjs.map → chunk-2RRXUGLI.mjs.map} +0 -0
- /package/out/__chunks__/{chunk-3NFKZZ7W.mjs.map → chunk-33D26THL.mjs.map} +0 -0
- /package/out/__chunks__/{chunk-VXLJWKLG.mjs.map → chunk-3AC72XDZ.mjs.map} +0 -0
- /package/out/__chunks__/{chunk-CJQAA4EP.mjs.map → chunk-3HHV6IM7.mjs.map} +0 -0
- /package/out/__chunks__/{chunk-RSUHZ7IH.mjs.map → chunk-53X3CO6E.mjs.map} +0 -0
- /package/out/__chunks__/{chunk-4QDHGYT4.mjs.map → chunk-5MC44CTJ.mjs.map} +0 -0
- /package/out/__chunks__/{chunk-XPYJSDNF.mjs.map → chunk-5TVRGEID.mjs.map} +0 -0
- /package/out/__chunks__/{chunk-BOAJJ4FX.mjs.map → chunk-5VEB2Q3E.mjs.map} +0 -0
- /package/out/__chunks__/{chunk-CVPP4HQE.mjs.map → chunk-6FGDARXH.mjs.map} +0 -0
- /package/out/__chunks__/{chunk-BQ2I655N.mjs.map → chunk-6XOHFAL4.mjs.map} +0 -0
- /package/out/__chunks__/{chunk-IXUYZYD2.mjs.map → chunk-AK44E24X.mjs.map} +0 -0
- /package/out/__chunks__/{chunk-U34BNBOX.mjs.map → chunk-APRKCU5W.mjs.map} +0 -0
- /package/out/__chunks__/{chunk-2SIHYJET.mjs.map → chunk-ATOIEDNS.mjs.map} +0 -0
- /package/out/__chunks__/{chunk-FZFKEGPM.mjs.map → chunk-B6UQJ7RN.mjs.map} +0 -0
- /package/out/__chunks__/{chunk-N2RYRHHL.mjs.map → chunk-BT27ZSJC.mjs.map} +0 -0
- /package/out/__chunks__/{chunk-JZ7434LN.mjs.map → chunk-BU6PLF6D.mjs.map} +0 -0
- /package/out/__chunks__/{chunk-6G7ATMU7.mjs.map → chunk-CBKDKXYT.mjs.map} +0 -0
- /package/out/__chunks__/{chunk-INWUHEQN.mjs.map → chunk-CWENDDPJ.mjs.map} +0 -0
- /package/out/__chunks__/{chunk-Z4OHB36I.mjs.map → chunk-DRETVXSY.mjs.map} +0 -0
- /package/out/__chunks__/{chunk-RBUHL65H.mjs.map → chunk-E53QIC6C.mjs.map} +0 -0
- /package/out/__chunks__/{chunk-KSMSBTTQ.mjs.map → chunk-EFUXCZER.mjs.map} +0 -0
- /package/out/__chunks__/{chunk-AF2QSDSV.mjs.map → chunk-FAOTAY77.mjs.map} +0 -0
- /package/out/__chunks__/{chunk-NPZ5PO2W.mjs.map → chunk-FRPCFHSV.mjs.map} +0 -0
- /package/out/__chunks__/{chunk-2EFXW7IG.mjs.map → chunk-HCROEWHT.mjs.map} +0 -0
- /package/out/__chunks__/{chunk-4YU2DWHA.mjs.map → chunk-HTG5MOLD.mjs.map} +0 -0
- /package/out/__chunks__/{chunk-ZWVYAOKB.mjs.map → chunk-ICDD7V53.mjs.map} +0 -0
- /package/out/__chunks__/{chunk-NQ6SJRHZ.mjs.map → chunk-IKVKOGWF.mjs.map} +0 -0
- /package/out/__chunks__/{chunk-P32DZ2CO.mjs.map → chunk-JEB6OIJ7.mjs.map} +0 -0
- /package/out/__chunks__/{chunk-CIY7IH2N.mjs.map → chunk-JHG3QIDR.mjs.map} +0 -0
- /package/out/__chunks__/{chunk-H7BJSM6C.mjs.map → chunk-JLVWBFTU.mjs.map} +0 -0
- /package/out/__chunks__/{chunk-MRV6OG7P.mjs.map → chunk-K4O6NCSM.mjs.map} +0 -0
- /package/out/__chunks__/{chunk-O2DO3WJJ.mjs.map → chunk-KARM6PTO.mjs.map} +0 -0
- /package/out/__chunks__/{chunk-V2C7APME.mjs.map → chunk-KEE42WYL.mjs.map} +0 -0
- /package/out/__chunks__/{chunk-42LFLNPA.mjs.map → chunk-KT7RICHS.mjs.map} +0 -0
- /package/out/__chunks__/{chunk-5LB2KNTP.mjs.map → chunk-LN5BGLT5.mjs.map} +0 -0
- /package/out/__chunks__/{chunk-GFTTAANM.mjs.map → chunk-MC23BEFI.mjs.map} +0 -0
- /package/out/__chunks__/{chunk-I37JLMZH.mjs.map → chunk-MFBGRZPB.mjs.map} +0 -0
- /package/out/__chunks__/{chunk-QSYQIJEO.mjs.map → chunk-MGF5WOBM.mjs.map} +0 -0
- /package/out/__chunks__/{chunk-RFKBUN7S.mjs.map → chunk-MMJFQNPX.mjs.map} +0 -0
- /package/out/__chunks__/{chunk-GT2HLNE7.mjs.map → chunk-MPLLWF75.mjs.map} +0 -0
- /package/out/__chunks__/{chunk-254WMLVS.mjs.map → chunk-NCVIHQO4.mjs.map} +0 -0
- /package/out/__chunks__/{chunk-VQAKIVIO.mjs.map → chunk-NEPD4C5Y.mjs.map} +0 -0
- /package/out/__chunks__/{chunk-4TZC3NF3.mjs.map → chunk-NGHOVWEO.mjs.map} +0 -0
- /package/out/__chunks__/{chunk-FAOCLLIW.mjs.map → chunk-NXJJ2A6Q.mjs.map} +0 -0
- /package/out/__chunks__/{chunk-SLH6IQJJ.mjs.map → chunk-OWBEAOLJ.mjs.map} +0 -0
- /package/out/__chunks__/{chunk-BHAZ2W52.mjs.map → chunk-OWZ7T4JN.mjs.map} +0 -0
- /package/out/__chunks__/{chunk-4AKPP7B3.mjs.map → chunk-PBBTJFMG.mjs.map} +0 -0
- /package/out/__chunks__/{chunk-YA5U6YEL.mjs.map → chunk-PHEK22HL.mjs.map} +0 -0
- /package/out/__chunks__/{chunk-2S5FRZJR.mjs.map → chunk-PL7G674F.mjs.map} +0 -0
- /package/out/__chunks__/{chunk-HXXZKQRJ.mjs.map → chunk-PQUTSIC4.mjs.map} +0 -0
- /package/out/__chunks__/{chunk-BVLXVOIC.mjs.map → chunk-PYQHSRH3.mjs.map} +0 -0
- /package/out/__chunks__/{chunk-5OM6KD5S.mjs.map → chunk-QMEKXQAU.mjs.map} +0 -0
- /package/out/__chunks__/{chunk-E7BYYSVM.mjs.map → chunk-R725UMBR.mjs.map} +0 -0
- /package/out/__chunks__/{chunk-ISPOZQQO.mjs.map → chunk-RGBXTDJ7.mjs.map} +0 -0
- /package/out/__chunks__/{chunk-4ZZJX7E7.mjs.map → chunk-RWNPPIFD.mjs.map} +0 -0
- /package/out/__chunks__/{chunk-6P7EXGAB.mjs.map → chunk-SCRYMTTV.mjs.map} +0 -0
- /package/out/__chunks__/{chunk-ID7WYMJZ.mjs.map → chunk-T5KTF5Z5.mjs.map} +0 -0
- /package/out/__chunks__/{chunk-FSCOQWQN.mjs.map → chunk-UBINPM6F.mjs.map} +0 -0
- /package/out/__chunks__/{chunk-745QCLQC.mjs.map → chunk-UC4MBL7R.mjs.map} +0 -0
- /package/out/__chunks__/{chunk-B7ZKW5ML.mjs.map → chunk-UFMXBWCD.mjs.map} +0 -0
- /package/out/__chunks__/{chunk-NJPTQNCT.mjs.map → chunk-UFRAVF3S.mjs.map} +0 -0
- /package/out/__chunks__/{chunk-BG6QTPZ4.mjs.map → chunk-UGI3S542.mjs.map} +0 -0
- /package/out/__chunks__/{chunk-4XP7BVJD.mjs.map → chunk-UPZSSHAY.mjs.map} +0 -0
- /package/out/__chunks__/{chunk-4YZQBDUE.mjs.map → chunk-UX6FJB7S.mjs.map} +0 -0
- /package/out/__chunks__/{chunk-6RGWVDNQ.mjs.map → chunk-VJJT22PO.mjs.map} +0 -0
- /package/out/__chunks__/{chunk-DGYPNF4O.mjs.map → chunk-VSPA6MX4.mjs.map} +0 -0
- /package/out/__chunks__/{chunk-6D2RBTVV.mjs.map → chunk-VU3NDTLL.mjs.map} +0 -0
- /package/out/__chunks__/{chunk-HUITKXBO.mjs.map → chunk-W77E3MVG.mjs.map} +0 -0
- /package/out/__chunks__/{chunk-CBF72LQF.mjs.map → chunk-WPFFITFH.mjs.map} +0 -0
- /package/out/__chunks__/{chunk-6ZL2QC74.mjs.map → chunk-XNPGQK42.mjs.map} +0 -0
- /package/out/__chunks__/{chunk-VFAKQ7NM.mjs.map → chunk-XRBOH3AB.mjs.map} +0 -0
- /package/out/__chunks__/{chunk-D5SD7UPB.mjs.map → chunk-Y3FER7B6.mjs.map} +0 -0
- /package/out/__chunks__/{chunk-S4WKQEYF.mjs.map → chunk-YLJTXHF4.mjs.map} +0 -0
- /package/out/__chunks__/{chunk-YO3ATAA6.mjs.map → chunk-YQEOOE3H.mjs.map} +0 -0
- /package/out/__chunks__/{chunk-YKRSCVRE.mjs.map → chunk-ZHAYVRGH.mjs.map} +0 -0
package/README.md
CHANGED
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
# MultiversX SDK for Front-End DApps
|
|
2
2
|
|
|
3
|
+
[](https://github.com/multiversx/mx-wallet-dapp/actions/workflows/pre-merge-main-unit-tests.yml)
|
|
4
|
+
[](https://github.com/multiversx/mx-wallet-dapp/actions/workflows/prun-template-dapps-integration.yml)
|
|
5
|
+
[](https://deepwiki.com/multiversx/mx-sdk-dapp)
|
|
6
|
+
|
|
3
7
|
MultiversX Front-End SDK for JavaScript and TypeScript (written in TypeScript).
|
|
4
8
|
|
|
5
9
|
## Introduction
|
|
@@ -8,9 +12,9 @@ MultiversX Front-End SDK for JavaScript and TypeScript (written in TypeScript).
|
|
|
8
12
|
|
|
9
13
|
It is built for applications that use any of the following technologies:
|
|
10
14
|
|
|
11
|
-
- React (example: [Template Dapp](https://github.com/multiversx/mx-template-dapp))
|
|
12
|
-
- Angular
|
|
13
|
-
- Vue
|
|
15
|
+
- React (example: [React Template Dapp](https://github.com/multiversx/mx-template-dapp))
|
|
16
|
+
- Angular (example: [Angular Template Dapp](https://github.com/multiversx/mx-template-dapp-angular))
|
|
17
|
+
- Vue (example: [Vue Template Dapp](https://github.com/multiversx/mx-template-dapp-vue))
|
|
14
18
|
- Any other JavaScript framework (e.g. Solid.js etc.) (example: [Solid.js Dapp](https://github.com/multiversx/mx-solidjs-template-dapp))
|
|
15
19
|
- React Native
|
|
16
20
|
- Next.js (example: [Next.js Dapp](https://github.com/multiversx/mx-template-dapp-nextjs))
|
|
@@ -21,7 +25,7 @@ The GitHub repository can be found here: [https://github.com/multiversx/mx-sdk-d
|
|
|
21
25
|
|
|
22
26
|
## Live demo: template-dapp
|
|
23
27
|
|
|
24
|
-
See [Template dApp](https://template-dapp.multiversx.com/) for live demo or
|
|
28
|
+
See [Template dApp](https://template-dapp.multiversx.com/) for live demo or check out usage in the [Github repo](https://github.com/multiversx/mx-template-dapp)
|
|
25
29
|
|
|
26
30
|
## Requirements
|
|
27
31
|
|
|
@@ -47,7 +51,7 @@ yarn add @multiversx/sdk-dapp
|
|
|
47
51
|
```
|
|
48
52
|
> **Note:** Make sure you run your app on `https`, not `http`, otherwise some providers will not work.
|
|
49
53
|
|
|
50
|
-
If you're transitioning from `@multiversx/sdk-dapp@4.x`, you can check out the [Migration guide](https://github.com/multiversx/mx-template-dapp/blob/
|
|
54
|
+
If you're transitioning from `@multiversx/sdk-dapp@4.x`, you can check out the [Migration guide](https://github.com/multiversx/mx-template-dapp/blob/main/MIGRATION_GUIDE.md) and the [migration PR](https://github.com/multiversx/mx-template-dapp/pull/343) of Template Dapp
|
|
51
55
|
|
|
52
56
|
## Usage
|
|
53
57
|
|
|
@@ -110,7 +114,7 @@ initApp(config).then(() => {
|
|
|
110
114
|
|
|
111
115
|
### 2. Provider interaction
|
|
112
116
|
|
|
113
|
-
Once your dApp has loaded, the first user action is logging in with a chosen provider. There are two ways to perform a login
|
|
117
|
+
Once your dApp has loaded, the first user action is logging in with a chosen provider. There are two ways to perform a login: using the `UnlockPanelManager` and programmatic login using the `ProviderFactory`.
|
|
114
118
|
|
|
115
119
|
#### 2.1 Using the `UnlockPanelManager`
|
|
116
120
|
By using the provided UI, you get the benefit of having all supported providers ready for login in a side panel. You simply need to link the `unlockPanelManager.openUnlockPanel` to a user action.
|
|
@@ -139,7 +143,7 @@ export const ConnectButton = () => {
|
|
|
139
143
|
Once the user has logged in, if `nativeAuth` is configured in the `initApp` method, an automatic logout will be performed upon native auth expiration. Before the actual logout is performed, the `LogoutManager` will show a warning toast to the user. This toast can be customized by passing a `tokenExpirationToastWarningSeconds` to the `nativeAuth` config.
|
|
140
144
|
|
|
141
145
|
```typescript
|
|
142
|
-
// in
|
|
146
|
+
// in initApp config
|
|
143
147
|
const config: InitAppType = {
|
|
144
148
|
// ...
|
|
145
149
|
nativeAuth: {
|
|
@@ -172,7 +176,7 @@ export const AdvancedConnectButton = () => {
|
|
|
172
176
|
anchor
|
|
173
177
|
});
|
|
174
178
|
const { address, signature } = await provider.login();
|
|
175
|
-
navigate(`/dashboard?address=${address}
|
|
179
|
+
navigate(`/dashboard?address=${address}`);
|
|
176
180
|
},
|
|
177
181
|
});
|
|
178
182
|
const handleOpenUnlockPanel = () => {
|
|
@@ -203,7 +207,7 @@ Depending on the framework, you can either use hooks or selectors to get the use
|
|
|
203
207
|
|
|
204
208
|
#### 3.1 React hooks
|
|
205
209
|
|
|
206
|
-
If you are using React, all hooks can be found under the `/out/react` folder. All store information can be accessed via different hooks but below you will find the main
|
|
210
|
+
If you are using React, all hooks can be found under the `/out/react` folder. All store information can be accessed via different hooks, but below you will find the main hooks related to the most common use cases
|
|
207
211
|
|
|
208
212
|
```bash
|
|
209
213
|
out/react/
|
|
@@ -333,16 +337,16 @@ await notificationManager.openNotificationsFeed();
|
|
|
333
337
|
|
|
334
338
|
You can find both methods and hooks to access transactions data, as seen in the table below.
|
|
335
339
|
|
|
336
|
-
**Table 2**.
|
|
340
|
+
**Table 2**. Inspecting transactions
|
|
337
341
|
| # | Helper | Description | React hook equivalent |
|
|
338
342
|
|---|------|-------------|----|
|
|
339
343
|
| | `methods/transactions` | path | `react/transactions` |
|
|
340
|
-
| 1 | `getTransactionSessions()` | returns all
|
|
341
|
-
| 2 | `getPendingTransactionsSessions()` | returns
|
|
344
|
+
| 1 | `getTransactionSessions()` | returns all transaction sessions |`useGetTransactionSessions()` |
|
|
345
|
+
| 2 | `getPendingTransactionsSessions()` | returns a record of pending sessions | `useGetPendingTransactionsSessions()`|
|
|
342
346
|
| 3 | `getPendingTransactions()` | returns an array of signed transactions | `useGetPendingTransactions()` |
|
|
343
|
-
| 4 | `getFailedTransactionsSessions()` | returns
|
|
347
|
+
| 4 | `getFailedTransactionsSessions()` | returns a record of failed sessions | `useGetFailedTransactionsSessions()`|
|
|
344
348
|
| 5 | `getFailedTransactions()` | returns an array of failed transactions | `useGetFailedTransactions()`|
|
|
345
|
-
| 6 | `getSuccessfulTransactionsSessions()` | returns
|
|
349
|
+
| 6 | `getSuccessfulTransactionsSessions()` | returns a record of successful sessions | `useGetSuccessfulTransactionsSessions()`|
|
|
346
350
|
| 7 | `getSuccessfulTransactions()` | returns an array of successful transactions | `useGetSuccessfulTransactions()`|
|
|
347
351
|
|
|
348
352
|
There is a way to inspect store information regarding a specific transaction, using the `transactionsSliceSelector`. An example is shown below:
|
|
@@ -499,12 +503,12 @@ The transaction lifecycle consists of the following steps:
|
|
|
499
503
|
| # | Helper | Description | React hook equivalent |
|
|
500
504
|
|---|------|-------------|----|
|
|
501
505
|
| | `methods/transactions` | path | `react/transactions` |
|
|
502
|
-
| 1 | `getTransactionSessions()` | returns all
|
|
506
|
+
| 1 | `getTransactionSessions()` | returns all transaction sessions |`useGetTransactionSessions()` |
|
|
503
507
|
| 2 | `getPendingTransactionsSessions()` | returns an record of pending sessions | `useGetPendingTransactionsSessions()`|
|
|
504
508
|
| 3 | `getPendingTransactions()` | returns an array of signed transactions | `useGetPendingTransactions()` |
|
|
505
|
-
| 4 | `getFailedTransactionsSessions()` | returns
|
|
509
|
+
| 4 | `getFailedTransactionsSessions()` | returns a record of failed sessions | `useGetFailedTransactionsSessions()`|
|
|
506
510
|
| 5 | `getFailedTransactions()` | returns an array of failed transactions | `useGetFailedTransactions()`|
|
|
507
|
-
| 6 | `getSuccessfulTransactionsSessions()` | returns
|
|
511
|
+
| 6 | `getSuccessfulTransactionsSessions()` | returns a record of successful sessions | `useGetSuccessfulTransactionsSessions()`|
|
|
508
512
|
| 7 | `getSuccessfulTransactions()` | returns an array of successful transactions | `useGetSuccessfulTransactions()`|
|
|
509
513
|
|
|
510
514
|
5. **User feedback** is provided through toast notifications, which are triggered to inform about transactions' progress. Additional tracking details can be optionally displayed in the toast UI.
|
|
@@ -747,7 +751,9 @@ If you want to override private components and create your own, you can implemen
|
|
|
747
751
|
|
|
748
752
|
## Debugging your dApp
|
|
749
753
|
|
|
750
|
-
|
|
754
|
+
> **Note:** For an advanced documentation on how internal flows are implemented, you can check out the [deepwiki](https://deepwiki.com/multiversx/mx-sdk-dapp) diagrams.
|
|
755
|
+
|
|
756
|
+
The recommended way to debug your application is by using [lerna](https://lerna.js.org/). Make sure you have the same package version in sdk-dapp's package.json and in your project's package.json.
|
|
751
757
|
|
|
752
758
|
If you preffer to use [npm link](https://docs.npmjs.com/cli/v11/commands/npm-link), make sure to use the `preserveSymlinks` option in the server configuration:
|
|
753
759
|
|
|
@@ -760,6 +766,8 @@ If you preffer to use [npm link](https://docs.npmjs.com/cli/v11/commands/npm-lin
|
|
|
760
766
|
},
|
|
761
767
|
```
|
|
762
768
|
|
|
769
|
+
Crome Redux DevTools are by default enabled to help you debug your application. You can find the extension in the Chrome Extensions store.
|
|
770
|
+
|
|
763
771
|
To build the library, run:
|
|
764
772
|
|
|
765
773
|
```bash
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{a as ot}from"./chunk-6GNNYFMN.mjs";import{a as ut}from"./chunk-6UZHM5LW.mjs";import{a as L}from"./chunk-NQ6SJRHZ.mjs";import{a as lt}from"./chunk-B7ZKW5ML.mjs";import{a as S}from"./chunk-QSYQIJEO.mjs";import{a as X,b as Z,g as tt,l as st}from"./chunk-CAA4VJRH.mjs";import{a as dt}from"./chunk-RBUHL65H.mjs";import{b as C}from"./chunk-IXUYZYD2.mjs";import{a as Tt}from"./chunk-4ZZJX7E7.mjs";import{a as vt}from"./chunk-4ODPAHHA.mjs";import{a as ft}from"./chunk-Z5CDCI3Y.mjs";import{a as gt}from"./chunk-YO3ATAA6.mjs";import{a as g}from"./chunk-YA5U6YEL.mjs";import{a as Q}from"./chunk-6ZL2QC74.mjs";import{a as ct}from"./chunk-ID7WYMJZ.mjs";import{a as y}from"./chunk-INWUHEQN.mjs";import{a as b,f as mt}from"./chunk-ISPOZQQO.mjs";import{b as pt}from"./chunk-VXLJWKLG.mjs";import{d as at}from"./chunk-O2DO3WJJ.mjs";import{k as et,l as it,n as nt}from"./chunk-65L5EBBL.mjs";import{a as w}from"./chunk-HORSXVIV.mjs";import{a as ht}from"./chunk-E7BYYSVM.mjs";import{a as J}from"./chunk-P32DZ2CO.mjs";import{a as I}from"./chunk-QTKK6OSJ.mjs";import{a as E}from"./chunk-6FXEHNGW.mjs";import{a as Et}from"./chunk-NJN53MJV.mjs";import{a as j}from"./chunk-YSCND2MX.mjs";import{a as V,b as q,s as u,u as Y}from"./chunk-4QDHGYT4.mjs";import{c as H,f as $}from"./chunk-QJSB5NX4.mjs";import{b as d}from"./chunk-VNLGNNIL.mjs";import{b as h}from"./chunk-6JM4DPOH.mjs";import{b as G,c as K,f as z}from"./chunk-R53MCZI6.mjs";import{b as It}from"./chunk-QWV25ZSJ.mjs";import{a as rt}from"./chunk-4YU2DWHA.mjs";import{a as v}from"./chunk-S2FQWSUO.mjs";import _ from"lodash.isequal";import yt from"lodash.isequal";var Ot="NOTIFICATIONS_FEED_STORE_SUBSCRIBE",A=class e extends ct{constructor(){super({uiDataUpdateEvent:"OPEN_NOTIFICATIONS_FEED",uiTag:"mvx-notifications-feed"});this.store=u();this.initialData={pendingTransactions:[],historicTransactions:[]};this.closeUI=async()=>{this.data.pendingTransactions.length>0?(this.unsubscribeFunctions.forEach(s=>s.forEach(o=>o())),this.unsubscribeFunctions.clear(),await this.uiElement?.closeWithAnimation()):super.closeUI()};this.data={...this.initialData}}static getInstance(){return e.instance||(e.instance=new e),e.instance}isNotificationsFeedOpen(){return this.isOpen}async openNotificationsFeed(){p.getInstance().hideToasts(),await this.openUI(),await this.updateDataAndNotifications();let o=this.store.subscribe(async({toasts:i,transactions:n},{toasts:a,transactions:c})=>{(!yt(a.transactionToasts,i.transactionToasts)||!yt(c,n))&&await this.updateDataAndNotifications()});this.unsubscribeFunctions.set(Ot,[o]),this.eventBus?.publish("OPEN_NOTIFICATIONS_FEED"),await this.updateDataAndNotifications()}async handleCloseUI(){let s=p.getInstance();await this.closeUI(),await s.showToasts()}async setupEventListeners(){this.eventBus&&(this.subscribeToEventBus("CLOSE_NOTIFICATIONS_FEED",this.handleCloseUI.bind(this)),this.subscribeToEventBus("CLEAR_NOTIFICATIONS_FEED_HISTORY",this.handleClearNotificationsFeedHistory.bind(this)))}async updateDataAndNotifications(){let{transactions:s,account:o,toasts:i,network:n}=this.store.getState(),{pendingTransactionToasts:a}=await L({toastList:i,transactionsSessions:s,account:o});this.data.pendingTransactions=a,this.data.historicTransactions=await ot.getTransactionsHistory({transactionsSessions:s,address:o.address,explorerAddress:n.network.explorerAddress,egldLabel:n.network.egldLabel}),await this.updateNotificationsFeed()}handleClearNotificationsFeedHistory(){at(),this.resetData(),this.updateNotificationsFeed()}async updateNotificationsFeed(){this.eventBus&&(this.eventBus.publish("PENDING_TRANSACTIONS_UPDATE",this.data.pendingTransactions),this.eventBus.publish("TRANSACTIONS_HISTORY_UPDATE",this.data.historicTransactions))}};import R from"bignumber.js";var x=class e{constructor(){this.store=u();this.warningLogoutTimeoutRef=null;this.actualLogoutTimeoutRef=null;this.plannedLogoutTimeoutRef=null;this.plannedLogoutKey=null;this.init=async()=>{if(!this.shouldStart())return;let t=this.store.getState(),s=d(t),{isExpired:o}=I(s?.nativeAuthToken);o?f().logout():this.addPlannedLogout()};this.stop=()=>{clearTimeout(this.warningLogoutTimeoutRef??0),clearTimeout(this.plannedLogoutTimeoutRef??0),clearTimeout(this.actualLogoutTimeoutRef??0),this.warningLogoutTimeoutRef=null,this.plannedLogoutTimeoutRef=null,this.actualLogoutTimeoutRef=null,this.plannedLogoutKey=null};this.shouldStart=()=>{let t=this.store.getState(),s=d(t),o=$(t);return!!(s?.nativeAuthToken&&o)};this.addPlannedLogout=()=>{let t=f(),s=H(this.store.getState()),o=t.getType()===v.webview;if(!s||o)return;this.addLogoutWarning();let i=d(this.store.getState()),{secondsUntilExpires:n,expiresAt:a}=I(i?.nativeAuthToken),c=new R(String(n)),r=`${s}_${a}`,m=this.plannedLogoutKey===r;if(!(n&&c.isGreaterThan(0))||m)return;this.plannedLogoutKey=r,clearTimeout(this.plannedLogoutTimeoutRef??0);let W=c.times(1e3);this.actualLogoutTimeoutRef=setTimeout(()=>{p.getInstance().createCustomToast({toastId:"native-auth-logout",iconClassName:"warning",title:"Logging out",icon:"times",message:"Your session has expired!"}),this.actualLogoutTimeoutRef=null},W.toNumber()-3e3),this.plannedLogoutTimeoutRef=setTimeout(()=>{t.logout(),this.plannedLogoutTimeoutRef=null,this.plannedLogoutKey=null},W.toNumber())};this.addLogoutWarning=()=>{if(this.warningLogoutTimeoutRef)return;let t=h(this.store.getState()),s=d(this.store.getState()),{secondsUntilExpires:o}=I(s?.nativeAuthToken),i=new R(String(o)),n=i.times(1e3);if(!o||i.isLessThanOrEqualTo(0)||!t?.tokenExpirationToastWarningSeconds)return;let c=new R(t?.tokenExpirationToastWarningSeconds??0).times(1e3),r=i.times(1e3).minus(c),m=ut(n.toNumber()),l=r.isLessThanOrEqualTo(0)?0:r.toNumber();clearTimeout(this.warningLogoutTimeoutRef??0),this.warningLogoutTimeoutRef=setTimeout(()=>{p.getInstance().createCustomToast({toastId:"native-auth-expired",iconClassName:"warning",title:"Session Expiration Warning",icon:"hourglass",message:`Your session will expire in ${m}!`}),this.warningLogoutTimeoutRef=null},l)}}static getInstance(){return e.instance||(e.instance=new e),e.instance}};async function B({address:e,provider:t,apiAddress:s}){let o=await E({address:e,baseURL:s});if(!o)throw new Error("Account not found");pt({address:e,providerType:t.getType()});let i={...o,username:w(o.username),nonce:y(o)};b(i),await C(e),S(),o.shard!=null&&await lt({shard:Number(o.shard),apiAddress:s})}async function Pt(e){let{network:{apiAddress:t}}=g();await e.login();let s=await e.getAddress();if(!s)throw new Error("Address not found");return await B({address:s,provider:e,apiAddress:t}),{address:s}}async function Dt({provider:e,nativeAuthConfig:t,token:s}){let{network:{apiAddress:o}}=g(),i=J(t),n=s;n||(n=await i.initialize({noCache:!0}));let{address:a,signature:c,...r}=await e.login({token:n});if(!a)return console.warn("Login cancelled."),null;if(!c)return console.error("Failed to sign login token"),null;let m=i.getToken({address:a,token:n,signature:c});q({loginToken:n,signature:c,nativeAuthToken:m});let l=await Tt({loginToken:n,extraInfoData:{multisig:r?.multisig,impersonate:r?.impersonate},address:a});return await B({address:l,provider:e,apiAddress:o}),{address:l,signature:c}}async function Lt(e,t){let s=h(Y());if(s)return await Dt({provider:e,nativeAuthConfig:s,token:t?.token});let{address:o}=await Pt(e);return await C(o),S(),{address:o}}var U={error:{title:"Error when signing".toString(),iconClassName:"danger",toastId:`${Z}-${Date.now()}`},warning:{title:"Signing canceled".toString(),iconClassName:"warning",toastId:`${X}-${Date.now()}`}},Rt={extensionResponse:"Unable to sign transactions","Transaction canceled":"Transaction canceled","cancelled by user":"Transaction signing cancelled by user","denied by the user":"Transaction signing denied by the user"},Bt=e=>{for(let[t,s]of Object.entries(Rt))if(e.includes(t))return s;return"Error when signing"};function k(e,t="error"){let s=e?.message,o=Bt(s),n=o!=="Error when signing"?"warning":t,a=Object.keys(U).includes(n)?U[n]:U.error,{toastId:c,iconClassName:r,title:m}=a;return N({toastId:c,duration:1e4,icon:"times",iconClassName:r,message:o,title:m}),o}async function bt({provider:e,transactions:t,options:s={}}){await Ct();let{isGuarded:o,activeGuardianAddress:i,nonce:n}=ht(),a=e.getType()===v.ledger,c=vt({latestNonce:n,transactions:t}),r=i&&o&&!s.skipGuardian?c?.map(l=>(l.version=G.withTxOptions().valueOf(),l.options=z.withOptions({guarded:!0,...a?{hashSign:!0}:{}}).valueOf(),l.guardian=K.newFromBech32(i),l)):c,m=await e.signTransactions(r)??[];return mt(n+m.length),m}var M=class{constructor(t){this._isLoggingOut=!1;this.provider=t}init(){return this.provider.init()}async login(t){let s=await Lt(this.provider,t);return V(this.provider.getType()),St(this),x.getInstance().init(),s}isInitialized(){return this.provider.isInitialized()}async logout(t={shouldBroadcastLogoutAcrossTabs:!0}){if(this._isLoggingOut)return console.warn("Logout already in progress"),!1;this._isLoggingOut=!0;let s=await dt({provider:this.provider,options:t});return this._isLoggingOut=!1,s}getType(){return this.provider.getType()}getProvider(){return this.provider}async signTransactions(t,s){try{return await bt({provider:this.provider,transactions:t,options:s})}catch(o){let i=k(o);throw new Error(i)}}async signMessage(t,s){try{return await gt({provider:this.provider,message:t,options:s})}catch(o){let i=k(o,"warning");throw new Error(i)}}async verifyMessage(t){return await ft(t)}cancelLogin(){this.provider.cancelLogin?.()}};var wt=null;function St(e){wt=e}function f(){return wt||new M(It)}var Ut=async()=>{try{let e=Q(),{network:t}=g();try{let s=await E({address:e,baseURL:t.apiAddress});if(s!=null){let o={...s,username:w(s.username),nonce:y(s)};return b(o),o}}catch(s){console.error("Failed getting account ",s)}}catch(e){console.error("Failed getting address ",e)}return null};async function Ct(){let e=f();if(e==null)throw"Provider not initialized";try{if(!e.init)throw"Current provider does not have init() function";return await e.init()?Ut():void 0}catch(t){console.error("Failed initializing provider ",t)}}var O={},T={},kt=(e,t)=>{u().setState(({toasts:s})=>{let o=s.customToasts.length>0?Math.max(...s.customToasts.map(r=>parseInt(r.toastId.split("-").pop()??"0"))):0,i=t??`custom-toast-${o+1}`,n=s.customToasts.findIndex(r=>r.toastId===i),a={...e,toastId:i};if(n!==-1){s.customToasts[n]=a;return}s.customToasts.push({...a,toastId:i})},!1,"addCustomToast")},F=e=>{u().setState(({toasts:t})=>{t.customToasts=t.customToasts.filter(s=>s.toastId!==e)},!1,"removeCustomToast")},At=()=>{u().setState(({toasts:e})=>{e.customToasts=[]},!1,"removeAllCustomToasts")},Go=()=>{u().setState(({toasts:e})=>{e.transactionToasts=[]})},xt=({toastId:e,totalDuration:t})=>{let s="";return u().setState(({toasts:o})=>{let i=o.transactionToasts.length>0?Math.max(...o.transactionToasts.map(n=>parseInt(n.toastId.split("-").pop()??"0"))):0;s=e??`transaction-toast-${i+1}`,o.transactionToasts.push({startTime:j(),endTime:Et(t),toastId:s})},!1,"addTransactionToast"),s},P=e=>{u().setState(({toasts:t})=>{t.transactionToasts=t.transactionToasts.filter(s=>s.toastId!==e)},!1,"removeTransactionToast"),delete T[e],delete O[e]},N=e=>{let{toasts:t}=u().getState(),s=t.customToasts.length>0?Math.max(...t.customToasts.map(i=>parseInt(i.toastId.split("-").pop()??"0"))):0,o=e.toastId||`custom-toast-${s+1}`;return e.onClose&&(T[o]=e.onClose),e.instantiateToastElement?(O[o]=e.instantiateToastElement,u().setState(({toasts:i})=>{let n=i.customToasts.findIndex(r=>r.toastId===o),a={...e,instantiateToastElement:null,toastId:o};n!==-1?i.customToasts[n]=a:i.customToasts.push(a)},!1,"createCustomToast"),o):(kt(e,o),o)};var Nt=1e4,D=class{constructor(){this.timeoutIntervals=new Map;this.successfulToastLifetime=Nt;this.start=t=>{if(this.stop(t),this.successfulToastLifetime<=0)return;let s=setTimeout(()=>{P(t)},this.successfulToastLifetime);this.timeoutIntervals.set(t,s)};this.startWithCustomDuration=(t,s)=>{if(this.stop(t),s<=0)return;let o=setTimeout(()=>{F(t);let i=T[t];i?.()},s);this.timeoutIntervals.set(t,o)};this.stop=t=>{let s=this.timeoutIntervals.get(t);s&&(clearTimeout(s),this.timeoutIntervals.delete(t))}}init({successfulToastLifetime:t}){this.successfulToastLifetime=t||Nt}destroy(){this.timeoutIntervals.forEach(t=>clearTimeout(t)),this.timeoutIntervals.clear()}};var p=class e{constructor(){this.isCreatingElement=!1;this.toastsElement=null;this.transactionToasts=[];this.customToasts=[];this.storeToastsSubscription=()=>null;this.eventBusUnsubscribeFunctions=[];this.eventBus=null;this.store=u();this.destroy(),this.lifetimeManager=new D,this.notificationsFeedManager=A.getInstance()}async init({successfulToastLifetime:t=5e3}={}){this.successfulToastLifetime=t,this.lifetimeManager.init({successfulToastLifetime:t}),await this.updateTransactionToastsList(),await this.updateCustomToastList(),await this.subscribeToEventBusNotifications(),this.storeToastsSubscription=this.store.subscribe(async({toasts:s,transactions:o},{toasts:i,transactions:n})=>{(!_(i.transactionToasts,s.transactionToasts)||!_(n,o))&&await this.updateTransactionToastsList(),_(i.customToasts,s.customToasts)||await this.updateCustomToastList()})}static getInstance(){return e.instance||(e.instance=new e),e.instance}handleCompletedTransaction(t){let{transactions:s}=this.store.getState(),o=s[t];if(!o)return!1;let{status:i}=o,n=nt(i),a=it(i),c=et(i),r=a||c||n;return r?(this.successfulToastLifetime&&this.lifetimeManager.start(t),r):(this.lifetimeManager.stop(t),r)}async createTransactionToast(t,s){let o=xt({toastId:t,totalDuration:s});return this.handleCompletedTransaction(t),await this.updateTransactionToastsList(),o}createCustomToast(t){let s=N(t);return this.updateCustomToastList(),s}async updateTransactionToastsList(){let{toasts:t,transactions:s,account:o}=this.store.getState(),{pendingTransactionToasts:i,completedTransactionToasts:n}=await L({toastList:t,transactionsSessions:s,account:o});this.transactionToasts=[...i,...n];for(let a of t.transactionToasts)this.handleCompletedTransaction(a.toastId);await this.publishTransactionToasts()}async updateCustomToastList(){let{toasts:t}=this.store.getState();this.customToasts=[];for(let s of t.customToasts){let i="message"in s?{...s}:{...s,instantiateToastElement:O[s.toastId]};this.customToasts.push(i),s.duration&&this.lifetimeManager.startWithCustomDuration(s.toastId,s.duration)}this.eventBus?.publish("CUSTOM_TOAST_DATA_UPDATE",this.customToasts)}async createToastListElement(){return this.toastsElement?this.toastsElement:(this.isCreatingElement||(this.isCreatingElement=!0,this.toastsElement=await rt.create({name:"mvx-toast-list"}),this.isCreatingElement=!1),this.toastsElement)}handleTransactionToastClose(t){this.handleCompletedTransaction(t)&&P(t)}async subscribeToEventBusNotifications(){let t=await this.createToastListElement();if(t){if(this.eventBus=await t.getEventBus(),!this.eventBus)throw new Error("eventBus is not initialized");this.eventBus.subscribe("CLOSE_TOAST",this.handleCloseToast.bind(this)),this.eventBusUnsubscribeFunctions.push(()=>{this.eventBus?.unsubscribe("CLOSE_TOAST",this.handleCloseToast.bind(this))}),this.eventBus.subscribe("OPEN_NOTIFICATIONS_FEED",this.handleOpenNotificationsFeed.bind(this)),this.eventBusUnsubscribeFunctions.push(()=>{this.eventBus?.unsubscribe("OPEN_NOTIFICATIONS_FEED",this.handleOpenNotificationsFeed.bind(this))})}}async showToasts(){this.eventBus?.publish("SHOW_TOAST_LIST",null),await this.updateCustomToastList(),await this.updateTransactionToastsList()}hideToasts(){this.eventBus?.publish("HIDE_TOAST_LIST",null)}async handleOpenNotificationsFeed(){this.notificationsFeedManager.openNotificationsFeed()}handleCloseToast(t){if(this.customToasts.find(o=>o.toastId===t)){this.lifetimeManager.stop(t);let o=T[t];o?.(),F(t);return}this.handleTransactionToastClose(t)}async publishTransactionToasts(){if(this.notificationsFeedManager.isNotificationsFeedOpen()&&this.eventBus){this.eventBus.publish("TRANSACTION_TOAST_DATA_UPDATE",this.transactionToasts),this.hideToasts();return}if(!this.eventBus){let t=await this.createToastListElement();if(!t)return;this.eventBus=await t.getEventBus()}this.eventBus.publish("TRANSACTION_TOAST_DATA_UPDATE",this.transactionToasts)}destroy(){this.storeToastsSubscription(),this.lifetimeManager?.destroy(),this.notificationsFeedManager?.destroy(),At(),this.eventBusUnsubscribeFunctions.forEach(t=>t()),this.eventBusUnsubscribeFunctions=[]}};export{A as a,O as b,T as c,kt as d,F as e,At as f,Go as g,xt as h,P as i,N as j,D as k,p as l,x as m,B as n,Lt as o,k as p,bt as q,M as r,St as s,f as t,Ct as u};
|
|
2
|
-
//# sourceMappingURL=chunk-
|
|
1
|
+
import{a as ot}from"./chunk-2HSERTN3.mjs";import{a as ut}from"./chunk-6UZHM5LW.mjs";import{a as L}from"./chunk-IKVKOGWF.mjs";import{a as lt}from"./chunk-UFMXBWCD.mjs";import{a as S}from"./chunk-MGF5WOBM.mjs";import{a as X,b as Z,g as tt,l as st}from"./chunk-CAA4VJRH.mjs";import{a as dt}from"./chunk-E53QIC6C.mjs";import{b as C}from"./chunk-AK44E24X.mjs";import{a as Tt}from"./chunk-RWNPPIFD.mjs";import{a as vt}from"./chunk-4ODPAHHA.mjs";import{a as ft}from"./chunk-Z5CDCI3Y.mjs";import{a as gt}from"./chunk-YQEOOE3H.mjs";import{a as g}from"./chunk-PHEK22HL.mjs";import{a as Q}from"./chunk-XNPGQK42.mjs";import{a as ct}from"./chunk-T5KTF5Z5.mjs";import{a as y}from"./chunk-CWENDDPJ.mjs";import{a as b,f as mt}from"./chunk-RGBXTDJ7.mjs";import{b as pt}from"./chunk-3AC72XDZ.mjs";import{d as at}from"./chunk-KARM6PTO.mjs";import{k as et,l as it,n as nt}from"./chunk-65L5EBBL.mjs";import{a as w}from"./chunk-HORSXVIV.mjs";import{a as ht}from"./chunk-R725UMBR.mjs";import{a as J}from"./chunk-JEB6OIJ7.mjs";import{a as I}from"./chunk-QTKK6OSJ.mjs";import{a as E}from"./chunk-6FXEHNGW.mjs";import{a as Et}from"./chunk-NJN53MJV.mjs";import{a as j}from"./chunk-YSCND2MX.mjs";import{a as V,b as q,s as u,u as Y}from"./chunk-5MC44CTJ.mjs";import{c as H,f as $}from"./chunk-QJSB5NX4.mjs";import{b as d}from"./chunk-VNLGNNIL.mjs";import{b as h}from"./chunk-6JM4DPOH.mjs";import{b as G,c as K,f as z}from"./chunk-R53MCZI6.mjs";import{b as It}from"./chunk-QWV25ZSJ.mjs";import{a as rt}from"./chunk-HTG5MOLD.mjs";import{a as v}from"./chunk-S2FQWSUO.mjs";import _ from"lodash.isequal";import yt from"lodash.isequal";var Ot="NOTIFICATIONS_FEED_STORE_SUBSCRIBE",A=class e extends ct{constructor(){super({uiDataUpdateEvent:"OPEN_NOTIFICATIONS_FEED",uiTag:"mvx-notifications-feed"});this.store=u();this.initialData={pendingTransactions:[],historicTransactions:[]};this.closeUI=async()=>{this.data.pendingTransactions.length>0?(this.unsubscribeFunctions.forEach(s=>s.forEach(o=>o())),this.unsubscribeFunctions.clear(),await this.uiElement?.closeWithAnimation()):super.closeUI()};this.data={...this.initialData}}static getInstance(){return e.instance||(e.instance=new e),e.instance}isNotificationsFeedOpen(){return this.isOpen}async openNotificationsFeed(){p.getInstance().hideToasts(),await this.openUI(),await this.updateDataAndNotifications();let o=this.store.subscribe(async({toasts:i,transactions:n},{toasts:a,transactions:c})=>{(!yt(a.transactionToasts,i.transactionToasts)||!yt(c,n))&&await this.updateDataAndNotifications()});this.unsubscribeFunctions.set(Ot,[o]),this.eventBus?.publish("OPEN_NOTIFICATIONS_FEED"),await this.updateDataAndNotifications()}async handleCloseUI(){let s=p.getInstance();await this.closeUI(),await s.showToasts()}async setupEventListeners(){this.eventBus&&(this.subscribeToEventBus("CLOSE_NOTIFICATIONS_FEED",this.handleCloseUI.bind(this)),this.subscribeToEventBus("CLEAR_NOTIFICATIONS_FEED_HISTORY",this.handleClearNotificationsFeedHistory.bind(this)))}async updateDataAndNotifications(){let{transactions:s,account:o,toasts:i,network:n}=this.store.getState(),{pendingTransactionToasts:a}=await L({toastList:i,transactionsSessions:s,account:o});this.data.pendingTransactions=a,this.data.historicTransactions=await ot.getTransactionsHistory({transactionsSessions:s,address:o.address,explorerAddress:n.network.explorerAddress,egldLabel:n.network.egldLabel}),await this.updateNotificationsFeed()}handleClearNotificationsFeedHistory(){at(),this.resetData(),this.updateNotificationsFeed()}async updateNotificationsFeed(){this.eventBus&&(this.eventBus.publish("PENDING_TRANSACTIONS_UPDATE",this.data.pendingTransactions),this.eventBus.publish("TRANSACTIONS_HISTORY_UPDATE",this.data.historicTransactions))}};import R from"bignumber.js";var x=class e{constructor(){this.store=u();this.warningLogoutTimeoutRef=null;this.actualLogoutTimeoutRef=null;this.plannedLogoutTimeoutRef=null;this.plannedLogoutKey=null;this.init=async()=>{if(!this.shouldStart())return;let t=this.store.getState(),s=d(t),{isExpired:o}=I(s?.nativeAuthToken);o?f().logout():this.addPlannedLogout()};this.stop=()=>{clearTimeout(this.warningLogoutTimeoutRef??0),clearTimeout(this.plannedLogoutTimeoutRef??0),clearTimeout(this.actualLogoutTimeoutRef??0),this.warningLogoutTimeoutRef=null,this.plannedLogoutTimeoutRef=null,this.actualLogoutTimeoutRef=null,this.plannedLogoutKey=null};this.shouldStart=()=>{let t=this.store.getState(),s=d(t),o=$(t);return!!(s?.nativeAuthToken&&o)};this.addPlannedLogout=()=>{let t=f(),s=H(this.store.getState()),o=t.getType()===v.webview;if(!s||o)return;this.addLogoutWarning();let i=d(this.store.getState()),{secondsUntilExpires:n,expiresAt:a}=I(i?.nativeAuthToken),c=new R(String(n)),r=`${s}_${a}`,m=this.plannedLogoutKey===r;if(!(n&&c.isGreaterThan(0))||m)return;this.plannedLogoutKey=r,clearTimeout(this.plannedLogoutTimeoutRef??0);let W=c.times(1e3);this.actualLogoutTimeoutRef=setTimeout(()=>{p.getInstance().createCustomToast({toastId:"native-auth-logout",iconClassName:"warning",title:"Logging out",icon:"times",message:"Your session has expired!"}),this.actualLogoutTimeoutRef=null},W.toNumber()-3e3),this.plannedLogoutTimeoutRef=setTimeout(()=>{t.logout(),this.plannedLogoutTimeoutRef=null,this.plannedLogoutKey=null},W.toNumber())};this.addLogoutWarning=()=>{if(this.warningLogoutTimeoutRef)return;let t=h(this.store.getState()),s=d(this.store.getState()),{secondsUntilExpires:o}=I(s?.nativeAuthToken),i=new R(String(o)),n=i.times(1e3);if(!o||i.isLessThanOrEqualTo(0)||!t?.tokenExpirationToastWarningSeconds)return;let c=new R(t?.tokenExpirationToastWarningSeconds??0).times(1e3),r=i.times(1e3).minus(c),m=ut(n.toNumber()),l=r.isLessThanOrEqualTo(0)?0:r.toNumber();clearTimeout(this.warningLogoutTimeoutRef??0),this.warningLogoutTimeoutRef=setTimeout(()=>{p.getInstance().createCustomToast({toastId:"native-auth-expired",iconClassName:"warning",title:"Session Expiration Warning",icon:"hourglass",message:`Your session will expire in ${m}!`}),this.warningLogoutTimeoutRef=null},l)}}static getInstance(){return e.instance||(e.instance=new e),e.instance}};async function B({address:e,provider:t,apiAddress:s}){let o=await E({address:e,baseURL:s});if(!o)throw new Error("Account not found");pt({address:e,providerType:t.getType()});let i={...o,username:w(o.username),nonce:y(o)};b(i),await C(e),S(),o.shard!=null&&await lt({shard:Number(o.shard),apiAddress:s})}async function Pt(e){let{network:{apiAddress:t}}=g();await e.login();let s=await e.getAddress();if(!s)throw new Error("Address not found");return await B({address:s,provider:e,apiAddress:t}),{address:s}}async function Dt({provider:e,nativeAuthConfig:t,token:s}){let{network:{apiAddress:o}}=g(),i=J(t),n=s;n||(n=await i.initialize({noCache:!0}));let{address:a,signature:c,...r}=await e.login({token:n});if(!a)return console.warn("Login cancelled."),null;if(!c)return console.error("Failed to sign login token"),null;let m=i.getToken({address:a,token:n,signature:c});q({loginToken:n,signature:c,nativeAuthToken:m});let l=await Tt({loginToken:n,extraInfoData:{multisig:r?.multisig,impersonate:r?.impersonate},address:a});return await B({address:l,provider:e,apiAddress:o}),{address:l,signature:c}}async function Lt(e,t){let s=h(Y());if(s)return await Dt({provider:e,nativeAuthConfig:s,token:t?.token});let{address:o}=await Pt(e);return await C(o),S(),{address:o}}var U={error:{title:"Error when signing".toString(),iconClassName:"danger",toastId:`${Z}-${Date.now()}`},warning:{title:"Signing canceled".toString(),iconClassName:"warning",toastId:`${X}-${Date.now()}`}},Rt={extensionResponse:"Unable to sign transactions","Transaction canceled":"Transaction canceled","cancelled by user":"Transaction signing cancelled by user","denied by the user":"Transaction signing denied by the user"},Bt=e=>{for(let[t,s]of Object.entries(Rt))if(e.includes(t))return s;return"Error when signing"};function k(e,t="error"){let s=e?.message,o=Bt(s),n=o!=="Error when signing"?"warning":t,a=Object.keys(U).includes(n)?U[n]:U.error,{toastId:c,iconClassName:r,title:m}=a;return N({toastId:c,duration:1e4,icon:"times",iconClassName:r,message:o,title:m}),o}async function bt({provider:e,transactions:t,options:s={}}){await Ct();let{isGuarded:o,activeGuardianAddress:i,nonce:n}=ht(),a=e.getType()===v.ledger,c=vt({latestNonce:n,transactions:t}),r=i&&o&&!s.skipGuardian?c?.map(l=>(l.version=G.withTxOptions().valueOf(),l.options=z.withOptions({guarded:!0,...a?{hashSign:!0}:{}}).valueOf(),l.guardian=K.newFromBech32(i),l)):c,m=await e.signTransactions(r)??[];return mt(n+m.length),m}var M=class{constructor(t){this._isLoggingOut=!1;this.provider=t}init(){return this.provider.init()}async login(t){let s=await Lt(this.provider,t);return V(this.provider.getType()),St(this),x.getInstance().init(),s}isInitialized(){return this.provider.isInitialized()}async logout(t={shouldBroadcastLogoutAcrossTabs:!0}){if(this._isLoggingOut)return console.warn("Logout already in progress"),!1;this._isLoggingOut=!0;let s=await dt({provider:this.provider,options:t});return this._isLoggingOut=!1,s}getType(){return this.provider.getType()}getProvider(){return this.provider}async signTransactions(t,s){try{return await bt({provider:this.provider,transactions:t,options:s})}catch(o){let i=k(o);throw new Error(i)}}async signMessage(t,s){try{return await gt({provider:this.provider,message:t,options:s})}catch(o){let i=k(o,"warning");throw new Error(i)}}async verifyMessage(t){return await ft(t)}cancelLogin(){this.provider.cancelLogin?.()}};var wt=null;function St(e){wt=e}function f(){return wt||new M(It)}var Ut=async()=>{try{let e=Q(),{network:t}=g();try{let s=await E({address:e,baseURL:t.apiAddress});if(s!=null){let o={...s,username:w(s.username),nonce:y(s)};return b(o),o}}catch(s){console.error("Failed getting account ",s)}}catch(e){console.error("Failed getting address ",e)}return null};async function Ct(){let e=f();if(e==null)throw"Provider not initialized";try{if(!e.init)throw"Current provider does not have init() function";return await e.init()?Ut():void 0}catch(t){console.error("Failed initializing provider ",t)}}var O={},T={},kt=(e,t)=>{u().setState(({toasts:s})=>{let o=s.customToasts.length>0?Math.max(...s.customToasts.map(r=>parseInt(r.toastId.split("-").pop()??"0"))):0,i=t??`custom-toast-${o+1}`,n=s.customToasts.findIndex(r=>r.toastId===i),a={...e,toastId:i};if(n!==-1){s.customToasts[n]=a;return}s.customToasts.push({...a,toastId:i})},!1,"addCustomToast")},F=e=>{u().setState(({toasts:t})=>{t.customToasts=t.customToasts.filter(s=>s.toastId!==e)},!1,"removeCustomToast")},At=()=>{u().setState(({toasts:e})=>{e.customToasts=[]},!1,"removeAllCustomToasts")},Go=()=>{u().setState(({toasts:e})=>{e.transactionToasts=[]})},xt=({toastId:e,totalDuration:t})=>{let s="";return u().setState(({toasts:o})=>{let i=o.transactionToasts.length>0?Math.max(...o.transactionToasts.map(n=>parseInt(n.toastId.split("-").pop()??"0"))):0;s=e??`transaction-toast-${i+1}`,o.transactionToasts.push({startTime:j(),endTime:Et(t),toastId:s})},!1,"addTransactionToast"),s},P=e=>{u().setState(({toasts:t})=>{t.transactionToasts=t.transactionToasts.filter(s=>s.toastId!==e)},!1,"removeTransactionToast"),delete T[e],delete O[e]},N=e=>{let{toasts:t}=u().getState(),s=t.customToasts.length>0?Math.max(...t.customToasts.map(i=>parseInt(i.toastId.split("-").pop()??"0"))):0,o=e.toastId||`custom-toast-${s+1}`;return e.onClose&&(T[o]=e.onClose),e.instantiateToastElement?(O[o]=e.instantiateToastElement,u().setState(({toasts:i})=>{let n=i.customToasts.findIndex(r=>r.toastId===o),a={...e,instantiateToastElement:null,toastId:o};n!==-1?i.customToasts[n]=a:i.customToasts.push(a)},!1,"createCustomToast"),o):(kt(e,o),o)};var Nt=1e4,D=class{constructor(){this.timeoutIntervals=new Map;this.successfulToastLifetime=Nt;this.start=t=>{if(this.stop(t),this.successfulToastLifetime<=0)return;let s=setTimeout(()=>{P(t)},this.successfulToastLifetime);this.timeoutIntervals.set(t,s)};this.startWithCustomDuration=(t,s)=>{if(this.stop(t),s<=0)return;let o=setTimeout(()=>{F(t);let i=T[t];i?.()},s);this.timeoutIntervals.set(t,o)};this.stop=t=>{let s=this.timeoutIntervals.get(t);s&&(clearTimeout(s),this.timeoutIntervals.delete(t))}}init({successfulToastLifetime:t}){this.successfulToastLifetime=t||Nt}destroy(){this.timeoutIntervals.forEach(t=>clearTimeout(t)),this.timeoutIntervals.clear()}};var p=class e{constructor(){this.isCreatingElement=!1;this.toastsElement=null;this.transactionToasts=[];this.customToasts=[];this.storeToastsSubscription=()=>null;this.eventBusUnsubscribeFunctions=[];this.eventBus=null;this.store=u();this.destroy(),this.lifetimeManager=new D,this.notificationsFeedManager=A.getInstance()}async init({successfulToastLifetime:t=5e3}={}){this.successfulToastLifetime=t,this.lifetimeManager.init({successfulToastLifetime:t}),await this.updateTransactionToastsList(),await this.updateCustomToastList(),await this.subscribeToEventBusNotifications(),this.storeToastsSubscription=this.store.subscribe(async({toasts:s,transactions:o},{toasts:i,transactions:n})=>{(!_(i.transactionToasts,s.transactionToasts)||!_(n,o))&&await this.updateTransactionToastsList(),_(i.customToasts,s.customToasts)||await this.updateCustomToastList()})}static getInstance(){return e.instance||(e.instance=new e),e.instance}handleCompletedTransaction(t){let{transactions:s}=this.store.getState(),o=s[t];if(!o)return!1;let{status:i}=o,n=nt(i),a=it(i),c=et(i),r=a||c||n;return r?(this.successfulToastLifetime&&this.lifetimeManager.start(t),r):(this.lifetimeManager.stop(t),r)}async createTransactionToast(t,s){let o=xt({toastId:t,totalDuration:s});return this.handleCompletedTransaction(t),await this.updateTransactionToastsList(),o}createCustomToast(t){let s=N(t);return this.updateCustomToastList(),s}async updateTransactionToastsList(){let{toasts:t,transactions:s,account:o}=this.store.getState(),{pendingTransactionToasts:i,completedTransactionToasts:n}=await L({toastList:t,transactionsSessions:s,account:o});this.transactionToasts=[...i,...n];for(let a of t.transactionToasts)this.handleCompletedTransaction(a.toastId);await this.publishTransactionToasts()}async updateCustomToastList(){let{toasts:t}=this.store.getState();this.customToasts=[];for(let s of t.customToasts){let i="message"in s?{...s}:{...s,instantiateToastElement:O[s.toastId]};this.customToasts.push(i),s.duration&&this.lifetimeManager.startWithCustomDuration(s.toastId,s.duration)}this.eventBus?.publish("CUSTOM_TOAST_DATA_UPDATE",this.customToasts)}async createToastListElement(){return this.toastsElement?this.toastsElement:(this.isCreatingElement||(this.isCreatingElement=!0,this.toastsElement=await rt.create({name:"mvx-toast-list"}),this.isCreatingElement=!1),this.toastsElement)}handleTransactionToastClose(t){this.handleCompletedTransaction(t)&&P(t)}async subscribeToEventBusNotifications(){let t=await this.createToastListElement();if(t){if(this.eventBus=await t.getEventBus(),!this.eventBus)throw new Error("eventBus is not initialized");this.eventBus.subscribe("CLOSE_TOAST",this.handleCloseToast.bind(this)),this.eventBusUnsubscribeFunctions.push(()=>{this.eventBus?.unsubscribe("CLOSE_TOAST",this.handleCloseToast.bind(this))}),this.eventBus.subscribe("OPEN_NOTIFICATIONS_FEED",this.handleOpenNotificationsFeed.bind(this)),this.eventBusUnsubscribeFunctions.push(()=>{this.eventBus?.unsubscribe("OPEN_NOTIFICATIONS_FEED",this.handleOpenNotificationsFeed.bind(this))})}}async showToasts(){this.eventBus?.publish("SHOW_TOAST_LIST",null),await this.updateCustomToastList(),await this.updateTransactionToastsList()}hideToasts(){this.eventBus?.publish("HIDE_TOAST_LIST",null)}async handleOpenNotificationsFeed(){this.notificationsFeedManager.openNotificationsFeed()}handleCloseToast(t){if(this.customToasts.find(o=>o.toastId===t)){this.lifetimeManager.stop(t);let o=T[t];o?.(),F(t);return}this.handleTransactionToastClose(t)}async publishTransactionToasts(){if(this.notificationsFeedManager.isNotificationsFeedOpen()&&this.eventBus){this.eventBus.publish("TRANSACTION_TOAST_DATA_UPDATE",this.transactionToasts),this.hideToasts();return}if(!this.eventBus){let t=await this.createToastListElement();if(!t)return;this.eventBus=await t.getEventBus()}this.eventBus.publish("TRANSACTION_TOAST_DATA_UPDATE",this.transactionToasts)}destroy(){this.storeToastsSubscription(),this.lifetimeManager?.destroy(),this.notificationsFeedManager?.destroy(),At(),this.eventBusUnsubscribeFunctions.forEach(t=>t()),this.eventBusUnsubscribeFunctions=[]}};export{A as a,O as b,T as c,kt as d,F as e,At as f,Go as g,xt as h,P as i,N as j,D as k,p as l,x as m,B as n,Lt as o,k as p,bt as q,M as r,St as s,f as t,Ct as u};
|
|
2
|
+
//# sourceMappingURL=chunk-2D4DUCY4.mjs.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{a as r}from"./chunk-RWQNLK3I.mjs";import{a as o}from"./chunk-IPMSVHGJ.mjs";import{a as g}from"./chunk-PSJI2G34.mjs";import{a as i}from"./chunk-2CG6PNPJ.mjs";import{a as c}from"./chunk-FROSOADM.mjs";import{a as d}from"./chunk-VJBLHJYB.mjs";import{a
|
|
2
|
-
//# sourceMappingURL=chunk-
|
|
1
|
+
import{a as r}from"./chunk-RWQNLK3I.mjs";import{a}from"./chunk-RRK6GTWZ.mjs";import{a as o}from"./chunk-IPMSVHGJ.mjs";import{a as g}from"./chunk-PSJI2G34.mjs";import{a as i}from"./chunk-2CG6PNPJ.mjs";import{a as c}from"./chunk-FROSOADM.mjs";import{a as d}from"./chunk-VJBLHJYB.mjs";import{a as p,b as e}from"./chunk-HDRB2QL6.mjs";import{rest as t}from"msw";import{setupServer as u}from"msw/node";var s=m=>(R,f,n)=>f(n.status(200),n.json(m)),k=[t.get(`${e.apiAddress}/dapp/config`,s(c)),t.get(`${e.apiAddress}/network/config`,s(i)),t.get(`https://${o.url}/socket.io/`,s(g)),t.get(`${e.apiAddress}/websocket/config`,s(o)),t.get(`${e.apiAddress}/accounts/${p}`,s(a)),t.get(`${e.apiAddress}/accounts/${r.address}`,s(r)),t.get(`${e.apiAddress}/blocks`,s(d))],P=u(...k);export{t as a,s as b,P as c};
|
|
2
|
+
//# sourceMappingURL=chunk-2ONA7QPD.mjs.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{a as i}from"./chunk-FKBLKOLI.mjs";import{a as t}from"./chunk-U64LDJTG.mjs";import{a as o}from"./chunk-
|
|
2
|
-
//# sourceMappingURL=chunk-
|
|
1
|
+
import{a as i}from"./chunk-FKBLKOLI.mjs";import{a as t}from"./chunk-U64LDJTG.mjs";import{a as o}from"./chunk-R725UMBR.mjs";import{u as n}from"./chunk-5MC44CTJ.mjs";import{b as e}from"./chunk-SAAOQW7P.mjs";var w=async r=>{let{isGuarded:s}=o();if(!i({isGuarded:s,transactions:r}))return r;let a=r[0].getSender().bech32().toString(),{walletAddress:d}=e(n());return await(await t({address:a,walletUrl:d}))?.guardTransactions(r)||[]};export{w as a};
|
|
2
|
+
//# sourceMappingURL=chunk-33D26THL.mjs.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{l as p,s as e}from"./chunk-
|
|
2
|
-
//# sourceMappingURL=chunk-
|
|
1
|
+
import{l as p,s as e}from"./chunk-5MC44CTJ.mjs";import{c as i}from"./chunk-R53MCZI6.mjs";var T=()=>e().setState(p),m=({address:o,providerType:d})=>{e().setState(({account:r,loginInfo:t})=>{r.address=o,r.publicKey=new i(o).hex(),t&&(t.providerType=d)},!1,"loginAction")};export{T as a,m as b};
|
|
2
|
+
//# sourceMappingURL=chunk-3AC72XDZ.mjs.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{a as w}from"./chunk-QXC4D3AC.mjs";import{a as g}from"./chunk-YGI3KXMZ.mjs";import{a as b}from"./chunk-
|
|
2
|
-
//# sourceMappingURL=chunk-
|
|
1
|
+
import{a as w}from"./chunk-QXC4D3AC.mjs";import{a as g}from"./chunk-YGI3KXMZ.mjs";import{a as b}from"./chunk-PHEK22HL.mjs";import{a as f}from"./chunk-6FXEHNGW.mjs";import{f as m}from"./chunk-J4CPYFK6.mjs";import x from"bignumber.js";var v=async({manager:e,provider:d})=>{if(!e||!d)throw new Error("Provider is not initialized.");let{network:u}=b(),n=e.getAccountScreenData()?.startIndex||0,r=e.getAllAccounts(),a=await w({baseURL:u.apiAddress}),l=c=>c.index>=n&&c.index<n+e.addressesPerPage,I=r.reduce((c,s)=>Object.assign(c,{[s.index]:s}),{}),A=r.filter(l),y=!!I[n];if(e.updateAccountScreen({isLoading:!y}),A.length>0){e.updateAccountScreen({accounts:A});return}try{let c=await d.getAccounts(n,e.addressesPerPage),s=c.map((t,o)=>({address:t,balance:"...",index:o+n})),L=[...r,...s],j=c.map(t=>f({address:t,baseURL:u.apiAddress})),O=await Promise.all(j),i=L.reduce((t,o)=>Object.assign(t,{[o.address]:o}),{});O.forEach(t=>{if(!t||!a||!a.price)return;let o=new x(t.balance),U=o.dividedBy(x(10).pow(18)).toFormat(4).toString();if(o.isNaN())return;let h=g({amount:m({input:t.balance}),usd:a?.price});i[t.address].balance=U,i[t.address].usdValue=h});let p=Object.values(i).sort((t,o)=>t.index-o.index),S=p.filter(l);e.updateAllAccounts(p),e.updateAccountScreen({accounts:S,isLoading:!1})}catch(c){console.error("Failed to fetch accounts:",c)}};export{v as a};
|
|
2
|
+
//# sourceMappingURL=chunk-3HHV6IM7.mjs.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{b as s,f as l}from"./chunk-QJSB5NX4.mjs";import{f as a}from"./chunk-VNLGNNIL.mjs";import{a as d,b as L}from"./chunk-NLRDRI7Q.mjs";import{a as k}from"./chunk-
|
|
2
|
-
//# sourceMappingURL=chunk-
|
|
1
|
+
import{b as s,f as l}from"./chunk-QJSB5NX4.mjs";import{f as a}from"./chunk-VNLGNNIL.mjs";import{a as d,b as L}from"./chunk-NLRDRI7Q.mjs";import{a as k}from"./chunk-PBBTJFMG.mjs";import{a as v}from"./chunk-KRWR77QE.mjs";import{b as y}from"./chunk-A7FTKX2A.mjs";import{a as g,b as c}from"./chunk-7BP53CXF.mjs";import{a as f,b as m}from"./chunk-X4XULIVT.mjs";import{a as T}from"./chunk-CYCS3K6Q.mjs";import{a as S,b as u}from"./chunk-VKEESSBI.mjs";import{a as x}from"./chunk-2DNGCNYM.mjs";import{a as I}from"./chunk-NB7A4C7L.mjs";import{c as p}from"./chunk-R53MCZI6.mjs";import{createJSONStorage as h,devtools as O,persist as V}from"zustand/middleware";import{immer as H}from"zustand/middleware/immer";import{createStore as N}from"zustand/vanilla";var A=e=>{e.account=g,e.loginInfo=f,e.transactions=d,e.toasts=S};function R(){return new Date().setHours(new Date().getHours()+24)}function w(e){if(e==null){E();return}b(e)}var C=e=>{let t=l(e),n=a(e),{address:i,publicKey:M}=s(e);if(i&&M!==new p(i).hex()&&A(e),!t)return;if(n==null){w(R());return}let P=Date.now();n-P<0&&(w(null),o().setState(A))};var W=(e,t)=>{C(e)};var z=e=>{let t=N(O(V(H((...n)=>({network:x(...n),account:c(...n),loginInfo:m(...n),config:T(...n),transactions:L(...n),toasts:u(...n),cache:y(...n),ui:I(...n)})),{name:"sdk-dapp-store",storage:h(e)})));return t.subscribe(W),t},r,D=e=>{r=e},o=()=>(r||D(z(()=>new v)),r),ae=(e=k)=>D(z(e)),pe=()=>o().getState();var fe=e=>o().setState(({loginInfo:t})=>{t.providerType=e},!1,"setProviderType"),me=e=>o().setState(({loginInfo:t})=>{t.tokenLogin=e},!1,"setTokenLogin"),Se=e=>o().setState(({loginInfo:t})=>{if(t.tokenLogin!=null){t.tokenLogin.loginToken=e;return}t.tokenLogin={loginToken:e}},!1,"setLoginToken"),ue=e=>o().setState(({loginInfo:t})=>{t?.tokenLogin!=null&&(t.tokenLogin.signature=e)},!1,"setTokenLoginSignature"),de=e=>o().setState(({loginInfo:t})=>{t.walletLogin=e},!1,"setWalletLogin"),Le=e=>o().setState(({loginInfo:t})=>{t.walletConnectLogin=e},!1,"setWalletConnectLogin"),xe=e=>o().setState(({loginInfo:t})=>{t.ledgerLogin=e},!1,"setLedgerLogin"),Te=e=>o().setState(({loginInfo:t})=>{t.logoutRoute=e},!1,"setLogoutRoute"),ye=e=>o().setState(({loginInfo:t})=>{t.isWalletConnectV2Initialized=e},!1,"setIsWalletConnectV2Initialized"),E=()=>o().setState(({loginInfo:e})=>{e.loginExpiresAt=null},!1,"removeLoginExpiresAt"),b=e=>o().setState(({loginInfo:t})=>{t.loginExpiresAt=e},!1,"addLoginExpiresAt");export{fe as a,me as b,Se as c,ue as d,de as e,Le as f,xe as g,Te as h,ye as i,E as j,b as k,A as l,R as m,w as n,C as o,W as p,z as q,D as r,o as s,ae as t,pe as u};
|
|
2
|
+
//# sourceMappingURL=chunk-5MC44CTJ.mjs.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{a as h}from"./chunk-
|
|
2
|
-
//# sourceMappingURL=chunk-
|
|
1
|
+
import{a as h}from"./chunk-JLVWBFTU.mjs";import{a as p}from"./chunk-BU6PLF6D.mjs";import{a as d}from"./chunk-53X3CO6E.mjs";import{a as T}from"./chunk-LUDF7ZUR.mjs";var f=a=>a.sort((i,o)=>o.timestamp-i.timestamp),H=async({transactions:a,address:i,explorerAddress:o,egldLabel:g})=>{let e=[],r=[];if(a.forEach(s=>{let t=d(s.hash);t?e.push(t):r.push(s.hash)}),r.length===0)return f(e);let c=await h(r),I=c.map(s=>s.txHash),m=r.filter(s=>!I.includes(s));if(m.length>0){let t=a.filter(n=>m.includes(n.hash)).map(n=>({...n,txHash:n.hash,price:0,status:"pending",gasUsed:0,miniBlockHash:"",receiverShard:0,round:0,senderShard:0,timestamp:Date.now()}));c.push(...t)}return c.forEach(s=>{let t=T({transaction:s,address:i,explorerAddress:o,egldLabel:g});t.status!=="pending"&&p({key:`transaction-${s.txHash}`,value:t}),e.push(t)}),f(e)};export{H as a};
|
|
2
|
+
//# sourceMappingURL=chunk-5TVRGEID.mjs.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{a as s}from"./chunk-
|
|
2
|
-
//# sourceMappingURL=chunk-
|
|
1
|
+
import{a as s}from"./chunk-HTG5MOLD.mjs";var a=class{constructor({uiDataUpdateEvent:t,uiTag:e}){this.eventBus=null;this.uiElement=null;this.isCreatingElement=!1;this.unsubscribeFunctions=new Map;this.uiDataUpdateEvent=t,this.uiTag=e,this.data=this.getInitialData()}async init(t){this.anchor=t,await this.createUIElement(t),await this.setupEventListeners()}updateData(t){this.data={...this.data,...t},this.notifyDataUpdate()}subscribeToEventBus(t,e){if(!this.eventBus)throw new Error("eventBus is not initialized");let i=this.eventBus?.subscribe(t,e);if(i){let n=this.unsubscribeFunctions.get(t)||[];n.push(i),this.unsubscribeFunctions.set(t,n)}}notifyDataUpdate(){this.eventBus?.publish(this.uiDataUpdateEvent,this.data)}destroy(){this.unsubscribeFunctions.forEach(t=>t.forEach(e=>e())),this.unsubscribeFunctions.clear(),this.eventBus=null,this.uiElement?.remove(),this.uiElement=null}getInitialData(){return this.initialData}resetData(){this.data=this.getInitialData()}async createUIElement(t=this.anchor){if(this.isCreatingElement||this.uiElement)return this.uiElement;if(this.isCreatingElement=!0,this.uiElement=await s.create({name:this.uiTag,anchor:t}),this.isCreatingElement=!1,!this.uiElement)throw new Error(`Failed to create ${this.uiTag} element`);if(this.eventBus||(this.eventBus=await this.uiElement.getEventBus()),!this.eventBus)throw new Error("eventBus is not initialized");return this.uiElement}};export{a};
|
|
2
|
+
//# sourceMappingURL=chunk-5VEB2Q3E.mjs.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{u as e}from"./chunk-
|
|
2
|
-
//# sourceMappingURL=chunk-
|
|
1
|
+
import{u as e}from"./chunk-5MC44CTJ.mjs";import{b as o}from"./chunk-SAAOQW7P.mjs";import{a as i}from"./chunk-CKTFPRJS.mjs";var n="https://api.multiversx.com",s=60*60*24,a=5*60,d=t=>{let r=o(e());return{origin:t?.origin||i().origin,apiAddress:t?.apiAddress||r.apiAddress||n,expirySeconds:t?.expirySeconds||s,tokenExpirationToastWarningSeconds:t?.tokenExpirationToastWarningSeconds||a}};export{d as a};
|
|
2
|
+
//# sourceMappingURL=chunk-6FGDARXH.mjs.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{a as r}from"./chunk-
|
|
2
|
-
//# sourceMappingURL=chunk-
|
|
1
|
+
import{a as r}from"./chunk-JEB6OIJ7.mjs";import{a as o}from"./chunk-WE7YOBO7.mjs";async function p({loginToken:i,extraInfoData:n}){if(i==null||Object.keys(n).length===0)return null;let t=o(String(i)),{timestamp:e,...a}=t?.extraInfo||{};if(!(t&&e!=null))return null;let s={hash:String(t?.blockHash),timestamp:Number(e)};return await r({extraInfo:{...a,...n},expirySeconds:t?.ttl,origin:t?.origin}).initialize({latestBlockInfo:s})}export{p as a};
|
|
2
|
+
//# sourceMappingURL=chunk-6XOHFAL4.mjs.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{a as e}from"./chunk-
|
|
2
|
-
//# sourceMappingURL=chunk-
|
|
1
|
+
import{a as e}from"./chunk-MC23BEFI.mjs";var t={closeConnectionRef:void 0};async function c(n){let{closeConnection:o}=await e(n);t.closeConnectionRef=o}export{t as a,c as b};
|
|
2
|
+
//# sourceMappingURL=chunk-AK44E24X.mjs.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{a as e}from"./chunk-
|
|
2
|
-
//# sourceMappingURL=chunk-
|
|
1
|
+
import{a as e}from"./chunk-JLVWBFTU.mjs";var i=async a=>{let r=a.map(s=>s.hash),n=await e(r);return a.map(s=>{let t=n.find(o=>o?.txHash===s.hash);return{...s,status:t?.status,invalidTransaction:t==null,results:t?.results??[],previousStatus:s.status?.toString()||"",hasStatusChanged:!!(t&&t.status!==s.status)}})};export{i as a};
|
|
2
|
+
//# sourceMappingURL=chunk-APRKCU5W.mjs.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{a as u}from"./chunk-
|
|
2
|
-
//# sourceMappingURL=chunk-
|
|
1
|
+
import{a as u}from"./chunk-R725UMBR.mjs";import{a as f}from"./chunk-JEB6OIJ7.mjs";import{a as g}from"./chunk-6FGDARXH.mjs";import{b as a}from"./chunk-5MC44CTJ.mjs";import{c as s,g as r}from"./chunk-R53MCZI6.mjs";var v=async({signMessageCallback:m,nativeAuthClientConfig:o})=>{let{address:t}=u(),c=g(),i=f(o||c),e=await i.initialize({noCache:!!o});if(!e)return null;let h=new r({address:new s(t),data:Buffer.from(`${t}${e}`)}),n=await m(h,{});if(!n?.signature)throw"Message not signed";return a({loginToken:e,signature:Buffer.from(n.signature).toString("hex")}),i.getToken({address:t,token:e,signature:Buffer.from(n.signature).toString("hex")})};export{v as a};
|
|
2
|
+
//# sourceMappingURL=chunk-ATOIEDNS.mjs.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{a as w}from"./chunk-YK7T6MBD.mjs";import{a as l}from"./chunk-KMJMQEXI.mjs";import{s as u}from"./chunk-
|
|
2
|
-
//# sourceMappingURL=chunk-
|
|
1
|
+
import{a as w}from"./chunk-YK7T6MBD.mjs";import{a as l}from"./chunk-KMJMQEXI.mjs";import{s as u}from"./chunk-5MC44CTJ.mjs";import{a as c}from"./chunk-SQVKVA7X.mjs";import{a as i}from"./chunk-ULUZWP2P.mjs";var e=o=>u().setState(({network:r})=>{r.network={...r.network,...o}},!1,"initializeNetworkConfig");var y=async({customNetworkConfig:o={},environment:r})=>{let d=!o?.skipFetchFromServer,g=o?.apiAddress,n=r&&r in i,p=n?i[r]:{},s={...c,...p,...o},t={...s,apiTimeout:String(s.apiTimeout)},N=p?.apiAddress;if(!n&&d){let a=g||N,m=await w(a),f=t.roundDuration?null:await l(a);if(f!=null&&(t.roundDuration=f.erd_round_duration),m!=null){let k={...t,...m,...o};return e(k),k}}return e(t),t};export{y as a,e as b};
|
|
2
|
+
//# sourceMappingURL=chunk-B6UQJ7RN.mjs.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{s as a}from"./chunk-
|
|
2
|
-
//# sourceMappingURL=chunk-
|
|
1
|
+
import{s as a}from"./chunk-5MC44CTJ.mjs";var r=({key:e,value:t})=>{a().setState(({cache:c})=>{c[e]=t},!1,"saveToCache")},s=e=>{a().setState(({cache:t})=>{delete t[e]},!1,"removeFromCache")},h=()=>{a().setState(({cache:e})=>{Object.keys(e).forEach(t=>{delete e[t]})},!1,"clearCache")};export{r as a,s as b,h as c};
|
|
2
|
+
//# sourceMappingURL=chunk-BU6PLF6D.mjs.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{a as ce}from"./chunk-OZ4ZZI3H.mjs";import{a as de}from"./chunk-M3YL36ZL.mjs";import{a as oe}from"./chunk-HXXZKQRJ.mjs";import{a as R}from"./chunk-4XP7BVJD.mjs";import{a as ne}from"./chunk-254WMLVS.mjs";import{a as ie}from"./chunk-FAOCLLIW.mjs";import{a as u}from"./chunk-CIY7IH2N.mjs";import{a as te}from"./chunk-YUFPUG5O.mjs";import{a as le}from"./chunk-D5SD7UPB.mjs";import{a as p}from"./chunk-2S5FRZJR.mjs";import{a as re}from"./chunk-V2C7APME.mjs";import{a as ae}from"./chunk-BG6QTPZ4.mjs";import{a as se}from"./chunk-3NFKZZ7W.mjs";import{a as ee}from"./chunk-QJGFIK7H.mjs";import{b as Z}from"./chunk-4Z3DZ2A3.mjs";import{e as w,f as Q}from"./chunk-FFHVVGYW.mjs";import{j as Y,l as N,r as S,s as C,t as b}from"./chunk-I6BXGQLQ.mjs";import{a as I}from"./chunk-RFKBUN7S.mjs";import{g as X}from"./chunk-CAA4VJRH.mjs";import{a as $}from"./chunk-6ZL2QC74.mjs";import{a as U}from"./chunk-4TBVQD27.mjs";import{a as J}from"./chunk-VXLJWKLG.mjs";import{a as j,s as K,u as l}from"./chunk-4QDHGYT4.mjs";import{f as B}from"./chunk-QJSB5NX4.mjs";import{b as E,c as H}from"./chunk-SAAOQW7P.mjs";import{a as G}from"./chunk-VNLGNNIL.mjs";import{b as q,c as F}from"./chunk-6JM4DPOH.mjs";import{a as L}from"./chunk-VMFJUT3G.mjs";import{a as c}from"./chunk-TI73UXGG.mjs";import{a as n}from"./chunk-S2FQWSUO.mjs";import{a as M}from"./chunk-L4QPPHVR.mjs";import{IframeLoginTypes as ve}from"@multiversx/sdk-web-wallet-iframe-provider/out/constants";var y=class extends p{constructor({address:e,anchor:r,shouldInitProvider:t}){super(e);this.provider=null;this.config=null;this.ledgerLogin=async e=>{if(!this.provider)throw new Error("Provider is not initialized.");if(!e||typeof e.addressIndex!="number")throw new Error("Missing addressIndex for Ledger login");let{address:r,signature:t}=await this.provider.login({addressIndex:e.addressIndex});return{address:r,signature:t??""}};this.loginOperation=async e=>{if(!this.provider||!this.config)throw new Error("Provider is not initialized.");return await oe({options:e,config:this.config,provider:this.provider,login:this.ledgerLogin.bind(this)})};this.initLegderConnectManager=async e=>{if(!!u())return;await R.getInstance().init(e)};this.signTransactions=async e=>{if(!this.provider)throw new Error("Provider is not initialized.");return await this.rebuildProvider(),await ae({transactions:e,handleSign:this.provider.signTransactions.bind(this.provider)})};this.signMessage=async e=>{if(!this.provider)throw new Error("Provider is not initialized.");return await this.rebuildProvider(),await pe({message:e,handleSignMessage:this.provider.signMessage.bind(this.provider)})};this.rebuildProvider=async()=>{try{await this.provider?.getAddress()}catch{try{let{ledgerProvider:r}=await ie({shouldInitProvider:!0});this.provider=r}catch(r){throw Y({toastId:"ledger-provider-rebuild-error",duration:1e4,icon:"times",iconClassName:"warning",message:"Unlock your device & open the MultiversX App",title:"Ledger unavailable"}),r}}};this.options={anchor:r,shouldInitProvider:t},this._login=this.ledgerLogin.bind(this)}async init(){try{this.initializeAddress(),await this.initializeProvider()}catch{return!1}return!0}logout(){if(!this.provider)throw new Error("Provider is not initialized.");return this.provider.logout()}getType(){return n.ledger}getAddress(){if(!this.provider)throw new Error("Provider is not initialized.");return this.provider.getAddress()}setAccount(e){return this.provider?.setAccount(e)}isInitialized(){if(!this.provider)throw new Error("Provider is not initialized.");return this.provider.isInitialized()}async initializeProvider(){await L(M),await this.initLegderConnectManager(this.options?.anchor);let e=R.getInstance(),{ledgerProvider:r,ledgerConfig:t}=await new Promise((o,a)=>ne({manager:e,resolve:o,reject:a,shouldInitProvider:this.options?.shouldInitProvider}));this.config=t,this.provider=r}};var ue=3e4,fe=5e3,we=3e3,z=class s{constructor(){this.store=K();this.connectionCheckInterval=null;this.recreateProviderInterval=null;this.init=async()=>{this.startCheckConnectionLoop()};this.shouldCheckConnection=()=>{let i=this.store.getState(),{providerType:e}=G(i),r=B(i);return!!(e===n.ledger&&r)};this.startCheckConnectionLoop=()=>{this.connectionCheckInterval||(this.connectionCheckInterval=setInterval(async()=>{let i=Z(l());if(!(!this.shouldCheckConnection()||i))try{await b().getProvider().getAddress()}catch{if(N.getInstance().createCustomToast({toastId:"ledger-provider-idle-warning",icon:"times",iconClassName:"warning",message:"Unlock your device to continue signing transactions",title:"Ledger disconnected"}),this.reset(),this.recreateProviderInterval)return;this.recreateProviderInterval=setInterval(this.reconnectProvider,fe)}},ue))};this.reconnectProvider=async()=>{if(this.shouldCheckConnection())try{let i=new y({shouldInitProvider:!0});await i.init();let e=new S(i);i.getType=()=>n.ledger,C(e),this.reset(),clearInterval(this.recreateProviderInterval??0),this.recreateProviderInterval=null,N.getInstance().createCustomToast({toastId:"ledger-provider-idle-warning",duration:we,icon:"check",iconClassName:"success",message:"Your device is ready to sign transactions",title:"Ledger reconnected"}),this.startCheckConnectionLoop()}catch{console.log("Unable to reconnect to Ledger")}};this.reset=()=>{clearInterval(this.connectionCheckInterval??0),this.connectionCheckInterval=null}}static getInstance(){return s.instance||(s.instance=new s),s.instance}};var W=class extends p{constructor(e){super(e?.address);this.cancelAction=async()=>{this.provider.cancelAction()};this.signTransactions=async e=>{if(!this.provider)throw new Error("Provider is not initialized.");let{onClose:r,manager:t}=await this.initSignState();try{let o=await this.provider.signTransactions(e)??[];return await se(o)}catch(o){throw await r({shouldCancelAction:!0}),o}finally{t.closeUI()}};this.signMessage=async e=>{if(!this.provider)throw new Error("Provider is not initialized.");return await g({message:e,handleSignMessage:this.provider.signMessage.bind(this.provider),cancelAction:this.cancelAction,providerType:c.crossWindow})};this.walletAddress=e?.walletAddress,this.provider=ee.getInstance(),this._login=this.provider.login.bind(this.provider)}async init(){return this.initializeAddress(),this.initializeProvider()}async initializeProvider(){let e=E(l()),r=await this.provider.init();return this.provider.setWalletUrl(this.walletAddress??e.walletAddress),this.address&&this.provider.setAddress(this.address),r}logout(){return this.provider.logout()}getType(){return n.crossWindow}getAddress(){if(!this.provider)throw new Error("Provider is not initialized.");return this.provider.getAddress()}setAccount(e){return this.provider.setAccount(e)}isInitialized(){return this.provider.isInitialized()}};import{ExtensionProvider as ye}from"@multiversx/sdk-extension-provider/out/extensionProvider";var _=class extends p{constructor(e){super(e);this.cancelAction=async()=>{this.provider.cancelAction()};this.signTransactions=async e=>{if(!this.provider)throw new Error("Provider is not initialized.");let{manager:r,onClose:t}=await this.initSignState();try{return await this.provider.signTransactions(e)??[]}catch(o){throw await t({shouldCancelAction:!1}),o}finally{r.closeUI()}};this.signMessage=async e=>{if(!this.provider)throw new Error("Provider is not initialized.");return await g({message:e,handleSignMessage:this.provider.signMessage.bind(this.provider),cancelAction:this.cancelAction,providerType:c.extension})};this.provider=ye.getInstance(),this._login=this.provider.login.bind(this.provider)}async init(){return this.initializeAddress(),this.initializeProvider()}async initializeProvider(){let e=await this.provider.init();return this.address&&this.setAccount({address:this.address}),e}getAddress(){return this.provider.getAddress()}setAccount(e){return this.provider.setAccount(e)}isInitialized(){return this.provider.isInitialized()}logout(){return this.provider.logout()}getType(){return n.extension}};var Pe={passkey:n.passkey,metamask:n.metamask},T=class extends p{constructor({type:e,address:r,walletUrl:t}){super(r);this.cancelAction=async()=>{this.provider.cancelAction()};this.signTransactions=async e=>{if(!this.provider)throw new Error("Provider is not initialized.");let{manager:r,onClose:t}=await this.initSignState();try{return await this.provider.signTransactions(e)}catch(o){throw await t({shouldCancelAction:!0}),o}finally{r.closeUI()}};this.signMessage=async e=>{if(!this.provider||!this.type)throw new Error("Provider is not initialized.");return await g({message:e,handleSignMessage:this.provider.signMessage.bind(this.provider),cancelAction:this.cancelAction,providerType:c[this.type]})};this.type=e,this.walletUrl=t??"",this.provider=de.getInstance(),this._login=this.provider.login.bind(this.provider)}init(){return this.initializeAddress(),this.initializeWalletUrl(),this.initializeProvider()}initializeWalletUrl(){if(this.walletUrl)return;let e=E(l());if(!e.iframeWalletAddress)throw new Error("Invalid walletUrl");this.walletUrl=e.iframeWalletAddress}async initializeProvider(){return await this.provider.init(),this.address&&this.setAccount({address:this.address}),this.provider.setLoginType(this.type),this.provider.setWalletUrl(this.walletUrl),!0}logout(){return this.provider.logout()}getType(){return Pe[this.type]}getAddress(){if(!this.provider)throw new Error("Provider is not initialized.");return this.provider.getAddress()}setAccount(e){this.provider.setAccount(e)}isInitialized(){return this.provider.isInitialized()}};import{OptionalOperation as ge}from"@multiversx/sdk-wallet-connect-provider/out";var me=[w.CANCEL_ACTION,w.SIGN_LOGIN_TOKEN],x=class extends p{constructor(e){super();this.provider=null;this.methods=[];this._approval=null;this.signTransactions=async e=>{if(!this.provider)throw new Error("Provider is not initialized.");let{manager:r,onClose:t}=await this.initSignState();try{return await this.provider.signTransactions(e)}catch(o){throw await t({shouldCancelAction:!0}),await this.sendCustomRequest({method:w.CANCEL_ACTION,action:ge.CANCEL_ACTION}),o}finally{r.closeUI()}};this.cancelAction=async()=>{await this.sendCustomRequest({method:w.CANCEL_ACTION,action:ge.CANCEL_ACTION})};this.signMessage=async e=>{if(!this.provider)throw new Error("Provider is not initialized.");return await g({message:e,handleSignMessage:this.provider.signMessage.bind(this.provider),cancelAction:this.cancelAction,providerType:c.extension})};this.config=e}async init(){try{await this.initializeProvider()}catch{return!1}return!0}logout(){if(!this.provider)throw new Error("Provider is not initialized.");return this.provider.logout()}getType(){return n.walletConnect}getAddress(){if(!this.provider)throw new Error("Provider is not initialized.");return Promise.resolve(this.provider.getAddress())}setAccount(e){return this.provider?.setAccount(e)}isInitialized(){if(!this.provider)throw new Error("Provider is not initialized.");return this.provider.isInitialized()}async initializeProvider(){if(await L(M),await this.initWalletConnectManager(),!this.config)throw new Error("Invalid WalletConnect setup");let{walletConnectProvider:e,dappMethods:r}=await this.createWalletConnectProvider(this.config);this.provider=e,this.methods=r;let{uri:t="",approval:o}=await this.provider.connect({methods:this.methods}),a=this.config.walletConnectDeepLink??U.walletConnectDeepLink;this._approval=o,I.getInstance().updateData({wcURI:t,walletConnectDeepLink:`${a}?wallet-connect=${encodeURIComponent(t)}`})}async initWalletConnectManager(){if(!!u())return;await I.getInstance().init(this.config?.anchor)}async createWalletConnectProvider(e){let r=u(),t=H(l());if(q(l())&&me.push(w.SIGN_NATIVE_AUTH_TOKEN),!e?.walletConnectV2ProjectId)throw new Error("Invalid WalletConnect setup");let h={onClientLogin:()=>{},onClientLogout:()=>{J()},onClientEvent:m=>{}};try{let{walletConnectV2ProjectId:m,walletConnectV2Options:O={},walletConnectV2RelayAddress:D=""}=e,P=new Q(h,t,D,m,O);return await P.init(),{walletConnectProvider:P,dappMethods:me}}catch(m){throw console.error("Unable to connect",m),r&&await this.logout(),m}}async login(e){if(!this.provider)throw new Error("Provider is not initialized. Call createProvider first.");let r=async()=>{if(!this.provider)throw new Error("Provider is not initialized.");try{await this.provider.init();let t=I.getInstance(),{uri:o="",approval:a}=await this.provider.connect({methods:this.methods}),d=this.config.walletConnectDeepLink??U.walletConnectDeepLink;t.updateData({wcURI:o,walletConnectDeepLink:`${d}?wallet-connect=${encodeURIComponent(o)}`});let v=await this.provider.login({approval:a,token:e?.token}),{address:h="",signature:m=""}=v??{};return t.handleClose({isLoginFinished:!!h}),{address:h,signature:m}}catch{return await r()}};if(!this._approval)throw new Error("Approval or login is not initialized");try{let t=await this.provider.login({approval:this._approval.bind(this),token:e?.token}),{address:o="",signature:a=""}=t??{};return I.getInstance().handleClose({isLoginFinished:!!o}),{address:o,signature:a}}catch(t){return console.error("User rejected connection proposal",t),await r()}}async sendCustomRequest({action:e,method:r}){if(!this.provider)throw new Error("Provider is not initialized.");try{await this.provider.sendCustomRequest?.({request:{method:r,params:{action:e}}})}catch(t){console.error("Unable to send event",t)}}};var A=class{static set customProviders(i){this._customProviders=i}static get customProviders(){return this._customProviders}static async create({type:i,anchor:e}){let r=null;switch(i){case n.extension:{r=new _;break}case n.crossWindow:{r=new W;break}case n.ledger:{r=new y({anchor:e}),await z.getInstance().init();break}case n.metamask:{r=new T({type:ve.metamask});break}case n.passkey:{r=new T({type:ve.passkey});break}case n.walletConnect:{let d=F(l());if(!d?.walletConnectV2ProjectId)throw new Error("Invalid WalletConnect setup");r=new x({anchor:e,...d});break}case n.webview:{r=new le;break}default:{let d=$();for(let v of this._customProviders)v.type===i&&(r=await v.constructor({address:d,anchor:e}));break}}if(!r)throw new Error("Unable to create provider");await r.init();let t=u(),o=new S(r);t&&C(o);let a=[n.crossWindow,n.metamask,n.passkey].includes(i);return ce(a?{skipLoginMethod:i}:null),o}static async destroy(){b().cancelLogin(),C(null),j(n.none)}};A._customProviders=[];var Ce=(s,i)=>s.some(e=>e.type===i);async function g({message:s,handleSignMessage:i,cancelAction:e,providerType:r}){return await new Promise(async(o,a)=>{let{manager:d,onClose:v}=await re({cancelAction:e}),h=Object.values(A.customProviders),m=h.reduce((f,V)=>(f[V.type]=V.name,f),{}),O={...c,...m},D=async()=>{await v({shouldCancelAction:!0}),a({message:"Signing canceled"})};d.subscribeToEventBus("CLOSE_PENDING_TRANSACTIONS",D);let P=Ce(h,r)?r:n.none;d.updateData({name:O[P],type:P});try{let f=await i(s);o(f)}catch(f){await v({shouldCancelAction:!0}),a(f)}finally{d.closeUI()}})}async function pe({message:s,handleSignMessage:i}){try{return await g({message:s,handleSignMessage:i,providerType:c.ledger})}catch(e){let{errorMessage:r}=te(e);throw r?{message:r}:e}}export{pe as a,y as b,z as c,A as d,g as e,W as f,_ as g,T as h,x as i};
|
|
2
|
-
//# sourceMappingURL=chunk-
|
|
1
|
+
import{a as ce}from"./chunk-OZ4ZZI3H.mjs";import{a as de}from"./chunk-M3YL36ZL.mjs";import{a as oe}from"./chunk-PQUTSIC4.mjs";import{a as R}from"./chunk-UPZSSHAY.mjs";import{a as ne}from"./chunk-NCVIHQO4.mjs";import{a as ie}from"./chunk-NXJJ2A6Q.mjs";import{a as C}from"./chunk-JHG3QIDR.mjs";import{a as te}from"./chunk-YUFPUG5O.mjs";import{a as le}from"./chunk-Y3FER7B6.mjs";import{a as p}from"./chunk-PL7G674F.mjs";import{a as re}from"./chunk-KEE42WYL.mjs";import{a as ae}from"./chunk-UGI3S542.mjs";import{a as se}from"./chunk-33D26THL.mjs";import{a as ee}from"./chunk-QJGFIK7H.mjs";import{b as Z}from"./chunk-4Z3DZ2A3.mjs";import{e as u,f as Q}from"./chunk-FFHVVGYW.mjs";import{j as Y,l as N,r as S,s as I,t as b}from"./chunk-2D4DUCY4.mjs";import{a as P}from"./chunk-MMJFQNPX.mjs";import{g as X}from"./chunk-CAA4VJRH.mjs";import{a as $}from"./chunk-XNPGQK42.mjs";import{a as U}from"./chunk-4TBVQD27.mjs";import{a as J}from"./chunk-3AC72XDZ.mjs";import{a as j,s as K,u as l}from"./chunk-5MC44CTJ.mjs";import{f as B}from"./chunk-QJSB5NX4.mjs";import{b as E,c as H}from"./chunk-SAAOQW7P.mjs";import{a as G}from"./chunk-VNLGNNIL.mjs";import{b as q,c as F}from"./chunk-6JM4DPOH.mjs";import{a as L}from"./chunk-VMFJUT3G.mjs";import{a as d}from"./chunk-TI73UXGG.mjs";import{a as o}from"./chunk-S2FQWSUO.mjs";import{a as M}from"./chunk-R35LPX6Q.mjs";import{IframeLoginTypes as ve}from"@multiversx/sdk-web-wallet-iframe-provider/out/constants";var f=class extends p{constructor({address:e,anchor:r,shouldInitProvider:t}){super(e);this.provider=null;this.config=null;this.ledgerLogin=async e=>{if(!this.provider)throw new Error("Provider is not initialized.");if(!e||typeof e.addressIndex!="number")throw new Error("Missing addressIndex for Ledger login");let{address:r,signature:t}=await this.provider.login({addressIndex:e.addressIndex});return{address:r,signature:t??""}};this.loginOperation=async e=>{if(!this.provider||!this.config)throw new Error("Provider is not initialized.");return await oe({options:e,config:this.config,provider:this.provider,login:this.ledgerLogin.bind(this)})};this.initLegderConnectManager=async e=>{if(!!C())return;await R.getInstance().init(e)};this.signTransactions=async e=>{if(!this.provider)throw new Error("Provider is not initialized.");return await this.rebuildProvider(),await ae({transactions:e,handleSign:this.provider.signTransactions.bind(this.provider)})};this.signMessage=async e=>{if(!this.provider)throw new Error("Provider is not initialized.");return await this.rebuildProvider(),await pe({message:e,handleSignMessage:this.provider.signMessage.bind(this.provider)})};this.rebuildProvider=async()=>{try{await this.provider?.getAddress()}catch{try{let{ledgerProvider:r}=await ie({shouldInitProvider:!0});this.provider=r}catch(r){throw Y({toastId:"ledger-provider-rebuild-error",duration:1e4,icon:"times",iconClassName:"warning",message:"Unlock your device & open the MultiversX App",title:"Ledger unavailable"}),r}}};this.options={anchor:r,shouldInitProvider:t},this._login=this.ledgerLogin.bind(this)}async init(){try{this.initializeAddress(),await this.initializeProvider()}catch{return!1}return!0}logout(){if(!this.provider)throw new Error("Provider is not initialized.");return this.provider.logout()}getType(){return o.ledger}getAddress(){if(!this.provider)throw new Error("Provider is not initialized.");return this.provider.getAddress()}setAccount(e){return this.provider?.setAccount(e)}isInitialized(){if(!this.provider)throw new Error("Provider is not initialized.");return this.provider.isInitialized()}async initializeProvider(){await L(M),await this.initLegderConnectManager(this.options?.anchor);let e=R.getInstance(),{ledgerProvider:r,ledgerConfig:t}=await new Promise((n,s)=>ne({manager:e,resolve:n,reject:s,shouldInitProvider:this.options?.shouldInitProvider}));this.config=t,this.provider=r}};var ue=3e4,fe=5e3,we=3e3,z=class a{constructor(){this.store=K();this.connectionCheckInterval=null;this.recreateProviderInterval=null;this.init=async()=>{this.startCheckConnectionLoop()};this.shouldCheckConnection=()=>{let i=this.store.getState(),{providerType:e}=G(i),r=B(i);return!!(e===o.ledger&&r)};this.startCheckConnectionLoop=()=>{this.connectionCheckInterval||(this.connectionCheckInterval=setInterval(async()=>{let i=Z(l());if(!(!this.shouldCheckConnection()||i))try{await b().getProvider().getAddress()}catch{if(N.getInstance().createCustomToast({toastId:"ledger-provider-idle-warning",icon:"times",iconClassName:"warning",message:"Unlock your device to continue signing transactions",title:"Ledger disconnected"}),this.reset(),this.recreateProviderInterval)return;this.recreateProviderInterval=setInterval(this.reconnectProvider,fe)}},ue))};this.reconnectProvider=async()=>{if(this.shouldCheckConnection())try{let i=new f({shouldInitProvider:!0});await i.init();let e=new S(i);i.getType=()=>o.ledger,I(e),this.reset(),clearInterval(this.recreateProviderInterval??0),this.recreateProviderInterval=null,N.getInstance().createCustomToast({toastId:"ledger-provider-idle-warning",duration:we,icon:"check",iconClassName:"success",message:"Your device is ready to sign transactions",title:"Ledger reconnected"}),this.startCheckConnectionLoop()}catch{console.log("Unable to reconnect to Ledger")}};this.reset=()=>{clearInterval(this.connectionCheckInterval??0),this.connectionCheckInterval=null}}static getInstance(){return a.instance||(a.instance=new a),a.instance}};var W=class extends p{constructor(e){super(e?.address);this.cancelAction=async()=>{this.provider.cancelAction()};this.signTransactions=async e=>{if(!this.provider)throw new Error("Provider is not initialized.");let{onClose:r,manager:t}=await this.initSignState();try{let n=await this.provider.signTransactions(e)??[];return await se(n)}catch(n){throw await r({shouldCancelAction:!0}),n}finally{t.closeUI()}};this.signMessage=async e=>{if(!this.provider)throw new Error("Provider is not initialized.");return await g({message:e,handleSignMessage:this.provider.signMessage.bind(this.provider),cancelAction:this.cancelAction,providerType:d.crossWindow})};this.walletAddress=e?.walletAddress,this.provider=ee.getInstance(),this._login=this.provider.login.bind(this.provider)}async init(){return this.initializeAddress(),this.initializeProvider()}async initializeProvider(){let e=E(l()),r=await this.provider.init();return this.provider.setWalletUrl(this.walletAddress??e.walletAddress),this.address&&this.provider.setAddress(this.address),r}logout(){return this.provider.logout()}getType(){return o.crossWindow}getAddress(){if(!this.provider)throw new Error("Provider is not initialized.");return this.provider.getAddress()}setAccount(e){return this.provider.setAccount(e)}isInitialized(){return this.provider.isInitialized()}};import{ExtensionProvider as ye}from"@multiversx/sdk-extension-provider/out/extensionProvider";var _=class extends p{constructor(e){super(e);this.cancelAction=async()=>{this.provider.cancelAction()};this.signTransactions=async e=>{if(!this.provider)throw new Error("Provider is not initialized.");let{manager:r,onClose:t}=await this.initSignState();try{return await this.provider.signTransactions(e)??[]}catch(n){throw await t({shouldCancelAction:!1}),n}finally{r.closeUI()}};this.signMessage=async e=>{if(!this.provider)throw new Error("Provider is not initialized.");return await g({message:e,handleSignMessage:this.provider.signMessage.bind(this.provider),cancelAction:this.cancelAction,providerType:d.extension})};this.provider=ye.getInstance(),this._login=this.provider.login.bind(this.provider)}async init(){return this.initializeAddress(),this.initializeProvider()}async initializeProvider(){let e=await this.provider.init();return this.address&&this.setAccount({address:this.address}),e}getAddress(){return this.provider.getAddress()}setAccount(e){return this.provider.setAccount(e)}isInitialized(){return this.provider.isInitialized()}logout(){return this.provider.logout()}getType(){return o.extension}};var Pe={passkey:o.passkey,metamask:o.metamask},T=class extends p{constructor({type:e,address:r,walletUrl:t}){super(r);this.cancelAction=async()=>{this.provider.cancelAction()};this.signTransactions=async e=>{if(!this.provider)throw new Error("Provider is not initialized.");let{manager:r,onClose:t}=await this.initSignState();try{return await this.provider.signTransactions(e)}catch(n){throw await t({shouldCancelAction:!0}),n}finally{r.closeUI()}};this.signMessage=async e=>{if(!this.provider||!this.type)throw new Error("Provider is not initialized.");return await g({message:e,handleSignMessage:this.provider.signMessage.bind(this.provider),cancelAction:this.cancelAction,providerType:d[this.type]})};this.type=e,this.walletUrl=t??"",this.provider=de.getInstance(),this._login=this.provider.login.bind(this.provider)}init(){return this.initializeAddress(),this.initializeWalletUrl(),this.initializeProvider()}initializeWalletUrl(){if(this.walletUrl)return;let e=E(l());if(!e.iframeWalletAddress)throw new Error("Invalid walletUrl");this.walletUrl=e.iframeWalletAddress}async initializeProvider(){return await this.provider.init(),this.address&&this.setAccount({address:this.address}),this.provider.setLoginType(this.type),this.provider.setWalletUrl(this.walletUrl),!0}logout(){return this.provider.logout()}getType(){return Pe[this.type]}getAddress(){if(!this.provider)throw new Error("Provider is not initialized.");return this.provider.getAddress()}setAccount(e){this.provider.setAccount(e)}isInitialized(){return this.provider.isInitialized()}};import{OptionalOperation as ge}from"@multiversx/sdk-wallet-connect-provider/out";var me=[u.CANCEL_ACTION,u.SIGN_LOGIN_TOKEN],x=class extends p{constructor(e){super();this.provider=null;this.methods=[];this._approval=null;this.signTransactions=async e=>{if(!this.provider)throw new Error("Provider is not initialized.");let{manager:r,onClose:t}=await this.initSignState();try{return await this.provider.signTransactions(e)}catch(n){throw await t({shouldCancelAction:!0}),await this.sendCustomRequest({method:u.CANCEL_ACTION,action:ge.CANCEL_ACTION}),n}finally{r.closeUI()}};this.cancelAction=async()=>{await this.sendCustomRequest({method:u.CANCEL_ACTION,action:ge.CANCEL_ACTION})};this.signMessage=async e=>{if(!this.provider)throw new Error("Provider is not initialized.");return await g({message:e,handleSignMessage:this.provider.signMessage.bind(this.provider),cancelAction:this.cancelAction,providerType:d.extension})};this.config=e}async init(){try{await this.initializeProvider()}catch{return!1}return!0}logout(){if(!this.provider)throw new Error("Provider is not initialized.");return this.provider.logout()}getType(){return o.walletConnect}getAddress(){if(!this.provider)throw new Error("Provider is not initialized.");return Promise.resolve(this.provider.getAddress())}setAccount(e){return this.provider?.setAccount(e)}isInitialized(){if(!this.provider)throw new Error("Provider is not initialized.");return this.provider.isInitialized()}async initializeProvider(){if(await L(M),await this.initWalletConnectManager(),!this.config)throw new Error("Invalid WalletConnect setup");let{walletConnectProvider:e,dappMethods:r}=await this.createWalletConnectProvider(this.config);this.provider=e,this.methods=r;let{uri:t="",approval:n}=await this.provider.connect({methods:this.methods}),s=this.config.walletConnectDeepLink??U.walletConnectDeepLink;this._approval=n,P.getInstance().updateData({wcURI:t,walletConnectDeepLink:`${s}?wallet-connect=${encodeURIComponent(t)}`})}async initWalletConnectManager(){if(!!C())return;await P.getInstance().init(this.config?.anchor)}async createWalletConnectProvider(e){let r=C(),t=H(l());if(q(l())&&me.push(u.SIGN_NATIVE_AUTH_TOKEN),!e?.walletConnectV2ProjectId)throw new Error("Invalid WalletConnect setup");let v={onClientLogin:()=>{},onClientLogout:()=>{J()},onClientEvent:m=>{}};try{let{walletConnectV2ProjectId:m,walletConnectV2Options:O={},walletConnectV2RelayAddress:D=""}=e,y=new Q(v,t,D,m,O);return await y.init(),{walletConnectProvider:y,dappMethods:me}}catch(m){throw console.error("Unable to connect",m),r&&await this.logout(),m}}async login(e){if(!this.provider)throw new Error("Provider is not initialized. Call createProvider first.");let r=async()=>{if(!this.provider)throw new Error("Provider is not initialized.");try{await this.provider.init();let t=P.getInstance(),{uri:n="",approval:s}=await this.provider.connect({methods:this.methods}),c=this.config.walletConnectDeepLink??U.walletConnectDeepLink;t.updateData({wcURI:n,walletConnectDeepLink:`${c}?wallet-connect=${encodeURIComponent(n)}`});let w=await this.provider.login({approval:s,token:e?.token}),{address:v="",signature:m=""}=w??{};return t.handleClose({isLoginFinished:!!v}),{address:v,signature:m}}catch{return await r()}};if(!this._approval)throw new Error("Approval or login is not initialized");try{let t=await this.provider.login({approval:this._approval.bind(this),token:e?.token}),{address:n="",signature:s=""}=t??{};return P.getInstance().handleClose({isLoginFinished:!!n}),{address:n,signature:s}}catch(t){return console.error("User rejected connection proposal",t),await r()}}async sendCustomRequest({action:e,method:r}){if(!this.provider)throw new Error("Provider is not initialized.");try{await this.provider.sendCustomRequest?.({request:{method:r,params:{action:e}}})}catch(t){console.error("Unable to send event",t)}}};var A=class{static set customProviders(i){this._customProviders=i}static get customProviders(){return this._customProviders}static async create({type:i,anchor:e}){let r=null;switch(i){case o.extension:{r=new _;break}case o.crossWindow:{r=new W;break}case o.ledger:{r=new f({anchor:e}),await z.getInstance().init();break}case o.metamask:{r=new T({type:ve.metamask});break}case o.passkey:{r=new T({type:ve.passkey});break}case o.walletConnect:{let s=F(l());if(!s?.walletConnectV2ProjectId)throw new Error("Invalid WalletConnect setup");r=new x({anchor:e,...s});break}case o.webview:{r=new le;break}default:{let s=$();for(let c of this._customProviders)c.type===i&&(r=await c.constructor({address:s,anchor:e}));break}}if(!r)throw new Error("Unable to create provider");await r.init();let t=new S(r);I(t);let n=[o.crossWindow,o.metamask,o.passkey].includes(i);return ce(n?{skipLoginMethod:i}:null),t}static async destroy(){b().cancelLogin(),I(null),j(o.none)}};A._customProviders=[];var Ce=(a,i)=>a.some(e=>e.type===i);async function g({message:a,handleSignMessage:i,cancelAction:e,providerType:r}){return await new Promise(async(n,s)=>{let{manager:c,onClose:w}=await re({cancelAction:e}),v=Object.values(A.customProviders),m=v.reduce((h,V)=>(h[V.type]=V.name,h),{}),O={...d,...m},D=async()=>{await w({shouldCancelAction:!0}),s({message:"Signing canceled"})};c.subscribeToEventBus("CLOSE_PENDING_TRANSACTIONS",D);let y=Ce(v,r)?r:o.none;c.updateData({name:O[y],type:y});try{let h=await i(a);n(h)}catch(h){await w({shouldCancelAction:!0}),s(h)}finally{c.closeUI()}})}async function pe({message:a,handleSignMessage:i}){try{return await g({message:a,handleSignMessage:i,providerType:d.ledger})}catch(e){let{errorMessage:r}=te(e);throw r?{message:r}:e}}export{pe as a,f as b,z as c,A as d,g as e,W as f,_ as g,T as h,x as i};
|
|
2
|
+
//# sourceMappingURL=chunk-C43MOZMC.mjs.map
|