Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
constructor(genesisBlock, config = {}) {
const errors = liskValidator.validate(genesisBlockSchema, genesisBlock);
if (errors.length) {
throw errors;
}
// Don't change the object parameters provided
let appConfig = _.cloneDeep(config);
if (!_.has(appConfig, 'app.label')) {
_.set(
appConfig,
'app.label',
`lisk-${genesisBlock.payloadHash.slice(0, 7)}`,
);
}
if (!_.has(appConfig, 'components.logger.logFileName')) {
public constructor(rawTransaction: unknown) {
super(rawTransaction);
const tx = (typeof rawTransaction === 'object' && rawTransaction !== null
? rawTransaction
: {}) as Partial;
// Initializes to empty object if it doesn't exist
if (tx.asset) {
const rawAsset = tx.asset as RawAsset;
this.asset = {
data: rawAsset.data,
recipientId: rawAsset.recipientId,
amount: new BigNum(
isPositiveNumberString(rawAsset.amount) ? rawAsset.amount : '0',
),
};
} else {
// tslint:disable-next-line no-object-literal-type-assertion
this.asset = {
amount: new BigNum('0'),
recipientId: '',
} as TransferAsset;
}
}
async handleRPCGetTransactions(data = {}, peerId) {
await this._addRateLimit(
'getTransactions',
peerId,
DEFAULT_RATE_LIMIT_FREQUENCY,
);
const errors = validator.validate(schemas.getTransactionsRequest, data);
if (errors.length) {
this.logger.warn(
{ err: errors, peerId },
'Received invalid transactions body',
);
await this.channel.invoke('network:applyPenalty', {
peerId,
penalty: 100,
});
throw errors;
}
const { transactionIds } = data;
if (!transactionIds) {
return {
transactions: this.transactionPoolModule.getMergedTransactionList(
async handleEventPostSignatures(data, peerId) {
await this._addRateLimit(
'postSignatures',
peerId,
DEFAULT_RATE_LIMIT_FREQUENCY,
);
const errors = validator.validate(schemas.postSignatureEvent, data);
if (errors.length) {
this.logger.warn({ err: errors }, 'Invalid signatures body');
await this.channel.invoke('network:applyPenalty', {
peerId,
penalty: 100,
});
throw errors;
}
for (const signature of data.signatures) {
const signatureObjectErrors = validator.validate(
schemas.signatureObject,
signature,
);
async run(): Promise {
const {
args,
flags: {
networkIdentifier: networkIdentifierSource,
passphrase: passphraseSource,
'second-passphrase': secondPassphraseSource,
'no-signature': noSignature,
},
} = this.parse(MultisignatureCommand);
const { lifetime, minimum, keysgroup: keysgroupStr }: Args = args;
const keysgroup = keysgroupStr.split(',');
validatePublicKeys(keysgroup);
validateLifetime(lifetime);
validateMinimum(minimum);
const transactionLifetime = parseInt(lifetime, 10);
const transactionMinimumConfirmations = parseInt(minimum, 10);
const networkIdentifier = getNetworkIdentifierWithInput(
networkIdentifierSource,
this.userConfig.api.network,
);
const processFunction = processInputs(
networkIdentifier,
transactionLifetime,
transactionMinimumConfirmations,
keysgroup,
);
const validateSchema = ({ block }) => {
const errors = validator.validate(blockSchema, block);
if (errors.length) {
throw errors;
}
};
protected validateAsset(): ReadonlyArray {
const schemaErrors = validator.validate(
secondSignatureAssetFormatSchema,
this.asset,
);
const errors = convertToAssetError(
this.id,
schemaErrors,
) as TransactionError[];
return errors;
}
const objectNormalize = (block, exceptions = {}) => {
Object.keys(block).forEach(key => {
if (block[key] === null || typeof block[key] === 'undefined') {
delete block[key];
}
});
const errors = validator.validate(blockSchema, block);
if (errors.length) {
throw errors;
}
const { transactionsResponses } = validateTransactions(exceptions)(
block.transactions
);
const invalidTransactionResponse = transactionsResponses.find(
transactionResponse => transactionResponse.status !== TransactionStatus.OK
);
if (invalidTransactionResponse) {
throw invalidTransactionResponse.errors;
}
return block;
};
const validateSchema = ({ block }) => {
const errors = validator.validate(baseBlockSchema, block);
if (errors.length) {
throw errors;
}
};
const objectNormalize = (block, exceptions = {}) => {
Object.keys(block).forEach(key => {
if (block[key] === null || typeof block[key] === 'undefined') {
delete block[key];
}
});
const errors = validator.validate(blockSchema, block);
if (errors.length) {
throw errors;
}
const { transactionsResponses } = validateTransactions(exceptions)(
block.transactions
);
const invalidTransactionResponse = transactionsResponses.find(
transactionResponse => transactionResponse.status !== TransactionStatus.OK
);
if (invalidTransactionResponse) {
throw invalidTransactionResponse.errors;
}
return block;
};