-
Notifications
You must be signed in to change notification settings - Fork 37
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
base: main
Are you sure you want to change the base?
Conversation
Code Climate has analyzed commit 530b5f6 and detected 0 issues on this pull request. View more on Code Climate. |
✅ Deploy Preview for jellyfishsdk ready!
To edit notification comments on pull requests, go to your Netlify site settings. |
Codecov ReportBase: 82.49% // Head: 91.58% // Increases project coverage by
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
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. |
There was a problem hiding this 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
packages/jellyfish-api-core/__tests__/category/wallet/listTransactions.test.ts
Outdated
Show resolved
Hide resolved
packages/jellyfish-api-core/__tests__/category/wallet/listTransactions.test.ts
Outdated
Show resolved
Hide resolved
There was a problem hiding this 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({ |
There was a problem hiding this comment.
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
?
There was a problem hiding this comment.
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
-> booleanwalletconflicts
-> 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
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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
What this PR does / why we need it:
/kind feature
Which issue(s) does this PR fixes?:
Implemented RPC call for #48
Additional comments?:
wallet.listtransactions
function