envio
Version:
A latency and sync speed optimized, developer friendly blockchain data indexer.
43 lines (34 loc) • 1.2 kB
JavaScript
// Generated by ReScript, PLEASE EDIT WITH CARE
import * as Viem from "viem";
import * as Stdlib_JsError from "@rescript/runtime/lib/es6/Stdlib_JsError.js";
import * as S$RescriptSchema from "rescript-schema/src/S.res.mjs";
let schema = S$RescriptSchema.setName(S$RescriptSchema.string, "Address");
function fromStringLowercaseOrThrow(string) {
if (Viem.isAddress(string)) {
return string.toLowerCase();
} else {
return Stdlib_JsError.throwWithMessage(`Address "` + string + `" is invalid. Expected a 20-byte hex string starting with 0x.`);
}
}
function fromAddressLowercaseOrThrow(address) {
return address.toLowerCase();
}
function fromStringOrThrow(string) {
try {
return Viem.getAddress(string);
} catch (exn) {
return Stdlib_JsError.throwWithMessage(`Address "` + string + `" is invalid. Expected a 20-byte hex string starting with 0x.`);
}
}
let fromAddressOrThrow = fromStringOrThrow;
let Evm = {
fromStringLowercaseOrThrow: fromStringLowercaseOrThrow,
fromAddressLowercaseOrThrow: fromAddressLowercaseOrThrow,
fromStringOrThrow: fromStringOrThrow,
fromAddressOrThrow: fromAddressOrThrow
};
export {
schema,
Evm,
}
/* schema Not a pure module */