1. 28 Sep, 2022 1 commit
    • Michael Müller's avatar
      Add E2E testing framework MVP (#1395) · 64fbe40a
      Michael Müller authored
      * Add missing words to spellcheck dictionary
      * Add `contracts-node.scale` metadata
      Has been exported via
      	cargo install subxt-cli
      	subxt metadata > contracts-node.scale
      For `substrate-contracts-node` v0.20.0.
      * Run `substrate-contracts-node` in CI
      * Invoke `cargo doc` separately for each crate
      * Add MVP for E2E testing framework
      * Add E2E tests for `contract-transfer` example
      * Add ToDo comment for migration to `state_call` RPC
      * Update to new `ink` entrance crate
      * Add ToDo for `node_log_contains`
      * Update to `ink` entrance crate
      * Migrate to `state_call` RPC
      * Always initialize `env_logger`
      * Use latest `subxt` release
      * Remove superfluous TODO
      * Apply `cargo fmt`
      * Adapt test fixtures
  2. 21 Sep, 2022 1 commit
  3. 13 Sep, 2022 2 commits
    • Sasha Gryaznov's avatar
      Add `ink_env::pay_with_call!` helper macro for off-chain emulation of sending... · d42bfbfd
      Sasha Gryaznov authored
      Add `ink_env::pay_with_call!` helper macro for off-chain emulation of sending payments with contract msg calls (#1379)
      * first ver.: transfer_in api function implememted but we can't have it in on-chain env
      * transfer_in moved to test_api
      * doc + example updated
      * Update examples/contract-transfer/lib.rs
      Co-authored-by: default avatarHernando Castano <HCastano@users.noreply.github.com>
      * use stmt moved to macro
      * docs and nitty gritties
      * moved the macro to the test mod
      * spell fix
      * next review round suggestions applied
      * Use four spaces for macro indentation
      Co-authored-by: default avatarHernando Castano <HCastano@users.noreply.github.com>
      Co-authored-by: default avatarHernando Castano <hernando@hcastano.com>
    • Andrew Jones's avatar
      Combine storage traits and derives into single crate (#1389) · fb871a04
      Andrew Jones authored
      * Add ink_storage_traits crate
      * Remove unused hash layout trait and impls
      * Remove dependency between storage traits and ink_env
      * Move Storable definition and derive to ink_storage_traits
      * Replace usages of primitives storable with new location
      * Fmt
      * README and license sym links
      * Fix up CI script crates and codegen symlinks
      * update CI crates again
      * Add StorageLayout impl for Hash
      * Fix up collections ui tests
      * Fix up storage traits tests
      * Add missing feature to codegen syn dependency
      * Fix storage traits reference in env
      * Add missing no_std cfg_attr
      * Fix example build
      * Fmt
      * Fix example
      * Move Clear trait to primitives
      * Fix example
      * Fix env access
      * Fix up docs
      * Trying to fix UI tests
      * Fix LICENSE and README paths
  4. 05 Sep, 2022 1 commit
    • GreenBaneling | Supercolony's avatar
      Storage refactoring new hope for review (#1331) · 5fc2d2af
      GreenBaneling | Supercolony authored
      * Import new unstable functions with transparent hashing.
      Updated the API to work with the generic key `K: Encode` instead of the old `Key`.
      Also, the change contains optimization to reduce the size of contracts. In most cases, it is `#[inline(always)]`; but `return_value` also got small optimization; removed usage of `extract_from_slice` where it is not needed.
      * primitives crate:
      Removed old 32 bytes `Key`. Replaced it with `u32`. Added `KeyComposer`, it is a helper struct that does all manipulation with the storage key. It allows concat two storage keys into one, compute storage key for fields based on the filed, struct, enum, variants names.
      Removed all tests and benches. Didn't add it for new primitives because the key is standard `u32` and all keys are calculated during compilation.
      storage crate:
      Removed `SpreadLayout`, `PackedLayout`, `SpreadAllocate`, `PackedAllocate`, and all related helper functions.
      Removed `Packed` struct cause it is the default behavior for storage right now. Added `Lazy` struct that allows `get`/`set` value from/into the storage. It is similar to `Mapping` but works with one storage key and one value.
      Introduced new main traits to work with storage in `storage/src/traits/storage.rs`.
      Also added a new `OnCallInitializer` trait to improve the flow with upgradable contracts and support initialization on demand by default. Added `pull_or_init` macro that inits the storage struct if it is impossible to load it. It also can be used as optimization for contracts without an explicit constructor.
      Replaced implementation of old traits for main primitives with a new one. Added blanket implementation of new traits for structures that are `Packed` by default. It reduces the amount of code and adds support of generic structures but adds problems with tuples(now tuples implement new traits only if inner items are `Packed`).
      Introduced `AutoKey` and `ManualKey` that allows specifying which key the user wants to use. Added support of it into all traits and structures.
      Refactored `Mapping` to follow new rules.
      * metadata crate:
      Updated storage layout in the metadata. Introduces the concept of roots and leafs. Root defines the storage key for all sub-tree until there will be another Root. Leafs are common types that are part of the sub-tree and serialized/deserialized together into one storage key.
      Replaced 32 bytes storage key with `u32`.
      Added validation that all root storage keys don't overlap. Maybe better to add that error or reuse that validator on the `cargo-contract` side to show a more user-friendly error.
      `RootLayout` and validator are used in codegen(next commit). The contract is wrapped into `RootLayout`, and we do validation for that tree.
      Metadata now contains name for each struct/enum/variant/field. It is useful information because now the storage key is calculated based on the name of struct/enum/variant/field.
      storage crate:
      Added a new helper crate `storage/codegen`. It contains some useful functional that is used in `ink_storage_derive` and in `ink_lang_codegen` crates. It has a method that returns all types of the struct/enum/unit and a method that finds "salt" in the generics of the struct/enum. It uses magic constant "KeyHolder"(about that you can read in issue) to find salt, so I tried to have only one place where we are using that constant.
      Replaced derive implementation of old trait with new one. You can check the tests to see how the implementation looks like. `Storable` recursively call `encode` and `decode` for all fields. `KeyHolder` return key of the salt. `Item` uses `AutoKey` or key specified by the user. I want to highlight that `PreferredKey` only is used with the `AutoItem` trait. If `PreferredKey` is `AutoKey`, then `AutoItem<AutoGenerated>` select auto-generated key, otherwise preferred. So `AutoItem` trait decides that key to use. It is why derive macro only set `PreferredKey`.
      Updated drive for `StorageLayout`, now it uses `u32` and pass name of the struct into metadata.
      * Removed `initialize_contract` and related to initialization stuff. Now the codegen uses `pull_or_init` in the `call`. Updated `execute_constructor` to work with new storage methods.
      Allowed usage of generics during the declaration of the primary contract storage. Users can specify the default storage key with `KeyHolder` via generic.
      Added parser for `storage_item` macro with its config.
      * Removed the old codegen related to spread and packed layout. If some object implements `Decode` and `Encode`, it is `Packed`, and it uses the blanket implementation of new traits.
      In dispatch, codegen started to use a new method to work with storage.
      In metadata codegen added usage of new `RootLayout`. We wrap the contract into that layout because the contract has its storage key for all inner fields by default. Also added a run of validation logic during metadata generation.
      Added `storage_item` macro. It transforms all types from autokey into manual key(if types support it). It calculates the storage key based on the name(it uses the `KeyComposer::compute_key` function from the primitives crate). Also, macro generates an additional `Check` structure that includes all raw fields. It helps show correct errors to the user in case of typos, wrong types, etc.
      * Updated all examples to use a new API.
      Simplified delegate call example very well causes of new `OnCallInitializer` trait and support of manual specifying key.
      * UI tests for a new codegen.
      Can't highlight something unusual here=)
      * Apply all suggestion from the review
      * Make CI happy
      * Fix tests
      * Fix tests
      * Fix tests
      * Fix tests
      * Apply suggestions:
      - In most cases it is comments=)
      - Moved `pull_or_init` on one level upper.
      - Put the tests into the `impls/mod.rs`
      * Fix doc
      * Add comment to autoref specialisation
      * Suggestion from the review
      * Revert back u8
      * Remove unwrap
      * Collapse if let
      * Fixed overflow for enums
      * Fixing comments
      * Renamed `Item` to `StorableHint` and `AutoItem` to `AutoStorableHint`
      * Fix test
      * Renamed key_holder.
      Add UI test for double storage_item.
      Applied suggestion from the review.
      * Nightly fmt
      * Remove `Packed` path
      * Fix doc test
      * Apply suggestions from hte review
      * Fixed build
      * Fix build
      * Removed `initialize_contract` from linting and deleted all tests
      * Fix doc link
      * Fix mapping example
      * Applied suggestion.
      Removed `delegate-call` example with `OnCallInitializer`
      * Removed `delegate-calls` from the CI. Replaced it with `set-code-hash`
      * fix test
      * fix test
      * Fix CI to use stable for contract build
      * Fix CI to use stable for examples
  5. 25 Jul, 2022 1 commit
  6. 23 May, 2022 2 commits
  7. 18 May, 2022 1 commit
  8. 13 May, 2022 1 commit
  9. 11 May, 2022 1 commit
  10. 04 May, 2022 1 commit
  11. 03 May, 2022 1 commit
  12. 22 Apr, 2022 2 commits
  13. 08 Apr, 2022 1 commit
  14. 15 Mar, 2022 1 commit
  15. 08 Mar, 2022 1 commit
    • Oleksandr Mykhailenko's avatar
      `CallBuilder` delegated calls API (#1133) · f4252a0a
      Oleksandr Mykhailenko authored
      * [env] [lang] refactor CallBuilder to allow for delegate calls, add delegated calls implementations, update expected test results
      * Created an upgradable flipper. `Upgradable<bool, NotInitialized>` means that the code will init `bool` if storage cell is empty. But if it is not empty, it will use the value from the storage.
      * Get updated key
      * [env] update proxy example
      * [env] fix `build_call` compilation errors
      * [env] allow complex types
      * [lang] fix doc-tests for `eval_contract`, `eval_contract_delegate`, `invoke_contract`, `invoke_contract_delegate`
      * [examples] Add description to `ProxyFields` struct
      * [examples] Change version for `upgradeable_flipper`
      * Rebased to latest `master`.
      Fixes according comments in PR.
      * Fix tests
      * Fix tests
      * Fix tests
      * Changes according comments in PR.
      * "upgradeable" everywhere instead of "upgradable"
      * Changes according the suggestion in the PR
      * Fix clippy
      * Fixes according Cmichi's comments
      * Fixes according HCastano's comments
      * Fixed the bugs after merging with `master`. Applied last suggestions from the PR
      Co-authored-by: default avatarxgreenx <xgreenx9999@gmail.com>
  16. 07 Mar, 2022 1 commit
    • Andrew Jones's avatar
      Unify `ink_env::{eval_contract, invoke_contract}` (#1165) · 776df42c
      Andrew Jones authored
      * Merge contract invoke and eval
      * Fix up call builder
      * Fmt
      * Restore off chain param getters
      * Use ReturnType in generated CallBuilder
      * No longer need to explicitly wrap return type in ReturnType
      * Fmt
      * Remove some unused ReturnType usage
      * Default to `returns::<()>()`, remove ReturnType usage in api
      * Fmt
      * Fix UI test
      * Another UI test
  17. 04 Mar, 2022 1 commit
  18. 02 Mar, 2022 2 commits
  19. 01 Mar, 2022 2 commits
  20. 26 Feb, 2022 1 commit
  21. 23 Feb, 2022 1 commit
    • Sasha Gryaznov's avatar
      Implement `seal_is_contract` and `seal_caller_is_origin` (#1129) · ff5add1c
      Sasha Gryaznov authored
      * [env][lang] add support for new `is_contract` API
      * added `is_contract()` to ink_lang::EnvAccess to use from within contract with self.env()
      * added `is-contract` example
      * add support for `caller_is_origin()` API
      * updated is-contract example to use `caller_is_origin()` as well
      * Corrections in response to @HCastrano review
      * removed `examples/is-contract`
      * turned back whitespaces in `env_access.rs` not to mess up with the changed thing
      * added new functions to `experimental_offchain_engine`
      * fixed `wrong_self_convention` clippy warning for `is_` functions
      * supressed `wrong_self_convention` clippy warning for `is_` functions
      This reverts commit a40fab17
      * Update crates/env/src/api.rs
      Co-authored-by: Michael Müller's avatarMichael Müller <mich@elmueller.net>
      * set `is_contract` and `caller_is_origin` as `unimplemented` in experimental_off_chain eingine
      * Apply suggestions from code review
      Co-authored-by: default avatarHernando Castano <HCastano@users.noreply.github.com>
      * message cant take ref as a param: revert suggested change
      Co-authored-by: Michael Müller's avatarMichael Müller <mich@elmueller.net>
      Co-authored-by: default avatarHernando Castano <HCastano@users.noreply.github.com>
  22. 10 Feb, 2022 1 commit
    • Davide Galassi's avatar
      Enable use of global secp256k1 context (#1123) · 88b12d69
      Davide Galassi authored
      * Enable use of global secp256k1 context
      Context creation is expensive.
      Use the preallocated context that ships with the library.
      * Cargo fmt
      * Set `secp256k1` crate as optional
      * `global-context` feature depends on `std`
      * Its usage scope was already limited to `std` environment
      * ink-engine requires `secp256k1` feature
  23. 09 Feb, 2022 1 commit
  24. 17 Jan, 2022 1 commit
  25. 04 Jan, 2022 1 commit
  26. 16 Dec, 2021 1 commit
  27. 10 Dec, 2021 1 commit
    • Michael Müller's avatar
      Remove `BelowSubsistenceThreshold` and `NewContractNotFunded` (#1062) · 9ed2f488
      Michael Müller authored
      * Remove `BelowSubsistenceThreshold` and `NewContractNotFunded`
      * Fix `clippy:single-match`
      * Fix doc-link
      * Fix `clippy:redundant-pattern-matching`
      * Fix error codes
      * Fix error codes
      * Remove superfluous whitespace
      * Clarity what minimum balance refers to
      * Fix typo: chain's ➜ chains
      * Revert "Fix typo: chain's ➜ chains"
      This reverts commit 40c0920f.
  28. 08 Dec, 2021 2 commits
  29. 02 Dec, 2021 2 commits
  30. 30 Nov, 2021 1 commit
  31. 26 Nov, 2021 1 commit
  32. 24 Nov, 2021 2 commits