@exromany/lido-csm-sdk
Version:
[](https://github.com/lidofinance/lido-csm-sdk/blob/main/LICENSE.txt) [](h
46 lines • 2.15 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.checkItem = void 0;
const compare_lowercase_js_1 = require("../../common/utils/compare-lowercase.js");
const is_hexadecimal_string_js_1 = require("../../common/utils/is-hexadecimal-string.js");
const constants_js_1 = require("./constants.js");
const checkItem = (data, chainId, wc) => {
if (typeof data.pubkey !== 'string' ||
data.pubkey.length !== constants_js_1.PUBKEY_LENGTH ||
!(0, is_hexadecimal_string_js_1.isHexadecimalString)(data.pubkey)) {
return 'pubkey is not valid string';
}
if (typeof data.signature !== 'string' ||
data.signature.length !== constants_js_1.SIGNATURE_LENGTH ||
!(0, is_hexadecimal_string_js_1.isHexadecimalString)(data.signature)) {
return 'signature is not valid string';
}
if (typeof data.deposit_message_root !== 'string') {
return 'deposit_message_root is not a string';
}
if (typeof data.deposit_data_root !== 'string') {
return 'deposit_data_root is not a string';
}
if (typeof data.withdrawal_credentials !== 'string') {
return 'withdrawal_credentials is not a string';
}
if (data.amount !== constants_js_1.FIXED_AMOUNT) {
return 'amount is not equal to 32 eth';
}
const networkNames = constants_js_1.FIXED_NETWORK[chainId];
if (!networkNames?.includes(data.network_name ||
data.eth2_network_name)) {
const networks = networkNames?.join(', ');
return `network_name or eth2_network_name is not equal to ${networks}`;
}
const forkVersion = constants_js_1.FIXED_FORK_VERSION[chainId];
if (data.fork_version !== forkVersion) {
return `fork_version is not equal to ${forkVersion}`;
}
if (!(0, compare_lowercase_js_1.compareLowercase)(data.withdrawal_credentials, `${constants_js_1.FIXED_WC_PREFIX}${wc}`) &&
!(0, compare_lowercase_js_1.compareLowercase)(data.withdrawal_credentials, `${wc}`)) {
return `withdrawal_credentials is not equal to ${wc}`;
}
};
exports.checkItem = checkItem;
//# sourceMappingURL=check-item.js.map