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

feat(jellyfish-api-core): add wallet.listtransactions RPC #2060

Open
wants to merge 12 commits into
base: main
Choose a base branch
from

Conversation

andyrobert3
Copy link

@andyrobert3 andyrobert3 commented Feb 20, 2023

What this PR does / why we need it:

/kind feature

Which issue(s) does this PR fixes?:

Implemented RPC call for #48

  1. wallet.listtransactions

Additional comments?:

  • Unsure how to test the "skip" parameter for the wallet.listtransactions function

@codeclimate
Copy link

codeclimate bot commented Feb 20, 2023

Code Climate has analyzed commit 530b5f6 and detected 0 issues on this pull request.

View more on Code Climate.

@netlify
Copy link

netlify bot commented Feb 20, 2023

Deploy Preview for jellyfishsdk ready!

Name Link
🔨 Latest commit 530b5f6
🔍 Latest deploy log https://app.netlify.com/sites/jellyfishsdk/deploys/63f81aa19f1a7600082650bb
😎 Deploy Preview https://deploy-preview-2060--jellyfishsdk.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site settings.

@codecov
Copy link

codecov bot commented Feb 20, 2023

Codecov Report

Base: 82.49% // Head: 91.58% // Increases project coverage by +9.08% 🎉

Coverage data is based on head (530b5f6) compared to base (b0642d9).
Patch coverage: 100.00% of modified lines in pull request are covered.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2060      +/-   ##
==========================================
+ Coverage   82.49%   91.58%   +9.08%     
==========================================
  Files         357      362       +5     
  Lines       10837    10884      +47     
  Branches     1416     1421       +5     
==========================================
+ Hits         8940     9968    +1028     
+ Misses       1803      873     -930     
+ Partials       94       43      -51     
Impacted Files Coverage Δ
packages/jellyfish-api-core/src/category/wallet.ts 100.00% <100.00%> (+4.49%) ⬆️
...ners/src/containers/RegTestContainer/Persistent.ts 11.11% <0.00%> (-81.49%) ⬇️
packages/whale-api-client/src/api/consortium.ts 33.33% <0.00%> (-66.67%) ⬇️
...es/ocean-api-client/src/errors/TimeoutException.ts 33.33% <0.00%> (-66.67%) ⬇️
...ckages/jellyfish-network/src/TransactionSkipped.ts 37.50% <0.00%> (-50.00%) ⬇️
...core/src/saga/AddressParser/dftx/AccountToUtxos.ts 62.50% <0.00%> (-37.50%) ⬇️
...ges/rich-list-core/src/saga/AddressParser/index.ts 60.71% <0.00%> (-35.72%) ⬇️
...ule.indexer/model/dftx/set.oracle.data.interval.ts 61.40% <0.00%> (-35.09%) ⬇️
...pi/src/module.indexer/model/dftx/appoint.oracle.ts 75.75% <0.00%> (-24.25%) ⬇️
...api/src/module.indexer/model/dftx/update.oracle.ts 74.41% <0.00%> (-23.26%) ⬇️
... and 110 more

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

☔ View full report at Codecov.
📢 Do you have feedback about the report comment? Let us know in this issue.

@andyrobert3 andyrobert3 marked this pull request as ready for review February 21, 2023 06:28
Copy link
Contributor

@eli-lim eli-lim left a comment

Choose a reason for hiding this comment

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

Generally LGTM! Some comments

@andyrobert3 andyrobert3 requested a review from eli-lim February 22, 2023 06:18
Copy link
Contributor

@eli-lim eli-lim left a comment

Choose a reason for hiding this comment

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

Generally LGTM

expect(inWalletTransactions.length).toStrictEqual(10)

for (const inWalletTransaction of inWalletTransactions) {
expect(inWalletTransaction).toMatchObject({
Copy link
Contributor

Choose a reason for hiding this comment

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

Is there a reason why we prefer toMatchObject here over toStrictEqual?

Copy link
Author

@andyrobert3 andyrobert3 Feb 22, 2023

Choose a reason for hiding this comment

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

Here are the specifications on what attributes are returned by the listtransactions function on DeFiChain

https://github.com/DeFiCh/ain/blob/master/src/wallet/rpcwallet.cpp

RPCResult {
            "[\n"
            "  {\n"
            "    \"address\":\"address\",    (string) The defi address of the transaction.\n"
            "    \"category\":               (string) The transaction category.\n"
            "                \"send\"                  Transactions sent.\n"
            "                \"receive\"               Non-coinbase transactions received.\n"
            "                \"generate\"              Coinbase transactions received with more than 100 confirmations.\n"
            "                \"immature\"              Coinbase transactions received with 100 or fewer confirmations.\n"
            "                \"orphan\"                Orphaned coinbase transactions received.\n"
            "    \"amount\": x.xxx,          (numeric) The amount in " + CURRENCY_UNIT + ". This is negative for the 'send' category, and is positive\n"
            "                                        for all other categories\n"
            "    \"label\": \"label\",       (string) A comment for the address/transaction, if any\n"
            "    \"vout\": n,                (numeric) the vout value\n"
            "    \"fee\": x.xxx,             (numeric) The amount of the fee in " + CURRENCY_UNIT + ". This is negative and only available for the \n"
            "                                         'send' category of transactions.\n"
            "    \"confirmations\": n,       (numeric) The number of confirmations for the transaction. Negative confirmations indicate the\n"
            "                                         transaction conflicts with the block chain\n"
            "    \"trusted\": xxx,           (bool) Whether we consider the outputs of this unconfirmed transaction safe to spend.\n"
            "    \"blockhash\": \"hashvalue\", (string) The block hash containing the transaction.\n"
            "    \"blockindex\": n,          (numeric) The index of the transaction in the block that includes it.\n"
            "    \"blocktime\": xxx,         (numeric) The block time in seconds since epoch (1 Jan 1970 GMT).\n"
            "    \"txid\": \"transactionid\", (string) The transaction id.\n"
            "    \"time\": xxx,              (numeric) The transaction time in seconds since epoch (midnight Jan 1 1970 GMT).\n"
            "    \"timereceived\": xxx,      (numeric) The time received in seconds since epoch (midnight Jan 1 1970 GMT).\n"
            "    \"comment\": \"...\",       (string) If a comment is associated with the transaction.\n"
            "    \"bip125-replaceable\": \"yes|no|unknown\",  (string) Whether this transaction could be replaced due to BIP125 (replace-by-fee);\n"
            "                                                     may be unknown for unconfirmed transactions not in the mempool\n"
            "    \"abandoned\": xxx          (bool) 'true' if the transaction has been abandoned (inputs are respendable). Only available for the \n"
            "                                         'send' category of transactions.\n"
            "  }\n"
            "]\n"
}

When running the tests, sometimes there are additional optional returned parameters that are not included in the specifications above:

  • generated -> boolean
  • walletconflicts -> Array

These parameters appear in some responses, and not others.

Using toStrictEqual may fail tests here, the extra parameters generated & walletconflicts are not always included in the response.

However, toMatchObject is defined as "check that a JavaScript object matches a subset of the properties of an object"

In this case, we can just compare the response result if it matches a subset of the specification parameters from the DeFiChain repository

Copy link
Author

Choose a reason for hiding this comment

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

If anyone from the DeFi chain team knows when & why the 2 extra parameters appear, feel free to add on here so I can modify my tests to use toStrictEqual

Copy link
Contributor

Choose a reason for hiding this comment

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

Ah okay that makes sense

I guess the RPC doc needs updating in ain then

Copy link
Author

Choose a reason for hiding this comment

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

do you know who should i ask here? @eli-lim

I'll probably raise a ticket to the ain repo?

Copy link
Contributor

Choose a reason for hiding this comment

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

Sure, just raise a ticket

In the mean time, let's wait for others to review this PR

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants