This content applies to WaaS 1.0 only. We highly recommend that you upgrade to WaaS 2.0.
BaseAuthorizer, developers would typically need to manually write abi.decode codes in order to decode complicated transaction data.
To simplify this process, Cobo Safe has introduced the BaseACL contract, which is based upon BaseAuthorizer.
Developers can use BaseACL to define a function declaration to be exactly the same as the function of the target contract they intend to control. By doing so, the compiler will automatically generate the decoding codes. Developers can then focus on coding the core access control logic within the function body.
BaseACL only implements the preExecCheck function, which is commonly used for access control validation. Developers can, however, extend BaseACL to configure customized access controls at both the address and function levels.
The process of using BaseACL to implement a customized Authorizer is as follows:
- Configure variables such as
NAMEandVERSION. - Implement the
contracts()function. A list of smart contract addresses controlled by theAuthorizerwill be returned. TheAuthorizerwill continue the validation process only if thetoaddress of a transaction is in the whitelist. Otherwise, theAuthorizerwill directly reject the transaction. - Implement functions that are used to conduct access control validation for the target contract. These functions should be exactly the same as the function declarations of the target contract. However, they should not return any values and should not be decorated as
payable. We recommend that you convert them toexternal view(i.e., modifying the smart contract state is not allowed). If you choose not to follow this approach, additional caller checks must be placed appropriately. - When a validation function is called, its parameters must be identical to those used in the smart contract call. This ensures that you can verify the parameters in a validation function body by directly using Solidity’s
require()statement. If the validation fails, theAuthorizerwill reject the transaction. - If the
Authorizerneeds to manage multiple smart contracts, amodifiernamedonlyContractmust be used in a validation function to verify the contract address of the transaction. This prevents theDelegatefrom calling another smart contract that contains the same function.
BaseACL to implement a customized Authorizer. The Authorizer allows Delegate to engage in yield farming activities on PancakeSwap.
Delegateis allowed to call theapprove()function of LP Token but thespenderis restricted toMasterChef.Delegateis allowed to call thedeposit()function ofMasterChefand thepidparameter value is 3.Delegateis allowed to call thewithdraw()function ofMasterChefand thepidparameter value is 3.
