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"
|
2019-03-21 02:56:58 +01:00
|
|
|
import { InstantiableConfig } from "../../Instantiable.abstract"
|
2018-10-29 10:53:22 +01:00
|
|
|
|
|
|
|
export default class DIDRegistry extends ContractBase {
|
|
|
|
|
2019-03-21 02:56:58 +01:00
|
|
|
public static async getInstance(config: InstantiableConfig): Promise<DIDRegistry> {
|
2018-10-29 10:53:22 +01:00
|
|
|
const didRegistry: DIDRegistry = new DIDRegistry("DIDRegistry")
|
2019-03-21 02:56:58 +01:00
|
|
|
await didRegistry.init(config)
|
2018-10-29 10:53:22 +01:00
|
|
|
return didRegistry
|
|
|
|
}
|
|
|
|
|
2019-03-25 13:47:21 +01:00
|
|
|
public async registerAttribute(did: string, checksum: string, providers: string[], value: string, ownerAddress: string) {
|
2019-04-01 17:26:42 +02:00
|
|
|
return this.send(
|
|
|
|
"registerAttribute",
|
|
|
|
ownerAddress,
|
|
|
|
[zeroX(did), Web3Provider.getWeb3().utils.fromAscii(checksum), providers.map(zeroX), 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
|
|
|
}
|
|
|
|
}
|