From ac51e7f2815e2fc02ec71f148fc7e7c3dc082611 Mon Sep 17 00:00:00 2001 From: Maycon Mello Date: Wed, 10 Jan 2024 18:01:47 -0300 Subject: [PATCH 1/2] fixing sentry issue with transaction history --- packages/transactions/lib/transactions.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/packages/transactions/lib/transactions.js b/packages/transactions/lib/transactions.js index cc89ee51..27fa4834 100644 --- a/packages/transactions/lib/transactions.js +++ b/packages/transactions/lib/transactions.js @@ -93,7 +93,7 @@ export const TransactionEvents = { async function getAllTransactions() { try { const data = await getLocalStorage().getItem('transactions'); - return JSON.parse(data); + return JSON.parse(data) || []; } catch (err) { return []; } @@ -207,8 +207,11 @@ export class Transactions { return; } + let dbTransactions = await getAllTransactions(); - const dbTransactions = await getAllTransactions(); + if (!dbTransactions) { + dbTransactions = []; + } const handleTransaction = tx => { if (tx.from !== address && tx.to !== address) { From 3ee1b4c49a6d1b501d30e74bb74fdb50a7dff3e2 Mon Sep 17 00:00:00 2001 From: Maycon Mello Date: Wed, 10 Jan 2024 21:24:23 -0300 Subject: [PATCH 2/2] better error logging for didcomm resolvers + wallet-sdk-cli command --- packages/cli/src/commands/dids.ts | 22 ++++++++++++++++++++++ packages/relay-service/src/index.js | 7 ++++++- 2 files changed, 28 insertions(+), 1 deletion(-) diff --git a/packages/cli/src/commands/dids.ts b/packages/cli/src/commands/dids.ts index 8fa50166..e574b68f 100644 --- a/packages/cli/src/commands/dids.ts +++ b/packages/cli/src/commands/dids.ts @@ -3,6 +3,7 @@ import inquirer from 'inquirer'; import axios from 'axios'; import {IWallet} from '@docknetwork/wallet-sdk-core/lib/types'; import {createDIDProvider} from '@docknetwork/wallet-sdk-core/src/did-provider'; +import {relayService} from '@docknetwork/wallet-sdk-wasm/lib/services/relay-service'; import {getWallet} from '../helpers'; const didsCommand = new Command('dids').description('list, create'); @@ -40,4 +41,25 @@ didsCommand console.log(did); }); +/** + * Resolve a DIDComm message + * Ex.: didcomm://https://relay.dock.io/read/659ed4b1655cf81a6a35e140' + */ +didsCommand + .command('resolve-message') + .option('-m, --message ', 'Message to be resolved') + .description('Resolve didcomm message') + .action(async ({ message }) => { + const wallet: IWallet = await getWallet(); + const didProvider = createDIDProvider({wallet}); + const keyPairDocs = await didProvider.getDIDKeyPairs(); + + const messsage = await relayService.resolveDidcommMessage({ + message, + keyPairDocs, + }); + + console.log(messsage); + }); + export {didsCommand}; diff --git a/packages/relay-service/src/index.js b/packages/relay-service/src/index.js index a045e0df..f94722c8 100644 --- a/packages/relay-service/src/index.js +++ b/packages/relay-service/src/index.js @@ -232,7 +232,12 @@ export async function resolveDidcommMessage({keyPairDocs, message}) { didCommRecipients.find(did => did.indexOf(doc.controller) > -1), ); - assert(!!keyPairDoc, `keyPairDoc not found for did ${message.to}`); + assert( + !!keyPairDoc, + `keyPairDoc not found for recipients ${JSON.stringify( + didCommRecipients, + )}`, + ); const keyAgreementKey = await getDerivedAgreementKey(keyPairDoc); result = await didcommDecrypt(jwe, keyAgreementKey); }