2018-11-07 14:33:56 +01:00
|
|
|
import Web3Provider from "../Web3Provider"
|
2018-10-29 10:53:22 +01:00
|
|
|
import ContractBase from "./ContractBase"
|
2019-03-04 14:34:24 +01:00
|
|
|
import { zeroX } from "../../utils"
|
2018-10-29 10:53:22 +01:00
|
|
|
|
|
|
|
export default class DIDRegistry extends ContractBase {
|
|
|
|
|
|
|
|
public static async getInstance(): Promise<DIDRegistry> {
|
|
|
|
const didRegistry: DIDRegistry = new DIDRegistry("DIDRegistry")
|
|
|
|
await didRegistry.init()
|
|
|
|
return didRegistry
|
|
|
|
}
|
|
|
|
|
2019-03-01 13:24:04 +01:00
|
|
|
public async registerAttribute(did: string, checksum: string, value: string, ownerAddress: string) {
|
2019-03-04 14:34:24 +01:00
|
|
|
return this.send("registerAttribute", ownerAddress, [zeroX(did), Web3Provider.getWeb3().utils.fromAscii(checksum), value])
|
2018-10-29 10:53:22 +01:00
|
|
|
}
|
|
|
|
|
2019-03-04 13:05:27 +01:00
|
|
|
public async getDIDOwner(did: string): Promise<string> {
|
2019-03-04 14:34:24 +01:00
|
|
|
return this.call("getDIDOwner", [zeroX(did)])
|
2018-10-29 10:53:22 +01:00
|
|
|
}
|
|
|
|
|
2019-03-04 13:05:27 +01:00
|
|
|
public async getBlockNumberUpdated(did: string): Promise<number> {
|
2019-03-04 14:34:24 +01:00
|
|
|
return +await this.call("getBlockNumberUpdated", [zeroX(did)])
|
2018-10-29 10:53:22 +01:00
|
|
|
}
|
|
|
|
}
|