File tree Expand file tree Collapse file tree 1 file changed +9
-2
lines changed
governance/xc_admin/packages/xc_admin_common/src/governance_payload Expand file tree Collapse file tree 1 file changed +9
-2
lines changed Original file line number Diff line number Diff line change @@ -5,14 +5,21 @@ export class UInt64BE extends Layout<bigint> {
5
5
super ( span , property ) ;
6
6
}
7
7
8
+ // Note: we can not use read/writeBigUInt64BE because it is not supported in the browsers
8
9
override decode ( b : Uint8Array , offset ?: number ) : bigint {
9
10
let o = offset ?? 0 ;
10
- return Buffer . from ( b . slice ( o , o + this . span ) ) . readBigUInt64BE ( ) ;
11
+ const buffer = Buffer . from ( b . slice ( o , o + this . span ) ) ;
12
+ const hi32 = buffer . readUInt32BE ( ) ;
13
+ const lo32 = buffer . readUInt32BE ( 4 ) ;
14
+ return BigInt ( lo32 ) + ( BigInt ( hi32 ) << BigInt ( 32 ) ) ;
11
15
}
12
16
13
17
override encode ( src : bigint , b : Uint8Array , offset ?: number ) : number {
14
18
const buffer = Buffer . alloc ( this . span ) ;
15
- buffer . writeBigUint64BE ( src ) ;
19
+ const hi32 = Number ( src >> BigInt ( 32 ) ) ;
20
+ const lo32 = Number ( src & BigInt ( 0xffffffff ) ) ;
21
+ buffer . writeUInt32BE ( hi32 , 0 ) ;
22
+ buffer . writeUInt32BE ( lo32 , 4 ) ;
16
23
b . set ( buffer , offset ) ;
17
24
return this . span ;
18
25
}
You can’t perform that action at this time.
0 commit comments