-
Notifications
You must be signed in to change notification settings - Fork 98
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
Billy/454 tx info #770
Billy/454 tx info #770
Conversation
@@ -89,6 +89,8 @@ Object.assign(Client.prototype, { | |||
}, | |||
coinTxs: argReq("GET", "/tx/coin"), | |||
|
|||
txs: argReq("GET", "/txs"), |
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.
🥇
Codecov Report
@@ Coverage Diff @@
## develop #770 +/- ##
===========================================
- Coverage 87.56% 87.55% -0.01%
===========================================
Files 94 95 +1
Lines 1608 1639 +31
Branches 91 94 +3
===========================================
+ Hits 1408 1435 +27
- Misses 184 188 +4
Partials 16 16
|
i'm not sure about what data is actually available - but if it could match the tx history component that might be nice. |
@@ -44,13 +44,23 @@ page(:title="pageBlockTitle") | |||
part(title='Transactions') | |||
data-loading(v-if="blockchain.blockLoading") | |||
data-empty(v-else-if="block.header.num_txs === 0" title="Empty Block" subtitle="There were no transactions in this block.") | |||
list-item(v-else v-for="tx in block.data.txs" :key="tx.id" dt="Transaction" :dd="TODO") | |||
template( |
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.
@jolesbi this is what you were looking for, right?
@@ -68,12 +79,15 @@ export default { | |||
Page | |||
}, | |||
computed: { | |||
...mapGetters(["blockchain"]), | |||
...mapGetters(["blockchain", "blocTxInfo", "config"]), |
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.
typo?
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.
at least it was consistently misspelled 😜
@@ -61,6 +81,66 @@ export default ({ commit, node }) => { | |||
}) | |||
}) | |||
}, | |||
async queryTxInfo({ state, dispatch }, height) { | |||
let blockTxInfo = state.blockTxs.find( |
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.
why not store them per height?
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.
was following method used by queryBlockInfo()
but you're right keying the height is smart i'll update both of em
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.
actually just updating the blockchain one for sake of PR scope
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.
actually i think both of these need to stay as arrays as they are used in for loops
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.
Can you point me to where they are used in loops? What I have found, there is always a selection by height happening when blockTxs appear in code.
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.
oops i totally misinterpreted the unit test error relating to should disable the next block button if last block
. thought that info was counting an array length for looping and failed when it became an obj (as per a similar error in blockchain.spec.js
). i've gone back and updated to a keyed storage method for blockTxs
as well as blockMetas
blockTxInfo && state.blockTxs.push(blockTxInfo) | ||
return blockTxInfo | ||
} catch (error) { | ||
return Promise.reject(error) |
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.
isn't that the default for async functions rejecting on error?
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.
i was having trouble getting the error reporting come out correctly in the tests so went through and made each error very explicit until i found the culprit, i'll walk it back
}, | ||
getTxs({ state, commit, dispatch }, { key, len, txs }) { | ||
return new Promise(async (resolve, reject) => { | ||
if (key >= len) return resolve(txs) |
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.
Could you add a comment stating what this statement accomplishes?
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.
👍
return Promise.reject(error) | ||
} | ||
}, | ||
convertTx({ state }, txstring) { |
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.
this doesn't do any manipulation on the store and should therefor maybe be in a script or someplace
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 clever place to put it in or just make a new file under /src/scripts?
@@ -84,9 +85,9 @@ export default ({ commit, node }) => { | |||
}, | |||
async queryWalletHistory({ state, commit, dispatch }) { | |||
commit("setHistoryLoading", true) | |||
// let res = await node.coinTxs(state.address) | |||
let res = await node.coinTxs(state.address) |
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.
does history work again?!
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.
oh i uncommented this to see what NiLiTx
looked like and it seemed to work with mock network. i'll remove tho since that's not the point of this pr
app/src/renderer/scripts/utils.js
Outdated
import varint from "varint" | ||
import b64 from "base64-js" | ||
|
||
export default function(txstring) { |
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.
The script is called utils and exports a function that converts tx strings into json? I think this is not really understandable.
How about a script called tx-utils.js that exports a function named parseTx?
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.
I agree it should be named, could be something like getTxHash
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.
makes sense, i think getTxHash
is an accurate name
]) | ||
.then(() => { | ||
state.blockLoading = false | ||
dispatch("queryTxInfo", height) |
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 you return this, I think you save yourself the inner .catch
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.
refactored all the promises to be more concise
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.
Left some comments but nice work overall, I know it can be a pain figuring out how to derive the same hash as the golang code. 😋
app/src/renderer/scripts/utils.js
Outdated
import b64 from "base64-js" | ||
|
||
export default function(txstring) { | ||
let txbytes = b64.toByteArray(txstring) |
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.
Why add a dependency instead of doing Buffer.from(base64string, 'base64')
?
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.
didn't realize it was that ez!
let txstring = atob(txs[key]) | ||
let hash = await convertTx(txs[key]) | ||
node | ||
.txs(hash) |
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.
Why mix await
and .then
syntax?
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.
refactored all the promises to be more concise
blockTxInfo = await dispatch("getTxs", { | ||
key: 0, | ||
len: | ||
state.block && state.block.data && state.block.data.txs |
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.
What's the purpose of these chains of &&'s? Seems like it makes things harder to debug because if the format changes or data is missing, it will silently pass this call and have undefined behavior inside getTxs.
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.
this was to allow the tests that had very minimal dummy blocks to pass. but you're right if the block is malformed it should throw an error. i've updated the other tests to use a well formed block dummy
app/src/renderer/scripts/utils.js
Outdated
@@ -0,0 +1,14 @@ | |||
import createHash from "create-hash" |
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.
Couldn't we just get this from the Node crypto module to avoid adding a dependency?
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.
nice, didn't realize it was also that ez
app/src/renderer/scripts/utils.js
Outdated
import varint from "varint" | ||
import b64 from "base64-js" | ||
|
||
export default function(txstring) { |
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.
I agree it should be named, could be something like getTxHash
Closes #454
Description:
the block explorer doesn't show any details of transactions.
followed the same method of querying txs from the explorer and added an rpc handler to get them.
need help with layout design of how these should look @nylira @jolesbi
will add tests next as this is still WIP