@multiversx/sdk-dapp 5.0.0-alpha.2 → 5.0.0-alpha.4
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 +223 -74
- package/out/__chunks__/{chunk-DHLQNKB7.mjs → chunk-46WBKAT4.mjs} +2 -2
- package/out/__chunks__/{chunk-HOVFLZIM.mjs → chunk-4NMRZJSQ.mjs} +2 -2
- package/out/__chunks__/{chunk-C3KLB5TA.mjs → chunk-4OO7HE5Q.mjs} +1 -1
- package/out/__chunks__/{chunk-C3KLB5TA.mjs.map → chunk-4OO7HE5Q.mjs.map} +1 -1
- package/out/__chunks__/chunk-55SACSMS.mjs +2 -0
- package/out/__chunks__/chunk-55SACSMS.mjs.map +7 -0
- package/out/__chunks__/{chunk-42SCXW2U.mjs → chunk-67X3ORNS.mjs} +2 -2
- package/out/__chunks__/{chunk-SY63TM6N.mjs → chunk-773UPGVZ.mjs} +2 -2
- package/out/__chunks__/{chunk-XS3SFPZ6.mjs → chunk-CRSZQV7V.mjs} +2 -2
- package/out/__chunks__/{chunk-IGUBISXF.mjs → chunk-DELLFT6H.mjs} +2 -2
- package/out/__chunks__/{chunk-NCUYIZYI.mjs → chunk-DGXP3AZR.mjs} +2 -2
- package/out/__chunks__/chunk-EOCZROR3.mjs +2 -0
- package/out/__chunks__/chunk-GDSFFLIR.mjs +2 -0
- package/out/__chunks__/{chunk-SM5IXWZT.mjs → chunk-HNEBEFTL.mjs} +2 -2
- package/out/__chunks__/{chunk-6GNOK3TJ.mjs → chunk-HTPPS2MF.mjs} +1 -1
- package/out/__chunks__/chunk-HTPPS2MF.mjs.map +7 -0
- package/out/__chunks__/{chunk-YRLMECJT.mjs → chunk-HWH2SKSH.mjs} +2 -2
- package/out/__chunks__/{chunk-PVTRVIAK.mjs → chunk-IJX53ZJI.mjs} +2 -2
- package/out/__chunks__/{chunk-YVVDA6LN.mjs → chunk-IOKDBFGH.mjs} +1 -1
- package/out/__chunks__/{chunk-YVVDA6LN.mjs.map → chunk-IOKDBFGH.mjs.map} +1 -1
- package/out/__chunks__/chunk-J7P6SJOM.mjs +2 -0
- package/out/__chunks__/chunk-J7P6SJOM.mjs.map +7 -0
- package/out/__chunks__/{chunk-C4CJSICS.mjs → chunk-LEVR7744.mjs} +2 -2
- package/out/__chunks__/{chunk-ZC3TMTLB.mjs → chunk-LRKA4F33.mjs} +2 -2
- package/out/__chunks__/chunk-MHCIV2K5.mjs +2 -0
- package/out/__chunks__/chunk-MHCIV2K5.mjs.map +7 -0
- package/out/__chunks__/{chunk-LAWWSFCA.mjs → chunk-MJGS5LXB.mjs} +2 -2
- package/out/__chunks__/chunk-N7KSN2OU.mjs +2 -0
- package/out/__chunks__/chunk-N7KSN2OU.mjs.map +7 -0
- package/out/__chunks__/{chunk-ARD5PCMI.mjs → chunk-OSYFYAJA.mjs} +2 -2
- package/out/__chunks__/chunk-OZ3OBQJ6.mjs +2 -0
- package/out/__chunks__/chunk-OZ3OBQJ6.mjs.map +7 -0
- package/out/__chunks__/{chunk-IGKQDUHE.mjs → chunk-PBIRC7U4.mjs} +2 -2
- package/out/__chunks__/{chunk-IGKQDUHE.mjs.map → chunk-PBIRC7U4.mjs.map} +2 -2
- package/out/__chunks__/{chunk-RNCF2III.mjs → chunk-PMPTCB44.mjs} +2 -2
- package/out/__chunks__/{chunk-DZ3UVNJK.mjs → chunk-PUSIK3N4.mjs} +2 -2
- package/out/__chunks__/{chunk-KQ3I46X7.mjs → chunk-RCBOU6TT.mjs} +2 -2
- package/out/__chunks__/{chunk-4PV6SFXA.mjs → chunk-SVNWQXWC.mjs} +2 -2
- package/out/__chunks__/{chunk-3XS5MAKS.mjs → chunk-TCCW2HZK.mjs} +2 -2
- package/out/__chunks__/{chunk-KJCZ5HAU.mjs → chunk-TO3DGAQU.mjs} +2 -2
- package/out/__chunks__/chunk-U5PPKFAJ.mjs +2 -0
- package/out/__chunks__/chunk-U5PPKFAJ.mjs.map +7 -0
- package/out/__chunks__/chunk-VMFJUT3G.mjs +2 -0
- package/out/__chunks__/chunk-VMFJUT3G.mjs.map +7 -0
- package/out/__chunks__/{chunk-7YGJXJUC.mjs → chunk-WUAYFGWU.mjs} +2 -2
- package/out/__chunks__/{chunk-SLLCCPCW.mjs → chunk-X7AQOVLN.mjs} +2 -2
- package/out/__chunks__/{chunk-ZYZ7BDOH.mjs → chunk-XQLVTH7K.mjs} +2 -2
- package/out/__chunks__/{chunk-CUF7MTDG.mjs → chunk-YDXS2C4W.mjs} +2 -2
- package/out/__chunks__/{chunk-WTCFHVW3.mjs → chunk-YMME2BFO.mjs} +2 -2
- package/out/__chunks__/chunk-YRHMGKLM.mjs +2 -0
- package/out/__chunks__/chunk-YRHMGKLM.mjs.map +7 -0
- 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/index.mjs +1 -1
- package/out/constants/UITags.enum.d.ts +2 -2
- package/out/constants/UITags.enum.js +2 -2
- package/out/constants/UITags.enum.js.map +1 -1
- package/out/constants/UITags.enum.mjs +1 -1
- package/out/constants/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/sdkDappUi.d.ts +2 -2
- package/out/lib/sdkDappUi.mjs +1 -1
- package/out/managers/NotificationsFeedManager/NotificationsFeedManager.d.ts +1 -1
- package/out/managers/NotificationsFeedManager/NotificationsFeedManager.js.map +1 -1
- package/out/managers/NotificationsFeedManager/NotificationsFeedManager.mjs +1 -1
- package/out/managers/NotificationsFeedManager/index.mjs +1 -1
- package/out/managers/TransactionManager/TransactionManager.mjs +1 -1
- package/out/managers/TransactionManager/helpers/getAreTransactionsCorssShards.mjs +1 -1
- package/out/managers/TransactionManager/helpers/getShardOfAddress.mjs +1 -1
- package/out/managers/TransactionManager/helpers/getToastDuration.mjs +1 -1
- package/out/managers/TransactionManager/helpers/isCrossShardTransaction.mjs +1 -1
- package/out/managers/TransactionManager/index.mjs +1 -1
- package/out/managers/UnlockPanelManager/UnlockPanelManager.d.ts +5 -5
- package/out/managers/UnlockPanelManager/UnlockPanelManager.js +5 -5
- package/out/managers/UnlockPanelManager/UnlockPanelManager.js.map +1 -1
- package/out/managers/UnlockPanelManager/UnlockPanelManager.mjs +1 -1
- package/out/managers/UnlockPanelManager/UnlockPanelManager.types.d.ts +17 -9
- package/out/managers/UnlockPanelManager/UnlockPanelManager.types.mjs +1 -1
- package/out/managers/UnlockPanelManager/index.mjs +1 -1
- package/out/managers/index.mjs +1 -1
- package/out/managers/internal/LedgerConnectStateManager/LedgerConnectStateManager.d.ts +2 -2
- package/out/managers/internal/LedgerConnectStateManager/LedgerConnectStateManager.js +1 -1
- package/out/managers/internal/LedgerConnectStateManager/LedgerConnectStateManager.js.map +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.d.ts +2 -2
- 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/initApp/initApp.mjs +1 -1
- package/out/methods/loginInfo/getLoginInfo.d.ts +57 -0
- package/out/methods/loginInfo/getLoginInfo.js +14 -0
- package/out/methods/loginInfo/getLoginInfo.js.map +1 -0
- package/out/methods/loginInfo/getLoginInfo.mjs +2 -0
- package/out/methods/loginInfo/getLoginInfo.mjs.map +7 -0
- package/out/methods/network/getEgldLabel.js +2 -2
- package/out/methods/network/getEgldLabel.js.map +1 -1
- package/out/methods/network/getEgldLabel.mjs +1 -1
- package/out/methods/network/getExplorerAddress.js +2 -2
- package/out/methods/network/getExplorerAddress.js.map +1 -1
- package/out/methods/network/getExplorerAddress.mjs +1 -1
- package/out/methods/network/getNetworkConfig.d.ts +1 -1
- package/out/methods/network/getNetworkConfig.js +2 -2
- package/out/methods/network/getNetworkConfig.js.map +1 -1
- package/out/methods/network/getNetworkConfig.mjs +1 -1
- package/out/methods/transactions/getPendingTransactions.d.ts +1 -0
- package/out/methods/transactions/getPendingTransactions.js +10 -0
- package/out/methods/transactions/getPendingTransactions.js.map +1 -0
- package/out/methods/transactions/getPendingTransactions.mjs +2 -0
- package/out/methods/transactions/getPendingTransactions.mjs.map +7 -0
- package/out/methods/transactions/getPendingTransactionsSessions.d.ts +1 -0
- package/out/methods/transactions/getPendingTransactionsSessions.js +10 -0
- package/out/methods/transactions/getPendingTransactionsSessions.js.map +1 -0
- package/out/methods/transactions/getPendingTransactionsSessions.mjs +2 -0
- package/out/methods/transactions/getPendingTransactionsSessions.mjs.map +7 -0
- package/out/methods/transactions/getTransactionSessions.d.ts +1 -0
- package/out/methods/transactions/getTransactionSessions.js +10 -0
- package/out/methods/transactions/getTransactionSessions.js.map +1 -0
- package/out/methods/transactions/getTransactionSessions.mjs +2 -0
- package/out/methods/transactions/getTransactionSessions.mjs.map +7 -0
- 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/login.js +2 -2
- package/out/providers/DappProvider/helpers/login/login.js.map +1 -1
- package/out/providers/DappProvider/helpers/login/login.mjs +1 -1
- package/out/providers/DappProvider/helpers/signErrors/handleSignError.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.mjs +1 -1
- package/out/providers/helpers/accountProvider.mjs +1 -1
- package/out/providers/helpers/cancelCrossWindowAction.mjs +1 -1
- package/out/providers/helpers/restoreProvider.mjs +1 -1
- package/out/providers/index.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.js +1 -1
- package/out/providers/strategies/LedgerProviderStrategy/helpers/updateAccountsList/updateAccountsList.js.map +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/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/signTransactions.mjs +1 -1
- package/out/providers/strategies/index.mjs +1 -1
- package/out/react/transactions/useGetPendingTransactionsSessions.d.ts +1 -1
- package/out/react/transactions/useGetPendingTransactionsSessions.js +3 -3
- package/out/react/transactions/useGetPendingTransactionsSessions.js.map +1 -1
- package/out/react/transactions/useGetPendingTransactionsSessions.mjs +1 -1
- package/out/react/transactions/useGetPendingTransactionsSessions.mjs.map +3 -3
- package/out/store/actions/index.mjs +1 -1
- package/out/store/actions/toasts/index.mjs +1 -1
- package/out/store/actions/toasts/toastsActions.mjs +1 -1
- package/out/utils/account/index.mjs +1 -1
- package/out/utils/account/refreshAccount.js +1 -1
- package/out/utils/account/refreshAccount.js.map +1 -1
- package/out/utils/account/refreshAccount.mjs +1 -1
- package/out/utils/createUIElement.mjs +1 -1
- package/out/utils/index.mjs +1 -1
- package/out/utils/transactions/getInterpretedTransaction/getInterpretedTransaction.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/package.json +2 -2
- package/out/__chunks__/chunk-6GNOK3TJ.mjs.map +0 -7
- package/out/__chunks__/chunk-6PTI5SU2.mjs +0 -2
- package/out/__chunks__/chunk-6PTI5SU2.mjs.map +0 -7
- package/out/__chunks__/chunk-7Q3M4L6V.mjs +0 -2
- package/out/__chunks__/chunk-7Q3M4L6V.mjs.map +0 -7
- package/out/__chunks__/chunk-7TOTBAGV.mjs +0 -2
- package/out/__chunks__/chunk-7TOTBAGV.mjs.map +0 -7
- package/out/__chunks__/chunk-HP5OTXWV.mjs +0 -2
- package/out/__chunks__/chunk-HP5OTXWV.mjs.map +0 -7
- package/out/__chunks__/chunk-IGA7KHXY.mjs +0 -2
- package/out/__chunks__/chunk-IGA7KHXY.mjs.map +0 -7
- package/out/__chunks__/chunk-S24E3INP.mjs +0 -2
- package/out/__chunks__/chunk-S24E3INP.mjs.map +0 -7
- package/out/__chunks__/chunk-SGPG7AHK.mjs +0 -2
- package/out/__chunks__/chunk-TOGPOKIP.mjs +0 -2
- package/out/__chunks__/chunk-TOGPOKIP.mjs.map +0 -7
- package/out/__chunks__/chunk-WZNCESVG.mjs +0 -2
- package/out/__chunks__/chunk-WZNCESVG.mjs.map +0 -7
- package/out/__chunks__/chunk-XU34NXIS.mjs +0 -2
- /package/out/__chunks__/{chunk-DHLQNKB7.mjs.map → chunk-46WBKAT4.mjs.map} +0 -0
- /package/out/__chunks__/{chunk-HOVFLZIM.mjs.map → chunk-4NMRZJSQ.mjs.map} +0 -0
- /package/out/__chunks__/{chunk-42SCXW2U.mjs.map → chunk-67X3ORNS.mjs.map} +0 -0
- /package/out/__chunks__/{chunk-SY63TM6N.mjs.map → chunk-773UPGVZ.mjs.map} +0 -0
- /package/out/__chunks__/{chunk-XS3SFPZ6.mjs.map → chunk-CRSZQV7V.mjs.map} +0 -0
- /package/out/__chunks__/{chunk-IGUBISXF.mjs.map → chunk-DELLFT6H.mjs.map} +0 -0
- /package/out/__chunks__/{chunk-NCUYIZYI.mjs.map → chunk-DGXP3AZR.mjs.map} +0 -0
- /package/out/__chunks__/{chunk-XU34NXIS.mjs.map → chunk-EOCZROR3.mjs.map} +0 -0
- /package/out/__chunks__/{chunk-SGPG7AHK.mjs.map → chunk-GDSFFLIR.mjs.map} +0 -0
- /package/out/__chunks__/{chunk-SM5IXWZT.mjs.map → chunk-HNEBEFTL.mjs.map} +0 -0
- /package/out/__chunks__/{chunk-YRLMECJT.mjs.map → chunk-HWH2SKSH.mjs.map} +0 -0
- /package/out/__chunks__/{chunk-PVTRVIAK.mjs.map → chunk-IJX53ZJI.mjs.map} +0 -0
- /package/out/__chunks__/{chunk-C4CJSICS.mjs.map → chunk-LEVR7744.mjs.map} +0 -0
- /package/out/__chunks__/{chunk-ZC3TMTLB.mjs.map → chunk-LRKA4F33.mjs.map} +0 -0
- /package/out/__chunks__/{chunk-LAWWSFCA.mjs.map → chunk-MJGS5LXB.mjs.map} +0 -0
- /package/out/__chunks__/{chunk-ARD5PCMI.mjs.map → chunk-OSYFYAJA.mjs.map} +0 -0
- /package/out/__chunks__/{chunk-RNCF2III.mjs.map → chunk-PMPTCB44.mjs.map} +0 -0
- /package/out/__chunks__/{chunk-DZ3UVNJK.mjs.map → chunk-PUSIK3N4.mjs.map} +0 -0
- /package/out/__chunks__/{chunk-KQ3I46X7.mjs.map → chunk-RCBOU6TT.mjs.map} +0 -0
- /package/out/__chunks__/{chunk-4PV6SFXA.mjs.map → chunk-SVNWQXWC.mjs.map} +0 -0
- /package/out/__chunks__/{chunk-3XS5MAKS.mjs.map → chunk-TCCW2HZK.mjs.map} +0 -0
- /package/out/__chunks__/{chunk-KJCZ5HAU.mjs.map → chunk-TO3DGAQU.mjs.map} +0 -0
- /package/out/__chunks__/{chunk-7YGJXJUC.mjs.map → chunk-WUAYFGWU.mjs.map} +0 -0
- /package/out/__chunks__/{chunk-SLLCCPCW.mjs.map → chunk-X7AQOVLN.mjs.map} +0 -0
- /package/out/__chunks__/{chunk-ZYZ7BDOH.mjs.map → chunk-XQLVTH7K.mjs.map} +0 -0
- /package/out/__chunks__/{chunk-CUF7MTDG.mjs.map → chunk-YDXS2C4W.mjs.map} +0 -0
- /package/out/__chunks__/{chunk-WTCFHVW3.mjs.map → chunk-YMME2BFO.mjs.map} +0 -0
package/README.md
CHANGED
|
@@ -8,12 +8,12 @@ MultiversX Front-End SDK for JavaScript and TypeScript (written in TypeScript).
|
|
|
8
8
|
|
|
9
9
|
It is built for applications that use any of the following technologies:
|
|
10
10
|
|
|
11
|
-
- React
|
|
11
|
+
- React (example: [Template Dapp](https://github.com/multiversx/mx-template-dapp))
|
|
12
12
|
- Angular
|
|
13
13
|
- Vue
|
|
14
|
-
- Any other JavaScript framework (e.g. Solid.js etc.)
|
|
14
|
+
- Any other JavaScript framework (e.g. Solid.js etc.) (example: [Solid.js Dapp](https://github.com/multiversx/mx-solidjs-template-dapp))
|
|
15
15
|
- React Native
|
|
16
|
-
- Next.js
|
|
16
|
+
- Next.js (example: [Next.js Dapp](https://github.com/multiversx/mx-template-dapp-nextjs))
|
|
17
17
|
|
|
18
18
|
## GitHub project
|
|
19
19
|
|
|
@@ -60,7 +60,7 @@ Also, make sure you run your app on `https`, not `http`, otherwise some provider
|
|
|
60
60
|
npm install
|
|
61
61
|
```
|
|
62
62
|
|
|
63
|
-
If you're transitioning from
|
|
63
|
+
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/0eb7bc6194195b6c364b8010023d351d914db65e/MIGRATION_GUIDE.md) and [migration PR](https://github.com/multiversx/mx-template-dapp/pull/343) of Template Dapp
|
|
64
64
|
|
|
65
65
|
## Usage
|
|
66
66
|
|
|
@@ -81,18 +81,18 @@ Having this knowledge, we can consider several steps needed to put a dApp togeth
|
|
|
81
81
|
| 1 | Configuration | - storage configuration (e.g. sessionStorage, localStorage etc.)<br>- chain configuration<br>- custom provider configuration (adding / disabling / changing providers) |
|
|
82
82
|
| 2 | Provider interaction | - logging in and out<br>- signing transactions / messages |
|
|
83
83
|
| 3 | Presenting data | - get store data (e.g. account balance, account address etc.)<br>- use components to display data (e.g. balance, address, transactions list) |
|
|
84
|
-
| 4 | Transactions | - sending transactions<br>- tracking transactions |
|
|
84
|
+
| 4 | Transactions | - sending transactions<br>- tracking transactions<br>- displayingtransactions history |
|
|
85
85
|
|
|
86
86
|
Each of these steps will be explained in more detail in the following sections.
|
|
87
87
|
|
|
88
88
|
### 1. Configuration
|
|
89
89
|
|
|
90
|
-
Before your application bootstraps, you need to configure the storage, the network, and the signing providers. This is done by calling the `initApp` method from the `
|
|
90
|
+
Before your application bootstraps, you need to configure the storage, the network, and the signing providers. This is done by calling the `initApp` method from the `methods` folder. It is recommended to call this method in the `index.tsx` to ensure the sdk-dapp internal functions are initialized before rendering the app.
|
|
91
91
|
|
|
92
92
|
```typescript
|
|
93
93
|
// index.tsx
|
|
94
|
-
import { initApp } from '@multiversx/sdk-dapp/out/
|
|
95
|
-
import type { InitAppType } from '@multiversx/sdk-dapp/out/
|
|
94
|
+
import { initApp } from '@multiversx/sdk-dapp/out/methods/initApp/initApp';
|
|
95
|
+
import type { InitAppType } from '@multiversx/sdk-dapp/out/methods/initApp/initApp.types';
|
|
96
96
|
import { EnvironmentsEnum } from '@multiversx/sdk-dapp/out/types/enums.types';
|
|
97
97
|
import { App } from "./App";
|
|
98
98
|
|
|
@@ -116,11 +116,59 @@ initApp(config).then(() => {
|
|
|
116
116
|
|
|
117
117
|
### 2. Provider interaction
|
|
118
118
|
|
|
119
|
-
Once your dApp has loaded, the first user action is logging in with a chosen provider.
|
|
119
|
+
Once your dApp has loaded, the first user action is logging in with a chosen provider. There are two ways to perform a login, namely using the `UnlockPanelManager` and programatic login using the `ProviderFactory`.
|
|
120
|
+
|
|
121
|
+
#### 2.1 Using the `UnlockPanelManager`
|
|
122
|
+
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.
|
|
120
123
|
|
|
121
124
|
```typescript
|
|
122
|
-
import {
|
|
123
|
-
import { ProviderFactory } from '@multiversx/sdk-dapp/out/
|
|
125
|
+
import { UnlockPanelManager } from '@multiversx/sdk-dapp/out/managers/UnlockPanelManager';
|
|
126
|
+
import { ProviderFactory } from '@multiversx/sdk-dapp/out/providers/ProviderFactory';
|
|
127
|
+
|
|
128
|
+
export const ConnectButton = () => {
|
|
129
|
+
const unlockPanelManager = UnlockPanelManager.init({
|
|
130
|
+
loginHandler: () => {
|
|
131
|
+
navigate('/dashboard');
|
|
132
|
+
},
|
|
133
|
+
onClose: () => { // optional action to be performed when the user closes the Unlock Panel
|
|
134
|
+
navigate('/');
|
|
135
|
+
},
|
|
136
|
+
});
|
|
137
|
+
const handleOpenUnlockPanel = () => {
|
|
138
|
+
unlockPanelManager.openUnlockPanel();
|
|
139
|
+
};
|
|
140
|
+
return <Button onClick={handleOpenUnlockPanel}>Connect</Button>;
|
|
141
|
+
};
|
|
142
|
+
|
|
143
|
+
```
|
|
144
|
+
|
|
145
|
+
If you want to perform some actions as soon as the user has logged in, you will need to call `ProviderFactory.create` inside a handler accepting arguments.
|
|
146
|
+
|
|
147
|
+
```typescript
|
|
148
|
+
export const AdvancedConnectButton = () => {
|
|
149
|
+
const unlockPanelManager = UnlockPanelManager.init({
|
|
150
|
+
loginHandler: async ({ type, anchor }) => {
|
|
151
|
+
const provider = await ProviderFactory.create({
|
|
152
|
+
type,
|
|
153
|
+
anchor
|
|
154
|
+
});
|
|
155
|
+
const { address, signature } = await provider.login();
|
|
156
|
+
navigate(`/dashboard?address=${address}`;
|
|
157
|
+
}
|
|
158
|
+
});
|
|
159
|
+
const handleOpenUnlockPanel = () => {
|
|
160
|
+
unlockPanelManager.openUnlockPanel();
|
|
161
|
+
};
|
|
162
|
+
return <Button onClick={handleOpenUnlockPanel}>Advanced Connect</Button>;
|
|
163
|
+
};
|
|
164
|
+
|
|
165
|
+
```
|
|
166
|
+
|
|
167
|
+
#### 2.2 Programatic login using the `ProviderFactory`
|
|
168
|
+
If you want to login using your custom UI, you can link user actions to specific providers by calling the `ProviderFactory`.
|
|
169
|
+
|
|
170
|
+
```typescript
|
|
171
|
+
import { ProviderTypeEnum } from '@multiversx/sdk-dapp/out/providers/types/providerFactory.types';
|
|
124
172
|
|
|
125
173
|
const provider = await ProviderFactory.create({
|
|
126
174
|
type: ProviderTypeEnum.extension
|
|
@@ -128,15 +176,28 @@ const provider = await ProviderFactory.create({
|
|
|
128
176
|
await provider.login();
|
|
129
177
|
```
|
|
130
178
|
|
|
131
|
-
### 3. Displaying
|
|
179
|
+
### 3. Displaying app data
|
|
132
180
|
|
|
133
181
|
Depending on the framework, you can either use hooks or selectors to get the user details:
|
|
134
182
|
|
|
135
|
-
#### React hooks
|
|
183
|
+
#### 3.1 React hooks
|
|
184
|
+
|
|
185
|
+
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 hook related to most common use cases
|
|
186
|
+
|
|
187
|
+
```bash
|
|
188
|
+
out/react/
|
|
189
|
+
├── account/useGetAccount ### access account data like address, balance and nonce
|
|
190
|
+
├── loginInfo/useGetLoginInfo ### access login data like accessToken and provider type
|
|
191
|
+
├── network/useGetNetworkConfig ### access network information like chainId and egldLabel
|
|
192
|
+
├── store/useSelector ### make use of the useSelector hook for querying the store via selectors
|
|
193
|
+
└── transactions/useGetTransactionSessions ### access all current and historic transaction sessions
|
|
194
|
+
```
|
|
195
|
+
|
|
196
|
+
Below is an example of using the hooks to display the user address and balance.
|
|
136
197
|
|
|
137
198
|
```typescript
|
|
138
|
-
import { useGetAccount } from '@multiversx/sdk-dapp/out/
|
|
139
|
-
import { useGetNetworkConfig } from '@multiversx/sdk-dapp/out/
|
|
199
|
+
import { useGetAccount } from '@multiversx/sdk-dapp/out/react/account/useGetAccount';
|
|
200
|
+
import { useGetNetworkConfig } from '@multiversx/sdk-dapp/out/react/network/useGetNetworkConfig';
|
|
140
201
|
|
|
141
202
|
const account = useGetAccount();
|
|
142
203
|
const {
|
|
@@ -147,40 +208,62 @@ console.log(account.address);
|
|
|
147
208
|
console.log(`${account.balance} ${egldLabel}`);
|
|
148
209
|
```
|
|
149
210
|
|
|
150
|
-
#### Store selector functions:
|
|
211
|
+
#### 3.2 Store selector functions:
|
|
212
|
+
|
|
213
|
+
If you are not using the React ecosystem, you can use store selectors to get the store data, but note that information will not be reactive unless you subscribe to store changes.
|
|
151
214
|
|
|
152
215
|
```typescript
|
|
153
|
-
import { getAccount } from '@multiversx/sdk-dapp/out/
|
|
154
|
-
import { getNetworkConfig } from '@multiversx/sdk-dapp/out/
|
|
216
|
+
import { getAccount } from '@multiversx/sdk-dapp/out/methods/account/getAccount';
|
|
217
|
+
import { getNetworkConfig } from '@multiversx/sdk-dapp/out/methods/network/getNetworkConfig';
|
|
155
218
|
|
|
156
219
|
const account = getAccount();
|
|
157
220
|
const { egldLabel } = getNetworkConfig();
|
|
158
221
|
```
|
|
159
222
|
|
|
223
|
+
In order to get live updates you may need to subscribe to the store like this:
|
|
224
|
+
|
|
225
|
+
```typescript
|
|
226
|
+
import { createSignal, onCleanup } from 'solid-js';
|
|
227
|
+
import { getStore } from '@multiversx/sdk-dapp/out/store/store';
|
|
228
|
+
|
|
229
|
+
export function useStore() {
|
|
230
|
+
const store = getStore();
|
|
231
|
+
const [state, setState] = createSignal(store.getState());
|
|
232
|
+
|
|
233
|
+
const unsubscribe = store.subscribe((newState) => {
|
|
234
|
+
setState(newState);
|
|
235
|
+
});
|
|
236
|
+
|
|
237
|
+
onCleanup(() => unsubscribe());
|
|
238
|
+
|
|
239
|
+
return state;
|
|
240
|
+
}
|
|
241
|
+
```
|
|
242
|
+
|
|
160
243
|
### 4. Transactions
|
|
161
244
|
|
|
162
|
-
#### Signing transactions
|
|
245
|
+
#### 4.1 Signing transactions
|
|
163
246
|
|
|
164
|
-
To sign transactions, you first need to create the `Transaction` object then pass it to the initialized provider.
|
|
247
|
+
To sign transactions, you first need to create the `Transaction` object, then pass it to the initialized provider.
|
|
165
248
|
|
|
166
249
|
```typescript
|
|
167
|
-
import { Transaction, TransactionPayload } from '@multiversx/sdk-core
|
|
250
|
+
import { Address, Transaction, TransactionPayload } from '@multiversx/sdk-core';
|
|
168
251
|
import {
|
|
169
252
|
GAS_PRICE,
|
|
170
253
|
GAS_LIMIT
|
|
171
254
|
} from '@multiversx/sdk-dapp/out/constants/mvx.constants';
|
|
172
|
-
import { getAccountProvider } from '@multiversx/sdk-dapp/out/
|
|
255
|
+
import { getAccountProvider } from '@multiversx/sdk-dapp/out/providers/helpers/accountProvider';
|
|
173
256
|
import { refreshAccount } from '@multiversx/sdk-dapp/out/utils/account/refreshAccount';
|
|
174
257
|
|
|
175
258
|
const pongTransaction = new Transaction({
|
|
176
|
-
value:
|
|
259
|
+
value: BigInt(0),
|
|
177
260
|
data: new TransactionPayload('pong'),
|
|
178
|
-
receiver: contractAddress,
|
|
179
|
-
gasLimit: GAS_LIMIT,
|
|
180
|
-
gasPrice: GAS_PRICE,
|
|
261
|
+
receiver: Address.newFromBech32(contractAddress),
|
|
262
|
+
gasLimit: BigInt(GAS_LIMIT),
|
|
263
|
+
gasPrice: BigInt(GAS_PRICE),
|
|
181
264
|
chainID: network.chainId,
|
|
182
|
-
nonce: account.nonce,
|
|
183
|
-
sender: account.address,
|
|
265
|
+
nonce: BigInt(account.nonce),
|
|
266
|
+
sender: Address.newFromBech32(account.address),
|
|
184
267
|
version: 1
|
|
185
268
|
});
|
|
186
269
|
|
|
@@ -189,22 +272,77 @@ const provider = getAccountProvider();
|
|
|
189
272
|
const signedTransactions = await provider.signTransactions(transactions);
|
|
190
273
|
```
|
|
191
274
|
|
|
192
|
-
#### Sending and tracking transactions
|
|
275
|
+
#### 4.2 Sending and tracking transactions
|
|
193
276
|
|
|
194
|
-
Then, to send the transactions, you need to use the `TransactionManager` class and pass in the signedTransactions to the send method. You can
|
|
277
|
+
Then, to send the transactions, you need to use the `TransactionManager` class and pass in the `signedTransactions` to the `send` method. You can then track the transactions by using the `track` method. This will create a toast notification with the transaction hash and its status.
|
|
195
278
|
|
|
196
279
|
```typescript
|
|
197
|
-
import { TransactionManager } from '@multiversx/sdk-dapp/out/
|
|
280
|
+
import { TransactionManager } from '@multiversx/sdk-dapp/out/managers/TransactionManager';
|
|
281
|
+
import type { TransactionsDisplayInfoType } from '@multiversx/sdk-dapp/out/types/transactions.types';
|
|
282
|
+
|
|
198
283
|
|
|
199
284
|
const txManager = TransactionManager.getInstance();
|
|
200
|
-
await txManager.send(signedTransactions);
|
|
201
|
-
|
|
285
|
+
const sentTransactions = await txManager.send(signedTransactions);
|
|
286
|
+
|
|
287
|
+
const toastInformation: TransactionsDisplayInfoType = {
|
|
288
|
+
processingMessage: 'Processing transactions',
|
|
289
|
+
errorMessage: 'An error has occurred during transaction execution',
|
|
290
|
+
successMessage: 'Transactions executed'
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
const sessionId = await txManager.track(sentTransactions, {
|
|
294
|
+
transactionsDisplayInfo: toastInformation
|
|
295
|
+
});
|
|
202
296
|
```
|
|
203
297
|
|
|
204
|
-
|
|
298
|
+
#### 4.3 Using the Notifications Feed
|
|
299
|
+
|
|
300
|
+
The Notifications Feed is a component that displays **session transactions** in a list. Internally it gets initialized in the `initApp` method. It can be accessed via the `NotificationManager.getInstance()` method.
|
|
301
|
+
Once the user logs out of the dApp, all transactions displayed by the Notifications Feed are removed from the store. Note that you can switch between toast notifications and Notifications Feed by pressing the View All button above the current pending transaction toast in the UI.
|
|
205
302
|
|
|
206
303
|
```typescript
|
|
207
|
-
|
|
304
|
+
const notificationManager = NotificationManager.getInstance();
|
|
305
|
+
notificationManager.openNotificationsFeed();
|
|
306
|
+
```
|
|
307
|
+
|
|
308
|
+
#### 4.4 Inspecting transactions
|
|
309
|
+
|
|
310
|
+
You can find both methods and hooks to access transactions data, as seen in the table below.
|
|
311
|
+
|
|
312
|
+
**Table 2**. Inspectig transactions
|
|
313
|
+
| # | Helper | Description | React hook equivalent |
|
|
314
|
+
|---|------|-------------|----|
|
|
315
|
+
| | `methods/transactions` | path | `react/transactions` |
|
|
316
|
+
| 1 | `getTransactionSessions()` | returns all trabsaction sessions |`useGetTransactionSessions()` |
|
|
317
|
+
| 2 | `getPendingTransactionsSessions()` | returns an array of pending sessions | `useGetPendingTransactionsSessions()`|
|
|
318
|
+
| 3 | `getPendingTransactions()` | returns an array of signed transactions | `useGetPendingTransactions()` |
|
|
319
|
+
|
|
320
|
+
There is a way to inspect store information regarding a specific transaction, using the `transactionsSliceSelector`. An example is shown below:
|
|
321
|
+
|
|
322
|
+
```typescript
|
|
323
|
+
import {
|
|
324
|
+
pendingTransactionsSessionsSelector,
|
|
325
|
+
transactionsSliceSelector
|
|
326
|
+
} from '@multiversx/sdk-dapp/out/store/selectors/transactionsSelector';
|
|
327
|
+
import { getStore } from '@multiversx/sdk-dapp/out/store/store';
|
|
328
|
+
|
|
329
|
+
const store = getStore(); // or use useStore hook for reactivity
|
|
330
|
+
const pendingSessions = pendingTransactionsSessionsSelector(store.getState());
|
|
331
|
+
const allTransactionSessions = transactionsSliceSelector(store.getState());
|
|
332
|
+
|
|
333
|
+
const isSessionIdPending =
|
|
334
|
+
Object.keys(pendingSessions).includes(sessionId);
|
|
335
|
+
const currentSession = allTransactionSessions[sessionId];
|
|
336
|
+
const currentSessionStatus = currentSession?.status;
|
|
337
|
+
const currentTransaction = currentSession?.transactions?.[0];
|
|
338
|
+
const currentTransactionStatus = currentTransaction?.status;
|
|
339
|
+
```
|
|
340
|
+
|
|
341
|
+
#### 4.5 Logging out
|
|
342
|
+
The user journey ends with calling the `provider.logout()` method.
|
|
343
|
+
|
|
344
|
+
```typescript
|
|
345
|
+
import { getAccountProvider } from '@multiversx/sdk-dapp/out/providers/helpers/accountProvider';
|
|
208
346
|
const provider = getAccountProvider();
|
|
209
347
|
await provider.logout();
|
|
210
348
|
```
|
|
@@ -213,7 +351,7 @@ await provider.logout();
|
|
|
213
351
|
|
|
214
352
|
We have seen in the previous chapter what are the minimal steps to get up and running with a blockchain interaction using sdk-dapp. Next we will detail each element mentioned above
|
|
215
353
|
|
|
216
|
-
**Table
|
|
354
|
+
**Table 3**. Elements needed to build a dApp
|
|
217
355
|
| # | Type | Description |
|
|
218
356
|
|---|------|-------------|
|
|
219
357
|
| 1 | Network | Chain configuration |
|
|
@@ -223,50 +361,54 @@ We have seen in the previous chapter what are the minimal steps to get up and ru
|
|
|
223
361
|
| 5 | UI Components | Displaying UI information like balance, public keys etc. |
|
|
224
362
|
|
|
225
363
|
Since these are mixtures of business logic and UI components, the library is split into several folders to make it easier to navigate.
|
|
226
|
-
When inspecting the package, there is more content under `src`, but the
|
|
364
|
+
When inspecting the package, there is more content under `src`, but the folders of interest are:
|
|
365
|
+
|
|
227
366
|
|
|
228
367
|
```bash
|
|
229
368
|
src/
|
|
230
369
|
├── apiCalls/ ### methods for interacting with the API
|
|
231
370
|
├── constants/ ### useful constants from the ecosystem like ledger error codes, default gas limits for transactions etc.
|
|
232
|
-
├── controllers/ ### business logic for UI elements
|
|
233
|
-
├──
|
|
371
|
+
├── controllers/ ### business logic for UI elements that are not bound to the store
|
|
372
|
+
├── managers/ ### business logic for UI elements that are bound to the store
|
|
373
|
+
├── providers/ ### signing providers
|
|
374
|
+
├── methods/ ### utility functions to query and update the store
|
|
375
|
+
├── react/ ### react hooks to query the store
|
|
234
376
|
└── store/ ### store initialization, middleware, slices, selectors and actions
|
|
235
377
|
```
|
|
236
378
|
|
|
237
379
|
Conceptually, these can be split into 3 main parts:
|
|
238
380
|
|
|
239
|
-
- First is the business logic in `apiCalls`, `constants` and `
|
|
381
|
+
- First is the business logic in `apiCalls`, `constants`, `providers` and `methods`
|
|
240
382
|
- Then comes the persistence layer hosted in the `store` folder, using [Zustand](https://zustand.docs.pmnd.rs/) under the hood.
|
|
241
|
-
- Last are the UI components hosted in [@multiversx/sdk-dapp](https://github.com/multiversx/mx-sdk-dapp-ui) with some components controlled on demand by classes defined in `controlles`
|
|
383
|
+
- Last are the UI components hosted in [@multiversx/sdk-dapp-ui](https://github.com/multiversx/mx-sdk-dapp-ui) with some components controlled on demand by classes defined in `controlles` and `managers`
|
|
242
384
|
|
|
243
|
-
Next, we will take the elements from Table
|
|
385
|
+
Next, we will take the elements from Table 3 and detail them in the following sections.
|
|
244
386
|
|
|
245
387
|
### 1. Network
|
|
246
388
|
|
|
247
389
|
The network configuration is done in the `initApp` method, where you can make several confgurations like:
|
|
248
390
|
|
|
249
|
-
- specifying the environment (devnet
|
|
391
|
+
- specifying the environment (`devnet`, `testnet`, `mainnet`)
|
|
250
392
|
- overriding certain network parameters like wallet address, explorer address etc.
|
|
251
393
|
|
|
252
394
|
Once the network is configured, the `network` slice in the store will hold the network configuration.
|
|
253
395
|
|
|
254
|
-
To query different network parameters, you can use the `getNetworkConfig` method from the `
|
|
396
|
+
To query different network parameters, you can use the `getNetworkConfig` method from the `methods/network` folder.
|
|
255
397
|
|
|
256
398
|
### 2. Provider
|
|
257
399
|
|
|
258
|
-
The provider is the main class that handles the signing of transactions and messages. It is initialized in the `initApp` method and can be accessed via the `getAccountProvider` method from the `
|
|
400
|
+
The provider is the main class that handles the signing of transactions and messages. It is initialized in the `initApp` method and can be accessed via the `getAccountProvider` method from the `providers/helpers` folder.
|
|
259
401
|
|
|
260
402
|
#### Initialization
|
|
261
403
|
|
|
262
|
-
|
|
404
|
+
An existing provider is initialized on app load (this is take care of by `initApp`), since it restores the session from the store and allows signing transactions without the need of making a new login.
|
|
263
405
|
|
|
264
406
|
#### Creating a custom provider
|
|
265
407
|
|
|
266
408
|
If you need to create a custom signing provider, make sure to extend the `IProvider` interface and implement all required methods (see example [here](https://github.com/multiversx/mx-template-dapp/tree/main/src/provider)). Next step would be to include it in the `customProviders` array in the `initApp` method or add it to the [window object](https://github.com/multiversx/mx-template-dapp/tree/main/src/initConfig). Last step is to login using the custom provider.
|
|
267
409
|
|
|
268
410
|
```typescript
|
|
269
|
-
import { ProviderTypeEnum } from '@multiversx/sdk-dapp/out/
|
|
411
|
+
import { ProviderTypeEnum } from '@multiversx/sdk-dapp/out/providers/types/providerFactory.types';
|
|
270
412
|
|
|
271
413
|
const ADDITIONAL_PROVIDERS = {
|
|
272
414
|
myCustomProvider: 'myCustomProvider'
|
|
@@ -292,12 +434,12 @@ Once the provider is initialized, you can get a reference to it using the `getAc
|
|
|
292
434
|
|
|
293
435
|
#### Getting account data
|
|
294
436
|
|
|
295
|
-
Once the user logs in, a call is made to the API for fetching the account data. This data is persisted in the store and is accessible through helpers found in `
|
|
437
|
+
Once the user logs in, a call is made to the API for fetching the account data. This data is persisted in the store and is accessible through helpers found in `methods/account`. These functions are:
|
|
296
438
|
|
|
297
|
-
**Table
|
|
439
|
+
**Table 4**. Getting account data
|
|
298
440
|
| # | Helper | Description | React hook equivalent |
|
|
299
441
|
|---|------|-------------|----|
|
|
300
|
-
| | `
|
|
442
|
+
| | `methods/account` | path | `react/account` |
|
|
301
443
|
| 1 | `getAccount()` | returns all account data |`useGetAccount()` |
|
|
302
444
|
| 2 | `getAddress()` | returns just the user's public key | `useGetAddress()`|
|
|
303
445
|
| 3 | `getIsLoggedIn()` | returns a login status boolean | `useGetIsLoggedIn()` |
|
|
@@ -305,13 +447,13 @@ Once the user logs in, a call is made to the API for fetching the account data.
|
|
|
305
447
|
|
|
306
448
|
#### Nonce management
|
|
307
449
|
|
|
308
|
-
sdk-dapp has a mechanism that does its best to manage the account nonce. For example, if the user sends a transaction, the nonce gets incremented on the client so that if
|
|
450
|
+
`sdk-dapp` has a mechanism that does its best to manage the account nonce. For example, if the user sends a transaction, the nonce gets incremented on the client so that if a new transaction is sent, it will have the correct increased nonce. If you want to make sure the nonce is in sync with the API account, you can call `refreshAccount()` as shown above in the **Signing transactions** section.
|
|
309
451
|
|
|
310
452
|
### 4. Transactions Manager
|
|
311
453
|
|
|
312
454
|
#### Overview
|
|
313
455
|
|
|
314
|
-
The `TransactionManager` is a class that handles sending and tracking transactions in the MultiversX ecosystem. It provides methods to send single
|
|
456
|
+
The `TransactionManager` is a class that handles sending and tracking transactions in the MultiversX ecosystem. It provides methods to send either single or batch transactions. It also handles tracking, error management, and toast notifications for user feedback. It is initialized in the `initApp` method and can be accessed via `TransactionManager.getInstance()`.
|
|
315
457
|
|
|
316
458
|
#### Features
|
|
317
459
|
|
|
@@ -324,15 +466,15 @@ The `TransactionManager` is a class that handles sending and tracking transactio
|
|
|
324
466
|
|
|
325
467
|
The transaction lifecycle consists of the following steps:
|
|
326
468
|
|
|
327
|
-
1. **Creating** a `Transaction` object
|
|
469
|
+
1. **Creating** a `Transaction` object from `@multiversx/sdk-core`
|
|
328
470
|
2. **Signing** the transaction with the initialized provider and receiving a `SignedTransactionType` object
|
|
329
471
|
3. **Sending** the signed transaction using TransactionManager's `send()` function. Signed transactions can be sent in 2 ways:
|
|
330
472
|
|
|
331
|
-
**Table
|
|
473
|
+
**Table 5**. Sending signed transactions
|
|
332
474
|
| # | Signature | Method | Description |
|
|
333
475
|
|---|------|-------------|-------------|
|
|
334
476
|
| 1 | `send([tx1, tx2])` | `POST` to `/transactions` | Transactions are executed in parallel
|
|
335
|
-
| 2 | `send([[tx1, tx2], [tx3]])` | `POST` to `/batch` |
|
|
477
|
+
| 2 | `send([[tx1, tx2], [tx3]])` | `POST` to `/batch` | **a)** 1<sup>st</sup> batch of two transactions is executed, **b)** the 2<sup>nd</sup> batch of one transaction waits for the finished results, **c)** and once the 1<sup>st</sup> batch is finished, the 2<sup>nd</sup> batch is executed
|
|
336
478
|
|
|
337
479
|
4. **Tracking** transactions is made by using `transactionManager.track()`. Since the `send()` function returns the same arguments it has received, the same array payload can be passed into the `track()` method. Under the hood, status updates are received via a WebSocket or polling mechanism.
|
|
338
480
|
Once a transaction array is tracked, it gets associated with a `sessionId`, returned by the `track()` method and stored in the `transactions` slice. Depending on the array's type (plain/batch), the session's status varies from initial (`pending`/`invalid`/`sent`) to final (`successful`/`failed`/`timedOut`).
|
|
@@ -370,22 +512,23 @@ createCustomToast({
|
|
|
370
512
|
6. **Error Handling & Recovery** is done through a custom toast that prompts the user to take appropriate action.
|
|
371
513
|
|
|
372
514
|
#### Methods
|
|
515
|
+
___
|
|
373
516
|
|
|
374
|
-
1. Sending Transactions
|
|
517
|
+
#### 1. Sending Transactions
|
|
375
518
|
|
|
376
519
|
In this way, all transactions are sent simultaneously. There is no limit to the number of transactions contained in the array.
|
|
377
520
|
|
|
378
|
-
```
|
|
521
|
+
```typescript
|
|
379
522
|
const transactionManager = TransactionManager.getInstance();
|
|
380
523
|
const parallelTransactions: SigendTransactionType[] = [tx1, tx2, tx3, tx4];
|
|
381
524
|
const sentTransactions = await transactionManager.send(parallelTransactions);
|
|
382
525
|
```
|
|
383
526
|
|
|
384
|
-
2. Sending Batch Transactions
|
|
527
|
+
#### 2. Sending Batch Transactions
|
|
385
528
|
|
|
386
529
|
In this sequential case, each batch waits for the previous one to complete.
|
|
387
530
|
|
|
388
|
-
```
|
|
531
|
+
```typescript
|
|
389
532
|
const transactionManager = TransactionManager.getInstance();
|
|
390
533
|
const batchTransactions: SignedTransactionType[][] = [
|
|
391
534
|
[tx1, tx2],
|
|
@@ -394,11 +537,11 @@ const batchTransactions: SignedTransactionType[][] = [
|
|
|
394
537
|
const sentTransactions = await transactionManager.send(batchTransactions);
|
|
395
538
|
```
|
|
396
539
|
|
|
397
|
-
3. Tracking Transactions
|
|
540
|
+
#### 3. Tracking Transactions
|
|
398
541
|
|
|
399
542
|
The basic option is to use the built-in tracking, which displays toast notifications with default messages.
|
|
400
543
|
|
|
401
|
-
```
|
|
544
|
+
```typescript
|
|
402
545
|
const sessionId = await transactionManager.track(
|
|
403
546
|
sentTransactions
|
|
404
547
|
// { disableToasts: true } optionally disable toast notifications
|
|
@@ -407,7 +550,7 @@ const sessionId = await transactionManager.track(
|
|
|
407
550
|
|
|
408
551
|
If you want to provide more human-friendly messages to your users, you can enable tracking with custom toast messages:
|
|
409
552
|
|
|
410
|
-
```
|
|
553
|
+
```typescript
|
|
411
554
|
const sessionId = await transactionManager.track(sentTransactions, {
|
|
412
555
|
transactionsDisplayInfo: {
|
|
413
556
|
errorMessage: 'Failed adding stake',
|
|
@@ -417,16 +560,16 @@ const sessionId = await transactionManager.track(sentTransactions, {
|
|
|
417
560
|
});
|
|
418
561
|
```
|
|
419
562
|
|
|
420
|
-
|
|
563
|
+
#### 3.1 Tracking transactions without being logged in
|
|
421
564
|
|
|
422
565
|
If your application needs to track transactions sent by a server and the user does not need to login to see the outcome of these transactions, there are several steps that you need to do to enable this process.
|
|
423
566
|
|
|
424
567
|
Step 1. Enabling the tracking mechanism
|
|
425
568
|
|
|
426
|
-
By default the tracking mechanism is enabled only after the user logs in. That is the moment when the WebSocket connection is established. If you want to enable tracking before the user logs in, you need to call the `trackTransactions` method from the `
|
|
569
|
+
By default the tracking mechanism is enabled only after the user logs in. That is the moment when the WebSocket connection is established. If you want to enable tracking before the user logs in, you need to call the `trackTransactions` method from the `methods/trackTransactions` folder. This method will enable a polling mechanism.
|
|
427
570
|
|
|
428
571
|
```typescript
|
|
429
|
-
import { trackTransactions } from '@multiversx/sdk-dapp/out/
|
|
572
|
+
import { trackTransactions } from '@multiversx/sdk-dapp/out/methods/trackTransactions/trackTransactions';
|
|
430
573
|
|
|
431
574
|
initApp(config).then(async () => {
|
|
432
575
|
await trackTransactions(); // enable here since by default tracking will be enabled only after login
|
|
@@ -434,10 +577,12 @@ initApp(config).then(async () => {
|
|
|
434
577
|
});
|
|
435
578
|
```
|
|
436
579
|
|
|
580
|
+
Step 2. Tracking transactions
|
|
581
|
+
|
|
437
582
|
Then, you can track transactions by calling the `track` method from the `TransactionManager` class with a plain transaction containing the transaction hash.
|
|
438
583
|
|
|
439
584
|
```typescript
|
|
440
|
-
import { Transaction, TransactionsConverter } from '@multiversx/sdk-core
|
|
585
|
+
import { Transaction, TransactionsConverter } from '@multiversx/sdk-core';
|
|
441
586
|
|
|
442
587
|
const tManager = TransactionManager.getInstance();
|
|
443
588
|
const txConverter = new TransactionsConverter();
|
|
@@ -449,11 +594,11 @@ const plainTransaction = { ...transaction.toPlainObject(), hash };
|
|
|
449
594
|
await tManager.track([plainTransaction]);
|
|
450
595
|
```
|
|
451
596
|
|
|
452
|
-
#### Advanced Usage
|
|
597
|
+
#### 3.2 Advanced Usage
|
|
453
598
|
|
|
454
599
|
If you need to check the status of the signed transactions, you can query the store direclty using the `sessionId` returned by the `track()` method.
|
|
455
600
|
|
|
456
|
-
```
|
|
601
|
+
```typescript
|
|
457
602
|
import { getStore } from '@multiversx/sdk-dapp/out/store/store';
|
|
458
603
|
import { transactionsSliceSelector } from '@multiversx/sdk-dapp/out/store/selectors/transactionsSelector';
|
|
459
604
|
|
|
@@ -467,13 +612,17 @@ Object.entries(state).forEach(([sessionKey, data]) => {
|
|
|
467
612
|
|
|
468
613
|
### 5. UI Components
|
|
469
614
|
|
|
470
|
-
sdk-dapp needs to make use of visual elements for allowing the user to interact with some providers (like the ledger), or to display messages to the user (like idle states or toasts). These visual elements consitst of webcomponents hosted in the `@multiversx/sdk-dapp-ui` package. Thus, sdk-dapp does not hold any UI elements, just business logic that controls external components. We can consider two types of UI components: internal and
|
|
615
|
+
`sdk-dapp` needs to make use of visual elements for allowing the user to interact with some providers (like the ledger), or to display messages to the user (like idle states or toasts). These visual elements consitst of webcomponents hosted in the `@multiversx/sdk-dapp-ui` package. Thus, `sdk-dapp` does not hold any UI elements, just business logic that controls external components. We can consider two types of UI components: internal and public. They are differentiated by the way they are controlled: internal components are controlled by `sdk-dapp`'s signing or logging in flows, while public components should be controlled by the dApp.
|
|
616
|
+
|
|
617
|
+
#### 5.1 Public components
|
|
618
|
+
|
|
619
|
+
The public components are the ones that are used in the dApp and are controlled by the dApp. They are defined in the `@multiversx/sdk-dapp-ui` package.
|
|
471
620
|
|
|
472
|
-
|
|
621
|
+
// TODO: add examples
|
|
473
622
|
|
|
474
|
-
####
|
|
623
|
+
#### 5.2 Internal components
|
|
475
624
|
|
|
476
|
-
The way
|
|
625
|
+
The way internal components are controlled are trough a [pub-sub pattern](https://en.wikipedia.org/wiki/Publish%E2%80%93subscribe_pattern) called EventBus. Each webcomponent has a method of exposing its EventBus, thus allowing `sdk-dapp` to get a reference to it and use it for communication.
|
|
477
626
|
|
|
478
627
|
```mermaid
|
|
479
628
|
flowchart LR
|
|
@@ -482,13 +631,13 @@ flowchart LR
|
|
|
482
631
|
|
|
483
632
|
```typescript
|
|
484
633
|
const modalElement = await createUIElement<LedgerConnectModal>(
|
|
485
|
-
'ledger-connect-panel'
|
|
634
|
+
'mvx-ledger-connect-panel'
|
|
486
635
|
);
|
|
487
636
|
const eventBus = await modalElement.getEventBus();
|
|
488
637
|
eventBus.publish('TRANSACTION_TOAST_DATA_UPDATE', someData);
|
|
489
638
|
```
|
|
490
639
|
|
|
491
|
-
If you want to override private components and create your own, you can implement a similar strategy
|
|
640
|
+
If you want to override private components and create your own, you can implement a similar strategy by respecting each webcomponent's API (see an interface example [here](https://github.com/multiversx/mx-sdk-dapp/blob/main/src/providers/strategies/LedgerProviderStrategy/types/ledger.types.ts)).
|
|
492
641
|
|
|
493
642
|
## Debugging your dApp
|
|
494
643
|
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{a as g}from"./chunk-
|
|
2
|
-
//# sourceMappingURL=chunk-
|
|
1
|
+
import{a as g}from"./chunk-MJGS5LXB.mjs";import{a as y}from"./chunk-OYA4AQFY.mjs";import{a as f}from"./chunk-GUHNF5RM.mjs";import{a as c}from"./chunk-67X3ORNS.mjs";import{a as I}from"./chunk-OSYFYAJA.mjs";import{a as l}from"./chunk-LEVR7744.mjs";import{a as w}from"./chunk-XQLVTH7K.mjs";import{a as u}from"./chunk-TCCW2HZK.mjs";import{n as m,o as n,p as P}from"./chunk-J7P6SJOM.mjs";import{a as p}from"./chunk-6746F2FY.mjs";import{a as s}from"./chunk-CN4RHVUE.mjs";import{IframeLoginTypes as b}from"@multiversx/sdk-web-wallet-iframe-provider/out/constants";var d=class{static set customProviders(t){this._customProviders=t}static get customProviders(){return this._customProviders}static async create({type:t,anchor:o}){let e=null;switch(t){case"extension":{e=await new I().createProvider();break}case"crossWindow":{e=await new l().createProvider();break}case"ledger":{e=await new u().createProvider({anchor:o}),await g.getInstance().init();break}case"metamask":{e=await new c({type:b.metamask}).createProvider();break}case"passkey":{e=await new c({type:b.passkey}).createProvider();break}case"walletConnect":{e=await new w().createProvider({anchor:o});break}case"webview":{e=await new f().createProvider();break}default:{let r=p();for(let a of this._customProviders)a.type===t&&(e=await a.constructor({address:r,anchor:o}));break}}if(!e)throw new Error("Unable to create provider");e.getType=()=>t;let v=new m(e);n(v);let i=t;s(i);let k=["crossWindow","metamask","passkey"].includes(i);return y(k?{skipLoginMethod:i}:null),v}static async destroy(){P().cancelLogin(),n(null),s("")}};d._customProviders=[];export{d as a};
|
|
2
|
+
//# sourceMappingURL=chunk-46WBKAT4.mjs.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{a as f}from"./chunk-FRDR4A7Z.mjs";import{a as g}from"./chunk-BQL3NILA.mjs";import{p as c}from"./chunk-
|
|
2
|
-
//# sourceMappingURL=chunk-
|
|
1
|
+
import{a as f}from"./chunk-FRDR4A7Z.mjs";import{a as g}from"./chunk-BQL3NILA.mjs";import{p as c}from"./chunk-J7P6SJOM.mjs";import{u as n}from"./chunk-CN4RHVUE.mjs";import{g as a}from"./chunk-LTF535HP.mjs";import{e as l}from"./chunk-VNLGNNIL.mjs";import{HWProvider as m}from"@multiversx/sdk-hw-provider";async function A(u){let v=g(),d=u?.shouldInitProvider||!v,o=l(n()),t=a(n()),r=c(),i=new m,I=async()=>{let e=o?.index!=null;if(r instanceof m&&r.isInitialized())return e&&await r.setAddressIndex(o.index),r;if(d&&!await i.init())throw new Error("Failed to initialize Ledger Provider");return e&&await i.setAddressIndex(o.index),i};try{if(!d&&t)return{ledgerProvider:i,ledgerConfig:{version:t.version,dataEnabled:t.hasContractDataEnabled}};let e=await I(),s=await f(e);return{ledgerProvider:e,ledgerConfig:s}}catch(e){throw console.error("Could not initialize ledger app",e),e}}export{A as a};
|
|
2
|
+
//# sourceMappingURL=chunk-4NMRZJSQ.mjs.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import{u as e}from"./chunk-CN4RHVUE.mjs";import{b as r}from"./chunk-SAAOQW7P.mjs";function d(t=e()){return r(t).explorerAddress}export{d as a};
|
|
2
|
-
//# sourceMappingURL=chunk-
|
|
2
|
+
//# sourceMappingURL=chunk-4OO7HE5Q.mjs.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/methods/network/getExplorerAddress.ts"],
|
|
4
|
-
"sourcesContent": ["import { networkSelector } from 'store/selectors';\nimport { getState } from 'store/store';\n\nexport function getExplorerAddress(state = getState()) {\n return networkSelector(state).explorerAddress;\n}\n"],
|
|
4
|
+
"sourcesContent": ["import { networkSelector } from 'store/selectors/networkSelectors';\nimport { getState } from 'store/store';\n\nexport function getExplorerAddress(state = getState()) {\n return networkSelector(state).explorerAddress;\n}\n"],
|
|
5
5
|
"mappings": "kFAGO,SAASA,EAAmBC,EAAQC,EAAS,EAAG,CACrD,OAAOC,EAAgBF,CAAK,EAAE,eAChC",
|
|
6
6
|
"names": ["getExplorerAddress", "state", "getState", "networkSelector"]
|
|
7
7
|
}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
var e=(N=>(N.LEDGER_CONNECT="mvx-ledger-connect",N.NOTIFICATIONS_FEED="mvx-notifications-feed",N.PENDING_TRANSACTIONS_PANEL="mvx-pending-transactions-panel",N.SIGN_TRANSACTIONS_PANEL="mvx-sign-transactions-panel",N.TOAST_LIST="mvx-toast-list",N.WALLET_CONNECT="mvx-wallet-connect",N.UNLOCK_PANEL="mvx-unlock-panel",N))(e||{});export{e as a};
|
|
2
|
+
//# sourceMappingURL=chunk-55SACSMS.mjs.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/constants/UITags.enum.ts"],
|
|
4
|
+
"sourcesContent": ["export enum UITagsEnum {\n LEDGER_CONNECT = 'mvx-ledger-connect',\n NOTIFICATIONS_FEED = 'mvx-notifications-feed',\n PENDING_TRANSACTIONS_PANEL = 'mvx-pending-transactions-panel',\n SIGN_TRANSACTIONS_PANEL = 'mvx-sign-transactions-panel',\n TOAST_LIST = 'mvx-toast-list',\n WALLET_CONNECT = 'mvx-wallet-connect',\n UNLOCK_PANEL = 'mvx-unlock-panel'\n}\n"],
|
|
5
|
+
"mappings": "AAAO,IAAKA,OACVA,EAAA,eAAiB,qBACjBA,EAAA,mBAAqB,yBACrBA,EAAA,2BAA6B,iCAC7BA,EAAA,wBAA0B,8BAC1BA,EAAA,WAAa,iBACbA,EAAA,eAAiB,qBACjBA,EAAA,aAAe,mBAPLA,OAAA",
|
|
6
|
+
"names": ["UITagsEnum"]
|
|
7
|
+
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{a as d}from"./chunk-VLHG5NVE.mjs";import{a as c}from"./chunk-
|
|
2
|
-
//# sourceMappingURL=chunk-
|
|
1
|
+
import{a as d}from"./chunk-VLHG5NVE.mjs";import{a as c}from"./chunk-RCBOU6TT.mjs";import{a as p}from"./chunk-DGXP3AZR.mjs";import{a}from"./chunk-CBIH5QMT.mjs";import{u as o}from"./chunk-CN4RHVUE.mjs";import{b as n}from"./chunk-SAAOQW7P.mjs";import{a as e}from"./chunk-2X7ENE6Y.mjs";import{IframeProvider as l}from"@multiversx/sdk-web-wallet-iframe-provider/out";var g=class extends d{constructor({type:r,address:i}){super(i);this.provider=null;this.type=null;this._signTransactions=null;this._signMessage=null;this.createProvider=async()=>{this.initialize();let r=n(o());if(!this.type)throw new Error("Invalid provider type.");return this.provider||(this.provider=l.getInstance(),await this.provider.init()),this.provider.setLoginType(this.type),this.provider.setWalletUrl(String(r.iframeWalletAddress)),this._signTransactions=this.provider.signTransactions.bind(this.provider),this._signMessage=this.provider.signMessage.bind(this.provider),this._login=this.provider.login.bind(this.provider),this.buildProvider()};this.buildProvider=()=>{let{address:r}=a();if(!this.provider)throw new Error("Provider is not initialized.");let i=this.provider;return i.setAccount({address:this.address||r}),i.signTransactions=this.signTransactions,i.signMessage=this.signMessage,i.login=this.login,i.cancelLogin=this.cancelLogin,i};this.signTransactions=async r=>{if(!this.provider||!this._signTransactions)throw new Error("Provider is not initialized.");let{manager:i,onClose:s}=await p({cancelAction:this.provider.cancelAction.bind(this.provider)});i.subscribeToEventBus("CLOSE_PENDING_TRANSACTIONS",s),this.type&&i.updateData({name:e.iframe,type:this.type});try{return await this._signTransactions(r)}catch(t){throw await s({shouldCancelAction:!0}),t}finally{i.closeUI()}};this.signMessage=async r=>{if(!this.provider||!this._signMessage||!this.type)throw new Error("Provider is not initialized.");return await c({message:r,handleSignMessage:this._signMessage.bind(this.provider),cancelAction:this.provider.cancelAction.bind(this.provider),providerType:e[this.type]})};this.type=r}cancelAction(){return this.provider?.cancelAction?.bind(this.provider)()}};export{g as a};
|
|
2
|
+
//# sourceMappingURL=chunk-67X3ORNS.mjs.map
|