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

Add ink_env::pay_with_call! helper macro for off-chain emulation of sending payments with contract msg calls #1379

Merged
merged 14 commits into from
Sep 13, 2022

Conversation

agryaznov
Copy link
Contributor

Solves #1346

@agryaznov agryaznov marked this pull request as ready for review September 1, 2022 09:38
examples/contract-transfer/lib.rs Outdated Show resolved Hide resolved
crates/env/src/lib.rs Outdated Show resolved Hide resolved
crates/env/src/engine/off_chain/test_api.rs Show resolved Hide resolved
examples/contract-transfer/lib.rs Outdated Show resolved Hide resolved
crates/env/src/engine/off_chain/test_api.rs Show resolved Hide resolved
crates/env/src/lib.rs Outdated Show resolved Hide resolved
examples/contract-transfer/lib.rs Outdated Show resolved Hide resolved
crates/env/src/lib.rs Outdated Show resolved Hide resolved
Copy link
Contributor

@HCastano HCastano left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some small things to fix, but looks good!

crates/env/src/engine/off_chain/test_api.rs Outdated Show resolved Hide resolved
crates/env/src/engine/off_chain/test_api.rs Outdated Show resolved Hide resolved
crates/env/src/engine/off_chain/test_api.rs Outdated Show resolved Hide resolved
crates/env/src/engine/off_chain/test_api.rs Outdated Show resolved Hide resolved
examples/contract-transfer/lib.rs Show resolved Hide resolved
crates/env/src/engine/off_chain/test_api.rs Show resolved Hide resolved
crates/env/src/engine/off_chain/test_api.rs Show resolved Hide resolved
@codecov-commenter
Copy link

codecov-commenter commented Sep 10, 2022

Codecov Report

Merging #1379 (96908b7) into master (a314b34) will decrease coverage by 25.24%.
The diff coverage is n/a.

❗ Current head 96908b7 differs from pull request most recent head e60a5dc. Consider uploading reports for the commit e60a5dc to get more accurate results

@@             Coverage Diff             @@
##           master    #1379       +/-   ##
===========================================
- Coverage   70.16%   44.92%   -25.25%     
===========================================
  Files         190      189        -1     
  Lines        5940     5888       -52     
===========================================
- Hits         4168     2645     -1523     
- Misses       1772     3243     +1471     
Impacted Files Coverage Δ
crates/env/src/engine/off_chain/test_api.rs 86.84% <ø> (ø)
crates/lang/codegen/src/traits.rs 0.00% <0.00%> (-100.00%) ⬇️
crates/lang/codegen/src/generator/env.rs 0.00% <0.00%> (-100.00%) ⬇️
crates/lang/codegen/src/generator/mod.rs 0.00% <0.00%> (-100.00%) ⬇️
crates/lang/codegen/src/enforced_error.rs 0.00% <0.00%> (-100.00%) ⬇️
crates/lang/codegen/src/generator/blake2b.rs 0.00% <0.00%> (-100.00%) ⬇️
crates/lang/codegen/src/generator/storage.rs 0.00% <0.00%> (-100.00%) ⬇️
crates/lang/codegen/src/generator/arg_list.rs 0.00% <0.00%> (-100.00%) ⬇️
crates/lang/codegen/src/generator/contract.rs 0.00% <0.00%> (-100.00%) ⬇️
crates/lang/codegen/src/generator/selector.rs 0.00% <0.00%> (-100.00%) ⬇️
... and 47 more

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

@agryaznov agryaznov merged commit d42bfbf into master Sep 13, 2022
@agryaznov agryaznov deleted the ag-call-payable-offchain branch September 13, 2022 15:22
@armyhaylenko
Copy link

hey @agryaznov, we tested out the macro and it does not work.
since the macro is defined as ($contract:ident . $message:ident ( $($params:ty)? ) , $amount:expr), you can't really pass multiple params there, like ink_env::pay_with_call!(contract.foobar(arg1, arg2, arg3.quox), 1000). it'll lead to compile errors. and why is params a type?

@ascjones ascjones mentioned this pull request Sep 21, 2022
agryaznov added a commit that referenced this pull request Oct 18, 2022
… sending payments with contract msg calls (#1379)

* first ver.: transfer_in api function implememted but we can't have it in on-chain env

* transfer_in moved to test_api

* doc + example updated

* Update examples/contract-transfer/lib.rs

Co-authored-by: Hernando Castano <[email protected]>

* use stmt moved to macro

* docs and nitty gritties

* moved the macro to the test mod

* spell fix

* next review round suggestions applied

* Use four spaces for macro indentation

Co-authored-by: Hernando Castano <[email protected]>
Co-authored-by: Hernando Castano <[email protected]>
agryaznov added a commit that referenced this pull request Oct 20, 2022
* Add `ink_env::pay_with_call!` helper macro for off-chain emulation of sending payments with contract msg calls (#1379)

* first ver.: transfer_in api function implememted but we can't have it in on-chain env

* transfer_in moved to test_api

* doc + example updated

* Update examples/contract-transfer/lib.rs

Co-authored-by: Hernando Castano <[email protected]>

* use stmt moved to macro

* docs and nitty gritties

* moved the macro to the test mod

* spell fix

* next review round suggestions applied

* Use four spaces for macro indentation

Co-authored-by: Hernando Castano <[email protected]>

* Allow `pay_with_call` to take multiple arguments (#1401)

* Moved constants from `match` to a separate constants (#1418)

* fix tests

Co-authored-by: Hernando Castano <[email protected]>
Co-authored-by: Andrew Jones <[email protected]>
@ascjones ascjones mentioned this pull request Feb 15, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants