Skip to content

Commit

Permalink
feat: Registry config
Browse files Browse the repository at this point in the history
  • Loading branch information
simonas-notcat committed May 13, 2020
1 parent 5a3391e commit fe2ebc6
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
15 changes: 13 additions & 2 deletions packages/daf-ethr-did/src/identity-controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ export class IdentityController extends AbstractIdentityController {
private address: string
private gas?: number
private ttl?: number
private registry?: string

constructor(options: {
did: string
Expand All @@ -23,6 +24,7 @@ export class IdentityController extends AbstractIdentityController {
address: string
ttl?: number
gas?: number
registry?: string
}) {
super()
this.did = options.did
Expand All @@ -32,10 +34,15 @@ export class IdentityController extends AbstractIdentityController {
this.address = options.address
this.ttl = options.ttl || DEFAULT_TTL
this.gas = options.gas || DEFAULT_GAS
this.registry = options.registry
}

async addService(service: { id: string; type: string; serviceEndpoint: string }): Promise<any> {
const ethrDid = new EthrDID({ address: this.address, provider: this.web3Provider })
const ethrDid = new EthrDID({
address: this.address,
provider: this.web3Provider,
registry: this.registry
})

const attribute = 'did/svc/' + service.type
const value = service.serviceEndpoint
Expand All @@ -53,7 +60,11 @@ export class IdentityController extends AbstractIdentityController {

async addPublicKey(type: 'Ed25519' | 'Secp256k1', proofPurpose?: string[]): Promise<any> {
const serializedIdentity = await this.identityStore.get(this.did)
const ethrDid = new EthrDID({ address: this.address, provider: this.web3Provider })
const ethrDid = new EthrDID({
address: this.address,
provider: this.web3Provider,
registry: this.registry
})

const key = await this.kms.createKey(type)

Expand Down
3 changes: 3 additions & 0 deletions packages/daf-ethr-did/src/identity-provider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ export class IdentityProvider extends AbstractIdentityProvider {
private identityStore: AbstractIdentityStore
private gas?: number
private ttl?: number
private registry?: string

constructor(options: {
kms: AbstractKeyManagementSystem
Expand All @@ -38,6 +39,7 @@ export class IdentityProvider extends AbstractIdentityProvider {
web3Provider?: object
ttl?: number
gas?: number
registry?: string
}) {
super()
this.kms = options.kms
Expand All @@ -49,6 +51,7 @@ export class IdentityProvider extends AbstractIdentityProvider {
this.description = 'did:ethr ' + options.network + ' ' + this.description
this.ttl = options.ttl
this.gas = options.gas
this.registry = options.registry
}

private async identityFromSerialized(serializedIdentity: SerializedIdentity): Promise<AbstractIdentity> {
Expand Down

0 comments on commit fe2ebc6

Please sign in to comment.