-
Notifications
You must be signed in to change notification settings - Fork 24
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(website): interact render of objects #1659
Conversation
return '0'; | ||
default: | ||
return '(no result)'; | ||
function _isArrayAbiParameter( |
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 it make sense to wrap Array.isArray
? perhaps we can use it directly in the condition.
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.
or is it for TS to devive the value to AbiParameter[]
?
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.
It is a TS thing, when used it fixes the types on the following lines
return arrayTooltip === _encodeArg(type, val) ? '' : arrayTooltip; | ||
} | ||
|
||
if (type.startsWith('bytes') && val.startsWith('0x')) { |
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 code is hard to read. Couldn't we use the return early strategy? It should eliminate the complexity.
if (type assertion) {
doSomething...
return
}
if (type assertion2) {
doSomething...
return
}
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 work Mati 💯 .
perhaps we can go one step further and convert packages/website/src/components/AbiParameterPreview
into a folder with the following structure:
utils > with all the internal functions. Then we can add UT in this folder for each function.
index.ts > that exports AbiParameterPreview.tsx
moving this chat here, from Mati to future references:
|
This PR refactors the Abi Input renderer from the TransactionDisplay component into a separate component, which then it is reutilised for rendering interact outputs. Effectively fixing some rendering bugs for rendering arrays and objects which were already solved on the TX view.
It also fixes the rendering of non-values for objects and arrays, generating an template result with zeroed values (working the same way as Solidity).