Skip to content

Commit

Permalink
chore: first
Browse files Browse the repository at this point in the history
  • Loading branch information
addiaddiaddi committed Nov 23, 2024
1 parent 9d78a51 commit c0aa18a
Show file tree
Hide file tree
Showing 10 changed files with 147 additions and 57 deletions.
6 changes: 6 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
[submodule "lib/forge-std"]
path = lib/forge-std
url = https://github.com/foundry-rs/forge-std
[submodule "lib/openzeppelin-contracts"]
path = lib/openzeppelin-contracts
url = https://github.com/openzeppelin/openzeppelin-contracts
[submodule "lib/openzeppelin-contracts-upgradeable"]
path = lib/openzeppelin-contracts-upgradeable
url = https://github.com/openzeppelin/openzeppelin-contracts-upgradeable
1 change: 1 addition & 0 deletions lib/openzeppelin-contracts
Submodule openzeppelin-contracts added at 69c8de
1 change: 1 addition & 0 deletions lib/openzeppelin-contracts-upgradeable
19 changes: 0 additions & 19 deletions script/Counter.s.sol

This file was deleted.

27 changes: 27 additions & 0 deletions script/Main.s.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.13;

import {Script, console} from "forge-std/Script.sol";
import {DepositV1} from "../src/DepositV1.sol";
import "@openzeppelin/contracts/proxy/transparent/TransparentUpgradeableProxy.sol";

function deployDepositV1(address move, address owner, address bridge) returns (DepositV1) {
DepositV1 implementation = new DepositV1();
TransparentUpgradeableProxy proxy = new TransparentUpgradeableProxy(address(implementation), address(owner), "");
DepositV1 proxyContract = DepositV1(address(proxy));

proxyContract.initialize(move, owner, bridge);
return proxyContract;
}

contract CounterScript is Script {

function setUp() public {}

function run() public {
vm.startBroadcast();


vm.stopBroadcast();
}
}
14 changes: 0 additions & 14 deletions src/Counter.sol

This file was deleted.

41 changes: 41 additions & 0 deletions src/DepositV1.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.13;
import "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol";
import "@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol";
import "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import "src/mock/NativeBridge.sol";

contract DepositV1 is Initializable, OwnableUpgradeable {


mapping(address => uint256) public deposits;
mapping(address => bytes32) public moveAddresses;

IERC20 public move;
NativeBridge public bridge;

event Deposit(address user, uint256 indexed amount, bytes32 indexed moveAddress, uint256 indexed timestamp);

function initialize(address move_, address owner_, address bridge_) public initializer {
__Ownable_init(owner_);
move = IERC20(move_);
bridge = NativeBridge(bridge_);
}

function deposit(address to, uint256 amount, bytes32 moveAddress) external {
move.transferFrom(msg.sender, address(this), amount);
deposits[to] += amount;
moveAddresses[to] = moveAddress;

emit Deposit(to, amount, moveAddress, block.timestamp);
}

function bridgeToMovement(bytes32 moveAddress, uint256 amount) external onlyOwner {
move.approve(address(bridge), amount);
bridge.initiateBridgeTransfer(moveAddress, amount);



}
}

36 changes: 36 additions & 0 deletions src/mock/NativeBridge.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.22;
pragma abicoder v2;

import {IERC20} from "@openzeppelin/contracts/token/ERC20/IERC20.sol";

// import {RateLimiter} from "./RateLimiter.sol";

contract NativeBridge {
IERC20 public moveToken;
// Prevents initialization of implementation contract exploits
constructor(address _moveToken) {
moveToken = IERC20(_moveToken);
}

event BridgeTransferInitiated(
bytes32 indexed bridgeTransferId,
address indexed originator,
bytes32 indexed recipient,
uint256 amount,
uint256 nonce
);

function initiateBridgeTransfer(bytes32 recipient, uint256 amount)
external
returns (bytes32 bridgeTransferId)
{
address initiator = msg.sender;
moveToken.transferFrom(initiator, address(this), amount);

bridgeTransferId = keccak256(abi.encodePacked(initiator, recipient, amount));

emit BridgeTransferInitiated(bridgeTransferId, initiator, recipient, amount, 0);
}

}
24 changes: 0 additions & 24 deletions test/Counter.t.sol

This file was deleted.

35 changes: 35 additions & 0 deletions test/Main.t.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.13;

import {Test, console} from "forge-std/Test.sol";
import "src/DepositV1.sol";
import "src/mock/NativeBridge.sol";
import "@openzeppelin/contracts/token/ERC20/ERC20.sol";
import "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import {deployDepositV1} from "script/Main.s.sol";

contract Move is ERC20 {
constructor() ERC20("Movement", "MOVE") {
_mint(msg.sender, 1000000 * 10 ** decimals());
}
}

contract MainTest is Test {

address gov = address(0x100);
function setUp() public {
ERC20 move = new Move();

NativeBridge bridge = new NativeBridge(address(move));


DepositV1 deposit = deployDepositV1(address(move), gov, address(bridge) );

}

function test_Increment() public {
}

function testFuzz_SetNumber(uint256 x) public {
}
}

0 comments on commit c0aa18a

Please sign in to comment.