Skip to content

Commit ae16ecd

Browse files
committed
Merge branch 'timfn/21856-prep-for-bn-service-client' into timfn/21856-add-bn-service-client
2 parents 7ee63f7 + 597ba0c commit ae16ecd

File tree

16 files changed

+1776
-769
lines changed

16 files changed

+1776
-769
lines changed

.github/workflows/node-zxc-build-release-artifact.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,12 @@ jobs:
143143
semver --version
144144
echo "::endgroup::"
145145
146+
- name: Checkout Code
147+
if: ${{ github.event.repository.private == true }}
148+
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
149+
with:
150+
ref: ${{ inputs.ref || '' }}
151+
146152
- name: Verify Workflow Parameters
147153
id: parameters
148154
env:

hapi/hedera-protobuf-java-api/src/main/proto/fees/fee_schedule.proto

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,10 @@ enum Extra {
9797
CRYPTO_TRANSFER_BASE_FUNGIBLE_CUSTOM_FEES=19;
9898
CRYPTO_TRANSFER_BASE_NFT_CUSTOM_FEES=20;
9999
HOOK_EXECUTION=21;
100+
TOKEN_CREATE_FUNGIBLE=22;
101+
TOKEN_CREATE_NFT=23;
102+
TOKEN_MINT_FUNGIBLE=24;
103+
TOKEN_MINT_NFT=25;
100104
}
101105

102106
/**

hedera-node/hedera-app/src/main/java/com/hedera/node/app/workflows/dispatcher/TransactionDispatcher.java

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -148,11 +148,16 @@ private boolean shouldUseSimpleFees(FeeContext feeContext) {
148148
CRYPTO_TRANSFER,
149149
SCHEDULE_CREATE,
150150
SCHEDULE_SIGN,
151-
SCHEDULE_DELETE,
152-
FILE_CREATE,
153-
FILE_APPEND,
154-
FILE_UPDATE,
155-
FILE_DELETE -> true;
151+
SCHEDULE_DELETE -> true;
152+
case FILE_CREATE, FILE_APPEND, FILE_UPDATE, FILE_DELETE -> true;
153+
case TOKEN_CREATION,
154+
TOKEN_MINT,
155+
TOKEN_BURN,
156+
TOKEN_DELETION,
157+
TOKEN_PAUSE,
158+
TOKEN_FREEZE,
159+
TOKEN_UNPAUSE,
160+
TOKEN_UNFREEZE -> true;
156161
default -> false;
157162
};
158163
}

hedera-node/hedera-file-service-impl/src/main/resources/genesis/simpleFeesSchedules.json

Lines changed: 49 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,21 +20,25 @@
2020
{ "name": "KEYS", "fee": 100000000 },
2121
{ "name": "TOKEN_TYPES", "fee": 0 },
2222
{ "name": "NFT_SERIALS", "fee": 8900000 },
23-
{ "name": "ACCOUNTS", "fee": 0 },
23+
{ "name": "ACCOUNTS", "fee": 1000000 },
2424
{ "name": "FUNGIBLE_TOKENS", "fee": 1000000 },
2525
{ "name": "NON_FUNGIBLE_TOKENS", "fee": 1000000 },
2626
{ "name": "CREATED_AUTO_ASSOCIATIONS", "fee": 0 },
2727
{ "name": "CREATED_ACCOUNTS", "fee": 0 },
2828
{ "name": "CUSTOM_FEE", "fee": 0 },
2929
{ "name": "GAS", "fee": 1 },
3030
{ "name": "ALLOWANCES", "fee": 500000000 },
31+
{ "name": "TOKEN_CREATE_FUNGIBLE", "fee": 9999000000 },
32+
{ "name": "TOKEN_CREATE_NFT", "fee": 19999000000 },
33+
{ "name": "TOKEN_MINT_FUNGIBLE", "fee": 0 },
34+
{ "name": "TOKEN_MINT_NFT", "fee": 199000000 },
3135
{ "name": "AIRDROPS", "fee": 8800 },
3236
{ "name": "HOOK_UPDATES", "fee": 10000000000 },
3337
{ "name": "CRYPTO_TRANSFER_BASE_FUNGIBLE", "fee": 9000000 },
3438
{ "name": "CRYPTO_TRANSFER_BASE_NFT", "fee": 9000000 },
3539
{ "name": "CRYPTO_TRANSFER_BASE_FUNGIBLE_CUSTOM_FEES", "fee": 19000000 },
3640
{ "name": "CRYPTO_TRANSFER_BASE_NFT_CUSTOM_FEES", "fee": 19000000 },
37-
{ "name": "HOOK_EXECUTION", "fee": 50000000 }
41+
{ "name": "HOOK_EXECUTION", "fee": 10000000000 }
3842
],
3943
"services": [
4044
{
@@ -177,13 +181,54 @@
177181
"schedule": [
178182
{
179183
"name": "TokenCreate",
180-
"baseFee": 25,
184+
"baseFee": 0,
181185
"extras": [
186+
{"name": "KEYS", "includedCount": 1},
187+
{"name": "TOKEN_CREATE_FUNGIBLE", "includedCount": 0 },
188+
{"name": "TOKEN_CREATE_NFT", "includedCount": 0 }
182189
]
183190
},
184191
{
185192
"name": "TokenMint",
186-
"baseFee": 33,
193+
"baseFee": 9000000,
194+
"extras": [
195+
{"name": "TOKEN_MINT_FUNGIBLE", "includedCount": 0 },
196+
{"name": "TOKEN_MINT_NFT", "includedCount": 0 }
197+
]
198+
},
199+
{
200+
"name": "TokenBurn",
201+
"baseFee": 9000000,
202+
"extras": [
203+
]
204+
},
205+
{
206+
"name": "TokenDelete",
207+
"baseFee": 9000000,
208+
"extras": [
209+
]
210+
},
211+
{
212+
"name": "TokenFreezeAccount",
213+
"baseFee": 9000000,
214+
"extras": [
215+
]
216+
},
217+
{
218+
"name": "TokenUnfreezeAccount",
219+
"baseFee": 9000000,
220+
"extras": [
221+
]
222+
},
223+
{
224+
"name": "TokenPause",
225+
"baseFee": 9000000,
226+
"extras": [
227+
]
228+
},
229+
{
230+
"name": "TokenUnpause",
231+
"baseFee": 9000000,
187232
"extras": [
188233
{ "name": "FUNGIBLE_TOKENS", "includedCount": 1 },
189234
{ "name": "NON_FUNGIBLE_TOKENS", "includedCount": 1 }

hedera-node/hedera-token-service-impl/src/main/java/com/hedera/node/app/service/token/impl/TokenServiceImpl.java

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,14 @@
1111
import com.hedera.node.app.service.token.impl.calculator.CryptoDeleteFeeCalculator;
1212
import com.hedera.node.app.service.token.impl.calculator.CryptoTransferFeeCalculator;
1313
import com.hedera.node.app.service.token.impl.calculator.CryptoUpdateFeeCalculator;
14+
import com.hedera.node.app.service.token.impl.calculator.TokenBurnFeeCalculator;
15+
import com.hedera.node.app.service.token.impl.calculator.TokenCreateFeeCalculator;
16+
import com.hedera.node.app.service.token.impl.calculator.TokenDeleteFeeCalculator;
17+
import com.hedera.node.app.service.token.impl.calculator.TokenFreezeAccountFeeCalculator;
18+
import com.hedera.node.app.service.token.impl.calculator.TokenMintFeeCalculator;
19+
import com.hedera.node.app.service.token.impl.calculator.TokenPauseFeeCalculator;
20+
import com.hedera.node.app.service.token.impl.calculator.TokenUnfreezeAccountFeeCalculator;
21+
import com.hedera.node.app.service.token.impl.calculator.TokenUnpauseFeeCalculator;
1422
import com.hedera.node.app.service.token.impl.schemas.V0490TokenSchema;
1523
import com.hedera.node.app.service.token.impl.schemas.V0530TokenSchema;
1624
import com.hedera.node.app.service.token.impl.schemas.V0610TokenSchema;
@@ -51,6 +59,14 @@ public Set<ServiceFeeCalculator> serviceFeeCalculators() {
5159
new CryptoDeleteAllowanceFeeCalculator(),
5260
new CryptoDeleteFeeCalculator(),
5361
new CryptoUpdateFeeCalculator(),
54-
new CryptoTransferFeeCalculator());
62+
new CryptoTransferFeeCalculator(),
63+
new TokenCreateFeeCalculator(),
64+
new TokenMintFeeCalculator(),
65+
new TokenPauseFeeCalculator(),
66+
new TokenUnpauseFeeCalculator(),
67+
new TokenFreezeAccountFeeCalculator(),
68+
new TokenUnfreezeAccountFeeCalculator(),
69+
new TokenBurnFeeCalculator(),
70+
new TokenDeleteFeeCalculator());
5571
}
5672
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
// SPDX-License-Identifier: Apache-2.0
2+
package com.hedera.node.app.service.token.impl.calculator;
3+
4+
import static org.hiero.hapi.fees.FeeScheduleUtils.lookupServiceFee;
5+
6+
import com.hedera.hapi.node.base.HederaFunctionality;
7+
import com.hedera.hapi.node.transaction.TransactionBody;
8+
import com.hedera.node.app.spi.fees.FeeContext;
9+
import com.hedera.node.app.spi.fees.ServiceFeeCalculator;
10+
import edu.umd.cs.findbugs.annotations.NonNull;
11+
import edu.umd.cs.findbugs.annotations.Nullable;
12+
import org.hiero.hapi.fees.FeeResult;
13+
import org.hiero.hapi.support.fees.ServiceFeeDefinition;
14+
15+
/** Calculates Token Burn fees. */
16+
public class TokenBurnFeeCalculator implements ServiceFeeCalculator {
17+
18+
@Override
19+
public void accumulateServiceFee(
20+
@NonNull final TransactionBody txnBody,
21+
@Nullable final FeeContext feeContext,
22+
@NonNull final FeeResult feeResult,
23+
@NonNull final org.hiero.hapi.support.fees.FeeSchedule feeSchedule) {
24+
final var op = txnBody.tokenBurnOrThrow();
25+
// Add service base + extras
26+
final ServiceFeeDefinition serviceDef = lookupServiceFee(feeSchedule, HederaFunctionality.TOKEN_BURN);
27+
feeResult.addServiceFee(1, serviceDef.baseFee());
28+
}
29+
30+
public TransactionBody.DataOneOfType getTransactionType() {
31+
return TransactionBody.DataOneOfType.TOKEN_BURN;
32+
}
33+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
// SPDX-License-Identifier: Apache-2.0
2+
package com.hedera.node.app.service.token.impl.calculator;
3+
4+
import static com.hedera.node.app.spi.fees.SimpleFeeCalculatorImpl.countKeys;
5+
import static org.hiero.hapi.fees.FeeScheduleUtils.lookupServiceFee;
6+
7+
import com.hedera.hapi.node.base.HederaFunctionality;
8+
import com.hedera.hapi.node.base.TokenType;
9+
import com.hedera.hapi.node.transaction.TransactionBody;
10+
import com.hedera.node.app.spi.fees.FeeContext;
11+
import com.hedera.node.app.spi.fees.ServiceFeeCalculator;
12+
import edu.umd.cs.findbugs.annotations.NonNull;
13+
import edu.umd.cs.findbugs.annotations.Nullable;
14+
import org.hiero.hapi.fees.FeeResult;
15+
import org.hiero.hapi.support.fees.Extra;
16+
import org.hiero.hapi.support.fees.FeeSchedule;
17+
import org.hiero.hapi.support.fees.ServiceFeeDefinition;
18+
19+
/** Calculates Token Create fees. */
20+
public class TokenCreateFeeCalculator implements ServiceFeeCalculator {
21+
22+
@Override
23+
public void accumulateServiceFee(
24+
@NonNull final TransactionBody txnBody,
25+
@Nullable final FeeContext feeContext,
26+
@NonNull final FeeResult feeResult,
27+
@NonNull final FeeSchedule feeSchedule) {
28+
final ServiceFeeDefinition serviceDef = lookupServiceFee(feeSchedule, HederaFunctionality.TOKEN_CREATE);
29+
feeResult.addServiceFee(1, serviceDef.baseFee());
30+
var op = txnBody.tokenCreationOrThrow();
31+
long keys = 0;
32+
if (op.hasAdminKey()) {
33+
keys += countKeys(op.adminKey());
34+
}
35+
if (op.hasFeeScheduleKey()) {
36+
keys += countKeys(op.feeScheduleKey());
37+
}
38+
if (op.hasFreezeKey()) {
39+
keys += countKeys(op.freezeKey());
40+
}
41+
if (op.hasKycKey()) {
42+
keys += countKeys(op.kycKey());
43+
}
44+
if (op.hasMetadataKey()) {
45+
keys += countKeys(op.metadataKey());
46+
}
47+
if (op.hasPauseKey()) {
48+
keys += countKeys(op.pauseKey());
49+
}
50+
if (op.hasSupplyKey()) {
51+
keys += countKeys(op.supplyKey());
52+
}
53+
if (op.hasWipeKey()) {
54+
keys += countKeys(op.wipeKey());
55+
}
56+
addExtraFee(feeResult, serviceDef, Extra.KEYS, feeSchedule, keys);
57+
58+
if (op.tokenType() == TokenType.FUNGIBLE_COMMON) {
59+
addExtraFee(feeResult, serviceDef, Extra.TOKEN_CREATE_FUNGIBLE, feeSchedule, 1);
60+
}
61+
if (op.tokenType() == TokenType.NON_FUNGIBLE_UNIQUE) {
62+
addExtraFee(feeResult, serviceDef, Extra.TOKEN_CREATE_NFT, feeSchedule, 1);
63+
}
64+
}
65+
66+
@Override
67+
public TransactionBody.DataOneOfType getTransactionType() {
68+
return TransactionBody.DataOneOfType.TOKEN_CREATION;
69+
}
70+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
// SPDX-License-Identifier: Apache-2.0
2+
package com.hedera.node.app.service.token.impl.calculator;
3+
4+
import static org.hiero.hapi.fees.FeeScheduleUtils.lookupServiceFee;
5+
6+
import com.hedera.hapi.node.base.HederaFunctionality;
7+
import com.hedera.hapi.node.transaction.TransactionBody;
8+
import com.hedera.node.app.spi.fees.FeeContext;
9+
import com.hedera.node.app.spi.fees.ServiceFeeCalculator;
10+
import edu.umd.cs.findbugs.annotations.NonNull;
11+
import edu.umd.cs.findbugs.annotations.Nullable;
12+
import org.hiero.hapi.fees.FeeResult;
13+
import org.hiero.hapi.support.fees.ServiceFeeDefinition;
14+
15+
/** Calculates Token Delete fees */
16+
public class TokenDeleteFeeCalculator implements ServiceFeeCalculator {
17+
18+
@Override
19+
public void accumulateServiceFee(
20+
@NonNull final TransactionBody txnBody,
21+
@Nullable final FeeContext feeContext,
22+
@NonNull final FeeResult feeResult,
23+
@NonNull final org.hiero.hapi.support.fees.FeeSchedule feeSchedule) {
24+
final var op = txnBody.tokenDeletionOrThrow();
25+
final ServiceFeeDefinition serviceDef = lookupServiceFee(feeSchedule, HederaFunctionality.TOKEN_DELETE);
26+
feeResult.addServiceFee(1, serviceDef.baseFee());
27+
}
28+
29+
public TransactionBody.DataOneOfType getTransactionType() {
30+
return TransactionBody.DataOneOfType.TOKEN_DELETION;
31+
}
32+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
// SPDX-License-Identifier: Apache-2.0
2+
package com.hedera.node.app.service.token.impl.calculator;
3+
4+
import static org.hiero.hapi.fees.FeeScheduleUtils.lookupServiceFee;
5+
6+
import com.hedera.hapi.node.base.HederaFunctionality;
7+
import com.hedera.hapi.node.transaction.TransactionBody;
8+
import com.hedera.node.app.spi.fees.FeeContext;
9+
import com.hedera.node.app.spi.fees.ServiceFeeCalculator;
10+
import edu.umd.cs.findbugs.annotations.NonNull;
11+
import edu.umd.cs.findbugs.annotations.Nullable;
12+
import org.hiero.hapi.fees.FeeResult;
13+
import org.hiero.hapi.support.fees.ServiceFeeDefinition;
14+
15+
/** Calculates Token Freeze fees */
16+
public class TokenFreezeAccountFeeCalculator implements ServiceFeeCalculator {
17+
18+
@Override
19+
public void accumulateServiceFee(
20+
@NonNull final TransactionBody txnBody,
21+
@Nullable final FeeContext feeContext,
22+
@NonNull final FeeResult feeResult,
23+
@NonNull final org.hiero.hapi.support.fees.FeeSchedule feeSchedule) {
24+
final var op = txnBody.tokenFreezeOrThrow();
25+
final ServiceFeeDefinition serviceDef = lookupServiceFee(feeSchedule, HederaFunctionality.TOKEN_FREEZE_ACCOUNT);
26+
feeResult.addServiceFee(1, serviceDef.baseFee());
27+
}
28+
29+
public TransactionBody.DataOneOfType getTransactionType() {
30+
return TransactionBody.DataOneOfType.TOKEN_FREEZE;
31+
}
32+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
// SPDX-License-Identifier: Apache-2.0
2+
package com.hedera.node.app.service.token.impl.calculator;
3+
4+
import static org.hiero.hapi.fees.FeeScheduleUtils.lookupServiceFee;
5+
6+
import com.hedera.hapi.node.base.HederaFunctionality;
7+
import com.hedera.hapi.node.transaction.TransactionBody;
8+
import com.hedera.node.app.spi.fees.FeeContext;
9+
import com.hedera.node.app.spi.fees.ServiceFeeCalculator;
10+
import edu.umd.cs.findbugs.annotations.NonNull;
11+
import edu.umd.cs.findbugs.annotations.Nullable;
12+
import org.hiero.hapi.fees.FeeResult;
13+
import org.hiero.hapi.support.fees.Extra;
14+
import org.hiero.hapi.support.fees.FeeSchedule;
15+
import org.hiero.hapi.support.fees.ServiceFeeDefinition;
16+
17+
/** Calculates Token Mint fees*/
18+
public class TokenMintFeeCalculator implements ServiceFeeCalculator {
19+
20+
@Override
21+
public void accumulateServiceFee(
22+
@NonNull final TransactionBody txnBody,
23+
@Nullable final FeeContext feeContext,
24+
@NonNull final FeeResult feeResult,
25+
@NonNull final FeeSchedule feeSchedule) {
26+
final ServiceFeeDefinition serviceDef = lookupServiceFee(feeSchedule, HederaFunctionality.TOKEN_MINT);
27+
feeResult.addServiceFee(1, serviceDef.baseFee());
28+
var op = txnBody.tokenMintOrThrow();
29+
if (op.amount() > 0) {
30+
addExtraFee(feeResult, serviceDef, Extra.TOKEN_MINT_FUNGIBLE, feeSchedule, op.amount());
31+
addExtraFee(feeResult, serviceDef, Extra.TOKEN_MINT_NFT, feeSchedule, 0);
32+
} else {
33+
addExtraFee(feeResult, serviceDef, Extra.TOKEN_MINT_FUNGIBLE, feeSchedule, 0);
34+
addExtraFee(
35+
feeResult,
36+
serviceDef,
37+
Extra.TOKEN_MINT_NFT,
38+
feeSchedule,
39+
op.metadata().size());
40+
}
41+
}
42+
43+
@Override
44+
public TransactionBody.DataOneOfType getTransactionType() {
45+
return TransactionBody.DataOneOfType.TOKEN_MINT;
46+
}
47+
}

0 commit comments

Comments
 (0)