Skip to content

Commit 4d1c0dd

Browse files
authored
fix: ensure bigints are bigints (#177)
Protobufjs returns bigints as numbers. Can be reverted by switching to protons.
1 parent 7910c71 commit 4d1c0dd

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

src/utils.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,16 @@ export const marshal = (obj: IPNSEntry): Uint8Array => {
123123
export const unmarshal = (buf: Uint8Array): IPNSEntry => {
124124
const message = IpnsEntry.decode(buf)
125125

126+
// protobufjs returns bigints as numbers
127+
if (message.sequence != null) {
128+
message.sequence = BigInt(message.sequence)
129+
}
130+
131+
// protobufjs returns bigints as numbers
132+
if (message.ttl != null) {
133+
message.ttl = BigInt(message.ttl)
134+
}
135+
126136
return {
127137
value: message.value ?? new Uint8Array(0),
128138
signature: message.signature ?? new Uint8Array(0),

0 commit comments

Comments
 (0)