# ProxyWalletRegistry

The `ProxyWalletRegistry` manages the creation and administration of proxy wallets. This contract serves as a registry to associate owners with their respective proxy wallets and includes features to manage access and operational states.

#### Events

* **`LogAddToWhitelist`**:
  * Emitted when an address is added to the whitelist. Only in centralized mode.
  * Parameters:
    * `_user` (address indexed): The address added to the whitelist.
* **`LogRemoveFromWhitelist`**:
  * Emitted when an address is removed from the whitelist. Only in centralized mode.
  * Parameters:
    * `_user` (address indexed): The address removed from the whitelist.
* **`LogSetDecentralizedMode`**:
  * Emitted when the decentralized mode is toggled.
  * Parameters:
    * `newValue` (bool): The new state of the decentralized mode (true for enabled, false for disabled).
* **`LogProxyWalletCreation`**:
  * Emitted when a new proxy wallet is created and associated with an owner.
  * Parameters:
    * `owner` (address): The owner of the new proxy wallet.
    * `proxyWallet` (address): The address of the newly created proxy wallet.

#### State Variables

* **`proxies`** (mapping(address => ProxyWallet)):
  * Maps an owner's address to their corresponding proxy wallet.
* **`factory`** (ProxyWalletFactory):
  * The factory contract used for creating new proxy wallets.
* **`whitelisted`** (mapping(address => bool)):
  * Tracks whether addresses are whitelisted, which influences their ability to create proxy wallets. Only in centralized mode.
* **`bookKeeper`** (IBookKeeper):
  * Reference to the `BookKeeper` contract used for managing financial interactions within the system.
* **`isDecentralizedMode`** (bool):
  * A flag indicating whether the system is operating in a decentralized mode, affecting proxy wallet creation permissions.

#### Functions

**Public/External Functions**

* **`initialize`**:
  * Initializes the `ProxyWalletRegistry` with necessary contract references.
  * Parameters:
    * `_factory` (address): Address of the `ProxyWalletFactory` contract.
    * `_bookKeeper` (address): Address of the `BookKeeper` contract.
* **`addToWhitelist`**:
  * Adds an address to the whitelist. Only in centralized mode.
  * Parameters:
    * `_usr` (address): The address to add to the whitelist.
* **`removeFromWhitelist`**:
  * Removes an address from the whitelist. Only in centralized mode.
  * Parameters:
    * `_usr` (address): The address to remove from the whitelist.
* **`setDecentralizedMode`**:
  * Toggles the decentralized mode of the registry.
  * Parameters:
    * `isOn` (bool): Boolean to enable or disable decentralized mode.
* **`pause`** and **`unpause`**:
  * Controls the paused state of the contract, restricting or enabling function execution based on the contract's operational state.
* **`build0`**:
  * Convenience function that allows an owner to create a proxy wallet for themselves without specifying an owner explicitly.
* **`build`**:
  * Creates a new proxy wallet for a specified owner if they are whitelisted or if the contract is in decentralized mode.
  * Parameters:
    * `_owner` (address): The intended owner of the new proxy wallet.
* **`setOwner`**:
  * Changes the owner of a specific proxy wallet.
  * Parameters:
    * `_newOwner` (address): The new owner to set.
