-
Notifications
You must be signed in to change notification settings - Fork 480
[E2E alternative backend]: Abstract error and result structs #1844
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
Merged
ascjones
merged 11 commits into
use-ink:master
from
pmikolajczyk41:pmikolajczyk41/abstracting-client
Jul 13, 2023
Merged
Changes from 1 commit
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
77d81cd
Extract error
pmikolajczyk41 d24f0ff
Correct doc for error
pmikolajczyk41 58c6af6
Start moving results: instantiation result
pmikolajczyk41 8fb5f17
UploadResult
pmikolajczyk41 ed8b9cf
CallResult
pmikolajczyk41 0430924
CallDryRunResult
pmikolajczyk41 96ac3ba
Formatting
pmikolajczyk41 46a5e90
Annotation
pmikolajczyk41 c77b670
Formatting
pmikolajczyk41 f29b27d
Formatting
pmikolajczyk41 3a5d1ab
No `E`
pmikolajczyk41 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Start moving results: instantiation result
- Loading branch information
commit 58c6af6f267efef214e14fe2772f5d22d3ff9b36
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,45 @@ | ||
| use ink::codegen::ContractCallBuilder; | ||
| use ink_env::call::FromAccountId; | ||
| use ink_env::Environment; | ||
| use pallet_contracts_primitives::ContractInstantiateResult; | ||
| use std::fmt::Debug; | ||
|
|
||
| /// Result of a contract instantiation. | ||
| pub struct InstantiationResult<E: Environment, EventLog> { | ||
| /// The account id at which the contract was instantiated. | ||
| pub account_id: E::AccountId, | ||
| /// The result of the dry run, contains debug messages | ||
| /// if there were any. | ||
| pub dry_run: ContractInstantiateResult<E::AccountId, E::Balance, ()>, | ||
| /// Events that happened with the contract instantiation. | ||
| pub events: EventLog, | ||
| } | ||
|
|
||
| impl<E: Environment, EventLog> InstantiationResult<E, EventLog> { | ||
| /// Returns the account id at which the contract was instantiated. | ||
| pub fn call<Contract>(&self) -> <Contract as ContractCallBuilder>::Type | ||
| where | ||
| Contract: ContractCallBuilder, | ||
| Contract::Type: FromAccountId<E>, | ||
| { | ||
| <<Contract as ContractCallBuilder>::Type as FromAccountId<E>>::from_account_id( | ||
| self.account_id.clone(), | ||
| ) | ||
| } | ||
| } | ||
|
|
||
| /// We implement a custom `Debug` here, as to avoid requiring the trait bound `Debug` for `E`. | ||
| impl<E: Environment, EventLog> Debug for InstantiationResult<E, EventLog> | ||
| where | ||
| E::AccountId: Debug, | ||
| E::Balance: Debug, | ||
| EventLog: Debug, | ||
| { | ||
| fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result { | ||
| f.debug_struct("InstantiationResult") | ||
| .field("account_id", &self.account_id) | ||
| .field("dry_run", &self.dry_run) | ||
| .field("events", &self.events) | ||
| .finish() | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.