mirror of
https://github.com/oceanprotocol-archive/squid-js.git
synced 2024-02-02 15:31:51 +01:00
fix 500 on aquarius, hardened tests, avoided loading contracts more than once per chain and item
This commit is contained in:
parent
6df097ea8f
commit
2df3a68abf
@ -12,7 +12,12 @@ export default class Brizo {
|
||||
return `${this.url}/api/v1/brizo/services/access/purchase?`
|
||||
}
|
||||
|
||||
public getServiceEndpoint(pubKey: string, serviceId: string, url: string) {
|
||||
public getConsumeEndpoint(pubKey: string, serviceId: string, url: string) {
|
||||
return `${this.url}/api/v1/brizo/services/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}"`
|
||||
}
|
||||
}
|
||||
|
@ -25,13 +25,13 @@ export default class DDO {
|
||||
|
||||
public constructor(ddo?: {
|
||||
id?: string,
|
||||
publicKey?: PublicKey[],
|
||||
publicKey?: any[],
|
||||
authentication?: Authentication[],
|
||||
service?: Service[],
|
||||
}) {
|
||||
this.authentication = ddo ? ddo.authentication ? ddo.authentication : [] : []
|
||||
this.id = ddo ? ddo.id ? ddo.id : null : null
|
||||
this.publicKey = ddo ? ddo.publicKey ? ddo.publicKey : [] : []
|
||||
this.authentication = ddo ? ddo.authentication ? ddo.authentication : [] : []
|
||||
this.service = ddo ? ddo.service ? ddo.service : [] : []
|
||||
}
|
||||
}
|
||||
|
@ -95,16 +95,28 @@ export default class Ocean {
|
||||
|
||||
// create ddo itself
|
||||
const ddo: DDO = new DDO({
|
||||
id: did,
|
||||
authentication: [{
|
||||
publicKey: publisher.getId(),
|
||||
type: "RsaSignatureAuthentication2018",
|
||||
publicKey: did + "#keys-1",
|
||||
} as Authentication],
|
||||
id: did,
|
||||
publicKey: [
|
||||
{
|
||||
id: did + "#keys-1",
|
||||
},
|
||||
{
|
||||
type: "Ed25519VerificationKey2018",
|
||||
},
|
||||
{
|
||||
owner: did,
|
||||
},
|
||||
{
|
||||
publicKeyBase58: publisher.getId(),
|
||||
},
|
||||
],
|
||||
service: [
|
||||
{
|
||||
type: template.templateName,
|
||||
// tslint:disable-next-line
|
||||
serviceEndpoint: this.brizo.getServiceEndpoint(publisher.getId(),
|
||||
serviceDefinitionId, metadata.base.contentUrls[0]),
|
||||
purchaseEndpoint: this.brizo.getPurchaseEndpoint(),
|
||||
// the id of the service agreement?
|
||||
serviceDefinitionId,
|
||||
@ -113,14 +125,23 @@ export default class Ocean {
|
||||
conditions: ddoConditions,
|
||||
} as Service,
|
||||
{
|
||||
serviceEndpoint,
|
||||
serviceEndpoint: this.brizo.getConsumeEndpoint(publisher.getId(),
|
||||
serviceDefinitionId, metadata.base.contentUrls[0]),
|
||||
type: "Consume",
|
||||
} as Service,
|
||||
{
|
||||
serviceEndpoint: this.brizo.getComputeEndpoint(publisher.getId(),
|
||||
serviceDefinitionId, "xxx", "xxx"),
|
||||
type: "Consume",
|
||||
} as Service,
|
||||
{
|
||||
type: "Metadata",
|
||||
metadata,
|
||||
serviceEndpoint,
|
||||
} as Service,
|
||||
],
|
||||
})
|
||||
|
||||
// Logger.log(JSON.stringify(ddo, null, 2))
|
||||
|
||||
const storedDdo = await this.aquarius.storeDDO(ddo)
|
||||
|
||||
await didRegistry.registerAttribute(id, ValueType.DID, "Metadata", serviceEndpoint,
|
||||
|
@ -95,11 +95,10 @@ export default class ServiceAgreementTemplate extends OceanBase {
|
||||
}
|
||||
|
||||
private async getMethodReflections(): Promise<MethodReflection[]> {
|
||||
const methodReflections: MethodReflection[] =
|
||||
await Promise.all(this.template.Methods.map(async (method: Method) => {
|
||||
const methodReflection = await ContractReflector.reflectContractMethod(method.path)
|
||||
return methodReflection
|
||||
}))
|
||||
const methodReflections: MethodReflection[] = []
|
||||
for (const method of this.template.Methods) {
|
||||
methodReflections.push(await ContractReflector.reflectContractMethod(method.path))
|
||||
}
|
||||
return methodReflections
|
||||
}
|
||||
}
|
||||
|
@ -78,7 +78,7 @@ export default class TestContractHandler extends ContractHandler {
|
||||
|
||||
// dont redeploy if there is already something loaded
|
||||
if (ContractHandler.has(name)) {
|
||||
return ContractHandler.get(name)
|
||||
return await ContractHandler.get(name)
|
||||
}
|
||||
|
||||
const web3 = Web3Provider.getWeb3()
|
||||
|
Loading…
Reference in New Issue
Block a user