• Hero Bird's avatar
    Implement ink! chain extensions (#592) · 59a7f5ed
    Hero Bird authored
    * add new tests for #[ink(namespace = ..)] and #[ink(selector = ..)] attrs
    * [lang] implement new errors for ink! attributes: namespace, selector
    * add #[ink(extension = N: u32)] attribute
    * apply rustfmt
    * [lang] add initial implementation of chain extension proc. macro
    * [lang] rename AttributeArg -> AttributeFrag
    * rename AttributeFrag::kind field to arg
    * rename AttributeArgKind -> AttributeArg
    Also introduce a new AttributeArgKind type and AttributeArg::kind method.
    * [lang] apply rustfmt
    * add Display impl for AttributeArgKind
    * [lang] use AttributeArgKind in sanitize_attributes and ensure_first methods
    * [lang/ir] improve error reporting for duplicate ink! attributes
    * [lang/ir] refactoring and improvements to chain extension IR impl
    * [lang/ir] add tests for IR implementation of chain extensions
    * [lang/ir] remove some code dupe
    * [lang/ir] add getters to ChainExtension
    * [lang/ir] add re-exports for ChainExtension definitions
    * [lang/codegen] add initial impl for ChainExtensions
    * [env] add ChainExtension assoc type to the Environment trait
    * [lang] initial impl to make it possible to use chain extension syntax
    * [env] improvements to chain extensions API
    Also removes the unstable crate feature guarding the feature.
    * [lang/macro] add UI test for chain extension
    * [lang/macro] register new UI test
    * [lang/codegen] fix some codegen bugs with new chain extension feature
    * [lang, env] apply rustfmt
    * [lang/ir] apply clippy suggestions and fix outdated error messages
    * [lang/ir] fix some tests and incorrect error messages
    * [examples] apply clippy suggestion
    * add ErrorCode to ink! chain extension trait
    * add FromStatusCode trait to ink_lang
    * add #[ink(expect_output)] and #[ink(expect_ok)] attributes
    Also add their handling for the #[ink::chain_extension] proc. macro.
    * add ink_lang::IsResultType trait
    * add ChainExtensionMethodInputs iterator
    * hide docs for IsResultType trait
    * add some docs to chain extension codegen
    * implement expect_ok and expect_output where bounds in codegen
    * apply code review suggestions by (cmichi)
    * add ReturnCode::into_u32 getter
    * change return type of ext::call_chain_extension: RetCode -> u32
    Chain extensions do not follow the general scheme of error return code because they have their own set of errors that is custom defined by the author of the chain extension.
    * [lang] add ChainExtension trait
    Not yet sure we need it.
    * change EnvBackend::call_chain_extension signature
    The new signature is much more low-level and supports all the different ways to call a chain extension method.
    This commit already implements the chain extension call on the on-chain environment.
    More work needs to be done to properly support this for the off-chain environment.
    * remove old high-level API for calling chain extension methods
    * [env] add new high-level module to handle chain extension calls
    * rename ChainExtensionMethodInstance -> ChainExtensionMethod
    * [env] add doc examples to chain extension method API
    * apply rustfmt
    * [env] clippy: allow complex type in ChainExtensionMethod type state
    * silence some warnings
    * re-export IsResultType from ink_lang crate
    * [lang] remove FromStatusCode trait
    This trait already exists in the ink_env crate.
    * [lang] update codegen for chain extensions
    Not yet done but close.
    * [lang] update simple chain extension test
    Compiles now again.
    * apply rustfmt
    * update some license headers
    * [env] fix where bound
    * extend chain extension test case to cover all cases
    * add messages for read_small, access and unlock_access
    * fix some bugs with chain extension method signatures in test
    * fix some bugs and docs in chain extension test
    * fix test
    * update quickcheck to 1.0
    * [env] implement chain extension calling for off-chain env
    The new interface is much more lower-level and it is still impossible to use chain state from within the chain extension call. The latter must be fixed as soon as the off-chain environment receives its rework.
    * apply rustfmt
    * add docs to #[ink::chain_extension] proc. macro
    * rename env_types -> env everywhere
    * make doc examples for #[ink::chain_extension] compile
    * add yet another technical limitation
    * make link to simple.rs test case more stable (point to revision)
    * fix docs (code suggestion)
    Co-authored-by: Michael Müller's avatarMichael Müller <michi@parity.io>
    * fix docs (code suggestion)
    Co-authored-by: Michael Müller's avatarMichael Müller <michi@parity.io>
    * fix docs (code suggestion)
    Co-authored-by: Michael Müller's avatarMichael Müller <michi@parity.io>
    * fix docs (code suggestion)
    Co-authored-by: Michael Müller's avatarMichael Müller <michi@parity.io>
    * add dev. note to Backend::call_chain_extension
    * fix docs example (code suggestion)
    Co-authored-by: Andrew Jones's avatarAndrew Jones <ascjones@gmail.com>
    * [env] chain extension: make doc examples/tests compile
    * fix some doc comments according to review suggestions
    * review suggestion: telling -> meaning
    * fix docs (review suggestion)
    Co-authored-by: Andrew Jones's avatarAndrew Jones <ascjones@gmail.com>
    * fix docs (review suggestion)
    Co-authored-by: Andrew Jones's avatarAndrew Jones <ascjones@gmail.com>
    * improve docs (review suggestion)
    Co-authored-by: Andrew Jones's avatarAndrew Jones <ascjones@gmail.com>
    * rename chain extension test file
    * analyse_error_code add doc comments for possible errors
    * rename expect_ok -> returns_result and expect_output -> handle_status
    Some examples and docs might be invalidated or outdated.
    * [lang/ir] improve error reporting for ink! namespace attribute with missing parameter
    * [lang/*] implement new handle_status and returns_result attributes
    * [env] apply rustfmt
    Co-authored-by: Michael Müller's avatarMichael Müller <michi@parity.io>
    Co-authored-by: Andrew Jones's avatarAndrew Jones <ascjones@gmail.com>