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

rollback did containing 0x

This commit is contained in:
Sebastian Gerske 2018-12-17 14:17:35 +01:00
parent d6a643772d
commit 09191fab59
8 changed files with 14 additions and 14 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, [did, type, Web3Provider.getWeb3().utils.fromAscii(key), value], ownerAddress, ["0x" + 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",
[did], ["0x" + 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",
[did], ["0x" + did],
) )
return parseInt(blockNum, 10) return parseInt(blockNum, 10)

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, did.replace("did:op:", ""), timeoutValues, serviceAgreementId, "0x" + 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, assetId, documentKeyId, serviceAgreementId, "0x" + assetId, "0x" + 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, assetId, price, serviceAgreementId, "0x" + assetId, price,
]) ])
} }
} }

View File

@ -1,4 +1,4 @@
import { v4 } from "uuid" import {v4} from "uuid"
export default class IdGenerator { export default class IdGenerator {
public static generateId(): string { public static generateId(): string {

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.generatePrefixedId() const assetId: string = IdGenerator.generateId()
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"

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.generatePrefixedId() const did = IdGenerator.generateId()
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.generatePrefixedId() const did = IdGenerator.generateId()
{ {
// 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.generatePrefixedId() const did = IdGenerator.generateId()
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("0x1234") const owner = await didRegistry.getOwner("1234")
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.generatePrefixedId() const did = IdGenerator.generateId()
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.generatePrefixedId() const assetId: string = IdGenerator.generateId()
describe("ServiceAgreement", () => { describe("ServiceAgreement", () => {