Skip to content

Commit 230430c

Browse files
committed
Add debug logging to Ethereum EDV module.
- Add console.log statements to trace EDV access and creation flow. - Log available meters and their referenceIds for debugging. - Add logging to key storage operations in keys.js. - Use globalThis.crypto.randomUUID() instead of uuid package in keys.js. NOTE: Debug console.log statements will be removed before final PR approval.
1 parent a8c1218 commit 230430c

File tree

2 files changed

+29
-8
lines changed

2 files changed

+29
-8
lines changed

lib/ethereum/edv.js

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,24 +31,37 @@ export async function getEthereumEdv({profileId} = {}) {
3131
referenceIdPrefix: ETHEREUM_EDV_REFERENCE_ID
3232
}));
3333
} catch(e) {
34+
console.log('EDV access error:', e.message);
3435
// EDV doesn't exist, create it
3536
const meters = await profileManager.getProfileMeters({profileId});
37+
console.log('Available meters:', JSON.stringify(meters, null, 2));
38+
39+
// Log all referenceIds to see what's available
40+
console.log('All referenceIds:',
41+
meters?.map(m => m.referenceId || m.meter?.referenceId));
42+
3643
const edvMeter = meters.find(m => m.referenceId === 'profile:core:edv');
44+
console.log('EDV meter found:', JSON.stringify(edvMeter, null, 2));
3745

3846
if(!edvMeter) {
3947
throw new Error('No EDV meter found for profile.');
4048
}
4149

50+
console.log('Using meterId:', edvMeter.id);
51+
4252
({edvClient} = await profileManager.createProfileEdv({
4353
profileId,
4454
meterId: edvMeter.id,
4555
referenceId: ETHEREUM_EDV_REFERENCE_ID
4656
}));
47-
48-
// Ensure indexes for efficient queries
49-
edvClient.ensureIndex({attribute: 'content.type', unique: false});
50-
edvClient.ensureIndex({attribute: 'content.address', unique: false});
5157
}
5258

59+
// Ensure indexes for efficient queries
60+
edvClient.ensureIndex({attribute: 'content.type', unique: false});
61+
edvClient.ensureIndex({attribute: 'content.address', unique: false});
62+
63+
console.log(`profileId: ${profileId}`);
64+
// console.log(`edvClient: ${JSON.stringify(edvClient)}`);
65+
5366
return {profileId, edvClient};
5467
}

lib/ethereum/keys.js

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
11
/*!
22
* Copyright (c) 2025 Digital Bazaar, Inc. All rights reserved.
33
*/
4-
import {v4 as uuid} from 'uuid';
4+
import {EdvClient} from '@digitalbazaar/edv-client';
5+
// TODO: Confirm with Dave Longley if it is right to use in web-wallet
6+
// package or not?
7+
// To my understanding correct usage of edv-client package will be the
8+
// frontend e.g., vue-wallet maybe.
59

610
const DOCUMENT_TYPE = 'EthereumKeyDocument';
711

@@ -39,9 +43,9 @@ export async function storeKey({
3943
}
4044

4145
const doc = {
42-
id: await edvClient.generatedId(),
46+
id: await EdvClient.generateId(),
4347
content: {
44-
id: `urn:uuid:${uuid()}`,
48+
id: `urn:uuid:${globalThis.crypto.randomUUID()}`,
4549
type: DOCUMENT_TYPE,
4650
address: address.toLowerCase(),
4751
privateKey,
@@ -53,7 +57,11 @@ export async function storeKey({
5357
}
5458
};
5559

56-
return edvClient.insert({doc});
60+
console.log('Storing document:', doc.id);
61+
const result = await edvClient.insert({doc});
62+
console.log('Document stored successfully:', result.id);
63+
64+
return result;
5765
}
5866

5967
/**

0 commit comments

Comments
 (0)