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:
parent
01822d81c5
commit
cf0c1221a9
@ -643,6 +643,7 @@ export class Provider {
|
|||||||
payload.signature = signature
|
payload.signature = signature
|
||||||
payload.documentId = this.noZeroX(did)
|
payload.documentId = this.noZeroX(did)
|
||||||
payload.consumerAddress = consumerAddress
|
payload.consumerAddress = consumerAddress
|
||||||
|
payload.nonce = nonce
|
||||||
if (jobId) payload.jobId = jobId
|
if (jobId) payload.jobId = jobId
|
||||||
|
|
||||||
if (!computeStopUrl) return null
|
if (!computeStopUrl) return null
|
||||||
|
@ -9,7 +9,8 @@ import {
|
|||||||
FreOrderParams,
|
FreOrderParams,
|
||||||
approve,
|
approve,
|
||||||
FixedRateExchange,
|
FixedRateExchange,
|
||||||
ConsumeMarketFee
|
ConsumeMarketFee,
|
||||||
|
ProviderFees
|
||||||
} from '../index'
|
} from '../index'
|
||||||
import Decimal from 'decimal.js'
|
import Decimal from 'decimal.js'
|
||||||
|
|
||||||
@ -19,7 +20,10 @@ import Decimal from 'decimal.js'
|
|||||||
* @param {Signer} consumerAccount - The signer account of the consumer.
|
* @param {Signer} consumerAccount - The signer account of the consumer.
|
||||||
* @param {Config} config - The configuration settings.
|
* @param {Config} config - The configuration settings.
|
||||||
* @param {Datatoken} datatoken - The Datatoken instance.
|
* @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 {ConsumeMarketFee} [consumeMarketOrderFee] - Optional consume market fee.
|
||||||
|
* @param {ProviderFees} [providerFees] - Optional provider fees
|
||||||
* @param {string} [consumeMarketFixedSwapFee='0'] - Fixed swap fee for consuming the market.
|
* @param {string} [consumeMarketFixedSwapFee='0'] - Fixed swap fee for consuming the market.
|
||||||
* @param {number} [datatokenIndex=0] - Index of the datatoken within the asset.
|
* @param {number} [datatokenIndex=0] - Index of the datatoken within the asset.
|
||||||
* @param {number} [serviceIndex=0] - Index of the service within the asset.
|
* @param {number} [serviceIndex=0] - Index of the service within the asset.
|
||||||
@ -32,7 +36,10 @@ export async function orderAsset(
|
|||||||
consumerAccount: Signer,
|
consumerAccount: Signer,
|
||||||
config: Config,
|
config: Config,
|
||||||
datatoken: Datatoken,
|
datatoken: Datatoken,
|
||||||
|
providerUrl?: string,
|
||||||
|
consumerAddress?: string,
|
||||||
consumeMarketOrderFee?: ConsumeMarketFee,
|
consumeMarketOrderFee?: ConsumeMarketFee,
|
||||||
|
providerFees?: ProviderFees,
|
||||||
consumeMarketFixedSwapFee: string = '0',
|
consumeMarketFixedSwapFee: string = '0',
|
||||||
datatokenIndex: number = 0,
|
datatokenIndex: number = 0,
|
||||||
serviceIndex: number = 0,
|
serviceIndex: number = 0,
|
||||||
@ -68,18 +75,23 @@ export async function orderAsset(
|
|||||||
)
|
)
|
||||||
const pricingType =
|
const pricingType =
|
||||||
fixedRates.length > 0 ? 'fixed' : dispensers.length > 0 ? 'free' : 'NOT_ALLOWED'
|
fixedRates.length > 0 ? 'fixed' : dispensers.length > 0 ? 'free' : 'NOT_ALLOWED'
|
||||||
const initializeData = await ProviderInstance.initialize(
|
|
||||||
|
const fees =
|
||||||
|
providerFees ||
|
||||||
|
(
|
||||||
|
await ProviderInstance.initialize(
|
||||||
asset.id,
|
asset.id,
|
||||||
asset.services[serviceIndex].id,
|
asset.services[serviceIndex].id,
|
||||||
0,
|
0,
|
||||||
await consumerAccount.getAddress(),
|
await consumerAccount.getAddress(),
|
||||||
config.providerUri
|
providerUrl || config.providerUri
|
||||||
)
|
)
|
||||||
|
).providerFee
|
||||||
|
|
||||||
const orderParams = {
|
const orderParams = {
|
||||||
consumer: await consumerAccount.getAddress(),
|
consumer: consumerAddress || (await consumerAccount.getAddress()),
|
||||||
serviceIndex,
|
serviceIndex,
|
||||||
_providerFee: initializeData.providerFee,
|
_providerFee: fees,
|
||||||
_consumeMarketFee: consumeMarketOrderFee
|
_consumeMarketFee: consumeMarketOrderFee
|
||||||
} as OrderParams
|
} as OrderParams
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user