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

Merge branch 'develop' into fix/file_download

This commit is contained in:
Sebastian Gerske 2018-12-14 16:15:36 +01:00 committed by GitHub
commit d6495036d7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
11 changed files with 24 additions and 23 deletions

View File

@ -15,21 +15,21 @@ export default class DIDRegistry extends ContractBase {
value: string, ownerAddress: string): Promise<Receipt> { value: string, ownerAddress: string): Promise<Receipt> {
return this.send("registerAttribute", return this.send("registerAttribute",
ownerAddress, ["0x" + did, type, Web3Provider.getWeb3().utils.fromAscii(key), value], ownerAddress, [did, type, Web3Provider.getWeb3().utils.fromAscii(key), value],
) )
} }
public async getOwner(did: string): Promise<string> { public async getOwner(did: string): Promise<string> {
return this.call("getOwner", return this.call("getOwner",
["0x" + did], [did],
) )
} }
public async getUpdateAt(did: string): Promise<number> { public async getUpdateAt(did: string): Promise<number> {
const blockNum = await this.call("getUpdateAt", const blockNum = await this.call("getUpdateAt",
["0x" + did], [did],
) )
return parseInt(blockNum, 10) return parseInt(blockNum, 10)

View File

@ -12,7 +12,7 @@ export default class OceanMarket extends ContractBase {
// call functions (costs no gas) // call functions (costs no gas)
public async isAssetActive(assetId: string): Promise<boolean> { public async isAssetActive(assetId: string): Promise<boolean> {
return this.call("checkAsset", ["0x" + assetId]) return this.call("checkAsset", [assetId])
} }
public async verifyOrderPayment(orderId: string): Promise<boolean> { public async verifyOrderPayment(orderId: string): Promise<boolean> {
@ -20,7 +20,7 @@ export default class OceanMarket extends ContractBase {
} }
public async getAssetPrice(assetId: string): Promise<number> { public async getAssetPrice(assetId: string): Promise<number> {
return this.call("getAssetPrice", ["0x" + assetId]) return this.call("getAssetPrice", [assetId])
.then((price: string) => new BigNumber(price).toNumber()) .then((price: string) => new BigNumber(price).toNumber())
} }
@ -33,6 +33,6 @@ export default class OceanMarket extends ContractBase {
} }
public async register(assetId: string, price: number, publisherAddress: string): Promise<Receipt> { public async register(assetId: string, price: number, publisherAddress: string): Promise<Receipt> {
return this.send("register", publisherAddress, ["0x" + assetId, price]) return this.send("register", publisherAddress, [assetId, price])
} }
} }

View File

@ -49,7 +49,7 @@ export default class ServiceAgreement extends ContractBase {
return this.send("executeAgreement", publisherAddress, [ return this.send("executeAgreement", publisherAddress, [
serviceAgreementTemplateId, serviceAgreementSignatureHash, consumerAddress, valueHashes, serviceAgreementTemplateId, serviceAgreementSignatureHash, consumerAddress, valueHashes,
timeoutValues, serviceAgreementId, "0x" + did.replace("did:op:", ""), timeoutValues, serviceAgreementId, did.replace("did:op:", ""),
]) ])
} }
} }

View File

@ -14,7 +14,7 @@ export default class AccessConditions extends ContractBase {
public async grantAccess(serviceAgreementId: any, assetId: any, documentKeyId: any, publisherAddress: string) public async grantAccess(serviceAgreementId: any, assetId: any, documentKeyId: any, publisherAddress: string)
: Promise<Receipt> { : Promise<Receipt> {
return this.send("grantAccess", publisherAddress, [ return this.send("grantAccess", publisherAddress, [
serviceAgreementId, "0x" + assetId, "0x" + documentKeyId, serviceAgreementId, assetId, documentKeyId,
]) ])
} }
} }

View File

@ -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,
]) ])
} }
} }

View File

@ -66,7 +66,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"
@ -182,7 +182,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,
) )

View File

@ -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

View File

@ -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,
}) })

View File

@ -26,7 +26,7 @@ describe("DIDRegistry", () => {
it("should register an attribute in a new did", async () => { it("should register an attribute in a new did", async () => {
const ownerAccount: Account = (await ocean.getAccounts())[0] const ownerAccount: Account = (await ocean.getAccounts())[0]
const did = IdGenerator.generateId() const did = IdGenerator.generatePrefixedId()
const providerKey = Web3Provider.getWeb3().utils.fromAscii("provider") const providerKey = Web3Provider.getWeb3().utils.fromAscii("provider")
const data = "my nice provider, is nice" const data = "my nice provider, is nice"
const receipt = await didRegistry.registerAttribute(did, ValueType.DID, providerKey, const receipt = await didRegistry.registerAttribute(did, ValueType.DID, providerKey,
@ -37,7 +37,7 @@ describe("DIDRegistry", () => {
it("should register another attribute in the same did", async () => { it("should register another attribute in the same did", async () => {
const ownerAccount: Account = (await ocean.getAccounts())[0] const ownerAccount: Account = (await ocean.getAccounts())[0]
const did = IdGenerator.generateId() const did = IdGenerator.generatePrefixedId()
{ {
// register the first attribute // register the first attribute
const providerKey = Web3Provider.getWeb3().utils.fromAscii("provider") const providerKey = Web3Provider.getWeb3().utils.fromAscii("provider")
@ -62,7 +62,7 @@ describe("DIDRegistry", () => {
it("should get the owner of a did properly", async () => { it("should get the owner of a did properly", async () => {
const ownerAccount: Account = (await ocean.getAccounts())[0] const ownerAccount: Account = (await ocean.getAccounts())[0]
const did = IdGenerator.generateId() const did = IdGenerator.generatePrefixedId()
const providerKey = Web3Provider.getWeb3().utils.fromAscii("provider") const providerKey = Web3Provider.getWeb3().utils.fromAscii("provider")
const data = "my nice provider, is nice" const data = "my nice provider, is nice"
await didRegistry.registerAttribute(did, ValueType.DID, providerKey, await didRegistry.registerAttribute(did, ValueType.DID, providerKey,
@ -74,7 +74,7 @@ describe("DIDRegistry", () => {
}) })
it("should get 0x00.. for a not registered did", async () => { it("should get 0x00.. for a not registered did", async () => {
const owner = await didRegistry.getOwner("1234") const owner = await didRegistry.getOwner("0x1234")
assert(owner === "0x0000000000000000000000000000000000000000") assert(owner === "0x0000000000000000000000000000000000000000")
}) })
@ -84,7 +84,7 @@ describe("DIDRegistry", () => {
it("should the block number of the last update of the did attribute", async () => { it("should the block number of the last update of the did attribute", async () => {
const ownerAccount: Account = (await ocean.getAccounts())[0] const ownerAccount: Account = (await ocean.getAccounts())[0]
const did = IdGenerator.generateId() const did = IdGenerator.generatePrefixedId()
const providerKey = Web3Provider.getWeb3().utils.fromAscii("provider") const providerKey = Web3Provider.getWeb3().utils.fromAscii("provider")
const data = "my nice provider, is nice" const data = "my nice provider, is nice"
await didRegistry.registerAttribute(did, ValueType.DID, providerKey, await didRegistry.registerAttribute(did, ValueType.DID, providerKey,

View File

@ -23,7 +23,7 @@ let consumerAccount: Account
let accessService: Service let accessService: Service
let metaDataService: Service let metaDataService: Service
const assetId: string = IdGenerator.generateId() const assetId: string = IdGenerator.generatePrefixedId()
describe("ServiceAgreement", () => { describe("ServiceAgreement", () => {
@ -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

View File

@ -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)
}) })
}) })