-
Notifications
You must be signed in to change notification settings - Fork 0
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
9d78a51
commit c0aa18a
Showing
10 changed files
with
147 additions
and
57 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 |
---|---|---|
@@ -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 |
Submodule openzeppelin-contracts
added at
69c8de
Submodule openzeppelin-contracts-upgradeable
added at
fa5253
This file was deleted.
Oops, something went wrong.
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,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(); | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
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,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); | ||
|
||
|
||
|
||
} | ||
} | ||
|
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,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); | ||
} | ||
|
||
} |
This file was deleted.
Oops, something went wrong.
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,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 { | ||
} | ||
} |