-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
cadc142
commit 9811ffa
Showing
67 changed files
with
4,094 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
book/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
table { | ||
margin: 0 auto; | ||
border-collapse: collapse; | ||
width: 100%; | ||
} | ||
|
||
table td:first-child { | ||
width: 15%; | ||
} | ||
|
||
table td:nth-child(2) { | ||
width: 25%; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
[book] | ||
src = "src" | ||
title = "" | ||
|
||
[output.html] | ||
additional-css = ["book.css"] | ||
additional-js = ["solidity.min.js"] | ||
git-repository-url = "https://github.com/ava-labs/teleporter" | ||
no-section-label = true | ||
|
||
[output.html.fold] | ||
enable = true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
hljs.registerLanguage("solidity",(()=>{"use strict";function e(){try{return!0 | ||
}catch(e){return!1}} | ||
var a=/-?(\b0[xX]([a-fA-F0-9]_?)*[a-fA-F0-9]|(\b[1-9](_?\d)*(\.((\d_?)*\d)?)?|\.\d(_?\d)*)([eE][-+]?\d(_?\d)*)?|\b0)(?!\w|\$)/ | ||
;e()&&(a=a.source.replace(/\\b/g,"(?<!\\$)\\b"));var s={className:"number", | ||
begin:a,relevance:0},n={ | ||
keyword:"assembly let function if switch case default for leave break continue u256 jump jumpi stop return revert selfdestruct invalid", | ||
built_in:"add sub mul div sdiv mod smod exp not lt gt slt sgt eq iszero and or xor byte shl shr sar addmod mulmod signextend keccak256 pc pop dup1 dup2 dup3 dup4 dup5 dup6 dup7 dup8 dup9 dup10 dup11 dup12 dup13 dup14 dup15 dup16 swap1 swap2 swap3 swap4 swap5 swap6 swap7 swap8 swap9 swap10 swap11 swap12 swap13 swap14 swap15 swap16 mload mstore mstore8 sload sstore msize gas address balance selfbalance caller callvalue calldataload calldatasize calldatacopy codesize codecopy extcodesize extcodecopy returndatasize returndatacopy extcodehash create create2 call callcode delegatecall staticcall log0 log1 log2 log3 log4 chainid origin gasprice basefee blockhash coinbase timestamp number difficulty gaslimit", | ||
literal:"true false"},i={className:"string", | ||
begin:/\bhex'(([0-9a-fA-F]{2}_?)*[0-9a-fA-F]{2})?'/},t={className:"string", | ||
begin:/\bhex"(([0-9a-fA-F]{2}_?)*[0-9a-fA-F]{2})?"/};function r(e){ | ||
return e.inherit(e.APOS_STRING_MODE,{begin:/(\bunicode)?'/})}function l(e){ | ||
return e.inherit(e.QUOTE_STRING_MODE,{begin:/(\bunicode)?"/})}var o={ | ||
SOL_ASSEMBLY_KEYWORDS:n,baseAssembly:e=>{ | ||
var a=r(e),o=l(e),c=/[A-Za-z_$][A-Za-z_$0-9.]*/,d=e.inherit(e.TITLE_MODE,{ | ||
begin:/[A-Za-z$_][0-9A-Za-z$_]*/,lexemes:c,keywords:n}),u={className:"params", | ||
begin:/\(/,end:/\)/,excludeBegin:!0,excludeEnd:!0,lexemes:c,keywords:n, | ||
contains:[e.C_LINE_COMMENT_MODE,e.C_BLOCK_COMMENT_MODE,a,o,s]},_={ | ||
className:"operator",begin:/:=|->/};return{keywords:n,lexemes:c, | ||
contains:[a,o,i,t,e.C_LINE_COMMENT_MODE,e.C_BLOCK_COMMENT_MODE,s,_,{ | ||
className:"function",lexemes:c,beginKeywords:"function",end:"{",excludeEnd:!0, | ||
contains:[d,u,e.C_LINE_COMMENT_MODE,e.C_BLOCK_COMMENT_MODE,_]}]}}, | ||
solAposStringMode:r,solQuoteStringMode:l,HEX_APOS_STRING_MODE:i, | ||
HEX_QUOTE_STRING_MODE:t,SOL_NUMBER:s,isNegativeLookbehindAvailable:e} | ||
;const{baseAssembly:c,solAposStringMode:d,solQuoteStringMode:u,HEX_APOS_STRING_MODE:_,HEX_QUOTE_STRING_MODE:m,SOL_NUMBER:b,isNegativeLookbehindAvailable:E}=o | ||
;return e=>{for(var a=d(e),s=u(e),n=[],i=0;i<32;i++)n[i]=i+1 | ||
;var t=n.map((e=>8*e)),r=[];for(i=0;i<=80;i++)r[i]=i | ||
;var l=n.map((e=>"bytes"+e)).join(" ")+" ",o=t.map((e=>"uint"+e)).join(" ")+" ",g=t.map((e=>"int"+e)).join(" ")+" ",M=[].concat.apply([],t.map((e=>r.map((a=>e+"x"+a))))),p={ | ||
keyword:"var bool string int uint "+g+o+"byte bytes "+l+"fixed ufixed "+M.map((e=>"fixed"+e)).join(" ")+" "+M.map((e=>"ufixed"+e)).join(" ")+" enum struct mapping address new delete if else for while continue break return throw emit try catch revert unchecked _ function modifier event constructor fallback receive error virtual override constant immutable anonymous indexed storage memory calldata external public internal payable pure view private returns import from as using pragma contract interface library is abstract type assembly", | ||
literal:"true false wei gwei szabo finney ether seconds minutes hours days weeks years", | ||
built_in:"self this super selfdestruct suicide now msg block tx abi blockhash gasleft assert require Error Panic sha3 sha256 keccak256 ripemd160 ecrecover addmod mulmod log0 log1 log2 log3 log4" | ||
},O={className:"operator",begin:/[+\-!~*\/%<>&^|=]/ | ||
},C=/[A-Za-z_$][A-Za-z_$0-9]*/,N={className:"params",begin:/\(/,end:/\)/, | ||
excludeBegin:!0,excludeEnd:!0,lexemes:C,keywords:p, | ||
contains:[e.C_LINE_COMMENT_MODE,e.C_BLOCK_COMMENT_MODE,a,s,b,"self"]},f={ | ||
begin:/\.\s*/,end:/[^A-Za-z0-9$_\.]/,excludeBegin:!0,excludeEnd:!0,keywords:{ | ||
built_in:"gas value selector address length push pop send transfer call callcode delegatecall staticcall balance code codehash wrap unwrap name creationCode runtimeCode interfaceId min max" | ||
},relevance:2},y=e.inherit(e.TITLE_MODE,{begin:/[A-Za-z$_][0-9A-Za-z$_]*/, | ||
lexemes:C,keywords:p}),w={className:"built_in", | ||
begin:(E()?"(?<!\\$)\\b":"\\b")+"(gas|value|salt)(?=:)"};function x(e,a){return{ | ||
begin:(E()?"(?<!\\$)\\b":"\\b")+e+"\\.\\s*",end:/[^A-Za-z0-9$_\.]/, | ||
excludeBegin:!1,excludeEnd:!0,lexemes:C,keywords:{built_in:e+" "+a}, | ||
contains:[f],relevance:10}}var h=c(e),v=e.inherit(h,{ | ||
contains:h.contains.concat([{begin:/\./,end:/[^A-Za-z0-9$.]/,excludeBegin:!0, | ||
excludeEnd:!0,keywords:{built_in:"slot offset length address selector"}, | ||
relevance:2},{begin:/_/,end:/[^A-Za-z0-9$.]/,excludeBegin:!0,excludeEnd:!0, | ||
keywords:{built_in:"slot offset"},relevance:2}])});return{aliases:["sol"], | ||
keywords:p,lexemes:C, | ||
contains:[a,s,_,m,e.C_LINE_COMMENT_MODE,e.C_BLOCK_COMMENT_MODE,b,w,O,{ | ||
className:"function",lexemes:C, | ||
beginKeywords:"function modifier event constructor fallback receive error", | ||
end:/[{;]/,excludeEnd:!0, | ||
contains:[y,N,w,e.C_LINE_COMMENT_MODE,e.C_BLOCK_COMMENT_MODE],illegal:/%/ | ||
},x("msg","gas value data sender sig"),x("block","blockhash coinbase difficulty gaslimit basefee number timestamp chainid"),x("tx","gasprice origin"),x("abi","decode encode encodePacked encodeWithSelector encodeWithSignature encodeCall"),x("bytes","concat"),f,{ | ||
className:"class",lexemes:C,beginKeywords:"contract interface library",end:"{", | ||
excludeEnd:!0,illegal:/[:"\[\]]/,contains:[{beginKeywords:"is",lexemes:C | ||
},y,N,w,e.C_LINE_COMMENT_MODE,e.C_BLOCK_COMMENT_MODE]},{lexemes:C, | ||
beginKeywords:"struct enum",end:"{",excludeEnd:!0,illegal:/[:"\[\]]/, | ||
contains:[y,e.C_LINE_COMMENT_MODE,e.C_BLOCK_COMMENT_MODE]},{ | ||
beginKeywords:"import",end:";",lexemes:C,keywords:"import from as", | ||
contains:[y,a,s,_,m,e.C_LINE_COMMENT_MODE,e.C_BLOCK_COMMENT_MODE,O]},{ | ||
beginKeywords:"using",end:";",lexemes:C,keywords:"using for", | ||
contains:[y,e.C_LINE_COMMENT_MODE,e.C_BLOCK_COMMENT_MODE,O]},{className:"meta", | ||
beginKeywords:"pragma",end:";",lexemes:C,keywords:{ | ||
keyword:"pragma solidity experimental abicoder", | ||
built_in:"ABIEncoderV2 SMTChecker v1 v2"}, | ||
contains:[e.C_LINE_COMMENT_MODE,e.C_BLOCK_COMMENT_MODE,e.inherit(a,{ | ||
className:"meta-string"}),e.inherit(s,{className:"meta-string"})]},{ | ||
beginKeywords:"assembly",end:/\b\B/, | ||
contains:[e.C_LINE_COMMENT_MODE,e.C_BLOCK_COMMENT_MODE,e.inherit(v,{begin:"{", | ||
end:"}",endsParent:!0,contains:v.contains.concat([e.inherit(v,{begin:"{", | ||
end:"}",contains:v.contains.concat(["self"])})])})]}],illegal:/#/}}})()); | ||
|
||
// Ugly hack to reload HLJS | ||
hljs.initHighlightingOnLoad(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
## Teleporter Messenger Contract and Example Cross Chain Applications | ||
This directory contains Solidity contracts implementing the Teleporter messaging protocol and example cross-chain applications built using Teleporter. | ||
|
||
This directory is set up as a [Foundry](https://github.com/foundry-rs/foundry) project. Follow the linked guide to install the necessary dependencies. Further documentation about given contracts can be found in `src/Teleporter/` and `src/CrossChainApplications`. | ||
|
||
## Building and Running | ||
- To compile the contracts run `forge build` from this directory. | ||
- Similarly, to run unit tests, run `forge test`. | ||
- See additional testing and deployment options [here](https://book.getfoundry.sh/forge/). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
# Summary | ||
- [Home](README.md) | ||
# src | ||
- [❱ CrossChainApplications](src/CrossChainApplications/README.md) | ||
- [❱ ERC20Bridge](src/CrossChainApplications/ERC20Bridge/README.md) | ||
- [❱ tests](src/CrossChainApplications/ERC20Bridge/tests/README.md) | ||
- [ERC20BridgeTest](src/CrossChainApplications/ERC20Bridge/tests/ERC20BridgeTests.t.sol/contract.ERC20BridgeTest.md) | ||
- [BridgeToken](src/CrossChainApplications/ERC20Bridge/BridgeToken.sol/contract.BridgeToken.md) | ||
- [ERC20Bridge](src/CrossChainApplications/ERC20Bridge/ERC20Bridge.sol/contract.ERC20Bridge.md) | ||
- [IERC20Bridge](src/CrossChainApplications/ERC20Bridge/IERC20Bridge.sol/interface.IERC20Bridge.md) | ||
- [❱ ExampleMessenger](src/CrossChainApplications/ExampleMessenger/README.md) | ||
- [ExampleCrossChainMessenger](src/CrossChainApplications/ExampleMessenger/ExampleCrossChainMessenger.sol/contract.ExampleCrossChainMessenger.md) | ||
- [❱ VerifiedBlockHash](src/CrossChainApplications/VerifiedBlockHash/README.md) | ||
- [BlockHashPublisher](src/CrossChainApplications/VerifiedBlockHash/BlockHashPublisher.sol/contract.BlockHashPublisher.md) | ||
- [BlockHashReceiver](src/CrossChainApplications/VerifiedBlockHash/BlockHashReceiver.sol/contract.BlockHashReceiver.md) | ||
- [❱ Mocks](src/Mocks/README.md) | ||
- [ExampleERC20](src/Mocks/ExampleERC20.sol/contract.ExampleERC20.md) | ||
- [UnitTestMockERC20](src/Mocks/UnitTestMockERC20.sol/contract.UnitTestMockERC20.md) | ||
- [❱ Teleporter](src/Teleporter/README.md) | ||
- [❱ tests](src/Teleporter/tests/README.md) | ||
- [AddFeeAmountTest](src/Teleporter/tests/AddFeeAmountTests.t.sol/contract.AddFeeAmountTest.md) | ||
- [CheckIsAllowedRelayerTest](src/Teleporter/tests/CheckAllowedRelayerTests.t.sol/contract.CheckIsAllowedRelayerTest.md) | ||
- [GetFeeInfoTest](src/Teleporter/tests/GetFeeInfoTests.t.sol/contract.GetFeeInfoTest.md) | ||
- [GetMessageHashTest](src/Teleporter/tests/GetMessageHashTests.t.sol/contract.GetMessageHashTest.md) | ||
- [GetNextMessageIDTest](src/Teleporter/tests/GetNextMessageIdTests.t.sol/contract.GetNextMessageIDTest.md) | ||
- [GetOutstandingReceiptsToSendTest](src/Teleporter/tests/GetOutstandingReceiptsToSendTests.t.sol/contract.GetOutstandingReceiptsToSendTest.md) | ||
- [GetRelayerRewardAddressTest](src/Teleporter/tests/GetRelayerRewardAddressTests.t.sol/contract.GetRelayerRewardAddressTest.md) | ||
- [SampleMessageReceiverAction](src/Teleporter/tests/HandleInitialMessageExecutionTests.t.sol/enum.SampleMessageReceiverAction.md) | ||
- [SampleMessageReceiver](src/Teleporter/tests/HandleInitialMessageExecutionTests.t.sol/contract.SampleMessageReceiver.md) | ||
- [HandleInitialMessageExecutionTest](src/Teleporter/tests/HandleInitialMessageExecutionTests.t.sol/contract.HandleInitialMessageExecutionTest.md) | ||
- [MarkReceiptTest](src/Teleporter/tests/MarkReceiptTests.t.sol/contract.MarkReceiptTest.md) | ||
- [MessageReceivedTest](src/Teleporter/tests/MessageReceivedTests.t.sol/contract.MessageReceivedTest.md) | ||
- [ReceiptQueueTest](src/Teleporter/tests/ReceiptsQueueTests.t.sol/contract.ReceiptQueueTest.md) | ||
- [ReceiveCrossChainMessagedTest](src/Teleporter/tests/ReceiveCrossChainMessageTests.t.sol/contract.ReceiveCrossChainMessagedTest.md) | ||
- [RedeemRelayerRewardsTest](src/Teleporter/tests/RedeemRelayerRewardsTests.t.sol/contract.RedeemRelayerRewardsTest.md) | ||
- [ReentrancyGuardsTests](src/Teleporter/tests/ReentrancyGuardsTests.t.sol/contract.ReentrancyGuardsTests.md) | ||
- [SampleMessenger](src/Teleporter/tests/ReentrancyGuardsTests.t.sol/contract.SampleMessenger.md) | ||
- [FlakyMessageReceiverAction](src/Teleporter/tests/RetryMessageExecutionTests.t.sol/enum.FlakyMessageReceiverAction.md) | ||
- [FlakyMessageReceiver](src/Teleporter/tests/RetryMessageExecutionTests.t.sol/contract.FlakyMessageReceiver.md) | ||
- [RetryMessageExecutionTest](src/Teleporter/tests/RetryMessageExecutionTests.t.sol/contract.RetryMessageExecutionTest.md) | ||
- [RetryReceiptTest](src/Teleporter/tests/RetryReceiptTests.t.sol/contract.RetryReceiptTest.md) | ||
- [RetrySendCrossChainMessageTest](src/Teleporter/tests/RetrySendCrossChainMessageTests.t.sol/contract.RetrySendCrossChainMessageTest.md) | ||
- [SendCrossChainMessageTest](src/Teleporter/tests/SendCrossChainMessageTests.t.sol/contract.SendCrossChainMessageTest.md) | ||
- [TeleporterMessengerTest](src/Teleporter/tests/TeleporterMessengerTest.t.sol/contract.TeleporterMessengerTest.md) | ||
- [❱ upgrades](src/Teleporter/upgrades/README.md) | ||
- [❱ tests](src/Teleporter/upgrades/tests/README.md) | ||
- [TeleporterRegistryTest](src/Teleporter/upgrades/tests/TeleporterRegistryTests.t.sol/contract.TeleporterRegistryTest.md) | ||
- [ExampleUpgradeableApp](src/Teleporter/upgrades/tests/TeleporterUpgradeableTests.t.sol/contract.ExampleUpgradeableApp.md) | ||
- [TeleporterUpgradeableTest](src/Teleporter/upgrades/tests/TeleporterUpgradeableTests.t.sol/contract.TeleporterUpgradeableTest.md) | ||
- [TeleporterRegistry](src/Teleporter/upgrades/TeleporterRegistry.sol/contract.TeleporterRegistry.md) | ||
- [TeleporterUpgradeable](src/Teleporter/upgrades/TeleporterUpgradeable.sol/abstract.TeleporterUpgradeable.md) | ||
- [TeleporterMessageReceipt](src/Teleporter/ITeleporterMessenger.sol/struct.TeleporterMessageReceipt.md) | ||
- [TeleporterMessageInput](src/Teleporter/ITeleporterMessenger.sol/struct.TeleporterMessageInput.md) | ||
- [TeleporterMessage](src/Teleporter/ITeleporterMessenger.sol/struct.TeleporterMessage.md) | ||
- [TeleporterFeeInfo](src/Teleporter/ITeleporterMessenger.sol/struct.TeleporterFeeInfo.md) | ||
- [ITeleporterMessenger](src/Teleporter/ITeleporterMessenger.sol/interface.ITeleporterMessenger.md) | ||
- [ITeleporterReceiver](src/Teleporter/ITeleporterReceiver.sol/interface.ITeleporterReceiver.md) | ||
- [ReceiptQueue](src/Teleporter/ReceiptQueue.sol/library.ReceiptQueue.md) | ||
- [ReentrancyGuards](src/Teleporter/ReentrancyGuards.sol/abstract.ReentrancyGuards.md) | ||
- [SafeERC20TransferFrom](src/Teleporter/SafeERC20TransferFrom.sol/library.SafeERC20TransferFrom.md) | ||
- [TeleporterMessenger](src/Teleporter/TeleporterMessenger.sol/contract.TeleporterMessenger.md) | ||
- [ProtocolRegistryEntry](src/WarpProtocolRegistry.sol/struct.ProtocolRegistryEntry.md) | ||
- [WarpProtocolRegistry](src/WarpProtocolRegistry.sol/abstract.WarpProtocolRegistry.md) |
78 changes: 78 additions & 0 deletions
78
.../src/CrossChainApplications/ERC20Bridge/BridgeToken.sol/contract.BridgeToken.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
# BridgeToken | ||
[Git Source](https://github.com/ava-labs/teleporter/blob/cadc1420fd95195b094eea855b7496cc71b5be2a/src/CrossChainApplications/ERC20Bridge/BridgeToken.sol) | ||
|
||
**Inherits:** | ||
ERC20Burnable | ||
|
||
*BridgeToken is an ERC20Burnable token contract that is associated with a specific native chain bridge and asset, and is only mintable by the bridge contract on this chain.* | ||
|
||
|
||
## State Variables | ||
### bridgeContract | ||
|
||
```solidity | ||
address public immutable bridgeContract; | ||
``` | ||
|
||
|
||
### nativeChainID | ||
|
||
```solidity | ||
bytes32 public immutable nativeChainID; | ||
``` | ||
|
||
|
||
### nativeBridge | ||
|
||
```solidity | ||
address public immutable nativeBridge; | ||
``` | ||
|
||
|
||
### nativeAsset | ||
|
||
```solidity | ||
address public immutable nativeAsset; | ||
``` | ||
|
||
|
||
### _decimals | ||
|
||
```solidity | ||
uint8 private immutable _decimals; | ||
``` | ||
|
||
|
||
## Functions | ||
### constructor | ||
|
||
*Initializes a BridgeToken instance.* | ||
|
||
|
||
```solidity | ||
constructor( | ||
bytes32 sourceChainID, | ||
address sourceBridge, | ||
address sourceAsset, | ||
string memory tokenName, | ||
string memory tokenSymbol, | ||
uint8 tokenDecimals | ||
) ERC20(tokenName, tokenSymbol); | ||
``` | ||
|
||
### mint | ||
|
||
*Mints tokens to `account` if called by original `bridgeContract`.* | ||
|
||
|
||
```solidity | ||
function mint(address account, uint256 amount) public; | ||
``` | ||
|
||
### decimals | ||
|
||
|
||
```solidity | ||
function decimals() public view virtual override returns (uint8); | ||
``` | ||
|
Oops, something went wrong.