# Identity Registry Storage Interface

The Identity Registry Storage interface defines the set of functions and events used to manage and store identity data within the T-REX protocol. Below is a detailed breakdown of each function and event, explaining its purpose, source, and functionality.

**`IdentityStored`**

**Event**

**Description**: Emitted when an identity is registered into the storage contract.

```solidity
event IdentityStored(address indexed investorAddress, IIdentity indexed identity);
```

***

**`IdentityUnstored`**

**Event**

**Description**: Emitted when an identity is removed from the storage contract.

```solidity
event IdentityUnstored(address indexed investorAddress, IIdentity indexed identity);
```

***

**`IdentityModified`**

**Event**

**Description**: Emitted when an identity has been updated in the storage contract.

```solidity
event IdentityModified(IIdentity indexed oldIdentity, IIdentity indexed newIdentity);
```

***

**`CountryModified`**

**Event**

**Description**: Emitted when an identity's country has been updated in the storage contract.

```solidity
event CountryModified(address indexed investorAddress, uint16 indexed country);
```

***

**`IdentityRegistryBound`**

**Event**

**Description**: Emitted when an Identity Registry is bound to the storage contract.

```solidity
event IdentityRegistryBound(address indexed identityRegistry);
```

***

**`IdentityRegistryUnbound`**

**Event**

**Description**: Emitted when an Identity Registry is unbound from the storage contract.

```solidity
event IdentityRegistryUnbound(address indexed identityRegistry);
```

***

**`addIdentityToStorage`**

**Source**: `IIdentityRegistryStorage`

**Description**: Adds an identity contract corresponding to a user address in the storage. Only callable by an agent of the contract.

```solidity
function addIdentityToStorage(
    address _userAddress,
    IIdentity _identity,
    uint16 _country
) external;
```

***

**`removeIdentityFromStorage`**

**Source**: `IIdentityRegistryStorage`

**Description**: Removes a user from the storage. Only callable by an agent of the contract.

```solidity
function removeIdentityFromStorage(address _userAddress) external;
```

***

**`modifyStoredInvestorCountry`**

**Source**: `IIdentityRegistryStorage`

**Description**: Updates the country corresponding to a user address. Only callable by an agent of the contract.

```solidity
function modifyStoredInvestorCountry(address _userAddress, uint16 _country) external;
```

***

**`modifyStoredIdentity`**

**Source**: `IIdentityRegistryStorage`

**Description**: Updates an identity contract corresponding to a user address. Only callable by an agent of the contract.

```solidity
function modifyStoredIdentity(address _userAddress, IIdentity _identity) external;
```

***

**`bindIdentityRegistry`**

**Source**: `IIdentityRegistryStorage`

**Description**: Adds an identity registry as an agent of the Identity Registry Storage Contract. Only callable by the owner of the contract.

```solidity
function bindIdentityRegistry(address _identityRegistry) external;
```

***

**`unbindIdentityRegistry`**

**Source**: `IIdentityRegistryStorage`

**Description**: Removes an identity registry from being an agent of the Identity Registry Storage Contract. Only callable by the owner of the contract.

```solidity
function unbindIdentityRegistry(address _identityRegistry) external;
```

***

**`linkedIdentityRegistries`**

**Source**: `IIdentityRegistryStorage`

**Description**: Returns the identity registries linked to the storage contract.

```solidity
function linkedIdentityRegistries() external view returns (address[] memory);
```

***

**`storedIdentity`**

**Source**: `IIdentityRegistryStorage`

**Description**: Returns the ONCHAINID of an investor based on their wallet address.

```solidity
function storedIdentity(address _userAddress) external view returns (IIdentity);
```

***

**`storedInvestorCountry`**

**Source**: `IIdentityRegistryStorage`

**Description**: Returns the country code of an investor based on their wallet address.

```solidity
function storedInvestorCountry(address _userAddress) external view returns (uint16);
```
