73 lines
2.6 KiB
JavaScript
73 lines
2.6 KiB
JavaScript
"use strict";
|
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
exports.isSilentPayload = exports.isReservedEvent = exports.isInternalEvent = exports.isJsonRpcResponseError = exports.isJsonRpcResponseSuccess = exports.isJsonRpcRequest = exports.isJsonRpcSubscription = exports.isHexString = exports.getEncoding = exports.getType = exports.isArrayBuffer = exports.isTypedArray = exports.isBuffer = exports.isEmptyArray = exports.isEmptyString = void 0;
|
|
const tslib_1 = require("tslib");
|
|
const encoding = tslib_1.__importStar(require("@walletconnect/encoding"));
|
|
const constants_1 = require("./constants");
|
|
function isEmptyString(value) {
|
|
return value === "" || (typeof value === "string" && value.trim() === "");
|
|
}
|
|
exports.isEmptyString = isEmptyString;
|
|
function isEmptyArray(array) {
|
|
return !(array && array.length);
|
|
}
|
|
exports.isEmptyArray = isEmptyArray;
|
|
function isBuffer(val) {
|
|
return encoding.isBuffer(val);
|
|
}
|
|
exports.isBuffer = isBuffer;
|
|
function isTypedArray(val) {
|
|
return encoding.isTypedArray(val);
|
|
}
|
|
exports.isTypedArray = isTypedArray;
|
|
function isArrayBuffer(val) {
|
|
return encoding.isArrayBuffer(val);
|
|
}
|
|
exports.isArrayBuffer = isArrayBuffer;
|
|
function getType(val) {
|
|
return encoding.getType(val);
|
|
}
|
|
exports.getType = getType;
|
|
function getEncoding(val) {
|
|
return encoding.getEncoding(val);
|
|
}
|
|
exports.getEncoding = getEncoding;
|
|
function isHexString(value, length) {
|
|
return encoding.isHexString(value, length);
|
|
}
|
|
exports.isHexString = isHexString;
|
|
function isJsonRpcSubscription(object) {
|
|
return typeof object.params === "object";
|
|
}
|
|
exports.isJsonRpcSubscription = isJsonRpcSubscription;
|
|
function isJsonRpcRequest(object) {
|
|
return typeof object.method !== "undefined";
|
|
}
|
|
exports.isJsonRpcRequest = isJsonRpcRequest;
|
|
function isJsonRpcResponseSuccess(object) {
|
|
return typeof object.result !== "undefined";
|
|
}
|
|
exports.isJsonRpcResponseSuccess = isJsonRpcResponseSuccess;
|
|
function isJsonRpcResponseError(object) {
|
|
return typeof object.error !== "undefined";
|
|
}
|
|
exports.isJsonRpcResponseError = isJsonRpcResponseError;
|
|
function isInternalEvent(object) {
|
|
return typeof object.event !== "undefined";
|
|
}
|
|
exports.isInternalEvent = isInternalEvent;
|
|
function isReservedEvent(event) {
|
|
return constants_1.reservedEvents.includes(event) || event.startsWith("wc_");
|
|
}
|
|
exports.isReservedEvent = isReservedEvent;
|
|
function isSilentPayload(request) {
|
|
if (request.method.startsWith("wc_")) {
|
|
return true;
|
|
}
|
|
if (constants_1.signingMethods.includes(request.method)) {
|
|
return false;
|
|
}
|
|
return true;
|
|
}
|
|
exports.isSilentPayload = isSilentPayload;
|
|
//# sourceMappingURL=validators.js.map
|