Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions contracts/extensions/token-create/TokenCreateContract.sol
Original file line number Diff line number Diff line change
Expand Up @@ -376,4 +376,8 @@ contract TokenCreateContract is HederaTokenService, KeyHelper {
revert ();
}
}

function redirectForTokenPublic(address token, bytes memory encodedFunctionSelector) external returns (int responseCode, bytes memory response) {
(responseCode, response) = HederaTokenService.redirectForToken(token, encodedFunctionSelector);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ contract TokenTransferContract is HederaTokenService {
}

function transferFromPublic(address token, address from, address to, uint256 amount) public returns (int64 responseCode) {
responseCode = this.transferFrom(token, from, to, amount);
responseCode = HederaTokenService.transferFrom(token, from, to, amount);
emit ResponseCode(responseCode);

if (responseCode != HederaResponseCodes.SUCCESS) {
Expand All @@ -63,7 +63,7 @@ contract TokenTransferContract is HederaTokenService {
}

function transferFromNFTPublic(address token, address from, address to, uint256 serialNumber) public returns (int64 responseCode) {
responseCode = this.transferFromNFT(token, from, to, serialNumber);
responseCode = HederaTokenService.transferFromNFT(token, from, to, serialNumber);
emit ResponseCode(responseCode);

if (responseCode != HederaResponseCodes.SUCCESS) {
Expand Down
8 changes: 4 additions & 4 deletions contracts/token-service-v2/HederaTokenService.sol
Original file line number Diff line number Diff line change
Expand Up @@ -473,7 +473,7 @@ abstract contract HederaTokenService {
address from,
address to,
uint256 amount
) external returns (int64 responseCode) {
) internal returns (int64 responseCode) {
(bool success, bytes memory result) = precompileAddress.call(
abi.encodeWithSelector(
IHederaTokenService.transferFrom.selector,
Expand All @@ -500,7 +500,7 @@ abstract contract HederaTokenService {
address from,
address to,
uint256 serialNumber
) external returns (int64 responseCode) {
) internal returns (int64 responseCode) {
(bool success, bytes memory result) = precompileAddress.call(
abi.encodeWithSelector(
IHederaTokenService.transferFromNFT.selector,
Expand Down Expand Up @@ -1119,7 +1119,7 @@ abstract contract HederaTokenService {
function redirectForToken(
address token,
bytes memory encodedFunctionSelector
) external returns (int64 responseCode, bytes memory response) {
) internal returns (int64 responseCode, bytes memory response) {
(bool success, bytes memory result) = precompileAddress.call(
abi.encodeWithSelector(
IHederaTokenService.redirectForToken.selector,
Expand Down Expand Up @@ -1259,7 +1259,7 @@ abstract contract HederaTokenService {
address nftToken,
int64[] memory serialNumbers,
bytes memory metadata
) external returns (int64 responseCode) {
) internal returns (int64 responseCode) {
(bool success, bytes memory result) = precompileAddress.call(
abi.encodeWithSelector(
IHederaTokenService.updateNFTsMetadata.selector,
Expand Down
4 changes: 2 additions & 2 deletions contracts/token-service/AtomicHTS.sol
Original file line number Diff line number Diff line change
Expand Up @@ -84,10 +84,10 @@ contract AtomicHTS is HederaTokenService {
"Failed to associate token."
);

(int grantKYCResponseCode) = HederaTokenService.grantTokenKyc(token, recipient);
(int grantKYCResponseCode) = HederaTokenService.grantTokenKyc(token, recipient);
require(grantKYCResponseCode == HederaResponseCodes.SUCCESS, "Failed to grant token KYC.");

(int transferFromResponseCode) = this.transferFrom(token, spender, recipient, allowance);
(int transferFromResponseCode) = HederaTokenService.transferFrom(token, spender, recipient, allowance);
require(transferFromResponseCode == HederaResponseCodes.SUCCESS, "Failed to transfer token.");

emit BatchApproveAssociateGrantKYCTransferFrom(transferTokenResponseCode, approveResponseCode, associateResponseCode, grantKYCResponseCode, transferFromResponseCode);
Expand Down
6 changes: 3 additions & 3 deletions contracts/token-service/HederaTokenService.sol
Original file line number Diff line number Diff line change
Expand Up @@ -473,7 +473,7 @@ abstract contract HederaTokenService {
address from,
address to,
uint256 amount
) external returns (int64 responseCode) {
) internal returns (int64 responseCode) {
(bool success, bytes memory result) = precompileAddress.call(
abi.encodeWithSelector(
IHederaTokenService.transferFrom.selector,
Expand All @@ -500,7 +500,7 @@ abstract contract HederaTokenService {
address from,
address to,
uint256 serialNumber
) external returns (int64 responseCode) {
) internal returns (int64 responseCode) {
(bool success, bytes memory result) = precompileAddress.call(
abi.encodeWithSelector(
IHederaTokenService.transferFromNFT.selector,
Expand Down Expand Up @@ -1119,7 +1119,7 @@ abstract contract HederaTokenService {
function redirectForToken(
address token,
bytes memory encodedFunctionSelector
) external returns (int64 responseCode, bytes memory response) {
) internal returns (int64 responseCode, bytes memory response) {
(bool success, bytes memory result) = precompileAddress.call(
abi.encodeWithSelector(
IHederaTokenService.redirectForToken.selector,
Expand Down
12 changes: 6 additions & 6 deletions test/token-service/hrc-719/HRC719Contract.js
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ describe('@HRC-719 Test Suite', function () {
describe('redirectoForToken', () => {
it('should be able to execute associate() via redirectForToken', async function () {
const encodedFunc = IHRC719.encodeFunctionData('associate()');
const tx = await tokenCreateContract.redirectForToken(
const tx = await tokenCreateContract.redirectForTokenPublic(
tokenAddress,
encodedFunc,
Constants.GAS_LIMIT_1_000_000,
Expand All @@ -198,15 +198,15 @@ describe('@HRC-719 Test Suite', function () {
it('should be able to execute dissociate() via redirectForToken', async function () {
// first associate the token before dissociate other wise get response_code = 184 instead of 22 (success)
const encodedFuncAssociate = IHRC719.encodeFunctionData('associate()');
const associateTx = await tokenCreateContract.redirectForToken(
const associateTx = await tokenCreateContract.redirectForTokenPublic(
tokenAddress,
encodedFuncAssociate,
Constants.GAS_LIMIT_1_000_000,
);
await associateTx.wait();

const enCodedFuncDissociate = IHRC719.encodeFunctionData('dissociate()');
const dissociateTx = await tokenCreateContract.redirectForToken(
const dissociateTx = await tokenCreateContract.redirectForTokenPublic(
tokenAddress,
enCodedFuncDissociate,
Constants.GAS_LIMIT_1_000_000,
Expand All @@ -219,7 +219,7 @@ describe('@HRC-719 Test Suite', function () {

it('should be able to execute isAssociated() via redirectForToken', async function () {
const encodedFunc = IHRC719.encodeFunctionData('isAssociated()');
const tx = await tokenCreateContract.redirectForToken(
const tx = await tokenCreateContract.redirectForTokenPublic(
tokenAddress,
encodedFunc,
Constants.GAS_LIMIT_1_000_000,
Expand All @@ -231,15 +231,15 @@ describe('@HRC-719 Test Suite', function () {

it('should be able to execute isAssociated() after association via redirectForToken', async function () {
await (
await tokenCreateContract.redirectForToken(
await tokenCreateContract.redirectForTokenPublic(
tokenAddress,
IHRC719.encodeFunctionData('associate()'),
Constants.GAS_LIMIT_1_000_000,
)
).wait();

const encodedFunc = IHRC719.encodeFunctionData('isAssociated()');
const tx = await tokenCreateContract.redirectForToken(
const tx = await tokenCreateContract.redirectForTokenPublic(
tokenAddress,
encodedFunc,
Constants.GAS_LIMIT_1_000_000,
Expand Down
20 changes: 10 additions & 10 deletions test/token-service/redirect-for-token.js
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ describe('RedirectForToken Test Suite', function () {

it('should be able to execute name()', async function () {
const encodedFunc = IERC20.encodeFunctionData('name()');
const tx = await tokenCreateContract.redirectForToken(
const tx = await tokenCreateContract.redirectForTokenPublic(
tokenAddress,
encodedFunc,
);
Expand All @@ -99,7 +99,7 @@ describe('RedirectForToken Test Suite', function () {

it('should be able to execute symbol()', async function () {
const encodedFunc = IERC20.encodeFunctionData('symbol()');
const tx = await tokenCreateContract.redirectForToken(
const tx = await tokenCreateContract.redirectForTokenPublic(
tokenAddress,
encodedFunc,
);
Expand All @@ -110,7 +110,7 @@ describe('RedirectForToken Test Suite', function () {

it('should be able to execute decimals()', async function () {
const encodedFunc = IERC20.encodeFunctionData('decimals()');
const tx = await tokenCreateContract.redirectForToken(
const tx = await tokenCreateContract.redirectForTokenPublic(
tokenAddress,
encodedFunc,
);
Expand All @@ -121,7 +121,7 @@ describe('RedirectForToken Test Suite', function () {

it('should be able to execute totalSupply()', async function () {
const encodedFunc = IERC20.encodeFunctionData('totalSupply()');
const tx = await tokenCreateContract.redirectForToken(
const tx = await tokenCreateContract.redirectForTokenPublic(
tokenAddress,
encodedFunc,
);
Expand All @@ -134,7 +134,7 @@ describe('RedirectForToken Test Suite', function () {
const encodedFuncSigner0 = IERC20.encodeFunctionData('balanceOf(address)', [
signers[0].address,
]);
const tx0 = await tokenCreateContract.redirectForToken(
const tx0 = await tokenCreateContract.redirectForTokenPublic(
tokenAddress,
encodedFuncSigner0,
);
Expand All @@ -145,7 +145,7 @@ describe('RedirectForToken Test Suite', function () {
const encodedFuncSigner1 = IERC20.encodeFunctionData('balanceOf(address)', [
signers[1].address,
]);
const tx1 = await tokenCreateContract.redirectForToken(
const tx1 = await tokenCreateContract.redirectForTokenPublic(
tokenAddress,
encodedFuncSigner1,
);
Expand All @@ -159,7 +159,7 @@ describe('RedirectForToken Test Suite', function () {
signers[1].address,
amount,
]);
const tx = await tokenCreateContract.redirectForToken(
const tx = await tokenCreateContract.redirectForTokenPublic(
tokenAddress,
encodedFunc,
Constants.GAS_LIMIT_10_000_000,
Expand All @@ -173,7 +173,7 @@ describe('RedirectForToken Test Suite', function () {
'allowance(address,address)',
[await tokenCreateContract.getAddress(), signers[1].address],
);
const tx = await tokenCreateContract.redirectForToken(
const tx = await tokenCreateContract.redirectForTokenPublic(
tokenAddress,
encodedFunc,
Constants.GAS_LIMIT_10_000_000,
Expand All @@ -198,7 +198,7 @@ describe('RedirectForToken Test Suite', function () {
signers[1].address,
amount,
]);
const tx = await tokenCreateContract.redirectForToken(
const tx = await tokenCreateContract.redirectForTokenPublic(
tokenAddress,
encodedFunc,
);
Expand Down Expand Up @@ -237,7 +237,7 @@ describe('RedirectForToken Test Suite', function () {
'transferFrom(address,address,uint256)',
[await tokenCreateContract.getAddress(), signers[1].address, amount],
);
const tx = await tokenCreateContract.redirectForToken(
const tx = await tokenCreateContract.redirectForTokenPublic(
tokenAddress,
encodedFunc,
Constants.GAS_LIMIT_1_000_000,
Expand Down
Loading