Resolver
View Source: @nomisma/elektro-protocol-aux/contracts/delegate/Resolver.sol
↗ Extends: RoleAware
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
bytes32 private constant GOVERNOR_ROLE_NAME;
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'slookup()
will return an incorrect address, since with any call in this case only {Router.setResolver()} will be called.
bytes32 internal constant SET_RESOLVER_SIG;
SignatureRegistered
Event fired for every newly registered function signature on Resolver.
Parameters
keccakSignature
bytes32
destination
address
SignatureUpdated
Event fired for every updated (e.g. arguments changed after upgrade) function signature on Resolver.
Parameters
keccakSignature
bytes32
destination
address
SignatureRemoved
Event fired for every updated (e.g. arguments changed after upgrade) function signature on Resolver.
Parameters
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
function (address roleManager) public nonpayable
Arguments
roleManager
address
address of {RoleManager} contract
bulkRegister
Function to register mapping of multiple signatures to corresponding smart contract addresses.
function bulkRegister(bytes32[] keccakSignatures, address[] destinations) public nonpayable onlyRole
Arguments
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
function register(bytes32 keccakSignature, address destination) public nonpayable onlyRole
Arguments
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
function bulkUpdate(bytes32[] keccakSignatures, address[] destinations) public nonpayable onlyRole
Arguments
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
function updateSignature(bytes32 keccakSignature, address destination) public nonpayable onlyRole
Arguments
keccakSignature
bytes32
signature to be updated
destination
address
contract address that signature will point to
removeSignature
Function to remove single keccakSignature
.
function removeSignature(bytes32 keccakSignature) public nonpayable onlyRole
Arguments
keccakSignature
bytes32
signature to be removed
lookup
View to check address of contract for given first 4 bytes of keccak signature
.
function lookup(bytes4 signature) public view
returns(address)
Arguments
signature
bytes4
stringToSig
Converts string signature to first 4 bytes of keccak signature
.
function stringToSig(string signature) public pure
returns(bytes4)
Arguments
signature
string
_register
Function to register single keccakSignature
to address mapping and emit a SignatureRegistered
event that can be found in the transaction events.
function _register(bytes32 keccakSignature, address destination) internal nonpayable
Arguments
keccakSignature
bytes32
destination
address
_updateSignature
function _updateSignature(bytes32 keccakSignature, address destination) internal nonpayable
Arguments
keccakSignature
bytes32
destination
address
assertSignatureAndDestination
function assertSignatureAndDestination(bytes32 keccakSignature, address destination) internal view
Arguments
keccakSignature
bytes32
destination
address
Last updated
Was this helpful?