@multiversx/sdk-dapp-liquidity 2.0.0 → 2.1.0-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/all-networks--dfVLHLJ.js +2 -0
- package/all-networks-Czd8zS1n.mjs +4 -0
- package/api/checkAccount.js +1 -21
- package/api/checkAccount.mjs +13 -13
- package/api/confirmRate.js +1 -29
- package/api/confirmRate.mjs +17 -22
- package/api/getChains.js +1 -17
- package/api/getChains.mjs +10 -10
- package/api/getRate.js +1 -27
- package/api/getRate.mjs +17 -20
- package/api/getTokens.js +1 -22
- package/api/getTokens.mjs +14 -15
- package/api/getTokensBalances.js +1 -21
- package/api/getTokensBalances.mjs +13 -13
- package/api/getTransactions.js +1 -38
- package/api/getTransactions.mjs +25 -31
- package/api/index.js +1 -18
- package/api/index.mjs +16 -16
- package/api/sendTransactions.js +1 -32
- package/api/sendTransactions.mjs +19 -19
- package/api/tests/confirmRate.spec.js +1 -130
- package/api/tests/confirmRate.spec.mjs +44 -58
- package/api/tests/getChains.spec.js +1 -43
- package/api/tests/getChains.spec.mjs +15 -18
- package/api/tests/getRate.spec.js +1 -87
- package/api/tests/getRate.spec.mjs +35 -49
- package/api/tests/getTokens.spec.js +1 -68
- package/api/tests/getTokens.spec.mjs +23 -29
- package/api/tests/getTransactions.spec.js +1 -94
- package/api/tests/getTransactions.spec.mjs +35 -51
- package/api/tests/sendTransactions.spec.js +1 -96
- package/api/tests/sendTransactions.spec.mjs +44 -52
- package/constants/index.js +1 -4
- package/constants/index.mjs +2 -2
- package/default-D0Jk5ROI.mjs +4 -0
- package/default-DbU6vPaB.js +2 -0
- package/helpers/assertRateConfirmationMatchesIntent.d.ts +8 -0
- package/helpers/assertRateConfirmationMatchesIntent.js +2 -0
- package/helpers/assertRateConfirmationMatchesIntent.mjs +20 -0
- package/helpers/base64Utils.js +1 -31
- package/helpers/base64Utils.mjs +14 -24
- package/helpers/decodeLoginToken.js +1 -27
- package/helpers/decodeLoginToken.mjs +13 -18
- package/helpers/decodeToken.js +1 -39
- package/helpers/decodeToken.mjs +20 -31
- package/helpers/getApiURL.js +1 -7
- package/helpers/getApiURL.mjs +3 -5
- package/helpers/getBridgeURL.js +1 -7
- package/helpers/getBridgeURL.mjs +3 -5
- package/helpers/getDisplayName.js +1 -11
- package/helpers/getDisplayName.mjs +3 -8
- package/helpers/getMvxApiURL.js +1 -7
- package/helpers/getMvxApiURL.mjs +3 -5
- package/helpers/getMvxChainId.js +1 -7
- package/helpers/getMvxChainId.mjs +3 -5
- package/helpers/getMvxExplorerAddress.js +1 -7
- package/helpers/getMvxExplorerAddress.mjs +3 -5
- package/helpers/index.d.ts +2 -0
- package/helpers/index.js +1 -22
- package/helpers/index.mjs +24 -20
- package/helpers/safeImageUrl.d.ts +1 -0
- package/helpers/safeImageUrl.js +2 -0
- package/helpers/safeImageUrl.mjs +13 -0
- package/helpers/serializeTransaction.js +1 -8
- package/helpers/serializeTransaction.mjs +3 -5
- package/helpers/tests/assertRateConfirmationMatchesIntent.spec.d.ts +1 -0
- package/helpers/tests/assertRateConfirmationMatchesIntent.spec.js +2 -0
- package/helpers/tests/assertRateConfirmationMatchesIntent.spec.mjs +52 -0
- package/helpers/tests/base64Utils.spec.js +1 -29
- package/helpers/tests/base64Utils.spec.mjs +11 -24
- package/helpers/tests/decodeLoginToken.spec.js +1 -34
- package/helpers/tests/decodeLoginToken.spec.mjs +13 -24
- package/helpers/tests/decodeToken.spec.js +1 -27
- package/helpers/tests/decodeToken.spec.mjs +7 -12
- package/helpers/tests/safeImageUrl.spec.d.ts +1 -0
- package/helpers/tests/safeImageUrl.spec.js +2 -0
- package/helpers/tests/safeImageUrl.spec.mjs +32 -0
- package/helpers/tests/serializeTransaction.spec.d.ts +1 -0
- package/helpers/tests/serializeTransaction.spec.js +2 -0
- package/helpers/tests/serializeTransaction.spec.mjs +24 -0
- package/index.js +1 -228
- package/index.mjs +196 -192
- package/package.json +14 -9
- package/react.esm-B0AMOHxa.js +73 -0
- package/react.esm-BxvJJ86Q.mjs +9949 -0
- package/reactjs/adapters/SuiAdapter.d.ts +14 -0
- package/reactjs/adapters/SuiAdapter.js +1 -349
- package/reactjs/adapters/SuiAdapter.mjs +171 -199
- package/reactjs/components/AccountAddress/AccountAddress.js +1 -31
- package/reactjs/components/AccountAddress/AccountAddress.mjs +16 -16
- package/reactjs/components/AccountAddress/index.js +1 -4
- package/reactjs/components/AccountAddress/index.mjs +2 -2
- package/reactjs/components/AmountCard/AmountCard.js +1 -33
- package/reactjs/components/AmountCard/AmountCard.mjs +19 -21
- package/reactjs/components/AmountCard/index.js +1 -4
- package/reactjs/components/AmountCard/index.mjs +2 -2
- package/reactjs/components/AmountInput/AmountInput.js +1 -71
- package/reactjs/components/AmountInput/AmountInput.mjs +42 -46
- package/reactjs/components/AmountInput/index.js +1 -4
- package/reactjs/components/AmountInput/index.mjs +2 -2
- package/reactjs/components/BridgeForm/BridgeForm.d.ts +9 -0
- package/reactjs/components/BridgeForm/BridgeForm.js +1 -89
- package/reactjs/components/BridgeForm/BridgeForm.mjs +72 -79
- package/reactjs/components/BridgeForm/Deposit.js +1 -673
- package/reactjs/components/BridgeForm/Deposit.mjs +381 -503
- package/reactjs/components/BridgeForm/Transfer.js +1 -559
- package/reactjs/components/BridgeForm/Transfer.mjs +316 -427
- package/reactjs/components/BridgeForm/hooks/useBridgeAmounts.js +1 -78
- package/reactjs/components/BridgeForm/hooks/useBridgeAmounts.mjs +47 -70
- package/reactjs/components/BridgeForm/hooks/useBridgeRateFetching.js +1 -58
- package/reactjs/components/BridgeForm/hooks/useBridgeRateFetching.mjs +36 -47
- package/reactjs/components/BridgeForm/hooks/useBridgeTokenSelection.js +1 -266
- package/reactjs/components/BridgeForm/hooks/useBridgeTokenSelection.mjs +163 -231
- package/reactjs/components/BridgeForm/index.js +1 -4
- package/reactjs/components/BridgeForm/index.mjs +2 -2
- package/reactjs/components/BridgeForm/utils/bridgeFormHelpers.js +1 -76
- package/reactjs/components/BridgeForm/utils/bridgeFormHelpers.mjs +35 -65
- package/reactjs/components/BridgeHistory/BridgeHistory.js +1 -367
- package/reactjs/components/BridgeHistory/BridgeHistory.mjs +177 -193
- package/reactjs/components/BridgeHistory/index.js +1 -4
- package/reactjs/components/BridgeHistory/index.mjs +2 -2
- package/reactjs/components/Connect/BridgeAccountDisplay.js +1 -150
- package/reactjs/components/Connect/BridgeAccountDisplay.mjs +99 -115
- package/reactjs/components/Connect/BridgeConnectButton.js +1 -34
- package/reactjs/components/Connect/BridgeConnectButton.mjs +20 -19
- package/reactjs/components/Connect/ChainSelectConnect.js +1 -144
- package/reactjs/components/Connect/ChainSelectConnect.mjs +70 -83
- package/reactjs/components/Connect/CustomConnectButton.js +1 -40
- package/reactjs/components/Connect/CustomConnectButton.mjs +24 -30
- package/reactjs/components/Connect/MvxAccountDisplay.js +1 -97
- package/reactjs/components/Connect/MvxAccountDisplay.mjs +47 -50
- package/reactjs/components/Connect/MvxConnectButton.js +1 -43
- package/reactjs/components/Connect/MvxConnectButton.mjs +35 -40
- package/reactjs/components/Connect/SwitchChainButton.js +1 -29
- package/reactjs/components/Connect/SwitchChainButton.mjs +15 -18
- package/reactjs/components/Connect/index.js +1 -16
- package/reactjs/components/Connect/index.mjs +14 -14
- package/reactjs/components/CopyButton/CopyButton.js +1 -46
- package/reactjs/components/CopyButton/CopyButton.mjs +33 -36
- package/reactjs/components/CopyButton/index.js +1 -4
- package/reactjs/components/CopyButton/index.mjs +2 -2
- package/reactjs/components/CopyButton/utils/copyToClipboard.js +1 -38
- package/reactjs/components/CopyButton/utils/copyToClipboard.mjs +20 -32
- package/reactjs/components/CopyButton/utils/index.js +1 -4
- package/reactjs/components/CopyButton/utils/index.mjs +2 -2
- package/reactjs/components/DisplayAmount/DisplayAmount.js +1 -90
- package/reactjs/components/DisplayAmount/DisplayAmount.mjs +68 -75
- package/reactjs/components/DisplayAmount/components/AnimateNumber/AnimateNumber.js +1 -39
- package/reactjs/components/DisplayAmount/components/AnimateNumber/AnimateNumber.mjs +26 -33
- package/reactjs/components/DisplayAmount/components/PrecisedAmount/PrecisedAmount.js +1 -61
- package/reactjs/components/DisplayAmount/components/PrecisedAmount/PrecisedAmount.mjs +38 -46
- package/reactjs/components/DisplayAmount/index.js +1 -4
- package/reactjs/components/DisplayAmount/index.mjs +2 -2
- package/reactjs/components/DisplayAmount/utils/index.js +1 -4
- package/reactjs/components/DisplayAmount/utils/index.mjs +2 -2
- package/reactjs/components/DisplayAmount/utils/truncateAmount.js +1 -21
- package/reactjs/components/DisplayAmount/utils/truncateAmount.mjs +9 -13
- package/reactjs/components/Error/Error.js +1 -66
- package/reactjs/components/Error/Error.mjs +29 -29
- package/reactjs/components/Error/index.js +1 -4
- package/reactjs/components/Error/index.mjs +2 -2
- package/reactjs/components/SmallLoader/SmallLoader.js +1 -21
- package/reactjs/components/SmallLoader/SmallLoader.mjs +13 -18
- package/reactjs/components/SmallLoader/index.js +1 -4
- package/reactjs/components/SmallLoader/index.mjs +2 -2
- package/reactjs/components/ToggleDirection/ToggleDirection.js +1 -30
- package/reactjs/components/ToggleDirection/ToggleDirection.mjs +22 -28
- package/reactjs/components/TokenSelector/TokenSelector.js +1 -172
- package/reactjs/components/TokenSelector/TokenSelector.mjs +98 -118
- package/reactjs/components/TokenSelector/components/ChainSelect/ChainSelect.js +1 -94
- package/reactjs/components/TokenSelector/components/ChainSelect/ChainSelect.mjs +48 -57
- package/reactjs/components/TokenSelector/components/ChainSelect/components/ChainOptionLabel.js +1 -51
- package/reactjs/components/TokenSelector/components/ChainSelect/components/ChainOptionLabel.mjs +45 -44
- package/reactjs/components/TokenSelector/components/ChainSelect/components/FormatChainOptionLabel.js +1 -18
- package/reactjs/components/TokenSelector/components/ChainSelect/components/FormatChainOptionLabel.mjs +9 -14
- package/reactjs/components/TokenSelector/components/ChainSelect/components/IndicatorSeparator.js +1 -6
- package/reactjs/components/TokenSelector/components/ChainSelect/components/IndicatorSeparator.mjs +2 -4
- package/reactjs/components/TokenSelector/components/ChainSelect/components/SelectedChainOption.js +1 -39
- package/reactjs/components/TokenSelector/components/ChainSelect/components/SelectedChainOption.mjs +22 -18
- package/reactjs/components/TokenSelector/components/SelectContainer.js +1 -40
- package/reactjs/components/TokenSelector/components/SelectContainer.mjs +36 -38
- package/reactjs/components/TokenSelector/components/SelectContent.js +1 -136
- package/reactjs/components/TokenSelector/components/SelectContent.mjs +79 -103
- package/reactjs/components/TokenSelector/components/SelectedOption.js +1 -28
- package/reactjs/components/TokenSelector/components/SelectedOption.mjs +22 -24
- package/reactjs/components/TokenSelector/components/TokenIcon.js +1 -81
- package/reactjs/components/TokenSelector/components/TokenIcon.mjs +52 -57
- package/reactjs/components/TokenSelector/components/TokenItem.js +1 -80
- package/reactjs/components/TokenSelector/components/TokenItem.mjs +41 -54
- package/reactjs/components/TokenSelector/components/TokenList.js +1 -23
- package/reactjs/components/TokenSelector/components/TokenList.mjs +19 -21
- package/reactjs/components/TokenSelector/components/TokenSymbol.js +1 -25
- package/reactjs/components/TokenSelector/components/TokenSymbol.mjs +14 -15
- package/reactjs/components/TokenSelector/index.js +1 -4
- package/reactjs/components/TokenSelector/index.mjs +2 -2
- package/reactjs/components/TransactionToast/TransactionToast.js +1 -53
- package/reactjs/components/TransactionToast/TransactionToast.mjs +27 -28
- package/reactjs/components/TransactionToast/TransactionToastContainer.js +1 -20
- package/reactjs/components/TransactionToast/TransactionToastContainer.mjs +16 -18
- package/reactjs/components/TransactionToast/index.js +1 -6
- package/reactjs/components/TransactionToast/index.mjs +4 -4
- package/reactjs/components/TrimAddress/TrimAddress.js +1 -27
- package/reactjs/components/TrimAddress/TrimAddress.mjs +19 -24
- package/reactjs/components/TrimAddress/index.js +1 -4
- package/reactjs/components/TrimAddress/index.mjs +2 -2
- package/reactjs/components/base/MxButton/MxButton.js +1 -71
- package/reactjs/components/base/MxButton/MxButton.mjs +46 -46
- package/reactjs/components/base/MxButton/index.js +1 -4
- package/reactjs/components/base/MxButton/index.mjs +2 -2
- package/reactjs/components/base/MxCard/MxCard.js +1 -54
- package/reactjs/components/base/MxCard/MxCard.mjs +34 -34
- package/reactjs/components/base/MxCard/index.js +1 -4
- package/reactjs/components/base/MxCard/index.mjs +2 -2
- package/reactjs/components/base/MxCircleLoader/MxCircleLoader.js +1 -28
- package/reactjs/components/base/MxCircleLoader/MxCircleLoader.mjs +24 -26
- package/reactjs/components/base/MxCircleLoader/index.js +1 -4
- package/reactjs/components/base/MxCircleLoader/index.mjs +2 -2
- package/reactjs/components/base/MxLink/MxLink.js +1 -70
- package/reactjs/components/base/MxLink/MxLink.mjs +44 -46
- package/reactjs/components/base/MxLink/index.js +1 -4
- package/reactjs/components/base/MxLink/index.mjs +2 -2
- package/reactjs/components/base/MxSearch/MxSearch.js +1 -69
- package/reactjs/components/base/MxSearch/MxSearch.mjs +37 -41
- package/reactjs/components/base/MxSearch/index.js +1 -4
- package/reactjs/components/base/MxSearch/index.mjs +2 -2
- package/reactjs/components/base/MxSlideover/MxSlideover.js +1 -78
- package/reactjs/components/base/MxSlideover/MxSlideover.mjs +72 -74
- package/reactjs/components/base/MxSlideover/index.js +1 -4
- package/reactjs/components/base/MxSlideover/index.mjs +2 -2
- package/reactjs/components/base/MxTooltip/MxTooltip.js +1 -163
- package/reactjs/components/base/MxTooltip/MxTooltip.mjs +92 -135
- package/reactjs/components/base/MxTooltip/components/TooltipContainer/TooltipContainer.js +1 -33
- package/reactjs/components/base/MxTooltip/components/TooltipContainer/TooltipContainer.mjs +29 -31
- package/reactjs/components/base/MxTooltip/components/TooltipContainer/index.js +1 -4
- package/reactjs/components/base/MxTooltip/components/TooltipContainer/index.mjs +2 -2
- package/reactjs/components/base/MxTooltip/components/TooltipContent/TooltipContent.js +1 -27
- package/reactjs/components/base/MxTooltip/components/TooltipContent/TooltipContent.mjs +23 -25
- package/reactjs/components/base/MxTooltip/components/TooltipContent/index.js +1 -4
- package/reactjs/components/base/MxTooltip/components/TooltipContent/index.mjs +2 -2
- package/reactjs/components/base/MxTooltip/components/index.js +1 -6
- package/reactjs/components/base/MxTooltip/components/index.mjs +4 -4
- package/reactjs/components/base/MxTooltip/index.js +1 -4
- package/reactjs/components/base/MxTooltip/index.mjs +2 -2
- package/reactjs/components/base/index.js +1 -14
- package/reactjs/components/base/index.mjs +12 -12
- package/reactjs/components/index.js +1 -54
- package/reactjs/components/index.mjs +52 -52
- package/reactjs/constants/chains.js +1 -54
- package/reactjs/constants/chains.mjs +33 -52
- package/reactjs/constants/index.js +1 -13
- package/reactjs/constants/index.mjs +9 -10
- package/reactjs/context/Web3AppProvider.js +1 -40
- package/reactjs/context/Web3AppProvider.mjs +34 -34
- package/reactjs/context/queryClient.js +1 -11
- package/reactjs/context/queryClient.mjs +5 -8
- package/reactjs/context/useWeb3App.js +1 -12
- package/reactjs/context/useWeb3App.mjs +7 -8
- package/reactjs/helpers/index.js +1 -6
- package/reactjs/helpers/index.mjs +4 -4
- package/reactjs/helpers/resolveBridgeApiChainId.js +1 -40
- package/reactjs/helpers/resolveBridgeApiChainId.mjs +21 -34
- package/reactjs/hooks/index.js +1 -35
- package/reactjs/hooks/index.mjs +33 -33
- package/reactjs/hooks/tests/useGenericSignMessage.spec.d.ts +1 -0
- package/reactjs/hooks/tests/useGenericSignMessage.spec.js +2 -0
- package/reactjs/hooks/tests/useGenericSignMessage.spec.mjs +52 -0
- package/reactjs/hooks/tests/useSignTransaction.spec.d.ts +1 -0
- package/reactjs/hooks/tests/useSignTransaction.spec.js +2 -0
- package/reactjs/hooks/tests/useSignTransaction.spec.mjs +156 -0
- package/reactjs/hooks/useAccount.js +1 -13
- package/reactjs/hooks/useAccount.mjs +7 -8
- package/reactjs/hooks/useBalances.js +1 -53
- package/reactjs/hooks/useBalances.mjs +28 -40
- package/reactjs/hooks/useBridgeApiChainId.js +1 -13
- package/reactjs/hooks/useBridgeApiChainId.mjs +9 -9
- package/reactjs/hooks/useBridgeFormik.js +1 -162
- package/reactjs/hooks/useBridgeFormik.mjs +110 -150
- package/reactjs/hooks/useDebounce.js +1 -13
- package/reactjs/hooks/useDebounce.mjs +8 -10
- package/reactjs/hooks/useFetchBridgeData.js +1 -45
- package/reactjs/hooks/useFetchBridgeData.mjs +37 -38
- package/reactjs/hooks/useFetchTokens.js +1 -113
- package/reactjs/hooks/useFetchTokens.mjs +80 -106
- package/reactjs/hooks/useGenericSignMessage.js +1 -55
- package/reactjs/hooks/useGenericSignMessage.mjs +47 -47
- package/reactjs/hooks/useGetChainId.js +1 -11
- package/reactjs/hooks/useGetChainId.mjs +7 -8
- package/reactjs/hooks/useResolveTokenChain.js +1 -20
- package/reactjs/hooks/useResolveTokenChain.mjs +11 -14
- package/reactjs/hooks/useSendTransactions.js +1 -25
- package/reactjs/hooks/useSendTransactions.mjs +19 -23
- package/reactjs/hooks/useSignTransaction.js +1 -86
- package/reactjs/hooks/useSignTransaction.mjs +59 -59
- package/reactjs/hooks/useSuiConnect.js +1 -86
- package/reactjs/hooks/useSuiConnect.mjs +52 -70
- package/reactjs/hooks/validation/index.js +1 -10
- package/reactjs/hooks/validation/index.mjs +8 -8
- package/reactjs/hooks/validation/useAmountSchema.js +1 -32
- package/reactjs/hooks/validation/useAmountSchema.mjs +8 -11
- package/reactjs/hooks/validation/useSecondAmountSchema.js +1 -26
- package/reactjs/hooks/validation/useSecondAmountSchema.mjs +5 -6
- package/reactjs/hooks/validation/useTestHasEnoughFunds.js +1 -37
- package/reactjs/hooks/validation/useTestHasEnoughFunds.mjs +20 -29
- package/reactjs/hooks/validation/useTestIsConnected.js +1 -27
- package/reactjs/hooks/validation/useTestIsConnected.mjs +13 -19
- package/reactjs/index.js +1 -190
- package/reactjs/index.mjs +154 -154
- package/reactjs/init/index.js +1 -5
- package/reactjs/init/index.mjs +3 -3
- package/reactjs/init/init.d.ts +1 -0
- package/reactjs/init/init.js +1 -139
- package/reactjs/init/init.mjs +59 -72
- package/reactjs/queries/index.js +1 -17
- package/reactjs/queries/index.mjs +15 -15
- package/reactjs/queries/useCheckAccount.query.js +1 -39
- package/reactjs/queries/useCheckAccount.query.mjs +29 -33
- package/reactjs/queries/useGetAllTokens.query.js +1 -35
- package/reactjs/queries/useGetAllTokens.query.mjs +26 -30
- package/reactjs/queries/useGetChains.query.js +1 -34
- package/reactjs/queries/useGetChains.query.mjs +26 -28
- package/reactjs/queries/useGetHistory.query.d.ts +1 -1
- package/reactjs/queries/useGetHistory.query.js +1 -68
- package/reactjs/queries/useGetHistory.query.mjs +55 -58
- package/reactjs/queries/useGetMvxTokensBalances.query.d.ts +1 -1
- package/reactjs/queries/useGetMvxTokensBalances.query.js +1 -71
- package/reactjs/queries/useGetMvxTokensBalances.query.mjs +40 -53
- package/reactjs/queries/useGetNonMvxTokensBalances.query.d.ts +1 -1
- package/reactjs/queries/useGetNonMvxTokensBalances.query.js +1 -81
- package/reactjs/queries/useGetNonMvxTokensBalances.query.mjs +51 -59
- package/reactjs/queries/useGetRate.mutation.js +1 -18
- package/reactjs/queries/useGetRate.mutation.mjs +12 -15
- package/reactjs/reexports.js +1 -48
- package/reactjs/reexports.mjs +13 -13
- package/reactjs/utils/delay.js +1 -6
- package/reactjs/utils/delay.mjs +3 -3
- package/reactjs/utils/formatAmount.js +1 -23
- package/reactjs/utils/formatAmount.mjs +16 -17
- package/reactjs/utils/getCleanStringAmount.js +1 -11
- package/reactjs/utils/getCleanStringAmount.mjs +6 -8
- package/reactjs/utils/getCompletePathname.js +1 -5
- package/reactjs/utils/getCompletePathname.mjs +3 -3
- package/reactjs/utils/getInitialTokens.js +1 -12
- package/reactjs/utils/getInitialTokens.mjs +6 -7
- package/reactjs/utils/hasEnoughFunds.js +1 -19
- package/reactjs/utils/hasEnoughFunds.mjs +11 -14
- package/reactjs/utils/index.js +1 -26
- package/reactjs/utils/index.mjs +24 -24
- package/reactjs/utils/isStringFloat.js +1 -21
- package/reactjs/utils/isStringFloat.mjs +11 -18
- package/reactjs/utils/mxClsx.js +1 -8
- package/reactjs/utils/mxClsx.mjs +4 -6
- package/reactjs/utils/pipe.js +1 -25
- package/reactjs/utils/pipe.mjs +13 -17
- package/reactjs/utils/removeCommas.js +1 -6
- package/reactjs/utils/removeCommas.mjs +2 -4
- package/reactjs/utils/roundAmount.js +1 -40
- package/reactjs/utils/roundAmount.mjs +16 -36
- package/reactjs/utils/testNumber.js +1 -4
- package/reactjs/utils/testNumber.mjs +2 -2
- package/store/inMemoryStore.js +1 -39
- package/store/inMemoryStore.mjs +17 -21
- package/style.css +1 -2274
- package/types/chainType.js +1 -11
- package/types/chainType.mjs +2 -9
- package/types/errors.d.ts +3 -0
- package/types/errors.js +2 -0
- package/types/errors.mjs +8 -0
- package/types/providerType.js +1 -9
- package/types/providerType.mjs +2 -7
- package/types/transaction.d.ts +2 -0
- package/all-networks-EJIVYZ_i.mjs +0 -4
- package/all-networks-NYACMyeN.js +0 -4
- package/default-BYtXv70Z.mjs +0 -4
- package/default-H3AbmzFV.js +0 -4
- package/reactjs/hooks/useSignTransaction.d.ts +0 -511
|
@@ -7,6 +7,11 @@ export type SuiAdapterOptions = {
|
|
|
7
7
|
* AppKit sometimes passes an empty `networks` array into `construct`; this keeps WC valid.
|
|
8
8
|
*/
|
|
9
9
|
explicitCaipChains?: string[];
|
|
10
|
+
/**
|
|
11
|
+
* When set, `connect()` will throw if the WalletConnect session advertises a different address.
|
|
12
|
+
* If not set, any address is accepted (backward-compatible).
|
|
13
|
+
*/
|
|
14
|
+
expectedSuiAddress?: string;
|
|
10
15
|
};
|
|
11
16
|
export declare class SuiAdapter extends AdapterBlueprint {
|
|
12
17
|
/**
|
|
@@ -16,6 +21,7 @@ export declare class SuiAdapter extends AdapterBlueprint {
|
|
|
16
21
|
*/
|
|
17
22
|
private sharedWcProvider?;
|
|
18
23
|
private readonly explicitCaipChainsFromInit;
|
|
24
|
+
private readonly expectedSuiAddress?;
|
|
19
25
|
constructor(opts?: SuiAdapterOptions);
|
|
20
26
|
/**
|
|
21
27
|
* AppKit passes `networks` here from `createAppKit({ networks })` filtered by namespace.
|
|
@@ -47,6 +53,14 @@ export declare class SuiAdapter extends AdapterBlueprint {
|
|
|
47
53
|
syncConnection(params: AdapterBlueprint.SyncConnectionParams): Promise<AdapterBlueprint.ConnectResult>;
|
|
48
54
|
syncConnections({ connectToFirstConnector, caipNetwork }: AdapterBlueprint.SyncConnectionsParams): Promise<void>;
|
|
49
55
|
getWalletConnectProvider(params: AdapterBlueprint.GetWalletConnectProviderParams): AdapterBlueprint.GetWalletConnectProviderResult;
|
|
56
|
+
/**
|
|
57
|
+
* Resolves the CAIP-2 chain scope string for WalletConnect requests.
|
|
58
|
+
* Resolution order:
|
|
59
|
+
* 1. `caipNetworkId` argument (if it starts with `'sui:'`)
|
|
60
|
+
* 2. First `'sui:'`-prefixed entry in `explicitCaipChainsFromInit`
|
|
61
|
+
* 3. `'sui:mainnet'` as a safe last resort
|
|
62
|
+
*/
|
|
63
|
+
private getChainScope;
|
|
50
64
|
signMessage(params: AdapterBlueprint.SignMessageParams): Promise<AdapterBlueprint.SignMessageResult>;
|
|
51
65
|
sendTransaction(params: AdapterBlueprint.SendTransactionParams): Promise<AdapterBlueprint.SendTransactionResult>;
|
|
52
66
|
estimateGas(): Promise<AdapterBlueprint.EstimateGasTransactionResult>;
|
|
@@ -1,350 +1,2 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
"use strict";
|
|
3
|
-
var __defProp = Object.defineProperty;
|
|
4
|
-
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
5
|
-
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
6
|
-
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
7
|
-
const appkitControllers = require("@reown/appkit-controllers");
|
|
8
|
-
const WC_ID = "walletConnect";
|
|
9
|
-
const DEFAULT_SUI_CAIP_CHAINS = ["sui:mainnet", "sui:testnet", "sui:devnet"];
|
|
10
|
-
class SuiAdapter extends appkitControllers.AdapterBlueprint {
|
|
11
|
-
constructor(opts) {
|
|
12
|
-
super({
|
|
13
|
-
namespace: "sui",
|
|
14
|
-
adapterType: "sui"
|
|
15
|
-
});
|
|
16
|
-
/**
|
|
17
|
-
* AppKit’s single WalletConnect UniversalProvider (same instance as Wagmi/EVM).
|
|
18
|
-
* @see @reown/appkit-adapter-solana — adapters must NOT call UniversalProvider.init() again
|
|
19
|
-
* (duplicate Core breaks pairing / QR). `listenWalletConnect` attaches `display_uri` here only.
|
|
20
|
-
*/
|
|
21
|
-
__publicField(this, "sharedWcProvider");
|
|
22
|
-
__publicField(this, "explicitCaipChainsFromInit");
|
|
23
|
-
/**
|
|
24
|
-
* AppKit passes `networks` here from `createAppKit({ networks })` filtered by namespace.
|
|
25
|
-
* `ChainController.getRequestedCaipNetworks('sui')` is often still empty → we must keep this.
|
|
26
|
-
*/
|
|
27
|
-
__publicField(this, "suiNetworksFromConfig", []);
|
|
28
|
-
this.explicitCaipChainsFromInit = (opts == null ? void 0 : opts.explicitCaipChains) ?? [];
|
|
29
|
-
}
|
|
30
|
-
construct(params) {
|
|
31
|
-
super.construct(params);
|
|
32
|
-
this.suiNetworksFromConfig = params.networks ?? [];
|
|
33
|
-
}
|
|
34
|
-
/**
|
|
35
|
-
* Resolves CAIP-2 chain ids for the WC session. Never return [] (breaks pairing + QR UI).
|
|
36
|
-
*/
|
|
37
|
-
pickChainsFromExplicit(explicit, chainId) {
|
|
38
|
-
if (explicit.length === 0) {
|
|
39
|
-
return DEFAULT_SUI_CAIP_CHAINS;
|
|
40
|
-
}
|
|
41
|
-
if (chainId !== void 0 && chainId !== null) {
|
|
42
|
-
const cid = chainId.toString();
|
|
43
|
-
const match = explicit.find(
|
|
44
|
-
(c) => c === `sui:${cid}` || c.endsWith(`:${cid}`)
|
|
45
|
-
);
|
|
46
|
-
if (match) {
|
|
47
|
-
return [match];
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
return explicit;
|
|
51
|
-
}
|
|
52
|
-
resolveSuiChainsForConnect(chainId) {
|
|
53
|
-
const fromController = this.getCaipNetworks("sui");
|
|
54
|
-
const source = fromController.length > 0 ? fromController : this.suiNetworksFromConfig;
|
|
55
|
-
if (source.length === 0) {
|
|
56
|
-
return this.pickChainsFromExplicit(
|
|
57
|
-
this.explicitCaipChainsFromInit,
|
|
58
|
-
chainId
|
|
59
|
-
);
|
|
60
|
-
}
|
|
61
|
-
const toCaip = (n) => n.caipNetworkId || `sui:${n.id}`;
|
|
62
|
-
if (chainId !== void 0 && chainId !== null) {
|
|
63
|
-
const match = source.find((n) => {
|
|
64
|
-
var _a;
|
|
65
|
-
return ((_a = n.id) == null ? void 0 : _a.toString()) === chainId.toString();
|
|
66
|
-
});
|
|
67
|
-
if (match) {
|
|
68
|
-
return [toCaip(match)];
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
return source.map(toCaip);
|
|
72
|
-
}
|
|
73
|
-
/**
|
|
74
|
-
* `WalletConnectConnector` typings require `caipNetworks` (ChainController may still be empty
|
|
75
|
-
* when this runs). Prefer networks from `construct`, else explicit/init CAIP ids.
|
|
76
|
-
*/
|
|
77
|
-
getCaipNetworksForWalletConnectConnector() {
|
|
78
|
-
if (this.suiNetworksFromConfig.length > 0) {
|
|
79
|
-
return this.suiNetworksFromConfig;
|
|
80
|
-
}
|
|
81
|
-
const caipIds = this.explicitCaipChainsFromInit.length > 0 ? this.explicitCaipChainsFromInit : DEFAULT_SUI_CAIP_CHAINS;
|
|
82
|
-
return caipIds.map((caip) => {
|
|
83
|
-
const id = caip.startsWith("sui:") ? caip.slice(4) : caip;
|
|
84
|
-
return {
|
|
85
|
-
id,
|
|
86
|
-
chainNamespace: "sui",
|
|
87
|
-
caipNetworkId: caip,
|
|
88
|
-
name: "Sui",
|
|
89
|
-
nativeCurrency: { name: "SUI", symbol: "SUI", decimals: 9 },
|
|
90
|
-
rpcUrls: {
|
|
91
|
-
default: { http: [`https://fullnode.${id}.sui.io:443`] }
|
|
92
|
-
}
|
|
93
|
-
};
|
|
94
|
-
});
|
|
95
|
-
}
|
|
96
|
-
syncConnectors() {
|
|
97
|
-
}
|
|
98
|
-
async setUniversalProvider(sharedProvider) {
|
|
99
|
-
this.sharedWcProvider = sharedProvider;
|
|
100
|
-
const wcConnector = new appkitControllers.WalletConnectConnector({
|
|
101
|
-
provider: sharedProvider,
|
|
102
|
-
namespace: "sui",
|
|
103
|
-
caipNetworks: this.getCaipNetworksForWalletConnectConnector()
|
|
104
|
-
});
|
|
105
|
-
this.addConnector(wcConnector);
|
|
106
|
-
appkitControllers.WcHelpersUtil.listenWcProvider({
|
|
107
|
-
universalProvider: sharedProvider,
|
|
108
|
-
namespace: "sui",
|
|
109
|
-
onConnect: (accounts) => this.onConnect(accounts, WC_ID),
|
|
110
|
-
onDisconnect: () => this.onDisconnect(WC_ID),
|
|
111
|
-
onAccountsChanged: (accounts) => this.onAccountsChanged(accounts, WC_ID, false)
|
|
112
|
-
});
|
|
113
|
-
}
|
|
114
|
-
getWcProvider() {
|
|
115
|
-
if (!this.sharedWcProvider) {
|
|
116
|
-
throw new Error(
|
|
117
|
-
"SuiAdapter: UniversalProvider not ready — setUniversalProvider must run before connect"
|
|
118
|
-
);
|
|
119
|
-
}
|
|
120
|
-
return this.sharedWcProvider;
|
|
121
|
-
}
|
|
122
|
-
async connectWalletConnect(chainId) {
|
|
123
|
-
var _a, _b;
|
|
124
|
-
const wc = this.getWcProvider();
|
|
125
|
-
if ((_b = (_a = wc.session) == null ? void 0 : _a.namespaces) == null ? void 0 : _b["sui"]) {
|
|
126
|
-
const clientId2 = await wc.client.core.crypto.getClientId();
|
|
127
|
-
return { clientId: clientId2 };
|
|
128
|
-
}
|
|
129
|
-
const chains = this.resolveSuiChainsForConnect(chainId);
|
|
130
|
-
const safeChains = chains.length > 0 ? chains : DEFAULT_SUI_CAIP_CHAINS;
|
|
131
|
-
await wc.connect({
|
|
132
|
-
optionalNamespaces: {
|
|
133
|
-
sui: {
|
|
134
|
-
methods: [
|
|
135
|
-
"sui_signPersonalMessage",
|
|
136
|
-
"sui_signTransaction",
|
|
137
|
-
"sui_signAndExecuteTransaction"
|
|
138
|
-
],
|
|
139
|
-
chains: safeChains,
|
|
140
|
-
events: []
|
|
141
|
-
}
|
|
142
|
-
}
|
|
143
|
-
});
|
|
144
|
-
const clientId = await wc.client.core.crypto.getClientId();
|
|
145
|
-
return { clientId };
|
|
146
|
-
}
|
|
147
|
-
async connect(params) {
|
|
148
|
-
var _a, _b, _c;
|
|
149
|
-
const connector = this.connectors.find((c) => c.id === params.id);
|
|
150
|
-
if (!connector) {
|
|
151
|
-
throw new Error("Sui connector not found");
|
|
152
|
-
}
|
|
153
|
-
const existingConnection = this.getConnection({
|
|
154
|
-
address: params.address,
|
|
155
|
-
connectorId: connector.id,
|
|
156
|
-
connections: this.connections,
|
|
157
|
-
connectors: this.connectors
|
|
158
|
-
});
|
|
159
|
-
if (existingConnection == null ? void 0 : existingConnection.account) {
|
|
160
|
-
const chainId2 = ((_a = existingConnection.caipNetwork) == null ? void 0 : _a.id) ?? params.chainId ?? "mainnet";
|
|
161
|
-
this.emit("accountChanged", {
|
|
162
|
-
address: existingConnection.account.address,
|
|
163
|
-
chainId: chainId2,
|
|
164
|
-
connector
|
|
165
|
-
});
|
|
166
|
-
return {
|
|
167
|
-
id: connector.id,
|
|
168
|
-
address: existingConnection.account.address,
|
|
169
|
-
chainId: chainId2,
|
|
170
|
-
provider: connector.provider,
|
|
171
|
-
type: connector.type
|
|
172
|
-
};
|
|
173
|
-
}
|
|
174
|
-
const wc = this.getWcProvider();
|
|
175
|
-
const accounts = appkitControllers.WcHelpersUtil.getWalletConnectAccounts(
|
|
176
|
-
wc,
|
|
177
|
-
"sui"
|
|
178
|
-
);
|
|
179
|
-
const address = (_b = accounts[0]) == null ? void 0 : _b.address;
|
|
180
|
-
if (!address) {
|
|
181
|
-
throw new Error("No Sui account found after WalletConnect session");
|
|
182
|
-
}
|
|
183
|
-
const caipNetwork = (_c = this.getCaipNetworks()) == null ? void 0 : _c.find(
|
|
184
|
-
(n) => n.id === params.chainId
|
|
185
|
-
);
|
|
186
|
-
this.addConnection({
|
|
187
|
-
connectorId: connector.id,
|
|
188
|
-
accounts: [{ address }],
|
|
189
|
-
caipNetwork
|
|
190
|
-
});
|
|
191
|
-
const chainId = params.chainId ?? (caipNetwork == null ? void 0 : caipNetwork.id) ?? "mainnet";
|
|
192
|
-
this.emit("accountChanged", {
|
|
193
|
-
address,
|
|
194
|
-
chainId,
|
|
195
|
-
connector
|
|
196
|
-
});
|
|
197
|
-
return {
|
|
198
|
-
id: connector.id,
|
|
199
|
-
address,
|
|
200
|
-
chainId,
|
|
201
|
-
provider: connector.provider,
|
|
202
|
-
type: connector.type
|
|
203
|
-
};
|
|
204
|
-
}
|
|
205
|
-
async disconnect(params) {
|
|
206
|
-
if (params == null ? void 0 : params.id) {
|
|
207
|
-
if (this.sharedWcProvider) {
|
|
208
|
-
try {
|
|
209
|
-
await this.sharedWcProvider.disconnect();
|
|
210
|
-
} catch {
|
|
211
|
-
}
|
|
212
|
-
}
|
|
213
|
-
this.deleteConnection(params.id);
|
|
214
|
-
}
|
|
215
|
-
if (this.connections.length === 0) {
|
|
216
|
-
this.emit("disconnect");
|
|
217
|
-
} else {
|
|
218
|
-
this.emitFirstAvailableConnection();
|
|
219
|
-
}
|
|
220
|
-
return { connections: this.connections };
|
|
221
|
-
}
|
|
222
|
-
async getAccounts(params) {
|
|
223
|
-
if (!this.sharedWcProvider) {
|
|
224
|
-
return { accounts: [] };
|
|
225
|
-
}
|
|
226
|
-
const accounts = appkitControllers.WcHelpersUtil.getWalletConnectAccounts(
|
|
227
|
-
this.sharedWcProvider,
|
|
228
|
-
"sui"
|
|
229
|
-
);
|
|
230
|
-
return {
|
|
231
|
-
accounts: accounts.map((a) => ({
|
|
232
|
-
namespace: "sui",
|
|
233
|
-
address: a.address,
|
|
234
|
-
type: "eoa"
|
|
235
|
-
}))
|
|
236
|
-
};
|
|
237
|
-
}
|
|
238
|
-
async getBalance(params) {
|
|
239
|
-
var _a, _b, _c;
|
|
240
|
-
if (!params.address) {
|
|
241
|
-
return { balance: "0", symbol: "SUI" };
|
|
242
|
-
}
|
|
243
|
-
try {
|
|
244
|
-
const caipNetwork = (_a = this.getCaipNetworks()) == null ? void 0 : _a.find(
|
|
245
|
-
(n) => n.id === params.chainId
|
|
246
|
-
);
|
|
247
|
-
const rpcUrl = `https://fullnode.${caipNetwork == null ? void 0 : caipNetwork.id}.sui.io:443`;
|
|
248
|
-
if (!rpcUrl) {
|
|
249
|
-
return { balance: "0", symbol: "SUI" };
|
|
250
|
-
}
|
|
251
|
-
const res = await fetch(rpcUrl, {
|
|
252
|
-
method: "POST",
|
|
253
|
-
headers: { "Content-Type": "application/json" },
|
|
254
|
-
body: JSON.stringify({
|
|
255
|
-
jsonrpc: "2.0",
|
|
256
|
-
id: 1,
|
|
257
|
-
method: "suix_getBalance",
|
|
258
|
-
params: [params.address, "0x2::sui::SUI"]
|
|
259
|
-
})
|
|
260
|
-
});
|
|
261
|
-
const data = await res.json();
|
|
262
|
-
const totalBalance = ((_b = data == null ? void 0 : data.result) == null ? void 0 : _b.totalBalance) ?? "0";
|
|
263
|
-
const formatted = (parseInt(totalBalance, 10) / 1e9).toString();
|
|
264
|
-
return {
|
|
265
|
-
balance: formatted,
|
|
266
|
-
symbol: ((_c = caipNetwork == null ? void 0 : caipNetwork.nativeCurrency) == null ? void 0 : _c.symbol) || "SUI"
|
|
267
|
-
};
|
|
268
|
-
} catch {
|
|
269
|
-
return { balance: "0", symbol: "SUI" };
|
|
270
|
-
}
|
|
271
|
-
}
|
|
272
|
-
async switchNetwork(params) {
|
|
273
|
-
await super.switchNetwork(params);
|
|
274
|
-
}
|
|
275
|
-
async syncConnection(params) {
|
|
276
|
-
return this.connect({ ...params, type: "" });
|
|
277
|
-
}
|
|
278
|
-
async syncConnections({
|
|
279
|
-
connectToFirstConnector,
|
|
280
|
-
caipNetwork
|
|
281
|
-
}) {
|
|
282
|
-
if (!this.sharedWcProvider) {
|
|
283
|
-
return;
|
|
284
|
-
}
|
|
285
|
-
const accounts = appkitControllers.WcHelpersUtil.getWalletConnectAccounts(
|
|
286
|
-
this.sharedWcProvider,
|
|
287
|
-
"sui"
|
|
288
|
-
);
|
|
289
|
-
if (accounts.length > 0) {
|
|
290
|
-
this.addConnection({
|
|
291
|
-
connectorId: WC_ID,
|
|
292
|
-
accounts: accounts.map((a) => ({ address: a.address })),
|
|
293
|
-
caipNetwork
|
|
294
|
-
});
|
|
295
|
-
}
|
|
296
|
-
if (connectToFirstConnector) {
|
|
297
|
-
this.emitFirstAvailableConnection();
|
|
298
|
-
}
|
|
299
|
-
}
|
|
300
|
-
getWalletConnectProvider(params) {
|
|
301
|
-
return params.provider;
|
|
302
|
-
}
|
|
303
|
-
async signMessage(params) {
|
|
304
|
-
const wc = this.getWcProvider();
|
|
305
|
-
const result = await wc.request(
|
|
306
|
-
{
|
|
307
|
-
method: "sui_signPersonalMessage",
|
|
308
|
-
params: { message: params.message, address: params.address }
|
|
309
|
-
},
|
|
310
|
-
"sui:mainnet"
|
|
311
|
-
);
|
|
312
|
-
return { signature: result.signature };
|
|
313
|
-
}
|
|
314
|
-
async sendTransaction(params) {
|
|
315
|
-
const wc = this.getWcProvider();
|
|
316
|
-
const result = await wc.request(
|
|
317
|
-
{
|
|
318
|
-
method: "sui_signAndExecuteTransaction",
|
|
319
|
-
params: { transaction: params.data, address: params.to }
|
|
320
|
-
},
|
|
321
|
-
"sui:mainnet"
|
|
322
|
-
);
|
|
323
|
-
return { hash: result.digest };
|
|
324
|
-
}
|
|
325
|
-
async estimateGas() {
|
|
326
|
-
return { gas: 0n };
|
|
327
|
-
}
|
|
328
|
-
async writeContract() {
|
|
329
|
-
return { hash: "" };
|
|
330
|
-
}
|
|
331
|
-
parseUnits() {
|
|
332
|
-
return 0n;
|
|
333
|
-
}
|
|
334
|
-
formatUnits() {
|
|
335
|
-
return "";
|
|
336
|
-
}
|
|
337
|
-
async getCapabilities() {
|
|
338
|
-
return {};
|
|
339
|
-
}
|
|
340
|
-
async grantPermissions() {
|
|
341
|
-
return {};
|
|
342
|
-
}
|
|
343
|
-
async revokePermissions() {
|
|
344
|
-
return "0x";
|
|
345
|
-
}
|
|
346
|
-
async walletGetAssets() {
|
|
347
|
-
return {};
|
|
348
|
-
}
|
|
349
|
-
}
|
|
350
|
-
exports.SuiAdapter = SuiAdapter;
|
|
2
|
+
"use strict";var y=Object.defineProperty;var v=(d,o,t)=>o in d?y(d,o,{enumerable:!0,configurable:!0,writable:!0,value:t}):d[o]=t;var l=(d,o,t)=>v(d,typeof o!="symbol"?o+"":o,t);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const h=require("@reown/appkit-controllers"),g="walletConnect",m=["sui:mainnet","sui:testnet","sui:devnet"];class w extends h.AdapterBlueprint{constructor(t){super({namespace:"sui",adapterType:"sui"});l(this,"sharedWcProvider");l(this,"explicitCaipChainsFromInit");l(this,"expectedSuiAddress");l(this,"suiNetworksFromConfig",[]);this.explicitCaipChainsFromInit=(t==null?void 0:t.explicitCaipChains)??[],this.expectedSuiAddress=t==null?void 0:t.expectedSuiAddress}construct(t){super.construct(t),this.suiNetworksFromConfig=t.networks??[]}pickChainsFromExplicit(t,e){if(t.length===0)return m;if(e!=null){const n=e.toString(),i=t.find(s=>s===`sui:${n}`||s.endsWith(`:${n}`));if(i)return[i]}return t}resolveSuiChainsForConnect(t){const e=this.getCaipNetworks("sui"),n=e.length>0?e:this.suiNetworksFromConfig;if(n.length===0)return this.pickChainsFromExplicit(this.explicitCaipChainsFromInit,t);const i=s=>s.caipNetworkId||`sui:${s.id}`;if(t!=null){const s=n.find(r=>{var c;return((c=r.id)==null?void 0:c.toString())===t.toString()});if(s)return[i(s)]}return n.map(i)}getCaipNetworksForWalletConnectConnector(){return this.suiNetworksFromConfig.length>0?this.suiNetworksFromConfig:(this.explicitCaipChainsFromInit.length>0?this.explicitCaipChainsFromInit:m).map(e=>{const n=e.startsWith("sui:")?e.slice(4):e;return{id:n,chainNamespace:"sui",caipNetworkId:e,name:"Sui",nativeCurrency:{name:"SUI",symbol:"SUI",decimals:9},rpcUrls:{default:{http:[`https://fullnode.${n}.sui.io:443`]}}}})}syncConnectors(){}async setUniversalProvider(t){this.sharedWcProvider=t;const e=new h.WalletConnectConnector({provider:t,namespace:"sui",caipNetworks:this.getCaipNetworksForWalletConnectConnector()});this.addConnector(e),h.WcHelpersUtil.listenWcProvider({universalProvider:t,namespace:"sui",onConnect:n=>this.onConnect(n,g),onDisconnect:()=>this.onDisconnect(g),onAccountsChanged:n=>this.onAccountsChanged(n,g,!1)})}getWcProvider(){if(!this.sharedWcProvider)throw new Error("SuiAdapter: UniversalProvider not ready — setUniversalProvider must run before connect");return this.sharedWcProvider}async connectWalletConnect(t){var r,c;const e=this.getWcProvider();if((c=(r=e.session)==null?void 0:r.namespaces)!=null&&c.sui)return{clientId:await e.client.core.crypto.getClientId()};const n=this.resolveSuiChainsForConnect(t),i=n.length>0?n:m;return await e.connect({optionalNamespaces:{sui:{methods:["sui_signPersonalMessage","sui_signTransaction","sui_signAndExecuteTransaction"],chains:i,events:[]}}}),{clientId:await e.client.core.crypto.getClientId()}}async connect(t){var C,f,p;const e=this.connectors.find(u=>u.id===t.id);if(!e)throw new Error("Sui connector not found");const n=this.getConnection({address:t.address,connectorId:e.id,connections:this.connections,connectors:this.connectors});if(n!=null&&n.account){const u=((C=n.caipNetwork)==null?void 0:C.id)??t.chainId??"mainnet";return this.emit("accountChanged",{address:n.account.address,chainId:u,connector:e}),{id:e.id,address:n.account.address,chainId:u,provider:e.provider,type:e.type}}const i=this.getWcProvider(),r=(f=h.WcHelpersUtil.getWalletConnectAccounts(i,"sui")[0])==null?void 0:f.address;if(!r)throw new Error("No Sui account found after WalletConnect session");if(this.expectedSuiAddress&&r!==this.expectedSuiAddress)throw new Error(`Sui account mismatch: expected ${this.expectedSuiAddress}, got ${r}`);const c=(p=this.getCaipNetworks())==null?void 0:p.find(u=>u.id===t.chainId);this.addConnection({connectorId:e.id,accounts:[{address:r}],caipNetwork:c});const a=t.chainId??(c==null?void 0:c.id)??"mainnet";return this.emit("accountChanged",{address:r,chainId:a,connector:e}),{id:e.id,address:r,chainId:a,provider:e.provider,type:e.type}}async disconnect(t){if(t!=null&&t.id){if(this.sharedWcProvider)try{await this.sharedWcProvider.disconnect()}catch{}this.deleteConnection(t.id)}return this.connections.length===0?this.emit("disconnect"):this.emitFirstAvailableConnection(),{connections:this.connections}}async getAccounts(t){return this.sharedWcProvider?{accounts:h.WcHelpersUtil.getWalletConnectAccounts(this.sharedWcProvider,"sui").map(n=>({namespace:"sui",address:n.address,type:"eoa"}))}:{accounts:[]}}async getBalance(t){var e,n,i;if(!t.address)return{balance:"0",symbol:"SUI"};try{const s=(e=this.getCaipNetworks())==null?void 0:e.find(p=>p.id===t.chainId),r=`https://fullnode.${s==null?void 0:s.id}.sui.io:443`;if(!r)return{balance:"0",symbol:"SUI"};const a=await(await fetch(r,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({jsonrpc:"2.0",id:1,method:"suix_getBalance",params:[t.address,"0x2::sui::SUI"]})})).json(),C=((n=a==null?void 0:a.result)==null?void 0:n.totalBalance)??"0";return{balance:(parseInt(C,10)/1e9).toString(),symbol:((i=s==null?void 0:s.nativeCurrency)==null?void 0:i.symbol)||"SUI"}}catch{return{balance:"0",symbol:"SUI"}}}async switchNetwork(t){await super.switchNetwork(t)}async syncConnection(t){return this.connect({...t,type:""})}async syncConnections({connectToFirstConnector:t,caipNetwork:e}){if(!this.sharedWcProvider)return;const n=h.WcHelpersUtil.getWalletConnectAccounts(this.sharedWcProvider,"sui");n.length>0&&this.addConnection({connectorId:g,accounts:n.map(i=>({address:i.address})),caipNetwork:e}),t&&this.emitFirstAvailableConnection()}getWalletConnectProvider(t){return t.provider}getChainScope(t){if(t!=null&&t.startsWith("sui:"))return t;const e=this.explicitCaipChainsFromInit.find(n=>n.startsWith("sui:"));return e||"sui:mainnet"}async signMessage(t){const e=this.getWcProvider(),n=this.getChainScope();return{signature:(await e.request({method:"sui_signPersonalMessage",params:{message:t.message,address:t.address}},n)).signature}}async sendTransaction(t){var s;const e=this.getWcProvider(),n=this.getChainScope((s=t.caipNetwork)==null?void 0:s.caipNetworkId);return{hash:(await e.request({method:"sui_signAndExecuteTransaction",params:{transaction:t.data,address:t.to}},n)).digest}}async estimateGas(){return{gas:0n}}async writeContract(){return{hash:""}}parseUnits(){return 0n}formatUnits(){return""}async getCapabilities(){return{}}async grantPermissions(){return{}}async revokePermissions(){return"0x"}async walletGetAssets(){return{}}}exports.SuiAdapter=w;
|