diff --git a/src/components/@shared/atoms/Blockies.tsx b/src/components/@shared/atoms/Blockies.tsx
index ecc9fd839..42acba907 100644
--- a/src/components/@shared/atoms/Blockies.tsx
+++ b/src/components/@shared/atoms/Blockies.tsx
@@ -12,8 +12,7 @@ export default function Blockies({
if (!accountId) return null
// TODO: just put this back once finished
- // const blockies = toDataUrl(accountId)
- const blockies = 'randomstring12345'
+ const blockies = toDataUrl(accountId)
return (
()
@@ -97,11 +69,7 @@ export default function Compute({
useState()
const [hasAlgoAssetDatatoken, setHasAlgoAssetDatatoken] = useState()
const [isPublished, setIsPublished] = useState(false)
- const [hasPreviousAlgorithmOrder, setHasPreviousAlgorithmOrder] =
- useState(false)
const [algorithmDTBalance, setAlgorithmDTBalance] = useState()
- const [algorithmConsumeDetails, setAlgorithmConsumeDetails] =
- useState()
const [isOwned, setIsOwned] = useState(false)
const [validOrderTx, setValidOrderTx] = useState('')
@@ -112,8 +80,6 @@ export default function Compute({
const [orderAlgorithmPriceAndFees, setOrderAlgorithmPriceAndFees] =
useState()
- const [datasetTimeout, setDatasetTimeout] = useState()
- const [algorithmTimeout, setAlgorithmTimeout] = useState()
const hasDatatoken = Number(dtBalance) >= 1
const isMounted = useIsMounted()
const newCancelToken = useCancelToken()
@@ -123,9 +89,7 @@ export default function Compute({
isJobStarting === true ||
file === null ||
(!validOrderTx && !hasDatatoken && !isConsumablePrice) ||
- (!hasPreviousAlgorithmOrder &&
- !hasAlgoAssetDatatoken &&
- !isAlgoConsumablePrice)
+ (!validAlgorithmOrderTx && !hasAlgoAssetDatatoken && !isAlgoConsumablePrice)
async function checkAssetDTBalance(asset: DDO) {
if (!asset?.services[0].datatokenAddress) return
@@ -149,13 +113,13 @@ export default function Compute({
if (asset?.accessDetails?.addressOrId === ZERO_ADDRESS) return
const computeEnv = await getComputeEnviroment(asset)
const validUntil = getValidUntilTime(
- computeEnv.maxJobDuration,
+ computeEnv?.maxJobDuration,
asset?.services[0]?.timeout
)
const orderPriceAndFees = await getOrderPriceAndFees(
asset,
ZERO_ADDRESS,
- computeEnv.id,
+ computeEnv?.id,
validUntil
)
setOrderPriceAndFees(orderPriceAndFees)
@@ -164,6 +128,10 @@ export default function Compute({
}, [asset?.accessDetails])
useEffect(() => {
+ console.log(
+ 'selectedAlgorithmAsset?.accessDetails == ',
+ selectedAlgorithmAsset?.accessDetails
+ )
if (!selectedAlgorithmAsset?.accessDetails || !accountId) return
checkAssetDTBalance(selectedAlgorithmAsset)
@@ -178,24 +146,22 @@ export default function Compute({
return
const computeEnv = await getComputeEnviroment(selectedAlgorithmAsset)
const validUntil = getValidUntilTime(
- computeEnv.maxJobDuration,
+ computeEnv?.maxJobDuration,
+ asset?.services[0]?.timeout,
selectedAlgorithmAsset?.services[0]?.timeout
)
const orderPriceAndFees = await getOrderPriceAndFees(
selectedAlgorithmAsset,
ZERO_ADDRESS,
- computeEnv.id,
+ computeEnv?.id,
validUntil
)
setOrderAlgorithmPriceAndFees(orderPriceAndFees)
+ console.log('orderPriceAndFees ', orderPriceAndFees)
}
init()
}, [selectedAlgorithmAsset])
- // useEffect(() => {
- // setDatasetTimeout(secondsToString(timeout))
- // }, [ddo])
-
useEffect(() => {
if (!asset) return
@@ -216,7 +182,7 @@ export default function Compute({
toast.error(newError)
}, [error])
- async function startJob(algorithmId: string): Promise {
+ async function startJob(): Promise {
try {
setIsJobStarting(true)
setIsPublished(false) // would be nice to rename this
@@ -245,12 +211,15 @@ export default function Compute({
const computeEnv = await getComputeEnviroment(asset)
const validUntil = getValidUntilTime(
- computeEnv.maxJobDuration,
+ computeEnv?.maxJobDuration,
asset.services[0].timeout,
selectedAlgorithmAsset.services[0].timeout
)
let datasetOrderTx
- if (!isOwned) {
+ if (isOwned) {
+ datasetOrderTx = validOrderTx
+ LoggerInstance.log('[compute] Dataset owned txId:', validOrderTx)
+ } else {
try {
if (!hasDatatoken && asset?.accessDetails.type === 'dynamic') {
const tx = await buyDtFromPool(
@@ -258,7 +227,6 @@ export default function Compute({
accountId,
web3
)
-
LoggerInstance.log('[compute] Buy dataset dt from pool: ', tx)
if (!tx) {
toast.error('Failed to buy datatoken from pool!')
@@ -271,9 +239,9 @@ export default function Compute({
asset,
orderPriceAndFees,
accountId,
- computeEnv.id,
+ computeEnv?.id,
validUntil,
- computeEnv.consumerAddress
+ computeEnv?.consumerAddress
)
if (!orderTx) {
toast.error('Failed to order dataset asset!')
@@ -288,14 +256,19 @@ export default function Compute({
datasetOrderTx = orderTx.transactionHash
} catch (e) {
LoggerInstance.log(e.message)
+ toast.error('Failed to order dataset asset!')
+ return
}
- } else {
- datasetOrderTx = validOrderTx
- LoggerInstance.log('[compute] Dataset owned txId:', validOrderTx)
}
let algorithmOrderTx
- if (!isAlgorithmOwned) {
+ if (isAlgorithmOwned) {
+ algorithmOrderTx = validAlgorithmOrderTx
+ LoggerInstance.log(
+ '[compute] Algorithm owned txId:',
+ validAlgorithmOrderTx
+ )
+ } else {
try {
if (
!hasAlgoAssetDatatoken &&
@@ -321,9 +294,9 @@ export default function Compute({
selectedAlgorithmAsset,
orderAlgorithmPriceAndFees,
accountId,
- computeEnv.id,
+ computeEnv?.id,
validUntil,
- computeEnv.consumerAddress
+ computeEnv?.consumerAddress
)
if (!orderTx) {
toast.error('Failed to order algorithm asset!')
@@ -338,13 +311,9 @@ export default function Compute({
algorithmOrderTx = orderTx.transactionHash
} catch (e) {
LoggerInstance.log(e.message)
+ toast.error('Failed to order algorithm asset!')
+ return
}
- } else {
- algorithmOrderTx = validAlgorithmOrderTx
- LoggerInstance.log(
- '[compute] Algorithm owned txId:',
- validAlgorithmOrderTx
- )
}
LoggerInstance.log('[compute] Starting compute job.')
@@ -362,19 +331,18 @@ export default function Compute({
asset.services[0].serviceEndpoint,
web3,
accountId,
- computeEnv.id,
+ computeEnv?.id,
computeAsset,
computeAlgorithm,
newAbortController(),
null,
- null
+ output
)
if (!response) {
setError('Error starting compute job.')
return
}
LoggerInstance.log('[compute] Starting compute job response: ', response)
-
setIsPublished(true)
} catch (error) {
setError('Failed to start job!')
@@ -408,7 +376,8 @@ export default function Compute({
validateOnMount
validationSchema={validationSchema}
onSubmit={async (values) => {
- await startJob(values.algorithm)
+ if (!values.algorithm) return
+ await startJob()
}}
>