Cardano-wallet: Add API endpoint for delegation fee estimation

Created on 29 Nov 2019  路  7Comments  路  Source: input-output-hk/cardano-wallet

Context

Users of the API would like to know the cost of joining a stake-pool before pulling the trigger.

In this task we implement the API, leveraging the work of #1094.

Decision

Add the following endpoint:

/wallets/\{walletId\}/delegations/fees: 
    get: 
      operationId: getDelegationFee
      tags: ["Stake Pools"]
      summary: Estimate Fee
      parameters: 
        - *parametersWalletId
      responses: *responsesGetDelegationFee

x-responsesGetDelegationFee: &responsesGetDelegationFee
  <<: *responsesErr403
  <<: *responsesErr404
  <<: *responsesErr405
  <<: *responsesErr406
  200:
    description: Ok
    schema: *ApiFee

Acceptance Criteria

  • The endpoint _must_ be implemented
  • JSON roundtrip tests for any added Api-types _should_ exist
  • The endpoint _should_ be tested with integration tests

Development

  • 1116

  • QA

    Most helpful comment

    We might want to add integration tests to check that:

    • The _eventual_ fee paid for joining a stake pool is similar or identical to the _estimated_ delegation fee (similar to BYRON_MIGRATE_03).
    • The estimated delegation fee for a non-empty wallet is > 0 (similar to BYRON_CALCULATE_01).
    • Attempting to calculate a delegation fee for an empty wallet produces an appropriate error (similar to BYRON_CALCULATE_02).
    • Attempting to calculate a delegation fee for a non-Shelley wallet produces an appropriate error (similar to BYRON_CALCULATE_03).
    • Attempting to calculate a delegation fee for a non-existing wallet produces an appropriate error (similar to BYRON_CALCULATE_04).

    All 7 comments

    We might want to add integration tests to check that:

    • The _eventual_ fee paid for joining a stake pool is similar or identical to the _estimated_ delegation fee (similar to BYRON_MIGRATE_03).
    • The estimated delegation fee for a non-empty wallet is > 0 (similar to BYRON_CALCULATE_01).
    • Attempting to calculate a delegation fee for an empty wallet produces an appropriate error (similar to BYRON_CALCULATE_02).
    • Attempting to calculate a delegation fee for a non-Shelley wallet produces an appropriate error (similar to BYRON_CALCULATE_03).
    • Attempting to calculate a delegation fee for a non-existing wallet produces an appropriate error (similar to BYRON_CALCULATE_04).

    @KtorZ I've added a question regarding the original requirement here: https://jira.iohk.io/browse/WB-32?focusedCommentId=11089&page=com.atlassian.jira.plugin.system.issuetabpanels%3Acomment-tabpanel#comment-11089

    (The question is aimed at clarifying whether or not this endpoint should really be an HTTP GET operation, or whether the endpoint really does require a user-supplied payload, in which case we will indeed need a POST operation.)

    Few more tests would be handy on negative cases side of things. Also there is no assertion check for the 200 http status code for most basic fee request.

    Fee estimation also does not show correct amount -> https://github.com/input-output-hk/cardano-wallet/issues/1150 (the amount does not correspond with genesis.yaml parameters -> some more info also here https://input-output-rnd.slack.com/archives/GBT05825V/p1575876039070100)

    Few more tests would be handy on negative cases side of things

    @piotr-iohk what kind of negative tests would you like to see? There are already three

    @piotr-iohk what kind of negative tests would you like to see? There are already three

    They are good indeed!
    Just added 2 more to test against 405 and 406 -> #1170.

    ok.

    Was this page helpful?
    0 / 5 - 0 ratings

    Related issues

    piotr-iohk picture piotr-iohk  路  11Comments

    got3nks picture got3nks  路  9Comments

    KtorZ picture KtorZ  路  11Comments

    Anviking picture Anviking  路  3Comments

    mestakepool picture mestakepool  路  10Comments