Comments (9)
That would be a helper method for string literals, but it wouldn't work for actual variables. Because of that I think it would be confusing/ misleading.
So mybytes = "abadad".HexToBytes()
would work but mybytes = myvar.HexToBytes()
would not
from neo-boa.
on that line hex
, unhex
could be a compiler level tool while it is not opcodes or interop ? this way we can actually start something: 1st as helpers -> interop -> opcode .. depending on the usage/popularity.
from neo-boa.
from neo-boa.
I believe @canesin will also support this, if possible to be implemented.
from neo-boa.
@metachris or @localhuman .. the idea is to remove the extension from the VM and replace it for a helper function into the compiler, this way support can be kept but behavior of the generated AVM is the same.
from neo-boa.
It doesn't make very much sense. a binary string, eg b'abmq'
is not necessarily one that an be unhexlified ( especially a binary string with an odd amount of characters ). If we arbitrarily unhex binary strings that can be unhexxed to something like b'\x01\xaf
etc, then we will be introducing a non-transparent api.
The main thing I have thought about in regards to this is that the VM should have opcodes ( or there should be interop methods) to hex
and unhex
a string or string of bytes.
from neo-boa.
Not sure this has a strong enough use-case to warrant a backwards incompatible change. Would break applications that used this part before.
What about a helper the other way around, to easily convert unhexlify a bytearray into the current format?
from neo-boa.
Thats true, not all bitstrings can be unhexlified, too bad, that would be beautiful :) anyway, keeping compatibility is also quite important, so a helper method HexToBytes will do the job. But still its better to accept a bitstring perhaps or both (string and bitstring) since its a helper it doesnt.matter on the avm. Thanks for the attention.
from neo-boa.
Guys, you know in C# there's already a helper to do it... something like: const byte[] b = "abcdabcd".HexToBytes();
The generated opcodes are just abcdabcd
, and could solve at least the problem above... but the discussion is nice to have something in lower levels for Neo, it opens more possibilities to build a safer smart contract code.
from neo-boa.
Related Issues (20)
- Crowdsale Demo directory shouldn't be labeled "nex" HOT 1
- Crowdsale demo and nep5 demo should be the same style HOT 1
- The method to_s(), which generates the output of the executable in readable format, is outdated
- [Feature] Use Python assert in smart contract HOT 4
- Smart Contract Migration results in different return value HOT 1
- Add support for multi-line invocation
- Neo 3x support HOT 2
- Built-in command line interface for neo-boa HOT 1
- support for avmdbgnfo format HOT 4
- replace coz-bytecode dependency with official bytecode project HOT 1
- .abi.json support HOT 3
- Python typehinting support
- About NEP-5 Smart Contract
- Generating incorrect hash for ABI file HOT 1
- Visual DevTracker deploy function not detecting contracts compiled with neo-boa
- negative shift count error when running unit test HOT 1
- Convert byte array to number ? HOT 1
- Invoking Neo.Contract.IsPayable fails HOT 1
- Crowdsale Demo totalSupply returns circulation
- Crowdsale Demo Contract missing OnTransfer event in deploy
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from neo-boa.