-
Notifications
You must be signed in to change notification settings - Fork 144
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Add TokenUpdateNFTs as a smart contract operation v2 (#15445)
Signed-off-by: Stanimir Stoyanov <stanimir.stoyanov@limechain.tech>
- Loading branch information
1 parent
f51f651
commit aaff32c
Showing
21 changed files
with
725 additions
and
72 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
64 changes: 64 additions & 0 deletions
64
...p/service/contract/impl/exec/systemcontracts/hts/update/UpdateNFTsMetadataTranslator.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
/* | ||
* Copyright (C) 2023-2024 Hedera Hashgraph, LLC | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package com.hedera.node.app.service.contract.impl.exec.systemcontracts.hts.update; | ||
|
||
import com.esaulpaugh.headlong.abi.Function; | ||
import com.hedera.hapi.node.base.AccountID; | ||
import com.hedera.hapi.node.transaction.TransactionBody; | ||
import com.hedera.node.app.service.contract.impl.exec.gas.DispatchType; | ||
import com.hedera.node.app.service.contract.impl.exec.gas.SystemContractGasCalculator; | ||
import com.hedera.node.app.service.contract.impl.exec.systemcontracts.common.AbstractCallTranslator; | ||
import com.hedera.node.app.service.contract.impl.exec.systemcontracts.common.Call; | ||
import com.hedera.node.app.service.contract.impl.exec.systemcontracts.hts.DispatchForResponseCodeHtsCall; | ||
import com.hedera.node.app.service.contract.impl.exec.systemcontracts.hts.HtsCallAttempt; | ||
import com.hedera.node.app.service.contract.impl.exec.systemcontracts.hts.ReturnTypes; | ||
import com.hedera.node.app.service.contract.impl.hevm.HederaWorldUpdater; | ||
import com.hedera.node.config.data.ContractsConfig; | ||
import edu.umd.cs.findbugs.annotations.NonNull; | ||
import javax.inject.Inject; | ||
|
||
public class UpdateNFTsMetadataTranslator extends AbstractCallTranslator<HtsCallAttempt> { | ||
public static final Function UPDATE_NFTs_METADATA = | ||
new Function("updateNFTsMetadata(address,int64[],bytes)", ReturnTypes.INT); | ||
|
||
private final UpdateDecoder decoder; | ||
|
||
@Inject | ||
public UpdateNFTsMetadataTranslator(@NonNull final UpdateDecoder decoder) { | ||
this.decoder = decoder; | ||
} | ||
|
||
@Override | ||
public boolean matches(@NonNull final HtsCallAttempt attempt) { | ||
return attempt.configuration().getConfigData(ContractsConfig.class).systemContractUpdateNFTsMetadataEnabled() | ||
&& attempt.isSelector(UPDATE_NFTs_METADATA); | ||
} | ||
|
||
@Override | ||
public Call callFrom(@NonNull final HtsCallAttempt attempt) { | ||
return new DispatchForResponseCodeHtsCall( | ||
attempt, decoder.decodeUpdateNFTsMetadata(attempt), UpdateNFTsMetadataTranslator::gasRequirement); | ||
} | ||
|
||
public static long gasRequirement( | ||
@NonNull final TransactionBody body, | ||
@NonNull final SystemContractGasCalculator systemContractGasCalculator, | ||
@NonNull final HederaWorldUpdater.Enhancement enhancement, | ||
@NonNull final AccountID payerId) { | ||
return systemContractGasCalculator.gasRequirement(body, DispatchType.TOKEN_UPDATE_NFTS, payerId); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.