# Resolver

View Source: @nomisma/elektro-protocol-aux/contracts/delegate/Resolver.sol

**↗ Extends:** [**RoleAware**](https://elektro.gitbook.io/elektro-protocol/smart-contracts/natspec-technical-documentation/proxy-pattern-base-logic/broken-reference)

**Resolver**

Contract is used to store mapping between keccak signatures and address of deployed contract. It is used by router to resolve and call correct contract address. This contract is an essential part of Elektro's Proxy Pattern architecture! It does NOT get redeployed during a system on-chain upgrade, only internal storage gets updated to store data for newly deployed/upgraded implementations contracts throughout the system.

## Contract Members

**Constants & Variables**

```js
bytes32 private constant GOVERNOR_ROLE_NAME;
```

***

```js
mapping(bytes4 => address) internal pointers;
```

***

> IMPORTANT: This is a signature of the native Router function that can NOT be shadowed by any implementation contract. We check a keccak signature against it for every `register()` to make sure this doesn't happen. In the case of shadowing, Resolver's `lookup()` will return an incorrect address, since with any call in this case only {Router.setResolver()} will be called.

```js
bytes32 internal constant SET_RESOLVER_SIG;
```

***

## SignatureRegistered

Event fired for every newly registered function signature on Resolver.

**Parameters**

| Name            | Type    | Description |
| --------------- | ------- | ----------- |
| keccakSignature | bytes32 |             |
| destination     | address |             |

## SignatureUpdated

Event fired for every updated (e.g. arguments changed after upgrade) function signature on Resolver.

**Parameters**

| Name            | Type    | Description |
| --------------- | ------- | ----------- |
| keccakSignature | bytes32 |             |
| destination     | address |             |

## SignatureRemoved

Event fired for every updated (e.g. arguments changed after upgrade) function signature on Resolver.

**Parameters**

| Name            | Type    | Description |
| --------------- | ------- | ----------- |
| keccakSignature | bytes32 |             |

## Functions

* (address roleManager)
* bulkRegister(bytes32\[] keccakSignatures, address\[] destinations)
* register(bytes32 keccakSignature, address destination)
* bulkUpdate(bytes32\[] keccakSignatures, address\[] destinations)
* updateSignature(bytes32 keccakSignature, address destination)
* removeSignature(bytes32 keccakSignature)
* lookup(bytes4 signature)
* stringToSig(string signature)
* \_register(bytes32 keccakSignature, address destination)
* \_updateSignature(bytes32 keccakSignature, address destination)
* assertSignatureAndDestination(bytes32 keccakSignature, address destination)

###

Constructor setting {RoleManager} contract to storage

```js
function (address roleManager) public nonpayable
```

**Arguments**

| Name        | Type    | Description                       |
| ----------- | ------- | --------------------------------- |
| roleManager | address | address of {RoleManager} contract |

### bulkRegister

Function to register mapping of multiple signatures to corresponding smart contract addresses.

```js
function bulkRegister(bytes32[] keccakSignatures, address[] destinations) public nonpayable onlyRole 
```

**Arguments**

| Name             | Type       | Description                                               |
| ---------------- | ---------- | --------------------------------------------------------- |
| keccakSignatures | bytes32\[] | array of signatures to be registered                      |
| destinations     | address\[] | array of contract addresses that signatures will point to |

### register

Function to register single `keccakSignature` to address mapping

```js
function register(bytes32 keccakSignature, address destination) public nonpayable onlyRole 
```

**Arguments**

| Name            | Type    | Description                                                    |
| --------------- | ------- | -------------------------------------------------------------- |
| keccakSignature | bytes32 | signature to be registered                                     |
| destination     | address | contract address that signature will point to See {\_register} |

### bulkUpdate

Function to update existing signatures in bulk during a SC upgrade

```js
function bulkUpdate(bytes32[] keccakSignatures, address[] destinations) public nonpayable onlyRole 
```

**Arguments**

| Name             | Type       | Description                                      |
| ---------------- | ---------- | ------------------------------------------------ |
| keccakSignatures | bytes32\[] | signatures to be updated                         |
| destinations     | address\[] | contract addresses that signatures will point to |

### updateSignature

Function to update existing `keccakSignature` to address mapping, used during SC upgrade

```js
function updateSignature(bytes32 keccakSignature, address destination) public nonpayable onlyRole 
```

**Arguments**

| Name            | Type    | Description                                   |
| --------------- | ------- | --------------------------------------------- |
| keccakSignature | bytes32 | signature to be updated                       |
| destination     | address | contract address that signature will point to |

### removeSignature

Function to remove single `keccakSignature`.

```js
function removeSignature(bytes32 keccakSignature) public nonpayable onlyRole 
```

**Arguments**

| Name            | Type    | Description             |
| --------------- | ------- | ----------------------- |
| keccakSignature | bytes32 | signature to be removed |

### lookup

View to check address of contract for given first 4 bytes of keccak `signature`.

```js
function lookup(bytes4 signature) public view
returns(address)
```

**Arguments**

| Name      | Type   | Description |
| --------- | ------ | ----------- |
| signature | bytes4 |             |

### stringToSig

Converts string signature to first 4 bytes of keccak `signature`.

```js
function stringToSig(string signature) public pure
returns(bytes4)
```

**Arguments**

| Name      | Type   | Description |
| --------- | ------ | ----------- |
| signature | string |             |

### \_register

Function to register single `keccakSignature` to address mapping and emit a `SignatureRegistered` event that can be found in the transaction events.

```js
function _register(bytes32 keccakSignature, address destination) internal nonpayable
```

**Arguments**

| Name            | Type    | Description |
| --------------- | ------- | ----------- |
| keccakSignature | bytes32 |             |
| destination     | address |             |

### \_updateSignature

```js
function _updateSignature(bytes32 keccakSignature, address destination) internal nonpayable
```

**Arguments**

| Name            | Type    | Description |
| --------------- | ------- | ----------- |
| keccakSignature | bytes32 |             |
| destination     | address |             |

### assertSignatureAndDestination

```js
function assertSignatureAndDestination(bytes32 keccakSignature, address destination) internal view
```

**Arguments**

| Name            | Type    | Description |
| --------------- | ------- | ----------- |
| keccakSignature | bytes32 |             |
| destination     | address |             |
