-
Notifications
You must be signed in to change notification settings - Fork 25
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
contract auth #598
Merged
Merged
contract auth #598
Changes from 24 commits
Commits
Show all changes
33 commits
Select commit
Hold shift + click to select a range
15edd8b
contract auth
tbfleming b7257c2
contract auth
tbfleming 4716d5a
contract auth
tbfleming 83dcd2c
contract auth
tbfleming e77b07e
Merge remote-tracking branch 'origin/main' into contract-auth
tbfleming 2cfac49
contract auth
tbfleming 5459062
contract auth
tbfleming 03ecc68
contract auth
tbfleming 301177f
contract auth
tbfleming a4462a6
Merge remote-tracking branch 'origin/main' into contract-auth
tbfleming c390977
contract auth
tbfleming 108cd32
contract auth
tbfleming 37041ba
contract auth
tbfleming 520a764
contract auth
tbfleming f45c09d
Merge remote-tracking branch 'origin/main' into contract-auth
tbfleming 4813981
contract auth
tbfleming 97a1508
cleanup
tbfleming 5677922
cleanup
tbfleming 8e4b859
cleanup
tbfleming 684d629
cleanup
tbfleming ce4b250
Merge remote-tracking branch 'origin/main' into contract-auth
tbfleming b1ec81a
sessions
tbfleming 45c22d8
Merge remote-tracking branch 'origin/main' into contract-auth
tbfleming 479bbde
sessions
tbfleming aa1c8bc
address feedback
tbfleming 3ff60f6
bug fix
tbfleming 869a544
Merge remote-tracking branch 'origin/main' into contract-auth
tbfleming 08ff926
address feedback
tbfleming b46a8b9
switch crypto key data to unsigned
tbfleming e028ee6
extensible auth
tbfleming 0a7c729
Merge remote-tracking branch 'origin/main' into contract-auth
tbfleming fea0b76
no_auth
tbfleming c58bb0a
contract auth
tbfleming 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
There are no files selected for viewing
This file contains 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 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 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,20 @@ | ||
#pragma once | ||
|
||
#define EOSIO_ABIGEN_ITEMeden_session_actions(ns, variant_name, missing_struct_name) \ | ||
([&] { \ | ||
gen.def.structs.push_back(eosio::struct_def{missing_struct_name}); \ | ||
eosio::variant_def vdef{variant_name}; \ | ||
ns::for_each_session_action([&](uint32_t index, const char* name, const auto&) { \ | ||
if (index >= vdef.types.size()) \ | ||
vdef.types.resize(index + 1, missing_struct_name); \ | ||
vdef.types[index] = name; \ | ||
}); \ | ||
auto& variants = gen.def.variants.value; \ | ||
auto it = std::find_if(variants.begin(), variants.end(), \ | ||
[&](auto& d) { return d.name == variant_name; }); \ | ||
if (it != variants.end()) \ | ||
*it = std::move(vdef); \ | ||
else \ | ||
variants.push_back(std::move(vdef)); \ | ||
})(); \ | ||
, 1 |
This file contains 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,108 @@ | ||
#pragma once | ||
|
||
#include <eosio/dispatcher.hpp> | ||
#include <sessions.hpp> | ||
|
||
namespace eden | ||
{ | ||
template <typename T, typename R, typename... Args> | ||
void execute_session_action( | ||
eosio::name contract, | ||
R (T::*func)(const eosio::excluded_arg<session_info>& current_session, Args...), | ||
const eosio::excluded_arg<session_info>& current_session, | ||
eosio::datastream<const char*>& ds) | ||
{ | ||
std::tuple<std::remove_cvref_t<Args>...> t; | ||
ds >> t; | ||
T inst(contract, contract, ds); | ||
std::apply([&](auto&... args) { (inst.*func)(current_session, std::move(args)...); }, t); | ||
} | ||
} // namespace eden | ||
|
||
#define EOSIO_MATCH_ACTIONeden_session_action EOSIO_MATCH_YES | ||
#define EOSIO_EXTRACT_ACTION_NAMEeden_session_action(name, index, ...) name | ||
#define EOSIO_EXTRACT_ACTION_ARGSeden_session_action(name, index, ...) __VA_ARGS__ | ||
|
||
#define EDEN_MATCH_SESSION_ACTION(x) EOSIO_MATCH(EDEN_MATCH_SESSION_ACTION, x) | ||
#define EDEN_MATCH_SESSION_ACTIONeden_session_action EOSIO_MATCH_YES | ||
|
||
#define EDEN_EXTRACT_SESSION_ACTION_INDEX(x) BOOST_PP_CAT(EDEN_EXTRACT_SESSION_ACTION_INDEX, x) | ||
#define EDEN_EXTRACT_SESSION_ACTION_INDEXeden_session_action(name, index, ...) index | ||
|
||
#define EDEN_DISPATCH_SESSION_ACTION_INTERNAL_1(r, type, member) \ | ||
case EDEN_EXTRACT_SESSION_ACTION_INDEX(member): \ | ||
::eden::execute_session_action(contract, &type::EOSIO_EXTRACT_ACTION_NAME(member), \ | ||
current_session, ds); \ | ||
return true; | ||
#define EDEN_DISPATCH_SESSION_ACTION_INTERNAL(r, type, member) \ | ||
BOOST_PP_IIF(EDEN_MATCH_SESSION_ACTION(member), EDEN_DISPATCH_SESSION_ACTION_INTERNAL_1, \ | ||
EOSIO_EMPTY) \ | ||
(r, type, member) | ||
#define EDEN_DISPATCH_SESSION_ACTION(type, MEMBERS) \ | ||
BOOST_PP_SEQ_FOR_EACH(EDEN_DISPATCH_SESSION_ACTION_INTERNAL, type, MEMBERS) | ||
|
||
#define EDEN_GET_SESSION_ACTION_INTERNAL_1(r, type, member) \ | ||
f(EDEN_EXTRACT_SESSION_ACTION_INDEX(member), \ | ||
BOOST_PP_STRINGIZE(EOSIO_EXTRACT_ACTION_NAME(member)), \ | ||
&type::EOSIO_EXTRACT_ACTION_NAME(member)); | ||
#define EDEN_GET_SESSION_ACTION_INTERNAL(r, type, member) \ | ||
BOOST_PP_IIF(EDEN_MATCH_SESSION_ACTION(member), EDEN_GET_SESSION_ACTION_INTERNAL_1, \ | ||
EOSIO_EMPTY) \ | ||
(r, type, member) | ||
#define EDEN_GET_SESSION_ACTION(type, MEMBERS) \ | ||
BOOST_PP_SEQ_FOR_EACH(EDEN_GET_SESSION_ACTION_INTERNAL, type, MEMBERS) | ||
|
||
#define EDEN_NAME_FOR_SESSION_ACTION_INTERNAL_1(r, type, member) \ | ||
case EDEN_EXTRACT_SESSION_ACTION_INDEX(member): \ | ||
return BOOST_PP_CAT(BOOST_PP_STRINGIZE(EOSIO_EXTRACT_ACTION_NAME(member)), _n); | ||
#define EDEN_NAME_FOR_SESSION_ACTION_INTERNAL(r, type, member) \ | ||
BOOST_PP_IIF(EDEN_MATCH_SESSION_ACTION(member), EDEN_NAME_FOR_SESSION_ACTION_INTERNAL_1, \ | ||
EOSIO_EMPTY) \ | ||
(r, type, member) | ||
#define EDEN_NAME_FOR_SESSION_ACTION(type, MEMBERS) \ | ||
BOOST_PP_SEQ_FOR_EACH(EDEN_NAME_FOR_SESSION_ACTION_INTERNAL, type, MEMBERS) | ||
|
||
#define EDEN_INDEX_FOR_SESSION_ACTION_INTERNAL_1(r, type, member) \ | ||
if (name == BOOST_PP_CAT(BOOST_PP_STRINGIZE(EOSIO_EXTRACT_ACTION_NAME(member)), _n)) \ | ||
return EDEN_EXTRACT_SESSION_ACTION_INDEX(member); | ||
#define EDEN_INDEX_FOR_SESSION_ACTION_INTERNAL(r, type, member) \ | ||
BOOST_PP_IIF(EDEN_MATCH_SESSION_ACTION(member), EDEN_INDEX_FOR_SESSION_ACTION_INTERNAL_1, \ | ||
EOSIO_EMPTY) \ | ||
(r, type, member) | ||
#define EDEN_INDEX_FOR_SESSION_ACTION(type, MEMBERS) \ | ||
BOOST_PP_SEQ_FOR_EACH(EDEN_INDEX_FOR_SESSION_ACTION_INTERNAL, type, MEMBERS) | ||
|
||
#define EDEN_ACTIONS(CONTRACT_CLASS, CONTRACT_ACCOUNT, ...) \ | ||
EOSIO_ACTIONS(CONTRACT_CLASS, CONTRACT_ACCOUNT, __VA_ARGS__) \ | ||
namespace actions \ | ||
{ \ | ||
inline bool session_dispatch(eosio::name contract, \ | ||
uint32_t index, \ | ||
const eosio::excluded_arg<session_info>& current_session, \ | ||
eosio::datastream<const char*>& ds) \ | ||
{ \ | ||
switch (index) \ | ||
{ \ | ||
EDEN_DISPATCH_SESSION_ACTION(CONTRACT_CLASS, BOOST_PP_VARIADIC_TO_SEQ(__VA_ARGS__)) \ | ||
} \ | ||
return false; \ | ||
} \ | ||
template <typename F> \ | ||
void for_each_session_action(F f) \ | ||
{ \ | ||
EDEN_GET_SESSION_ACTION(CONTRACT_CLASS, BOOST_PP_VARIADIC_TO_SEQ(__VA_ARGS__)) \ | ||
} \ | ||
inline eosio::name get_name_for_session_action(uint32_t index) \ | ||
{ \ | ||
switch (index) \ | ||
{ \ | ||
EDEN_NAME_FOR_SESSION_ACTION(CONTRACT_CLASS, BOOST_PP_VARIADIC_TO_SEQ(__VA_ARGS__)) \ | ||
} \ | ||
return {}; \ | ||
} \ | ||
inline std::optional<uint32_t> get_index_for_session_action(eosio::name name) \ | ||
{ \ | ||
EDEN_INDEX_FOR_SESSION_ACTION(CONTRACT_CLASS, BOOST_PP_VARIADIC_TO_SEQ(__VA_ARGS__)) \ | ||
return {}; \ | ||
} \ | ||
} |
This file contains 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
Oops, something went wrong.
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.
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.
I don't like this interface much
std::vector<eosio::action>
or eveneosio::transaction
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.
If we come up with an alternative, I don't want it to sacrifice the ability of existing history tools to create a human-readable decoding of the original request. Right now they can use ABI decoding to show what's in the action vector.
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.
For history purposes,I don't see why it's important that the original request is human readable vs. having a human readable decoding in the trace. Having the original request human readable is normally critical for signing, but that's not an issue here.
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.
I like this too, starting to look good... but still hard to digest in block explorer (needs to open the transactions first and then look for traces)