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:
parent
e1b1642907
commit
233aede5f6
@ -12,7 +12,7 @@ export default class PaymentConditions extends ContractBase {
|
|||||||
public async lockPayment(serviceAgreementId: string, assetId: string, price: number, consumerAddress: string)
|
public async lockPayment(serviceAgreementId: string, assetId: string, price: number, consumerAddress: string)
|
||||||
: Promise<Receipt> {
|
: Promise<Receipt> {
|
||||||
return this.send("lockPayment", consumerAddress, [
|
return this.send("lockPayment", consumerAddress, [
|
||||||
serviceAgreementId, "0x" + assetId, price,
|
serviceAgreementId, assetId, price,
|
||||||
])
|
])
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -67,7 +67,7 @@ export default class Ocean {
|
|||||||
const aquarius = AquariusProvider.getAquarius()
|
const aquarius = AquariusProvider.getAquarius()
|
||||||
const brizo = BrizoProvider.getBrizo()
|
const brizo = BrizoProvider.getBrizo()
|
||||||
|
|
||||||
const assetId: string = IdGenerator.generateId()
|
const assetId: string = IdGenerator.generatePrefixedId()
|
||||||
const did: string = `did:op:${assetId}`
|
const did: string = `did:op:${assetId}`
|
||||||
const accessServiceDefinitionId: string = "0"
|
const accessServiceDefinitionId: string = "0"
|
||||||
const computeServiceDefintionId: string = "1"
|
const computeServiceDefintionId: string = "1"
|
||||||
@ -183,7 +183,8 @@ export default class Ocean {
|
|||||||
event.listenOnce(async (data) => {
|
event.listenOnce(async (data) => {
|
||||||
|
|
||||||
const sa: ServiceAgreement = new ServiceAgreement(data.returnValues.serviceAgreementId)
|
const sa: ServiceAgreement = new ServiceAgreement(data.returnValues.serviceAgreementId)
|
||||||
await sa.payAsset(id,
|
await sa.payAsset(
|
||||||
|
id,
|
||||||
metadataService.metadata.base.price,
|
metadataService.metadata.base.price,
|
||||||
consumer,
|
consumer,
|
||||||
)
|
)
|
||||||
|
@ -111,9 +111,9 @@ export default class ServiceAgreementTemplate extends OceanBase {
|
|||||||
case "price":
|
case "price":
|
||||||
return metadata.base.price
|
return metadata.base.price
|
||||||
case "assetId":
|
case "assetId":
|
||||||
return "0x" + assetId
|
return assetId
|
||||||
case "documentKeyId":
|
case "documentKeyId":
|
||||||
return "0x" + assetId
|
return assetId
|
||||||
}
|
}
|
||||||
|
|
||||||
return null
|
return null
|
||||||
|
@ -85,7 +85,7 @@ describe("Aquarius", () => {
|
|||||||
|
|
||||||
it("should store a ddo", async () => {
|
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({
|
const ddo: DDO = new DDO({
|
||||||
id: did,
|
id: did,
|
||||||
})
|
})
|
||||||
@ -103,7 +103,7 @@ describe("Aquarius", () => {
|
|||||||
|
|
||||||
it("should store a ddo", async () => {
|
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({
|
const ddo: DDO = new DDO({
|
||||||
id: did,
|
id: did,
|
||||||
})
|
})
|
||||||
|
@ -44,7 +44,7 @@ describe("ServiceAgreement", () => {
|
|||||||
|
|
||||||
accessService = {
|
accessService = {
|
||||||
type: "Access",
|
type: "Access",
|
||||||
serviceDefinitionId: IdGenerator.generateId(),
|
serviceDefinitionId: "0",
|
||||||
templateId: serviceAgreementTemplate.getId(),
|
templateId: serviceAgreementTemplate.getId(),
|
||||||
conditions,
|
conditions,
|
||||||
} as Service
|
} as Service
|
||||||
|
@ -49,7 +49,7 @@ describe("ServiceAgreementTemplate", () => {
|
|||||||
new ServiceAgreementTemplate(access)
|
new ServiceAgreementTemplate(access)
|
||||||
assert(serviceAgreementTemplate)
|
assert(serviceAgreementTemplate)
|
||||||
|
|
||||||
const conds = await serviceAgreementTemplate.getConditions(new MetaData(), IdGenerator.generateId())
|
const conds = await serviceAgreementTemplate.getConditions(new MetaData(), IdGenerator.generatePrefixedId())
|
||||||
assert(conds)
|
assert(conds)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
Loading…
Reference in New Issue
Block a user