ethereum / play

playproject
https://playproject.io
MIT License
22 stars 5 forks source link

Solidity validator - BYTES #136

Closed ninabreznik closed 5 years ago

ninabreznik commented 5 years ago

We need to validate bytes field too. So far we were validating it as a string, but when we send the EVM doesn't accept it as a string, but we need to convert it into a byte, so it makes sense to also validate it as a byte.

So, we should validate both:

There are many types of bytes, so we also need to check if it's bytes, byte32 etc.

alincode commented 5 years ago

bytes1 0x00 ~ 0xff bytes2 0x0000 ~ 0xffff

ninabreznik commented 5 years ago

I actually don't know exactly, but if both are valid bytes, we can except any and then before I send them to the contract with ethers.js, I encode them into the right format that ethers.js excepts. But user should be able to write any valid format of bytes. Also a string...

Does that make sense?

ninabreznik commented 5 years ago

@alincode Just implemented formating and parsing bytes when sending a transaction.

This is the format of the hex byte ethers.js wants 0x736f6d657468696e670000000000000000000000000000000000000000000000

So, user can either write a string, that will be formatted to a bytecode or they can paste in the bytecode itself in this format 0x736f6d657468696e670000000000000000000000000000000000000000000000

Please let me know once validators are ready so I can update it in the smartcontract-app.

I am using ethers.js (ethers.utils.formatBytes32String and ethers.utils.parseBytes32String)

alincode commented 5 years ago

@ninabreznik I know how to valid bytes, so I just noted it for myself. when I finish, I will leave the release message to you.

ninabreznik commented 5 years ago

@alincode Perfect. Let me know once you're done so I can update the validate module and test it in smartcontract-app :)

alincode commented 5 years ago

@ninabreznik

release at https://www.npmjs.com/package/solidity-validator 0.2.1

alincode commented 5 years ago

@ninabreznik fixed and update at 0.3.0