From 147b0ded4c8c49dac28b6f1ae3a263e50f985ed5 Mon Sep 17 00:00:00 2001 From: Renan Kruger Date: Wed, 9 Aug 2023 16:27:56 -0300 Subject: [PATCH 1/2] Update evm_contract_design.md --- .../evm-compatible-bridge/evm_contract_design.md | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/projects/evm-compatible-bridge/evm_contract_design.md b/projects/evm-compatible-bridge/evm_contract_design.md index ba951ac..45ef638 100644 --- a/projects/evm-compatible-bridge/evm_contract_design.md +++ b/projects/evm-compatible-bridge/evm_contract_design.md @@ -62,22 +62,19 @@ This contract is "ownable" and the admin will be able to make some operations, f ##### _Token equivalency_ -The contract will require some data structures to be stored on the persistent storage mainly to track the mapping of Hathor tokens to EVM tokens and the crossing operations. +The contract will require some data conversions from bytes32 to address to repesent tokens from hathor on eth. The ERC-777 and ERC-20 tokens are identified by the contract address and the Hathor token by its 32 bytes token uid. -There should be a map going both ways to map a contract address to a token uid and a map from token uid to contract address. +There should be function for data conversion on bridge contract. ```solidity -// This maps a local token address to a hathor token uid -// This can be used to know which token in Hathor is equivalent to our native token. -mapping (address => bytes32) localTokenToHathorUid; - -// This maps a Hathor token uid to a local token address. -mapping (bytes32 => address) hathorUidToLocalToken; + // this converts bytes32 to address + function bytesToAddress (bytes32 data) public pure returns (address) { + return address(uint160(uint256(data))); + } ``` The only special case is Hathor native token (HTR) which has a token uid of `00` which is not 32 bytes long. -To use the same method we will map HTR to a 32 bytes sequence of zeroes, i.e. `00000000000000000000000000000000`. ### Federation contract From 931de41362ec0e24303f2d64c3f1900c9026d21e Mon Sep 17 00:00:00 2001 From: Renan Kruger Date: Wed, 9 Aug 2023 16:28:41 -0300 Subject: [PATCH 2/2] Update evm_contract_design.md --- projects/evm-compatible-bridge/evm_contract_design.md | 2 -- 1 file changed, 2 deletions(-) diff --git a/projects/evm-compatible-bridge/evm_contract_design.md b/projects/evm-compatible-bridge/evm_contract_design.md index 45ef638..42b57fd 100644 --- a/projects/evm-compatible-bridge/evm_contract_design.md +++ b/projects/evm-compatible-bridge/evm_contract_design.md @@ -74,8 +74,6 @@ There should be function for data conversion on bridge contract. } ``` -The only special case is Hathor native token (HTR) which has a token uid of `00` which is not 32 bytes long. - ### Federation contract A good example implementation can be found [here](https://github.com/onepercentio/tokenbridge/blob/master/bridge/contracts/Federation.sol).