STLX-15822_add_explainTransaction_implemented_in_account_lib_call#2237
Conversation
Codecov Report
@@ Coverage Diff @@
## master #2237 +/- ##
===========================================
+ Coverage 0 52.61% +52.61%
===========================================
Files 0 6 +6
Lines 0 574 +574
Branches 0 94 +94
===========================================
+ Hits 0 302 +302
- Misses 0 262 +262
- Partials 0 10 +10
Flags with carried forward coverage won't be shown. Click here to find out more.
|
| }); | ||
| }); | ||
|
|
||
| describe('Explain Transactions:', () => { |
There was a problem hiding this comment.
Get Invalid cases.
| let rawTxBase64 = params.txPrebuild.txHex; | ||
| if (HEX_REGEX.test(params.txPrebuild.txHex)) { | ||
| rawTxBase64 = Buffer.from(params.txPrebuild.txHex, 'hex').toString('base64'); | ||
| } |
There was a problem hiding this comment.
Maybe be can do something like
const txHex = params.txPrebuild.txHex;
const rawTxBase64 = HEX_REGEX.test(txHex) ? Buffer.from(txHex, 'hex').toString('base64') : txHex;
I propose this because because Im kind of confused, params.txPrebuild.txHex is always a hex? or it could come as base64? if we always expect a hex, lets just the try catch do his job, delete the if.
There was a problem hiding this comment.
Well, I'm going to try this refactoring
| const explainedTransaction = (rebuiltTransaction as accountLib.BaseCoin.BaseTransaction).explainTransaction(); | ||
|
|
||
| return explainedTransaction as NearTransactionExplanation; |
There was a problem hiding this comment.
I think we can just add the type to the statement instead of use 'as'
let rebuiltTransaction : accountLib.BaseCoin.BaseTransaction;
and then
const explainedTransaction: NearTransactionExplanation = rebuiltTransaction.explainTransaction(); return explainedTransaction;
| const explainedTransaction = await basecoin.explainTransaction({ | ||
| txPrebuild: { | ||
| txHex: rawTx.transfer.signed, | ||
| }, | ||
| }); |
There was a problem hiding this comment.
What happen if we add
feeInfo: {
fee: '5000',
},
to the parameters? it is allowed by the function, can we add a test with that?
| throw new MethodNotImplementedError('Near recovery not implemented'); | ||
| ): Promise<NearTransactionExplanation> { | ||
| const factory = accountLib.register(this.getChain(), accountLib.Near.TransactionBuilderFactory); | ||
| let rebuiltTransaction; |
There was a problem hiding this comment.
reorder code here
There was a problem hiding this comment.
If I declare rebuiltTransaction as a constant inside the try block, I cannot use it later in line 175 because it is outside the scope of the try, that is why it was defined outside.
5802ee6 to
92e1d6b
Compare
92e1d6b to
09ec016
Compare
There was a problem hiding this comment.
nit: redundant variable
5aa5b50
09ec016 to
5aa5b50
Compare
…n core Add explainTransaction implemented in account lib call in core STLX-15822
5aa5b50 to
81d0861
Compare
Add explainTransaction implemented in account lib call in core.
STLX-15822