# IModuleFactory\_v1.sol

[Git Source](https://github.com/InverterNetwork/inverter-contracts/blob/2a8a4c80ff4f24a59546d4e6126b81bc51228c94/src/factories/interfaces/IModuleFactory_v1.sol)

### Functions

#### reverter

Returns the address of the [{InverterReverter\_v1}](https://docs.inverter.network/contracts/technical-reference/external/reverter/inverterreverter_v1.sol) contract.

```solidity
function reverter() external view returns (address);
```

**Returns**

| Name     | Type      | Description                                                                                                                                                                          |
| -------- | --------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| `<none>` | `address` | reverterAddress Returns the address of the [{InverterReverter\_v1}](https://docs.inverter.network/contracts/technical-reference/external/reverter/inverterreverter_v1.sol) contract. |

#### governor

Returns the [{Governor\_v1}](https://docs.inverter.network/contracts/technical-reference/external/governance/governor_v1.sol) contract address.

```solidity
function governor() external view returns (address);
```

**Returns**

| Name     | Type      | Description                                                                                                                                                             |
| -------- | --------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `<none>` | `address` | govnernorAddress Returns the address of the [{Governor\_v1}](https://docs.inverter.network/contracts/technical-reference/external/governance/governor_v1.sol) contract. |

#### createAndInitModule

Creates a module instance identified by given `metadata` and initiates it.

```solidity
function createAndInitModule(
    IModule_v1.Metadata memory metadata,
    IOrchestrator_v1 orchestrator,
    bytes memory configData,
    IOrchestratorFactory_v1.WorkflowConfig memory workflowConfig
) external returns (address);
```

**Parameters**

| Name             | Type                                     | Description                                                                                                                                    |
| ---------------- | ---------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------- |
| `metadata`       | `IModule_v1.Metadata`                    | The module's `metadata`.                                                                                                                       |
| `orchestrator`   | `IOrchestrator_v1`                       | The [{Orchestrator\_v1}](https://docs.inverter.network/contracts/technical-reference/orchestrator/orchestrator_v1.sol) instance of the module. |
| `configData`     | `bytes`                                  | The configData of the module.                                                                                                                  |
| `workflowConfig` | `IOrchestratorFactory_v1.WorkflowConfig` | The configData of the workflow.                                                                                                                |

**Returns**

| Name     | Type      | Description                                                         |
| -------- | --------- | ------------------------------------------------------------------- |
| `<none>` | `address` | moduleProxyAddress Returns the address of the created module proxy. |

#### createModuleProxy

Creates a module proxy instance identified by given `metadata`.

```solidity
function createModuleProxy(
    IModule_v1.Metadata memory metadata,
    IOrchestrator_v1 orchestrator,
    IOrchestratorFactory_v1.WorkflowConfig memory workflowConfig
) external returns (address);
```

**Parameters**

| Name             | Type                                     | Description                                                                                                                                    |
| ---------------- | ---------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------- |
| `metadata`       | `IModule_v1.Metadata`                    | The module's metadata.                                                                                                                         |
| `orchestrator`   | `IOrchestrator_v1`                       | The [{Orchestrator\_v1}](https://docs.inverter.network/contracts/technical-reference/orchestrator/orchestrator_v1.sol) instance of the module. |
| `workflowConfig` | `IOrchestratorFactory_v1.WorkflowConfig` | The configData of the workflow.                                                                                                                |

**Returns**

| Name     | Type      | Description                                      |
| -------- | --------- | ------------------------------------------------ |
| `<none>` | `address` | Returns the address of the created module proxy. |

#### getBeaconAndId

Returns the [{IInverterBeacon\_v1}](https://docs.inverter.network/contracts/technical-reference/proxies/interfaces/iinverterbeacon_v1.sol) instance registered and the `id` for given `metadata`.

```solidity
function getBeaconAndId(IModule_v1.Metadata memory metadata)
    external
    view
    returns (IInverterBeacon_v1, bytes32);
```

**Parameters**

| Name       | Type                  | Description            |
| ---------- | --------------------- | ---------------------- |
| `metadata` | `IModule_v1.Metadata` | The module's metadata. |

**Returns**

| Name     | Type                 | Description                                                                                                                                                             |
| -------- | -------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `<none>` | `IInverterBeacon_v1` | beacon The module's [{IInverterBeacon\_v1}](https://docs.inverter.network/contracts/technical-reference/proxies/interfaces/iinverterbeacon_v1.sol) instance registered. |
| `<none>` | `bytes32`            | id The metadata's id.                                                                                                                                                   |

#### getOrchestratorOfProxy

Returns the [{Orchestrator\_v1}](https://docs.inverter.network/contracts/technical-reference/orchestrator/orchestrator_v1.sol) address of a beacon proxy.

```solidity
function getOrchestratorOfProxy(address proxy)
    external
    view
    returns (address);
```

**Parameters**

| Name    | Type      | Description               |
| ------- | --------- | ------------------------- |
| `proxy` | `address` | The beacon proxy address. |

**Returns**

| Name     | Type      | Description                                                                                                                                                                              |
| -------- | --------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `<none>` | `address` | orchestratorAddress The corresponding [{Orchestrator\_v1}](https://docs.inverter.network/contracts/technical-reference/orchestrator/orchestrator_v1.sol) address for the provided proxy. |

#### registerMetadata

Registers metadata `metadata` with [{IInverterBeacon\_v1}](https://docs.inverter.network/contracts/technical-reference/proxies/interfaces/iinverterbeacon_v1.sol) implementation `beacon`.

*Only callable by owner.*

```solidity
function registerMetadata(
    IModule_v1.Metadata memory metadata,
    IInverterBeacon_v1 beacon
) external;
```

**Parameters**

| Name       | Type                  | Description                                                                                                                                           |
| ---------- | --------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------- |
| `metadata` | `IModule_v1.Metadata` | The module's metadata.                                                                                                                                |
| `beacon`   | `IInverterBeacon_v1`  | The module's [{IInverterBeacon\_v1}](https://docs.inverter.network/contracts/technical-reference/proxies/interfaces/iinverterbeacon_v1.sol) instance. |

### Events

#### MetadataRegistered

Event emitted when new beacon registered for metadata.

```solidity
event MetadataRegistered(
    IModule_v1.Metadata metadata, IInverterBeacon_v1 indexed beacon
);
```

**Parameters**

| Name       | Type                  | Description              |
| ---------- | --------------------- | ------------------------ |
| `metadata` | `IModule_v1.Metadata` | The registered Metadata. |
| `beacon`   | `IInverterBeacon_v1`  | The registered Beacon.   |

#### ModuleCreated

Event emitted when new module created for an [{Orchestrator\_v1}](https://docs.inverter.network/contracts/technical-reference/orchestrator/orchestrator_v1.sol).

```solidity
event ModuleCreated(
    address indexed orchestrator,
    address indexed module,
    IModule_v1.Metadata metadata
);
```

**Parameters**

| Name           | Type                  | Description                                                                                                                           |
| -------------- | --------------------- | ------------------------------------------------------------------------------------------------------------------------------------- |
| `orchestrator` | `address`             | The corresponding [{Orchestrator\_v1}](https://docs.inverter.network/contracts/technical-reference/orchestrator/orchestrator_v1.sol). |
| `module`       | `address`             | The created module instance.                                                                                                          |
| `metadata`     | `IModule_v1.Metadata` | The registered metadata.                                                                                                              |

#### GovernorSet

Event emitted when [{Governor\_v1}](https://docs.inverter.network/contracts/technical-reference/external/governance/governor_v1.sol) is set.

```solidity
event GovernorSet(address indexed governor);
```

**Parameters**

| Name       | Type      | Description                                                                                                                           |
| ---------- | --------- | ------------------------------------------------------------------------------------------------------------------------------------- |
| `governor` | `address` | The address of the [{Governor\_v1}](https://docs.inverter.network/contracts/technical-reference/external/governance/governor_v1.sol). |

### Errors

#### ModuleFactory\_\_InvalidMetadata

Given metadata invalid.

```solidity
error ModuleFactory__InvalidMetadata();
```

#### ModuleFactory\_\_InvalidInitialRegistrationData

Given metadata invalid.

```solidity
error ModuleFactory__InvalidInitialRegistrationData();
```

#### ModuleFactory\_\_InvalidInverterBeacon

Given beacon invalid.

```solidity
error ModuleFactory__InvalidInverterBeacon();
```

#### ModuleFactory\_\_UnregisteredMetadata

Given metadata unregistered.

```solidity
error ModuleFactory__UnregisteredMetadata();
```

#### ModuleFactory\_\_MetadataAlreadyRegistered

Given metadata already registered.

```solidity
error ModuleFactory__MetadataAlreadyRegistered();
```

#### ModuleFactory\_\_ModuleIsSunset

Given module version is sunset.

```solidity
error ModuleFactory__ModuleIsSunset();
```
