Skip to content

Commit

Permalink
fix: Switch to LinkedResource type (#183)
Browse files Browse the repository at this point in the history
* fix: Resource file type conversion && Remove address

* Switched inputs to align with Linked Resource type

---------

Co-authored-by: Tasos Derisiotis <50984242+Eengineer1@users.noreply.github.com>
  • Loading branch information
DaevMithran and Eengineer1 committed Feb 6, 2023
1 parent 6526541 commit 434c6fb
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
4 changes: 4 additions & 0 deletions src/agent/ICheqd.ts
Original file line number Diff line number Diff line change
Expand Up @@ -346,6 +346,10 @@ export class Cheqd implements IAgentPlugin {
args.payload.data = toString(await Cheqd.getFile(args.file), 'base64')
}

if (typeof args?.payload?.data === 'string') {
args.payload.data = fromString(args.payload.data, 'base64')
}

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

Expand Down
11 changes: 5 additions & 6 deletions src/did-manager/cheqd-did-provider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,6 @@ export class CheqdDIDProvider extends AbstractIdentifierProvider {
private readonly cosmosPayerWallet: Promise<DirectSecp256k1HdWallet | DirectSecp256k1Wallet>
private sdk?: CheqdSDK
private fee?: DidStdFee
private address?: string

constructor(options: { defaultKms: string, cosmosPayerSeed: string, networkType?: NetworkType, rpcUrl?: string }) {
super()
Expand Down Expand Up @@ -97,7 +96,7 @@ export class CheqdDIDProvider extends AbstractIdentifierProvider {

this.sdk = await createCheqdSDK(sdkOptions)
this.fee = fee
this.address = (await wallet.getAccounts())[0].address

if (this?.fee && !this?.fee?.payer) {
const feePayer = (await (await this.cosmosPayerWallet).getAccounts())[0].address
this.fee.payer = feePayer
Expand All @@ -117,7 +116,7 @@ export class CheqdDIDProvider extends AbstractIdentifierProvider {
const tx = await sdk.createDidTx(
signInputs,
options.document,
this.address!,
'',
this?.fee,
undefined,
options?.versionId,
Expand Down Expand Up @@ -172,7 +171,7 @@ export class CheqdDIDProvider extends AbstractIdentifierProvider {
const tx = await sdk.updateDidTx(
signInputs,
document as DIDDocument,
this.address!,
'',
this?.fee,
undefined,
options?.versionId,
Expand Down Expand Up @@ -227,7 +226,7 @@ export class CheqdDIDProvider extends AbstractIdentifierProvider {
const tx = await sdk.deactivateDidTx(
signInputs,
document as DIDDocument,
this.address!,
'',
this?.fee,
undefined,
undefined,
Expand All @@ -250,7 +249,7 @@ export class CheqdDIDProvider extends AbstractIdentifierProvider {
const tx = await sdk.createResourceTx(
options.signInputs,
options.payload,
this.address!,
'',
this?.fee,
undefined,
{ sdk: sdk }
Expand Down

0 comments on commit 434c6fb

Please sign in to comment.