EOS WiKi Bilingual News & Info Of EOS, Vote for us: eosdotwikibp

EOSIO.CDT1.6.0版本:构建更无缝的合约开发体验/EOSIO.CDT Version 1.6.0: Building Towards a More Seamless Contract Development Experience

E
This image has an empty alt attribute; its file name is 1*DHuDRSDAgqASZXNzuONr4A.jpeg

译文/Translated:

作为EOSIOTM软件开发和优化的推动者,我们很荣幸在此确认EOSIO.CDT稳定版本的发布。EOSIO.CDT V1.6.0的更多详细信息可在GitHub库中参阅。相关文档如常更新在EOSIO开发者门户

我们正积极了解企业在EOSIO软件上构建应用程序的情况,这是支持我们持续努力,以优化EOSIO开发者体验的基石。在此版本中,我们聚焦于创造更加无缝的智能合约开发体验,通过提供自动化排错工具以及新的功能,帮助实现被我们视为最优秀的开发操作。

继续阅读以下内容,了解EOSIO.CDT更新的功能:

EOSIO.CDT v1.6.0的亮点

自动生成的调度器

使用新发布的EOSIO.CDT 1.6.0版本,在编写EOSIO智能合约时,您将不再需要手动添加调度器或者使用EOSIO_DISPATCH宏指令。合约调度器将基于操作、通知处理程序、pre_dispatch挂钩(hook)以及post_dispatch挂钩进行创建。只要您在相应的属性中明确指定有效的EOSIO操作,它就允许将构成EOSIO操作的C ++技术命名为任何有效的C ++名称。

自动生成的调度器也能让智能合约开发者将合约逻辑分拆为子合约,并使用聚合模式将这些操作共同连接至调度器,并在开发更易维护的代码时拥有更大的控制权。

作为全新自动生成调度器的一部分,若基于此进行的操作没有条目,那么所有采用此功能构建的智能合约将为默认的assert。若智能合约接收到一个onerror通知,并且用户必须通过提供精确的onerror通知处理器选择退出此项操作,那么新的调度器也将采用assert。若您愿意,您依然能够为智能合约编写自己的调度器,此时不会自动生成调度器。

两项新的功能被定义为EOSIO智能合约开发项:pre_dispatch和post_dispatch。这些是挂钩(hook),合约编写者可以在自身的智能合约中为其定义,用以在调度前和调度发生后使用自定义验证/逻辑。

通知处理的第一级支持

如前所述,新的attribute[[eosio::on_notify(<code account>::<action name>]]现在实现了智能合约的通知处理。这种方法被记为通知处理器,与attribute[[eosio::action]]标记操作的方式类似。此新功能允许智能合约开发人员通过提供代码帐户和操作名称来指定处理器处理的通知类型。此外,代码账户可以为通配符(*),它让处理器能够接受来自任一代码账户的特定操作通知。添加通知处理的第一级支持,将减少智能合约编写者使用自定义宏或手写自己的调度器的需求。

为“原生”构建的智能合约进行适当排错

Linux和macOS都增加了对智能合约“原生”构建的源代码级的排错支持。有关智能合约原生API和工具集的更多信息请参阅GitHub中native-tester文档。

划分eosiolib,以求更好地实现开发的最佳操作

过去,用以开发智能合约的C API被错误使用,但通过本发行版中提出的C ++类型安全替代方案,可以更好地实现其功能。从此以往,采用C++进行开发的智能合约开发人员将无法再使用C API。这可能会为直接使用旧C-API的开发人员带来重大变化。但是,如果您仍然需要使用这些,则必须使用C构建智能合约并使用C编译器。请注意,如果您选择继续使用,您将无法使用新的功能,例如自动生成的调度器以及eosiolib附带的大部分内容。为了简化智能合约开发人员的过渡,已经努力为C++类型的安全对应程序维持与C内联函数对接的语法接口。这意味着大多数C API内在函数现在具有适当的C ++类型安全替代方案。未更改病名,采用相同数量的参数,并且采用语法“匹配”的类型。但是,某些内联函数无法以这种方式创建,并可能导致构建破裂。这些新的划分库在此版本中为选择性加入,同时带有旧有包含项的弃用警告,因此,若开发人员愿意,他们有时间对自身的合约进行更新。

全新EOSIO.CDT库以及其他弃用工具

此版本中的EOSIO.CDT中添加了两个新的库:softfloat和compiler-rt。它们与flag use-rt一同使用,以生成不导入compiler-rt内联函数的二进制文件。这对于生成更加自包含的WebAssembly非常有用。当wasm-ql问世,并添加未来WASM模式时,这会变得更加有用。#325

由于eosio-ld和eosio-cpp的ABI连接功能,此版本中也启用了eosio-abigen工具。未来,eosio-cpp将与abigen flag一起使用。即便这不是最佳操作也应当将这两项进行联合,因为除非您的合约代码更新,否则ABI不会改变。#377

新发布版本更新的完整列表请在Github之上参阅EOSIO.CDT1.6.0变更总结

社区开发者支持

除了我们不断成长的Block.one团队,我们想要特别感谢几个其他的社区贡献者,他们也为此次版本的发布提供了补丁。在此代表EOS社区,感谢你们为EOSIO软件发展所提供的帮助和贡献:

  • @conr2d
  • @maoueh

保持连接

一如既往,若您有意提供反馈并与我们的团队密切合作,为社区优化EOSIO,您可以向开发者关系团队发送邮件,邮箱为:developers@block.one。

您也可以在EOSIO开发者门户订阅我们的邮件列表,获得更多更新信息。我们很高兴将继续为EOSIO的开发者们完善软件的使用,我们将持续为区块链的大规模应用奠定坚实的基础。

免责声明

Block.one作为EOSIO社区的一员,自愿做出自身贡献,并不对软件的总体性能及任何相关应用程序负责。对于此处所述版本以及相关GitHub版本或EOSIO软件,我们不作任何明示或暗示的陈述、保证、担保或承诺,包括且不限于提供担保,保证适销性或对某一特定目的和非侵权的适用性,并不承担相应的责任。在任何情况下,无论是合约操作、侵权行为或其他,亦无论是否与软件或文档相关,或由于软件使用导致,或在软件和文档上的其他交易导致的任何索赔、损害赔偿或其他债务,我们均不承担责任。任何测试结果或绩效数据具有指示性,无法反映所有情况下的绩效。任何对第三方或第三方产品、资源或服务的引用都不受Block.one的认可或推荐。对于您使用或信任这些资源的行为,我们概不负责,并且不承担任何责任和义务。第三方资源可能随时更新、变更或终止,因此此处的信息可能已过期或不准确。

原文/Original:

As a contributor to the development and enhancement of the EOSIO™ software, we are pleased to confirm that a stable release is available for EOSIO.CDT. More details about EOSIO.CDT v1.6.0 are available in the GitHub repository. Documentation, as always, is updated on the EOSIO Developer Portal.

We are actively engaged in how businesses are building applications on the EOSIO software, which underpins our continual efforts to improve the developer experience with EOSIO. In this release, we focus on our intention to create a more seamless experience developing smart contracts by providing automation, debugging tools, and new features to facilitate what we believe to be best practices in development.

Continue reading below for the features updated in EOSIO.CDT:

Highlights in EOSIO.CDT v1.6.0

Auto-Generated Dispatcher

With the release of EOSIO.CDT v1.6.0, when writing smart contracts for EOSIO, you no longer need to manually add a dispatcher or use the EOSIO_DISPATCH macro. The dispatcher will be created for the contract based on actions, notify handlers, pre_dispatch hook and post_dispatch hook. What this new feature does is it allows for the naming of C++ methods that constitute EOSIO actions into any valid C++ name, as long as you explicitly specify the valid EOSIO action in the corresponding attribute.

The auto-generated dispatcher also enables smart contract developers to split up the logic of their contracts into sub-contracts and use an aggregate pattern to link these actions together in the dispatcher and have greater control in developing easier-to-maintain code.

As part of this new auto-generated dispatcher, all smart-contracts built with this functionality will be default assert if an action is run against it that it has no entry for. The new dispatcher will also assert if the smart-contract receives an onerror notification and the user would have to opt out of this by supplying an explicit notification handler for onerror. If desired, you are still able to write your own dispatcher for the smart contract in which case one will not be auto-generated.

Two new functions are defined for EOSIO smart contract development: pre_dispatch and post_dispatch. These are hooks that the contract writer can define in their smart contract to apply custom validation/logic before any dispatching is done and after any dispatching occurs.

First Class Support for Notification Handling

As mentioned above, notification handling for smart-contracts is now enabled by a new attribute [[eosio::on_notify(<code account>::<action name>]] This marks a method as a notification handler, much like how the [[eosio::action]] attribute is used to mark an action. This new functionality allows smart contract developers to specify what types of notifications a handler handles by giving the code account and name of the action. In addition to this, the code account can be a wild-card (*), which would allow the handler to accept notifications of a particular action from any code accounts. The addition of first class support for notification handling should eliminate the need for smart contract writers to use custom macros or hand write their own dispatchers.

Proper Debugging for “Native” Built Smart-Contracts

Support for source-level debugging for the “native” builds for smart contracts has been added for both Linux and macOS. For more information about the native smart contract API and set of tools, please refer to the native-testerdocumentation in GitHub.

Partitioning of eosiolib to Better Facilitate Development Best Practices

Historically, the C API for smart contract development has been error-prone to use, but its functions are better served through C++ type-safe alternatives proposed in this release. Going forward, the C API is no longer available to smart-contract developers developing with C++. This may inflict breaking changes for developers that are explicitly using the old C-API. If you still need these, however, you will have to build your smart contract with C and use the C compiler. Note that if you choose this approach, you will lose the ability to use new features, such as auto-generated dispatchers and most of what comes with eosiolib. To ease the transition for smart-contract developers, effort has been made to maintain lexical interfaces with the C intrinsics for their C++ type-safe counterparts. This means that most of the C API intrinsics now have proper C++ type-safe alternatives with no naming changes and take the same number of arguments and use types that lexically “match”. However, some of the intrinsics could not be created this way and may cause breakage of builds. These new partitioned libraries are an opt-in for this release with deprecation warnings for the old includes, so developers have time to update their contracts if they so choose.

New EOSIO.CDT Libraries and Additional Deprecated Tools

Two new libraries have been added to EOSIO.CDT in this release: softfloat and compiler-rt. These can be used with the flag use-rt to produce a binary that doesn’t import the compiler-rt intrinsics. This is useful for generating WebAssembly that is more self-contained. This will be more useful when wasm-ql arrives and future WASM modes are added. (#325)

The eosio-abigen tool has also been deprecated in this release because of the “ABI” linking capabilities of eosio-ld and eosio-cpp. In the future, use eosio-cpp with the — abigen flag. These two should be linked regardless as a best practice because the ABI shouldn’t change unless your contract code is updated. (#377)

For a full list of updates made in this release, please refer to the Summary of Changes in EOSIO.CDT 1.6.0 in detail on Github.

Community Developer Support

In addition to our growing team at Block.one, we would like to send our special thanks to a few other community contributors who have submitted patches for this release. On behalf of the community, thank you for your contributions and commitment to the growth of the EOSIO software:

  • @conr2d
  • @maoueh

Stay Connected

If you are interested in providing feedback and working more closely with our team to improve the EOSIO software for developers, you can send our developer relations team an email at developers@block.one.

You can also keep up to date with future updates by subscribing to our mailing list on the EOSIO Developer Portal. We are excited to be continually improving the usability of the software for EOSIO developers as we continue laying a foundation for the mass adoption of blockchain technology.


Disclaimer

Block.one makes its contribution on a voluntary basis as a member of the EOSIO community and is not responsible for ensuring the overall performance of the software or any related applications. We make no representation, warranty, guarantee or undertaking in respect of the releases described here, the related GitHub release, the EOSIO software or any related documentation, whether expressed or implied, including but not limited to the warranties or merchantability, fitness for a particular purpose and noninfringement. In no event shall we be liable for any claim, damages or other liability, whether in an action of contract, tort or otherwise, arising from, out of or in connection with the software or documentation or the use or other dealings in the software or documentation. Any test results or performance figures are indicative and will not reflect performance under all conditions. Any reference to any third party or third-party product, resource or service is not an endorsement or recommendation by Block.one. We are not responsible, and disclaim any and all responsibility and liability, for your use of or reliance on any of these resources. Third-party resources may be updated, changed or terminated at any time, so the information here may be out of date or inaccurate.

原文链接/Original URL:

https://medium.com/@eosio/eosio-cdt-version-1-6-0-building-towards-a-more-seamless-contract-development-experience-2816084a4615

About the author

By user
EOS WiKi Bilingual News & Info Of EOS, Vote for us: eosdotwikibp

Recent Posts