Skip to content

Commit

Permalink
Merge branch 'main' into ron/transact-from-eth-to-sub
Browse files Browse the repository at this point in the history
  • Loading branch information
yrong committed Mar 6, 2024
2 parents 2e4140c + 637cb1c commit dd3378e
Show file tree
Hide file tree
Showing 26 changed files with 6,139 additions and 54 deletions.
4 changes: 4 additions & 0 deletions contracts/src/Assets.sol
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ library Assets {
error InvalidDestination();
error TokenNotRegistered();
error Unsupported();
error InvalidDestinationFee();

function isTokenRegistered(address token) external view returns (bool) {
return AssetsStorage.layout().tokenRegistry[token].isRegistered;
Expand Down Expand Up @@ -106,6 +107,9 @@ library Assets {
revert Unsupported();
}
} else {
if (destinationChainFee == 0) {
revert InvalidDestinationFee();
}
// The funds will be minted into sovereign account of the destination parachain on AssetHub,
// and then reserve-transferred to the receiver's account on the destination parachain.
if (destinationAddress.isAddress32()) {
Expand Down
17 changes: 17 additions & 0 deletions contracts/test/Gateway.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -898,6 +898,23 @@ contract GatewayTest is Test {
assertEq(fee, 10000000000000000);
}

function testSendTokenToForeignDestWithInvalidFee() public {
// Let gateway lock up to 1 tokens
token.approve(address(gateway), 1);

// Multilocation for recipient
ParaID destPara = ParaID.wrap(2043);

// register token first
uint256 fee = IGateway(address(gateway)).quoteRegisterTokenFee();
IGateway(address(gateway)).registerToken{value: fee}(address(token));

fee = IGateway(address(gateway)).quoteSendTokenFee(address(token), destPara, 0);

vm.expectRevert(Assets.InvalidDestinationFee.selector);
IGateway(address(gateway)).sendToken{value: fee}(address(token), destPara, recipientAddress32, 0, 1);
}

/**
* Transact
*/
Expand Down
12 changes: 12 additions & 0 deletions control/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# Generated by Cargo
# will have compiled files and executables
**/target/
# These are backup files generated by rustfmt
**/*.rs.bk

*.log

.envrc

# The cache for chain data in container
.local
Loading

0 comments on commit dd3378e

Please sign in to comment.