-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: crypto transfer method implemented (#195) #216
Conversation
Signed-off-by: Mariusz Jasuwienas <[email protected]>
contracts/HtsSystemContract.sol
Outdated
@@ -43,6 +43,119 @@ contract HtsSystemContract is IHederaTokenService, IERC20Events, IERC721Events { | |||
assembly { accountId := sload(slot) } | |||
} | |||
|
|||
function cryptoTransfer(TransferList memory transferList, TokenTransferList[] memory tokenTransfers) | |||
payable htsCall external returns (int64 responseCode) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This method is not yet implemented in the services repository:
so it does not necessarily have to be payable.
contracts/HtsSystemContract.sol
Outdated
@@ -43,6 +43,119 @@ contract HtsSystemContract is IHederaTokenService, IERC20Events, IERC721Events { | |||
assembly { accountId := sload(slot) } | |||
} | |||
|
|||
function cryptoTransfer(TransferList memory transferList, TokenTransferList[] memory tokenTransfers) | |||
payable htsCall external returns (int64 responseCode) { | |||
uint256 hbarsReceived = msg.value; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure we are in the right track here. The wrapper method for cryptoTransfer
https://github.com/hashgraph/hedera-smart-contracts/blob/0a617acfd804131e6f0ad5b7bc46019783f82bad/contracts/system-contracts/hedera-token-service/HederaTokenService.sol#L29-L35 does not pass msg.value
so it does not seem this should be payable
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That is because the HTS is responsible for the hbar transfer then.
/// Performs transfers among combinations of tokens and hbars
To mimic this behaviour and NOT have this method payable we would have to do some vm cheats here (which perhaps is not a bad idea, I will try to figure out the possibilities).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It won't work in hardhat, but is accomplishable in foundry. I'll proceed with implementing that; I'm currently working on adding the approval mechanism.
Also, since I'm using vm deal cheatcodes to change balances now, I have to rethink / double check the validation and assertions.
Signed-off-by: Mariusz Jasuwienas <[email protected]>
Description:
Adding crypto transfer method support to the hts. While calling the address 0x167 you the cryptoTransefer method can be invoked.
Related issue(s):
Fixes #195
Notes for reviewer:
Checklist