From 315c5e66b384a2f66816dfa387812d05ed2cdde0 Mon Sep 17 00:00:00 2001 From: dave | d1onys1us <13951458+d1onys1us@users.noreply.github.com> Date: Tue, 7 Feb 2023 03:48:01 -0500 Subject: [PATCH] chore(repo): update smart contract markdown docs (#13102) --- packages/protocol/docs/L1/TaikoL1.md | 218 ------------------ packages/protocol/docs/L1/TkoToken.md | 75 ------ packages/protocol/docs/L2/TaikoL2.md | 115 --------- packages/protocol/docs/bridge/Bridge.md | 132 ----------- packages/protocol/docs/bridge/BridgedERC20.md | 79 ------- packages/protocol/docs/bridge/EtherVault.md | 82 ------- packages/protocol/docs/bridge/IBridge.md | 111 --------- packages/protocol/docs/bridge/TokenVault.md | 154 ------------- .../protocol/docs/common/AddressResolver.md | 99 -------- .../protocol/docs/common/IAddressManager.md | 41 ---- packages/protocol/docs/common/IHeaderSync.md | 21 -- .../protocol/docs/common/IMintableERC20.md | 13 -- packages/protocol/hardhat.config.ts | 2 +- packages/protocol/package.json | 2 +- .../L1/ProofVerifier.md | 10 +- .../contract-documentation/L1/TaikoData.md | 2 + .../contract-documentation/L1/TaikoL1.md | 12 +- .../contract-documentation/L2/TaikoL2.md | 16 +- .../contract-documentation/_meta.json | 9 +- .../contract-documentation/bridge/Bridge.md | 45 ++-- .../bridge/EtherVault.md | 29 ++- .../contract-documentation/bridge/IBridge.md | 49 ++-- .../bridge/TokenVault.md | 43 +++- .../common/AddressResolver.md | 26 +-- .../signal/ISignalService.md | 57 +++++ .../signal/SignalService.md | 80 +++++++ 26 files changed, 289 insertions(+), 1233 deletions(-) delete mode 100644 packages/protocol/docs/L1/TaikoL1.md delete mode 100644 packages/protocol/docs/L1/TkoToken.md delete mode 100644 packages/protocol/docs/L2/TaikoL2.md delete mode 100644 packages/protocol/docs/bridge/Bridge.md delete mode 100644 packages/protocol/docs/bridge/BridgedERC20.md delete mode 100644 packages/protocol/docs/bridge/EtherVault.md delete mode 100644 packages/protocol/docs/bridge/IBridge.md delete mode 100644 packages/protocol/docs/bridge/TokenVault.md delete mode 100644 packages/protocol/docs/common/AddressResolver.md delete mode 100644 packages/protocol/docs/common/IAddressManager.md delete mode 100644 packages/protocol/docs/common/IHeaderSync.md delete mode 100644 packages/protocol/docs/common/IMintableERC20.md create mode 100644 packages/website/pages/docs/reference/contract-documentation/signal/ISignalService.md create mode 100644 packages/website/pages/docs/reference/contract-documentation/signal/SignalService.md diff --git a/packages/protocol/docs/L1/TaikoL1.md b/packages/protocol/docs/L1/TaikoL1.md deleted file mode 100644 index bbf47978112..00000000000 --- a/packages/protocol/docs/L1/TaikoL1.md +++ /dev/null @@ -1,218 +0,0 @@ -## TaikoL1 - -### state - -```solidity -struct TaikoData.State state -``` - -### tentative - -```solidity -struct TaikoData.TentativeState tentative -``` - -### \_\_gap - -```solidity -uint256[50] __gap -``` - -### init - -```solidity -function init(address _addressManager, bytes32 _genesisBlockHash) external -``` - -### commitBlock - -```solidity -function commitBlock(uint64 commitSlot, bytes32 commitHash) external -``` - -Write a _commit hash_ so a few blocks later a L2 block can be proposed -such that `calculateCommitHash(meta.beneficiary, meta.txListHash)` equals -to this commit hash. - -#### Parameters - -| Name | Type | Description | -| ---------- | ------- | --------------------------------------------------------------------------- | -| commitSlot | uint64 | A slot to save this commit. Slot 0 will always be reset to zero for refund. | -| commitHash | bytes32 | Calculated with: `calculateCommitHash(beneficiary, txListHash)`. | - -### proposeBlock - -```solidity -function proposeBlock(bytes[] inputs) external -``` - -Propose a Taiko L2 block. - -#### Parameters - -| Name | Type | Description | -| ------ | ------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -| inputs | bytes[] | A list of data input: - inputs[0] is abi-encoded BlockMetadata that the actual L2 block header must satisfy. Note the following fields in the provided meta object must be zeros -- their actual values will be provisioned by Ethereum. - id - l1Height - l1Hash - mixHash - timestamp - inputs[1] is a list of transactions in this block, encoded with RLP. Note, in the corresponding L2 block an _anchor transaction_ will be the first transaction in the block -- if there are n transactions in `txList`, then there will be up to n+1 transactions in the L2 block. | - -### proveBlock - -```solidity -function proveBlock(uint256 blockId, bytes[] inputs) external -``` - -Prove a block is valid with a zero-knowledge proof, a transaction -merkel proof, and a receipt merkel proof. - -#### Parameters - -| Name | Type | Description | -| ------- | ------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -| blockId | uint256 | The index of the block to prove. This is also used to select the right implementation version. | -| inputs | bytes[] | A list of data input: - inputs[0] is an abi-encoded object with various information regarding the block to be proven and the actual proofs. - inputs[1] is the actual anchor transaction in this L2 block. Note that the anchor transaction is always the first transaction in the block. - inputs[2] is the receipt of the anchor transaction. | - -### proveBlockInvalid - -```solidity -function proveBlockInvalid(uint256 blockId, bytes[] inputs) external -``` - -Prove a block is invalid with a zero-knowledge proof and a receipt -merkel proof. - -#### Parameters - -| Name | Type | Description | -| ------- | ------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -| blockId | uint256 | The index of the block to prove. This is also used to select the right implementation version. | -| inputs | bytes[] | A list of data input: - inputs[0] An Evidence object with various information regarding the block to be proven and the actual proofs. - inputs[1] The target block to be proven invalid. - inputs[2] The receipt for the `invalidBlock` transaction on L2. Note that the `invalidBlock` transaction is supposed to be the only transaction in the L2 block. | - -### verifyBlocks - -```solidity -function verifyBlocks(uint256 maxBlocks) external -``` - -Verify up to N blocks. - -#### Parameters - -| Name | Type | Description | -| --------- | ------- | ------------------------------- | -| maxBlocks | uint256 | Max number of blocks to verify. | - -### halt - -```solidity -function halt(bool toHalt) public -``` - -Halt or resume the chain. - -#### Parameters - -| Name | Type | Description | -| ------ | ---- | ------------------------------ | -| toHalt | bool | True to halt, false to resume. | - -### isProposerWhitelisted - -```solidity -function isProposerWhitelisted(address proposer) public view returns (bool) -``` - -Check whether a proposer is whitelisted. - -#### Parameters - -| Name | Type | Description | -| -------- | ------- | ------------- | -| proposer | address | The proposer. | - -#### Return Values - -| Name | Type | Description | -| ---- | ---- | ----------------------------------------------------- | -| [0] | bool | True if the proposer is whitelisted, false otherwise. | - -### isProverWhitelisted - -```solidity -function isProverWhitelisted(address prover) public view returns (bool) -``` - -Check whether a prover is whitelisted. - -#### Parameters - -| Name | Type | Description | -| ------ | ------- | ----------- | -| prover | address | The prover. | - -#### Return Values - -| Name | Type | Description | -| ---- | ---- | --------------------------------------------------- | -| [0] | bool | True if the prover is whitelisted, false otherwise. | - -### isHalted - -```solidity -function isHalted() public view returns (bool) -``` - -Check if the L1 is halted. - -#### Return Values - -| Name | Type | Description | -| ---- | ---- | -------------------------------- | -| [0] | bool | True if halted, false otherwise. | - -### isCommitValid - -```solidity -function isCommitValid(uint256 commitSlot, uint256 commitHeight, bytes32 commitHash) public view returns (bool) -``` - -### getProposedBlock - -```solidity -function getProposedBlock(uint256 id) public view returns (struct TaikoData.ProposedBlock) -``` - -### getSyncedHeader - -```solidity -function getSyncedHeader(uint256 number) public view returns (bytes32) -``` - -### getLatestSyncedHeader - -```solidity -function getLatestSyncedHeader() public view returns (bytes32) -``` - -### getStateVariables - -```solidity -function getStateVariables() public view returns (uint64, uint64, uint64, uint64) -``` - -### signWithGoldenTouch - -```solidity -function signWithGoldenTouch(bytes32 hash, uint8 k) public view returns (uint8 v, uint256 r, uint256 s) -``` - -### getBlockProvers - -```solidity -function getBlockProvers(uint256 id, bytes32 parentHash) public view returns (address[]) -``` - -### getConstants - -```solidity -function getConstants() public pure returns (uint256, uint256, uint256, uint256, uint256, uint256, uint256, uint256, uint256, uint256, uint256) -``` diff --git a/packages/protocol/docs/L1/TkoToken.md b/packages/protocol/docs/L1/TkoToken.md deleted file mode 100644 index d71fc1fb008..00000000000 --- a/packages/protocol/docs/L1/TkoToken.md +++ /dev/null @@ -1,75 +0,0 @@ -## TkoToken - -_This is Taiko's governance and fee token._ - -### \_\_gap - -```solidity -uint256[50] __gap -``` - -### Mint - -```solidity -event Mint(address account, uint256 amount) -``` - -### Burn - -```solidity -event Burn(address account, uint256 amount) -``` - -### init - -```solidity -function init(address _addressManager) external -``` - -_Initializer to be called after being deployed behind a proxy. -Based on our simulation in simulate/tokenomics/index.js, both -amountMintToDAO and amountMintToDev shall be set to ~150,000,000._ - -### transfer - -```solidity -function transfer(address to, uint256 amount) public returns (bool) -``` - -### transferFrom - -```solidity -function transferFrom(address from, address to, uint256 amount) public returns (bool) -``` - -### mint - -```solidity -function mint(address account, uint256 amount) public -``` - -_Mints tokens to the given address's balance. This will increase -the circulating supply._ - -#### Parameters - -| Name | Type | Description | -| ------- | ------- | ---------------------------------- | -| account | address | The address to receive the tokens. | -| amount | uint256 | The amount of tokens to mint. | - -### burn - -```solidity -function burn(address account, uint256 amount) public -``` - -_Burn tokens from the given address's balance. This will decrease -the circulating supply._ - -#### Parameters - -| Name | Type | Description | -| ------- | ------- | ------------------------------------ | -| account | address | The address to burn the tokens from. | -| amount | uint256 | The amount of tokens to burn. | diff --git a/packages/protocol/docs/L2/TaikoL2.md b/packages/protocol/docs/L2/TaikoL2.md deleted file mode 100644 index bf7ed0351ec..00000000000 --- a/packages/protocol/docs/L2/TaikoL2.md +++ /dev/null @@ -1,115 +0,0 @@ -## TaikoL2 - -### l2Hashes - -```solidity -mapping(uint256 => bytes32) l2Hashes -``` - -### l1Hashes - -```solidity -mapping(uint256 => bytes32) l1Hashes -``` - -### publicInputHash - -```solidity -bytes32 publicInputHash -``` - -### latestSyncedHeader - -```solidity -bytes32 latestSyncedHeader -``` - -### \_\_gap - -```solidity -uint256[46] __gap -``` - -### BlockInvalidated - -```solidity -event BlockInvalidated(bytes32 txListHash) -``` - -### constructor - -```solidity -constructor(address _addressManager) public -``` - -### anchor - -```solidity -function anchor(uint256 l1Height, bytes32 l1Hash) external -``` - -Persist the latest L1 block height and hash to L2 for cross-layer -bridging. This function will also check certain block-level global -variables because they are not part of the Trie structure. - - Note that this transaction shall be the first transaction in every - L2 block. - -#### Parameters - -| Name | Type | Description | -| -------- | ------- | -------------------------------------------------------- | -| l1Height | uint256 | The latest L1 block height when this block was proposed. | -| l1Hash | bytes32 | The latest L1 block hash when this block was proposed. | - -### invalidateBlock - -```solidity -function invalidateBlock(bytes txList, enum LibInvalidTxList.Reason hint, uint256 txIdx) external -``` - -Invalidate a L2 block by verifying its txList is not intrinsically valid. - -#### Parameters - -| Name | Type | Description | -| ------ | ---------------------------- | ------------------------------------------------------------------------------------------------ | -| txList | bytes | The L2 block's txlist. | -| hint | enum LibInvalidTxList.Reason | A hint for this method to invalidate the txList. | -| txIdx | uint256 | If the hint is for a specific transaction in txList, txIdx specifies which transaction to check. | - -### getSyncedHeader - -```solidity -function getSyncedHeader(uint256 number) public view returns (bytes32) -``` - -### getLatestSyncedHeader - -```solidity -function getLatestSyncedHeader() public view returns (bytes32) -``` - -### getBlockHash - -```solidity -function getBlockHash(uint256 number) public view returns (bytes32) -``` - -### getConstants - -```solidity -function getConstants() public pure returns (uint256, uint256, uint256, uint256, uint256, uint256, uint256, uint256, uint256, uint256, uint256) -``` - -### \_checkPublicInputs - -```solidity -function _checkPublicInputs() private -``` - -### \_hashPublicInputs - -```solidity -function _hashPublicInputs(uint256 chainId, uint256 number, uint256 baseFee, bytes32[255] ancestors) private pure returns (bytes32) -``` diff --git a/packages/protocol/docs/bridge/Bridge.md b/packages/protocol/docs/bridge/Bridge.md deleted file mode 100644 index 9efb367bccf..00000000000 --- a/packages/protocol/docs/bridge/Bridge.md +++ /dev/null @@ -1,132 +0,0 @@ -## Bridge - -Bridge contract which is deployed on both L1 and L2. Mostly a thin wrapper -which calls the library implementations. See {IBridge} for more details. - -_The code hash for the same address on L1 and L2 may be different._ - -### state - -```solidity -struct LibBridgeData.State state -``` - -### \_\_gap - -```solidity -uint256[50] __gap -``` - -### MessageStatusChanged - -```solidity -event MessageStatusChanged(bytes32 signal, enum LibBridgeStatus.MessageStatus status) -``` - -### DestChainEnabled - -```solidity -event DestChainEnabled(uint256 chainId, bool enabled) -``` - -### receive - -```solidity -receive() external payable -``` - -Allow Bridge to receive ETH from EtherVault. - -### init - -```solidity -function init(address _addressManager) external -``` - -_Initializer to be called after being deployed behind a proxy._ - -### sendMessage - -```solidity -function sendMessage(struct IBridge.Message message) external payable returns (bytes32 signal) -``` - -Sends a message to the destination chain and takes custody -of Ether required in this contract. All extra Ether will be refunded. - -### sendSignal - -```solidity -function sendSignal(bytes32 signal) external -``` - -Stores a signal on the bridge contract and emits an event for the -relayer to pick up. - -### processMessage - -```solidity -function processMessage(struct IBridge.Message message, bytes proof) external -``` - -### retryMessage - -```solidity -function retryMessage(struct IBridge.Message message, bool isLastAttempt) external -``` - -### isMessageSent - -```solidity -function isMessageSent(bytes32 signal) public view virtual returns (bool) -``` - -Checks if a signal has been stored on the bridge contract by the -current address. - -### isMessageReceived - -```solidity -function isMessageReceived(bytes32 signal, uint256 srcChainId, bytes proof) public view virtual returns (bool) -``` - -Checks if a signal has been received on the destination chain and -sent by the src chain. - -### isSignalSent - -```solidity -function isSignalSent(address sender, bytes32 signal) public view virtual returns (bool) -``` - -Checks if a signal has been stored on the bridge contract by the -specified address. - -### isSignalReceived - -```solidity -function isSignalReceived(bytes32 signal, uint256 srcChainId, address sender, bytes proof) public view virtual returns (bool) -``` - -Check if a signal has been received on the destination chain and sent -by the specified sender. - -### getMessageStatus - -```solidity -function getMessageStatus(bytes32 signal) public view virtual returns (enum LibBridgeStatus.MessageStatus) -``` - -### context - -```solidity -function context() public view returns (struct IBridge.Context) -``` - -Returns the bridge state context. - -### isDestChainEnabled - -```solidity -function isDestChainEnabled(uint256 _chainId) public view returns (bool) -``` diff --git a/packages/protocol/docs/bridge/BridgedERC20.md b/packages/protocol/docs/bridge/BridgedERC20.md deleted file mode 100644 index c5d8c9767d8..00000000000 --- a/packages/protocol/docs/bridge/BridgedERC20.md +++ /dev/null @@ -1,79 +0,0 @@ -## BridgedERC20 - -### srcToken - -```solidity -address srcToken -``` - -### srcChainId - -```solidity -uint256 srcChainId -``` - -### \_\_gap - -```solidity -uint256[48] __gap -``` - -### BridgeMint - -```solidity -event BridgeMint(address account, uint256 amount) -``` - -### BridgeBurn - -```solidity -event BridgeBurn(address account, uint256 amount) -``` - -### init - -```solidity -function init(address _addressManager, address _srcToken, uint256 _srcChainId, uint8 _decimals, string _symbol, string _name) external -``` - -_Initializer to be called after being deployed behind a proxy._ - -### bridgeMintTo - -```solidity -function bridgeMintTo(address account, uint256 amount) public -``` - -_only a TokenVault can call this function_ - -### bridgeBurnFrom - -```solidity -function bridgeBurnFrom(address account, uint256 amount) public -``` - -_only a TokenVault can call this function_ - -### transfer - -```solidity -function transfer(address to, uint256 amount) public returns (bool) -``` - -_any address can call this_ - -### transferFrom - -```solidity -function transferFrom(address from, address to, uint256 amount) public returns (bool) -``` - -_any address can call this_ - -### source - -```solidity -function source() public view returns (address, uint256) -``` - -_returns the srcToken being bridged and the srcChainId_ diff --git a/packages/protocol/docs/bridge/EtherVault.md b/packages/protocol/docs/bridge/EtherVault.md deleted file mode 100644 index 071a289c952..00000000000 --- a/packages/protocol/docs/bridge/EtherVault.md +++ /dev/null @@ -1,82 +0,0 @@ -## EtherVault - -Vault that holds Ether. - -### authorizedAddrs - -```solidity -mapping(address => bool) authorizedAddrs -``` - -### \_\_gap - -```solidity -uint256[49] __gap -``` - -### Authorized - -```solidity -event Authorized(address addr, bool authorized) -``` - -### onlyAuthorized - -```solidity -modifier onlyAuthorized() -``` - -### receive - -```solidity -receive() external payable -``` - -### init - -```solidity -function init(address addressManager) external -``` - -### releaseEther - -```solidity -function releaseEther(uint256 amount) public -``` - -Send Ether from EtherVault to the sender, checking they are authorized. - -#### Parameters - -| Name | Type | Description | -| ------ | ------- | ------------------------ | -| amount | uint256 | Amount of ether to send. | - -### authorize - -```solidity -function authorize(address addr, bool authorized) public -``` - -Set the authorized status of an address, only the owner can call this. - -#### Parameters - -| Name | Type | Description | -| ---------- | ------- | ---------------------------------------- | -| addr | address | Address to set the authorized status of. | -| authorized | bool | Authorized status to set. | - -### isAuthorized - -```solidity -function isAuthorized(address addr) public view returns (bool) -``` - -Get the authorized status of an address. - -#### Parameters - -| Name | Type | Description | -| ---- | ------- | ---------------------------------------- | -| addr | address | Address to get the authorized status of. | diff --git a/packages/protocol/docs/bridge/IBridge.md b/packages/protocol/docs/bridge/IBridge.md deleted file mode 100644 index a1a9788f19b..00000000000 --- a/packages/protocol/docs/bridge/IBridge.md +++ /dev/null @@ -1,111 +0,0 @@ -## IBridge - -Bridge interface. - -_Cross-chain Ether is held by Bridges, not TokenVaults._ - -### Message - -```solidity -struct Message { - uint256 id; - address sender; - uint256 srcChainId; - uint256 destChainId; - address owner; - address to; - address refundAddress; - uint256 depositValue; - uint256 callValue; - uint256 processingFee; - uint256 gasLimit; - bytes data; - string memo; -} - -``` - -### Context - -```solidity -struct Context { - bytes32 signal; - address sender; - uint256 srcChainId; -} - -``` - -### SignalSent - -```solidity -event SignalSent(address sender, bytes32 signal) -``` - -### MessageSent - -```solidity -event MessageSent(bytes32 signal, struct IBridge.Message message) -``` - -### sendMessage - -```solidity -function sendMessage(struct IBridge.Message message) external payable returns (bytes32 signal) -``` - -Sends a message to the destination chain and takes custody -of Ether required in this contract. All extra Ether will be refunded. - -### sendSignal - -```solidity -function sendSignal(bytes32 signal) external -``` - -Stores a signal on the bridge contract and emits an event for the -relayer to pick up. - -### isMessageSent - -```solidity -function isMessageSent(bytes32 signal) external view returns (bool) -``` - -Checks if a signal has been stored on the bridge contract by the -current address. - -### isMessageReceived - -```solidity -function isMessageReceived(bytes32 signal, uint256 srcChainId, bytes proof) external view returns (bool) -``` - -Checks if a signal has been received on the destination chain and -sent by the src chain. - -### isSignalSent - -```solidity -function isSignalSent(address sender, bytes32 signal) external view returns (bool) -``` - -Checks if a signal has been stored on the bridge contract by the -specified address. - -### isSignalReceived - -```solidity -function isSignalReceived(bytes32 signal, uint256 srcChainId, address sender, bytes proof) external view returns (bool) -``` - -Check if a signal has been received on the destination chain and sent -by the specified sender. - -### context - -```solidity -function context() external view returns (struct IBridge.Context context) -``` - -Returns the bridge state context. diff --git a/packages/protocol/docs/bridge/TokenVault.md b/packages/protocol/docs/bridge/TokenVault.md deleted file mode 100644 index 8841d2e771e..00000000000 --- a/packages/protocol/docs/bridge/TokenVault.md +++ /dev/null @@ -1,154 +0,0 @@ -## TokenVault - -This vault holds all ERC20 tokens (but not Ether) that users have deposited. -It also manages the mapping between canonical ERC20 tokens and their bridged -tokens. - -### CanonicalERC20 - -```solidity -struct CanonicalERC20 { - uint256 chainId; - address addr; - uint8 decimals; - string symbol; - string name; -} - -``` - -### isBridgedToken - -```solidity -mapping(address => bool) isBridgedToken -``` - -### bridgedToCanonical - -```solidity -mapping(address => struct TokenVault.CanonicalERC20) bridgedToCanonical -``` - -### canonicalToBridged - -```solidity -mapping(uint256 => mapping(address => address)) canonicalToBridged -``` - -### \_\_gap - -```solidity -uint256[47] __gap -``` - -### BridgedERC20Deployed - -```solidity -event BridgedERC20Deployed(uint256 srcChainId, address canonicalToken, address bridgedToken, string canonicalTokenSymbol, string canonicalTokenName, uint8 canonicalTokenDecimal) -``` - -### EtherSent - -```solidity -event EtherSent(address to, uint256 destChainId, uint256 amount, bytes32 signal) -``` - -### EtherReceived - -```solidity -event EtherReceived(address from, uint256 amount) -``` - -### ERC20Sent - -```solidity -event ERC20Sent(address to, uint256 destChainId, address token, uint256 amount, bytes32 signal) -``` - -### ERC20Received - -```solidity -event ERC20Received(address to, address from, uint256 srcChainId, address token, uint256 amount) -``` - -### init - -```solidity -function init(address addressManager) external -``` - -### sendEther - -```solidity -function sendEther(uint256 destChainId, address to, uint256 gasLimit, uint256 processingFee, address refundAddress, string memo) external payable -``` - -Transfers Ether to this vault and sends a message to the destination -chain so the user can receive Ether. - -_Ether is held by Bridges on L1 and by the EtherVault on L2, -not TokenVaults._ - -#### Parameters - -| Name | Type | Description | -| ------------- | ------- | ------------------------------------------------------ | -| destChainId | uint256 | The destination chain ID where the `to` address lives. | -| to | address | The destination address. | -| gasLimit | uint256 | | -| processingFee | uint256 | @custom:see Bridge | -| refundAddress | address | | -| memo | string | | - -### sendERC20 - -```solidity -function sendERC20(uint256 destChainId, address to, address token, uint256 amount, uint256 gasLimit, uint256 processingFee, address refundAddress, string memo) external payable -``` - -Transfers ERC20 tokens to this vault and sends a message to the -destination chain so the user can receive the same amount of tokens -by invoking the message call. - -#### Parameters - -| Name | Type | Description | -| ------------- | ------- | ------------------------------------------------------------------------------------------------------------ | -| destChainId | uint256 | The destination chain ID where the `to` address lives. | -| to | address | The destination address. | -| token | address | The address of the token to be sent. | -| amount | uint256 | The amount of token to be transferred. | -| gasLimit | uint256 | @custom:see Bridge | -| processingFee | uint256 | @custom:see Bridge | -| refundAddress | address | The fee refund address. If this address is address(0), extra fees will be refunded back to the `to` address. | -| memo | string | | - -### receiveERC20 - -```solidity -function receiveERC20(struct TokenVault.CanonicalERC20 canonicalToken, address from, address to, uint256 amount) external -``` - -_This function can only be called by the bridge contract while -invoking a message call._ - -#### Parameters - -| Name | Type | Description | -| -------------- | -------------------------------- | -------------------------------------------------------------------------------------------------------------------- | -| canonicalToken | struct TokenVault.CanonicalERC20 | The canonical ERC20 token which may or may not live on this chain. If not, a BridgedERC20 contract will be deployed. | -| from | address | The source address. | -| to | address | The destination address. | -| amount | uint256 | The amount of tokens to be sent. 0 is a valid value. | - -### \_getOrDeployBridgedToken - -```solidity -function _getOrDeployBridgedToken(struct TokenVault.CanonicalERC20 canonicalToken) private returns (address) -``` - -### \_deployBridgedToken - -```solidity -function _deployBridgedToken(struct TokenVault.CanonicalERC20 canonicalToken) private returns (address bridgedToken) -``` diff --git a/packages/protocol/docs/common/AddressResolver.md b/packages/protocol/docs/common/AddressResolver.md deleted file mode 100644 index 1d84900aa87..00000000000 --- a/packages/protocol/docs/common/AddressResolver.md +++ /dev/null @@ -1,99 +0,0 @@ -## AddressResolver - -This abstract contract provides a name-to-address lookup. Under the hood, -it uses an AddressManager to manage the name-to-address mapping. - -### \_addressManager - -```solidity -contract IAddressManager _addressManager -``` - -### \_\_gap - -```solidity -uint256[49] __gap -``` - -### onlyFromNamed - -```solidity -modifier onlyFromNamed(string name) -``` - -### onlyFromNamedEither - -```solidity -modifier onlyFromNamedEither(string name1, string name2) -``` - -### resolve - -```solidity -function resolve(string name) public view virtual returns (address payable) -``` - -Resolves a name to an address on the current chain. - -_This function will throw if the resolved address is `address(0)`._ - -#### Parameters - -| Name | Type | Description | -| ---- | ------ | -------------------- | -| name | string | The name to resolve. | - -#### Return Values - -| Name | Type | Description | -| ---- | --------------- | --------------------------------- | -| [0] | address payable | The name's corresponding address. | - -### resolve - -```solidity -function resolve(uint256 chainId, string name) public view virtual returns (address payable) -``` - -Resolves a name to an address on the specified chain. - -_This function will throw if the resolved address is `address(0)`._ - -#### Parameters - -| Name | Type | Description | -| ------- | ------- | -------------------- | -| chainId | uint256 | The chainId. | -| name | string | The name to resolve. | - -#### Return Values - -| Name | Type | Description | -| ---- | --------------- | --------------------------------- | -| [0] | address payable | The name's corresponding address. | - -### addressManager - -```solidity -function addressManager() public view returns (address) -``` - -Returns the AddressManager's address. - -#### Return Values - -| Name | Type | Description | -| ---- | ------- | ----------------------------- | -| [0] | address | The AddressManager's address. | - -### \_init - -```solidity -function _init(address addressManager_) internal virtual -``` - -### \_resolve - -```solidity -function _resolve(uint256 chainId, string name) private view returns (address payable) -``` diff --git a/packages/protocol/docs/common/IAddressManager.md b/packages/protocol/docs/common/IAddressManager.md deleted file mode 100644 index 7b3385956e6..00000000000 --- a/packages/protocol/docs/common/IAddressManager.md +++ /dev/null @@ -1,41 +0,0 @@ -## IAddressManager - -Interface to set and get an address for a name. - -### setAddress - -```solidity -function setAddress(string name, address addr) external -``` - -Associate an address to a name. - -_The original address associated with the name, if exists, will be -replaced._ - -#### Parameters - -| Name | Type | Description | -| ---- | ------- | -------------------------------------------------- | -| name | string | The name which an address will be associated with. | -| addr | address | The address to be associated with the given name. | - -### getAddress - -```solidity -function getAddress(string name) external view returns (address) -``` - -Returns the address associated with the given name. - -#### Parameters - -| Name | Type | Description | -| ---- | ------ | ----------------------------------------------- | -| name | string | The name for which an address will be returned. | - -#### Return Values - -| Name | Type | Description | -| ---- | ------- | -------------------------------------------------------------------------------------------------- | -| [0] | address | The address associated with the given name. If no address is found, `address(0)` will be returned. | diff --git a/packages/protocol/docs/common/IHeaderSync.md b/packages/protocol/docs/common/IHeaderSync.md deleted file mode 100644 index d0086de8e11..00000000000 --- a/packages/protocol/docs/common/IHeaderSync.md +++ /dev/null @@ -1,21 +0,0 @@ -## IHeaderSync - -Interface to set and get an address for a name. - -### HeaderSynced - -```solidity -event HeaderSynced(uint256 height, uint256 srcHeight, bytes32 srcHash) -``` - -### getSyncedHeader - -```solidity -function getSyncedHeader(uint256 number) external view returns (bytes32) -``` - -### getLatestSyncedHeader - -```solidity -function getLatestSyncedHeader() external view returns (bytes32) -``` diff --git a/packages/protocol/docs/common/IMintableERC20.md b/packages/protocol/docs/common/IMintableERC20.md deleted file mode 100644 index e3cc948939e..00000000000 --- a/packages/protocol/docs/common/IMintableERC20.md +++ /dev/null @@ -1,13 +0,0 @@ -## IMintableERC20 - -### mint - -```solidity -function mint(address account, uint256 amount) external -``` - -### burn - -```solidity -function burn(address account, uint256 amount) external -``` diff --git a/packages/protocol/hardhat.config.ts b/packages/protocol/hardhat.config.ts index ec9f6684688..e1e67212de1 100644 --- a/packages/protocol/hardhat.config.ts +++ b/packages/protocol/hardhat.config.ts @@ -22,7 +22,7 @@ const config: HardhatUserConfig = { "thirdparty/", "common/EssentialContract.sol", ], - outputDir: "../website/pages/docs/contract-documentation/", + outputDir: "../website/pages/docs/reference/contract-documentation/", pages: "files", templates: "./solidity-docgen/templates", }, diff --git a/packages/protocol/package.json b/packages/protocol/package.json index 643841aca7a..875bb251774 100644 --- a/packages/protocol/package.json +++ b/packages/protocol/package.json @@ -6,7 +6,7 @@ "compile": "pnpm hardhat compile", "compile:yul": "LOG_LEVEL=debug pnpm hardhat compile_yul", "export:abi": "pnpm hardhat clear-abi && pnpm hardhat export-abi", - "export:docs": "pnpm hardhat docgen && pnpm prettier --write ../website/pages/docs/contract-documentation/**/*.md", + "export:docs": "pnpm hardhat docgen && pnpm prettier --write ../website/pages/docs/reference/contract-documentation/**/*.md", "clean": "rm -rf abis cache && pnpm hardhat clean", "lint:sol": "pnpm prettier '**/*.sol' --write && pnpm solhint 'contracts/**/*.sol' --fix", "eslint": "pnpm exec eslint --ignore-path .eslintignore --ext .js,.ts .", diff --git a/packages/website/pages/docs/reference/contract-documentation/L1/ProofVerifier.md b/packages/website/pages/docs/reference/contract-documentation/L1/ProofVerifier.md index 6d80dc4a5e3..f605f9bf704 100644 --- a/packages/website/pages/docs/reference/contract-documentation/L1/ProofVerifier.md +++ b/packages/website/pages/docs/reference/contract-documentation/L1/ProofVerifier.md @@ -7,7 +7,7 @@ title: IProofVerifier ### verifyZKP ```solidity -function verifyZKP(bytes verificationKey, bytes zkproof, bytes32 blockHash, address prover, bytes32 txListHash) external pure returns (bool verified) +function verifyZKP(string verifierId, bytes zkproof, bytes32 blockHash, address prover, bytes32 txListHash) external view returns (bool verified) ``` ### verifyMKP @@ -22,10 +22,16 @@ function verifyMKP(bytes key, bytes value, bytes proof, bytes32 root) external p ## ProofVerifier +### init + +```solidity +function init(address addressManager) external +``` + ### verifyZKP ```solidity -function verifyZKP(bytes verificationKey, bytes zkproof, bytes32 blockHash, address prover, bytes32 txListHash) external pure returns (bool) +function verifyZKP(string verifierId, bytes zkproof, bytes32 blockHash, address prover, bytes32 txListHash) external view returns (bool) ``` ### verifyMKP diff --git a/packages/website/pages/docs/reference/contract-documentation/L1/TaikoData.md b/packages/website/pages/docs/reference/contract-documentation/L1/TaikoData.md index c0370bf00a3..88940f827dd 100644 --- a/packages/website/pages/docs/reference/contract-documentation/L1/TaikoData.md +++ b/packages/website/pages/docs/reference/contract-documentation/L1/TaikoData.md @@ -35,6 +35,8 @@ struct Config { uint64 initialUncleDelay; bool enableTokenomics; bool enablePublicInputsCheck; + bool enableProofValidation; + bool enableOracleProver; } ``` diff --git a/packages/website/pages/docs/reference/contract-documentation/L1/TaikoL1.md b/packages/website/pages/docs/reference/contract-documentation/L1/TaikoL1.md index 9b908fdea25..681791f3df8 100644 --- a/packages/website/pages/docs/reference/contract-documentation/L1/TaikoL1.md +++ b/packages/website/pages/docs/reference/contract-documentation/L1/TaikoL1.md @@ -148,7 +148,7 @@ function getProposedBlock(uint256 id) public view returns (struct TaikoData.Prop ### getSyncedHeader ```solidity -function getSyncedHeader(uint256 number) public view returns (bytes32 header) +function getSyncedHeader(uint256 number) public view returns (bytes32) ``` ### getLatestSyncedHeader @@ -169,10 +169,10 @@ function getStateVariables() public view returns (uint64, uint64, uint64, uint25 function signWithGoldenTouch(bytes32 hash, uint8 k) public view returns (uint8 v, uint256 r, uint256 s) ``` -### getBlockProvers +### getForkChoice ```solidity -function getBlockProvers(uint256 id, bytes32 parentHash) public view returns (address[]) +function getForkChoice(uint256 id, bytes32 parentHash) public view returns (struct TaikoData.ForkChoice) ``` ### getUncleProofDelay @@ -186,3 +186,9 @@ function getUncleProofDelay(uint256 blockId) public view returns (uint64) ```solidity function getConfig() public pure virtual returns (struct TaikoData.Config) ``` + +### isBlockVerifiable + +```solidity +function isBlockVerifiable(uint256 blockId, bytes32 parentHash) public view returns (bool) +``` diff --git a/packages/website/pages/docs/reference/contract-documentation/L2/TaikoL2.md b/packages/website/pages/docs/reference/contract-documentation/L2/TaikoL2.md index be20ad227f8..2f315b55a87 100644 --- a/packages/website/pages/docs/reference/contract-documentation/L2/TaikoL2.md +++ b/packages/website/pages/docs/reference/contract-documentation/L2/TaikoL2.md @@ -10,10 +10,10 @@ title: TaikoL2 bytes32 publicInputHash ``` -### latestSyncedHeader +### latestSyncedL1Height ```solidity -bytes32 latestSyncedHeader +uint256 latestSyncedL1Height ``` ### BlockInvalidated @@ -51,18 +51,18 @@ variables because they are not part of the Trie structure. ### invalidateBlock ```solidity -function invalidateBlock(bytes txList, enum LibInvalidTxList.Reason hint, uint256 txIdx) external +function invalidateBlock(bytes txList, enum LibInvalidTxList.Hint hint, uint256 txIdx) external ``` Invalidate a L2 block by verifying its txList is not intrinsically valid. #### Parameters -| Name | Type | Description | -| ------ | ---------------------------- | ------------------------------------------------------------------------------------------------ | -| txList | bytes | The L2 block's txlist. | -| hint | enum LibInvalidTxList.Reason | A hint for this method to invalidate the txList. | -| txIdx | uint256 | If the hint is for a specific transaction in txList, txIdx specifies which transaction to check. | +| Name | Type | Description | +| ------ | -------------------------- | ------------------------------------------------------------------------------------------------ | +| txList | bytes | The L2 block's txlist. | +| hint | enum LibInvalidTxList.Hint | A hint for this method to invalidate the txList. | +| txIdx | uint256 | If the hint is for a specific transaction in txList, txIdx specifies which transaction to check. | ### getConfig diff --git a/packages/website/pages/docs/reference/contract-documentation/_meta.json b/packages/website/pages/docs/reference/contract-documentation/_meta.json index df581386e5d..aef85b496d2 100644 --- a/packages/website/pages/docs/reference/contract-documentation/_meta.json +++ b/packages/website/pages/docs/reference/contract-documentation/_meta.json @@ -5,10 +5,13 @@ "L2": { "title": "L2" }, - "bridge": { - "title": "Bridge" - }, "common": { "title": "Common" + }, + "signal": { + "title": "Signal" + }, + "bridge": { + "title": "Bridge" } } diff --git a/packages/website/pages/docs/reference/contract-documentation/bridge/Bridge.md b/packages/website/pages/docs/reference/contract-documentation/bridge/Bridge.md index 244db776306..a46dfddfaaa 100644 --- a/packages/website/pages/docs/reference/contract-documentation/bridge/Bridge.md +++ b/packages/website/pages/docs/reference/contract-documentation/bridge/Bridge.md @@ -12,7 +12,7 @@ _The code hash for the same address on L1 and L2 may be different._ ### MessageStatusChanged ```solidity -event MessageStatusChanged(bytes32 signal, enum LibBridgeStatus.MessageStatus status) +event MessageStatusChanged(bytes32 msgHash, enum LibBridgeStatus.MessageStatus status) ``` ### DestChainEnabled @@ -40,21 +40,18 @@ _Initializer to be called after being deployed behind a proxy._ ### sendMessage ```solidity -function sendMessage(struct IBridge.Message message) external payable returns (bytes32 signal) +function sendMessage(struct IBridge.Message message) external payable returns (bytes32 msgHash) ``` Sends a message to the destination chain and takes custody of Ether required in this contract. All extra Ether will be refunded. -### sendSignal +### releaseEther ```solidity -function sendSignal(bytes32 signal) external +function releaseEther(struct IBridge.Message message, bytes proof) external ``` -Stores a signal on the bridge contract and emits an event for the -relayer to pick up. - ### processMessage ```solidity @@ -70,43 +67,33 @@ function retryMessage(struct IBridge.Message message, bool isLastAttempt) extern ### isMessageSent ```solidity -function isMessageSent(bytes32 signal) public view virtual returns (bool) +function isMessageSent(bytes32 msgHash) public view virtual returns (bool) ``` -Checks if a signal has been stored on the bridge contract by the +Checks if a msgHash has been stored on the bridge contract by the current address. ### isMessageReceived ```solidity -function isMessageReceived(bytes32 signal, uint256 srcChainId, bytes proof) public view virtual returns (bool) +function isMessageReceived(bytes32 msgHash, uint256 srcChainId, bytes proof) public view virtual returns (bool) ``` -Checks if a signal has been received on the destination chain and +Checks if a msgHash has been received on the destination chain and sent by the src chain. -### isSignalSent - -```solidity -function isSignalSent(address sender, bytes32 signal) public view virtual returns (bool) -``` - -Checks if a signal has been stored on the bridge contract by the -specified address. - -### isSignalReceived +### isMessageFailed ```solidity -function isSignalReceived(bytes32 signal, uint256 srcChainId, address sender, bytes proof) public view virtual returns (bool) +function isMessageFailed(bytes32 msgHash, uint256 destChainId, bytes proof) public view virtual returns (bool) ``` -Check if a signal has been received on the destination chain and sent -by the specified sender. +Checks if a msgHash has been failed on the destination chain. ### getMessageStatus ```solidity -function getMessageStatus(bytes32 signal) public view virtual returns (enum LibBridgeStatus.MessageStatus) +function getMessageStatus(bytes32 msgHash) public view virtual returns (enum LibBridgeStatus.MessageStatus) ``` ### context @@ -123,8 +110,14 @@ Returns the bridge state context. function isDestChainEnabled(uint256 _chainId) public view returns (bool) ``` +### hashMessage + +```solidity +function hashMessage(struct IBridge.Message message) public pure returns (bytes32) +``` + ### getMessageStatusSlot ```solidity -function getMessageStatusSlot(bytes32 signal) public pure returns (bytes32) +function getMessageStatusSlot(bytes32 msgHash) public pure returns (bytes32) ``` diff --git a/packages/website/pages/docs/reference/contract-documentation/bridge/EtherVault.md b/packages/website/pages/docs/reference/contract-documentation/bridge/EtherVault.md index 1866d256863..f6e0635c294 100644 --- a/packages/website/pages/docs/reference/contract-documentation/bridge/EtherVault.md +++ b/packages/website/pages/docs/reference/contract-documentation/bridge/EtherVault.md @@ -12,6 +12,12 @@ Vault that holds Ether. event Authorized(address addr, bool authorized) ``` +### EtherReleased + +```solidity +event EtherReleased(address to, uint256 amount) +``` + ### onlyAuthorized ```solidity @@ -30,13 +36,14 @@ receive() external payable function init(address addressManager) external ``` -### sendEther +### releaseEther ```solidity -function sendEther(uint256 amount) public +function releaseEther(uint256 amount) public ``` -Send Ether from EtherVault to the sender, checking they are authorized. +Transfer Ether from EtherVault to the sender, checking that the sender +is authorized. #### Parameters @@ -44,6 +51,22 @@ Send Ether from EtherVault to the sender, checking they are authorized. | ------ | ------- | ------------------------ | | amount | uint256 | Amount of ether to send. | +### releaseEtherTo + +```solidity +function releaseEtherTo(address recipient, uint256 amount) public +``` + +Transfer Ether from EtherVault to an desinated address, checking that the +sender is authorized. + +#### Parameters + +| Name | Type | Description | +| --------- | ------- | ------------------------ | +| recipient | address | Address to receive Ether | +| amount | uint256 | Amount of ether to send. | + ### authorize ```solidity diff --git a/packages/website/pages/docs/reference/contract-documentation/bridge/IBridge.md b/packages/website/pages/docs/reference/contract-documentation/bridge/IBridge.md index 0eec0f526d4..9211f5fbe07 100644 --- a/packages/website/pages/docs/reference/contract-documentation/bridge/IBridge.md +++ b/packages/website/pages/docs/reference/contract-documentation/bridge/IBridge.md @@ -32,7 +32,7 @@ struct Message { ```solidity struct Context { - bytes32 signal; + bytes32 msgHash; address sender; uint256 srcChainId; } @@ -41,73 +41,72 @@ struct Context { ### SignalSent ```solidity -event SignalSent(address sender, bytes32 signal) +event SignalSent(address sender, bytes32 msgHash) ``` ### MessageSent ```solidity -event MessageSent(bytes32 signal, struct IBridge.Message message) +event MessageSent(bytes32 msgHash, struct IBridge.Message message) +``` + +### EtherReleased + +```solidity +event EtherReleased(bytes32 msgHash, address to, uint256 amount) ``` ### sendMessage ```solidity -function sendMessage(struct IBridge.Message message) external payable returns (bytes32 signal) +function sendMessage(struct IBridge.Message message) external payable returns (bytes32 msgHash) ``` Sends a message to the destination chain and takes custody of Ether required in this contract. All extra Ether will be refunded. -### sendSignal +### releaseEther ```solidity -function sendSignal(bytes32 signal) external +function releaseEther(struct IBridge.Message message, bytes proof) external ``` -Stores a signal on the bridge contract and emits an event for the -relayer to pick up. - ### isMessageSent ```solidity -function isMessageSent(bytes32 signal) external view returns (bool) +function isMessageSent(bytes32 msgHash) external view returns (bool) ``` -Checks if a signal has been stored on the bridge contract by the +Checks if a msgHash has been stored on the bridge contract by the current address. ### isMessageReceived ```solidity -function isMessageReceived(bytes32 signal, uint256 srcChainId, bytes proof) external view returns (bool) +function isMessageReceived(bytes32 msgHash, uint256 srcChainId, bytes proof) external view returns (bool) ``` -Checks if a signal has been received on the destination chain and +Checks if a msgHash has been received on the destination chain and sent by the src chain. -### isSignalSent +### isMessageFailed ```solidity -function isSignalSent(address sender, bytes32 signal) external view returns (bool) +function isMessageFailed(bytes32 msgHash, uint256 destChainId, bytes proof) external view returns (bool) ``` -Checks if a signal has been stored on the bridge contract by the -specified address. +Checks if a msgHash has been failed on the destination chain. -### isSignalReceived +### context ```solidity -function isSignalReceived(bytes32 signal, uint256 srcChainId, address sender, bytes proof) external view returns (bool) +function context() external view returns (struct IBridge.Context context) ``` -Check if a signal has been received on the destination chain and sent -by the specified sender. +Returns the bridge state context. -### context +### hashMessage ```solidity -function context() external view returns (struct IBridge.Context context) +function hashMessage(struct IBridge.Message message) external pure returns (bytes32) ``` - -Returns the bridge state context. diff --git a/packages/website/pages/docs/reference/contract-documentation/bridge/TokenVault.md b/packages/website/pages/docs/reference/contract-documentation/bridge/TokenVault.md index 7d71f245491..22be51518f0 100644 --- a/packages/website/pages/docs/reference/contract-documentation/bridge/TokenVault.md +++ b/packages/website/pages/docs/reference/contract-documentation/bridge/TokenVault.md @@ -20,6 +20,15 @@ struct CanonicalERC20 { } ``` +### MessageDeposit + +```solidity +struct MessageDeposit { + address token; + uint256 amount; +} +``` + ### isBridgedToken ```solidity @@ -38,6 +47,12 @@ mapping(address => struct TokenVault.CanonicalERC20) bridgedToCanonical mapping(uint256 => mapping(address => address)) canonicalToBridged ``` +### messageDeposits + +```solidity +mapping(bytes32 => struct TokenVault.MessageDeposit) messageDeposits +``` + ### BridgedERC20Deployed ```solidity @@ -47,25 +62,25 @@ event BridgedERC20Deployed(uint256 srcChainId, address canonicalToken, address b ### EtherSent ```solidity -event EtherSent(address to, uint256 destChainId, uint256 amount, bytes32 signal) +event EtherSent(bytes32 msgHash, address from, address to, uint256 destChainId, uint256 amount) ``` -### EtherReceived +### ERC20Sent ```solidity -event EtherReceived(address from, uint256 amount) +event ERC20Sent(bytes32 msgHash, address from, address to, uint256 destChainId, address token, uint256 amount) ``` -### ERC20Sent +### ERC20Released ```solidity -event ERC20Sent(address to, uint256 destChainId, address token, uint256 amount, bytes32 signal) +event ERC20Released(bytes32 msgHash, address from, address token, uint256 amount) ``` ### ERC20Received ```solidity -event ERC20Received(address to, address from, uint256 srcChainId, address token, uint256 amount) +event ERC20Received(bytes32 msgHash, address from, address to, uint256 srcChainId, address token, uint256 amount) ``` ### init @@ -120,6 +135,22 @@ by invoking the message call. | refundAddress | address | The fee refund address. If this address is address(0), extra fees will be refunded back to the `to` address. | | memo | string | | +### releaseERC20 + +```solidity +function releaseERC20(struct IBridge.Message message, bytes proof) external +``` + +Release deposited ERC20 back to the owner on the source TokenVault with +a proof that the message processing on the destination Bridge has failed. + +#### Parameters + +| Name | Type | Description | +| ------- | ---------------------- | -------------------------------------------------------------------- | +| message | struct IBridge.Message | The message that corresponds the ERC20 deposit on the source chain. | +| proof | bytes | The proof from the destination chain to show the message has failed. | + ### receiveERC20 ```solidity diff --git a/packages/website/pages/docs/reference/contract-documentation/common/AddressResolver.md b/packages/website/pages/docs/reference/contract-documentation/common/AddressResolver.md index 7e946e14b1b..ae839e5b6cc 100644 --- a/packages/website/pages/docs/reference/contract-documentation/common/AddressResolver.md +++ b/packages/website/pages/docs/reference/contract-documentation/common/AddressResolver.md @@ -19,16 +19,10 @@ contract IAddressManager _addressManager modifier onlyFromNamed(string name) ``` -### onlyFromNamedEither - -```solidity -modifier onlyFromNamedEither(string name1, string name2) -``` - ### resolve ```solidity -function resolve(string name) public view virtual returns (address payable) +function resolve(string name, bool allowZeroAddress) public view virtual returns (address payable) ``` Resolves a name to an address on the current chain. @@ -37,9 +31,10 @@ _This function will throw if the resolved address is `address(0)`._ #### Parameters -| Name | Type | Description | -| ---- | ------ | -------------------- | -| name | string | The name to resolve. | +| Name | Type | Description | +| ---------------- | ------ | ------------------------------------------ | +| name | string | The name to resolve. | +| allowZeroAddress | bool | True to allow zero address to be returned. | #### Return Values @@ -50,7 +45,7 @@ _This function will throw if the resolved address is `address(0)`._ ### resolve ```solidity -function resolve(uint256 chainId, string name) public view virtual returns (address payable) +function resolve(uint256 chainId, string name, bool allowZeroAddress) public view virtual returns (address payable) ``` Resolves a name to an address on the specified chain. @@ -59,10 +54,11 @@ _This function will throw if the resolved address is `address(0)`._ #### Parameters -| Name | Type | Description | -| ------- | ------- | -------------------- | -| chainId | uint256 | The chainId. | -| name | string | The name to resolve. | +| Name | Type | Description | +| ---------------- | ------- | ------------------------------------------ | +| chainId | uint256 | The chainId. | +| name | string | The name to resolve. | +| allowZeroAddress | bool | True to allow zero address to be returned. | #### Return Values diff --git a/packages/website/pages/docs/reference/contract-documentation/signal/ISignalService.md b/packages/website/pages/docs/reference/contract-documentation/signal/ISignalService.md new file mode 100644 index 00000000000..3f342e78a44 --- /dev/null +++ b/packages/website/pages/docs/reference/contract-documentation/signal/ISignalService.md @@ -0,0 +1,57 @@ +--- +title: ISignalService +--- + +## ISignalService + +### sendSignal + +```solidity +function sendSignal(bytes32 signal) external returns (bytes32 storageSlot) +``` + +Send a signal by storing the key with a value of 1. + +#### Parameters + +| Name | Type | Description | +| ------ | ------- | ------------------- | +| signal | bytes32 | The signal to send. | + +#### Return Values + +| Name | Type | Description | +| ----------- | ------- | -------------------------------------------------- | +| storageSlot | bytes32 | The slot in storage that this signal is persisted. | + +### isSignalSent + +```solidity +function isSignalSent(address app, bytes32 signal) external view returns (bool) +``` + +Check if a signal has been sent (key stored with a value of 1). + +#### Parameters + +| Name | Type | Description | +| ------ | ------- | ----------------------------------- | +| app | address | The address that sent this message. | +| signal | bytes32 | The signal to check. | + +### isSignalReceived + +```solidity +function isSignalReceived(uint256 srcChainId, address app, bytes32 signal, bytes proof) external view returns (bool) +``` + +Check if signal has been received on the destination chain (current). + +#### Parameters + +| Name | Type | Description | +| ---------- | ------- | ------------------------------------------------------- | +| srcChainId | uint256 | The source chain ID. | +| app | address | The address that sent this message. | +| signal | bytes32 | The signal to check. | +| proof | bytes | The proof of the signal being sent on the source chain. | diff --git a/packages/website/pages/docs/reference/contract-documentation/signal/SignalService.md b/packages/website/pages/docs/reference/contract-documentation/signal/SignalService.md new file mode 100644 index 00000000000..a5f19bbc0c7 --- /dev/null +++ b/packages/website/pages/docs/reference/contract-documentation/signal/SignalService.md @@ -0,0 +1,80 @@ +--- +title: SignalService +--- + +## SignalService + +### SignalProof + +```solidity +struct SignalProof { + struct BlockHeader header; + bytes proof; +} +``` + +### init + +```solidity +function init(address _addressManager) external +``` + +_Initializer to be called after being deployed behind a proxy._ + +### sendSignal + +```solidity +function sendSignal(bytes32 signal) public returns (bytes32 storageSlot) +``` + +Send a signal by storing the key with a value of 1. + +#### Parameters + +| Name | Type | Description | +| ------ | ------- | ------------------- | +| signal | bytes32 | The signal to send. | + +#### Return Values + +| Name | Type | Description | +| ----------- | ------- | -------------------------------------------------- | +| storageSlot | bytes32 | The slot in storage that this signal is persisted. | + +### isSignalSent + +```solidity +function isSignalSent(address app, bytes32 signal) public view returns (bool) +``` + +Check if a signal has been sent (key stored with a value of 1). + +#### Parameters + +| Name | Type | Description | +| ------ | ------- | ----------------------------------- | +| app | address | The address that sent this message. | +| signal | bytes32 | The signal to check. | + +### isSignalReceived + +```solidity +function isSignalReceived(uint256 srcChainId, address app, bytes32 signal, bytes proof) public view returns (bool) +``` + +Check if signal has been received on the destination chain (current). + +#### Parameters + +| Name | Type | Description | +| ---------- | ------- | ------------------------------------------------------- | +| srcChainId | uint256 | The source chain ID. | +| app | address | The address that sent this message. | +| signal | bytes32 | The signal to check. | +| proof | bytes | The proof of the signal being sent on the source chain. | + +### getSignalSlot + +```solidity +function getSignalSlot(address app, bytes32 signal) public pure returns (bytes32) +```