@yoroi/api
Version:
The API package of Yoroi SDK
106 lines (105 loc) • 3.51 kB
JavaScript
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.parseProtocolParamsResponse = exports.isProtocolParamsResponse = exports.getProtocolParams = void 0;
var _common = require("@yoroi/common");
var _zod = require("zod");
const getProtocolParams = (baseUrl, request = _common.fetcher) => async () => {
return request({
url: `${baseUrl}/protocolparameters`,
data: undefined,
method: 'GET',
headers: {
'Content-Type': 'application/json'
}
}).then(response => {
const parsedResponse = parseProtocolParamsResponse(response);
if (!parsedResponse) return Promise.reject(new Error('Invalid protocol params response'));
return Promise.resolve(parsedResponse);
});
};
exports.getProtocolParams = getProtocolParams;
const parseProtocolParamsResponse = data => {
return isProtocolParamsResponse(data) ? data : undefined;
};
exports.parseProtocolParamsResponse = parseProtocolParamsResponse;
const RatioSchema = _zod.z.object({
numerator: _zod.z.string(),
denominator: _zod.z.string()
});
const ProtocolParamsSchema = _zod.z.object({
linearFee: _zod.z.object({
constant: _zod.z.string(),
coefficient: _zod.z.string()
}),
minFeeReferenceScript: _zod.z.object({
coinsPerByte: RatioSchema,
tierStepBytes: _zod.z.string(),
multiplier: _zod.z.string()
}),
coinsPerUtxoByte: _zod.z.string(),
poolDeposit: _zod.z.string(),
keyDeposit: _zod.z.string(),
epoch: _zod.z.number().nonnegative(),
maxBlockBodySize: _zod.z.string(),
maxBlockHeaderSize: _zod.z.string(),
maxTxSize: _zod.z.string(),
maxReferenceScriptsSize: _zod.z.string(),
stakePoolPledgeInfluence: RatioSchema,
monetaryExpansion: RatioSchema,
treasuryExpansion: RatioSchema,
minPoolCost: _zod.z.string(),
maxExecutionUnits: _zod.z.object({
perTransaction: _zod.z.object({
memory: _zod.z.string(),
cpu: _zod.z.string()
}),
perBlock: _zod.z.object({
memory: _zod.z.string(),
cpu: _zod.z.string()
})
}),
scriptExecutionPrices: _zod.z.object({
memory: RatioSchema,
cpu: RatioSchema
}),
maxCollateralInputs: _zod.z.string(),
collateralPercentage: _zod.z.string(),
maxValueSize: _zod.z.string(),
version: _zod.z.object({
major: _zod.z.string(),
minor: _zod.z.string()
}),
governanceActionDeposit: _zod.z.string(),
delegateRepresentativeDeposit: _zod.z.string(),
constitutionalCommitteeMinSize: _zod.z.string(),
constitutionalCommitteeMaxTermLength: _zod.z.string(),
governanceActionLifetime: _zod.z.string(),
delegateRepresentativeMaxIdleTime: _zod.z.string(),
desiredNumberOfStakePools: _zod.z.string(),
stakePoolRetirementEpochBound: _zod.z.string(),
votingThresholds: _zod.z.object({
stakePool: _zod.z.object({
noConfidence: RatioSchema,
committeeNormal: RatioSchema,
committeeNoConfidence: RatioSchema,
hardFork: RatioSchema,
ppSecurity: RatioSchema
}),
delegateRep: _zod.z.object({
noConfidence: RatioSchema,
committeeNormal: RatioSchema,
committeeNoConfidence: RatioSchema,
constitution: RatioSchema,
hardFork: RatioSchema,
ppNetwork: RatioSchema,
ppEconomic: RatioSchema,
ppTechnical: RatioSchema,
ppGovernance: RatioSchema,
treasury: RatioSchema
})
})
});
const isProtocolParamsResponse = exports.isProtocolParamsResponse = (0, _common.createTypeGuardFromSchema)(ProtocolParamsSchema);
//# sourceMappingURL=protocol-params.js.map