1
0
mirror of https://github.com/oceanprotocol/ocean.js.git synced 2024-11-26 20:39:05 +01:00

fix compute stop & uptade order helper to be reused also for c2d oreder methods (#1761)

This commit is contained in:
Bogdan Fazakas 2023-09-04 09:35:09 +03:00 committed by GitHub
parent 01822d81c5
commit cf0c1221a9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 23 additions and 10 deletions

View File

@ -643,6 +643,7 @@ export class Provider {
payload.signature = signature
payload.documentId = this.noZeroX(did)
payload.consumerAddress = consumerAddress
payload.nonce = nonce
if (jobId) payload.jobId = jobId
if (!computeStopUrl) return null

View File

@ -9,7 +9,8 @@ import {
FreOrderParams,
approve,
FixedRateExchange,
ConsumeMarketFee
ConsumeMarketFee,
ProviderFees
} from '../index'
import Decimal from 'decimal.js'
@ -19,7 +20,10 @@ import Decimal from 'decimal.js'
* @param {Signer} consumerAccount - The signer account of the consumer.
* @param {Config} config - The configuration settings.
* @param {Datatoken} datatoken - The Datatoken instance.
* @param {string} [providerUrl] - Optional the consumer address
* @param {string} [consumerAccount] - Optional the consumer address
* @param {ConsumeMarketFee} [consumeMarketOrderFee] - Optional consume market fee.
* @param {ProviderFees} [providerFees] - Optional provider fees
* @param {string} [consumeMarketFixedSwapFee='0'] - Fixed swap fee for consuming the market.
* @param {number} [datatokenIndex=0] - Index of the datatoken within the asset.
* @param {number} [serviceIndex=0] - Index of the service within the asset.
@ -32,7 +36,10 @@ export async function orderAsset(
consumerAccount: Signer,
config: Config,
datatoken: Datatoken,
providerUrl?: string,
consumerAddress?: string,
consumeMarketOrderFee?: ConsumeMarketFee,
providerFees?: ProviderFees,
consumeMarketFixedSwapFee: string = '0',
datatokenIndex: number = 0,
serviceIndex: number = 0,
@ -68,18 +75,23 @@ export async function orderAsset(
)
const pricingType =
fixedRates.length > 0 ? 'fixed' : dispensers.length > 0 ? 'free' : 'NOT_ALLOWED'
const initializeData = await ProviderInstance.initialize(
asset.id,
asset.services[serviceIndex].id,
0,
await consumerAccount.getAddress(),
config.providerUri
)
const fees =
providerFees ||
(
await ProviderInstance.initialize(
asset.id,
asset.services[serviceIndex].id,
0,
await consumerAccount.getAddress(),
providerUrl || config.providerUri
)
).providerFee
const orderParams = {
consumer: await consumerAccount.getAddress(),
consumer: consumerAddress || (await consumerAccount.getAddress()),
serviceIndex,
_providerFee: initializeData.providerFee,
_providerFee: fees,
_consumeMarketFee: consumeMarketOrderFee
} as OrderParams