-
Notifications
You must be signed in to change notification settings - Fork 6
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: main
Are you sure you want to change the base?
Changes from all commits
7c2eac2
418aa63
3d385df
fd46a27
1022926
ecc82e2
e81f78a
f824801
4670503
2283161
f88dd89
61b3a17
c1616a3
13e947e
7757319
924df85
972e4c9
47e2ea6
9dcfccb
b067eda
8730f90
b591222
c2acbb5
3639320
81e9844
023d3dc
e683e16
28d971b
4e4512e
02dffc6
027cb85
30ff91a
9820e7f
5ac5a9a
d8ac5bd
00c5903
1acbd21
9ebe162
545bd33
99d0f6d
8b4f595
f13b39c
7c94284
5934fa8
f2ef7a1
b3dd993
0811598
6482a43
1b78c11
8d1c085
479dbb0
ec49dc3
d92a4c5
114934a
d7cba0a
a272657
c0ea3ed
206757b
07a0731
7f04779
8a1095b
d23c2b3
0ab510f
1c06043
f6976b0
d6408da
0399d46
5fdf406
ed7146b
7ce0674
8c1988f
7c4c470
4e44fba
a32f002
bf4062d
21c6826
894fcf9
817a351
6042f09
c8cc9d1
a8c063c
8176474
1945683
6aede89
b52ad33
6b2f17a
4a1bf3b
699275c
94ee34e
9bb3be8
f03a5ae
1bbc3ed
e8d68a9
4ead643
12d1af4
24afd15
8ecf6d9
6f521f4
7ce5d52
b29cf17
933c62e
de80906
8717adb
8ae2c00
97417e3
204ee06
540639a
867cc28
7dc6047
b433c67
e018e34
baab872
cb48a4d
ce009a1
e5f84aa
6f17c09
7e23172
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 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. To be clear, I'm not against adding stuff that is needed, but a useful thing to consider is that taking a trait bound on the whole Config trait makes mocking overly complex. An example is needing to add a mock pallet-contracts impl just to do basic things. Only expose what is required, nothing more. It may be easier, but has consequences downstream for implementors. |
||
() | ||
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(), ()) | ||
} |
This file was deleted.
This file was deleted.
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?