mirror of
https://github.com/oceanprotocol-archive/squid-js.git
synced 2024-02-02 15:31:51 +01:00
fix brizo connection
This commit is contained in:
parent
ccf6bb4227
commit
43a5e53d57
@ -1,6 +1,8 @@
|
||||
import Config from "../models/Config"
|
||||
import WebServiceConnectorProvider from "../utils/WebServiceConnectorProvider"
|
||||
|
||||
const apiPath = "/api/v1/brizo/services"
|
||||
|
||||
export default class Brizo {
|
||||
private url: string
|
||||
|
||||
@ -10,16 +12,16 @@ export default class Brizo {
|
||||
}
|
||||
|
||||
public getPurchaseEndpoint() {
|
||||
return `${this.url}/api/v1/brizo/services/access/purchase?`
|
||||
return `${this.url}${apiPath}/access/purchase?`
|
||||
}
|
||||
|
||||
public getConsumeEndpoint(pubKey: string, serviceId: string, url: string) {
|
||||
return `${this.url}/api/v1/brizo/services/consume?pubKey=${pubKey}&serviceId=${serviceId}&url=${url}`
|
||||
return `${this.url}${apiPath}/consume?pubKey=${pubKey}&serviceId=${serviceId}&url=${url}`
|
||||
}
|
||||
|
||||
public getComputeEndpoint(pubKey: string, serviceId: string, algo: string, container: string) {
|
||||
// tslint:disable-next-line
|
||||
return `${this.url}/api/v1/brizo/services/compute?pubKey=${pubKey}&serviceId=${serviceId}&algo=${algo}&container=${container}"`
|
||||
return `${this.url}${apiPath}/compute?pubKey=${pubKey}&serviceId=${serviceId}&algo=${algo}&container=${container}"`
|
||||
}
|
||||
|
||||
public async initializeServiceAgreement(
|
||||
@ -27,17 +29,20 @@ export default class Brizo {
|
||||
serviceAgreementId: string,
|
||||
serviceDefinitionId: string,
|
||||
signature: string,
|
||||
consumerPublicKey: string): Promise<any> {
|
||||
consumerAddress: string): Promise<any> {
|
||||
|
||||
return WebServiceConnectorProvider.getConnector().post(
|
||||
`${this.url}/api/v1/brizo/services/access/initialize`,
|
||||
{
|
||||
did,
|
||||
serviceAgreementId,
|
||||
serviceDefinitionId,
|
||||
signature,
|
||||
consumerPublicKey,
|
||||
})
|
||||
return WebServiceConnectorProvider
|
||||
.getConnector()
|
||||
.post(
|
||||
`${this.url}${apiPath}/access/initialize`,
|
||||
JSON.stringify({
|
||||
did,
|
||||
serviceAgreementId,
|
||||
serviceDefinitionId,
|
||||
signature,
|
||||
consumerAddress,
|
||||
}),
|
||||
)
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -74,6 +74,9 @@ import {Account, Logger, Ocean} from "../squid"
|
||||
Logger.log("did", ddo.id)
|
||||
|
||||
const accessService: Service = ddo.findServiceByType("Access")
|
||||
|
||||
await consumer.requestTokens(metaData.base.price)
|
||||
|
||||
const serviceAgreementResult: any = await ocean
|
||||
.signServiceAgreement(
|
||||
ddo.id,
|
||||
|
@ -216,7 +216,7 @@ export default class Ocean {
|
||||
serviceAgreementId,
|
||||
serviceDefinitionId,
|
||||
serviceAgreementSignature,
|
||||
await consumer.getPublicKey())
|
||||
consumer.getId())
|
||||
|
||||
Logger.log(result)
|
||||
}
|
||||
|
28
test.html
Normal file
28
test.html
Normal file
@ -0,0 +1,28 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>Title</title>
|
||||
<script src="dist/umd/squid.js"></script>
|
||||
<script>
|
||||
|
||||
const config = {
|
||||
// web3Provider: web3 ? web3.currentProvider : null,
|
||||
aquariusUri: "http://localhost:5000",
|
||||
brizoUri: "http://localhost:8030",
|
||||
parityUri: "http://localhost:9545",
|
||||
secretStoreUri: "http://localhost:12001",
|
||||
threshold: 0,
|
||||
password: "unittest",
|
||||
address: "0xed243adfb84a6626eba46178ccb567481c6e655d",
|
||||
}
|
||||
squid.Ocean
|
||||
.getInstance(config)
|
||||
.then(ocn => {
|
||||
console.log(ocn)
|
||||
})
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
</body>
|
||||
</html>
|
Loading…
Reference in New Issue
Block a user