Skip to content

Commit

Permalink
Update to new ChainExtension API (#1356)
Browse files Browse the repository at this point in the history
* Update to new `ChainExtension` API

* Update unreleased notes
  • Loading branch information
cmichi authored and xermicus committed Sep 8, 2022
1 parent d6bf3a4 commit d78f06c
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 5 deletions.
18 changes: 14 additions & 4 deletions RELEASES.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,20 @@
# [Unreleased]

There are a number of backwards incompatible changes which are on the `master` branch
waiting to be released. These include:
- Add Mapping::contains(key) and Mapping::insert_return_size(key, val) - [#1224](https://github.com/paritytech/ink/pull/1224)
- Optimise deny_payment. Use everywhere semantic of deny. [#1267](https://github.com/paritytech/ink/pull/1267)
- Implement ecdsa_to_eth_address() and remove eth_compatibility crate [#1233](https://github.com/paritytech/ink/pull/1233)
waiting to be released. These are:

- Add Mapping::contains(key) and Mapping::insert_return_size(key, val) ‒ [#1224](https://github.com/paritytech/ink/pull/1224)
- Optimise deny_payment. Use everywhere semantic of deny ‒ [#1267](https://github.com/paritytech/ink/pull/1267)
- Implement ecdsa_to_eth_address() and remove eth_compatibility crate ‒ [#1233](https://github.com/paritytech/ink/pull/1233)
- The `rand-extension` example has been adapted to an updated version of the `ChainExtension` API ‒ [#1356](https://github.com/paritytech/ink/pull/1356)

## Compatibility

We recommend using a version of the [`pallet-contracts`](https://github.com/paritytech/substrate/tree/master/frame/contracts)
later than [6b85535](https://github.com/paritytech/substrate/tree/6b8553511112afd5ae7e8e6877dc2f467850f155)
(Aug 12, 2022) in your node.

The compatibility issues will be with `ChainExtension`'s and the functions mentioned above.

# Version 3.3.1

Expand Down
4 changes: 3 additions & 1 deletion examples/rand-extension/runtime/chain-extension-example.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,19 @@ use pallet_contracts::chain_extension::{
use sp_runtime::DispatchError;

/// Contract extension for `FetchRandom`
#[derive(Default)]
pub struct FetchRandomExtension;

impl ChainExtension<Runtime> for FetchRandomExtension {
fn call<E: Ext>(
func_id: u32,
&mut self,
env: Environment<E, InitState>,
) -> Result<RetVal, DispatchError>
where
<E::T as SysConfig>::AccountId:
UncheckedFrom<<E::T as SysConfig>::Hash> + AsRef<[u8]>,
{
let func_id = env.func_id();
match func_id {
1101 => {
let mut env = env.buf_in_buf_out();
Expand Down

0 comments on commit d78f06c

Please sign in to comment.