Skip to content

Commit

Permalink
chore: rename token
Browse files Browse the repository at this point in the history
  • Loading branch information
QEDK committed Jan 16, 2024
1 parent 66ac2a8 commit a3be750
Show file tree
Hide file tree
Showing 5 changed files with 63 additions and 16 deletions.
2 changes: 1 addition & 1 deletion script/GetProofMockScript.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ contract GetProofMockScript is Script {
ERC20Mock avail = new ERC20Mock();
bridge.initialize(0, IWrappedAvail(address(avail)), msg.sender, msg.sender, IVectorx(vectorx));
avail.mint(msg.sender, 1 ether);
bridge.sendAVL(bytes32(uint256(1)), 1 ether);
bridge.sendAVAIL(bytes32(uint256(1)), 1 ether);
vm.stopBroadcast();
}
}
47 changes: 47 additions & 0 deletions script/SendMessage.s.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
// SPDX-License-Identifier: Apache-2.0
pragma solidity ^0.8.23;

import {TransparentUpgradeableProxy} from
"lib/openzeppelin-contracts/contracts/proxy/transparent/TransparentUpgradeableProxy.sol";
import {ProxyAdmin} from "lib/openzeppelin-contracts/contracts/proxy/transparent/ProxyAdmin.sol";
import {AvailBridge} from "src/AvailBridge.sol";
import {WrappedAvail} from "src/WrappedAvail.sol";
import {IWrappedAvail} from "src/interfaces/IWrappedAvail.sol";
import {IVectorx} from "src/interfaces/IVectorx.sol";
import {Script} from "forge-std/Script.sol";
import {console} from "forge-std/console.sol";

contract SendMessageScript is Script {
function run() external {
vm.startBroadcast();
address bridgeAddr = vm.envAddress("BRIDGE");
AvailBridge bridge = AvailBridge(bridgeAddr);
// bridge.sendMessage(bytes32(bytes("5GQsUevGEkoxGDJPDWbQiKDxqKmgZ5pGc732x7iXNBa1oAij")), "Hello, World!");
// console.logBytes32(bridge.isSent(0));
// AvailBridge.Message memory message = AvailBridge.Message(
// 0x01,
// bytes32(bytes20(0x681257BED628425a28B469114Dc21A7c30205cFD)),
// bytes32(bytes("5GQsUevGEkoxGDJPDWbQiKDxqKmgZ5pGc732x7iXNBa1oAij")),
// 2,
// 1,
// "Hello, World!",
// 0
// );
// console.logBytes(abi.encode(message));
// console.logBytes32(keccak256(abi.encode(message)));
// bridge.sendETH{value: 1 wei}(bytes32(bytes("5GQsUevGEkoxGDJPDWbQiKDxqKmgZ5pGc732x7iXNBa1oAij")));
// console.logBytes32(bridge.isSent(1));
// AvailBridge.Message memory message = AvailBridge.Message(
// 0x02,
// bytes32(bytes20(0x681257BED628425a28B469114Dc21A7c30205cFD)),
// bytes32(bytes("5GQsUevGEkoxGDJPDWbQiKDxqKmgZ5pGc732x7iXNBa1oAij")),
// 2,
// 1,
// abi.encode(0x4554480000000000000000000000000000000000000000000000000000000000, 1),
// 1
// );
// console.logBytes(abi.encode(message));
// console.logBytes32(keccak256(abi.encode(message)));
vm.stopBroadcast();
}
}
18 changes: 9 additions & 9 deletions src/AvailBridge.sol
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ contract AvailBridge is

/**
* @notice Initializes the AvailBridge contract
* @param newAvail Address of the WAVL token contract
* @param newAvail Address of the WAVAIL token contract
* @param governance Address of the governance multisig
* @param pauser Address of the pauser multisig
* @param newVectorx Address of the VectorX contract
Expand Down Expand Up @@ -226,12 +226,12 @@ contract AvailBridge is
}

/**
* @notice Takes an AVL transfer message and its proof of inclusion, verifies and executes it (if valid)
* @dev This function is used for AVL transfers from Avail to Ethereum
* @notice Takes an AVAIL transfer message and its proof of inclusion, verifies and executes it (if valid)
* @dev This function is used for AVAIL transfers from Avail to Ethereum
* @param message Message that is used to reconstruct the bridge leaf
* @param input Merkle tree proof of inclusion for the bridge leaf
*/
function receiveAVL(Message calldata message, MerkleProofInput calldata input)
function receiveAVAIL(Message calldata message, MerkleProofInput calldata input)
external
whenNotPaused
onlySupportedDomain(message.originDomain, message.destinationDomain)
Expand Down Expand Up @@ -342,12 +342,12 @@ contract AvailBridge is
}

/**
* @notice Burns amount worth of WAVL tokens and bridges it to the specified recipient on Avail
* @dev This function is used for AVL transfers from Ethereum to Avail
* @param recipient Recipient of the AVL tokens on Avail
* @param amount Amount of AVL tokens to bridge
* @notice Burns amount worth of WAVAIL tokens and bridges it to the specified recipient on Avail
* @dev This function is used for WAVAIL transfers from Ethereum to Avail
* @param recipient Recipient of the AVAIL tokens on Avail
* @param amount Amount of AVAIL tokens to bridge
*/
function sendAVL(bytes32 recipient, uint256 amount) external whenNotPaused checkDestAmt(recipient, amount) {
function sendAVAIL(bytes32 recipient, uint256 amount) external whenNotPaused checkDestAmt(recipient, amount) {
uint256 id;
unchecked {
id = messageId++;
Expand Down
2 changes: 1 addition & 1 deletion src/WrappedAvail.sol
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ contract WrappedAvail is ERC20Permit, IWrappedAvail {

error OnlyAvailBridge();

constructor(address _bridge) ERC20Permit("Wrapped Avail") ERC20("WAVL", "Wrapped Avail") {
constructor(address _bridge) ERC20Permit("Wrapped Avail") ERC20("WAVAIL", "Wrapped Avail") {
// slither-disable-next-line missing-zero-check
bridge = _bridge;
}
Expand Down
10 changes: 5 additions & 5 deletions test/AvailBridgeTest.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -284,10 +284,10 @@ contract AvailBridgeTest is Test, MurkyBase {
new bytes32[](0), new bytes32[](0), bytes32(0), 0, bytes32(0), bytes32(0), bytes32(0), 0
);
vm.expectRevert(AvailBridge.InvalidAssetId.selector);
bridge.receiveAVL(message, input);
bridge.receiveAVAIL(message, input);
}

function test_receiveAVL(bytes32 rangeHash, bytes32 from, uint256 amount, uint64 messageId) external {
function test_receiveAVAIL(bytes32 rangeHash, bytes32 from, uint256 amount, uint64 messageId) external {
vm.assume(amount != 0);
address to = makeAddr("to");
AvailBridge.Message memory message =
Expand All @@ -302,7 +302,7 @@ contract AvailBridgeTest is Test, MurkyBase {
AvailBridge.MerkleProofInput(emptyArr, emptyArr, rangeHash, 0, bytes32(0), messageHash, messageHash, 0);

vm.expectCall(address(avail), abi.encodeCall(avail.mint, (to, amount)));
bridge.receiveAVL(message, input);
bridge.receiveAVAIL(message, input);
assertEq(avail.totalSupply(), amount);
}

Expand Down Expand Up @@ -453,7 +453,7 @@ contract AvailBridgeTest is Test, MurkyBase {
assertEq(bridge.isSent(0), keccak256(abi.encode(message)));
}

function test_sendAVL(bytes32 to, uint256 amount) external {
function test_sendAVAIL(bytes32 to, uint256 amount) external {
vm.assume(to != bytes32(0) && amount != 0);
address from = makeAddr("from");
vm.prank(address(bridge));
Expand All @@ -462,7 +462,7 @@ contract AvailBridgeTest is Test, MurkyBase {
AvailBridge.Message(0x02, bytes32(bytes20(from)), to, 2, 1, abi.encode(bytes32(0), amount), 0);
vm.expectCall(address(avail), abi.encodeCall(avail.burn, (from, amount)));
vm.prank(from);
bridge.sendAVL(to, amount);
bridge.sendAVAIL(to, amount);
assertEq(bridge.isSent(0), keccak256(abi.encode(message)));
assertEq(avail.balanceOf(from), 0);
assertEq(avail.totalSupply(), 0);
Expand Down

0 comments on commit a3be750

Please sign in to comment.