Skip to content

Commit

Permalink
validate and execute send token
Browse files Browse the repository at this point in the history
  • Loading branch information
alistair-singh committed Jan 22, 2024
1 parent 2710a25 commit fbb1a42
Show file tree
Hide file tree
Showing 25 changed files with 711 additions and 612 deletions.
6 changes: 1 addition & 5 deletions contracts/src/DeployScript.sol
Original file line number Diff line number Diff line change
Expand Up @@ -61,11 +61,7 @@ contract DeployScript is Script {

AgentExecutor executor = new AgentExecutor();
Gateway gatewayLogic = new Gateway(
address(beefyClient),
address(executor),
bridgeHubParaID,
bridgeHubAgentID,
foreignTokenDecimals
address(beefyClient), address(executor), bridgeHubParaID, bridgeHubAgentID, foreignTokenDecimals
);

bool rejectOutboundMessages = vm.envBool("REJECT_OUTBOUND_MESSAGES");
Expand Down
2 changes: 0 additions & 2 deletions contracts/src/Gateway.sol
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,6 @@ contract Gateway is IGateway, IInitializable {
/**
* Getters
*/

function operatingMode() external view returns (OperatingMode) {
return CoreStorage.layout().mode;
}
Expand Down Expand Up @@ -396,7 +395,6 @@ contract Gateway is IGateway, IInitializable {
/**
* Assets
*/

function isTokenRegistered(address token) external view returns (bool) {
return Assets.isTokenRegistered(token);
}
Expand Down
4 changes: 3 additions & 1 deletion contracts/src/Types.sol
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,9 @@ enum Command {
SetPricingParameters
}

enum AgentExecuteCommand {TransferToken}
enum AgentExecuteCommand {
TransferToken
}

/// @dev Application-level costs for a message
struct Costs {
Expand Down
3 changes: 1 addition & 2 deletions contracts/src/interfaces/IGateway.sol
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ interface IGateway {
/**
* Getters
*/

function operatingMode() external view returns (OperatingMode);
function channelOperatingModeOf(ChannelID channelID) external view returns (OperatingMode);
function channelNoncesOf(ChannelID channelID) external view returns (uint64, uint64);
Expand Down Expand Up @@ -69,8 +68,8 @@ interface IGateway {

/// @dev Emitted once the funds are locked and an outbound message is successfully queued.
event TokenSent(
address indexed token,
address indexed sender,
address indexed token,
ParaID indexed destinationChain,
MultiAddress destinationAddress,
uint128 amount
Expand Down
1 change: 0 additions & 1 deletion contracts/src/utils/Bitfield.sol
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ library Bitfield {
* @dev Constants used to efficiently calculate the hamming weight of a bitfield. See
* https://en.wikipedia.org/wiki/Hamming_weight#Efficient_implementation for an explanation of those constants.
*/

uint256 internal constant M1 = 0x5555555555555555555555555555555555555555555555555555555555555555;
uint256 internal constant M2 = 0x3333333333333333333333333333333333333333333333333333333333333333;
uint256 internal constant M4 = 0x0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f;
Expand Down
1 change: 1 addition & 0 deletions contracts/src/utils/Math.sol
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ library Math {
Ceil, // Toward positive infinity
Trunc, // Toward zero
Expand // Away from zero

}

/**
Expand Down
1 change: 0 additions & 1 deletion contracts/src/utils/Uint16Array.sol
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ pragma solidity 0.8.23;
* above table counter XX is at logical index 22. It will convert to a physical index of 1 in the array and
* then to bit-index 96 to 111 of uint256[1].
*/

using {get, set} for Uint16Array global;

error IndexOutOfBounds();
Expand Down
18 changes: 3 additions & 15 deletions contracts/test/Gateway.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -93,13 +93,8 @@ contract GatewayTest is Test {

function setUp() public {
AgentExecutor executor = new AgentExecutor();
gatewayLogic = new GatewayMock(
address(0),
address(executor),
bridgeHubParaID,
bridgeHubAgentID,
foreignTokenDecimals
);
gatewayLogic =
new GatewayMock(address(0), address(executor), bridgeHubParaID, bridgeHubAgentID, foreignTokenDecimals);
Gateway.Config memory config = Gateway.Config({
mode: OperatingMode.Normal,
deliveryCost: outboundFee,
Expand All @@ -110,10 +105,7 @@ contract GatewayTest is Test {
assetHubReserveTransferFee: sendTokenFee,
exchangeRate: exchangeRate
});
gateway = new GatewayProxy(
address(gatewayLogic),
abi.encode(config)
);
gateway = new GatewayProxy(address(gatewayLogic), abi.encode(config));
GatewayMock(address(gateway)).setCommitmentsAreVerified(true);

SetOperatingModeParams memory params = SetOperatingModeParams({mode: OperatingMode.Normal});
Expand Down Expand Up @@ -176,7 +168,6 @@ contract GatewayTest is Test {
/**
* Message Verification
*/

function testSubmitHappyPath() public {
deal(assetHubAgent, 50 ether);

Expand Down Expand Up @@ -344,7 +335,6 @@ contract GatewayTest is Test {
/**
* Handlers
*/

function testAgentExecution() public {
token.transfer(address(assetHubAgent), 200);

Expand Down Expand Up @@ -562,7 +552,6 @@ contract GatewayTest is Test {
/**
* Assets
*/

function testRegisterToken() public {
vm.expectEmit(false, false, false, true);
emit IGateway.TokenRegistrationSent(address(token));
Expand Down Expand Up @@ -679,7 +668,6 @@ contract GatewayTest is Test {
/**
* Operating Modes
*/

function testDisableOutboundMessaging() public {
// Let gateway lock up to 1 tokens
token.approve(address(gateway), 1);
Expand Down
1 change: 0 additions & 1 deletion contracts/test/mocks/GatewayUpgradeMock.sol
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ contract GatewayUpgradeMock is IGateway, IInitializable {
/**
* Getters
*/

function operatingMode() external pure returns (OperatingMode) {
return OperatingMode.Normal;
}
Expand Down
2 changes: 1 addition & 1 deletion relayer/contracts/beefy_client.go

Large diffs are not rendered by default.

34 changes: 17 additions & 17 deletions relayer/contracts/gateway.go

Large diffs are not rendered by default.

16 changes: 8 additions & 8 deletions web/packages/api/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,14 @@
"typescript": "^5.1.6"
},
"dependencies": {
"@ethersproject/abi": "^5.7.0",
"@ethersproject/bytes": "^5.7.0",
"@ethersproject/providers": "^5.7.0",
"@ethersproject/units": "^5.7.0",
"@polkadot/api": "^10.10.1",
"@polkadot/types": "^10.10.1",
"ethers": "^6.9.0",
"@polkadot/api": "^10.11.1",
"@polkadot/types": "^10.11.1",
"@polkadot/util": "^12.6.1",
"@polkadot/util-crypto": "^12.6.1",
"@polkadot/keyring": "^12.6.1",
"@snowbridge/contract-types": "workspace:*",
"@typechain/ethers-v5": "^11.1.1",
"ethers": "^5.7.0"
"@typechain/ethers-v6": "^0.5.1",
"rxjs": "^7.8.1"
}
}
Loading

0 comments on commit fbb1a42

Please sign in to comment.