From 60a14838b4952d6fdcd68989514a105df7dfa004 Mon Sep 17 00:00:00 2001 From: DaevMithran Date: Mon, 6 Feb 2023 14:59:21 +0530 Subject: [PATCH 1/2] fix: Handle empty address condition --- src/modules/did.ts | 12 ++++++++++++ src/modules/resource.ts | 4 ++++ 2 files changed, 16 insertions(+) diff --git a/src/modules/did.ts b/src/modules/did.ts index e1923252..a6b8e2c9 100644 --- a/src/modules/did.ts +++ b/src/modules/did.ts @@ -168,6 +168,10 @@ export class DIDModule extends AbstractCheqdSDKModule { value } + if (address === '') { + address = (await context!.sdk!.options.wallet.getAccounts())[0].address + } + if (!fee) { fee = await DIDModule.generateCreateDidDocFees(address) } @@ -226,6 +230,10 @@ export class DIDModule extends AbstractCheqdSDKModule { value } + if (address === '') { + address = (await context!.sdk!.options.wallet.getAccounts())[0].address + } + if (!fee) { fee = await DIDModule.generateUpdateDidDocFees(address) } @@ -275,6 +283,10 @@ export class DIDModule extends AbstractCheqdSDKModule { value } + if (address === '') { + address = (await context!.sdk!.options.wallet.getAccounts())[0].address + } + if (!fee) { fee = await DIDModule.generateDeactivateDidDocFees(address) } diff --git a/src/modules/resource.ts b/src/modules/resource.ts index 7fb21c58..0a043b95 100644 --- a/src/modules/resource.ts +++ b/src/modules/resource.ts @@ -78,6 +78,10 @@ export class ResourceModule extends AbstractCheqdSDKModule { value: msg } + if (address === '') { + address = (await context!.sdk!.options.wallet.getAccounts())[0].address + } + if (!fee) { if (payload.data.length === 0) { throw new Error('Linked resource data is empty') From 3ddab24199bc6014d628c89778c5fd3f1a6552a4 Mon Sep 17 00:00:00 2001 From: Tasos Derisiotis <50984242+Eengineer1@users.noreply.github.com> Date: Mon, 6 Feb 2023 11:55:09 +0200 Subject: [PATCH 2/2] Cleanup --- src/modules/did.ts | 6 +++--- src/modules/resource.ts | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/modules/did.ts b/src/modules/did.ts index a6b8e2c9..084e88c4 100644 --- a/src/modules/did.ts +++ b/src/modules/did.ts @@ -169,7 +169,7 @@ export class DIDModule extends AbstractCheqdSDKModule { } if (address === '') { - address = (await context!.sdk!.options.wallet.getAccounts())[0].address + address = (await context!.sdk!.options.wallet.getAccounts())[0].address } if (!fee) { @@ -231,7 +231,7 @@ export class DIDModule extends AbstractCheqdSDKModule { } if (address === '') { - address = (await context!.sdk!.options.wallet.getAccounts())[0].address + address = (await context!.sdk!.options.wallet.getAccounts())[0].address } if (!fee) { @@ -284,7 +284,7 @@ export class DIDModule extends AbstractCheqdSDKModule { } if (address === '') { - address = (await context!.sdk!.options.wallet.getAccounts())[0].address + address = (await context!.sdk!.options.wallet.getAccounts())[0].address } if (!fee) { diff --git a/src/modules/resource.ts b/src/modules/resource.ts index 0a043b95..02959be6 100644 --- a/src/modules/resource.ts +++ b/src/modules/resource.ts @@ -79,7 +79,7 @@ export class ResourceModule extends AbstractCheqdSDKModule { } if (address === '') { - address = (await context!.sdk!.options.wallet.getAccounts())[0].address + address = (await context!.sdk!.options.wallet.getAccounts())[0].address } if (!fee) {