mirror of
https://github.com/oceanprotocol/market.git
synced 2024-12-02 05:57:29 +01:00
order fixes
This commit is contained in:
parent
936985a0f8
commit
be21be9559
2
package-lock.json
generated
2
package-lock.json
generated
@ -41998,7 +41998,6 @@
|
||||
"cross-fetch": "^3.1.5",
|
||||
"crypto-js": "^4.1.1",
|
||||
"decimal.js": "^10.3.1",
|
||||
"web3": "^1.7.3",
|
||||
"web3-core": "^1.7.1",
|
||||
"web3-eth-contract": "^1.7.1"
|
||||
}
|
||||
@ -42050,7 +42049,6 @@
|
||||
"integrity": "sha512-rmVKYEsKzurfRU0xJz+iHelbi1LGlihIWZ7Qvmb/CBz1EkhL7nOkW4SVXmG2dA5Ce0si2gr88i6q4eBOMRNJ1w==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"@oclif/config": "^1.18.2",
|
||||
"@oclif/errors": "^1.3.5",
|
||||
"@oclif/help": "^1.0.1",
|
||||
"@oclif/parser": "^3.8.6",
|
||||
|
@ -135,6 +135,8 @@ export async function reuseOrder(
|
||||
validOrderTx: string,
|
||||
providerFees?: ProviderFees
|
||||
): Promise<TransactionReceipt> {
|
||||
LoggerInstance.log('[compute] reuseOrder', providerFees)
|
||||
|
||||
const datatoken = new Datatoken(web3)
|
||||
const initializeData =
|
||||
!providerFees &&
|
||||
@ -145,19 +147,26 @@ export async function reuseOrder(
|
||||
accountId,
|
||||
asset.services[0].serviceEndpoint
|
||||
))
|
||||
LoggerInstance.log('[compute] initializeData', initializeData)
|
||||
|
||||
const txApprove = await approve(
|
||||
web3,
|
||||
accountId,
|
||||
providerFees.providerFeeToken ||
|
||||
initializeData.providerFee.providerFeeToken,
|
||||
asset.accessDetails.datatoken.address,
|
||||
providerFees.providerFeeAmount ||
|
||||
initializeData.providerFee.providerFeeAmount,
|
||||
false
|
||||
)
|
||||
if (!txApprove) {
|
||||
return
|
||||
if (
|
||||
providerFees?.providerFeeAmount ||
|
||||
initializeData.providerFee.providerFeeToken
|
||||
) {
|
||||
const txApprove = await approve(
|
||||
web3,
|
||||
accountId,
|
||||
providerFees.providerFeeToken ||
|
||||
initializeData.providerFee.providerFeeToken,
|
||||
asset.accessDetails.datatoken.address,
|
||||
providerFees.providerFeeAmount,
|
||||
false
|
||||
)
|
||||
|
||||
LoggerInstance.log('[compute] txApprove', txApprove)
|
||||
if (!txApprove) {
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
const tx = await datatoken.reuseOrder(
|
||||
@ -192,9 +201,16 @@ export async function handleComputeOrder(
|
||||
initializeData: ProviderComputeInitialize,
|
||||
computeConsumerAddress?: string
|
||||
): Promise<string> {
|
||||
LoggerInstance.log('[compute] handleComputeOrder asset: ', asset)
|
||||
LoggerInstance.log(
|
||||
'[compute] handleComputeOrder orderPriceAndFees: ',
|
||||
orderPriceAndFees
|
||||
)
|
||||
if (initializeData.validOrder && !initializeData.providerFee) {
|
||||
LoggerInstance.log('[compute] Has valid order: ', initializeData.validOrder)
|
||||
return initializeData.validOrder
|
||||
} else if (initializeData.validOrder) {
|
||||
LoggerInstance.log('[compute] Call reuse order', initializeData)
|
||||
const tx = await reuseOrder(
|
||||
web3,
|
||||
asset,
|
||||
@ -204,6 +220,7 @@ export async function handleComputeOrder(
|
||||
)
|
||||
return tx.transactionHash
|
||||
} else {
|
||||
LoggerInstance.log('[compute] Call order', initializeData)
|
||||
if (!hasDatatoken && asset?.accessDetails.type === 'dynamic') {
|
||||
const poolTx = await buyDtFromPool(asset?.accessDetails, accountId, web3)
|
||||
LoggerInstance.log('[compute] Buy dt from pool: ', poolTx)
|
||||
|
@ -8,7 +8,6 @@ import {
|
||||
ProviderComputeInitializeResults,
|
||||
ProviderInstance
|
||||
} from '@oceanprotocol/lib'
|
||||
import { da } from 'date-fns/locale'
|
||||
import { AssetExtended } from 'src/@types/AssetExtended'
|
||||
import Web3 from 'web3'
|
||||
import { getValidUntilTime } from './compute'
|
||||
@ -21,13 +20,13 @@ export async function initializeProviderForCompute(
|
||||
): Promise<ProviderComputeInitializeResults> {
|
||||
const computeAsset: ComputeAsset = {
|
||||
documentId: dataset.id,
|
||||
serviceId: dataset.services[0].id,
|
||||
transferTxId: dataset.accessDetails.validOrderTx
|
||||
serviceId: dataset.services[0].id
|
||||
// transferTxId: dataset.accessDetails.validOrderTx
|
||||
}
|
||||
const computeAlgo: ComputeAlgorithm = {
|
||||
documentId: algorithm.id,
|
||||
serviceId: algorithm.services[0].id,
|
||||
transferTxId: algorithm.accessDetails.validOrderTx
|
||||
serviceId: algorithm.services[0].id
|
||||
// transferTxId: algorithm.accessDetails.validOrderTx
|
||||
}
|
||||
|
||||
const validUntil = getValidUntilTime(
|
||||
|
@ -133,6 +133,7 @@ export default function Compute({
|
||||
accountId,
|
||||
computeEnv
|
||||
)
|
||||
console.log('initializedProvider == ', initializedProvider)
|
||||
setInitializedProviderResponse(initializedProvider)
|
||||
// setIsProviderFeeValid(
|
||||
// await checkComputeResourcesValidity(
|
||||
@ -158,7 +159,9 @@ export default function Compute({
|
||||
// setComputeValidUntil(validUntil)
|
||||
if (
|
||||
asset?.accessDetails?.addressOrId !== ZERO_ADDRESS ||
|
||||
asset?.accessDetails?.type !== 'free'
|
||||
asset?.accessDetails?.type !== 'free' ||
|
||||
(!initializedProvider.datasets[0].validOrder &&
|
||||
initializedProvider.datasets[0].providerFee)
|
||||
) {
|
||||
setIsRequestingDataseOrderPrice(true)
|
||||
setComputeStatusText(
|
||||
@ -190,6 +193,7 @@ export default function Compute({
|
||||
poolParams,
|
||||
initializedProvider.datasets[0].providerFee
|
||||
)
|
||||
console.log('datasetPriceAndFees', datasetPriceAndFees)
|
||||
if (!datasetPriceAndFees) {
|
||||
setError('Error setting dataset price and fees!')
|
||||
toast.error('Error setting dataset price and fees!')
|
||||
@ -201,7 +205,9 @@ export default function Compute({
|
||||
|
||||
if (
|
||||
selectedAlgorithmAsset?.accessDetails?.addressOrId !== ZERO_ADDRESS ||
|
||||
selectedAlgorithmAsset?.accessDetails?.type !== 'free'
|
||||
selectedAlgorithmAsset?.accessDetails?.type !== 'free' ||
|
||||
(!initializedProvider.algorithm.validOrder &&
|
||||
initializedProvider.algorithm.providerFee)
|
||||
) {
|
||||
setIsRequestingAlgoOrderPrice(true)
|
||||
setComputeStatusText(
|
||||
@ -239,6 +245,7 @@ export default function Compute({
|
||||
algoPoolParams,
|
||||
initializedProvider.algorithm.providerFee
|
||||
)
|
||||
console.log('algorithmOrderPriceAndFees', algorithmOrderPriceAndFees)
|
||||
if (!algorithmOrderPriceAndFees) {
|
||||
setError('Error setting algorithm price and fees!')
|
||||
toast.error('Error setting algorithm price and fees!')
|
||||
@ -331,6 +338,7 @@ export default function Compute({
|
||||
initializedProviderResponse.datasets[0],
|
||||
computeEnv.consumerAddress
|
||||
)
|
||||
console.log('datasetOrderTx', datasetOrderTx)
|
||||
// if (isOwned) {
|
||||
// datasetOrderTx = validOrderTx
|
||||
// LoggerInstance.log('[compute] Dataset owned txId:', validOrderTx)
|
||||
@ -392,13 +400,13 @@ export default function Compute({
|
||||
const algorithmOrderTx = await handleComputeOrder(
|
||||
web3,
|
||||
selectedAlgorithmAsset,
|
||||
datasetOrderPriceAndFees,
|
||||
algoOrderPriceAndFees,
|
||||
accountId,
|
||||
hasDatatoken,
|
||||
hasAlgoAssetDatatoken,
|
||||
initializedProviderResponse.algorithm,
|
||||
computeEnv.consumerAddress
|
||||
)
|
||||
|
||||
console.log('algorithmOrderTx', algorithmOrderTx)
|
||||
// if (isAlgorithmOwned) {
|
||||
// algorithmOrderTx = validAlgorithmOrderTx
|
||||
// LoggerInstance.log(
|
||||
|
Loading…
Reference in New Issue
Block a user