1
0
mirror of https://github.com/oceanprotocol-archive/squid-js.git synced 2024-02-02 15:31:51 +01:00

Merge remote-tracking branch 'origin/develop' into feature/secret_store

# Conflicts:
#	src/ocean/Ocean.ts
#	test/ocean/Asset.test.ts
This commit is contained in:
Sebastian Gerske 2018-10-26 10:46:32 +02:00
commit 2063530297
7 changed files with 31 additions and 32 deletions

View File

@ -1,7 +1,7 @@
import fetch from "node-fetch"
import Logger from "../utils/Logger"
export default class Provider {
export default class Aquarius {
public static async getAccessUrl(accessToken: any, payload: any): Promise<string> {
const accessUrl = await fetch(`${accessToken.service_endpoint}/${accessToken.resource_id}`, {

View File

@ -0,0 +1,14 @@
export default class AquariusProvider {
public static setAquarius(aquarius) {
AquariusProvider.aquarius = aquarius
}
public static getAquarius() {
return AquariusProvider.aquarius
}
private static aquarius
}

View File

@ -1,3 +1,5 @@
import Aquarius from "../aquarius/Aquarius"
import AquariusProvider from "../aquarius/AquariusProvider"
import ConfigProvider from "../ConfigProvider"
import Keeper from "../keeper/Keeper"
import Web3Provider from "../keeper/Web3Provider"
@ -17,7 +19,7 @@ export default class Ocean {
if (!Ocean.instance) {
ConfigProvider.configure(config)
SecretStoreProvider.configure(config)
ProviderProvider.setProvider(Provider)
AquariusProvider.setAquarius(Aquarius)
Ocean.instance = new Ocean(await Keeper.getInstance())
}

View File

@ -1,9 +1,9 @@
import * as EthEcies from "eth-ecies"
import * as JWT from "jsonwebtoken"
import AquariusProvider from "../aquarius/AquariusProvider"
import Keeper from "../keeper/Keeper"
import Web3Provider from "../keeper/Web3Provider"
import AccessStatus from "../models/AccessStatus"
import ProviderProvider from "../provider/ProviderProvider"
import Logger from "../utils/Logger"
import Account from "./Account"
import Asset from "./Asset"
@ -87,7 +87,7 @@ export default class Order extends OceanBase {
jwt: accessTokenEncoded,
})
const accessUrl = await ProviderProvider.getProvider().getAccessUrl(accessToken, payload)
const accessUrl = await AquariusProvider.getAquarius().getAccessUrl(accessToken, payload)
Logger.log("consume url: ", accessUrl)

View File

@ -1,14 +0,0 @@
export default class ProviderProvider {
public static setProvider(provider) {
ProviderProvider.provider = provider
}
public static getProvider() {
return ProviderProvider.provider
}
private static provider
}

View File

@ -1,6 +1,6 @@
import Provider from "../../src/provider/Provider"
import Aquarius from "../../src/aquarius/Aquarius"
export default class ProviderMock extends Provider {
export default class AquariusMock extends Aquarius {
public static async getAccessUrl(accessToken: any, payload: any): Promise<string> {
return "http://test/test"

View File

@ -1,13 +1,13 @@
import {assert} from "chai"
import AquariusProvider from "../../src/aquarius/AquariusProvider"
import ConfigProvider from "../../src/ConfigProvider"
import ContractHandler from "../../src/keeper/ContractHandler"
import Account from "../../src/ocean/Account"
import Asset from "../../src/ocean/Asset"
import Ocean from "../../src/ocean/Ocean"
import Order from "../../src/ocean/Order"
import ProviderProvider from "../../src/provider/ProviderProvider"
import config from "../config"
import ProviderMock from "../mocks/Provider.Mock"
import AquariusMock from "../mocks/Aquarius.mock"
const testName = "Test Asset 2"
const testDescription = "This asset is pure owange"
@ -19,11 +19,11 @@ let testAsset: Asset
let accounts: Account[]
let testPublisher: Account
describe("Asset", () => {
describe("#purchase()", () => {
before(async () => {
ConfigProvider.configure(config)
ProviderProvider.setProvider(ProviderMock)
AquariusProvider.setAquarius(AquariusMock)
await ContractHandler.deployContracts()
ocean = await Ocean.getInstance(config)
@ -34,14 +34,11 @@ describe("Asset", () => {
await ocean.register(testAsset)
})
describe("#purchase()", () => {
it("should purchase an asset", async () => {
it("should purchase an asset", async () => {
// todo
const consumerAccount = accounts[5]
const order: Order = await testAsset.purchase(consumerAccount, timeout)
assert(order)
})
// todo
const consumerAccount = accounts[5]
const order: Order = await testAsset.purchase(consumerAccount, timeout)
assert(order)
})
})