Add ability to Cache Authorities
When a user passes a message to a contract with a given authority, the contract can call the following API to "save" it. Later it can use the same api to "load" it before invoking a sync or async call that requires the authority.
save_authority( Scope, AccountName, PermissionLevel )
load_authority( Scope, AccountName, PermissionLevel )
clear_authority(Scope, AccountName, PermissionLevel )
get_permission( AccountName ) ///< returns permission level used by AccountName on this message
We allow the authority to be saved to any scope, but it must be loaded again from that same scope.
As discussed in the call, we want to allow the account whose authority is being cached to add some restrictions to the ability to cache authorities.
Some of the restrictions we discussed:
- Whether the permission can be cached at all -- if not allowed, then
save_authorityfails - Whether the permission can be cached for later use, or must be used immediately
- Whether the account must be notified (which implies veto power) when its authority is used
This can be implemented by updating Message::authorization. Right now, this field has type AccountPermission[], but we could instead define a new struct:
struct MessageAuth
permission AccountPermission
flags UInt8
Then Message::authorization could be of type MessageAuth[]. This allows the user to specify the restrictions on whether and how their authority can be cached and subsequently used.
closing this after a discussion with @bytemaster where we are going to move away from explicit authority caching to delegating permission levels to other accounts directly in the native contract for permissions.
That work is tracked as part of #402