1
0
mirror of https://github.com/oceanprotocol/market.git synced 2024-12-02 05:57:29 +01:00

minor fixes (#1639)

* minor fixes

* error fix

* add loading

* add price loading

* remove console.log

Co-authored-by: Matthias Kretschmann <m@kretschmann.io>
This commit is contained in:
mihaisc 2022-08-09 05:45:28 -07:00 committed by GitHub
parent 52ad877b13
commit dc4add5c70
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 22 additions and 8 deletions

View File

@ -57,7 +57,9 @@ export async function order(
_consumeMarketFee: {
consumeMarketFeeAddress: marketFeeAddress,
consumeMarketFeeAmount: consumeMarketOrderFee,
consumeMarketFeeToken: asset.accessDetails.baseToken.address
consumeMarketFeeToken:
asset?.accessDetails?.baseToken?.address ||
'0x0000000000000000000000000000000000000000'
}
} as OrderParams

View File

@ -16,6 +16,7 @@ import { toast } from 'react-toastify'
import { useIsMounted } from '@hooks/useIsMounted'
import { useMarketMetadata } from '@context/MarketMetadata'
import Alert from '@shared/atoms/Alert'
import Loader from '@shared/atoms/Loader'
export default function Download({
asset,
@ -41,6 +42,7 @@ export default function Download({
const [hasDatatoken, setHasDatatoken] = useState(false)
const [statusText, setStatusText] = useState('')
const [isLoading, setIsLoading] = useState(false)
const [isPriceLoading, setIsPriceLoading] = useState(false)
const [isOwned, setIsOwned] = useState(false)
const [validOrderTx, setValidOrderTx] = useState('')
const [orderPriceAndFees, setOrderPriceAndFees] =
@ -64,8 +66,11 @@ export default function Download({
)
return
!orderPriceAndFees && setIsPriceLoading(true)
const _orderPriceAndFees = await getOrderPriceAndFees(asset, ZERO_ADDRESS)
setOrderPriceAndFees(_orderPriceAndFees)
!orderPriceAndFees && setIsPriceLoading(false)
}
init()
@ -84,6 +89,7 @@ export default function Download({
useEffect(() => {
if (
(asset?.accessDetails?.type === 'fixed' && !orderPriceAndFees) ||
!isMounted ||
!accountId ||
!asset?.accessDetails ||
@ -112,7 +118,8 @@ export default function Download({
hasDatatoken,
accountId,
isOwned,
isUnsupportedPricing
isUnsupportedPricing,
orderPriceAndFees
])
async function handleOrderOrDownload() {
@ -184,12 +191,17 @@ export default function Download({
/>
) : (
<>
<Price
accessDetails={asset.accessDetails}
orderPriceAndFees={orderPriceAndFees}
conversion
size="large"
/>
{isPriceLoading ? (
<Loader message="Calculating full price (including fees)" />
) : (
<Price
accessDetails={asset.accessDetails}
orderPriceAndFees={orderPriceAndFees}
conversion
size="large"
/>
)}
{!isInPurgatory && <PurchaseButton />}
</>
)}