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:
commit
2063530297
@ -1,7 +1,7 @@
|
|||||||
import fetch from "node-fetch"
|
import fetch from "node-fetch"
|
||||||
import Logger from "../utils/Logger"
|
import Logger from "../utils/Logger"
|
||||||
|
|
||||||
export default class Provider {
|
export default class Aquarius {
|
||||||
public static async getAccessUrl(accessToken: any, payload: any): Promise<string> {
|
public static async getAccessUrl(accessToken: any, payload: any): Promise<string> {
|
||||||
|
|
||||||
const accessUrl = await fetch(`${accessToken.service_endpoint}/${accessToken.resource_id}`, {
|
const accessUrl = await fetch(`${accessToken.service_endpoint}/${accessToken.resource_id}`, {
|
14
src/aquarius/AquariusProvider.ts
Normal file
14
src/aquarius/AquariusProvider.ts
Normal 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
|
||||||
|
}
|
@ -1,3 +1,5 @@
|
|||||||
|
import Aquarius from "../aquarius/Aquarius"
|
||||||
|
import AquariusProvider from "../aquarius/AquariusProvider"
|
||||||
import ConfigProvider from "../ConfigProvider"
|
import ConfigProvider from "../ConfigProvider"
|
||||||
import Keeper from "../keeper/Keeper"
|
import Keeper from "../keeper/Keeper"
|
||||||
import Web3Provider from "../keeper/Web3Provider"
|
import Web3Provider from "../keeper/Web3Provider"
|
||||||
@ -17,7 +19,7 @@ export default class Ocean {
|
|||||||
if (!Ocean.instance) {
|
if (!Ocean.instance) {
|
||||||
ConfigProvider.configure(config)
|
ConfigProvider.configure(config)
|
||||||
SecretStoreProvider.configure(config)
|
SecretStoreProvider.configure(config)
|
||||||
ProviderProvider.setProvider(Provider)
|
AquariusProvider.setAquarius(Aquarius)
|
||||||
Ocean.instance = new Ocean(await Keeper.getInstance())
|
Ocean.instance = new Ocean(await Keeper.getInstance())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
import * as EthEcies from "eth-ecies"
|
import * as EthEcies from "eth-ecies"
|
||||||
import * as JWT from "jsonwebtoken"
|
import * as JWT from "jsonwebtoken"
|
||||||
|
import AquariusProvider from "../aquarius/AquariusProvider"
|
||||||
import Keeper from "../keeper/Keeper"
|
import Keeper from "../keeper/Keeper"
|
||||||
import Web3Provider from "../keeper/Web3Provider"
|
import Web3Provider from "../keeper/Web3Provider"
|
||||||
import AccessStatus from "../models/AccessStatus"
|
import AccessStatus from "../models/AccessStatus"
|
||||||
import ProviderProvider from "../provider/ProviderProvider"
|
|
||||||
import Logger from "../utils/Logger"
|
import Logger from "../utils/Logger"
|
||||||
import Account from "./Account"
|
import Account from "./Account"
|
||||||
import Asset from "./Asset"
|
import Asset from "./Asset"
|
||||||
@ -87,7 +87,7 @@ export default class Order extends OceanBase {
|
|||||||
jwt: accessTokenEncoded,
|
jwt: accessTokenEncoded,
|
||||||
})
|
})
|
||||||
|
|
||||||
const accessUrl = await ProviderProvider.getProvider().getAccessUrl(accessToken, payload)
|
const accessUrl = await AquariusProvider.getAquarius().getAccessUrl(accessToken, payload)
|
||||||
|
|
||||||
Logger.log("consume url: ", accessUrl)
|
Logger.log("consume url: ", accessUrl)
|
||||||
|
|
||||||
|
@ -1,14 +0,0 @@
|
|||||||
export default class ProviderProvider {
|
|
||||||
|
|
||||||
public static setProvider(provider) {
|
|
||||||
|
|
||||||
ProviderProvider.provider = provider
|
|
||||||
}
|
|
||||||
|
|
||||||
public static getProvider() {
|
|
||||||
|
|
||||||
return ProviderProvider.provider
|
|
||||||
}
|
|
||||||
|
|
||||||
private static provider
|
|
||||||
}
|
|
@ -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> {
|
public static async getAccessUrl(accessToken: any, payload: any): Promise<string> {
|
||||||
return "http://test/test"
|
return "http://test/test"
|
@ -1,13 +1,13 @@
|
|||||||
import {assert} from "chai"
|
import {assert} from "chai"
|
||||||
|
import AquariusProvider from "../../src/aquarius/AquariusProvider"
|
||||||
import ConfigProvider from "../../src/ConfigProvider"
|
import ConfigProvider from "../../src/ConfigProvider"
|
||||||
import ContractHandler from "../../src/keeper/ContractHandler"
|
import ContractHandler from "../../src/keeper/ContractHandler"
|
||||||
import Account from "../../src/ocean/Account"
|
import Account from "../../src/ocean/Account"
|
||||||
import Asset from "../../src/ocean/Asset"
|
import Asset from "../../src/ocean/Asset"
|
||||||
import Ocean from "../../src/ocean/Ocean"
|
import Ocean from "../../src/ocean/Ocean"
|
||||||
import Order from "../../src/ocean/Order"
|
import Order from "../../src/ocean/Order"
|
||||||
import ProviderProvider from "../../src/provider/ProviderProvider"
|
|
||||||
import config from "../config"
|
import config from "../config"
|
||||||
import ProviderMock from "../mocks/Provider.Mock"
|
import AquariusMock from "../mocks/Aquarius.mock"
|
||||||
|
|
||||||
const testName = "Test Asset 2"
|
const testName = "Test Asset 2"
|
||||||
const testDescription = "This asset is pure owange"
|
const testDescription = "This asset is pure owange"
|
||||||
@ -19,11 +19,11 @@ let testAsset: Asset
|
|||||||
let accounts: Account[]
|
let accounts: Account[]
|
||||||
let testPublisher: Account
|
let testPublisher: Account
|
||||||
|
|
||||||
describe("Asset", () => {
|
describe("#purchase()", () => {
|
||||||
|
|
||||||
before(async () => {
|
before(async () => {
|
||||||
ConfigProvider.configure(config)
|
ConfigProvider.configure(config)
|
||||||
ProviderProvider.setProvider(ProviderMock)
|
AquariusProvider.setAquarius(AquariusMock)
|
||||||
|
|
||||||
await ContractHandler.deployContracts()
|
await ContractHandler.deployContracts()
|
||||||
ocean = await Ocean.getInstance(config)
|
ocean = await Ocean.getInstance(config)
|
||||||
@ -34,8 +34,6 @@ describe("Asset", () => {
|
|||||||
await ocean.register(testAsset)
|
await ocean.register(testAsset)
|
||||||
})
|
})
|
||||||
|
|
||||||
describe("#purchase()", () => {
|
|
||||||
|
|
||||||
it("should purchase an asset", async () => {
|
it("should purchase an asset", async () => {
|
||||||
|
|
||||||
// todo
|
// todo
|
||||||
@ -44,4 +42,3 @@ describe("Asset", () => {
|
|||||||
assert(order)
|
assert(order)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
})
|
|
||||||
|
Loading…
Reference in New Issue
Block a user