swapOwner method
Future<SafeContractEncodedCall>
swapOwner({
- required ETHAddress prevOwner,
- required ETHAddress oldOwner,
- required ETHAddress newOwner,
override
"stateMutability": "nonpayable",
Replaces an existing owner (oldOwner) in the Safe with a new owner (newOwner).
Notes:
- This operation can only be executed through a Safe transaction.
- ⚠️ EIP-7702 Warning:
A Safe can set itself as an owner, which is valid for EIP-7702 delegation setups.
However, if the Safe address is not an EOA (Externally Owned Account) and
cannot sign for itself, this may lock access to the Safe.
For example, in an
n/nSafe (wherethreshold == ownerCount), if the Safe includes itself as an owner without EIP-7702 delegation, no valid signature can be produced, effectively preventing further Safe transactions.
Parameters:
prevOwner: Owner address that precedes theoldOwnerin the linked list of owners. IfoldOwneris the first (or only) element,prevOwnermust be the sentinel address0x1(referred to asSENTINEL_OWNERSin the implementation).oldOwner: Owner address to be replaced.newOwner: New owner address to replace the old one.
Implementation
@override
Future<SafeContractEncodedCall> swapOwner({
required ETHAddress prevOwner,
required ETHAddress oldOwner,
required ETHAddress newOwner,
}) async {
final params = [prevOwner, oldOwner, newOwner];
return encodeTransactionCall(
functionName: SafeContractFunction.swapOwner,
params: params,
);
}