We explicitly decided this architecture change, or this pattern, so that a lot of community does not break their projects, and they can easily migrate to the version four, which is more recent.
And the question is like, does it just rewrite of the v1 with the same API or does it include some new features as well or not? Yes, it is. It contains a lot of new features. It's not just the rewrite. Rewrite was the first objective, but during the rewrite, we focused on creating more features within the library so that we can be future safe and we can extend the library very easily in the future.
And some of the features which I'm going to present here, which is very unique for the version one, version four for the Web3.js library is unique in the Ethereum ecosystem. No other package or the utility as of now, which I remember may have introduced such features and hopefully you guys will like them.
So the first thing, the most important feature within our rewrite is this new introduction of the new validator. Because data is so important for any dev particularly and data validation has been an extensive job for the maintainers of the different devs and we decided to create a brand new layer of the declarative validation for the community. And we use this validator within our library as well and it is also available for you to use in your devs.
And so what is a declarative validator? So most of you know that JSON schema or JSON data is kind of a defacto data format for the JS community. JSON schema is also a defacto data standard for validation and communities already adopted it. So we use both of these schemes as a JSON data and the JSON schema and merge them together for the Ethereum community. And you don't need to have no if-else anymore and all of the validation that you're going to do using the JSON schema will be tightly coupled with the Ethereum types. So you don't need to remember the Ethereum native types or compare to the JavaScript native types. It will work seamlessly. And this validator is also compatible with Ethereum ABI schema. So if you have such an ABI, it will also validate the data based on the ABI as well.
Let's jump to some examples. So here you can see some examples. So we have some data and which contains some addresses in an array and some balance, and, if I go with the imperative validation, which we had been doing in previous library versions, you can see that, we have, some loops going on and then we are validating by using function calls and then throwing some errors and same for the balance field that we have, we are particularly validating by using some function call. But if we go with a declarative approach, you can see that we have schema defined for the data and this schema is going to present the whole anatomy of the data and if you notice that the data that we are going to present is very particular for the Ethereum. So we have an address array, we have UN256. These are Ethereum types and we can validate this data based on this schema and there are different formats of the schema and hope you can explore further.
So there is another feature that we introduced in version 4 rewrite and this is going to change the way you look into your data. So the question is that every dApp that you develop is not the same. So the need for every dApp is also different. For example, someone developing an app or using a library where he needs numbers in the beginning. Someone wants numbers in a number or someone wants number to be a number string. Similarly for the bytes.
Comments