Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add optional address parameter to listTransaction #4004

Merged
merged 29 commits into from
Jul 21, 2023

Conversation

paweljakubas
Copy link
Contributor

@paweljakubas paweljakubas commented Jun 26, 2023

  • Add support for optional address in api
  • Handle inputs, outputs, collateral inputs and collateral output
  • tests for shelley style
  • tests for byron style
  • tests for shared style
  • swagger update

Comments

Issue Number

https://cardanofoundation.atlassian.net/browse/ADP-2817

@paweljakubas paweljakubas self-assigned this Jun 26, 2023
@paweljakubas paweljakubas force-pushed the paweljakubas/add-address-parameter branch 3 times, most recently from 76d1535 to 012e873 Compare July 6, 2023 13:11
@paweljakubas paweljakubas requested a review from paolino July 6, 2023 13:13
@paweljakubas paweljakubas force-pushed the paweljakubas/add-address-parameter branch 2 times, most recently from 9db64c6 to b203b2c Compare July 14, 2023 06:49
@paolino paolino self-requested a review July 14, 2023 09:08
@paweljakubas paweljakubas changed the title Add address parameter to listTransaction Add optional address parameter to listTransaction Jul 14, 2023
@@ -604,6 +604,7 @@ type ListTransactions n = "wallets"
:> QueryParam "end" Iso8601Time
:> QueryParam "order" (ApiT SortOrder)
:> QueryParam "max_count" ApiLimit
:> QueryParam "addressId" (ApiAddressIdT n)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
:> QueryParam "addressId" (ApiAddressIdT n)
:> QueryParam "address" (ApiAddressIdT n)

?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree here, but complied with what is in InspectAddress and PutByronAddress. Nevertheless, address seems less confusing than addressId. We might want to change the legacy "addressId" in the future.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Independent of which name we prefer (I do prefer "address"), we have to be consistent with the OpenAPI specification, which had specified address, I believe:

x-parametersAddress: &parametersAddress
  in: query
  name: address

Whenever specification and code differ, that's a bug in the code. 🤓

Copy link
Collaborator

@paolino paolino left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

in: query
name: address
description: |
An optional address.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't we explain the usage here?

lib/wallet/src/Cardano/Wallet/DB/Pure/Implementation.hs Outdated Show resolved Hide resolved
Copy link
Contributor

@HeinrichApfelmus HeinrichApfelmus left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you! 😊

I have two requests:

  • Factor out listTransactionsFilteredByAddress to make the integration tests easier to read (less vertical space)
  • Check the status of the transaction ID for both wallets instead of comparing balances.

Other than that, I think that this is good to merge.

sendAmtToAddr ctx wSrc wDest a1 2
sendAmtToAddr ctx wSrc wDest a4 2
sendAmtToAddr ctx wSrc wDest a5 2

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
let listTransactionsFilteredByAddress wallet =
Link.listTransactions' @'Shared wallet
Nothing Nothing Nothing Nothing Nothing

In order to make the integration tests easier to read, I favor factoring out this common usage pattern.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good suggestion! Refactored this for all styles

Comment on lines 2635 to 2623
let linkList0 = Link.listTransactions' @'Shared wDest
Nothing
Nothing
Nothing
Nothing
Nothing
(Just (apiAddress addr0))
rl0 <- request @([ApiTransaction n]) ctx linkList0 Default Empty
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
let linkList0 = Link.listTransactions' @'Shared wDest
Nothing
Nothing
Nothing
Nothing
Nothing
(Just (apiAddress addr0))
rl0 <- request @([ApiTransaction n]) ctx linkList0 Default Empty
let query0 = listTransactionsFilteredByAddress wDest $ Just (apiAddress addr0)
rl0 <- request @([ApiTransaction n]) ctx query0 Default Empty

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

Nothing
Nothing
(Just (apiAddress addr1))
rl1 <- request @([ApiTransaction n]) ctx linkList1 Default Empty
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
rl1 <- request @([ApiTransaction n]) ctx linkList1 Default Empty
rl1 <- request @([ApiTransaction n]) ctx query1 Default Empty

As above, using listTransactionsFilteredByAddress.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

Nothing
Nothing
(Just (apiAddress addr2))
rl2 <- request @([ApiTransaction n]) ctx linkList2 Default Empty
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
rl2 <- request @([ApiTransaction n]) ctx linkList2 Default Empty
rl2 <- request @([ApiTransaction n]) ctx query2 Default Empty

As above with listTransactionsFilteredByAddress.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

sendAmtToAddr ctx wSrc wDest a3 2

eventually "There are exactly 8 transactions for wDest" $ do
let linkList = Link.listTransactions' @'Shared wDest
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

listTransactionsFilteredByAddress as above.

It may be worth putting this function listTransactionsFilteredByAddress into the where clause.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

listTransactionsFilteredByAddress now in where for shelley, shared and byron styles

specifications/api/swagger.yaml Show resolved Hide resolved
, expectResponseCode HTTP.status202
]
eventually "dest wallet balance is higher than before" $ do
rGet <- request @ApiWallet ctx
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 This is necessary to make the test robust for execution on an actual Cardano network, where concurrency, consensus, and timing can and will affect the results — typically leading to "flaky" test failure.

However, instead of checking the balances, I prefer checking that for each wallet, the transaction (identified by its transaction ID) has status in_ledger — this is the correct way to ensure that a transaction has been accommodated in both source and destination wallet.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

very reasonable idea! Did it for all styles - byron, shared and shelley!

@@ -604,6 +604,7 @@ type ListTransactions n = "wallets"
:> QueryParam "end" Iso8601Time
:> QueryParam "order" (ApiT SortOrder)
:> QueryParam "max_count" ApiLimit
:> QueryParam "addressId" (ApiAddressIdT n)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Independent of which name we prefer (I do prefer "address"), we have to be consistent with the OpenAPI specification, which had specified address, I believe:

x-parametersAddress: &parametersAddress
  in: query
  name: address

Whenever specification and code differ, that's a bug in the code. 🤓

@paweljakubas paweljakubas force-pushed the paweljakubas/add-address-parameter branch from 79c6ec7 to 212d85d Compare July 21, 2023 12:51
@paweljakubas paweljakubas added this pull request to the merge queue Jul 21, 2023
Merged via the queue into master with commit 1388223 Jul 21, 2023
@paweljakubas paweljakubas deleted the paweljakubas/add-address-parameter branch July 21, 2023 14:07
WilliamKingNoel-Bot pushed a commit that referenced this pull request Jul 21, 2023
…Detail in a few bullet points the work accomplished in this PR. Before you submit, don't forget to: CODE-OF-CONDUCT.md CONTRIBUTING.md LICENSE MAINTAINERS.md README.md bors.toml cabal.project default.nix docker-compose.yml docs flake.lock flake.nix floskell.json fourmolu.yaml hie-direnv.yaml lib nix prototypes reports scripts shell.nix specifications test touch.me.CI weeder.dhall Make sure the GitHub PR fields are correct: ✓ Set a good Title for your PR. ✓ Assign yourself to the PR. ✓ Assign one or more reviewer(s). ✓ Link to a Jira issue, and/or other GitHub issues or PRs. ✓ In the PR description delete any empty sections and all text commented in <!--, so that this text does not appear in merge commit messages. CODE-OF-CONDUCT.md CONTRIBUTING.md LICENSE MAINTAINERS.md README.md bors.toml cabal.project default.nix docker-compose.yml docs flake.lock flake.nix floskell.json fourmolu.yaml hie-direnv.yaml lib nix prototypes reports scripts shell.nix specifications test touch.me.CI weeder.dhall Don't waste reviewers' time: ✓ If it's a draft, select the Create Draft PR option. ✓ Self-review your changes to make sure nothing unexpected slipped through. CODE-OF-CONDUCT.md CONTRIBUTING.md LICENSE MAINTAINERS.md README.md bors.toml cabal.project default.nix docker-compose.yml docs flake.lock flake.nix floskell.json fourmolu.yaml hie-direnv.yaml lib nix prototypes reports scripts shell.nix specifications test touch.me.CI weeder.dhall Try to make your intent clear: ✓ Write a good Description that explains what this PR is meant to do. ✓ Jira will detect and link to this PR once created, but you can also link this PR in the description of the corresponding Jira ticket. ✓ Highlight what Testing you have done. ✓ Acknowledge any changes required to the Documentation. --> - [x] Add support for optional address in api - [x] Handle inputs, outputs, collateral inputs and collateral output - [x] tests for shelley style - [x] tests for byron style - [x] tests for shared style - [x] swagger update ### Comments <!-- Additional comments, links, or screenshots to attach, if any. --> ### Issue Number https://cardanofoundation.atlassian.net/browse/ADP-2817 <!-- Reference the Jira/GitHub issue that this PR relates to, and which requirements it tackles. Note: Jira issues of the form ADP- will be auto-linked. --> Source commit: 1388223
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants