Skip to content

Solidity API

Spanning

_This module provides a number of utility functions and modifiers for interacting with the Spanning Network. It includes:

  • Functions abstracting delegate state and methods
  • Functions for multi-domain ownership Note: This module is meant to be used through inheritance._

delegateLegacyAddress

address delegateLegacyAddress

delegate_

contract ISpanningDelegate delegate_

rootOwner

bytes32 rootOwner

constructor

constructor(address delegate) internal

Initializes a Spanning base module. Note: The initial rootOwner is set to whomever deployed the contract.

NameTypeDescription
delegateaddress- Legacy (local) address of our Spanning Delegate

isSpanning

function isSpanning() external pure returns (bool)
NameTypeDescription
[0]boolbool - true if the contract is a Spanning contract

isSpanningCall

function isSpanningCall() public view returns (bool)
NameTypeDescription
[0]boolbool - true if a sender is a Spanning Delegate

getDomain

function getDomain() internal view returns (bytes4)
NameTypeDescription
[0]bytes4bytes4 - Domain identifier

delegateAddress

function delegateAddress() internal view returns (address)
NameTypeDescription
[0]addressaddress - Local (legacy) address of the Delegate

updateDelegate

function updateDelegate(address newDelegateLegacyAddress) external override onlyOwner

Updates Delegate's legacy (local) address.

NameTypeDescription
newDelegateLegacyAddressaddress- Desired address for Spanning Delegate

makeRequest

function makeRequest(bytes32 programAddress, bytes payload) internal virtual

Creates a function request for a delegate to execute. Note: This can result in either a local or cross-domain transaction.

NameTypeDescription
programAddressbytes32- Address to be called
payloadbytes- ABI-encoding of the desired function call

getLegacyFromAddress

function getLegacyFromAddress(bytes32 inputAddress) internal view returns (address)

_Gets a Legacy Address from an Address, if in the same domain.

Note: This function can be used to create backwards-compatible events._

NameTypeDescription
inputAddressbytes32- Address to convert to a Legacy Address
NameTypeDescription
[0]addressaddress - Legacy Address if in the same domain, otherwise 0x0

getDomainFromAddress

function getDomainFromAddress(bytes32 inputAddress) internal pure returns (bytes4)

Gets a Domain from an Address

NameTypeDescription
inputAddressbytes32- Address to convert to a domain
NameTypeDescription
[0]bytes4domain - Domain ID

getAddressFromLegacy

function getAddressFromLegacy(address legacyAddress) internal view returns (bytes32)

Creates an Address from a Legacy Address, using the local domain.

NameTypeDescription
legacyAddressaddress- Legacy (local) address to convert
NameTypeDescription
[0]bytes32bytes32 - Packed Address

spanningMsgSender

function spanningMsgSender() internal view returns (bytes32)
NameTypeDescription
[0]bytes32bytes32 - Multi-domain msg.sender, defaulting to local sender.

spanningTxnSender

function spanningTxnSender() internal view returns (bytes32)
NameTypeDescription
[0]bytes32bytes32 - Multi-domain tx.origin, defaulting to local origin.

isValidSpanningInfo

function isValidSpanningInfo() internal view returns (bool)
NameTypeDescription
[0]boolbool - True if the current call stack has valid Spanning Info

spanningMsgSenderUnchecked

function spanningMsgSenderUnchecked() internal view returns (bytes32)
NameTypeDescription
[0]bytes32bytes32 - Multi-domain msg.sender, defaulting to local sender.

spanningTxnSenderUnchecked

function spanningTxnSenderUnchecked() internal view returns (bytes32)
NameTypeDescription
[0]bytes32bytes32 - Multi-domain tx.origin.

owner

function owner() public view virtual returns (bytes32)
NameTypeDescription
[0]bytes32bytes32 - Address of current owner

renounceOwnership

function renounceOwnership() public virtual override onlyOwner

Sets the owner to null, effectively removing contract ownership. Note: It will not be possible to call onlyOwner functions anymore Note: Can only be called by the current owner

transferOwnership

function transferOwnership(bytes32 newOwnerAddress) public virtual override onlyOwner

Assigns new owner for the contract. Note: Can only be called by the current owner

NameTypeDescription
newOwnerAddressbytes32- Address for desired owner

_transferOwnership

function _transferOwnership(bytes32 newOwnerAddress) internal virtual

Transfers ownership of the contract to a new Address.

NameTypeDescription
newOwnerAddressbytes32- Address for desired owner

Modifiers

onlySpanning

modifier onlySpanning()

Reverts if the function is executed by anyone but the Delegate.

onlyOwner

modifier onlyOwner()

Reverts if the function is executed by anyone but the owner.