Skip to content

Commit

Permalink
feat: consider deposit, refunds and withdrawals for fee calculation
Browse files Browse the repository at this point in the history
  • Loading branch information
tomasBustamante authored and AlanVerbner committed Dec 11, 2020
1 parent 04d3b79 commit c6a7e06
Show file tree
Hide file tree
Showing 8 changed files with 226 additions and 298 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import { ErrorFactory } from '../utils/errors';
import { withNetworkValidation } from './controllers-helper';
import { CardanoCli } from '../utils/cardanonode-cli';
import { NetworkService } from '../services/network-service';
import { AddressType, operationType } from '../utils/constants';
import { AddressType } from '../utils/constants';
import { isAddressTypeValid, isKeyValid } from '../utils/validations';

export interface ConstructionController {
Expand Down Expand Up @@ -185,21 +185,6 @@ const configure = (
const ttl = request.body.metadata.ttl;
const operations = request.body.operations;
const networkIdentifier = getNetworkIdentifierByRequestParameters(request.body.network_identifier);
operations.forEach(({ operation_identifier: operationId, type, metadata }) => {
if (!Object.values(operationType).includes(type as operationType)) {
logger.error(`[constructionPayloads] Operation with id ${operationId} has invalid type`);
throw ErrorFactory.invalidOperationTypeError();
}
if (
// eslint-disable-next-line camelcase
metadata?.staking_credential &&
// eslint-disable-next-line camelcase
!isKeyValid(metadata?.staking_credential.hex_bytes, metadata?.staking_credential.curve_type)
) {
logger.info('[constructionPayloads] Staking key has an invalid format');
throw ErrorFactory.invalidStakingKeyFormat();
}
});
logger.info(operations, '[constuctionPayloads] Operations about to be processed');
const unsignedTransaction = cardanoService.createUnsignedTransaction(
logger,
Expand Down
4 changes: 3 additions & 1 deletion cardano-rosetta-server/src/server/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ const linearFeeParameters: LinearFeeParameters = {
minFeeA: genesis.protocolParams.minFeeA,
minFeeB: genesis.protocolParams.minFeeB
};
const keyDeposit = genesis.protocolParams.keyDeposit;

const start = async (databaseInstance: Pool) => {
let server;
Expand All @@ -36,7 +37,8 @@ const start = async (databaseInstance: Pool) => {
networkMagic,
environment.TOPOLOGY_FILE,
environment.DEFAULT_RELATIVE_TTL,
linearFeeParameters
linearFeeParameters,
keyDeposit
);
server = buildServer(services, cardanoCli, cardanoNode, environment.LOGGER_LEVEL, {
networkId,
Expand Down
Loading

0 comments on commit c6a7e06

Please sign in to comment.