Skip to content

Commit

Permalink
Rename to sendForeignToken
Browse files Browse the repository at this point in the history
  • Loading branch information
yrong committed Mar 27, 2024
1 parent 3fc6cab commit e53afd0
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 14 deletions.
6 changes: 3 additions & 3 deletions contracts/src/Assets.sol
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ library Assets {
}

// @dev Transfer polkadot native tokens back
function transferToken(
function sendForeignToken(
address executor,
TokenInfo memory info,
address sender,
Expand Down Expand Up @@ -227,12 +227,12 @@ library Assets {

if (destinationAddress.isAddress32()) {
// The receiver has a 32-byte account ID
ticket.payload = SubstrateTypes.TransferTokenToAddress32(
ticket.payload = SubstrateTypes.SendForeignTokenToAddress32(
info.tokenID, destinationChain, destinationAddress.asAddress32(), destinationChainFee, amount
);
} else if (destinationAddress.isAddress20()) {
// The receiver has a 20-byte account ID
ticket.payload = SubstrateTypes.TransferTokenToAddress20(
ticket.payload = SubstrateTypes.SendForeignTokenToAddress20(
info.tokenID, destinationChain, destinationAddress.asAddress20(), destinationChainFee, amount
);
} else {
Expand Down
2 changes: 1 addition & 1 deletion contracts/src/Gateway.sol
Original file line number Diff line number Diff line change
Expand Up @@ -448,7 +448,7 @@ contract Gateway is IGateway, IInitializable {
}
if (info.isForeign) {
_submitOutbound(
Assets.transferToken(
Assets.sendForeignToken(
AGENT_EXECUTOR, info, msg.sender, destinationChain, destinationAddress, destinationFee, amount
)
);
Expand Down
24 changes: 14 additions & 10 deletions contracts/src/SubstrateTypes.sol
Original file line number Diff line number Diff line change
Expand Up @@ -135,11 +135,13 @@ library SubstrateTypes {
}

// destination is AccountID32 address
function TransferTokenToAddress32(bytes32 tokenID, ParaID paraID, bytes32 recipient, uint128 xcmFee, uint128 amount)
internal
view
returns (bytes memory)
{
function SendForeignTokenToAddress32(
bytes32 tokenID,
ParaID paraID,
bytes32 recipient,
uint128 xcmFee,
uint128 amount
) internal view returns (bytes memory) {
return bytes.concat(
bytes1(0x00),
ScaleCodec.encodeU64(uint64(block.chainid)),
Expand All @@ -154,11 +156,13 @@ library SubstrateTypes {
}

// destination is AccountID20 address
function TransferTokenToAddress20(bytes32 tokenID, ParaID paraID, bytes20 recipient, uint128 xcmFee, uint128 amount)
internal
view
returns (bytes memory)
{
function SendForeignTokenToAddress20(
bytes32 tokenID,
ParaID paraID,
bytes20 recipient,
uint128 xcmFee,
uint128 amount
) internal view returns (bytes memory) {
return bytes.concat(
bytes1(0x00),
ScaleCodec.encodeU64(uint64(block.chainid)),
Expand Down

0 comments on commit e53afd0

Please sign in to comment.