mirror of
https://github.com/luxfi/explore.git
synced 2026-09-24 00:28:18 +00:00
* create settings context with simple address format toggler * transform base16 hash to bech32 hash * add ENV variables * add snippet to address page * add redirect for bech32 addresses * change address format in search * add provider to tests * update demo values * migrate from Buffer to Uint8Array and add tests * bug fixes and screenshots updates * review fixes * roll back changes in env values * update screenshots
10 lines
338 B
TypeScript
10 lines
338 B
TypeScript
// hex can be with prefix - `0x{string}` - or without it - `{string}`
|
|
export default function hexToBytes(hex: string) {
|
|
const bytes = [];
|
|
const startIndex = hex.startsWith('0x') ? 2 : 0;
|
|
for (let c = startIndex; c < hex.length; c += 2) {
|
|
bytes.push(parseInt(hex.substring(c, c + 2), 16));
|
|
}
|
|
return new Uint8Array(bytes);
|
|
}
|