Arbitrum stuff ripped out, text changed.
This commit is contained in:
parent
77a0cf4461
commit
091be423aa
|
@ -1,6 +1,6 @@
|
|||
# 10grans-NG
|
||||
|
||||
10grans on Arbitrum chain, with a bridge to Ethereum.
|
||||
10grans on Base chain, with a bridge to Ethereum.
|
||||
|
||||
```shell
|
||||
npx hardhat help
|
||||
|
|
|
@ -1,30 +0,0 @@
|
|||
// SPDX-License-Identifier: MIT
|
||||
pragma solidity ^0.8.9;
|
||||
|
||||
import "./TenGransAbstractToken.sol";
|
||||
import "@arbitrum/token-bridge-contracts/contracts/tokenbridge/arbitrum/IArbToken.sol";
|
||||
|
||||
contract TenGransArbToken is AbstractGrans, IArbToken {
|
||||
uint256 public immutable cap = 15_000 * 10 ** 18;
|
||||
address public immutable l2Gateway;
|
||||
address public immutable override l1Address;
|
||||
|
||||
modifier onlyGateway() {
|
||||
require(msg.sender == l2Gateway, "ONLY_l2GATEWAY");
|
||||
_;
|
||||
}
|
||||
|
||||
constructor(address _l2Gateway, address _l1Address) AbstractGrans() {
|
||||
l2Gateway = _l2Gateway;
|
||||
l1Address = _l1Address;
|
||||
}
|
||||
|
||||
function bridgeMint(address account, uint256 amount) external virtual override onlyGateway {
|
||||
require(amount + totalSupply() <= cap, "CAP_EXCEEDED");
|
||||
_mint(account, amount);
|
||||
}
|
||||
|
||||
function bridgeBurn(address account, uint256 amount) external virtual override onlyGateway {
|
||||
_burn(account, amount);
|
||||
}
|
||||
}
|
|
@ -2,84 +2,18 @@
|
|||
pragma solidity ^0.8.9;
|
||||
|
||||
import "./TenGransAbstractToken.sol";
|
||||
import "@arbitrum/token-bridge-contracts/contracts/tokenbridge/ethereum/ICustomToken.sol";
|
||||
|
||||
interface IL1CustomGateway {
|
||||
function registerTokenToL2(
|
||||
address _l2Address,
|
||||
uint256 _maxGas,
|
||||
uint256 _gasPriceBid,
|
||||
uint256 _maxSubmissionCost,
|
||||
address _creditBackAddress
|
||||
) external payable returns (uint256);
|
||||
}
|
||||
contract TenGransEthToken is AbstractGrans {
|
||||
|
||||
interface IGatewayRouter2 {
|
||||
function setGateway(
|
||||
address _gateway,
|
||||
uint256 _maxGas,
|
||||
uint256 _gasPriceBid,
|
||||
uint256 _maxSubmissionCost,
|
||||
address _creditBackAddress
|
||||
) external payable returns (uint256);
|
||||
}
|
||||
|
||||
contract TenGransEthToken is AbstractGrans, ICustomToken {
|
||||
address public immutable gateway;
|
||||
address public immutable router;
|
||||
bool private shouldRegisterGateway;
|
||||
|
||||
constructor(address _gateway, address _router) AbstractGrans() {
|
||||
gateway = _gateway;
|
||||
router = _router;
|
||||
constructor() AbstractGrans() {
|
||||
_mint(msg.sender, 15_000 * 10 ** 18);
|
||||
}
|
||||
|
||||
function balanceOf(address account) public view virtual override(AbstractGrans, ICustomToken) returns (uint256) {
|
||||
function balanceOf(address account) public view virtual override(AbstractGrans) returns (uint256) {
|
||||
return AbstractGrans.balanceOf(account);
|
||||
}
|
||||
|
||||
function transferFrom(address sender, address recipient, uint256 amount) public virtual override(AbstractGrans, ICustomToken) returns (bool) {
|
||||
function transferFrom(address sender, address recipient, uint256 amount) public virtual override(AbstractGrans) returns (bool) {
|
||||
return AbstractGrans.transferFrom(sender, recipient, amount);
|
||||
}
|
||||
|
||||
/// @dev we only set shouldRegisterGateway to true when in `registerTokenOnL2`
|
||||
function isArbitrumEnabled() external view override returns (uint8) {
|
||||
require(shouldRegisterGateway, "NOT_EXPECTED_CALL");
|
||||
return uint8(uint16(uint32(uint64(uint128(0xa4b1)))));
|
||||
}
|
||||
|
||||
function registerTokenOnL2(
|
||||
address l2CustomTokenAddress,
|
||||
uint256 maxSubmissionCostForCustomGateway,
|
||||
uint256 maxSubmissionCostForRouter,
|
||||
uint256 maxGasForCustomGateway,
|
||||
uint256 maxGasForRouter,
|
||||
uint256 gasPriceBid,
|
||||
uint256 valueForGateway,
|
||||
uint256 valueForRouter,
|
||||
address creditBackAddress
|
||||
) public payable override onlyOwner {
|
||||
// we temporarily set `shouldRegisterGateway` to true for the callback in registerTokenToL2 to succeed
|
||||
bool prev = shouldRegisterGateway;
|
||||
shouldRegisterGateway = true;
|
||||
|
||||
IL1CustomGateway(gateway).registerTokenToL2{value: valueForGateway}(
|
||||
l2CustomTokenAddress,
|
||||
maxGasForCustomGateway,
|
||||
gasPriceBid,
|
||||
maxSubmissionCostForCustomGateway,
|
||||
creditBackAddress
|
||||
);
|
||||
|
||||
IGatewayRouter2(router).setGateway{value: valueForRouter}(
|
||||
gateway,
|
||||
maxGasForRouter,
|
||||
gasPriceBid,
|
||||
maxSubmissionCostForRouter,
|
||||
creditBackAddress
|
||||
);
|
||||
|
||||
shouldRegisterGateway = prev;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,7 +4,7 @@ import "hardhat-contract-sizer";
|
|||
|
||||
const config: HardhatUserConfig = {
|
||||
solidity: {
|
||||
version: "0.8.19",
|
||||
version: "0.8.19", // don't make this higher
|
||||
settings: {
|
||||
optimizer: {
|
||||
enabled: true,
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -1,7 +1,7 @@
|
|||
{
|
||||
"name": "10grans-ng",
|
||||
"version": "1.0.0",
|
||||
"description": "10grans on Arbitrum",
|
||||
"description": "10grans on Base",
|
||||
"main": "index.js",
|
||||
"scripts": {
|
||||
"test": "echo \"Error: no test specified\" && exit 1"
|
||||
|
@ -14,7 +14,8 @@
|
|||
"cryptocurrency",
|
||||
"erc-20",
|
||||
"token",
|
||||
"solidity"
|
||||
"solidity",
|
||||
"coinbase"
|
||||
],
|
||||
"author": "moon@shipoclu.com",
|
||||
"license": "MIT",
|
||||
|
@ -26,7 +27,6 @@
|
|||
"prettier-plugin-solidity": "^1.1.3"
|
||||
},
|
||||
"dependencies": {
|
||||
"@arbitrum/token-bridge-contracts": "^1.0.0-beta.0",
|
||||
"@openzeppelin/contracts": "^4.9.3",
|
||||
"erc-payable-token": "^4.9.3"
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue