Conduit Controller

ConduitController enables deploying and managing new conduits, or contracts that allow registered callers (or open "channels") to transfer approved ERC20/721/1155 tokens on their behalf.

_conduits

mapping(address => struct ConduitControllerInterface.ConduitProperties) _conduits

_CONDUIT_CREATION_CODE_HASH

bytes32 _CONDUIT_CREATION_CODE_HASH

_CONDUIT_RUNTIME_CODE_HASH

bytes32 _CONDUIT_RUNTIME_CODE_HASH

constructor

constructor() public

Initialize contract by deploying a conduit and setting the creation code and runtime code hashes as immutable arguments.

createConduit

function createConduit(bytes32 conduitKey, address initialOwner) external returns (address conduit)

Deploy a new conduit using a supplied conduit key and assigning an initial owner for the deployed conduit. Note that the first twenty bytes of the supplied conduit key must match the caller and that a new conduit cannot be created if one has already been deployed using the same conduit key.

NameTypeDescription
conduitKeybytes32The conduit key used to deploy the conduit. Note that the first twenty bytes of the conduit key must match the caller of this contract.
initialOwneraddressThe initial owner to set for the new conduit.
NameTypeDescription
conduitaddressThe address of the newly deployed conduit.

updateChannel

function updateChannel(address conduit, address channel, bool isOpen) external

Open or close a channel on a given conduit, thereby allowing the specified account to execute transfers against that conduit. Extreme care must be taken when updating channels, as malicious or vulnerable channels can transfer any ERC20, ERC721 and ERC1155 tokens where the token holder has granted the conduit approval. Only the owner of the conduit in question may call this function.

NameTypeDescription
conduitaddressThe conduit for which to open or close the channel.
channeladdressThe channel to open or close on the conduit.
isOpenboolA boolean indicating whether to open or close the channel.

transferOwnership

function transferOwnership(address conduit, address newPotentialOwner) external

Initiate conduit ownership transfer by assigning a new potential owner for the given conduit. Once set, the new potential owner may call acceptOwnership to claim ownership of the conduit. Only the owner of the conduit in question may call this function.

NameTypeDescription
conduitaddressThe conduit for which to initiate ownership transfer.
newPotentialOwneraddressThe new potential owner of the conduit.

cancelOwnershipTransfer

function cancelOwnershipTransfer(address conduit) external

Clear the currently set potential owner, if any, from a conduit. Only the owner of the conduit in question may call this function.

NameTypeDescription
conduitaddressThe conduit for which to cancel ownership transfer.

acceptOwnership

function acceptOwnership(address conduit) external

Accept ownership of a supplied conduit. Only accounts that the current owner has set as the new potential owner may call this function.

NameTypeDescription
conduitaddressThe conduit for which to accept ownership.

ownerOf

function ownerOf(address conduit) external view returns (address owner)

Retrieve the current owner of a deployed conduit.

NameTypeDescription
conduitaddressThe conduit for which to retrieve the associated owner.
NameTypeDescription
owneraddressThe owner of the supplied conduit.

getKey

function getKey(address conduit) external view returns (bytes32 conduitKey)

Retrieve the conduit key for a deployed conduit via reverse lookup.

NameTypeDescription
conduitaddressThe conduit for which to retrieve the associated conduit key.
NameTypeDescription
conduitKeybytes32The conduit key used to deploy the supplied conduit.

getConduit

function getConduit(bytes32 conduitKey) external view returns (address conduit, bool exists)

Derive the conduit associated with a given conduit key and determine whether that conduit exists (i.e. whether it has been deployed).

NameTypeDescription
conduitKeybytes32The conduit key used to derive the conduit.
NameTypeDescription
conduitaddressThe derived address of the conduit.
existsboolA boolean indicating whether the derived conduit has been deployed or not.

getPotentialOwner

function getPotentialOwner(address conduit) external view returns (address potentialOwner)

Retrieve the potential owner, if any, for a given conduit. The current owner may set a new potential owner via transferOwnership and that owner may then accept ownership of the conduit in question via acceptOwnership.

NameTypeDescription
conduitaddressThe conduit for which to retrieve the potential owner.
NameTypeDescription
potentialOwneraddressThe potential owner, if any, for the conduit.

getChannelStatus

function getChannelStatus(address conduit, address channel) external view returns (bool isOpen)

Retrieve the status (either open or closed) of a given channel on a conduit.

NameTypeDescription
conduitaddressThe conduit for which to retrieve the channel status.
channeladdressThe channel for which to retrieve the status.
NameTypeDescription
isOpenboolThe status of the channel on the given conduit.

getTotalChannels

function getTotalChannels(address conduit) external view returns (uint256 totalChannels)

Retrieve the total number of open channels for a given conduit.

NameTypeDescription
conduitaddressThe conduit for which to retrieve the total channel count.
NameTypeDescription
totalChannelsuint256The total number of open channels for the conduit.

getChannel

function getChannel(address conduit, uint256 channelIndex) external view returns (address channel)

Retrieve an open channel at a specific index for a given conduit. Note that the index of a channel can change as a result of other channels being closed on the conduit.

NameTypeDescription
conduitaddressThe conduit for which to retrieve the open channel.
channelIndexuint256The index of the channel in question.
NameTypeDescription
channeladdressThe open channel, if any, at the specified channel index.

getChannels

function getChannels(address conduit) external view returns (address[] channels)

Retrieve all open channels for a given conduit. Note that calling this function for a conduit with many channels will revert with an out-of-gas error.

NameTypeDescription
conduitaddressThe conduit for which to retrieve open channels.
NameTypeDescription
channelsaddress[]An array of open channels on the given conduit.

getConduitCodeHashes

function getConduitCodeHashes() external view returns (bytes32 creationCodeHash, bytes32 runtimeCodeHash)

Retrieve the conduit creation code and runtime code hashes.

_assertCallerIsConduitOwner

function _assertCallerIsConduitOwner(address conduit) private view

Private view function to revert if the caller is not the owner of a given conduit.

NameTypeDescription
conduitaddressThe conduit for which to assert ownership.

_assertConduitExists

function _assertConduitExists(address conduit) private view

Private view function to revert if a given conduit does not exist.

NameTypeDescription
conduitaddressThe conduit for which to assert existence.