feat: token preloaded lib - #1016
Conversation
| <<"committers">>, | ||
| <<"index">>, | ||
| <<"info">>, | ||
| <<"set_path">>, |
There was a problem hiding this comment.
- will match _ just as well in AO-Core. We are never going to be able to keep this up-to-date -- is it necessary for the design?
| %% mixed-case input cannot collide with AO/trie control keys after | ||
| %% canonicalization. | ||
| validate_address(Address, CustomList) -> | ||
| validate_address(Address, CustomList, #{}). |
There was a problem hiding this comment.
Let's just not offer a no-Opts version? I think in general we should remove those across the codebase. Far more trouble than good!
| validate_address(Address, CustomList, Opts) when is_binary(Address), is_list(CustomList) -> | ||
| ReservedKeys = ?AO_RESERVED_ADDRESS_KEYS ++ CustomList, | ||
| AccountKey = account_key(Address), | ||
| CanonicalReservedKeys = [account_key(Key) || Key <- ReservedKeys, is_binary(Key)], |
There was a problem hiding this comment.
If we expect this to be frequently executed can extract AO_RESERVED_ADDRESS_KEYS from the account_key-processed part? to_lower is surprisingly slow at the moment.
|
|
||
| trie_reserved_keys(Opts) -> | ||
| {ok, Trie} = hb_device_load:reference(<<"trie@1.0">>, Opts), | ||
| maps:get(reserved, Trie:info(), []). |
There was a problem hiding this comment.
We should have -- if we don't already -- a way to programmatically generate the list of device keys. in hb_device. The message_to_fun flow must use it somewhere, so we should just be able to extract it. Perhaps simple: Just use message_to_fun with #{ <<"device">> => DEV_NAME }, ... [key:] Address, ...)? If you get back fun dev_message:get/4 then you know there were no hits. I think you can also specify the default, at least in the neo/edge-1.0 branch.
|
|
||
| %% @doc Canonical token balance trie key for an external account ID. | ||
| account_key(Address) when is_binary(Address) -> | ||
| hb_util:to_lower(Address). |
There was a problem hiding this comment.
Probably want to do normalize_key here, too. I don't think this flow catches integer keys at the momen, for example. I think this will probably just crash?
|
thanks for the feedbacks @speeddragon @samcamwilliams -- addressed, now:
|
No description provided.