Procedure Table (Rudimentary)
Closed this issue · 0 comments
We need to create a procedure table that will act as the storage interface for the kernel:
-
#insert_proc
-
#remove_proc
-
#set_entry_proc_id
-
#set_current_proc_id
-
#contains
-
#get_proc_list_len
-
#get_proc_addr
-
#get_proc_index
-
#get_proc_id
-
#get_proc_cap_list_len
-
#get_proc_cap
-
#get_entry_proc_id
insert_proc
Insert a new procedure with given id, address, and capability list
Parameters
proc_id
: uint192, the procedure id, must be uniqueaddress
: uint160, the procedure contract addresscapabilities
: struct CapList, the capability list which is a decoded memory allocated list from calldata
** Returns **
result
: Result<(), ProcInsertError> where:ProcInsertError
is either:UsedId
: Procedure Id is already usedListFull
: Procedure List is Full
remove_proc
Remove a procedure with given id
Parameters
proc_id
: uint192, the procedure id, must be unique
Returns
result
: Result<(), ProcRemoveError> where:ProcRemoveError
is either:InvalidId
: Procedure Id is not usedEntryProc
: Procedure Id is the Entry Procedure
set_entry_proc_id
Sets the entry procedure id
Parameters
proc_id
: uint192, the procedure id, must be unique
Returns
result
: Result<(), SetEntryProcError> where:SetEntryProcError
whenInvalidId
: Procedure Id is not used
set_current_proc_id
Sets the current procedure id
Parameters
proc_id
: uint192, the procedure id, must be unique
Returns
result
: Result<(), SetCurrentProcError> where:SetCurrentProcError
whereInvalidId
: Procedure Id is not used
contains
Checks if procedure id exists
Parameters
proc_id
: uint192, the procedure id to check
** Returns **
result
: Boolean,true
if procedure id is taken,false
if not
get_proc_list_len
Returns the amount of procedure present in the table
Parameters
None
Returns
proc_list_len
: uint192, the length of the procedure list, must always be greater than 0
get_proc_addr
Returns the Procedure Address
Parameters
proc_id
: uint192, the procedure id
** Returns **
proc_address
: Option<uint160>, the procedure contract address, where:None
= 0, when Procedure Id is not used
get_proc_index
Returns the Procedure Index
Parameters
proc_id
: uint192, the procedure id
** Returns **
proc_index
: Option<uint8>, the procedure contract index, where:None
= 0, when Procedure Id is not used
get_proc_id
Returns the id of the designated procedure at index
Parameters
None
Returns
entry_id
: Option<uint192>, the procedure id of the designated entry procedure, where:None
= 0, when Procedure Id is not Used
get_proc_cap_list_len
Returns the length of the capability list of the corresponding type and procedure id
Parameters
proc_id
: uint192, the procedure id, must be uniquecap_type
: uint8, the capability type where:- (3) = CAP_PROC_CALL;
- (4) = CAP_PROC_REGISTER;
- (5) = CAP_PROC_DELETE;
- (6) = CAP_PROC_ENTRY;
- (7) = CAP_STORE_WRITE;
- (8) = CAP_LOG;
- (9) = CAP_ACC_CALL;
Returns
result
: Result<uint8, ProcGetCapListLenError>, length of capability list of typecap_type
and where:ProcGetCapListLenError
is either:InvalidId
: Procedure Id is not usedInvalidCapType
: Procedure Cap Type is Invalid
get_proc_cap
Returns a reference struct to the procedure corresponding to the procedure id
Parameters
proc_id
: uint192, the procedure id, must be uniquecap_type
: uint8, the capability type where:- (3) = CAP_PROC_CALL;
- (4) = CAP_PROC_REGISTER;
- (5) = CAP_PROC_DELETE;
- (6) = CAP_PROC_ENTRY;
- (7) = CAP_STORE_WRITE;
- (8) = CAP_LOG;
- (9) = CAP_ACC_CALL;
cap_index
: uint8, the capability index
Returns
result
: Result<Capability, ProcGetCapError> where:Capability
is an enum that is either:
- (3) = ProcedureCall;
- (4) = ProcedureRegister;
- (5) = ProcedureDelete;
- (6) = ProcedureEntry;
- (7) = StoreWrite;
- (8) = Log
- (9) = AccountCall;ProcGetCapError
is either:InvalidId
: Procedure Id is not usedInvalidCapType
: Procedure Cap Type is InvalidInvalidCapIndex
: Procedure Cap Index is greater than the cap list length
get_entry_proc_id
Returns the id of the designated entry procedure
Parameters
None
Returns
entry_id
: uint192, the procedure id of the designated entry procedure