mirror of
https://github.com/pezkuwichain/pwap.git
synced 2026-04-22 02:07:55 +00:00
debug: show field lengths and try multiple field name patterns
This commit is contained in:
@@ -205,12 +205,9 @@ export function useMessaging() {
|
|||||||
);
|
);
|
||||||
return { sender: msg.sender, blockNumber: msg.blockNumber, plaintext, raw: msg };
|
return { sender: msg.sender, blockNumber: msg.blockNumber, plaintext, raw: msg };
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.error('[PEZMessage] decrypt failed:', err,
|
|
||||||
'ephPubKey len:', msg.ephemeralPublicKey?.length,
|
|
||||||
'nonce len:', msg.nonce?.length,
|
|
||||||
'ct len:', msg.ciphertext?.length);
|
|
||||||
const errText = err instanceof Error ? err.message : String(err);
|
const errText = err instanceof Error ? err.message : String(err);
|
||||||
return { sender: msg.sender, blockNumber: msg.blockNumber, plaintext: `[ERR: ${errText}]`, raw: msg };
|
const dbg = `eph:${msg.ephemeralPublicKey?.length} n:${msg.nonce?.length} ct:${msg.ciphertext?.length}`;
|
||||||
|
return { sender: msg.sender, blockNumber: msg.blockNumber, plaintext: `[${errText}] ${dbg}`, raw: msg };
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -58,19 +58,28 @@ export async function getInbox(
|
|||||||
if (result.isEmpty || result.length === 0) return [];
|
if (result.isEmpty || result.length === 0) return [];
|
||||||
|
|
||||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||||
return result.map((msg: any) => {
|
const first = result[0];
|
||||||
console.log('[PEZMessage] msg keys:', Object.keys(msg.toJSON?.() ?? msg));
|
if (first) {
|
||||||
return msg;
|
const keys = Object.getOwnPropertyNames(first).filter(k => !k.startsWith('_'));
|
||||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
const json = first.toJSON?.() ?? {};
|
||||||
}).map((msg: Record<string, any>) => ({
|
const jsonKeys = Object.keys(json);
|
||||||
sender: msg.sender.toString(),
|
console.log('[PEZMessage] field names:', keys, 'json keys:', jsonKeys, 'json:', JSON.stringify(json));
|
||||||
blockNumber: msg.blockNumber?.toNumber?.() ?? msg.block_number?.toNumber?.() ?? 0,
|
}
|
||||||
ephemeralPublicKey: hexToBytes(
|
|
||||||
msg.ephemeralPublicKey?.toHex?.() ?? msg.ephemeral_public_key?.toHex?.() ?? '0x'
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||||
),
|
return result.map((msg: Record<string, any>) => {
|
||||||
nonce: hexToBytes(msg.nonce.toHex()),
|
// Try multiple field name patterns
|
||||||
ciphertext: hexToBytes(msg.ciphertext.toHex()),
|
const eph = msg.ephemeralPublicKey ?? msg.ephemeral_public_key ?? msg.ephemeralPubKey ?? msg.ephemeral_pub_key;
|
||||||
}));
|
const blk = msg.blockNumber ?? msg.block_number ?? msg.blockNum;
|
||||||
|
const ct = msg.ciphertext ?? msg.cipher_text;
|
||||||
|
return {
|
||||||
|
sender: msg.sender.toString(),
|
||||||
|
blockNumber: blk?.toNumber?.() ?? 0,
|
||||||
|
ephemeralPublicKey: hexToBytes(eph?.toHex?.() ?? '0x'),
|
||||||
|
nonce: hexToBytes(msg.nonce?.toHex?.() ?? '0x'),
|
||||||
|
ciphertext: hexToBytes(ct?.toHex?.() ?? '0x'),
|
||||||
|
};
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function getSendCount(
|
export async function getSendCount(
|
||||||
|
|||||||
Reference in New Issue
Block a user