-
Notifications
You must be signed in to change notification settings - Fork 5
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
fix(unmerged): contract caller
as a chain extension origin
#301
base: chungquantin/feat-psp22_example
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,10 @@ | ||
use core::fmt::Debug; | ||
|
||
use frame_support::pallet_prelude::Weight; | ||
use pallet_contracts::chain_extension::{BufInBufOutState, ChargedAmount, Result, State}; | ||
use pallet_contracts::{ | ||
chain_extension::{BufInBufOutState, ChargedAmount, Result, State}, | ||
Origin, | ||
}; | ||
use sp_std::vec::Vec; | ||
|
||
use crate::AccountIdOf; | ||
|
@@ -168,14 +171,14 @@ | |
type AccountId; | ||
|
||
/// Returns a reference to the account id of the current contract. | ||
fn address(&self) -> &Self::AccountId; | ||
fn address(&self) -> Self::AccountId; | ||
} | ||
|
||
impl Ext for () { | ||
type AccountId = (); | ||
|
||
fn address(&self) -> &Self::AccountId { | ||
&() | ||
fn address(&self) -> Self::AccountId { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Again, why are we changing this? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This was changed just to test if it works (will be reverted later when we decide the next step with the extension origin). Reason why I don't add the method |
||
() | ||
Check warning on line 181 in extension/src/environment.rs GitHub Actions / clippyunneeded unit expression
|
||
} | ||
} | ||
|
||
|
@@ -185,12 +188,16 @@ | |
impl<'a, E: pallet_contracts::chain_extension::Ext> Ext for ExternalEnvironment<'a, E> { | ||
type AccountId = AccountIdOf<E::T>; | ||
|
||
fn address(&self) -> &Self::AccountId { | ||
self.0.address() | ||
fn address(&self) -> Self::AccountId { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can we not add a function There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Explained here: #301 (comment) |
||
// TODO: Need to decide which address to return. | ||
match self.0.caller() { | ||
Origin::Root => self.0.address().clone(), | ||
Origin::Signed(caller) => caller, | ||
} | ||
} | ||
} | ||
|
||
#[test] | ||
fn default_ext_works() { | ||
assert_eq!(().address(), &()) | ||
assert_eq!(().address(), ()) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why are we changing this?