Skip to content
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

Replace Utils::toHex() with direct conversion. #61

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

pash7ka
Copy link
Contributor

@pash7ka pash7ka commented Apr 4, 2018

If an argument to a contract method is a string which can be converted to number (like "1"), Utils::toHex() does this conversion. Also if sting starts with '0x' it will be stripped, which may be not expected behaviour.

@codecov-io
Copy link

codecov-io commented Apr 4, 2018

Codecov Report

❗ No coverage uploaded for pull request base (master@1fb7762). Click here to learn what that means.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff            @@
##             master      #61   +/-   ##
=========================================
  Coverage          ?   88.24%           
  Complexity        ?      661           
=========================================
  Files             ?       47           
  Lines             ?     1455           
  Branches          ?        0           
=========================================
  Hits              ?     1284           
  Misses            ?      171           
  Partials          ?        0
Impacted Files Coverage Δ Complexity Δ
src/Contracts/Types/Str.php 100% <100%> (ø) 7 <0> (?)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 1fb7762...15b1103. Read the comment docs.

Copy link
Member

@sc0Vu sc0Vu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @pash7ka
If you pass 0x prefixed string, it will strip the zero.
I think it might not be expected behavior.
Maybe it better to change behavior in Util::toHex.

@pash7ka
Copy link
Contributor Author

pash7ka commented Apr 8, 2018

Hi @sc0Vu
With my fix 0x prefix will stay intact. One example of such string is tx hash, which somebody may want to store in the contract as a string.
I agree, that fixing this in Util::toHex would be preffered, but to do it properly we may need to add additional parameter to Util::toHex with the type of input. It's a major rewrite of this function, which i decided to leave up to you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants