envio
Version:
A latency and sync speed optimized, developer friendly blockchain data indexer.
45 lines (36 loc) • 1.21 kB
JavaScript
// Generated by ReScript, PLEASE EDIT WITH CARE
;
var Viem = require("viem");
var Js_exn = require("rescript/lib/js/js_exn.js");
var S$RescriptSchema = require("rescript-schema/src/S.res.js");
var schema = S$RescriptSchema.setName(S$RescriptSchema.string, "Address");
function fromStringLowercaseOrThrow(string) {
if (Viem.isAddress(string)) {
return string.toLowerCase();
} else {
return Js_exn.raiseError("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 Js_exn.raiseError("Address \"" + string + "\" is invalid. Expected a 20-byte hex string starting with 0x.");
}
}
function fromAddressOrThrow(address) {
return fromStringOrThrow(address);
}
var Evm = {
fromStringLowercaseOrThrow: fromStringLowercaseOrThrow,
fromAddressLowercaseOrThrow: fromAddressLowercaseOrThrow,
fromStringOrThrow: fromStringOrThrow,
fromAddressOrThrow: fromAddressOrThrow
};
exports.schema = schema;
exports.Evm = Evm;
/* schema Not a pure module */