UNPKG

envio

Version:

A latency and sync speed optimized, developer friendly blockchain data indexer.

87 lines (71 loc) 1.54 kB
// Generated by ReScript, PLEASE EDIT WITH CARE import * as Viem from "viem"; import * as Primitive_option from "@rescript/runtime/lib/es6/Primitive_option.js"; function toTwosComplement(num, bytesLen) { let maxValue = (1n << BigInt((bytesLen << 3))); let mask = maxValue - 1n; return num + maxValue & mask; } function fromSignedBigInt(val) { let val$1 = val >= 0n ? val : toTwosComplement(val, 32); return Viem.numberToHex(val$1, { size: 32 }); } function keccak256(prim) { return Viem.keccak256(prim); } function bytesToHex(prim0, prim1) { return Viem.bytesToHex(prim0, prim1 !== undefined ? Primitive_option.valFromOption(prim1) : undefined); } function concat(prim) { return Viem.concat(prim); } function castToHexUnsafe(val) { return val; } function fromBigInt(val) { return Viem.numberToHex(val, { size: 32 }); } function fromDynamicString(val) { return Viem.keccak256(val); } function fromString(val) { return Viem.stringToHex(val, { size: 32 }); } function fromAddress(addr) { return Viem.pad(addr); } function fromDynamicBytes(bytes) { return Viem.keccak256(bytes); } function fromBytes(bytes) { return Viem.bytesToHex(bytes, { size: 32 }); } function fromBool(b) { return Viem.boolToHex(b, { size: 32 }); } export { toTwosComplement, fromSignedBigInt, keccak256, bytesToHex, concat, castToHexUnsafe, fromBigInt, fromDynamicString, fromString, fromAddress, fromDynamicBytes, fromBytes, fromBool, } /* viem Not a pure module */