add_strategy
Used to add new strategies to the dapp. This does not need to be called for FT4-defined strategies.
This function helps avoid a common issue where a strategy is registered with the wrong name. If that happens, many functions of this module will throw errors pointing to that strategy as missing, since they won't be able to find it.
Example usage:
operation my_strategy(
main: accounts.auth_descriptor,
disposable: accounts.auth_descriptor? = null
) {
strategies.require_register_account_next_operation();
}
function account_details(gtv) {
val params = struct<ras_open>.from_gtv(gtv);
val signers = accounts.get_signers(params.main);
return strategies.account_details(
account_id = accounts.get_account_id_from_signers(signers),
main = params.main,
disposable = params.disposable
);
}
function my_custom_logic(accounts.account, gtv) {
// custom logic that the strategy has to follow
}
@extend(strategies.strategy)
function () = strategies.add_strategy(
op = rell.meta(my_strategy),
account_details = account_details(*),
action = my_custom_logic(*)
);
Parameters
the custom operation that defines the strategy and its name
the function that retrieves the account details from op
the function that implements the strategy logic. If null, _no_action
is called.
the function that determines the list of signers required. If it is null or the list is empty no signature is required
See also
for more information about the parameters of this function
for more information on performing no action