-
Notifications
You must be signed in to change notification settings - Fork 102
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
fix: Rectified the incorrect tuple value #1166
Conversation
@shamim-io is attempting to deploy a commit to the Hiro Systems Team on Vercel. A member of the Team first needs to authorize it. |
const value = arg.repr.replace('u', ''); | ||
if (arg.name.includes('ustx')) { | ||
const value = arg?.repr?.replace('u', ''); | ||
if (arg?.name?.includes('ustx')) { |
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 suggest we remove the optional operator ?
whenever possible. It looks like it used to expect arg to always exist.
|
||
const getReprValue = (item: any) => { | ||
let reprValue = item?.value ?? 'none'; | ||
if (item?.type?.includes('list')) { |
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.
Same for this one
Thank you for the PR @shamim-io! Left a few comments, please let me know if you have any questions. |
@He1DAr Can you please provide me a new tx link. The link that was provide to me earlier seems doesn't exist anymore. This was the link provided previously: https://explorer.hiro.so/txid/0x5644ab5008b78ada724946693bae8b64b221f84ed3234152e1553a1f978e8d3a?chain=testnet |
@He1DAr I have updated the PR. Please check! |
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.
Awesome work @shamim-io! Left a few comments.
if (item.type.includes('list')) { | ||
reprValue = item.value.map((listEntry: any) => listEntry.value).join(', '); | ||
} | ||
return typeof reprValue === 'object' ? JSON.stringify(reprValue) : reprValue.toString(); |
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.
Please try to avoid calling toString
for the list case as it's already a string. A similar implementation like existing one should do the trick.
@@ -15,6 +15,15 @@ export const FunctionSummaryResult = ({ result, txStatus }: FunctionSummaryResul | |||
if (!result) return null; | |||
const { success, type, value } = cvToJSON(hexToCV(result.hex)); | |||
const hasType = !type?.includes('UnknownType'); | |||
|
|||
const getReprValue = (item: any) => { |
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.
Please add typing to function argument and unit tests.
@@ -77,7 +77,16 @@ const TupleResult = ({ tuple, isPoxAddr, btc }: any) => { | |||
); | |||
}; | |||
|
|||
const getValue = (arg: { name: string; type: any; repr: any; value: any }, btc: null | string) => { | |||
const isJSONString = (str: string) => { |
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 suggest we move this to utility file and add a unit test.
} | ||
}; | ||
|
||
const getValue = (arg: any, btc: null | string) => { |
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.
Please add typing to function argument.
} | ||
}; | ||
|
||
const getValue = (arg: any, btc: null | string) => { |
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.
Please add unit tests to getValue
function that cover both cases (arg.repr is/isn't json).
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
@He1DAr I have updated the PR by adding typings and test cases wherever possible. However, there are components that still lack test cases. In those cases, I have refrained from writing a test case for a small function to avoid duplicating efforts. Instead, we need to create a test file for the entire component. |
if (!result) return null; | ||
const { success, type, value } = cvToJSON(hexToCV(result.hex)); | ||
const hasType = !type?.includes('UnknownType'); | ||
|
||
const getReprValue = ({ type, value }: ReprValueProps) => { | ||
let reprValue = value ?? 'none'; |
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 would add .toString();
to the value here to match the old code. This part is pretty sensitive to changes.
if (!result) return null; | ||
const { success, type, value } = cvToJSON(hexToCV(result.hex)); | ||
const hasType = !type?.includes('UnknownType'); | ||
|
||
const getReprValue = ({ type, value }: ReprValueProps) => { |
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 believe this function can be defined outside the component.
@@ -0,0 +1,45 @@ | |||
import { getValue } from './value'; |
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.
Thank you for adding tests!
const getReprValue = ({ type, value }: ReprValueProps) => { | ||
let reprValue = value ?? 'none'; | ||
if (type.includes('list') && Array.isArray(value)) { | ||
reprValue = value.map((listEntry: any) => listEntry.value).join(', '); |
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.
would be great if we eliminate this remaining any
Sounds good! Thank you for adding tests. I left a few tiny comments. Great work @shamim-io! |
57c2b1b
to
3db5913
Compare
🎉 This PR is included in version 1.123.0 🎉 The release is available on GitHub release Your semantic-release bot 📦🚀 |
closes #1156
Closes Incorrect display of optional in tuple result #1156
Fixes issue: Incorrect display of optional in tuple result
Feature details
Rectified the incorrect tuple value
Feature image