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

Generate assetId with 0x prefix, update all references to reflect this. This makes it similar to squid-py and fixes an issue in payAsset where the asset id in the condition param had double 0x prefix when paying a service agreement for an asset created in squid-py.

This commit is contained in:
ssallam 2018-12-14 13:40:08 +01:00
parent e1b1642907
commit 233aede5f6
6 changed files with 10 additions and 9 deletions

View File

@ -12,7 +12,7 @@ export default class PaymentConditions extends ContractBase {
public async lockPayment(serviceAgreementId: string, assetId: string, price: number, consumerAddress: string)
: Promise<Receipt> {
return this.send("lockPayment", consumerAddress, [
serviceAgreementId, "0x" + assetId, price,
serviceAgreementId, assetId, price,
])
}
}

View File

@ -67,7 +67,7 @@ export default class Ocean {
const aquarius = AquariusProvider.getAquarius()
const brizo = BrizoProvider.getBrizo()
const assetId: string = IdGenerator.generateId()
const assetId: string = IdGenerator.generatePrefixedId()
const did: string = `did:op:${assetId}`
const accessServiceDefinitionId: string = "0"
const computeServiceDefintionId: string = "1"
@ -183,7 +183,8 @@ export default class Ocean {
event.listenOnce(async (data) => {
const sa: ServiceAgreement = new ServiceAgreement(data.returnValues.serviceAgreementId)
await sa.payAsset(id,
await sa.payAsset(
id,
metadataService.metadata.base.price,
consumer,
)

View File

@ -111,9 +111,9 @@ export default class ServiceAgreementTemplate extends OceanBase {
case "price":
return metadata.base.price
case "assetId":
return "0x" + assetId
return assetId
case "documentKeyId":
return "0x" + assetId
return assetId
}
return null

View File

@ -85,7 +85,7 @@ describe("Aquarius", () => {
it("should store a ddo", async () => {
const did: string = `did:op:${IdGenerator.generateId()}`
const did: string = `did:op:${IdGenerator.generatePrefixedId()}`
const ddo: DDO = new DDO({
id: did,
})
@ -103,7 +103,7 @@ describe("Aquarius", () => {
it("should store a ddo", async () => {
const did: string = `did:op:${IdGenerator.generateId()}`
const did: string = `did:op:${IdGenerator.generatePrefixedId()}`
const ddo: DDO = new DDO({
id: did,
})

View File

@ -44,7 +44,7 @@ describe("ServiceAgreement", () => {
accessService = {
type: "Access",
serviceDefinitionId: IdGenerator.generateId(),
serviceDefinitionId: "0",
templateId: serviceAgreementTemplate.getId(),
conditions,
} as Service

View File

@ -49,7 +49,7 @@ describe("ServiceAgreementTemplate", () => {
new ServiceAgreementTemplate(access)
assert(serviceAgreementTemplate)
const conds = await serviceAgreementTemplate.getConditions(new MetaData(), IdGenerator.generateId())
const conds = await serviceAgreementTemplate.getConditions(new MetaData(), IdGenerator.generatePrefixedId())
assert(conds)
})
})