Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update to new ChainExtension API #1356

Merged
merged 2 commits into from
Aug 16, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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