Skip to content

Commit

Permalink
cleanups
Browse files Browse the repository at this point in the history
  • Loading branch information
vgeddes committed Oct 27, 2024
1 parent eae219e commit 318b7dc
Show file tree
Hide file tree
Showing 11 changed files with 24 additions and 32 deletions.
13 changes: 5 additions & 8 deletions contracts/scripts/DeployLocal.sol
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import {Gateway} from "../src/Gateway.sol";
import {MockGatewayV2} from "../test/mocks/MockGatewayV2.sol";
import {Agent} from "../src/Agent.sol";
import {AgentExecutor} from "../src/AgentExecutor.sol";
import {Constants} from "../src/Constants.sol";
import {ChannelID, ParaID, OperatingMode} from "../src/Types.sol";
import {Initializer} from "../src/Initializer.sol";
import {SafeNativeTransfer} from "../src/utils/SafeTransfer.sol";
Expand Down Expand Up @@ -59,10 +60,6 @@ contract DeployLocal is Script {
next
);

bytes32 bridgeHubAgentID = vm.envBytes32("BRIDGE_HUB_AGENT_ID");
ParaID assetHubParaID = ParaID.wrap(uint32(vm.envUint("ASSET_HUB_PARAID")));
bytes32 assetHubAgentID = vm.envBytes32("ASSET_HUB_AGENT_ID");

uint8 foreignTokenDecimals = uint8(vm.envUint("FOREIGN_TOKEN_DECIMALS"));
uint128 maxDestinationFee =
uint128(vm.envUint("RESERVE_TRANSFER_MAX_DESTINATION_FEE"));
Expand All @@ -82,8 +79,6 @@ contract DeployLocal is Script {
mode: defaultOperatingMode,
deliveryCost: uint128(vm.envUint("DELIVERY_COST")),
registerTokenFee: uint128(vm.envUint("REGISTER_TOKEN_FEE")),
assetHubParaID: assetHubParaID,
assetHubAgentID: assetHubAgentID,
assetHubCreateAssetFee: uint128(vm.envUint("CREATE_ASSET_FEE")),
assetHubReserveTransferFee: uint128(vm.envUint("RESERVE_TRANSFER_FEE")),
exchangeRate: ud60x18(vm.envUint("EXCHANGE_RATE")),
Expand All @@ -103,8 +98,10 @@ contract DeployLocal is Script {
// of messages originating from BridgeHub
uint256 initialDeposit = vm.envUint("BRIDGE_HUB_INITIAL_DEPOSIT");

address bridgeHubAgent = IGateway(address(gateway)).agentOf(bridgeHubAgentID);
address assetHubAgent = IGateway(address(gateway)).agentOf(assetHubAgentID);
address bridgeHubAgent =
IGateway(address(gateway)).agentOf(Constants.BRIDGE_HUB_AGENT_ID);
address assetHubAgent =
IGateway(address(gateway)).agentOf(Constants.ASSET_HUB_AGENT_ID);

payable(bridgeHubAgent).safeNativeTransfer(initialDeposit);
payable(assetHubAgent).safeNativeTransfer(initialDeposit);
Expand Down
2 changes: 0 additions & 2 deletions contracts/scripts/UpgradeShell.sol
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,6 @@ contract UpgradeShell is Script {
mode: OperatingMode.Normal,
deliveryCost: mDot(100), // 0.1 DOT
registerTokenFee: 0.002 ether,
assetHubParaID: ParaID.wrap(1000),
assetHubAgentID: 0x81c5ab2571199e3188135178f3c2c8e2d268be1313d029b30f534fa579b69b79,
assetHubCreateAssetFee: mDot(100), // 0.1 DOT
assetHubReserveTransferFee: mDot(100), // 0.1 DOT
exchangeRate: ud60x18(0.0024e18),
Expand Down
2 changes: 0 additions & 2 deletions contracts/scripts/westend/UpgradeShell.sol
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,6 @@ contract UpgradeShell is Script {
mode: OperatingMode.Normal,
deliveryCost: 200_000_000_000, // 0.2 Wnd
registerTokenFee: 0.002 ether,
assetHubParaID: ParaID.wrap(1000),
assetHubAgentID: 0x81c5ab2571199e3188135178f3c2c8e2d268be1313d029b30f534fa579b69b79,
assetHubCreateAssetFee: 200_000_000_000, // 0.2 Wnd
assetHubReserveTransferFee: 200_000_000_000, // 0.2 Wnd
exchangeRate: ud60x18(2_400_000_000_000_000),
Expand Down
10 changes: 4 additions & 6 deletions contracts/src/Initializer.sol
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,6 @@ library Initializer {
uint128 deliveryCost;
/// @dev The ETH/DOT exchange rate
UD60x18 exchangeRate;
ParaID assetHubParaID;
bytes32 assetHubAgentID;
/// @dev The extra fee charged for registering tokens (DOT)
uint128 assetHubCreateAssetFee;
/// @dev The extra fee charged for sending tokens (DOT)
Expand Down Expand Up @@ -94,11 +92,11 @@ library Initializer {
});

// Initialize agent for for AssetHub
address assetHubAgent = address(new Agent(config.assetHubAgentID));
core.agents[config.assetHubAgentID] = assetHubAgent;
address assetHubAgent = address(new Agent(Constants.ASSET_HUB_AGENT_ID));
core.agents[Constants.ASSET_HUB_AGENT_ID] = assetHubAgent;

// Initialize channel for AssetHub
core.channels[config.assetHubParaID.into()] = Channel({
core.channels[Constants.ASSET_HUB_PARA_ID.into()] = Channel({
mode: OperatingMode.Normal,
agent: assetHubAgent,
inboundNonce: 0,
Expand All @@ -114,7 +112,7 @@ library Initializer {
// Initialize assets storage
AssetsStorage.Layout storage assets = AssetsStorage.layout();

assets.assetHubParaID = config.assetHubParaID;
assets.assetHubParaID = Constants.ASSET_HUB_PARA_ID;
assets.assetHubAgent = assetHubAgent;
assets.registerTokenFee = config.registerTokenFee;
assets.assetHubCreateAssetFee = config.assetHubCreateAssetFee;
Expand Down
1 change: 0 additions & 1 deletion contracts/src/SubstrateTypes.sol
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ pragma solidity 0.8.25;

import {ScaleCodec} from "./utils/ScaleCodec.sol";
import {ParaID} from "./v1/Types.sol";
import {TransferKind} from "./v2/Types.sol";

/**
* @title SCALE encoders for common Substrate types
Expand Down
1 change: 0 additions & 1 deletion contracts/src/Types.sol
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ import {CallsV1} from "./v1/Calls.sol";
import {HandlersV1} from "./v1/Handlers.sol";

import {
TransferKind,
InboundMessage as InboundMessageV2,
Command as CommandV2,
CommandKind
Expand Down
9 changes: 9 additions & 0 deletions contracts/src/interfaces/IGateway.sol
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import {
ParaID,
ChannelID
} from "../v1/Types.sol";
import {InboundMessage as InboundMessageV2} from "../v2/Types.sol";
import {Verification} from "../Verification.sol";
import {UD60x18} from "prb/math/src/UD60x18.sol";

Expand Down Expand Up @@ -173,6 +174,14 @@ interface IGateway {

// V2

// Submit a message for verification and dispatch
function v2_submit(
InboundMessageV2 calldata message,
bytes32[] calldata leafProof,
Verification.Proof calldata headerProof,
bytes32 rewardAddress
) external;

// Send an XCM with arbitrary assets to Polkadot Asset Hub
//
// Params:
Expand Down
2 changes: 1 addition & 1 deletion contracts/src/v2/Calls.sol
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import {Upgrade} from "../Upgrade.sol";
import {Functions} from "../Functions.sol";
import {Constants} from "../Constants.sol";

import {Ticket, TransferKind, OperatingMode} from "./Types.sol";
import {Ticket, OperatingMode} from "./Types.sol";

import {UD60x18, ud60x18, convert} from "prb/math/src/UD60x18.sol";

Expand Down
1 change: 0 additions & 1 deletion contracts/src/v2/Handlers.sol
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ import {Functions} from "../Functions.sol";
import {Constants} from "../Constants.sol";

import {
TransferKind,
UpgradeParams,
SetOperatingModeParams,
UnlockNativeTokenParams,
Expand Down
5 changes: 0 additions & 5 deletions contracts/src/v2/Types.sol
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,6 @@ struct Ticket {
uint256 reward;
}

enum TransferKind {
NativeERC20,
ForeignERC20
}

// V2 Command Params

// Payload for Upgrade
Expand Down
10 changes: 5 additions & 5 deletions contracts/test/GatewayV1.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ import {TokenLib} from "../src/TokenLib.sol";
import {Token} from "../src/Token.sol";

import {Initializer} from "../src/Initializer.sol";
import {Constants} from "../src/Constants.sol";

import {
UpgradeParams,
Expand Down Expand Up @@ -67,7 +68,7 @@ import {
import {WETH9} from "canonical-weth/WETH9.sol";
import {UD60x18, ud60x18, convert} from "prb/math/src/UD60x18.sol";

contract GatewayTest is Test {
contract GatewayV1Test is Test {
// Emitted when token minted/burnt/transfered
event Transfer(address indexed from, address indexed to, uint256 value);

Expand Down Expand Up @@ -124,8 +125,6 @@ contract GatewayTest is Test {
mode: OperatingMode.Normal,
deliveryCost: outboundFee,
registerTokenFee: registerTokenFee,
assetHubParaID: assetHubParaID,
assetHubAgentID: assetHubAgentID,
assetHubCreateAssetFee: createTokenFee,
assetHubReserveTransferFee: sendTokenFee,
exchangeRate: exchangeRate,
Expand All @@ -143,8 +142,9 @@ contract GatewayTest is Test {
abi.encode(params)
);

bridgeHubAgent = IGateway(address(gateway)).agentOf(bridgeHubAgentID);
assetHubAgent = IGateway(address(gateway)).agentOf(assetHubAgentID);
bridgeHubAgent =
IGateway(address(gateway)).agentOf(Constants.BRIDGE_HUB_AGENT_ID);
assetHubAgent = IGateway(address(gateway)).agentOf(Constants.ASSET_HUB_AGENT_ID);

// fund the message relayer account
relayer = makeAddr("relayer");
Expand Down

0 comments on commit 318b7dc

Please sign in to comment.