Spaces:
Sleeping
Sleeping
Download meteora/node_modules/@solana/buffer-layout-utils/src/bigint.ts from Trireme/hyper_dashboard: direct link, hf CLI and curl.
- Browser
- Download file 1.81 kB
-
https://huggingface.co/spaces/Trireme/hyper_dashboard/resolve/main/meteora/node_modules/%40solana/buffer-layout-utils/src/bigint.ts
- Command line
-
hf download hf://spaces/Trireme/hyper_dashboard/meteora/node_modules/@solana/buffer-layout-utils/src/bigint.ts
-
curl -L -o bigint.ts https://huggingface.co/spaces/Trireme/hyper_dashboard/resolve/main/meteora/node_modules/%40solana/buffer-layout-utils/src/bigint.ts
1.81 kB
| import { blob, Layout } from '@solana/buffer-layout'; | |
| import { toBigIntBE, toBigIntLE, toBufferBE, toBufferLE } from 'bigint-buffer'; | |
| import { encodeDecode } from './base'; | |
| export const bigInt = | |
| (length: number) => | |
| (property?: string): Layout<bigint> => { | |
| const layout = blob(length, property); | |
| const { encode, decode } = encodeDecode(layout); | |
| const bigIntLayout = layout as Layout<unknown> as Layout<bigint>; | |
| bigIntLayout.decode = (buffer: Buffer, offset: number) => { | |
| const src = decode(buffer, offset); | |
| return toBigIntLE(Buffer.from(src)); | |
| }; | |
| bigIntLayout.encode = (bigInt: bigint, buffer: Buffer, offset: number) => { | |
| const src = toBufferLE(bigInt, length); | |
| return encode(src, buffer, offset); | |
| }; | |
| return bigIntLayout; | |
| }; | |
| export const bigIntBE = | |
| (length: number) => | |
| (property?: string): Layout<bigint> => { | |
| const layout = blob(length, property); | |
| const { encode, decode } = encodeDecode(layout); | |
| const bigIntLayout = layout as Layout<unknown> as Layout<bigint>; | |
| bigIntLayout.decode = (buffer: Buffer, offset: number) => { | |
| const src = decode(buffer, offset); | |
| return toBigIntBE(Buffer.from(src)); | |
| }; | |
| bigIntLayout.encode = (bigInt: bigint, buffer: Buffer, offset: number) => { | |
| const src = toBufferBE(bigInt, length); | |
| return encode(src, buffer, offset); | |
| }; | |
| return bigIntLayout; | |
| }; | |
| export const u64 = bigInt(8); | |
| export const u64be = bigIntBE(8); | |
| export const u128 = bigInt(16); | |
| export const u128be = bigIntBE(16); | |
| export const u192 = bigInt(24); | |
| export const u192be = bigIntBE(24); | |
| export const u256 = bigInt(32); | |
| export const u256be = bigIntBE(32); | |