COZ releases Boa v1.2.0, introducing boa-test-constructor and other improvements
- byAdmin
- 16 May, 2024
- 20 Mins
Introduction
Ahoy, developers! COZ has done it again with the release of Boa v1.2.0, the latest update to its Python smart contract compiler for the Neo N3 blockchain. This version packs a bunch of new features, improvements, and even a sprinkle of deprecations – because who doesn’t love a good cleanup? Whether you’re a coding wizard or just dabbling, this update promises to streamline your development process and sprinkle some magic dust on your smart contracts.
Key Updates
boa-test-constructor
Say hello to your new best friend: boa-test-constructor! With Boa v1.2.0, the days of wrestling with NeoTestRunner are over. Now, you can install this gem using `pip install neo3-boa[test]` and get right down to unit testing your code with newfound ease. Think of it as upgrading from a roommate who leaves dirty dishes everywhere to one who cooks you gourmet meals. Testing smart contracts has never been this smooth.
Type Union Annotations
Let’s talk type union annotations – because why should JavaScript have all the fun? Boa v1.2.0 introduces support for type union annotations leveraging the pipe operator. This addition provides developers with the flexibility they've been craving in their code. Imagine mixing your favorite ice cream flavors without any judgment; you get the best of both (or multiple) worlds, and your code gets a whole lot smarter.
Deprecated Warnings
In with the new, out with the old – it's the circle of software life. This update is issuing deprecated warnings for typing aliases and suggesting a migration to built-in types. Gone are the days of using List, Dict, and Tuple from the typing module; it's time to embrace the simplicity of the built-in types. And while you’re at it, import Collection, Mapping, MutableSequence, and Sequence from collections.abc. Think of it as Spring cleaning: a fresh start for a clutter-free coding space.
NeoMetadata.add_permission
Updating permissions just got a whole lot easier. The NeoMetadata.add_permission function signature has been revamped to be more intuitive, simplifying the addition of multiple method permissions. As we bid farewell to the @metadata decorator, know that the NeoMetadata return type is now the go-to for identifying the metadata function. It's like getting a new phone interface that's less confusing – streamlining the process so you can focus on more important things, like taking over the world with your code.
Improvements and fixes
Ready for some good news in your coding life? COZ has rolled out Boa v1.2.0, and it's brimming with enhancements that'll make you feel like a wizard with your Python wand. The highlight of this update is the introduction of the boa-test-constructor – think of it as your new bestie for unit testing. You can easily install it with `pip install neo3-boa[test]`. Adios, NeoTestRunner, hello easier and more versatile testing!
The update also brings some fancy new support for type union annotations using the pipe operator. Translation: more freedom and flexibility for developers, woohoo! Also, in this version, some old coding practices are getting the boot. Deprecated warnings will now pop up for typing aliases, and the use of List, Dict, and Tuple from the typing module is so out. Built-in types are in. Likewise, Collection, Mapping, MutableSequence, and Sequence should now be imported from collections.abc. A cleaner, streamlined code, just what the doc prescribed.
The cherry on top? The NeoMetadata.add_permission function signature has received a makeover for more intuitive use, simplifying the addition of multiple method permissions. Everyone loves a good makeover, right? The @metadata decorator has been retired. From now on, the metadata function will be recognized by using NeoMetadata as the function's return type. This update promises a plethora of delightful coding improvements, so let's dive into the detailed fixes and removals, shall we?
Dropped support for Python 3.10
First up, if you're a savvy coder keeping track of Python versions, you might want to pour one out for Python 3.10. Boa v1.2.0 has officially dropped support for it. Painful? Maybe a tad, especially if you were best buds with 3.10. But hey, everything has its season, and it's time to upgrade those skills and move forward. Remember, progress waits for no one!
Removing support for older versions can sometimes feel like having to say goodbye to a long-time friend but look on the bright side – it usually means enhanced security and better performance. The platform you’re working on keeps evolving, and Python v3.11 and beyond are packed with new features that can make your life easier. So, onwards and upwards to shinier, faster Python versions!
Tuple annotation behavior
Now, let's talk tuples – because who doesn't love a good tuple? Boa v1.2.0 has made sure to correct the annotation behavior related to tuples. It's the little things that matter, like making accurate annotations without having to resort to weird workarounds or casting shadows of doubt on your code. Say goodbye to confusing tuple annotations that needed more decoding than an ancient hieroglyphic!
This fix is like finally finding the matching sock you've been searching for in your code laundry basket. It brings clarity and precision back to your tuple annotations, making your life just a smidge easier. Yes, you can finally annotate tuples correctly and let out a communal sigh of relief.
runtime.script_container
Last but definitely not least, we’ve got an improvement for those using runtime.script_container. Boa v1.2.0 ensures that it now accurately returns the transaction type, which means no more casting needed. It's as if COZ took a giant lint roller and cleaned up those annoying bits in your script container.
You'll find that this update makes your runtime experience smoother and less cumbersome. The precision and efficiency it brings will save you not just time but quite a few headaches. Think of it as swapping out your old, creaky typewriter for a brand-new, sleek laptop. Yes, that much better.
Ethan Taylor
Ethan Taylor here, your trusted Financial Analyst at NexTokenNews. With over a decade of experience in the financial markets and a keen focus on cryptocurrency, I'm here to bring clarity to the complex dynamics of crypto investments.