mirror of
https://github.com/oceanprotocol/ocean.js.git
synced 2024-11-26 20:39:05 +01:00
Update Provider.checkFileUrl to allow non-URL file types (like Arweave) (#1627)
* Update Provider.checkFileUrl to allow non-URL file types * Reduce scope to only URLs and Arweave. * Remove parentheses to make linter happy * Update Provider tests to use UrlFile argument * Fix lint errors * Fix lint error * [REVERT THIS] comment coverage upload * CC_TEST_REPORTER_ID secret not available in PR workflows from external contributors. * Revert "[REVERT THIS] comment coverage upload" This reverts commit 7ca94b7e71ce5d53fa0c7b35bdff85e91b6db059. * Add Arweave fileinfo unit test * Rename `checkFileUrl` to `getFileInfo` * Fix lint error
This commit is contained in:
parent
f91a42aa60
commit
6efae8ebbc
@ -2,6 +2,7 @@ import Web3 from 'web3'
|
|||||||
import fetch from 'cross-fetch'
|
import fetch from 'cross-fetch'
|
||||||
import { LoggerInstance } from '../utils'
|
import { LoggerInstance } from '../utils'
|
||||||
import {
|
import {
|
||||||
|
Arweave,
|
||||||
FileInfo,
|
FileInfo,
|
||||||
ComputeJob,
|
ComputeJob,
|
||||||
ComputeOutput,
|
ComputeOutput,
|
||||||
@ -11,6 +12,7 @@ import {
|
|||||||
ProviderInitialize,
|
ProviderInitialize,
|
||||||
ProviderComputeInitializeResults,
|
ProviderComputeInitializeResults,
|
||||||
ServiceEndpoint,
|
ServiceEndpoint,
|
||||||
|
UrlFile,
|
||||||
UserCustomParameters
|
UserCustomParameters
|
||||||
} from '../@types'
|
} from '../@types'
|
||||||
|
|
||||||
@ -193,8 +195,8 @@ export class Provider {
|
|||||||
* @param {AbortSignal} signal abort signal
|
* @param {AbortSignal} signal abort signal
|
||||||
* @return {Promise<FileInfo[]>} urlDetails
|
* @return {Promise<FileInfo[]>} urlDetails
|
||||||
*/
|
*/
|
||||||
public async checkFileUrl(
|
public async getFileInfo(
|
||||||
url: string,
|
file: UrlFile | Arweave,
|
||||||
providerUri: string,
|
providerUri: string,
|
||||||
signal?: AbortSignal
|
signal?: AbortSignal
|
||||||
): Promise<FileInfo[]> {
|
): Promise<FileInfo[]> {
|
||||||
@ -203,7 +205,7 @@ export class Provider {
|
|||||||
providerUri,
|
providerUri,
|
||||||
providerEndpoints
|
providerEndpoints
|
||||||
)
|
)
|
||||||
const args = { url, type: 'url' }
|
const args = file
|
||||||
const files: FileInfo[] = []
|
const files: FileInfo[] = []
|
||||||
const path = this.getEndpointURL(serviceEndpoints, 'fileinfo')
|
const path = this.getEndpointURL(serviceEndpoints, 'fileinfo')
|
||||||
? this.getEndpointURL(serviceEndpoints, 'fileinfo').urlPath
|
? this.getEndpointURL(serviceEndpoints, 'fileinfo').urlPath
|
||||||
|
@ -25,9 +25,24 @@ describe('Provider tests', async () => {
|
|||||||
assert(valid === true)
|
assert(valid === true)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('Alice checks fileinfo', async () => {
|
it('Alice checks URL fileinfo', async () => {
|
||||||
const fileinfo: FileInfo[] = await providerInstance.checkFileUrl(
|
const fileinfo: FileInfo[] = await providerInstance.getFileInfo(
|
||||||
'https://dumps.wikimedia.org/enwiki/latest/enwiki-latest-abstract.xml.gz-rss.xml',
|
{
|
||||||
|
type: 'url',
|
||||||
|
url: 'https://dumps.wikimedia.org/enwiki/latest/enwiki-latest-abstract.xml.gz-rss.xml',
|
||||||
|
method: 'GET'
|
||||||
|
},
|
||||||
|
config.providerUri
|
||||||
|
)
|
||||||
|
assert(fileinfo[0].valid === true, 'Sent file is not valid')
|
||||||
|
})
|
||||||
|
|
||||||
|
it('Alice checks Arweave fileinfo', async () => {
|
||||||
|
const fileinfo: FileInfo[] = await providerInstance.getFileInfo(
|
||||||
|
{
|
||||||
|
type: 'arweave',
|
||||||
|
transactionId: 'a4qJoQZa1poIv5guEzkfgZYSAD0uYm7Vw4zm_tCswVQ'
|
||||||
|
},
|
||||||
config.providerUri
|
config.providerUri
|
||||||
)
|
)
|
||||||
assert(fileinfo[0].valid === true, 'Sent file is not valid')
|
assert(fileinfo[0].valid === true, 'Sent file is not valid')
|
||||||
|
Loading…
x
Reference in New Issue
Block a user