Skip to content

Commit

Permalink
add WETH to storage
Browse files Browse the repository at this point in the history
  • Loading branch information
alistair-singh committed Dec 5, 2024
1 parent c7ae26f commit eb4f52f
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 7 deletions.
9 changes: 5 additions & 4 deletions contracts/scripts/DeployLocal.sol
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,9 @@ contract DeployLocal is Script {
defaultOperatingMode = OperatingMode.Normal;
}

// Deploy WETH for testing
address weth = address(new WETH9());

Gateway.Config memory config = Gateway.Config({
mode: defaultOperatingMode,
deliveryCost: uint128(vm.envUint("DELIVERY_COST")),
Expand All @@ -88,14 +91,12 @@ contract DeployLocal is Script {
assetHubReserveTransferFee: uint128(vm.envUint("RESERVE_TRANSFER_FEE")),
exchangeRate: ud60x18(vm.envUint("EXCHANGE_RATE")),
multiplier: ud60x18(vm.envUint("FEE_MULTIPLIER")),
rescueOperator: address(0)
rescueOperator: address(0),
weth: weth
});

GatewayProxy gateway = new GatewayProxy(address(gatewayLogic), abi.encode(config));

// Deploy WETH for testing
new WETH9();

// Fund the sovereign account for the BridgeHub parachain. Used to reward relayers
// of messages originating from BridgeHub
uint256 initialDeposit = vm.envUint("BRIDGE_HUB_INITIAL_DEPOSIT");
Expand Down
2 changes: 2 additions & 0 deletions contracts/src/Gateway.sol
Original file line number Diff line number Diff line change
Expand Up @@ -615,6 +615,8 @@ contract Gateway is IGateway, IInitializable, IUpgradable {
UD60x18 multiplier;
/// @dev Optional rescueOperator
address rescueOperator;
/// @dev The WETH address used for wrapping ETH
address weth;
}

/// Initialize storage within the `GatewayProxy` contract using this initializer.
Expand Down
2 changes: 2 additions & 0 deletions contracts/src/storage/AssetsStorage.sol
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ library AssetsStorage {
uint256 registerTokenFee;
// Foreign token registry by token ID
mapping(bytes32 foreignID => address) tokenAddressOf;
// WETH token address for wrapping ETH
address weth;
}

bytes32 internal constant SLOT = keccak256("org.snowbridge.storage.assets");
Expand Down
8 changes: 5 additions & 3 deletions contracts/test/Gateway.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,9 @@ contract GatewayTest is Test {
gatewayLogic = new MockGateway(
address(0), address(executor), bridgeHubParaID, bridgeHubAgentID, foreignTokenDecimals, maxDestinationFee
);

token = new WETH9();

Gateway.Config memory config = Gateway.Config({
mode: OperatingMode.Normal,
deliveryCost: outboundFee,
Expand All @@ -122,7 +125,8 @@ contract GatewayTest is Test {
assetHubReserveTransferFee: sendTokenFee,
exchangeRate: exchangeRate,
multiplier: multiplier,
rescueOperator: 0x4B8a782D4F03ffcB7CE1e95C5cfe5BFCb2C8e967
rescueOperator: 0x4B8a782D4F03ffcB7CE1e95C5cfe5BFCb2C8e967,
weth: address(token)
});
gateway = new GatewayProxy(address(gatewayLogic), abi.encode(config));
MockGateway(address(gateway)).setCommitmentsAreVerified(true);
Expand All @@ -138,8 +142,6 @@ contract GatewayTest is Test {

// Features

token = new WETH9();

account1 = makeAddr("account1");
account2 = makeAddr("account2");

Expand Down

0 comments on commit eb4f52f

Please sign in to comment.