IPcl.changeAddressListAdmin

changeAddressListAdmin(uint64 listId, address newAdmin) external

Transfers administrative ownership of a shared address list to newAdmin. Only the current admin may call this; any other sender reverts with Unauthorized. Setting newAdmin to the zero address is rejected with InvalidAddressListConfig — renouncing admin rights is not supported through this entry point. Calling with the same address that is already the admin is a no-op and emits no event. On an actual change the registry emits AddressListAdminChanged(listId, oldAdmin, newAdmin) and all subsequent mutating calls (updateAddressList, setAddressListStatus, further changeAddressListAdmin) must come from newAdmin.

Parameters

Name Type Required Description
listId uint64 ✓ The target list's nonzero ID. An unknown ID reverts with AddressListNotFound(listId); ID 0 with InvalidAddressListConfig(0).
newAdmin address ✓ The address that will hold admin rights after the call. Must not be the zero address.

Returns

Type: void

No return value. Observe AddressListAdminChanged to confirm the rotation.

Errors

Code Name Description
Unauthorized Unauthorized Reverts when msg.sender is not the current admin of listId.
AddressListNotFound AddressListNotFound Reverts when no list with that ID exists (ID 0 reverts with InvalidAddressListConfig instead). Encoded as AddressListNotFound(uint64 listId).
InvalidAddressListConfig InvalidAddressListConfig Reverts when newAdmin is the zero address, or when the registry's stored metadata fails integrity checks. Encoded as InvalidAddressListConfig(uint64 listId).
AddressListStorageError AddressListStorageError Reverts when the underlying registry store cannot be read or written. Encoded as AddressListStorageError(uint64 listId).
ABISetupFailed ABISetupFailed Inherited from IPrecompile. Reverts when calldata cannot be decoded against the precompile ABI.

Examples

Rotate list admin to a multisig

After this transaction mines, further mutating calls on listId must come from multisig; the previous key can no longer update the list.

import { createWalletClient, http } from "viem";
import { privateKeyToAccount } from "viem/accounts";
import { iPclAbi } from "@maroo-chain/contracts/abi/precompiles/pcl/IPcl";

const PCL = "0x1000000000000000000000000000000000000005" as const;

const currentAdmin = privateKeyToAccount(process.env.LIST_ADMIN_KEY as `0x${string}`);
const wallet = createWalletClient({
  account: currentAdmin,
  transport: http(process.env.MAROO_RPC_URL),
});

// TODO: replace with the real list id and the multisig address before production.
const listId = 12n;
const multisig = "0x2c7f09b81a6d3ff1e5a0d4c6bc2a8f7e19dc3a4b";

await wallet.writeContract({
  address: PCL,
  abi: iPclAbi,
  functionName: "changeAddressListAdmin",
  args: [listId, multisig],
});

Decode rotation errors on the client

Decoding with the full iPclAbi covers both the admin-rotation errors and the inherited IPrecompile errors in one pass; do not hand-write a narrow error list.

import { BaseError, ContractFunctionRevertedError, decodeErrorResult } from "viem";
import { iPclAbi } from "@maroo-chain/contracts/abi/precompiles/pcl/IPcl";

try {
  await wallet.writeContract({
    address: PCL,
    abi: iPclAbi,
    functionName: "changeAddressListAdmin",
    args: [listId, multisig],
  });
} catch (err) {
  const reverted = err instanceof BaseError
    ? err.walk((e) => e instanceof ContractFunctionRevertedError)
    : null;
  if (!(reverted instanceof ContractFunctionRevertedError) || !reverted.raw) {
    // Not a contract revert (network, signing): rethrow.
    throw err;
  }
  // iPclAbi carries both the list-specific errors (Unauthorized,
  // AddressListNotFound, InvalidAddressListConfig, AddressListStorageError)
  // and the inherited IPrecompile errors, so decodeErrorResult covers every case.
  const decoded = decodeErrorResult({ abi: iPclAbi, data: reverted.raw });
  console.error("changeAddressListAdmin reverted:", decoded.errorName, decoded.args);
}
ESC
Type to search