Teleport Solidity API
AlwaysSameProviderSelector
TELEPORT_ADDRESS
address TELEPORT_ADDRESS
ZeroAddressProvider
error ZeroAddressProvider()
Used to make sure the router address is not the zero address.
ZeroAddressTeleport
error ZeroAddressTeleport()
Used to make sure the teleport address is not the zero address.
onlyTeleport
modifier onlyTeleport()
Modifier to restrict access to functions only to the Teleport facet.
constructor
constructor(address initialProvider, address teleportAddress_) public
isValidProvider
function isValidProvider(address provider) external view returns (bool)
Checks if a given address is a valid provider.
Parameters
Name | Type | Description |
---|---|---|
provider | address | The address of the provider to check. |
Return Values
Name | Type | Description |
---|---|---|
[0] | bool | A boolean indicating whether the provider is valid or not. |
currentProviderAddress
function currentProviderAddress() external view returns (address)
getProvider
function getProvider(uint8, bytes, bytes32, bytes) external view returns (address)
Returns the address of the current provider.
Return Values
Name | Type | Description |
---|---|---|
[0] | address | The address of the current provider. |
config
function config(bytes configData) external
Configures the current provider address.
Parameters
Name | Type | Description |
---|---|---|
configData | bytes | The configuration data. |
_decodeConfigParams
function _decodeConfigParams(bytes configData) internal pure returns (struct AlwaysSameProviderSelector.ConfigCallParamsV1 params)
Decodes bytes received from the teleport config call.
Parameters
Name | Type | Description |
---|---|---|
configData | bytes | The data to decode. |
Return Values
Name | Type | Description |
---|---|---|
params | struct AlwaysSameProviderSelector.ConfigCallParamsV1 | The decoded params. |
ConfigCallParamsV1
struct ConfigCallParamsV1 {
address newProvider;
}
Diamond
constructor
constructor(struct IDiamondCut.FacetCut[] _diamondCut, address _init, bytes _calldata) public payable
fallback
fallback() external payable
Governable
Provides modifiers for securing methods behind a governance vote
onlyConsensus
function onlyConsensus(struct LibGovernance.Storage gs, bytes32 _ethHash, bytes[] _signatures) internal view
Verifies the message hash against the signatures. Requires a majority.
Parameters
Name | Type | Description |
---|---|---|
gs | struct LibGovernance.Storage | |
_ethHash | bytes32 | hash to verify |
_signatures | bytes[] | governance hash signatures |
onlyConsensusNonce
modifier onlyConsensusNonce(bytes32 _ethHash, bytes[] _signatures)
Verifies the message hash against the signatures. Requires a majority. Burns a nonce.
Parameters
Name | Type | Description |
---|---|---|
_ethHash | bytes32 | hash to verify |
_signatures | bytes[] | governance hash signatures |
onlyConsensusHash
modifier onlyConsensusHash(bytes32 _ethHash, bytes[] _signatures)
Verifies the message hash against the signatures. Requires a majority. Burns the hash.
Parameters
Name | Type | Description |
---|---|---|
_ethHash | bytes32 | hash to verify |
_signatures | bytes[] | governance hash signatures |
MultiWithDefaultProviderSelector
TELEPORT_ADDRESS
address TELEPORT_ADDRESS
validProviders
mapping(address => bool) validProviders
ProviderAdded
event ProviderAdded(address provider)
Emitted when a new provider is added.
Parameters
Name | Type | Description |
---|---|---|
provider | address | The address of the added provider. |
ProviderRemoved
event ProviderRemoved(address provider)
Emitted when a provider is removed from the contract.
Parameters
Name | Type | Description |
---|---|---|
provider | address | The address of the removed provider. |
DefaultProviderUpdated
event DefaultProviderUpdated(address provider)
Emitted when the default provider is updated in the contract.
Parameters
Name | Type | Description |
---|---|---|
provider | address | The address of the new default provider. |
ZeroAddressProvider
error ZeroAddressProvider()
Used to make sure the router address is not the zero address.
ZeroAddressTeleport
error ZeroAddressTeleport()
Used to make sure the teleport address is not the zero address.
ProviderNotFound
error ProviderNotFound()
Used to make sure that the provider exists.
onlyTeleport
modifier onlyTeleport()
Modifier to restrict access to functions only to the Teleport facet.
constructor
constructor(address initialProvider, address teleportAddress_) public
isValidProvider
function isValidProvider(address provider) external view returns (bool)
Checks if a given address is a valid provider.
Parameters
Name | Type | Description |
---|---|---|
provider | address | The address of the provider to check. |
Return Values
Name | Type | Description |
---|---|---|
[0] | bool | A boolean indicating whether the provider is valid or not. |
currentProviderAddress
function currentProviderAddress() external view returns (address)
getProvider
function getProvider(uint8, bytes, bytes32, bytes) external view returns (address)
Returns the address of the current provider.
Return Values
Name | Type | Description |
---|---|---|
[0] | address | The address of the current provider. |
config
function config(bytes configData) external
The function can only be called by the teleport contract.
Configures the providers info.
Parameters
Name | Type | Description |
---|---|---|
configData | bytes | The configuration data. - It should be encoded using the abi.encode function. - The data should be a struct of type ConfigCallParamsV2. - The struct should contain the following fields: - - action: The action to be performed. It can be AddProvider, RemoveProvider or UpdateDefaultProvider. - - providerAddress: The address of the provider. |
_decodeConfigParams
function _decodeConfigParams(bytes configData) internal pure returns (struct MultiWithDefaultProviderSelector.ConfigCallParamsV2 params)
Decodes bytes received from the teleport config call.
Parameters
Name | Type | Description |
---|---|---|
configData | bytes | The data to decode. |
Return Values
Name | Type | Description |
---|---|---|
params | struct MultiWithDefaultProviderSelector.ConfigCallParamsV2 | The decoded params. |
_addProvider
function _addProvider(address provider) internal
_removeProvider
function _removeProvider(address provider) internal
Action
enum Action {
AddProvider,
RemoveProvider,
SetDefaultProvider
}
ConfigCallParamsV2
struct ConfigCallParamsV2 {
enum MultiWithDefaultProviderSelector.Action action;
address providerAddress;
}
Multicall2
Call
struct Call {
address target;
bytes callData;
}
Result
struct Result {
bool success;
bytes returnData;
}
CallFailed
error CallFailed()
aggregate
function aggregate(struct Multicall2.Call[] calls) public view returns (uint256 blockNumber, bytes[] returnData)
blockAndAggregate
function blockAndAggregate(struct Multicall2.Call[] calls) public view returns (uint256 blockNumber, bytes32 blockHash, struct Multicall2.Result[] returnData)
getBlockHash
function getBlockHash(uint256 blockNumber) public view returns (bytes32 blockHash)
getBlockNumber
function getBlockNumber() public view returns (uint256 blockNumber)
getCurrentBlockCoinbase
function getCurrentBlockCoinbase() public view returns (address coinbase)
getCurrentBlockGasLimit
function getCurrentBlockGasLimit() public view returns (uint256 gaslimit)
getCurrentBlockTimestamp
function getCurrentBlockTimestamp() public view returns (uint256 timestamp)
getEthBalance
function getEthBalance(address addr) public view returns (uint256 balance)
getLastBlockHash
function getLastBlockHash() public view returns (bytes32 blockHash)
tryAggregate
function tryAggregate(bool requireSuccess, struct Multicall2.Call[] calls) public view returns (struct Multicall2.Result[] returnData)
tryBlockAndAggregate
function tryBlockAndAggregate(bool requireSuccess, struct Multicall2.Call[] calls) public view returns (uint256 blockNumber, bytes32 blockHash, struct Multicall2.Result[] returnData)
SingletonFactory
This contract is to be deployed by a single-purpose wallet on all supported networks. It serves as a CREATE2 factory and lets us have the same Diamond addresses across networks. Which in turn allows the diamond to produce the same WrappedCollection addresses across networks.
OwnerZeroAddress
error OwnerZeroAddress()
TargetAddressOccupied
error TargetAddressOccupied()
InitializationFailed
error InitializationFailed()
constructor
constructor(address owner_) public
Sets owner address who can use deploy()
Parameters
Name | Type | Description |
---|---|---|
owner_ | address | owner address |
deploy
function deploy(bytes initCode_, bytes32 salt_, bytes initializer_) external payable returns (address payable deployedContractAddress)
Deploys a contract and optionally calls an initialization method
Parameters
Name | Type | Description |
---|---|---|
initCode_ | bytes | initCode for the contract to be deployed |
salt_ | bytes32 | hash salt for CREATE2 |
initializer_ | bytes | Encoded function call on the newly deployed contract |
DiamondCutGovernableFacet
diamondCut
function diamondCut(struct IDiamondCut.FacetCut[] _diamondCut, address _init, bytes _calldata, bytes[] _signatures) external
Add/replace/remove any number of functions and optionally execute a function with delegatecall
Parameters
Name | Type | Description |
---|---|---|
_diamondCut | struct IDiamondCut.FacetCut[] | Contains the facet addresses and function selectors |
_init | address | The address of the contract or facet to execute _calldata |
_calldata | bytes | A function call, including function selector and arguments _calldata is executed with delegatecall on _init |
_signatures | bytes[] |
computeDiamondCutMessage
function computeDiamondCutMessage(struct IDiamondCut.FacetCut[] _diamondCut, address _init, bytes _calldata) internal view returns (bytes32)
@notice Computes the bytes32 ethereum signed message hash of the signature
DiamondCutSimpleFacet
This facet is being attached on the diamond during construction, then, within the same transaction, it is used to remove itself and add all the other facets (including DiamondCutGovernableFacet). This way we always have the same init code accross networks and CREATE2 yields the same address.
diamondCut
function diamondCut(struct IDiamondCut.FacetCut[] _diamondCut, address _init, bytes _calldata) external
Add/replace/remove any number of functions and optionally execute a function with delegatecall
Parameters
Name | Type | Description |
---|---|---|
_diamondCut | struct IDiamondCut.FacetCut[] | Contains the facet addresses and function selectors |
_init | address | The address of the contract or facet to execute _calldata |
_calldata | bytes | A function call, including function selector and arguments _calldata is executed with delegatecall on _init |
DiamondLoupeFacet
facets
function facets() external view returns (struct IDiamondLoupe.Facet[] facets_)
Gets all facets and their selectors.
Return Values
Name | Type | Description |
---|---|---|
facets_ | struct IDiamondLoupe.Facet[] | Facet |
facetFunctionSelectors
function facetFunctionSelectors(address _facet) external view returns (bytes4[] _facetFunctionSelectors)
Gets all the function selectors supported by a specific facet.
Parameters
Name | Type | Description |
---|---|---|
_facet | address | The facet address. |
Return Values
Name | Type | Description |
---|---|---|
_facetFunctionSelectors | bytes4[] | The selectors associated with a facet address. |
facetAddresses
function facetAddresses() external view returns (address[] facetAddresses_)
Get all the facet addresses used by a diamond.
Return Values
Name | Type | Description |
---|---|---|
facetAddresses_ | address[] |
facetAddress
function facetAddress(bytes4 _functionSelector) external view returns (address facetAddress_)
Gets the facet that supports the given selector.
If facet is not found return address(0).
Parameters
Name | Type | Description |
---|---|---|
_functionSelector | bytes4 | The function selector. |
Return Values
Name | Type | Description |
---|---|---|
facetAddress_ | address | The facet address. |
FeeCalculatorFacet
state
function state(bytes data_) external
sets the state for the FeeCalculator facet
This state method is never attached on the diamond
Parameters
Name | Type | Description |
---|---|---|
data_ | bytes | abi encoded data - the service fee for the teleport. |
setServiceFee
function setServiceFee(uint256 serviceFee_, bytes[] signatures_) external
@notice Sets the service fee for this chain @param serviceFee_ The new service fee @param signatures_ The array of signatures from the members, authorising the operation
computeFeeUpdateMessage
function computeFeeUpdateMessage(uint256 newServiceFee_) internal view returns (bytes32)
@notice Computes the Eth signed message to use for extracting signature signers for fee updates @param newServiceFee_ The fee that was used when creating the validator signatures
feesAccrued
function feesAccrued() external view returns (uint256)
Return Values
Name | Type | Description |
---|---|---|
[0] | uint256 | The total amount of accrued fees |
previousAccrued
function previousAccrued() external view returns (uint256)
Return Values
Name | Type | Description |
---|---|---|
[0] | uint256 | The feesAccrued counter before the last reward distribution |
accumulator
function accumulator() external view returns (uint256)
Return Values
Name | Type | Description |
---|---|---|
[0] | uint256 | The total fees accumulated per account (claimed + unclaimed). Recalculated at reward distribution. |
claimedRewardsPerAccount
function claimedRewardsPerAccount(address account_) external view returns (uint256)
@param account_ The address of a validator @return The total amount of fees claimed by the provided validator address
claim
function claim() external
Sends out the reward accumulated by the caller
GovernanceFacet
state
function state(bytes data_) external
sets the state for the Governance facet
This state method is never attached on the diamond
Parameters
Name | Type | Description |
---|---|---|
data_ | bytes | abi encoded data - the list of governance members. |
updateMember
function updateMember(address account_, bool status_, bytes[] signatures_) external
@notice Adds/removes a member account @param account_ The account to be modified @param status_ Whether the account will be set as member or not @param signatures_ The signatures of the validators authorizing this member update @dev Upon removal we also send out the validator's accumulated reward
computeMemberUpdateMessage
function computeMemberUpdateMessage(address account_, bool status_) internal view returns (bytes32)
Computes the bytes32 ethereum signed message hash of the member update message
isMember
function isMember(address member_) external view returns (bool)
Return Values
Name | Type | Description |
---|---|---|
[0] | bool | True/false depending on whether a given address is member or not |
membersCount
function membersCount() external view returns (uint256)
Return Values
Name | Type | Description |
---|---|---|
[0] | uint256 | The count of members in the members set |
memberAt
function memberAt(uint256 index_) external view returns (address)
Return Values
Name | Type | Description |
---|---|---|
[0] | address | The address of a member at a given index |
administrativeNonce
function administrativeNonce() external view returns (uint256)
Return Values
Name | Type | Description |
---|---|---|
[0] | uint256 | The current administrative nonce |
MPProviderFacet
onlyTeleport
modifier onlyTeleport()
Modifier to restrict access to functions only to the Teleport facet. The teleport is another facet in this same diamond, so we can check that the caller is this same diamond address.
sendMsg
function sendMsg(uint8 targetChainId_, bytes, struct IProvider.DappTransmissionInfo dappTranmissionInfo, bytes) external payable
Transmits the payload
to the validators by emitting the Transmission
event.
The address of the teleport param is ignored on this provider, as we only interact with the teleport contract.
Parameters
Name | Type | Description |
---|---|---|
targetChainId_ | uint8 | The chainID where the message should be delivered to |
bytes | ||
dappTranmissionInfo | struct IProvider.DappTransmissionInfo | Information related to the dapp tranmission |
bytes |
manualClaim
function manualClaim(bytes args) external
computeTransmissionHash
function computeTransmissionHash(bytes32 transmissionId_, uint8 sourceChainId_, bytes transmissionSender_, address transmissionReceiver_, bytes32 dAppId_, bytes payload_) internal view returns (bytes32)
Computes the bytes32 ethereum signed message hash of the transmission signatures
transmissionReceiver must be encoded as bytes to ensure cross-chain compatibility_
fee
function fee(uint8, bytes, struct IProvider.DappTransmissionInfo, bytes) external pure returns (uint256)
Return Values
Name | Type | Description |
---|---|---|
[0] | uint256 | The currently set service fee |
DeliverArgs
struct DeliverArgs {
bytes32 transmissionId;
uint8 sourceChainId;
bytes transmissionSender;
address transmissionReceiver;
bytes32 dAppId;
bytes payload;
bytes[] signatures;
}
deliverArgsToBytes
function deliverArgsToBytes(struct MPProviderFacet.DeliverArgs args) external pure returns (bytes)
Encodes the DeliverArgs struct into bytes.
Parameters
Name | Type | Description |
---|---|---|
args | struct MPProviderFacet.DeliverArgs | The DeliverArgs struct to be encoded. |
Return Values
Name | Type | Description |
---|---|---|
[0] | bytes | The encoded bytes. |
_addressToBytes
function _addressToBytes(address addr) internal pure returns (bytes)
@param addr value of type address @return addr value converted to type bytes
config
function config(bytes configData) external
supportedChains
function supportedChains(uint256 index) external view returns (uint8)
supportedChainsCount
function supportedChainsCount() external view returns (uint256)
ReceiverFacet
receive
receive() external payable
TeleportFacet
onlyValidProvider
modifier onlyValidProvider()
state
function state(bytes data_) external
sets the state for the TeleportFacet
This method is never attached on the diamond
transmit
function transmit(uint8 targetChainId_, bytes transmissionReceiver_, bytes32 dAppId_, bytes payload_) external payable
Selects a provider to bridge the message to the target chain
Parameters
Name | Type | Description |
---|---|---|
targetChainId_ | uint8 | The chainID where the message should be delivered to |
transmissionReceiver_ | bytes | The address of the contract in the target chain to receive the transmission |
dAppId_ | bytes32 | ID for the dApp that the message belongs to |
payload_ | bytes | The dApp-specific message data |
transmitWithArgs
function transmitWithArgs(uint8 targetChainId_, bytes transmissionReceiver_, bytes32 dAppId_, bytes payload_, bytes extraOptionalArgs_) external payable
Selects a provider to bridge the message to the target chain
Parameters
Name | Type | Description |
---|---|---|
targetChainId_ | uint8 | The chainID where the message should be delivered to |
transmissionReceiver_ | bytes | The address of the contract in the target chain to receive the transmission |
dAppId_ | bytes32 | ID for the dApp that the message belongs to |
payload_ | bytes | The dApp-specific message data |
extraOptionalArgs_ | bytes | Extra optional arguments to be passed to the provider. This allow for specific provider configurations. Send bytes('') if not needed |
transmitWithProvider
function transmitWithProvider(uint8 targetChainId_, bytes transmissionReceiver_, bytes32 dAppId_, bytes payload_, address providerAddress_, bytes extraOptionalArgs_) external payable
Selects a provider to bridge the message to the target chain
Parameters
Name | Type | Description |
---|---|---|
targetChainId_ | uint8 | The chainID where the message should be delivered to |
transmissionReceiver_ | bytes | The address of the contract in the target chain to receive the transmission |
dAppId_ | bytes32 | ID for the dApp that the message belongs to |
payload_ | bytes | The dApp-specific message data |
providerAddress_ | address | The provider to be used for the transmission |
extraOptionalArgs_ | bytes | Extra arguments to be passed to the provider. This allow for specific provider configurations |
teleportFee
function teleportFee() external view returns (uint256)
Returns the teleport fee charged by the teleport contract.
Return Values
Name | Type | Description |
---|---|---|
[0] | uint256 | The teleport fee amount in wei. |
providerFee
function providerFee(uint8 targetChainId_, bytes transmissionReceiver_, bytes32 dAppId_, bytes payload_, bytes extraOptionalArgs_) external view returns (uint256)
Returns the provider fee charged by the provider contract.
Parameters
Name | Type | Description |
---|---|---|
targetChainId_ | uint8 | The chainID where the message should be delivered to |
transmissionReceiver_ | bytes | The address of the contract in the target chain to receive the transmission |
dAppId_ | bytes32 | ID for the dApp that the message belongs to |
payload_ | bytes | The dApp-specific message data |
extraOptionalArgs_ | bytes | Extra optional arguments to be passed to the provider. This allow for specific provider configurations. Send bytes('') if not needed |
Return Values
Name | Type | Description |
---|---|---|
[0] | uint256 | The provider fee amount in wei. |
providerFee
function providerFee(address providerAddress_, uint8 targetChainId_, bytes transmissionReceiver_, bytes32 dAppId_, bytes payload_, bytes extraOptionalArgs_) external view returns (uint256)
Returns the provider fee charged by the provider contract.
Parameters
Name | Type | Description |
---|---|---|
providerAddress_ | address | The provider to be used for the transmission |
targetChainId_ | uint8 | The chainID where the message should be delivered to |
transmissionReceiver_ | bytes | The address of the contract in the target chain to receive the transmission |
dAppId_ | bytes32 | ID for the dApp that the message belongs to |
payload_ | bytes | The dApp-specific message data |
extraOptionalArgs_ | bytes | Extra optional arguments to be passed to the provider. This allow for specific provider configurations. Send bytes('') if not needed |
Return Values
Name | Type | Description |
---|---|---|
[0] | uint256 | The provider fee amount in wei. |
serviceFee
function serviceFee(uint8 targetChainId_, bytes transmissionReceiver_, bytes32 dAppId_, bytes payload_, bytes extraOptionalArgs_) external view returns (uint256)
Returns the service fee charged by the teleport and the provider contracts.
Parameters
Name | Type | Description |
---|---|---|
targetChainId_ | uint8 | The chainID where the message should be delivered to |
transmissionReceiver_ | bytes | The address of the contract in the target chain to receive the transmission |
dAppId_ | bytes32 | ID for the dApp that the message belongs to |
payload_ | bytes | The dApp-specific message data |
extraOptionalArgs_ | bytes | Extra optional arguments to be passed to the provider. This allow for specific provider configurations. Send bytes('') if not needed |
Return Values
Name | Type | Description |
---|---|---|
[0] | uint256 | The service fee amount in wei. |
serviceFee
function serviceFee(address providerAddress_, uint8 targetChainId_, bytes transmissionReceiver_, bytes32 dAppId_, bytes payload_, bytes extraOptionalArgs_) external view returns (uint256)
Returns the service fee charged by the teleport and the provider contracts.
Parameters
Name | Type | Description |
---|---|---|
providerAddress_ | address | The provider to be used for the transmission |
targetChainId_ | uint8 | The chainID where the message should be delivered to |
transmissionReceiver_ | bytes | The address of the contract in the target chain to receive the transmission |
dAppId_ | bytes32 | ID for the dApp that the message belongs to |
payload_ | bytes | The dApp-specific message data |
extraOptionalArgs_ | bytes | Extra optional arguments to be passed to the provider. This allow for specific provider configurations. Send bytes('') if not needed |
Return Values
Name | Type | Description |
---|---|---|
[0] | uint256 | The service fee amount in wei. |
deliver
function deliver(address providerAddress, bytes args) external
Delivers a message using the provided provider. This might not be supported by all providers.
Parameters
Name | Type | Description |
---|---|---|
providerAddress | address | The address of the provider contract. |
args | bytes | The arguments to be passed to the provider contract. |
onProviderReceive
function onProviderReceive(struct ITeleport.DappTransmissionReceive args) external
Function called when a provider receives a transmission from another chain's teleport.
Parameters
Name | Type | Description |
---|---|---|
args | struct ITeleport.DappTransmissionReceive | The DappTransmissionReceive struct containing the transmission data. |
configProviderSelector
function configProviderSelector(bytes configData, bytes[] signatures_) external
computeConfigProviderSelector
function computeConfigProviderSelector(bytes configData) internal view returns (bytes32)
Computes the bytes32 ethereum signed message hash of the call to config the provider selector message
configProvider
function configProvider(bytes configData, address providerAddress, bytes[] signatures_) external
computeConfigProvider
function computeConfigProvider(bytes configData, address providerAddress) internal view returns (bytes32)
Computes the bytes32 ethereum signed message hash of the call to the config a provider message
_providerFee
function _providerFee(address providerAddress_, uint8 targetChainId_, bytes transmissionReceiver_, bytes32 dAppId_, bytes payload_, bytes extraOptionalArgs_) internal view returns (uint256)
Returns the provider fee charged by the provider contract.
Parameters
Name | Type | Description |
---|---|---|
providerAddress_ | address | The provider to be used for the transmission |
targetChainId_ | uint8 | The chainID where the message should be delivered to |
transmissionReceiver_ | bytes | The address of the contract in the target chain to receive the transmission |
dAppId_ | bytes32 | ID for the dApp that the message belongs to |
payload_ | bytes | The dApp-specific message data |
extraOptionalArgs_ | bytes | Extra optional arguments to be passed to the provider. This allow for specific provider configurations. Send bytes('') if not needed |
Return Values
Name | Type | Description |
---|---|---|
[0] | uint256 | The provider fee amount in wei. |
_addressToBytes
function _addressToBytes(address addr) internal pure returns (bytes)
@param addr value of type address @return addr value converted to type bytes
UtilityFacet
state
function state(bytes data_) external
Calls the state functions of other diamond facets
This state method is never attached on the diamond. This method is to be delegatecall-ed from diamondCutGovernableFacet.diamondCut and takes as parameter the encoded call data for the state methods of any other diamond facets.
chainId
function chainId() external view returns (uint8)
Return Values
Name | Type | Description |
---|---|---|
[0] | uint8 | Our chainId for the network |
providerSelector
function providerSelector() external view returns (address)
Returns the address of the provider selector.
getTeleportSender
function getTeleportSender(uint8 _chainId) external view returns (bytes)
Returns the teleport sender address for a given chainId.
Parameters
Name | Type | Description |
---|---|---|
_chainId | uint8 | The chainId of the teleport sender. |
Return Values
Name | Type | Description |
---|---|---|
[0] | bytes | The teleport sender address. |
setProviderSelector
function setProviderSelector(address providerSelector_, bytes[] signatures_) external
Sets the provider selector.
Parameters
Name | Type | Description |
---|---|---|
providerSelector_ | address | The address of the provider selector contract. |
signatures_ | bytes[] | The array of governance members signatures that allow the change. |
computeSetProviderSelectorMessage
function computeSetProviderSelectorMessage(address providerSelector_) internal view returns (bytes32)
Computes the bytes32 ethereum signed message hash of the member update message
setTeleportSenders
function setTeleportSenders(struct IUtility.TeleportSender[] senders_, bytes[] signatures_) external
@notice Set the allowed state for the specified teleport senders @param senders_ Array of chainId and sender @param signatures_ The array of signatures from the members, authorising the operation
computeSetTeleportSenders
function computeSetTeleportSenders(struct IUtility.TeleportSender[] senders_) internal view returns (bytes32)
@param senders_ Array of chainId and sender @return Hash message represeting the setTeleportSenders operation
Test1Facet
state
function state(bytes _input) external pure
f1
function f1() external pure returns (string)
f2
function f2() external pure returns (string)
f3
function f3() external pure returns (string)
Test2Facet
TestEvent
event TestEvent(uint256)
teleportFee
function teleportFee() external returns (uint256)
f2
function f2() external pure returns (string)
Test3Facet
f3
function f3() external pure returns (string)
f1337
function f1337() external pure returns (string)
IDiamondCut
FacetCutAction
enum FacetCutAction {
Add,
Replace,
Remove
}
FacetCut
struct FacetCut {
address facetAddress;
enum IDiamondCut.FacetCutAction action;
bytes4[] functionSelectors;
}
DiamondCut
event DiamondCut(struct IDiamondCut.FacetCut[] _diamondCut, address _init, bytes _calldata)
IDiamondCutGovernable
diamondCut
function diamondCut(struct IDiamondCut.FacetCut[] _diamondCut, address _init, bytes _calldata, bytes[] _signatures) external
Add/replace/remove any number of functions and optionally execute a function with delegatecall
Parameters
Name | Type | Description |
---|---|---|
_diamondCut | struct IDiamondCut.FacetCut[] | Contains the facet addresses and function selectors |
_init | address | The address of the contract or facet to execute _calldata |
_calldata | bytes | A function call, including function selector and arguments _calldata is executed with delegatecall on _init |
_signatures | bytes[] | Governance members' signatures authorizing the operation |
IDiamondCutSimple
diamondCut
function diamondCut(struct IDiamondCut.FacetCut[] _diamondCut, address _init, bytes _calldata) external
Add/replace/remove any number of functions and optionally execute a function with delegatecall
Parameters
Name | Type | Description |
---|---|---|
_diamondCut | struct IDiamondCut.FacetCut[] | Contains the facet addresses and function selectors |
_init | address | The address of the contract or facet to execute _calldata |
_calldata | bytes | A function call, including function selector and arguments _calldata is executed with delegatecall on _init |
ICommonErrors
NoDirectCall
error NoDirectCall()
TransferFailed
error TransferFailed(string message)
AccountIsAddressZero
error AccountIsAddressZero()
NoValueAllowed
error NoValueAllowed()
IDiamondLoupeFacetErrors
ExceededMaxFacets
error ExceededMaxFacets()
ILibDiamondErrors
FunctionDoesNotExist
error FunctionDoesNotExist()
NoSelectorsInFacetToCut
error NoSelectorsInFacetToCut()
FunctionAlreadyExists
error FunctionAlreadyExists()
CantReplaceImmutableFn
error CantReplaceImmutableFn()
CantReplaceWithSameFn
error CantReplaceWithSameFn()
CantReplaceNonexistentFn
error CantReplaceNonexistentFn()
RemoveFacetAddressMustBeZero
error RemoveFacetAddressMustBeZero()
CantRemoveNonexistentFn
error CantRemoveNonexistentFn()
CantRemoveImmutableFn
error CantRemoveImmutableFn()
IncorrectFacetCutAction
error IncorrectFacetCutAction()
InitIsAddress0AndCalldataNotEmpty
error InitIsAddress0AndCalldataNotEmpty()
CalldataIsEmpty
error CalldataIsEmpty()
InitFunctionReverted
error InitFunctionReverted()
ContractHasNoCode
error ContractHasNoCode(string checkCase)
LibDiamond__InitIsNotFacet
error LibDiamond__InitIsNotFacet()
ITeleportFacetErrors
OnlyValidProviderCalls
error OnlyValidProviderCalls()
Used to make sure the function is only called by the teleport contract.
TransmissionNotSupportedByAnyProvider
error TransmissionNotSupportedByAnyProvider()
Used when there's not provider that supports the specified transmission.
ProviderCannotBeZeroAddress
error ProviderCannotBeZeroAddress()
Used when the provided provider address is the zero address.
InvalidProvider
error InvalidProvider()
Used when the provided provider address is not supported by the provider selector.
SourceChainNotSupported
error SourceChainNotSupported()
Thrown when a message is received from an unknown source chain.
InvalidTeleportSender
error InvalidTeleportSender()
Thrown when a message is received from an invalid teleport sender.
TargetChainNotSupported
error TargetChainNotSupported()
Thrown when a message is being send to an unknown target chain.
InvalidChainId
error InvalidChainId()
InvalidSenderAddress
error InvalidSenderAddress()
DuplicateChainId
error DuplicateChainId()
IFeeCalculatorFacetErrors
NothingToClaim
error NothingToClaim()
InsufficientFeeAmount
error InsufficientFeeAmount()
IGovernanceFacetErrors
NotAValidMember
error NotAValidMember()
MemberListEmpty
error MemberListEmpty()
AccountAlreadyAdded
error AccountAlreadyAdded()
WouldBecomeMemberless
error WouldBecomeMemberless()
InvalidNumberOfSignatures
error InvalidNumberOfSignatures()
InvalidSigner
error InvalidSigner()
WrongSignersOrder
error WrongSignersOrder()
HashAlreadyUsed
error HashAlreadyUsed()
IDiamondErrors
IDiamondLoupe
Facet
struct Facet {
address facetAddress;
bytes4[] functionSelectors;
}
facets
function facets() external view returns (struct IDiamondLoupe.Facet[] facets_)
Gets all facet addresses and their four byte function selectors.
Return Values
Name | Type | Description |
---|---|---|
facets_ | struct IDiamondLoupe.Facet[] | Facet |
facetFunctionSelectors
function facetFunctionSelectors(address _facet) external view returns (bytes4[] facetFunctionSelectors_)
Gets all the function selectors supported by a specific facet.
Parameters
Name | Type | Description |
---|---|---|
_facet | address | The facet address. |
Return Values
Name | Type | Description |
---|---|---|
facetFunctionSelectors_ | bytes4[] |
facetAddresses
function facetAddresses() external view returns (address[] facetAddresses_)
Get all the facet addresses used by a diamond.
Return Values
Name | Type | Description |
---|---|---|
facetAddresses_ | address[] |
facetAddress
function facetAddress(bytes4 _functionSelector) external view returns (address facetAddress_)
Gets the facet that supports the given selector.
If facet is not found return address(0).
Parameters
Name | Type | Description |
---|---|---|
_functionSelector | bytes4 | The function selector. |
Return Values
Name | Type | Description |
---|---|---|
facetAddress_ | address | The facet address. |
IERC165
supportsInterface
function supportsInterface(bytes4 interfaceId) external view returns (bool)
Query if a contract implements an interface
Interface identification is specified in ERC-165. This function uses less than 30,000 gas.
Parameters
Name | Type | Description |
---|---|---|
interfaceId | bytes4 | The interface identifier, as specified in ERC-165 |
Return Values
Name | Type | Description |
---|---|---|
[0] | bool | true if the contract implements interfaceID and interfaceID is not 0xffffffff, false otherwise |
IFeeCalculator
ServiceFeeSet
event ServiceFeeSet(address account, uint256 newServiceFee)
An event emitted once the service fee is modified
Claim
event Claim(address member, uint256 amount)
An event emitted once a member claims fees accredited to him
setServiceFee
function setServiceFee(uint256 _serviceFee, bytes[] _signatures) external
@notice Sets the service fee for this chain @param _serviceFee The new service fee @param _signatures The array of signatures from the members, authorising the operation
feesAccrued
function feesAccrued() external view returns (uint256)
Return Values
Name | Type | Description |
---|---|---|
[0] | uint256 | The total amount of accrued fees |
previousAccrued
function previousAccrued() external view returns (uint256)
Return Values
Name | Type | Description |
---|---|---|
[0] | uint256 | The feesAccrued counter before the last reward distribution |
accumulator
function accumulator() external view returns (uint256)
Return Values
Name | Type | Description |
---|---|---|
[0] | uint256 | The total fees accumulated per account (claimed + unclaimed) |
claimedRewardsPerAccount
function claimedRewardsPerAccount(address _account) external view returns (uint256)
@param _account The address of a validator @return The total amount of fees claimed by the provided validator address
claim
function claim() external
Sends out the reward accumulated by the caller
IGovernance
MemberUpdated
event MemberUpdated(address member, bool status)
An event emitted once member is updated
updateMember
function updateMember(address _account, bool _status, bytes[] _signatures) external
@notice Adds/removes a member account @param _account The account to be modified @param _status Whether the account will be set as member or not @param _signatures The signatures of the validators authorizing this member update
isMember
function isMember(address _member) external view returns (bool)
Return Values
Name | Type | Description |
---|---|---|
[0] | bool | True/false depending on whether a given address is member or not |
membersCount
function membersCount() external view returns (uint256)
Return Values
Name | Type | Description |
---|---|---|
[0] | uint256 | The count of members in the members set |
memberAt
function memberAt(uint256 _index) external view returns (address)
Return Values
Name | Type | Description |
---|---|---|
[0] | address | The address of a member at a given index |
administrativeNonce
function administrativeNonce() external view returns (uint256)
Return Values
Name | Type | Description |
---|---|---|
[0] | uint256 | The current administrative nonce |
IProvider
OnlyTeleportCalls
error OnlyTeleportCalls()
Used to make sure the function is only called by the teleport contract.
Transmission
event Transmission(bytes transmissionSender, uint8 targetChainId, bytes transmissionReceiver, bytes32 dAppId, bytes payload)
emitted when transmitting a payload
Delivery
event Delivery(bytes32 transmissionId)
emitted when delivering a payload
DappTransmissionInfo
struct DappTransmissionInfo {
bytes dappTransmissionSender;
bytes dappTransmissionReceiver;
bytes32 dAppId;
bytes dappPayload;
}
supportedChains
function supportedChains(uint256 index) external view returns (uint8)
supportedChainsCount
function supportedChainsCount() external view returns (uint256)
fee
function fee(uint8 targetChainId, bytes transmissionTeleportReceiver, struct IProvider.DappTransmissionInfo dappTranmissionInfo, bytes extraOptionalArgs) external view returns (uint256)
Return Values
Name | Type | Description |
---|---|---|
[0] | uint256 | The currently set service fee |
sendMsg
function sendMsg(uint8 targetChainId, bytes transmissionTeleportReceiver, struct IProvider.DappTransmissionInfo dappTranmissionInfo, bytes extraOptionalArgs) external payable
manualClaim
function manualClaim(bytes args) external
config
function config(bytes configData) external
IProviderSelector
OnlyTeleportCalls
error OnlyTeleportCalls()
Used to make sure the function is only called by the teleport contract.
isValidProvider
function isValidProvider(address provider) external returns (bool)
getProvider
function getProvider(uint8 targetChainId_, bytes transmissionReceiver_, bytes32 dAppId_, bytes payload_) external view returns (address)
config
function config(bytes configData) external
IReceiver
Received
event Received(address, uint256)
receive
receive() external payable
ISingletonFactory
deploy
function deploy(bytes initCode_, bytes32 salt_, bytes initializer_) external payable returns (address payable deployedContractAddress)
ITeleport
Interface for the Teleport contract, which allows for cross-chain communication and messages transfer using different providers.
TransmissionFees
event TransmissionFees(uint256 serviceFee)
Emitted when collecting fees
Parameters
Name | Type | Description |
---|---|---|
serviceFee | uint256 | The amount of service fee collected |
transmit
function transmit(uint8 targetChainId, bytes transmissionReceiver, bytes32 dAppId, bytes payload) external payable
Transmits a message to the specified target chain ID. The message will be delivered using the most suitable provider.
Parameters
Name | Type | Description |
---|---|---|
targetChainId | uint8 | The ID of the target chain |
transmissionReceiver | bytes | The address of the receiver on the target chain |
dAppId | bytes32 | The ID of the dApp on the target chain |
payload | bytes | The message payload |
transmitWithArgs
function transmitWithArgs(uint8 targetChainId_, bytes transmissionReceiver_, bytes32 dAppId_, bytes payload_, bytes extraOptionalArgs_) external payable
Selects a provider to bridge the message to the target chain
Parameters
Name | Type | Description |
---|---|---|
targetChainId_ | uint8 | The chainID where the message should be delivered to |
transmissionReceiver_ | bytes | The address of the contract in the target chain to receive the transmission |
dAppId_ | bytes32 | ID for the dApp that the message belongs to |
payload_ | bytes | The dApp-specific message data |
extraOptionalArgs_ | bytes | Extra optional arguments to be passed to the provider. This allow for specific provider configurations. Send bytes('') if not needed |
transmitWithProvider
function transmitWithProvider(uint8 targetChainId, bytes transmissionReceiver, bytes32 dAppId, bytes payload, address providerAddress, bytes extraOptionalArgs_) external payable
Transmits a message to the specified target chain ID. The message will be delivered using the specified provider.
Parameters
Name | Type | Description |
---|---|---|
targetChainId | uint8 | The ID of the target chain |
transmissionReceiver | bytes | The address of the receiver on the target chain |
dAppId | bytes32 | The ID of the dApp on the target chain |
payload | bytes | The message payload |
providerAddress | address | The address of the provider to use |
extraOptionalArgs_ | bytes |
deliver
function deliver(address providerAddress, bytes args) external
Delivers a message to this chain.
Parameters
Name | Type | Description |
---|---|---|
providerAddress | address | |
args | bytes | The message arguments, which depend on the provider. See the provider's documentation for more information. |
teleportFee
function teleportFee() external view returns (uint256)
Returns the currently set teleport fee.
Return Values
Name | Type | Description |
---|---|---|
[0] | uint256 | The teleport fee amount |
providerFee
function providerFee(uint8 targetChainId_, bytes transmissionReceiver_, bytes32 dAppId_, bytes payload_, bytes extraOptionalArgs_) external view returns (uint256)
Returns the fee for the automatic selected provider.
Return Values
Name | Type | Description |
---|---|---|
[0] | uint256 | The provider fee amount |
providerFee
function providerFee(address providerAddress_, uint8 targetChainId_, bytes transmissionReceiver_, bytes32 dAppId_, bytes payload_, bytes extraOptionalArgs_) external view returns (uint256)
Returns the fee for the stated provider.
Return Values
Name | Type | Description |
---|---|---|
[0] | uint256 | The provider fee amount |
serviceFee
function serviceFee(uint8 targetChainId_, bytes transmissionReceiver_, bytes32 dAppId_, bytes payload_, bytes extraOptionalArgs_) external view returns (uint256)
Returns the currently set service fee.
Return Values
Name | Type | Description |
---|---|---|
[0] | uint256 | The service fee amount |
serviceFee
function serviceFee(address providerAddress_, uint8 targetChainId_, bytes transmissionReceiver_, bytes32 dAppId_, bytes payload_, bytes extraOptionalArgs_) external view returns (uint256)
Returns the currently set service fee.
Return Values
Name | Type | Description |
---|---|---|
[0] | uint256 | The service fee amount |
DappTransmissionReceive
struct DappTransmissionReceive {
bytes teleportSender;
uint8 sourceChainId;
bytes dappTransmissionSender;
address dappTransmissionReceiver;
bytes32 dAppId;
bytes payload;
}
onProviderReceive
function onProviderReceive(struct ITeleport.DappTransmissionReceive args) external
Notifies the teleport that the provider has received a new message. Teleport should invoke the related dapps.
Parameters
Name | Type | Description |
---|---|---|
args | struct ITeleport.DappTransmissionReceive | The arguments of the message. |
configProviderSelector
function configProviderSelector(bytes configData, bytes[] signatures_) external
configProvider
function configProvider(bytes configData, address providerAddress, bytes[] signatures_) external
ITeleportDApp
onTeleportMessage
function onTeleportMessage(uint8 _sourceChainId, bytes _transmissionSender, bytes32 _dAppId, bytes _payload) external
Called by a Teleport contract to deliver a verified payload to a dApp
Parameters
Name | Type | Description |
---|---|---|
_sourceChainId | uint8 | The chainID where the transmission originated |
_transmissionSender | bytes | The address that invoked transmit() on the source chain |
_dAppId | bytes32 | an identifier for the dApp |
_payload | bytes | a dApp-specific byte array with the message data |
ITeleportDiamond
IUtility
TeleportSenderSet
event TeleportSenderSet(struct IUtility.TeleportSender[] senders_)
ProviderSelectorSet
event ProviderSelectorSet(address providerSelector_)
Subroutine
struct Subroutine {
address contractAddress;
bytes callParams;
}
TeleportSender
struct TeleportSender {
uint8 chainId;
bytes senderAddress;
}
chainId
function chainId() external view returns (uint8)
Return Values
Name | Type | Description |
---|---|---|
[0] | uint8 | The internal Teleport chain Id |
providerSelector
function providerSelector() external view returns (address)
Returns the address of the provider selector.
getTeleportSender
function getTeleportSender(uint8 _chainId) external view returns (bytes)
Returns the teleport sender address for a given chainId.
Parameters
Name | Type | Description |
---|---|---|
_chainId | uint8 | The chainId of the teleport sender. |
Return Values
Name | Type | Description |
---|---|---|
[0] | bytes | The teleport sender address. |
setTeleportSenders
function setTeleportSenders(struct IUtility.TeleportSender[] senders_, bytes[] signatures_) external
Sets the teleport senders that are allowed to send messaged from another chains.
Parameters
Name | Type | Description |
---|---|---|
senders_ | struct IUtility.TeleportSender[] | An array of TeleportSender structs representing the teleport senders. |
signatures_ | bytes[] | An array of bytes representing the governance signatures that allow this change. |
setProviderSelector
function setProviderSelector(address providerSelector_, bytes[] signatures_) external
Sets the provider selector.
Parameters
Name | Type | Description |
---|---|---|
providerSelector_ | address | The address of the provider selector contract. |
signatures_ | bytes[] | The array of governance members signatures that allow the change. |
ExcessivelySafeCall
LOW_28_MASK
uint256 LOW_28_MASK
excessivelySafeCall
function excessivelySafeCall(address _target, uint256 _gas, uint256 _value, uint16 _maxCopy, bytes _calldata) internal returns (bool, bytes)
Use when you really really really don't trust the called contract. This prevents the called contract from causing reversion of the caller in as many ways as we can.
The main difference between this and a solidity low-level call is that we limit the number of bytes that the callee can cause to be copied to caller memory. This prevents stupid things like malicious contracts returning 10,000,000 bytes causing a local OOG when copying to memory.
Parameters
Name | Type | Description |
---|---|---|
_target | address | The address to call |
_gas | uint256 | The amount of gas to forward to the remote contract |
_value | uint256 | The value in wei to send to the remote contract |
_maxCopy | uint16 | The maximum number of bytes of returndata to copy to memory. |
_calldata | bytes | The data to send to the remote contract |
Return Values
Name | Type | Description |
---|---|---|
[0] | bool | success and returndata, as .call() . Returndata is capped to _maxCopy bytes. |
[1] | bytes |
excessivelySafeStaticCall
function excessivelySafeStaticCall(address _target, uint256 _gas, uint16 _maxCopy, bytes _calldata) internal view returns (bool, bytes)
Use when you really really really don't trust the called contract. This prevents the called contract from causing reversion of the caller in as many ways as we can.
The main difference between this and a solidity low-level call is that we limit the number of bytes that the callee can cause to be copied to caller memory. This prevents stupid things like malicious contracts returning 10,000,000 bytes causing a local OOG when copying to memory.
Parameters
Name | Type | Description |
---|---|---|
_target | address | The address to call |
_gas | uint256 | The amount of gas to forward to the remote contract |
_maxCopy | uint16 | The maximum number of bytes of returndata to copy to memory. |
_calldata | bytes | The data to send to the remote contract |
Return Values
Name | Type | Description |
---|---|---|
[0] | bool | success and returndata, as .call() . Returndata is capped to _maxCopy bytes. |
[1] | bytes |
swapSelector
function swapSelector(bytes4 _newSelector, bytes _buf) internal pure
Swaps function selectors in encoded contract calls
Allows reuse of encoded calldata for functions with identical argument types but different names. It simply swaps out the first 4 bytes for the new selector. This function modifies memory in place, and should only be used with caution.
Parameters
Name | Type | Description |
---|---|---|
_newSelector | bytes4 | The new 4-byte selector |
_buf | bytes | The encoded contract args |
LibDiamond
DIAMOND_STORAGE_POSITION
bytes32 DIAMOND_STORAGE_POSITION
DiamondStorage
struct DiamondStorage {
mapping(bytes4 => bytes32) facets;
mapping(uint256 => bytes32) selectorSlots;
uint16 selectorCount;
mapping(address => bool) validFacets;
}
diamondStorage
function diamondStorage() internal pure returns (struct LibDiamond.DiamondStorage ds)
DiamondCut
event DiamondCut(struct IDiamondCut.FacetCut[] _diamondCut, address _init, bytes _calldata)
diamondCut
function diamondCut(struct IDiamondCut.FacetCut[] _diamondCut, address _init, bytes _calldata) internal
addFacetSelector
function addFacetSelector(uint256 _selectorCount, bytes32 _selectorSlot, address _newFacetAddress, bytes4[] _selectors, struct LibDiamond.DiamondStorage ds) internal returns (uint256, bytes32)
replaceFacetSelector
function replaceFacetSelector(address _newFacetAddress, bytes4[] _selectors, struct LibDiamond.DiamondStorage ds) internal
removeFacetSelector
function removeFacetSelector(uint256 _selectorCount, bytes32 _selectorSlot, address _newFacetAddress, bytes4[] _selectors, struct LibDiamond.DiamondStorage ds) internal returns (uint256, bytes32)
addReplaceRemoveFacetSelectors
function addReplaceRemoveFacetSelectors(uint256 _selectorCount, bytes32 _selectorSlot, address _newFacetAddress, enum IDiamondCut.FacetCutAction _action, bytes4[] _selectors) internal returns (uint256, bytes32)
initializeDiamondCut
function initializeDiamondCut(struct LibDiamond.DiamondStorage ds, address _init, bytes _calldata) internal
enforceHasContractCode
function enforceHasContractCode(address _contract, string checkCase) internal view
LibFeeCalculator
Storage
struct Storage {
uint256 serviceFee;
uint256 feesAccrued;
uint256 previousAccrued;
uint256 accumulator;
mapping(address => uint256) claimedRewardsPerAccount;
}
feeCalculatorStorage
function feeCalculatorStorage() internal pure returns (struct LibFeeCalculator.Storage ds)
addNewMember
function addNewMember(address account_) internal
addNewMember Sets the initial claimed rewards for new members
Parameters
Name | Type | Description |
---|---|---|
account_ | address | The address of the new member |
claimReward
function claimReward(address claimer_) internal returns (uint256)
claimReward Make calculations based on fee distribution and returns the claimable amount
Parameters
Name | Type | Description |
---|---|---|
claimer_ | address | The address of the claimer |
accrueReward
function accrueReward(uint256 amount_) internal returns (uint256)
Accrue reward to be later distributed to members
LibGovernance
Storage
struct Storage {
struct Counters.Counter administrativeNonce;
struct EnumerableSet.AddressSet membersSet;
mapping(bytes32 => bool) hashesUsed;
}
governanceStorage
function governanceStorage() internal pure returns (struct LibGovernance.Storage gs)
updateMember
function updateMember(struct LibGovernance.Storage gs, address account_, bool status_) internal
Adds/removes a validator from the member set
isMember
function isMember(struct LibGovernance.Storage gs, address member_) internal view returns (bool)
Returns true/false depending on whether a given address is member or not
membersCount
function membersCount(struct LibGovernance.Storage gs) internal view returns (uint256)
Returns the count of the members
memberAt
function memberAt(struct LibGovernance.Storage gs, uint256 index_) internal view returns (address)
Returns the address of a member at a given index
LibTeleport
Storage
struct Storage {
uint8 chainId;
address providerSelector;
mapping(uint8 => bytes) teleportAddressByChainId;
uint8[] supportedChainIds;
}
teleportStorage
function teleportStorage() internal pure returns (struct LibTeleport.Storage mts)
Returns the Teleport Storage object at the correct slot
updateTeleportSenders
function updateTeleportSenders(struct IUtility.TeleportSender[] senders_) internal
Sets the teleports' addresses on all supported chains
CCIPProvider
TELEPORT_ADDRESS
address TELEPORT_ADDRESS
ccipChainSelectors
mapping(uint8 => uint64) ccipChainSelectors
A mapping that stores the destination chain selectors for the CCIPProvider contract mapped to their corresponding MPCids
ccipReceivers
mapping(uint8 => address) ccipReceivers
A mapping that stores the destination chain CCIPProvider contract that would receive the transmission
mpcIds
mapping(uint64 => uint8) mpcIds
Mapping of source messaging protocol chain IDs to their corresponding values destination chain CCIP selectors
ValueNotEqualToFee
error ValueNotEqualToFee(uint256 valueSent, uint256 calculatedFees)
Used to make sure the correct amount has been sent.
Parameters
Name | Type | Description |
---|---|---|
valueSent | uint256 | The amount sent by the sender. |
calculatedFees | uint256 | The amount calculated by the router. |
OnlyEVMSupport
error OnlyEVMSupport(bytes transmissionReceiver)
Used to make sure the transmissionReceiver is a valid EVM address
Parameters
Name | Type | Description |
---|---|---|
transmissionReceiver | bytes | The receiver of the transmission teleport. |
ZeroAddressRouter
error ZeroAddressRouter()
Used to make sure the router address is not the zero address.
ZeroAddressTeleport
error ZeroAddressTeleport()
Used to make sure the teleport address is not the zero address.
ArraysLenMismatch
error ArraysLenMismatch()
Used to make sure the chain MPCId and chain selector arrays have the same length.
DstChainUnsupported
error DstChainUnsupported()
Used to make sure the destination chain is supported.
SrcChainUnsupported
error SrcChainUnsupported()
Used to make sure the source chain is supported.
UnrecognizedCCIPSender
error UnrecognizedCCIPSender()
Used to indicate that the sender address from the source chain is not recognized.
UnrecognizedTeleportReceiver
error UnrecognizedTeleportReceiver()
Used to indicate that the teleport receiver address send is not recognized.
ManualClaimOffchain
error ManualClaimOffchain()
Used to indicate that the manual claim should be perform offchain, by using the sdk.
InvalidRouter
error InvalidRouter(address router)
Emitted when the router address is updated.
Parameters
Name | Type | Description |
---|---|---|
router | address | The new router address. |
DuplicateChainSelectorOrMPCId
error DuplicateChainSelectorOrMPCId()
ReceiverCannotBeZeroAddress
error ReceiverCannotBeZeroAddress()
onlyRouter
modifier onlyRouter()
only calls from the set router are accepted.
constructor
constructor(address _router, address _teleport, uint8[] _mpcIds, uint64[] _ccipChainSelectors, address[] _ccipReceivers) public
Constructor function for CCIPProvider contract.
Parameters
Name | Type | Description |
---|---|---|
_router | address | Address of the router contract. |
_teleport | address | Address of the teleport contract. |
_mpcIds | uint8[] | Array of MP chain IDs. |
_ccipChainSelectors | uint64[] | Array of CCIP chain selectors. |
_ccipReceivers | address[] |
onlyTeleport
modifier onlyTeleport()
Modifier to restrict access to functions only to the Teleport facet.
sendMsg
function sendMsg(uint8 targetChainId, bytes transmissionTeleportReceiver, struct IProvider.DappTransmissionInfo dappTranmissionInfo, bytes extraOptionalArgs_) external payable
Transmits the payload
to the validators by emitting the Transmission
event
Parameters
Name | Type | Description |
---|---|---|
targetChainId | uint8 | The chainID where the message should be delivered to |
transmissionTeleportReceiver | bytes | The address of the contract in the target chain to receive the transmission |
dappTranmissionInfo | struct IProvider.DappTransmissionInfo | The Id and data for the dApp that the message belongs to |
extraOptionalArgs_ | bytes |
getChainSelector
function getChainSelector(uint8 chainId) public view returns (uint64)
Returns the chain selector for a given chain ID.
Parameters
Name | Type | Description |
---|---|---|
chainId | uint8 | The ID of the chain to get the selector for. |
Return Values
Name | Type | Description |
---|---|---|
[0] | uint64 | The chain selector as a uint64. |
getCCIPReceiver
function getCCIPReceiver(uint8 chainId) public view returns (address)
Returns the chain selector for a given chain ID.
Parameters
Name | Type | Description |
---|---|---|
chainId | uint8 | The ID of the chain to get the selector for. |
Return Values
Name | Type | Description |
---|---|---|
[0] | address | The chain selector as a uint64. |
getChainId
function getChainId(uint64 chainSelector) public view returns (uint8)
Returns the chain ID for a given chain selector.
Parameters
Name | Type | Description |
---|---|---|
chainSelector | uint64 | The chain selector to get the chain ID for. |
Return Values
Name | Type | Description |
---|---|---|
[0] | uint8 | The chain ID as a uint8. |
manualClaim
function manualClaim(bytes) external view
getRouter
function getRouter() public view returns (address)
Return the current router
Return Values
Name | Type | Description |
---|---|---|
[0] | address | i_router address |
getGasLimit
function getGasLimit() public view returns (uint256)
Return the current gas limit
Return Values
Name | Type | Description |
---|---|---|
[0] | uint256 | _gasLimit gas limit |
fee
function fee(uint8 targetChainId, bytes transmissionTeleportReceiver, struct IProvider.DappTransmissionInfo dappTranmissionInfo, bytes extraOptionalArgs) external view returns (uint256)
Returns the fee required for transmitting a message from the source chain to the target chain.
Parameters
Name | Type | Description |
---|---|---|
targetChainId | uint8 | The MPC ID of the target chain. |
transmissionTeleportReceiver | bytes | The address of the receiver on the target chain. |
dappTranmissionInfo | struct IProvider.DappTransmissionInfo | The transmission information. |
extraOptionalArgs | bytes |
Return Values
Name | Type | Description |
---|---|---|
[0] | uint256 | The fee required for the transmission. |
config
function config(bytes configData) external
Only callable by the Teleport contract.
The params.mpcIds
and params.ccipChainSelectors
arrays must have the same length.
For each MPCId
in params.mpcIds
, sets the corresponding ccipChainSelector
in the ccipChainSelectors
mapping.
For each ccipChainSelector
in params.ccipChainSelectors
, sets the corresponding MPCId
in the mpcIds
mapping.
If params.routerAddress
is not the zero address, sets the i_router
address to params.routerAddress
.
Configures the CCIPProvider contract with the provided configuration data.
Parameters
Name | Type | Description |
---|---|---|
configData | bytes | The configuration data to be decoded and used to set the CCIPProvider parameters. |
ccipReceive
function ccipReceive(struct Client.Any2EVMMessage message) external
Internal function to handle receiving messages from the CCIP protocol.
Parameters
Name | Type | Description |
---|---|---|
message | struct Client.Any2EVMMessage | The message received from the CCIP protocol. |
_encodeTeleportMessage
function _encodeTeleportMessage(struct IProvider.DappTransmissionInfo info, address senderTeleportAddress, bytes receiverTeleportAddress) internal pure returns (bytes)
Encodes a teleport message for the CCIP protocol.
Parameters
Name | Type | Description |
---|---|---|
info | struct IProvider.DappTransmissionInfo | The transmission information for the message. |
senderTeleportAddress | address | |
receiverTeleportAddress | bytes |
Return Values
Name | Type | Description |
---|---|---|
[0] | bytes | The encoded message as bytes. |
MessageData
struct MessageData {
struct IProvider.DappTransmissionInfo info;
bytes senderTeleportAddress;
bytes receiverTeleportAddress;
}
_decodeTeleportMessage
function _decodeTeleportMessage(bytes _payload) internal pure returns (struct CCIPProvider.MessageData)
Decodes a teleport message payload into a DappTransmissionInfo struct.
Parameters
Name | Type | Description |
---|---|---|
_payload | bytes | The payload of the teleport message. |
Return Values
Name | Type | Description |
---|---|---|
[0] | struct CCIPProvider.MessageData | A DappTransmissionInfo struct containing the decoded information. |
_buildCCIPMessage
function _buildCCIPMessage(address _receiver, bytes _payload, address _feeTokenAddress, bytes extraOptionalArgs_) internal view returns (struct Client.EVM2AnyMessage)
Construct a CCIP message.
This function will create an EVM2AnyMessage struct with all the necessary information for sending a text.
Parameters
Name | Type | Description |
---|---|---|
_receiver | address | The address of the receiver. |
_payload | bytes | The data to be sent. |
_feeTokenAddress | address | The address of the token used for fees. Set address(0) for native gas. |
extraOptionalArgs_ | bytes |
Return Values
Name | Type | Description |
---|---|---|
[0] | struct Client.EVM2AnyMessage | Client.EVM2AnyMessage Returns an EVM2AnyMessage struct which contains information for sending a CCIP message. |
_decodeConfigMessage
function _decodeConfigMessage(bytes _data) internal pure returns (struct CCIPProvider.ConfigCallParamsV1)
Internal function to decode a configuration message received from the teleport.
Parameters
Name | Type | Description |
---|---|---|
_data | bytes | The config data received from the CCIP. |
Return Values
Name | Type | Description |
---|---|---|
[0] | struct CCIPProvider.ConfigCallParamsV1 | The decoded configuration params. |
ConfigCallParamsV1
struct ConfigCallParamsV1 {
uint8[] mpcIds;
uint64[] ccipChainSelectors;
address[] ccipReceivers;
address routerAddress;
uint256 gasLimit;
}
supportsInterface
function supportsInterface(bytes4 interfaceId) public pure returns (bool)
IERC165 supports an interfaceId
Parameters
Name | Type | Description |
---|---|---|
interfaceId | bytes4 | The interfaceId to check |
Return Values
Name | Type | Description |
---|---|---|
[0] | bool | true if the interfaceId is supported |
supportedChains
function supportedChains(uint256 index) external view returns (uint8)
Allows knowing all chains that are supported from offchain
supportedChainsCount
function supportedChainsCount() external view returns (uint256)
Amount of supported chains
CCIPRouterMock
chainSupported
bool chainSupported
supportedTokens
address[] supportedTokens
fee
uint256 fee
messageId
bytes32 messageId
isChainSupported
function isChainSupported(uint64) external view returns (bool)
getSupportedTokens
function getSupportedTokens(uint64) external view returns (address[])
getFee
function getFee(uint64, struct Client.EVM2AnyMessage) external view returns (uint256)
ccipSend
function ccipSend(uint64, struct Client.EVM2AnyMessage) external payable returns (bytes32)
setFee
function setFee(uint256 _fee) external
setSupportedTokens
function setSupportedTokens(address[] _supportedTokens) external
setChainSupported
function setChainSupported(bool _supported) external
setMessageId
function setMessageId(bytes32 _messageId) external
ReceiveRejector
MoneyRejector
error MoneyRejector()
receive
receive() external payable
TestDApp
TELEPORT
address TELEPORT
ReceivedMessage
struct ReceivedMessage {
uint8 sourceChainId;
bytes transmissionSender;
bytes32 dAppId;
bytes payload;
}
lastReceivedFromChain
mapping(uint8 => struct TestDApp.ReceivedMessage) lastReceivedFromChain
constructor
constructor(address teleport_) public
doTransmit
function doTransmit(uint8 targetChainId, bytes transmissionReceiver, bytes32 dAppId, bytes payload) external payable
doTransmitWithArgs
function doTransmitWithArgs(uint8 targetChainId, bytes transmissionReceiver, bytes32 dAppId, bytes payload, bytes extraOptionalArgs) external payable
onTeleportMessage
function onTeleportMessage(uint8 _sourceChainId, bytes _transmissionSender, bytes32 _dAppId, bytes _payload) external
Called by a Teleport contract to deliver a verified payload to a dApp
Parameters
Name | Type | Description |
---|---|---|
_sourceChainId | uint8 | The chainID where the transmission originated |
_transmissionSender | bytes | The address that invoked transmit() on the source chain |
_dAppId | bytes32 | an identifier for the dApp |
_payload | bytes | a dApp-specific byte array with the message data |
transferFundsToTeleport
function transferFundsToTeleport(uint256 amount) external payable