- {loading || stake?.toDecimal === undefined ? (
+ {loading || !stake ? (
) : (
-
- {balance?.bzz ? (
+
+ {walletBalance?.bzzBalance ? (
) : null}
diff --git a/src/pages/account/wallet/AccountWallet.tsx b/src/pages/account/wallet/AccountWallet.tsx
index 62af0fc7..d504741c 100644
--- a/src/pages/account/wallet/AccountWallet.tsx
+++ b/src/pages/account/wallet/AccountWallet.tsx
@@ -1,5 +1,5 @@
-import { BeeModes, Utils } from '@ethersphere/bee-js'
import { Box, Grid, Typography } from '@material-ui/core'
+import { BeeModes } from '@upcoming/bee-js'
import { ReactElement, useContext } from 'react'
import { useNavigate } from 'react-router'
import Download from 'remixicon-react/DownloadLineIcon'
@@ -13,15 +13,13 @@ import { SwarmButton } from '../../../components/SwarmButton'
import TroubleshootConnectionCard from '../../../components/TroubleshootConnectionCard'
import { Context as BeeContext, CheckState } from '../../../providers/Bee'
import { Context as SettingsContext } from '../../../providers/Settings'
-import { Context as BalanceProvider } from '../../../providers/WalletBalance'
import { ROUTES } from '../../../routes'
import { AccountNavigation } from '../AccountNavigation'
import { Header } from '../Header'
export function AccountWallet(): ReactElement {
- const { nodeAddresses, nodeInfo, status } = useContext(BeeContext)
+ const { nodeAddresses, nodeInfo, status, walletBalance } = useContext(BeeContext)
const { isDesktop } = useContext(SettingsContext)
- const { balance } = useContext(BalanceProvider)
const navigate = useNavigate()
@@ -53,20 +51,22 @@ export function AccountWallet(): ReactElement {
)}
- {balance && nodeAddresses ? (
+ {walletBalance && nodeAddresses ? (
<>
-
+
-
+
-
+
>
) : (
diff --git a/src/pages/accounting/PeerBalances.tsx b/src/pages/accounting/PeerBalances.tsx
index 130d011b..f281fba2 100644
--- a/src/pages/accounting/PeerBalances.tsx
+++ b/src/pages/accounting/PeerBalances.tsx
@@ -1,3 +1,4 @@
+import { BZZ } from '@upcoming/bee-js'
import type { ReactElement } from 'react'
import CashoutModal from '../../components/CashoutModal'
import ExpandableList from '../../components/ExpandableList'
@@ -5,44 +6,43 @@ import ExpandableListItem from '../../components/ExpandableListItem'
import ExpandableListItemActions from '../../components/ExpandableListItemActions'
import ExpandableListItemKey from '../../components/ExpandableListItemKey'
import { Accounting } from '../../hooks/accounting'
-import type { Token } from '../../models/Token'
interface Props {
isLoadingUncashed: boolean
- totalUncashed: Token
+ totalUncashed: BZZ
accounting: Accounting[] | null
}
export default function PeerBalances({ accounting, isLoadingUncashed, totalUncashed }: Props): ReactElement | null {
- const uncashedPeers = accounting?.filter(({ uncashedAmount }) => uncashedAmount.toBigNumber.isGreaterThan('0')) || []
+ const uncashedPeers = accounting?.filter(({ uncashedAmount }) => uncashedAmount.gt(BZZ.fromPLUR('0'))) || []
return (
-
+
{uncashedPeers.map(({ peer, balance, received, sent, uncashedAmount, total }) => (
-
+
-
+
- {uncashedAmount.toBigNumber.isGreaterThan('0') && (
+ {uncashedAmount.gt(BZZ.fromPLUR('0')) && (
-
+
)}
diff --git a/src/pages/fdp/index.tsx b/src/pages/fdp/index.tsx
index c388ddc2..15ae2b4d 100644
--- a/src/pages/fdp/index.tsx
+++ b/src/pages/fdp/index.tsx
@@ -1,14 +1,13 @@
-import { Bee } from '@ethersphere/bee-js'
import { FdpStorage } from '@fairdatasociety/fdp-storage'
import { Pod } from '@fairdatasociety/fdp-storage/dist/pod/types'
import { CircularProgress, Typography } from '@material-ui/core'
+import { Bee, MantarayNode } from '@upcoming/bee-js'
import { useSnackbar } from 'notistack'
import { ReactElement, useEffect, useState } from 'react'
import ImportIcon from 'remixicon-react/AddBoxLineIcon'
import PlusCircle from 'remixicon-react/AddCircleLineIcon'
import { SwarmButton } from '../../components/SwarmButton'
import { joinUrl } from '../../react-fs/Utility'
-import { ManifestJs } from '../../utils/manifest'
import { FdpLogin } from './FdpLogin'
import { FdpPods } from './FdpPods'
import { Horizontal } from './Horizontal'
@@ -25,7 +24,9 @@ async function makeFdp(): Promise {
return null
}
- return new FdpStorage('http://localhost:1633', highestCapacityBatch.batchID, {
+ // TODO: FDS has bad types
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
+ return new FdpStorage('http://localhost:1633', highestCapacityBatch.batchID.toHex() as any, {
ensOptions: {
rpcUrl: sepolia,
contractAddresses: {
@@ -120,11 +121,16 @@ export default function FDP(): ReactElement {
}
setCreatingPod(true)
const bee = new Bee('http://localhost:1633')
- const manifestJs = new ManifestJs(bee)
- const entries = await manifestJs.getHashes(importHash)
+ const manifest = await MantarayNode.unmarshal(bee, importHash)
+ await manifest.loadRecursively(bee)
+ const nodes = manifest.collect()
await fdp.personalStorage.create(name)
- for (const [path, hash] of Object.entries(entries)) {
- await fdp.file.uploadData(name, joinUrl('/', path), await bee.downloadData(hash))
+ for (const node of nodes) {
+ await fdp.file.uploadData(
+ name,
+ joinUrl('/', node.fullPathString),
+ (await bee.downloadData(node.targetAddress)).toUint8Array(),
+ )
}
const pods = await fdp.personalStorage.list()
setPods(pods.pods)
diff --git a/src/pages/feeds/CreateNewFeed.tsx b/src/pages/feeds/CreateNewFeed.tsx
index fb81db2c..3196fff4 100644
--- a/src/pages/feeds/CreateNewFeed.tsx
+++ b/src/pages/feeds/CreateNewFeed.tsx
@@ -1,4 +1,5 @@
import { Box, Grid, Typography } from '@material-ui/core'
+import { NULL_TOPIC } from '@upcoming/bee-js'
import { Form, Formik } from 'formik'
import { useSnackbar } from 'notistack'
import { ReactElement, useContext, useState } from 'react'
@@ -108,7 +109,7 @@ export default function CreateNewFeed(): ReactElement {
{values.type === 'V3' && }
-
+
diff --git a/src/pages/feeds/UpdateFeed.tsx b/src/pages/feeds/UpdateFeed.tsx
index bf108e53..bfc33306 100644
--- a/src/pages/feeds/UpdateFeed.tsx
+++ b/src/pages/feeds/UpdateFeed.tsx
@@ -122,7 +122,7 @@ export default function UpdateFeed(): ReactElement {
{stamps ? (
({ value: x.batchID, label: x.batchID.slice(0, 8) }))}
+ options={stamps.map(x => ({ value: x.batchID.toHex(), label: x.batchID.toHex().slice(0, 8) }))}
onChange={onStampChange}
label="Stamp"
/>
diff --git a/src/pages/feeds/index.tsx b/src/pages/feeds/index.tsx
index a8dada40..389a08f9 100644
--- a/src/pages/feeds/index.tsx
+++ b/src/pages/feeds/index.tsx
@@ -1,18 +1,19 @@
import { Box, Typography } from '@material-ui/core'
+import { NULL_TOPIC } from '@upcoming/bee-js'
import { ReactElement, useContext, useState } from 'react'
-import Download from 'remixicon-react/DownloadLineIcon'
+import { useNavigate } from 'react-router'
import PlusSquare from 'remixicon-react/AddBoxLineIcon'
-import Info from 'remixicon-react/InformationLineIcon'
import Trash from 'remixicon-react/DeleteBin7LineIcon'
-import { useNavigate } from 'react-router'
+import Download from 'remixicon-react/DownloadLineIcon'
+import Info from 'remixicon-react/InformationLineIcon'
import ExpandableList from '../../components/ExpandableList'
import ExpandableListItem from '../../components/ExpandableListItem'
import ExpandableListItemActions from '../../components/ExpandableListItemActions'
import ExpandableListItemKey from '../../components/ExpandableListItemKey'
import { SwarmButton } from '../../components/SwarmButton'
import TroubleshootConnectionCard from '../../components/TroubleshootConnectionCard'
-import { CheckState, Context as BeeContext } from '../../providers/Bee'
-import { Context as IdentityContext, Identity } from '../../providers/Feeds'
+import { Context as BeeContext, CheckState } from '../../providers/Bee'
+import { Identity, Context as IdentityContext } from '../../providers/Feeds'
import { ROUTES } from '../../routes'
import { formatEnum } from '../../utils'
import { persistIdentitiesWithoutUpdate } from '../../utils/identity'
@@ -97,7 +98,7 @@ export default function Feeds(): ReactElement {
-
+
{x.feedHash && }
diff --git a/src/pages/files/AssetSummary.tsx b/src/pages/files/AssetSummary.tsx
index 54249905..9a980c4a 100644
--- a/src/pages/files/AssetSummary.tsx
+++ b/src/pages/files/AssetSummary.tsx
@@ -1,5 +1,5 @@
-import { Utils } from '@ethersphere/bee-js'
import { Box } from '@material-ui/core'
+import { Reference } from '@upcoming/bee-js'
import { ReactElement } from 'react'
import { DocumentationText } from '../../components/DocumentationText'
import ExpandableListItemKey from '../../components/ExpandableListItemKey'
@@ -11,7 +11,7 @@ interface Props {
}
export function AssetSummary({ isWebsite, reference }: Props): ReactElement {
- const isHash = Utils.isHexString(reference) && reference.length === 64
+ const isHash = Reference.isValid(reference)
return (
<>
diff --git a/src/pages/files/AssetSyncing.tsx b/src/pages/files/AssetSyncing.tsx
index b3265ef5..c6b28262 100644
--- a/src/pages/files/AssetSyncing.tsx
+++ b/src/pages/files/AssetSyncing.tsx
@@ -1,9 +1,9 @@
-import { Context as SettingsContext } from '../../providers/Settings'
import { Box } from '@material-ui/core'
+import { Tag } from '@upcoming/bee-js'
import { ReactElement, useContext, useEffect, useRef, useState } from 'react'
import { DocumentationText } from '../../components/DocumentationText'
import { LinearProgressWithLabel } from '../../components/ProgressBar'
-import { Tag } from '@ethersphere/bee-js'
+import { Context as SettingsContext } from '../../providers/Settings'
interface Props {
reference: string
diff --git a/src/pages/files/Download.tsx b/src/pages/files/Download.tsx
index a514230d..d5755aa5 100644
--- a/src/pages/files/Download.tsx
+++ b/src/pages/files/Download.tsx
@@ -1,4 +1,4 @@
-import { BeeModes, Utils } from '@ethersphere/bee-js'
+import { BeeModes, MantarayNode, Reference } from '@upcoming/bee-js'
import { useSnackbar } from 'notistack'
import { ReactElement, useContext, useState } from 'react'
import { useNavigate } from 'react-router-dom'
@@ -11,7 +11,6 @@ import { Context as SettingsContext } from '../../providers/Settings'
import { ROUTES } from '../../routes'
import { recognizeEnsOrSwarmHash, regexpEns } from '../../utils'
import { HISTORY_KEYS, determineHistoryName, putHistory } from '../../utils/local-storage'
-import { ManifestJs } from '../../utils/manifest'
import { FileNavigation } from './FileNavigation'
export function Download(): ReactElement {
@@ -26,41 +25,43 @@ export function Download(): ReactElement {
const navigate = useNavigate()
const validateChange = (value: string) => {
- if (
- Utils.isHexString(value, 64) ||
- Utils.isHexString(value, 128) ||
- !value.trim().length ||
- regexpEns.test(value)
- ) {
+ if (Reference.isValid(value) || regexpEns.test(value)) {
setReferenceError(undefined)
} else {
setReferenceError('Incorrect format of swarm hash. Expected 64 or 128 hexstring characters or ENS domain.')
}
}
+ // TODO: Test this for feeds, bzz, and bytes
async function onSwarmIdentifier(identifier: string) {
- setLoading(true)
-
if (!beeApi) {
setLoading(false)
return
}
+ setLoading(true)
+
try {
- const manifestJs = new ManifestJs(beeApi)
- const feedIdentifier = await manifestJs.resolveFeedManifest(identifier)
+ let manifest = await MantarayNode.unmarshal(beeApi, identifier)
+ await manifest.loadRecursively(beeApi)
- if (feedIdentifier) {
- identifier = feedIdentifier
- }
- const isManifest = await manifestJs.isManifest(identifier)
+ // If the manifest is a feed, resolve it and overwrite the manifest
+ await manifest.resolveFeed(beeApi).then(
+ async feed =>
+ await feed.ifPresentAsync(async feedUpdate => {
+ manifest = MantarayNode.unmarshalFromData(feedUpdate.payload.toUint8Array())
+ await manifest.loadRecursively(beeApi)
+ }),
+ )
- if (!isManifest) {
- throw Error('The specified hash does not contain valid content.')
- }
- const indexDocument = await manifestJs.getIndexDocumentPath(identifier)
- putHistory(HISTORY_KEYS.DOWNLOAD_HISTORY, identifier, determineHistoryName(identifier, indexDocument))
+ const rootMetadata = manifest.getDocsMetadata()
+
+ putHistory(
+ HISTORY_KEYS.DOWNLOAD_HISTORY,
+ identifier,
+ determineHistoryName(identifier, rootMetadata.indexDocument),
+ )
setUploadOrigin(defaultUploadOrigin)
navigate(ROUTES.HASH.replace(':hash', identifier))
} catch (error: unknown) {
diff --git a/src/pages/files/SelectStamp.tsx b/src/pages/files/SelectStamp.tsx
index 16296beb..06927476 100644
--- a/src/pages/files/SelectStamp.tsx
+++ b/src/pages/files/SelectStamp.tsx
@@ -27,7 +27,7 @@ export default function SimpleMenu({ stamps, selectedStamp, setSelected }: Props
diff --git a/src/pages/files/Share.tsx b/src/pages/files/Share.tsx
index f6b160ab..0c1b77e4 100644
--- a/src/pages/files/Share.tsx
+++ b/src/pages/files/Share.tsx
@@ -1,4 +1,5 @@
import { Box, Typography } from '@material-ui/core'
+import { MantarayNode } from '@upcoming/bee-js'
import { saveAs } from 'file-saver'
import JSZip from 'jszip'
import { useSnackbar } from 'notistack'
@@ -12,11 +13,10 @@ import { Context as BeeContext } from '../../providers/Bee'
import { Context as SettingsContext } from '../../providers/Settings'
import { ROUTES } from '../../routes'
import { determineHistoryName, HISTORY_KEYS, putHistory } from '../../utils/local-storage'
-import { ManifestJs } from '../../utils/manifest'
import { AssetPreview } from './AssetPreview'
import { AssetSummary } from './AssetSummary'
-import { DownloadActionBar } from './DownloadActionBar'
import { AssetSyncing } from './AssetSyncing'
+import { DownloadActionBar } from './DownloadActionBar'
export function Share(): ReactElement {
const { apiUrl, beeApi } = useContext(SettingsContext)
@@ -41,44 +41,57 @@ export function Share(): ReactElement {
return
}
- const manifestJs = new ManifestJs(beeApi)
- const isManifest = await manifestJs.isManifest(reference)
-
- if (!isManifest) {
+ try {
+ let manifest = await MantarayNode.unmarshal(beeApi, reference)
+ await manifest.loadRecursively(beeApi)
+
+ // If the manifest is a feed, resolve it and overwrite the manifest
+ await manifest.resolveFeed(beeApi).then(
+ async feed =>
+ await feed.ifPresentAsync(async feedUpdate => {
+ manifest = MantarayNode.unmarshalFromData(feedUpdate.payload.toUint8Array())
+ await manifest.loadRecursively(beeApi)
+ }),
+ )
+
+ const entries = manifest.collectAndMap()
+ delete entries[META_FILE_NAME]
+ setSwarmEntries(entries)
+
+ const docsMetadata = manifest.getDocsMetadata()
+
+ // needed in catch block, shadows the outer variable
+ const indexDocument = docsMetadata.indexDocument
+ setIndexDocument(indexDocument)
+
+ try {
+ const remoteMetadata = await beeApi.downloadFile(reference, META_FILE_NAME)
+ const formattedMetadata = remoteMetadata.data.toJSON() as Metadata
+
+ if (formattedMetadata.isVideo || formattedMetadata.isImage) {
+ setPreview(`${apiUrl}/bzz/${reference}`)
+ }
+ setMetadata({ ...formattedMetadata, hash })
+ } catch (e) {
+ // if metadata is not available or invalid go with the default one
+ const count = Object.keys(entries).length
+ setMetadata({
+ hash,
+ type: count > 1 ? 'folder' : 'unknown',
+ name: reference,
+ count,
+ isWebsite: Boolean(indexDocument && /.*\.html?$/i.test(indexDocument)),
+ isVideo: Boolean(indexDocument && /.*\.(mp4|webm|ogg|mp3|ogg|wav)$/i.test(indexDocument)),
+ isImage: Boolean(indexDocument && /.*\.(jpg|jpeg|png|gif|webp|svg)$/i.test(indexDocument)),
+ // naive assumption based on indexDocument, we don't want to download the whole manifest
+ })
+ }
+ } catch {
setNotFound(true)
enqueueSnackbar('The specified hash does not contain valid content.', { variant: 'error' })
return
}
-
- const entries = await manifestJs.getHashes(reference, { exclude: [META_FILE_NAME] })
- setSwarmEntries(entries)
-
- const indexDocument = await manifestJs.getIndexDocumentPath(reference)
- setIndexDocument(indexDocument)
-
- try {
- const remoteMetadata = await beeApi.downloadFile(reference, META_FILE_NAME)
- const formattedMetadata = JSON.parse(remoteMetadata.data.text()) as Metadata
-
- if (formattedMetadata.isVideo || formattedMetadata.isImage) {
- setPreview(`${apiUrl}/bzz/${reference}`)
- }
- setMetadata({ ...formattedMetadata, hash })
- } catch (e) {
- // if metadata is not available or invalid go with the default one
- const count = Object.keys(entries).length
- setMetadata({
- hash,
- type: count > 1 ? 'folder' : 'unknown',
- name: reference,
- count,
- isWebsite: Boolean(indexDocument && /.*\.html?$/i.test(indexDocument)),
- isVideo: Boolean(indexDocument && /.*\.(mp4|webm|ogg|mp3|ogg|wav)$/i.test(indexDocument)),
- isImage: Boolean(indexDocument && /.*\.(jpg|jpeg|png|gif|webp|svg)$/i.test(indexDocument)),
- // naive assumption based on indexDocument, we don't want to donwload the whole manifest
- })
- }
}
function onOpen() {
@@ -119,7 +132,7 @@ export function Share(): ReactElement {
} else {
const zip = new JSZip()
for (const [path, hash] of Object.entries(swarmEntries)) {
- zip.file(path, await beeApi.downloadData(hash))
+ zip.file(path, (await beeApi.downloadData(hash)).toUint8Array())
}
const content = await zip.generateAsync({ type: 'blob' })
saveAs(content, reference + '.zip')
diff --git a/src/pages/files/Upload.tsx b/src/pages/files/Upload.tsx
index f51fa5b9..12aef381 100644
--- a/src/pages/files/Upload.tsx
+++ b/src/pages/files/Upload.tsx
@@ -114,10 +114,10 @@ export function Upload(): ReactElement {
beeApi
.uploadFiles(stamp.batchID, fls, { indexDocument, deferred: true })
.then(hash => {
- putHistory(HISTORY_KEYS.UPLOAD_HISTORY, hash.reference, getAssetNameFromFiles(files))
+ putHistory(HISTORY_KEYS.UPLOAD_HISTORY, hash.reference.toHex(), getAssetNameFromFiles(files))
if (uploadOrigin.origin === 'UPLOAD') {
- navigate(ROUTES.HASH.replace(':hash', hash.reference), { replace: true })
+ navigate(ROUTES.HASH.replace(':hash', hash.reference.toHex()), { replace: true })
} else {
updateFeed(beeApi, identity as Identity, hash.reference, stamp.batchID, password as string).then(() => {
persistIdentity(identities, identity as Identity)
@@ -164,7 +164,7 @@ export function Upload(): ReactElement {
<>
{hasAnyStamps && stampMode === 'SELECT' ? (
- setStamp(stamp)} defaultValue={stamp?.batchID} />
+ setStamp(stamp)} defaultValue={stamp?.batchID.toHex()} />
) : (
setStampMode('SELECT')} />
)}
diff --git a/src/pages/gift-code/index.tsx b/src/pages/gift-code/index.tsx
index 1edd9319..77f624ea 100644
--- a/src/pages/gift-code/index.tsx
+++ b/src/pages/gift-code/index.tsx
@@ -1,4 +1,5 @@
import { Box, Tooltip, Typography } from '@material-ui/core'
+import { BZZ, DAI } from '@upcoming/bee-js'
import { Wallet } from 'ethers'
import { useSnackbar } from 'notistack'
import { ReactElement, useContext, useEffect, useState } from 'react'
@@ -11,20 +12,19 @@ import ExpandableListItemKey from '../../components/ExpandableListItemKey'
import { HistoryHeader } from '../../components/HistoryHeader'
import { Loading } from '../../components/Loading'
import { SwarmButton } from '../../components/SwarmButton'
-import { Token } from '../../models/Token'
+import { Context as BeeContext } from '../../providers/Bee'
import { Context as SettingsContext } from '../../providers/Settings'
import { Context as TopUpContext } from '../../providers/TopUp'
-import { Context as BalanceProvider } from '../../providers/WalletBalance'
import { createGiftWallet } from '../../utils/desktop'
import { ResolvedWallet } from '../../utils/wallet'
-const GIFT_WALLET_FUND_DAI_AMOUNT = Token.fromDecimal('0.1', 18)
-const GIFT_WALLET_FUND_BZZ_AMOUNT = Token.fromDecimal('0.5', 16)
+const GIFT_WALLET_FUND_DAI_AMOUNT = DAI.fromDecimalString('0.1')
+const GIFT_WALLET_FUND_BZZ_AMOUNT = BZZ.fromDecimalString('0.5')
export default function Index(): ReactElement {
const { giftWallets, addGiftWallet } = useContext(TopUpContext)
const { rpcProvider, desktopUrl } = useContext(SettingsContext)
- const { balance } = useContext(BalanceProvider)
+ const { walletBalance } = useContext(BeeContext)
const [loading, setLoading] = useState(false)
const [balances, setBalances] = useState([])
@@ -67,13 +67,13 @@ export default function Index(): ReactElement {
navigate(-1)
}
- if (!balance) {
+ if (!walletBalance) {
return
}
const notEnoughFundsCheck =
- balance.dai.toBigNumber.isLessThanOrEqualTo(GIFT_WALLET_FUND_DAI_AMOUNT.toBigNumber) ||
- balance.bzz.toBigNumber.isLessThan(GIFT_WALLET_FUND_BZZ_AMOUNT.toBigNumber)
+ walletBalance.nativeTokenBalance.lte(GIFT_WALLET_FUND_DAI_AMOUNT) ||
+ walletBalance.bzzBalance.lt(GIFT_WALLET_FUND_BZZ_AMOUNT)
return (
<>
@@ -86,10 +86,13 @@ export default function Index(): ReactElement {
-
+
-
+
{balances.map((x, i) => (
diff --git a/src/pages/info/ChequebookInfoCard.tsx b/src/pages/info/ChequebookInfoCard.tsx
index 40317677..fecdbd45 100644
--- a/src/pages/info/ChequebookInfoCard.tsx
+++ b/src/pages/info/ChequebookInfoCard.tsx
@@ -1,3 +1,4 @@
+import { BZZ } from '@upcoming/bee-js'
import { useContext } from 'react'
import { useNavigate } from 'react-router'
import ExchangeFunds from 'remixicon-react/ExchangeFundsLineIcon'
@@ -9,10 +10,7 @@ export function ChequebookInfoCard() {
const { chequebookBalance } = useContext(BeeContext)
const navigate = useNavigate()
- if (
- chequebookBalance?.availableBalance !== undefined &&
- chequebookBalance?.availableBalance.toBigNumber.isGreaterThan(0)
- ) {
+ if (chequebookBalance?.availableBalance !== undefined && chequebookBalance?.availableBalance.gt(BZZ.fromPLUR('0'))) {
return (
- {chainId !== null && }
+ {walletBalance !== null && (
+
+ )}
)
}
diff --git a/src/pages/restart/LightModeRestart.tsx b/src/pages/restart/LightModeRestart.tsx
index 594a1374..936e8313 100644
--- a/src/pages/restart/LightModeRestart.tsx
+++ b/src/pages/restart/LightModeRestart.tsx
@@ -1,5 +1,5 @@
-import { BeeModes } from '@ethersphere/bee-js'
import { Box, Grid, Typography } from '@material-ui/core'
+import { BeeModes } from '@upcoming/bee-js'
import { useSnackbar } from 'notistack'
import { ReactElement, useContext, useEffect } from 'react'
import { useNavigate } from 'react-router'
diff --git a/src/pages/stamps/PostageStamp.tsx b/src/pages/stamps/PostageStamp.tsx
index 4b2a36ab..5d4ad69b 100644
--- a/src/pages/stamps/PostageStamp.tsx
+++ b/src/pages/stamps/PostageStamp.tsx
@@ -9,7 +9,7 @@ interface Props {
}
export function PostageStamp({ stamp, shorten }: Props): ReactElement {
- const batchId = shorten ? stamp.batchID.slice(0, 8) : stamp.batchID
+ const batchId = shorten ? stamp.batchID.toHex().slice(0, 8) : stamp.batchID
const label = `${batchId}${stamp.label ? ` - ${stamp.label}` : ''}`
return (
diff --git a/src/pages/stamps/PostageStampAdvancedCreation.tsx b/src/pages/stamps/PostageStampAdvancedCreation.tsx
index cf1bf6c7..37f312a5 100644
--- a/src/pages/stamps/PostageStampAdvancedCreation.tsx
+++ b/src/pages/stamps/PostageStampAdvancedCreation.tsx
@@ -1,5 +1,5 @@
-import { PostageBatchOptions, Utils } from '@ethersphere/bee-js'
import { Box, Grid, IconButton, Typography, createStyles, makeStyles } from '@material-ui/core'
+import { PostageBatchOptions, Utils } from '@upcoming/bee-js'
import BigNumber from 'bignumber.js'
import { useSnackbar } from 'notistack'
import { ReactElement, useContext, useState } from 'react'
@@ -13,7 +13,7 @@ import { Context as BeeContext } from '../../providers/Bee'
import { Context as SettingsContext } from '../../providers/Settings'
import { Context as StampsContext } from '../../providers/Stamps'
import { ROUTES } from '../../routes'
-import { calculateStampPrice, convertAmountToSeconds, secondsToTimeString, waitUntilStampExists } from '../../utils'
+import { secondsToTimeString } from '../../utils'
import { getHumanReadableFileSize } from '../../utils/file'
interface Props {
@@ -61,18 +61,22 @@ export function PostageStampAdvancedCreation({ onFinished }: Props): ReactElemen
const { enqueueSnackbar } = useSnackbar()
- function getTtl(amount: number): string {
+ function getTtl(amount: bigint): string {
const isCurrentPriceAvailable = chainState && chainState.currentPrice
if (amount <= 0 || !isCurrentPriceAvailable) {
return '-'
}
- const pricePerBlock = Number.parseInt(chainState.currentPrice, 10)
+ const pricePerBlock = chainState.currentPrice
- return `${secondsToTimeString(
- convertAmountToSeconds(amount, pricePerBlock),
- )} (with price of ${pricePerBlock.toFixed(0)} PLUR per block)`
+ try {
+ return `${secondsToTimeString(
+ Utils.getStampDuration(amount, pricePerBlock).toSeconds(),
+ )} (with price of ${pricePerBlock} PLUR per block)`
+ } catch {
+ return `0 seconds (with price of ${pricePerBlock} PLUR per block)`
+ }
}
function getPrice(depth: number, amount: bigint): string {
@@ -82,9 +86,9 @@ export function PostageStampAdvancedCreation({ onFinished }: Props): ReactElemen
return '-'
}
- const price = calculateStampPrice(depth, amount)
+ const price = Utils.getStampCost(depth, amount)
- return `${price.toSignificantDigits()} xBZZ`
+ return `${price.toSignificantDigits(4)} xBZZ`
}
async function submit() {
@@ -107,8 +111,7 @@ export function PostageStampAdvancedCreation({ onFinished }: Props): ReactElemen
immutableFlag: immutable,
}
- const batchId = await beeApi.createPostageBatch(amount.toString(), depth, options)
- await waitUntilStampExists(batchId, beeApi)
+ await beeApi.createPostageBatch(amount.toString(), depth, options)
await refresh()
onFinished()
} catch (e) {
@@ -173,7 +176,7 @@ export function PostageStampAdvancedCreation({ onFinished }: Props): ReactElemen
return '-'
}
- const theoreticalMaximumVolume = getHumanReadableFileSize(Utils.getStampMaximumCapacityBytes(depth))
+ const theoreticalMaximumVolume = getHumanReadableFileSize(Utils.getStampTheoreticalBytes(depth))
const effectiveVolume = getHumanReadableFileSize(Utils.getStampEffectiveBytes(depth))
return (
@@ -227,7 +230,7 @@ export function PostageStampAdvancedCreation({ onFinished }: Props): ReactElemen