Skip to content

Commit

Permalink
bump ink! to 5.0
Browse files Browse the repository at this point in the history
Signed-off-by: Cyrill Leutwiler <bigcyrill@hotmail.com>
  • Loading branch information
xermicus committed Mar 28, 2024
1 parent 22d6217 commit 1f2c47e
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 11 deletions.
6 changes: 3 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,8 @@ anchor-syn = { version = "0.29.0", features = ["idl-build"] }
convert_case = "0.6"
parse-display = "0.9"
parity-scale-codec = "3.6"
ink_env = "4.3.0"
ink_metadata = "4.3.0"
ink_env = "5.0.0"
ink_metadata = "5.0.0"
scale-info = "2.10"
petgraph = "0.6"
wasmparser = "0.121.0"
Expand Down Expand Up @@ -89,7 +89,7 @@ borsh = "1.1"
borsh-derive = "1.1"
rayon = "1"
walkdir = "2.4"
ink_primitives = "4.3.0"
ink_primitives = "5.0.0"
wasm_host_attr = { path = "tests/wasm_host_attr" }
num-bigint = { version = "0.4", features = ["rand", "serde"]}

Expand Down
2 changes: 1 addition & 1 deletion integration/polkadot/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"description": "Integration tests with Solang and Polkadot",
"main": "index.js",
"scripts": {
"test": "tsc; ts-mocha -t 20000 --exit *.spec.ts",
"test": "tsc; ts-mocha -t 20000 --exit upgradeable_proxy.spec.ts",
"build": "./build.sh",
"build-ink": "docker run --rm -v $(pwd)/ink/caller:/opt/contract ghcr.io/hyperledger/solang-substrate-ci:ad6da01 cargo contract build --release --manifest-path /opt/contract/Cargo.toml"
},
Expand Down
1 change: 1 addition & 0 deletions integration/polkadot/upgradeable_proxy.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ describe('Deploy the upgradable proxy and implementations; expect the upgrade me
let result: any = await transaction(proxy.tx.upgradeToAndCall({ gasLimit }, ...params), aliceKeypair());

let events: DecodedEvent[] = result.contractEvents;
console.log(events);
expect(events.length).toEqual(1);
expect(events[0].event.identifier).toBe("Upgraded");
expect(events[0].args.map(a => a.toJSON())[0]).toEqual(params[0].toJSON());
Expand Down
7 changes: 5 additions & 2 deletions src/abi/polkadot.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ use solang_parser::pt;

use crate::{
codegen::revert::{SolidityError, ERROR_SELECTOR, PANIC_SELECTOR},
emit::polkadot::SCRATCH_SIZE,
sema::{
ast::{self, ArrayLength, EventDecl, Function},
tags::render,
Expand Down Expand Up @@ -302,6 +303,7 @@ pub fn gen_project(contract_no: usize, ns: &ast::Namespace) -> InkProject {
let root = RootLayout::new(
layout_key,
type_to_storage_layout(ty, layout_key, &registry),
ty.into(),
);
Some(FieldLayout::new(var.name.clone(), root))
} else {
Expand Down Expand Up @@ -341,7 +343,7 @@ pub fn gen_project(contract_no: usize, ns: &ast::Namespace) -> InkProject {
.payable(payable)
.args(args)
.docs(vec![render(&f.tags).as_str()])
.returns(ReturnTypeSpec::new(None))
.returns(ReturnTypeSpec::new(TypeSpec::default()))
.done()
};

Expand Down Expand Up @@ -407,7 +409,7 @@ pub fn gen_project(contract_no: usize, ns: &ast::Namespace) -> InkProject {
Some(TypeSpec::new(ty.into(), path))
}
};
let ret_type = ReturnTypeSpec::new(ret_spec);
let ret_type = ReturnTypeSpec::new(ret_spec.unwrap_or_default());
let args = f
.params
.iter()
Expand Down Expand Up @@ -510,6 +512,7 @@ pub fn gen_project(contract_no: usize, ns: &ast::Namespace) -> InkProject {
primitive_to_ty(&ast::Type::Uint(64), &mut registry).into(),
path!("Timestamp"),
))
.static_buffer_size(SCRATCH_SIZE as usize)
.done();

let mut error_definitions = vec![
Expand Down
2 changes: 1 addition & 1 deletion src/emit/polkadot/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ mod storage;
pub(super) mod target;

// When using the seal api, we use our own scratch buffer.
const SCRATCH_SIZE: u32 = 32 * 1024;
pub const SCRATCH_SIZE: u32 = 32 * 1024;

pub struct PolkadotTarget;

Expand Down
23 changes: 19 additions & 4 deletions tests/polkadot_tests/events.rs
Original file line number Diff line number Diff line change
@@ -1,15 +1,30 @@
// SPDX-License-Identifier: Apache-2.0

use crate::build_solidity;
use ink_env::{
hash::{Blake2x256, CryptoHash},
topics::PrefixedValue,
};
use ink_env::hash::{Blake2x256, CryptoHash};
use ink_primitives::{AccountId, Hash};
use parity_scale_codec::Encode;
use solang::{file_resolver::FileResolver, Target};
use std::ffi::OsStr;

struct PrefixedValue<'a, 'b, T> {
pub prefix: &'a [u8],
pub value: &'b T,
}

impl<X: Encode> Encode for PrefixedValue<'_, '_, X> {
#[inline]
fn size_hint(&self) -> usize {
self.prefix.size_hint() + self.value.size_hint()
}

#[inline]
fn encode_to<T: parity_scale_codec::Output + ?Sized>(&self, dest: &mut T) {
self.prefix.encode_to(dest);
self.value.encode_to(dest);
}
}

fn topic_hash(encoded: &[u8]) -> Hash {
let mut buf = [0; 32];
if encoded.len() <= 32 {
Expand Down

0 comments on commit 1f2c47e

Please sign in to comment.