mirror of
https://github.com/logos-messaging/logos-messaging-js.git
synced 2026-01-22 09:53:08 +00:00
fix: convert bigint to string when serializing membership
This commit is contained in:
parent
66ba9f0af0
commit
a1c8f6e907
@ -160,7 +160,15 @@ export class Keystore {
|
||||
}
|
||||
|
||||
public toString(): string {
|
||||
return JSON.stringify(this.data);
|
||||
// Custom replacer function to handle BigInt serialization
|
||||
const bigIntReplacer = (_key: string, value: unknown): unknown => {
|
||||
if (typeof value === "bigint") {
|
||||
return value.toString();
|
||||
}
|
||||
return value;
|
||||
};
|
||||
|
||||
return JSON.stringify(this.data, bigIntReplacer);
|
||||
}
|
||||
|
||||
public toObject(): NwakuKeystore {
|
||||
@ -327,21 +335,32 @@ export class Keystore {
|
||||
const { IDCommitment, IDNullifier, IDSecretHash, IDTrapdoor } =
|
||||
options.identity;
|
||||
|
||||
// Custom replacer function to handle BigInt serialization
|
||||
const bigIntReplacer = (_key: string, value: unknown): unknown => {
|
||||
if (typeof value === "bigint") {
|
||||
return value.toString();
|
||||
}
|
||||
return value;
|
||||
};
|
||||
|
||||
return utf8ToBytes(
|
||||
JSON.stringify({
|
||||
treeIndex: options.membership.treeIndex,
|
||||
identityCredential: {
|
||||
idCommitment: Array.from(IDCommitment),
|
||||
idNullifier: Array.from(IDNullifier),
|
||||
idSecretHash: Array.from(IDSecretHash),
|
||||
idTrapdoor: Array.from(IDTrapdoor)
|
||||
JSON.stringify(
|
||||
{
|
||||
treeIndex: options.membership.treeIndex,
|
||||
identityCredential: {
|
||||
idCommitment: Array.from(IDCommitment),
|
||||
idNullifier: Array.from(IDNullifier),
|
||||
idSecretHash: Array.from(IDSecretHash),
|
||||
idTrapdoor: Array.from(IDTrapdoor)
|
||||
},
|
||||
membershipContract: {
|
||||
chainId: options.membership.chainId,
|
||||
address: options.membership.address
|
||||
},
|
||||
userMessageLimit: options.membership.rateLimit
|
||||
},
|
||||
membershipContract: {
|
||||
chainId: options.membership.chainId,
|
||||
address: options.membership.address
|
||||
},
|
||||
userMessageLimit: options.membership.rateLimit
|
||||
})
|
||||
bigIntReplacer
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user