celestiaorg / protobuf3-solidity-lib

Codec library for protobuf3 in Solidity
Apache License 2.0
14 stars 4 forks source link

Seems like doesn't compile with 0.8.4 solidity. #42

Closed andrewshvv closed 2 years ago

andrewshvv commented 2 years ago
Compiling 2 files with 0.8.4
TypeError: Unary operator - cannot be applied to type uint64
   --> @lazyledger/protobuf3-solidity-lib/contracts/ProtobufLib.sol:255:43:
    |
255 |         uint64 zigzag_val = (val >> 1) ^ (-(val & 1));
    |                                           ^^^^^^^^^^

TypeError: Unary operator - cannot be applied to type uint64
   --> @lazyledger/protobuf3-solidity-lib/contracts/ProtobufLib.sol:281:43:
    |
281 |         uint64 zigzag_val = (val >> 1) ^ (-(val & 1));
    |                                           ^^^^^^^^^^

TypeError: Explicit type conversion not allowed from "int32" to "uint64".
   --> @lazyledger/protobuf3-solidity-lib/contracts/ProtobufLib.sol:658:30:
    |
658 |         return encode_varint(uint64(n));
    |                              ^^^^^^^^^

Error HH600: Compilation failed
andrewshvv commented 2 years ago

@adlerjohn

We have fixed it here, but also introduced some unnecessary changes, let me know if I need to create a pull request. All tests seem to be working. Overall thanks for such a library!

We probably plan to use it to store NFT metadata, because metadata is used inside the smart contract. And .proto inside the IPFS for UI to understand the metadata.

Changes:

adlerjohn commented 2 years ago

Thanks, that's amazing! A PR would definitely be appreciated. Could you open one for each of the above 4 features, so they can be reviewed and tested in isolation (or use your best judgement to break it up into atomic changesets)?

andrewshvv commented 2 years ago

hey, I remember about this, just didn't have the time to break it down yet.