Skip to content

Commit

Permalink
Merge 'github/main'
Browse files Browse the repository at this point in the history
  • Loading branch information
vsuharnikov committed Nov 8, 2024
2 parents aa36240 + 613d21a commit f713aeb
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
4 changes: 4 additions & 0 deletions local-network/configs/blockscout/backend/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# precompiled.json

* `bytecode` - the result of `solc --bin-runtime ...`
* `abi` - the result of `solc --abi ... | jq . | tostring`
2 changes: 1 addition & 1 deletion local-network/configs/blockscout/backend/precompiled.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@
"source": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.26;\n\ncontract Bridge {\n address public constant BURN_ADDRESS = address(0);\n\n // 1 UNIT0(EL) = 1 UNIT0(CL)\n // 10^18 units in 1 UNIT0(EL)\n // 10^8 units in 1 UNIT0(CL)\n // 10^(18-8) = UNIT0(EL) / UNIT0(CL) = ratio\n // Conversion: N UNIT0(CL) = UNIT0(EL) / ratio\n uint256 public constant EL_TO_CL_RATIO = 10 ** 10; // 10 * 1 Gwei = 10 Gwei\n\n uint256 public constant MIN_AMOUNT_IN_WEI = 1 * EL_TO_CL_RATIO;\n uint256 public constant MAX_AMOUNT_IN_WEI = uint256(uint64(type(int64).max)) * EL_TO_CL_RATIO;\n\n uint16 public constant MAX_TRANSFERS_IN_BLOCK = 1024;\n\n mapping(uint => uint16) public transfersPerBlock;\n\n // wavesRecipient is a public key hash of recipient account.\n // effectively is it Waves address without 2 first bytes (version and chain id) and last 4 bytes (checksum).\n event SentNative(bytes20 wavesRecipient, int64 amount);\n\n function sendNative(bytes20 wavesRecipient) external payable {\n require(msg.value >= MIN_AMOUNT_IN_WEI, string.concat(\"Sent value \", uint2str(msg.value), \" must be greater or equal to \", uint2str(MIN_AMOUNT_IN_WEI)));\n require(msg.value <= MAX_AMOUNT_IN_WEI, string.concat(\"Sent value \", uint2str(msg.value), \" must be less or equal to \", uint2str(MAX_AMOUNT_IN_WEI)));\n\n uint blockNumber = block.number;\n require(transfersPerBlock[blockNumber] < MAX_TRANSFERS_IN_BLOCK, string.concat(\"Max transfers limit of \", uint2str(uint(MAX_TRANSFERS_IN_BLOCK)), \" reached in this block. Try to send transfers again\"));\n transfersPerBlock[blockNumber]++;\n\n uint256 ccAmount = msg.value / EL_TO_CL_RATIO;\n require(ccAmount * EL_TO_CL_RATIO == msg.value, string.concat(\"Sent value \", uint2str(msg.value), \" must be a multiple of \", uint2str(EL_TO_CL_RATIO)));\n\n (bool success,) = BURN_ADDRESS.call{value: msg.value}(\"\");\n require(success, \"Failed to send to burn address\");\n\n emit SentNative(wavesRecipient, int64(uint64(ccAmount)));\n }\n\n function uint2str(uint _i) internal pure returns (string memory _uintAsString) {\n if (_i == 0) {\n return \"0\";\n }\n uint j = _i;\n uint len;\n while (j != 0) {\n len++;\n j /= 10;\n }\n bytes memory bstr = new bytes(len);\n uint k = len;\n while (_i != 0) {\n k = k - 1;\n uint8 temp = (48 + uint8(_i - _i / 10 * 10));\n bytes1 b1 = bytes1(temp);\n bstr[k] = b1;\n _i /= 10;\n }\n return string(bstr);\n }\n}\n",
"abi": "[{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"bytes20\",\"name\":\"wavesRecipient\",\"type\":\"bytes20\"},{\"indexed\":false,\"internalType\":\"int64\",\"name\":\"amount\",\"type\":\"int64\"}],\"name\":\"SentNative\",\"type\":\"event\"},{\"inputs\":[],\"name\":\"BURN_ADDRESS\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"EL_TO_CL_RATIO\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"MAX_AMOUNT_IN_WEI\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"MAX_TRANSFERS_IN_BLOCK\",\"outputs\":[{\"internalType\":\"uint16\",\"name\":\"\",\"type\":\"uint16\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"MIN_AMOUNT_IN_WEI\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes20\",\"name\":\"wavesRecipient\",\"type\":\"bytes20\"}],\"name\":\"sendNative\",\"outputs\":[],\"stateMutability\":\"payable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"name\":\"transfersPerBlock\",\"outputs\":[{\"internalType\":\"uint16\",\"name\":\"\",\"type\":\"uint16\"}],\"stateMutability\":\"view\",\"type\":\"function\"}]"
}
]
]

0 comments on commit f713aeb

Please sign in to comment.