mirror of
https://github.com/oceanprotocol/ocean.js.git
synced 2024-11-26 20:39:05 +01:00
updated provider order for params
This commit is contained in:
parent
9076ae05b1
commit
21bebf4747
@ -73,10 +73,11 @@ export class Provider {
|
||||
public async getNonce(
|
||||
providerUri: string,
|
||||
consumerAddress: string,
|
||||
fetchMethod: any,
|
||||
fetchMethod?: any,
|
||||
providerEndpoints?: any,
|
||||
serviceEndpoints?: ServiceEndpoint[]
|
||||
): Promise<string> {
|
||||
const preferedFetch = fetchMethod || crossFetchGeneric
|
||||
if (!providerEndpoints) {
|
||||
providerEndpoints = await this.getEndpoints(providerUri)
|
||||
}
|
||||
@ -88,7 +89,7 @@ export class Provider {
|
||||
: null
|
||||
if (!path) return null
|
||||
try {
|
||||
const response = await fetchMethod(
|
||||
const response = await preferedFetch(
|
||||
'GET',
|
||||
path + `?userAddress=${consumerAddress}`,
|
||||
null,
|
||||
@ -127,7 +128,8 @@ export class Provider {
|
||||
* @param {string} postMethod http post method
|
||||
* @return {Promise<string>} urlDetails
|
||||
*/
|
||||
public async encrypt(data: any, providerUri: string, postMethod: any): Promise<any> {
|
||||
public async encrypt(data: any, providerUri: string, postMethod?: any): Promise<any> {
|
||||
const preferedFetch = postMethod || crossFetchGeneric
|
||||
const providerEndpoints = await this.getEndpoints(providerUri)
|
||||
const serviceEndpoints = await this.getServiceEndpoints(
|
||||
providerUri,
|
||||
@ -139,9 +141,14 @@ export class Provider {
|
||||
|
||||
if (!path) return null
|
||||
try {
|
||||
const response = await postMethod('POST', path, decodeURI(JSON.stringify(data)), {
|
||||
'Content-Type': 'application/octet-stream'
|
||||
})
|
||||
const response = await preferedFetch(
|
||||
'POST',
|
||||
path,
|
||||
decodeURI(JSON.stringify(data)),
|
||||
{
|
||||
'Content-Type': 'application/octet-stream'
|
||||
}
|
||||
)
|
||||
return response
|
||||
} catch (e) {
|
||||
LoggerInstance.error(e)
|
||||
@ -340,11 +347,11 @@ export class Provider {
|
||||
public async computeStart(
|
||||
providerUri: string,
|
||||
web3: Web3,
|
||||
fetchMethod?: any,
|
||||
consumerAddress: string,
|
||||
computeEnv: string,
|
||||
dataset: ComputeAsset,
|
||||
algorithm: ComputeAlgorithm,
|
||||
fetchMethod?: any,
|
||||
additionalDatasets?: ComputeAsset[],
|
||||
output?: ComputeOutput
|
||||
): Promise<ComputeJob | ComputeJob[]> {
|
||||
@ -609,7 +616,7 @@ export class Provider {
|
||||
jobId: string,
|
||||
providerUri: string,
|
||||
web3: Web3,
|
||||
fetchMethod: any
|
||||
fetchMethod?: any
|
||||
): Promise<ComputeJob | ComputeJob[]> {
|
||||
const preferedFetch = fetchMethod || crossFetchGeneric
|
||||
const providerEndpoints = await this.getEndpoints(providerUri)
|
||||
|
@ -303,7 +303,6 @@ describe('Simple compute tests', async () => {
|
||||
const computeJobs = await ProviderInstance.computeStart(
|
||||
providerUrl,
|
||||
web3,
|
||||
crossFetchGeneric,
|
||||
consumerAccount,
|
||||
'env1',
|
||||
{
|
||||
@ -315,7 +314,8 @@ describe('Simple compute tests', async () => {
|
||||
documentId: resolvedDDOAlgo.id,
|
||||
serviceId: resolvedDDOAlgo.services[0].id,
|
||||
transferTxId: txidAlgo.transactionHash
|
||||
}
|
||||
},
|
||||
crossFetchGeneric
|
||||
)
|
||||
assert(computeJobs, 'Cannot start compute job')
|
||||
const jobStatus = await ProviderInstance.computeStatus(
|
||||
|
Loading…
x
Reference in New Issue
Block a user