Skip to content

Commit

Permalink
fix: Fixed auto-load on resource & type fixes (#172)
Browse files Browse the repository at this point in the history
  • Loading branch information
Eengineer1 authored Jan 26, 2023
1 parent 40fbe7e commit aba5f50
Showing 1 changed file with 14 additions and 6 deletions.
20 changes: 14 additions & 6 deletions src/agent/ICheqd.ts
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ export class Cheqd implements IAgentPlugin {
throw new Error('[did-provider-cheqd]: keys array is required')
}

const provider = await Cheqd.loadProvider(document as unknown as DIDDocument, this.supportedDidProviders)
const provider = await Cheqd.loadProvider(<DIDDocument>args.document, this.supportedDidProviders)

this.didProvider = provider
this.providerId = Cheqd.generateProviderId(this.didProvider.network)
Expand Down Expand Up @@ -237,7 +237,7 @@ export class Cheqd implements IAgentPlugin {
throw new Error('[did-provider-cheqd]: keys array is required')
}

const provider = await Cheqd.loadProvider(document as unknown as DIDDocument, this.supportedDidProviders)
const provider = await Cheqd.loadProvider(<DIDDocument>args.document, this.supportedDidProviders)

this.didProvider = provider
this.providerId = Cheqd.generateProviderId(this.didProvider.network)
Expand Down Expand Up @@ -271,7 +271,7 @@ export class Cheqd implements IAgentPlugin {
throw new Error('[did-provider-cheqd]: keys array is required')
}

const provider = await Cheqd.loadProvider(document as unknown as DIDDocument, this.supportedDidProviders)
const provider = await Cheqd.loadProvider(<DIDDocument>args.document, this.supportedDidProviders)

this.didProvider = provider
this.providerId = Cheqd.generateProviderId(this.didProvider.network)
Expand All @@ -296,15 +296,23 @@ export class Cheqd implements IAgentPlugin {
throw new Error('[did-provider-cheqd]: payload object is required')
}

if (typeof args.payload !== 'object') {
throw new Error('[did-provider-cheqd]: payload object is required')
if (typeof args.signInputs !== 'object') {
throw new Error('[did-provider-cheqd]: signInputs array is required')
}

if (typeof args.network !== 'string') {
throw new Error('[did-provider-cheqd]: network is required')
}

this.providerId = Cheqd.generateProviderId(args.network)
this.didProvider = await Cheqd.loadProvider({ id: this.providerId } as DIDDocument, this.supportedDidProviders)

return await this.didProvider.createResource({
options: {
kms: args.kms,
payload: args.payload,
signInputs: args.signInputs
signInputs: args.signInputs,
fee: args?.fee
}
}, context)
}
Expand Down

0 comments on commit aba5f50

Please sign in to comment.