diff --git a/contracts/scripts/DeployLocal.sol b/contracts/scripts/DeployLocal.sol index 1eea900455..a5bce42442 100644 --- a/contracts/scripts/DeployLocal.sol +++ b/contracts/scripts/DeployLocal.sol @@ -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"; @@ -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")); @@ -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")), @@ -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); diff --git a/contracts/scripts/UpgradeShell.sol b/contracts/scripts/UpgradeShell.sol index d56b3b8caf..9ee7a9a4c3 100644 --- a/contracts/scripts/UpgradeShell.sol +++ b/contracts/scripts/UpgradeShell.sol @@ -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), diff --git a/contracts/scripts/westend/UpgradeShell.sol b/contracts/scripts/westend/UpgradeShell.sol index 37b32c8c6f..5918e8b0ff 100644 --- a/contracts/scripts/westend/UpgradeShell.sol +++ b/contracts/scripts/westend/UpgradeShell.sol @@ -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), diff --git a/contracts/src/Initializer.sol b/contracts/src/Initializer.sol index 8bde77cc1d..0ce8a11731 100644 --- a/contracts/src/Initializer.sol +++ b/contracts/src/Initializer.sol @@ -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) @@ -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, @@ -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; diff --git a/contracts/src/SubstrateTypes.sol b/contracts/src/SubstrateTypes.sol index 7e2227a522..3be484a208 100644 --- a/contracts/src/SubstrateTypes.sol +++ b/contracts/src/SubstrateTypes.sol @@ -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 diff --git a/contracts/src/Types.sol b/contracts/src/Types.sol index bc3092081e..3a51172696 100644 --- a/contracts/src/Types.sol +++ b/contracts/src/Types.sol @@ -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 diff --git a/contracts/src/interfaces/IGateway.sol b/contracts/src/interfaces/IGateway.sol index b381c187f6..6533253f56 100644 --- a/contracts/src/interfaces/IGateway.sol +++ b/contracts/src/interfaces/IGateway.sol @@ -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"; @@ -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: diff --git a/contracts/src/v2/Calls.sol b/contracts/src/v2/Calls.sol index 48f086aaec..85df1dd517 100644 --- a/contracts/src/v2/Calls.sol +++ b/contracts/src/v2/Calls.sol @@ -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"; diff --git a/contracts/src/v2/Handlers.sol b/contracts/src/v2/Handlers.sol index c37fa6ddac..20a53adab1 100644 --- a/contracts/src/v2/Handlers.sol +++ b/contracts/src/v2/Handlers.sol @@ -20,7 +20,6 @@ import {Functions} from "../Functions.sol"; import {Constants} from "../Constants.sol"; import { - TransferKind, UpgradeParams, SetOperatingModeParams, UnlockNativeTokenParams, diff --git a/contracts/src/v2/Types.sol b/contracts/src/v2/Types.sol index be3ae1a14c..d1cf756c9f 100644 --- a/contracts/src/v2/Types.sol +++ b/contracts/src/v2/Types.sol @@ -38,11 +38,6 @@ struct Ticket { uint256 reward; } -enum TransferKind { - NativeERC20, - ForeignERC20 -} - // V2 Command Params // Payload for Upgrade diff --git a/contracts/test/GatewayV1.t.sol b/contracts/test/GatewayV1.t.sol index fc7d70240c..1352db8336 100644 --- a/contracts/test/GatewayV1.t.sol +++ b/contracts/test/GatewayV1.t.sol @@ -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, @@ -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); @@ -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, @@ -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");