Skip to content

Commit 7a95e98

Browse files
committed
Merge branch 'master' into aj/shared-events
2 parents ea73683 + 7b73701 commit 7a95e98

File tree

61 files changed

+552
-131
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

61 files changed

+552
-131
lines changed

.github/workflows/examples.yml

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ jobs:
2828
toolchain:
2929
- stable
3030
job:
31-
- build
31+
- contract build
3232
- test
3333
runs-on: ${{ matrix.platform }}
3434
env:
@@ -102,19 +102,19 @@ jobs:
102102
$delegator_subcontracts = "accumulator","adder","subber"
103103
foreach ($contract in $delegator_subcontracts) {
104104
echo "Processing delegator contract: $contract";
105-
cargo contract ${{ matrix.job }} --verbose --manifest-path examples/delegator/${contract}/Cargo.toml;
105+
cargo ${{ matrix.job }} --verbose --manifest-path examples/delegator/${contract}/Cargo.toml;
106106
}
107107
$upgradeable_contracts = "forward-calls","set-code-hash"
108108
foreach ($contract in $upgradeable_contracts) {
109109
echo "Processing upgradeable contract: $contract";
110-
cargo contract ${{ matrix.job }} --verbose --manifest-path examples/upgradeable-contracts/${contract}/Cargo.toml;
110+
cargo ${{ matrix.job }} --verbose --manifest-path examples/upgradeable-contracts/${contract}/Cargo.toml;
111111
}
112-
cargo contract ${{ matrix.job }} --verbose --manifest-path examples/upgradeable-contracts/set-code-hash/updated-incrementer/Cargo.toml;
112+
cargo ${{ matrix.job }} --verbose --manifest-path examples/upgradeable-contracts/set-code-hash/updated-incrementer/Cargo.toml;
113113
foreach ($example in Get-ChildItem -Directory "examples\*") {
114114
if ($example -Match 'upgradeable-contracts') { continue }
115115
if ($example -Match 'lang-err-integration-tests') { continue }
116116
echo "Processing example: $example";
117-
cargo contract ${{ matrix.job }} --verbose --manifest-path=$example/Cargo.toml;
117+
cargo ${{ matrix.job }} --verbose --manifest-path=$example/Cargo.toml;
118118
cargo clean --manifest-path=$example/Cargo.toml;
119119
}
120120
@@ -123,16 +123,16 @@ jobs:
123123
run: |
124124
for contract in ${DELEGATOR_SUBCONTRACTS}; do
125125
echo "Processing delegator contract: $contract";
126-
cargo contract ${{ matrix.job }} --verbose --manifest-path examples/delegator/${contract}/Cargo.toml;
126+
cargo ${{ matrix.job }} --verbose --manifest-path examples/delegator/${contract}/Cargo.toml;
127127
done
128128
for contract in ${UPGRADEABLE_CONTRACTS}; do
129129
echo "Processing upgradeable contract: $contract";
130-
cargo contract ${{ matrix.job }} --verbose --manifest-path=examples/upgradeable-contracts/$contract/Cargo.toml;
130+
cargo ${{ matrix.job }} --verbose --manifest-path=examples/upgradeable-contracts/$contract/Cargo.toml;
131131
done
132-
cargo contract ${{ matrix.job }} --verbose --manifest-path=examples/upgradeable-contracts/set-code-hash/updated-incrementer/Cargo.toml;
132+
cargo ${{ matrix.job }} --verbose --manifest-path=examples/upgradeable-contracts/set-code-hash/updated-incrementer/Cargo.toml;
133133
for example in examples/*/; do
134134
if [ "$example" = "examples/upgradeable-contracts/" ]; then continue; fi;
135135
if [ "$example" = "examples/lang-err-integration-tests/" ]; then continue; fi;
136136
echo "Processing example: $example";
137-
cargo contract ${{ matrix.job }} --verbose --manifest-path=$example/Cargo.toml;
137+
cargo ${{ matrix.job }} --verbose --manifest-path=$example/Cargo.toml;
138138
done

.images/inkternals.png

1.06 KB
Loading

.images/pallet-contracts.png

394 Bytes
Loading

CHANGELOG.md

Lines changed: 91 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,98 @@ All notable changes to this project will be documented in this file.
44
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
55
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
66

7-
## [Unreleased]
7+
## Version 4.0.0
8+
9+
The latest stable release of ink! is here 🥳
10+
11+
This version brings a lot of usability improvements, making the language better suited
12+
for the needs of production parachains.
13+
14+
A couple of highlights include:
15+
- Changes to how contract storage works, which significantly reduced the sizes of
16+
contract binaries
17+
- A new end-to-end testing framework, letting you easily write integration tests
18+
- Changes to the metadata format, which (in part) makes error handling more expressive
19+
20+
There's a lot more to dig through, so take some time to poke around the `CHANGELOG`
21+
(including the `4.0.0-alpha` and `4.0.0-beta` releases).
22+
23+
You may notice there have been a few breaking changes. No need to be scared though, we
24+
wrote up a [migration guide](https://use.ink/faq/migrating-from-ink-3-to-4) covering all
25+
of the breaking changes and how to update your ink! 3.x contract accordingly.
26+
27+
Thanks to everyone that helped make this release possible ❤️
28+
29+
### Compatibility
30+
31+
In order to build contracts which use ink! `v4.0.0` you need to use
32+
`cargo-contract`
33+
[`v2.0.0`](https://github.com/paritytech/cargo-contract/releases/tag/v2.0.0).
34+
You can install it as follows:
35+
36+
`cargo install cargo-contract --forced --locked`
37+
38+
You will also need to use a version of [`pallet-contracts`](https://github.com/paritytech/substrate/tree/master/frame/contracts)
39+
later than [polkadot-v0.9.37](https://github.com/paritytech/substrate/tree/polkadot-v0.9.37)
40+
in your node.
41+
42+
The [`v0.24.0`](https://github.com/paritytech/substrate-contracts-node/releases/tag/v0.24.0)
43+
release of the [`substrate-contracts-node`](https://github.com/paritytech/substrate-contracts-node) is
44+
compatible with the ink! `4.0.0` release.
45+
46+
For full compatibility requirements see the [migration guide](https://use.ink/faq/migrating-from-ink-3-to-4/#compatibility).
47+
48+
### Added
49+
- Add `Mapping::contains(key)` and `Mapping::insert_return_size(key, val)`[#1224](https://github.com/paritytech/ink/pull/1224)
50+
- Add [`payment-channel`](https://github.com/paritytech/ink/tree/master/examples/payment-channel) example ‒ [#1248](https://github.com/paritytech/ink/pull/1248) (thanks [@kanishkatn](https://github.com/kanishkatn)!)
51+
- Add `version` field to ink! metadata ‒ [#1313](https://github.com/paritytech/ink/pull/1313)
52+
- The `rand-extension` example has been adapted to an updated version of the `ChainExtension` API ‒ [#1356](https://github.com/paritytech/ink/pull/1356)
53+
- Add `ink_env::pay_with_call!` helper macro for off-chain emulation of sending payments with contract message calls ‒ [#1379](https://github.com/paritytech/ink/pull/1379)
54+
- Allow using `Result<Self, Error>` as a return type in constructors ‒ [#1446](https://github.com/paritytech/ink/pull/1446)
55+
- Add `Mapping::take()` function allowing to get a value removing it from storage ‒ [#1461](https://github.com/paritytech/ink/pull/1461)
56+
- Add E2E testing framework MVP ‒ [#1395](https://github.com/paritytech/ink/pull/1395)
57+
- Add E2E tests for `Mapping` functions - [#1492](https://github.com/paritytech/ink/pull/1492)
58+
- E2E: expose call dry-run method ‒ [#1624](https://github.com/paritytech/ink/pull/1624)
59+
- Make cross-contract callee non-optional ‒ [#1636](https://github.com/paritytech/ink/pull/1636)
60+
- Support custom environment in E2E tests - [#1645](https://github.com/paritytech/ink/pull/1645) (thanks [@pmikolajczyk41](https://github.com/pmikolajczyk41)!)
61+
862
### Changed
63+
- Contract size optimization in case contract doesn't accept payment ‒ [#1267](https://github.com/paritytech/ink/pull/1267) (thanks [@xgreenx](https://github.com/xgreenx)!)
64+
- Move ink! linter into `ink` repository ‒ [#1361](https://github.com/paritytech/ink/pull/1267)
65+
- Introduce `ink` entrance crate ‒ [#1223](https://github.com/paritytech/ink/pull/1223)
66+
- Use `XXH32` instead of `sha256` for calculating storage keys ‒ [#1393](https://github.com/paritytech/ink/pull/1393)
67+
- Storage Refactoring ‒ [#1331](https://github.com/paritytech/ink/pull/1331)
68+
- Add support for language level errors (`LangError`) ‒ [#1450](https://github.com/paritytech/ink/pull/1450)
69+
- Return `LangError`s from constructors ‒ [#1504](https://github.com/paritytech/ink/pull/1504)
70+
- Update `scale-info` requirement to `2.3`[#1467](https://github.com/paritytech/ink/pull/1467)
71+
- Merge `Mapping::insert(key, val)` and `Mapping::insert_return_size(key, val)` into one method - [#1463](https://github.com/paritytech/ink/pull/1463)
72+
- FFI: no more `__unstable__` wasm import module ‒ [#1522](https://github.com/paritytech/ink/pull/1522)
73+
- Clean up CallBuilder `return()` type ‒ [#1525](https://github.com/paritytech/ink/pull/1525)
74+
- Fix trait message return type metadata ‒ [#1531](https://github.com/paritytech/ink/pull/1531)
75+
- Bump Dylint dependencies ‒ [#1551](https://github.com/paritytech/ink/pull/1551)
76+
- Stabilize `take_storage`[#1568](https://github.com/paritytech/ink/pull/1568)
77+
- Chain Extension: Evaluation of method return type at compile time ‒ [#1569](https://github.com/paritytech/ink/pull/1569)
78+
- Make more functions be const ‒ [#1574](https://github.com/paritytech/ink/pull/1574) (thanks [@yjhmelody](https://github.com/yjhmelody)!)
79+
- Unify fallible and non fallible `instantiate` methods ‒ [#1591](https://github.com/paritytech/ink/pull/1591)
80+
- Make `CallBuilder` and `CreateBuilder` error handling optional ‒ [#1602](https://github.com/paritytech/ink/pull/1602)
81+
- Rename `CallBuilder::fire()` method to `invoke()`[#1604](https://github.com/paritytech/ink/pull/1604)
82+
- chore: add minimum rust version to the ink crate ‒ [#1609](https://github.com/paritytech/ink/pull/1609) (thanks [@Kurtsley](https://github.com/Kurtsley)!)
83+
- Rename `_checked` codegen call methods with `try_`[#1621](https://github.com/paritytech/ink/pull/1621)
84+
- Bump Substrate and `subxt` dependencies ‒ [#1549](https://github.com/paritytech/ink/pull/1549)
985
- E2E: spawn a separate contracts node instance per test ‒ [#1642](https://github.com/paritytech/ink/pull/1642)
1086

87+
### Fixed
88+
- Trim single whitespace prefix in the metadata `docs` field ‒ [#1385](https://github.com/paritytech/ink/pull/1385)
89+
- Allow pay_with_call to take multiple arguments ‒ [#1401](https://github.com/paritytech/ink/pull/1401)
90+
- Add Determinism enum from pallet-contracts ‒ [#1547](https://github.com/paritytech/ink/pull/1547)
91+
- Added missed `WhereClosure` for the generics into `storage_item`[#1536](https://github.com/paritytech/ink/pull/1536) (thanks [@xgreenx](https://github.com/xgreenx)!)
92+
93+
### Removed
94+
- Implement `ecdsa_to_eth_address()` and remove `eth_compatibility` crate ‒ [#1233](https://github.com/paritytech/ink/pull/1233)
95+
- Remove `wee-alloc`[#1403](https://github.com/paritytech/ink/pull/1403)
96+
- Remove `ink_env::random` function ‒ [#1442](https://github.com/paritytech/ink/pull/1442)
97+
- Remove `Default` implementation for AccountId ‒ [#1255](https://github.com/paritytech/ink/pull/1255)
98+
1199
## Version 4.0.0-rc
12100

13101
The first release candidate is here! This is the first release which could become the final
@@ -37,7 +125,7 @@ breaking or otherwise.
37125
- Remove `Default` implementation for AccountId ‒ [#1255](https://github.com/paritytech/ink/pull/1255)
38126

39127
## Version 4.0.0-beta.1
40-
The coolest feature included in this release is the first first published version of
128+
The coolest feature included in this release is the first published version of
41129
ink!'s native ["end-to-end" (E2E) testing framework](https://github.com/paritytech/ink/issues/1234).
42130

43131
This enables testing of a contract by deploying and calling it on a Substrate node with
@@ -200,6 +288,7 @@ through a feature flag. `wee-alloc` is no longer maintained and we removed suppo
200288
### Changed
201289
- Introduce `ink` entrance crate ‒ [#1223](https://github.com/paritytech/ink/pull/1223)
202290
- Use `XXH32` instead of `sha256` for calculating storage keys ‒ [#1393](https://github.com/paritytech/ink/pull/1393)
291+
- Storage Refactoring ‒ [#1331](https://github.com/paritytech/ink/pull/1331)
203292

204293
### Fixed
205294
- Trim single whitespace prefix in the metadata `docs` field ‒ [#1385](https://github.com/paritytech/ink/pull/1385)

CONTRIBUTING.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,8 +135,22 @@ It's totally fine to extract changes made in one pull request to multiple pull r
135135

136136
If you've already opened a pull request, avoid force-pushing any new changes.
137137

138+
If your pull request is a work-in-progress, create it as a Draft pull request.
139+
138140
For a nice list of hints visit this [link][GitHub Perfect Pull Reqest].
139141

142+
### Reviews
143+
144+
We have GitHub set up in a way that core developers will automatically
145+
be assigned to review your pull request. If you feel there is somebody
146+
missing you're always free to add more people for a review.
147+
148+
For small changes one approval is typically enough to merge code, for
149+
significant or critical changes there should be at least two ✅.
150+
151+
If you made major changes to your pull request since the last approval,
152+
ping them for another approval please.
153+
140154
## I don't want to contribute, I just have some questions
141155

142156
For technical questions about the ink! and all other Polkadot projects, please post your questions to our [Stack Exchange community][Stack-Exchange-Link]. You can also stay tuned by joining our [Element channel][Riot-Smart-Contracts-ink] to be among first ones who gets our announcements.

README.md

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -71,16 +71,19 @@ More relevant links:
7171

7272
## Play with It
7373

74+
The best way to start is to check out the [Getting Started](https://use.ink/getting-started/setup)
75+
page in our documentation.
76+
7477
If you want to have a local setup you can use our [`substrate-contracts-node`](https://github.com/paritytech/substrate-contracts-node) for a quickstart.
7578
It's a simple Substrate blockchain which includes the Substrate module for smart contract functionality ‒ the `contracts` pallet (see [How it Works](#how-it-works) for more).
7679

77-
We also have a live testnet on [Rococo](https://github.com/paritytech/cumulus/#rococo-). Rococo is a Substrate based
80+
We also have a live testnet named "Contracts" on Rococo. Rococo is a Substrate based
7881
parachain which supports ink! smart contracts. For further instructions on using this
7982
testnet, follow the instructions in
8083
[our documentation](https://use.ink/testnet).
8184

82-
For both types of chains the [Contracts UI](https://contracts-ui.substrate.io/)
83-
can be used to instantiate your contract to a chain and interact with it.
85+
The [Contracts UI](https://contracts-ui.substrate.io/) can be used to instantiate your
86+
contract to a chain and interact with it.
8487

8588
## Usage
8689

@@ -111,7 +114,7 @@ In order to build the contract just execute this command in the `flipper` folder
111114
cargo contract build
112115
```
113116

114-
As a result you'll get a `target/flipper.wasm` file, a `metadata.json` file and a `<contract-name>.contract` file in the `target` folder of your contract.
117+
As a result you'll get a `target/flipper.wasm` file, a `flipper.json` file and a `<contract-name>.contract` file in the `target` folder of your contract.
115118
The `.contract` file combines the Wasm and metadata into one file and needs to be used when instantiating the contract.
116119

117120

@@ -210,7 +213,7 @@ This module is called the `contracts` pallet,
210213
* The `contracts` pallet requires smart contracts to be uploaded to the blockchain as a Wasm blob.
211214
* ink! is a smart contract language which targets the API exposed by `contracts`.
212215
Hence ink! contracts are compiled to Wasm.
213-
* When executing `cargo contract build` an additional file `metadata.json` is created.
216+
* When executing `cargo contract build` an additional file `<contract-name>.json` is created.
214217
It contains information about e.g. what methods the contract provides for others to call.
215218

216219
## ink! Macros & Attributes Overview

crates/allocator/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "ink_allocator"
3-
version = "4.0.0-rc"
3+
version = "4.0.0"
44
authors = ["Parity Technologies <[email protected]>", "Robin Freyler <[email protected]>"]
55
edition = "2021"
66

crates/e2e/Cargo.toml

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "ink_e2e"
3-
version = "4.0.0-rc"
3+
version = "4.0.0"
44
authors = ["Parity Technologies <[email protected]>"]
55
edition = "2021"
66

@@ -15,10 +15,10 @@ categories = ["no-std", "embedded"]
1515
include = ["/Cargo.toml", "src/**/*.rs", "/README.md", "/LICENSE"]
1616

1717
[dependencies]
18-
ink_e2e_macro = { version = "4.0.0-rc", path = "./macro" }
19-
ink = { version = "4.0.0-rc", path = "../ink" }
20-
ink_env = { version = "4.0.0-rc", path = "../env" }
21-
ink_primitives = { version = "4.0.0-rc", path = "../primitives" }
18+
ink_e2e_macro = { version = "4.0.0", path = "./macro" }
19+
ink = { version = "4.0.0", path = "../ink" }
20+
ink_env = { version = "4.0.0", path = "../env" }
21+
ink_primitives = { version = "4.0.0", path = "../primitives" }
2222

2323
contract-metadata = { version = "2.0.0-rc.1" }
2424
funty = "2.0.0"
@@ -30,14 +30,14 @@ tokio = { version = "1.18.2", features = ["rt-multi-thread"] }
3030
log = { version = "0.4" }
3131
env_logger = { version = "0.10" }
3232
scale = { package = "parity-scale-codec", version = "3", default-features = false, features = ["derive", "full"] }
33-
subxt = "0.26.0"
33+
subxt = "0.27.0"
3434

3535
# Substrate
36-
pallet-contracts-primitives = "12.0.0"
37-
sp-core = "11.0.0"
38-
sp-keyring = "12.0.0"
39-
sp-runtime = "12.0.0"
40-
sp-weights = "8.0.0"
36+
pallet-contracts-primitives = "18.0.0"
37+
sp-core = "16.0.0"
38+
sp-keyring = "18.0.0"
39+
sp-runtime = "18.0.0"
40+
sp-weights = "14.0.0"
4141

4242
[dev-dependencies]
4343
# Required for the doctest of `MessageBuilder::call`

crates/e2e/macro/Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "ink_e2e_macro"
3-
version = "4.0.0-rc"
3+
version = "4.0.0"
44
authors = ["Parity Technologies <[email protected]>"]
55
edition = "2021"
66

@@ -19,7 +19,7 @@ name = "ink_e2e_macro"
1919
proc-macro = true
2020

2121
[dependencies]
22-
ink_ir = { version = "4.0.0-beta.1", path = "../../ink/ir" }
22+
ink_ir = { version = "4.0.0", path = "../../ink/ir" }
2323
contract-build = { git = "https://github.com/paritytech/cargo-contract", branch = "aj/shared-events-metadata", package = "contract-build" }
2424
derive_more = "0.99.17"
2525
env_logger = "0.10.0"

crates/e2e/macro/src/codegen.rs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,12 @@ impl InkE2ETest {
7272
syn::ReturnType::Type(rarrow, ret_type) => quote! { #rarrow #ret_type },
7373
};
7474

75+
let environment = self
76+
.test
77+
.config
78+
.environment()
79+
.unwrap_or_else(|| syn::parse_quote! { ::ink::env::DefaultEnvironment });
80+
7581
let mut additional_contracts: Vec<String> =
7682
self.test.config.additional_contracts();
7783
let default_main_contract_manifest_path = String::from("Cargo.toml");
@@ -158,7 +164,7 @@ impl InkE2ETest {
158164

159165
let mut client = ::ink_e2e::Client::<
160166
::ink_e2e::PolkadotConfig,
161-
ink::env::DefaultEnvironment
167+
#environment
162168
>::new(
163169
node_proc.client(),
164170
[ #( #contracts ),* ]

0 commit comments

Comments
 (0)