UNPKG

lisk-framework

Version:

Lisk blockchain application platform

791 lines 25.1 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.getExpectedSharedRewardsResponseSchema = exports.getExpectedSharedRewardsRequestSchema = exports.getRegistrationFeeResponseSchema = exports.getPendingUnlocksResponseSchema = exports.getPendingUnlocksRequestSchema = exports.getLockedStakedAmountResponseSchema = exports.getLockedStakedAmountRequestSchema = exports.getClaimableRewardsResponseSchema = exports.getClaimableRewardsRequestSchema = exports.getLockedRewardResponseSchema = exports.getLockedRewardRequestSchema = exports.getValidatorsByStakeResponseSchema = exports.getValidatorsByStakeRequestSchema = exports.getPoSTokenIDResponseSchema = exports.getAllValidatorsResponseSchema = exports.getStakerResponseSchema = exports.getStakerRequestSchema = exports.getConstantsResponseSchema = exports.getValidatorResponseSchema = exports.getValidatorRequestSchema = exports.genesisStoreSchema = exports.configSchema = exports.changeCommissionCommandParamsSchema = exports.reportMisbehaviorCommandParamsSchema = exports.stakeCommandParamsSchema = exports.updateGeneratorKeyCommandParamsSchema = exports.validatorRegistrationCommandParamsSchema = void 0; const constants_1 = require("../../constants"); const constants_2 = require("./constants"); exports.validatorRegistrationCommandParamsSchema = { $id: '/pos/command/registerValidatorParams', type: 'object', required: ['name', 'blsKey', 'proofOfPossession', 'generatorKey'], properties: { name: { dataType: 'string', fieldNumber: 1, minLength: 1, maxLength: constants_2.MAX_LENGTH_NAME, }, blsKey: { dataType: 'bytes', minLength: constants_2.BLS_PUBLIC_KEY_LENGTH, maxLength: constants_2.BLS_PUBLIC_KEY_LENGTH, fieldNumber: 2, }, proofOfPossession: { dataType: 'bytes', minLength: constants_2.BLS_POP_LENGTH, maxLength: constants_2.BLS_POP_LENGTH, fieldNumber: 3, }, generatorKey: { dataType: 'bytes', minLength: constants_2.ED25519_PUBLIC_KEY_LENGTH, maxLength: constants_2.ED25519_PUBLIC_KEY_LENGTH, fieldNumber: 4, }, }, }; exports.updateGeneratorKeyCommandParamsSchema = { $id: '/pos/command/updateGeneratorKeyParams', type: 'object', required: ['generatorKey'], properties: { generatorKey: { dataType: 'bytes', fieldNumber: 1, minLength: 32, maxLength: 32, }, }, }; exports.stakeCommandParamsSchema = { $id: '/pos/command/stakeValidatorParams', type: 'object', required: ['stakes'], properties: { stakes: { type: 'array', fieldNumber: 1, minItems: 1, maxItems: 20, items: { type: 'object', required: ['validatorAddress', 'amount'], properties: { validatorAddress: { dataType: 'bytes', fieldNumber: 1, format: 'lisk32', }, amount: { dataType: 'sint64', fieldNumber: 2, }, }, }, }, }, }; exports.reportMisbehaviorCommandParamsSchema = { $id: '/pos/command/reportMisbehaviorParams', type: 'object', required: ['header1', 'header2'], properties: { header1: { dataType: 'bytes', fieldNumber: 1, }, header2: { dataType: 'bytes', fieldNumber: 2, }, }, }; exports.changeCommissionCommandParamsSchema = { $id: '/pos/command/changeCommissionCommandParams', type: 'object', required: ['newCommission'], properties: { newCommission: { dataType: 'uint32', fieldNumber: 1, maximum: constants_2.MAX_COMMISSION, }, }, }; exports.configSchema = { $id: '/pos/config', type: 'object', properties: { factorSelfStakes: { type: 'integer', format: 'uint32', minimum: 1, }, maxLengthName: { type: 'integer', format: 'uint32', minimum: 10, maximum: 30, }, maxNumberSentStakes: { type: 'integer', format: 'uint32', minimum: 1, maximum: 20, }, maxNumberPendingUnlocks: { type: 'integer', format: 'uint32', minimum: 1, maximum: 40, }, failSafeMissedBlocks: { type: 'integer', format: 'uint32', minimum: 2, }, failSafeInactiveWindow: { type: 'integer', format: 'uint32', minimum: (5 * 60 * 60 * 24) / 10, maximum: (365 * 60 * 60 * 24) / 10, }, punishmentWindowSelfStaking: { type: 'integer', format: 'uint32', minimum: (5 * 60 * 60 * 24) / 10, maximum: (365 * 60 * 60 * 24) / 10, }, minWeightStandby: { type: 'string', format: 'uint64', minimum: 1, }, numberActiveValidators: { type: 'integer', format: 'uint32', minimum: 1, maximum: constants_1.MAX_NUM_VALIDATORS, }, numberStandbyValidators: { type: 'integer', format: 'uint32', maximum: 2, }, posTokenID: { type: 'string', format: 'hex', }, validatorRegistrationFee: { type: 'string', format: 'uint64', }, maxBFTWeightCap: { type: 'integer', format: 'uint32', minimum: 300, maximum: 10000, }, commissionIncreasePeriod: { type: 'integer', format: 'uint32', }, maxCommissionIncreaseRate: { type: 'integer', format: 'uint32', minimum: 100, maximum: 10000, }, useInvalidBLSKey: { type: 'boolean', }, baseStakeAmount: { type: 'string', format: 'uint64', minimum: 1, }, lockingPeriodStaking: { type: 'integer', format: 'uint32', }, lockingPeriodSelfStaking: { type: 'integer', format: 'uint32', }, reportMisbehaviorReward: { type: 'string', format: 'uint64', }, reportMisbehaviorLimitBanned: { type: 'integer', format: 'uint32', minimum: 1, }, }, required: [ 'factorSelfStakes', 'maxLengthName', 'maxNumberSentStakes', 'maxNumberPendingUnlocks', 'failSafeMissedBlocks', 'failSafeInactiveWindow', 'punishmentWindowSelfStaking', 'minWeightStandby', 'numberActiveValidators', 'numberStandbyValidators', 'posTokenID', 'validatorRegistrationFee', 'maxBFTWeightCap', 'useInvalidBLSKey', 'baseStakeAmount', 'lockingPeriodStaking', 'lockingPeriodSelfStaking', 'reportMisbehaviorReward', 'reportMisbehaviorLimitBanned', ], }; exports.genesisStoreSchema = { $id: '/pos/module/genesis', type: 'object', required: ['validators', 'stakers', 'genesisData'], properties: { validators: { type: 'array', fieldNumber: 1, items: { type: 'object', required: [ 'address', 'name', 'blsKey', 'proofOfPossession', 'generatorKey', 'lastGeneratedHeight', 'isBanned', 'reportMisbehaviorHeights', 'consecutiveMissedBlocks', 'commission', 'lastCommissionIncreaseHeight', 'sharingCoefficients', ], properties: { address: { dataType: 'bytes', format: 'lisk32', fieldNumber: 1, }, name: { dataType: 'string', fieldNumber: 2, minLength: 1, maxLength: 20, }, blsKey: { dataType: 'bytes', fieldNumber: 3, minLength: 48, maxLength: 48, }, proofOfPossession: { dataType: 'bytes', fieldNumber: 4, minLength: 96, maxLength: 96, }, generatorKey: { dataType: 'bytes', fieldNumber: 5, minLength: 32, maxLength: 32, }, lastGeneratedHeight: { dataType: 'uint32', fieldNumber: 6, }, isBanned: { dataType: 'boolean', fieldNumber: 7, }, reportMisbehaviorHeights: { type: 'array', fieldNumber: 8, items: { dataType: 'uint32' }, }, consecutiveMissedBlocks: { dataType: 'uint32', fieldNumber: 9, }, commission: { dataType: 'uint32', fieldNumber: 10, maximum: constants_2.MAX_COMMISSION, }, lastCommissionIncreaseHeight: { dataType: 'uint32', fieldNumber: 11, }, sharingCoefficients: { type: 'array', fieldNumber: 12, items: { type: 'object', required: ['tokenID', 'coefficient'], properties: { tokenID: { dataType: 'bytes', minLength: constants_2.TOKEN_ID_LENGTH, maxLength: constants_2.TOKEN_ID_LENGTH, fieldNumber: 1, }, coefficient: { dataType: 'bytes', maxLength: constants_2.MAX_NUMBER_BYTES_Q96, fieldNumber: 2, }, }, }, }, }, }, }, stakers: { type: 'array', fieldNumber: 2, items: { type: 'object', required: ['address', 'stakes', 'pendingUnlocks'], properties: { address: { dataType: 'bytes', format: 'lisk32', fieldNumber: 1, }, stakes: { type: 'array', fieldNumber: 2, items: { type: 'object', required: ['validatorAddress', 'amount', 'sharingCoefficients'], properties: { validatorAddress: { dataType: 'bytes', format: 'lisk32', fieldNumber: 1, }, amount: { dataType: 'uint64', fieldNumber: 2, }, sharingCoefficients: { type: 'array', fieldNumber: 3, items: { type: 'object', required: ['tokenID', 'coefficient'], properties: { tokenID: { dataType: 'bytes', minLength: constants_2.TOKEN_ID_LENGTH, maxLength: constants_2.TOKEN_ID_LENGTH, fieldNumber: 1, }, coefficient: { dataType: 'bytes', maxLength: constants_2.MAX_NUMBER_BYTES_Q96, fieldNumber: 2, }, }, }, }, }, }, }, pendingUnlocks: { type: 'array', fieldNumber: 3, items: { type: 'object', required: ['validatorAddress', 'amount', 'unstakeHeight'], properties: { validatorAddress: { dataType: 'bytes', fieldNumber: 1, format: 'lisk32', }, amount: { dataType: 'uint64', fieldNumber: 2, }, unstakeHeight: { dataType: 'uint32', fieldNumber: 3, }, }, }, }, }, }, }, genesisData: { type: 'object', fieldNumber: 3, required: ['initRounds', 'initValidators'], properties: { initRounds: { dataType: 'uint32', fieldNumber: 1, }, initValidators: { type: 'array', fieldNumber: 2, items: { dataType: 'bytes', format: 'lisk32' }, }, }, }, }, }; const validatorJSONSchema = { type: 'object', required: [ 'address', 'name', 'totalStakeReceived', 'selfStake', 'lastGeneratedHeight', 'isBanned', 'pomHeights', 'punishmentPeriods', 'consecutiveMissedBlocks', ], properties: { address: { type: 'string', format: 'lisk32', }, name: { type: 'string', }, totalStakeReceived: { type: 'string', format: 'uint64', }, selfStake: { type: 'string', format: 'uint64', }, lastGeneratedHeight: { type: 'integer', format: 'uint32', }, isBanned: { type: 'boolean', }, pomHeights: { type: 'array', items: { type: 'integer', format: 'uint32' }, }, punishmentPeriods: { type: 'array', items: { type: 'object', required: ['start', 'end'], properties: { start: { type: 'integer', format: 'uint32', }, end: { type: 'integer', format: 'uint32', }, }, }, }, consecutiveMissedBlocks: { type: 'integer', format: 'uint32', }, }, }; exports.getValidatorRequestSchema = { $id: 'modules/pos/endpoint/getValidatorRequest', type: 'object', required: ['address'], properties: { address: { type: 'string', format: 'lisk32', }, }, }; exports.getValidatorResponseSchema = { $id: 'modules/pos/endpoint/getValidatorResponse', ...validatorJSONSchema, }; exports.getConstantsResponseSchema = { $id: 'modules/pos/endpoint/getConstantsResponseSchema', type: 'object', properties: { ...exports.configSchema.properties, defaultCommission: { type: 'integer', format: 'uint32', }, }, required: [...exports.configSchema.required, 'defaultCommission'], }; exports.getStakerRequestSchema = exports.getValidatorRequestSchema; exports.getStakerResponseSchema = { $id: 'modules/pos/endpoint/getStakerResponse', type: 'object', required: ['stakes', 'pendingUnlocks'], properties: { stakes: { type: 'array', fieldNumber: 1, items: { type: 'object', required: ['validatorAddress', 'amount'], properties: { validatorAddress: { type: 'string', format: 'lisk32', }, amount: { type: 'string', format: 'uint64', }, }, }, }, pendingUnlocks: { type: 'array', fieldNumber: 2, items: { type: 'object', required: ['validatorAddress', 'amount', 'unstakeHeight'], properties: { validatorAddress: { type: 'string', format: 'lisk32', }, amount: { type: 'string', format: 'uint64', }, unstakeHeight: { type: 'integer', format: 'uint32', }, }, }, }, }, }; exports.getAllValidatorsResponseSchema = { $id: 'modules/pos/endpoint/getAllValidatorsResponse', type: 'object', required: ['validators'], properties: { validators: { type: 'array', items: validatorJSONSchema, }, }, }; exports.getPoSTokenIDResponseSchema = { $id: 'modules/pos/endpoint/getPoSTokenIDResponse', type: 'object', required: ['tokenID'], properties: { tokenID: { type: 'string', format: 'hex', }, }, }; exports.getValidatorsByStakeRequestSchema = { $id: 'modules/pos/endpoint/getValidatorsByStakeRequest', type: 'object', properties: { limit: { type: 'integer', format: 'int32', }, }, }; exports.getValidatorsByStakeResponseSchema = { $id: 'modules/pos/endpoint/getValidatorsByStakeResponse', type: 'object', required: ['validators'], properties: { validators: { type: 'array', items: validatorJSONSchema, }, }, }; exports.getLockedRewardRequestSchema = { $id: 'modules/pos/endpoint/getLockedRewardRequest', type: 'object', required: ['address', 'tokenID'], properties: { address: { type: 'string', format: 'lisk32', }, tokenID: { type: 'string', format: 'hex', }, }, }; exports.getLockedRewardResponseSchema = { $id: 'modules/pos/endpoint/getLockedRewardResponse', type: 'object', required: ['reward'], properties: { reward: { type: 'string', format: 'uint64', }, }, }; exports.getClaimableRewardsRequestSchema = { $id: 'modules/pos/endpoint/getClaimableRewardsRequest', type: 'object', required: ['address'], properties: { address: { type: 'string', format: 'lisk32', }, }, }; exports.getClaimableRewardsResponseSchema = { $id: 'modules/pos/endpoint/getClaimableRewardsResponse', type: 'object', properties: { rewards: { items: { type: 'object', required: ['tokenID', 'reward'], properties: { tokenID: { type: 'string', format: 'hex', }, reward: { type: 'string', format: 'uint64', }, }, }, }, }, }; exports.getLockedStakedAmountRequestSchema = { $id: 'modules/pos/endpoint/getLockedStakedAmountRequest', type: 'object', required: ['address'], properties: { address: { type: 'string', format: 'lisk32', }, }, }; exports.getLockedStakedAmountResponseSchema = { $id: 'modules/pos/endpoint/getLockedStakedAmountResponse', type: 'object', required: ['amount'], properties: { amount: { type: 'string', format: 'uint64', }, }, }; exports.getPendingUnlocksRequestSchema = { $id: 'modules/pos/endpoint/getPendingUnlocksRequest', type: 'object', required: ['address'], properties: { address: { type: 'string', format: 'lisk32', }, }, }; exports.getPendingUnlocksResponseSchema = { $id: 'modules/pos/endpoint/getPendingUnlocksResponse', type: 'object', required: ['pendingUnlocks'], properties: { pendingUnlocks: { type: 'array', items: { type: 'object', required: [ 'validatorAddress', 'amount', 'unstakeHeight', 'expectedUnlockableHeight', 'unlockable', ], properties: { validatorAddress: { type: 'string', format: 'lisk32', }, amount: { type: 'string', format: 'uint64', }, unstakeHeight: { type: 'integer', format: 'uint32', }, expectedUnlockableHeight: { type: 'integer', format: 'uint32', }, unlockable: { type: 'boolean', }, }, }, }, }, }; exports.getRegistrationFeeResponseSchema = { $id: 'modules/pos/endpoint/getRegistrationFeeResponse', type: 'object', required: ['registrationFee'], properties: { registrationFee: { type: 'string', }, }, }; exports.getExpectedSharedRewardsRequestSchema = { $id: 'modules/pos/endpoint/getExpectedSharedRewardsRequest', type: 'object', required: ['validatorAddress', 'validatorReward', 'stake'], properties: { validatorAddress: { type: 'string', format: 'lisk32', }, validatorReward: { type: 'string', format: 'uint64', }, stake: { type: 'string', format: 'uint64', }, }, }; exports.getExpectedSharedRewardsResponseSchema = { $id: 'modules/pos/endpoint/getExpectedSharedRewardsResponse', type: 'object', required: ['reward'], properties: { reward: { type: 'string', format: 'uint64', }, }, }; //# sourceMappingURL=schemas.js.map