swapOwner method

  1. @override
Future<SafeContractEncodedCall> swapOwner({
  1. required ETHAddress prevOwner,
  2. required ETHAddress oldOwner,
  3. 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/n Safe (where threshold == 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 the oldOwner in the linked list of owners. If oldOwner is the first (or only) element, prevOwner must be the sentinel address 0x1 (referred to as SENTINEL_OWNERS in 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,
  );
}