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

call_v2 cross-contract calls with additional limit parameters #2077

Merged
merged 51 commits into from
Feb 8, 2024
Merged
Show file tree
Hide file tree
Changes from 46 commits
Commits
Show all changes
51 commits
Select commit Hold shift + click to select a range
de543ed
init call_v2 methods and types
ascjones Jan 29, 2024
8339352
add e2e tests to basic-contract-caller example
ascjones Jan 30, 2024
7fb24b9
Merge branch 'master' into aj/call-v2
ascjones Jan 30, 2024
a84fe4f
Add storage_deposit
ascjones Jan 30, 2024
b7ad4b0
Fix basic-contract-caller e2e tests
ascjones Jan 30, 2024
99a9c03
Remove `basic_contract_caller` integration test, moved to #1909
ascjones Jan 30, 2024
cc52b41
WIP adding cross_contract_calls test
ascjones Jan 31, 2024
a0813f9
Add `integration-test` for possible migration pattern (#1909)
ascjones Jan 31, 2024
bab2e0a
Add `basic-contract-caller` E2E test (#2085)
ascjones Jan 31, 2024
b2a2cf9
Only need one .gitignore
ascjones Jan 31, 2024
bd83e18
WIP adding create v2 API
ascjones Jan 31, 2024
ae6330a
Merge branch 'master' into aj/call-v2
ascjones Feb 1, 2024
ab251c2
Revert "WIP adding create v2 API"
ascjones Feb 1, 2024
16d1479
WIP e2e tests
ascjones Feb 1, 2024
85e7e9c
Add CallV2 builder methods
ascjones Feb 2, 2024
eb7ca99
Pass weight limit as params
ascjones Feb 2, 2024
2c0a632
Allow deprecated
ascjones Feb 2, 2024
8b6ce3f
Add storage_deposit_limit
ascjones Feb 2, 2024
982089d
Clippy
ascjones Feb 2, 2024
1d8cd75
Use struct update syntax
ascjones Feb 2, 2024
9393e42
Remove space
ascjones Feb 2, 2024
ab62c5b
CHANGELOG
ascjones Feb 2, 2024
818358e
fmt
ascjones Feb 2, 2024
b648bfc
Import OtherContract directly instead of reexporting
ascjones Feb 5, 2024
2c91364
Make other_contract pub
ascjones Feb 5, 2024
649bc69
Revert prev
ascjones Feb 5, 2024
58f5104
docs
ascjones Feb 5, 2024
7c9c85c
top level gitignore for integration-tests
ascjones Feb 5, 2024
e909ecd
Remove unused setters
ascjones Feb 5, 2024
6e75a0e
Use ContractRef
ascjones Feb 5, 2024
f6e77dc
integration-test comments
ascjones Feb 5, 2024
7b0b5b1
Rename to `call_v2`
ascjones Feb 5, 2024
b176da9
Comments and builder method
ascjones Feb 5, 2024
a3dd520
SP
ascjones Feb 5, 2024
1d400ad
comments
ascjones Feb 5, 2024
dab7ab0
fix doc test
ascjones Feb 6, 2024
d29152c
merge `basic-contract-caller` into `cross-contract-calls`
ascjones Feb 6, 2024
fab7a54
Make `call_v2` the default for cross contract calls
ascjones Feb 6, 2024
2fdb9ab
Complete switch to make `call_v2` default
ascjones Feb 6, 2024
fc409f1
Fix doc test
ascjones Feb 6, 2024
dbd4d87
Update crates/env/src/call/call_builder.rs
ascjones Feb 6, 2024
35b0907
Update crates/env/src/call/call_builder.rs
ascjones Feb 6, 2024
e766fae
Update crates/env/src/call/call_builder.rs
ascjones Feb 6, 2024
75ebea3
Update crates/env/src/call/call_builder.rs
ascjones Feb 6, 2024
b777fbf
Review suggestion
ascjones Feb 6, 2024
4d3a1d5
Fmt
ascjones Feb 6, 2024
6a5008e
Review suggestion and spellcheck
ascjones Feb 6, 2024
845c8cd
Use call_v2 in other examples
ascjones Feb 6, 2024
85edec2
Docs
ascjones Feb 6, 2024
183772b
Merge branch 'master' into aj/call-v2
ascjones Feb 8, 2024
3abc574
Merge branch 'master' into aj/call-v2
ascjones Feb 8, 2024
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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- [Linter] `non_fallible_api` lint - [#2004](https://github.com/paritytech/ink/pull/2004)
- [Linter] Publish the linting crates on crates.io - [#2060](https://github.com/paritytech/ink/pull/2060)
- [E2E] Added `create_call_builder` for testing existing contracts - [#2075](https://github.com/paritytech/ink/pull/2075)
- `call_v2` cross-contract calls with additional limit parameters - [#2077](https://github.com/paritytech/ink/pull/2077)

### Changed
- `Mapping`: Reflect all possible failure cases in comments ‒ [#2079](https://github.com/paritytech/ink/pull/2079)
Expand Down
36 changes: 36 additions & 0 deletions crates/env/src/api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ use crate::{
call::{
Call,
CallParams,
CallV1,
ConstructorReturnType,
CreateParams,
DelegateCall,
Expand Down Expand Up @@ -265,6 +266,9 @@ where
/// This is a low level way to evaluate another smart contract.
/// Prefer to use the ink! guided and type safe approach to using this.
///
/// **This will call into the original version of the host function. It is recommended to
/// use [`invoke_contract`] to use the latest version if the target runtime supports it.**
///
/// # Errors
///
/// - If the called account does not exist.
Expand All @@ -273,6 +277,38 @@ where
/// - If the called contract execution has trapped.
/// - If the called contract ran out of gas upon execution.
/// - If the returned value failed to decode properly.
pub fn invoke_contract_v1<E, Args, R>(
params: &CallParams<E, CallV1<E>, Args, R>,
) -> Result<ink_primitives::MessageResult<R>>
where
E: Environment,
Args: scale::Encode,
R: scale::Decode,
{
<EnvInstance as OnInstance>::on_instance(|instance| {
TypedEnvBackend::invoke_contract_v1::<E, Args, R>(instance, params)
})
}

/// Invokes a contract message and returns its result.
///
/// # Note
///
/// **This will call into the latest version of the host function which allows setting new
/// weight and storage limit parameters.**
///
/// This is a low level way to evaluate another smart contract.
/// Prefer to use the ink! guided and type safe approach to using this.
///
/// # Errors
///
/// - If the called account does not exist.
/// - If the called account is not a contract.
/// - If arguments passed to the called contract message are invalid.
/// - If the called contract execution has trapped.
/// - If the called contract ran out of gas, proof time, or storage deposit upon
/// execution.
/// - If the returned value failed to decode properly.
pub fn invoke_contract<E, Args, R>(
params: &CallParams<E, Call<E>, Args, R>,
) -> Result<ink_primitives::MessageResult<R>>
Expand Down
19 changes: 19 additions & 0 deletions crates/env/src/backend.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ use crate::{
call::{
Call,
CallParams,
CallV1,
ConstructorReturnType,
CreateParams,
DelegateCall,
Expand Down Expand Up @@ -294,6 +295,24 @@ pub trait TypedEnvBackend: EnvBackend {
///
/// # Note
///
/// **This will call into the original `call` host function.**
///
/// For more details visit: [`invoke_contract`][`crate::invoke_contract_v1`]
fn invoke_contract_v1<E, Args, R>(
&mut self,
call_data: &CallParams<E, CallV1<E>, Args, R>,
) -> Result<ink_primitives::MessageResult<R>>
where
E: Environment,
Args: scale::Encode,
R: scale::Decode;

/// Invokes a contract message and returns its result.
///
/// # Note
///
/// **This will call into the latest `call_v2` host function.**
///
/// For more details visit: [`invoke_contract`][`crate::invoke_contract`]
fn invoke_contract<E, Args, R>(
&mut self,
Expand Down
Loading
Loading