|
61 | 61 | public class FeeModelRegistry { |
62 | 62 | private static final Map<HederaFunctionality, FeeModel> registry = new LinkedHashMap<>(); |
63 | 63 |
|
| 64 | + private static void register(FeeModel feeModel) { |
| 65 | + registry.put(feeModel.getApi(), feeModel); |
| 66 | + } |
| 67 | + |
64 | 68 | static { |
65 | | - registry.put(CONSENSUS_CREATE_TOPIC, new StandardFeeModel(CONSENSUS_CREATE_TOPIC, "Create a new topic")); |
66 | | - registry.put(CONSENSUS_UPDATE_TOPIC, new StandardFeeModel(CONSENSUS_UPDATE_TOPIC, "Update topic")); |
67 | | - registry.put(CONSENSUS_DELETE_TOPIC, new StandardFeeModel(CONSENSUS_DELETE_TOPIC, "Delete topic")); |
68 | | - registry.put( |
69 | | - CONSENSUS_GET_TOPIC_INFO, new StandardFeeModel(CONSENSUS_GET_TOPIC_INFO, "Get metadata for a topic")); |
70 | | - registry.put( |
71 | | - CONSENSUS_SUBMIT_MESSAGE, new StandardFeeModel(CONSENSUS_SUBMIT_MESSAGE, "Submit message to topic")); |
| 69 | + register(new StandardFeeModel(CONSENSUS_CREATE_TOPIC, "Create a new topic")); |
| 70 | + register(new StandardFeeModel(CONSENSUS_UPDATE_TOPIC, "Update topic")); |
| 71 | + register(new StandardFeeModel(CONSENSUS_DELETE_TOPIC, "Delete topic")); |
| 72 | + register(new StandardFeeModel(CONSENSUS_GET_TOPIC_INFO, "Get metadata for a topic")); |
| 73 | + register(new StandardFeeModel(CONSENSUS_SUBMIT_MESSAGE, "Submit message to topic")); |
72 | 74 |
|
73 | | - registry.put(FILE_CREATE, new StandardFeeModel(FILE_CREATE, "Create file")); |
74 | | - registry.put(FILE_APPEND, new StandardFeeModel(FILE_APPEND, "Append to file")); |
75 | | - registry.put(FILE_UPDATE, new StandardFeeModel(FILE_UPDATE, "Update file")); |
76 | | - registry.put(FILE_DELETE, new StandardFeeModel(FILE_DELETE, "Delete file")); |
77 | | - registry.put(FILE_GET_CONTENTS, new StandardFeeModel(FILE_GET_CONTENTS, "Get file contents")); |
78 | | - registry.put(FILE_GET_INFO, new StandardFeeModel(FILE_GET_INFO, "Get file info")); |
| 75 | + register(new StandardFeeModel(FILE_CREATE, "Create file")); |
| 76 | + register(new StandardFeeModel(FILE_APPEND, "Append to file")); |
| 77 | + register(new StandardFeeModel(FILE_UPDATE, "Update file")); |
| 78 | + register(new StandardFeeModel(FILE_DELETE, "Delete file")); |
| 79 | + register(new StandardFeeModel(FILE_GET_CONTENTS, "Get file contents")); |
| 80 | + register(new StandardFeeModel(FILE_GET_INFO, "Get file info")); |
79 | 81 |
|
80 | | - registry.put(CRYPTO_TRANSFER, new StandardFeeModel(CRYPTO_TRANSFER, "Transfer tokens among accounts")); |
81 | | - registry.put(CRYPTO_UPDATE, new StandardFeeModel(CRYPTO_UPDATE, "Update an account")); |
82 | | - registry.put(CRYPTO_DELETE, new StandardFeeModel(CRYPTO_DELETE, "Delete an account")); |
83 | | - registry.put(CRYPTO_CREATE, new StandardFeeModel(CRYPTO_CREATE, "Create a new account")); |
84 | | - registry.put( |
85 | | - CRYPTO_APPROVE_ALLOWANCE, |
86 | | - new StandardFeeModel(CRYPTO_APPROVE_ALLOWANCE, "Approve an allowance for a spender")); |
87 | | - registry.put( |
88 | | - CRYPTO_DELETE_ALLOWANCE, |
89 | | - new StandardFeeModel(CRYPTO_DELETE_ALLOWANCE, "Delete an allowance for a spender")); |
| 82 | + register(new StandardFeeModel(CRYPTO_TRANSFER, "Transfer tokens among accounts")); |
| 83 | + register(new StandardFeeModel(CRYPTO_UPDATE, "Update an account")); |
| 84 | + register(new StandardFeeModel(CRYPTO_DELETE, "Delete an account")); |
| 85 | + register(new StandardFeeModel(CRYPTO_CREATE, "Create a new account")); |
| 86 | + register(new StandardFeeModel(CRYPTO_APPROVE_ALLOWANCE, "Approve an allowance for a spender")); |
| 87 | + register(new StandardFeeModel(CRYPTO_DELETE_ALLOWANCE, "Delete an allowance for a spender")); |
90 | 88 |
|
91 | | - registry.put(CONTRACT_CALL, new StandardFeeModel(CONTRACT_CALL, "Execute a smart contract call")); |
92 | | - registry.put(CONTRACT_CREATE, new StandardFeeModel(CONTRACT_CREATE, "Create a smart contract")); |
93 | | - registry.put(CONTRACT_UPDATE, new StandardFeeModel(CONTRACT_UPDATE, "Update a smart contract")); |
94 | | - registry.put( |
95 | | - CONTRACT_GET_INFO, new StandardFeeModel(CONTRACT_GET_INFO, "Get information about a smart contract")); |
96 | | - registry.put( |
97 | | - CONTRACT_GET_BYTECODE, |
98 | | - new StandardFeeModel(CONTRACT_GET_BYTECODE, "Get the compiled bytecode for a smart contract")); |
99 | | - registry.put(CONTRACT_DELETE, new StandardFeeModel(CONTRACT_DELETE, "Delete a smart contract")); |
| 89 | + register(new StandardFeeModel(CONTRACT_CALL, "Execute a smart contract call")); |
| 90 | + register(new StandardFeeModel(CONTRACT_CREATE, "Create a smart contract")); |
| 91 | + register(new StandardFeeModel(CONTRACT_UPDATE, "Update a smart contract")); |
| 92 | + register(new StandardFeeModel(CONTRACT_GET_INFO, "Get information about a smart contract")); |
| 93 | + register(new StandardFeeModel(CONTRACT_GET_BYTECODE, "Get the compiled bytecode for a smart contract")); |
| 94 | + register(new StandardFeeModel(CONTRACT_DELETE, "Delete a smart contract")); |
100 | 95 |
|
101 | | - registry.put(TOKEN_CREATE, new StandardFeeModel(TOKEN_CREATE, "Create a token")); |
102 | | - registry.put(TOKEN_GET_INFO, new StandardFeeModel(TOKEN_GET_INFO, "Get metadata for a token")); |
103 | | - registry.put( |
104 | | - TOKEN_FREEZE_ACCOUNT, |
105 | | - new StandardFeeModel(TOKEN_FREEZE_ACCOUNT, "Freeze a specific account with respect to a token")); |
106 | | - registry.put( |
107 | | - TOKEN_UNFREEZE_ACCOUNT, |
108 | | - new StandardFeeModel(TOKEN_UNFREEZE_ACCOUNT, "Unfreeze a specific account with respect to a token")); |
109 | | - registry.put( |
110 | | - TOKEN_GRANT_KYC_TO_ACCOUNT, |
111 | | - new StandardFeeModel( |
112 | | - TOKEN_GRANT_KYC_TO_ACCOUNT, "Grant KYC status to an account for a specific token")); |
113 | | - registry.put( |
114 | | - TOKEN_REVOKE_KYC_FROM_ACCOUNT, |
115 | | - new StandardFeeModel( |
116 | | - TOKEN_REVOKE_KYC_FROM_ACCOUNT, "Revoke KYC status from an account for a specific token")); |
117 | | - registry.put(TOKEN_DELETE, new StandardFeeModel(TOKEN_DELETE, "Delete a specific token")); |
118 | | - registry.put(TOKEN_UPDATE, new StandardFeeModel(TOKEN_UPDATE, "Update a specific token")); |
119 | | - registry.put(TOKEN_MINT, new StandardFeeModel(TOKEN_MINT, "Mint tokens")); |
120 | | - registry.put(TOKEN_BURN, new StandardFeeModel(TOKEN_BURN, "Burn tokens")); |
121 | | - registry.put( |
122 | | - TOKEN_ACCOUNT_WIPE, new StandardFeeModel(TOKEN_ACCOUNT_WIPE, "Wipe all amounts for a specific token")); |
123 | | - registry.put( |
124 | | - TOKEN_ASSOCIATE_TO_ACCOUNT, |
125 | | - new StandardFeeModel(TOKEN_ASSOCIATE_TO_ACCOUNT, "Associate account to a specific token")); |
126 | | - registry.put( |
127 | | - TOKEN_DISSOCIATE_FROM_ACCOUNT, |
128 | | - new StandardFeeModel(TOKEN_DISSOCIATE_FROM_ACCOUNT, "Dissociate account from a specific token")); |
129 | | - registry.put(TOKEN_PAUSE, new StandardFeeModel(TOKEN_PAUSE, "Pause a specific token")); |
130 | | - registry.put(TOKEN_UNPAUSE, new StandardFeeModel(TOKEN_UNPAUSE, "Unpause a specific token")); |
131 | | - registry.put(TOKEN_UPDATE_NFTS, new StandardFeeModel(TOKEN_UPDATE_NFTS, "Update metadata of an NFT token")); |
132 | | - registry.put(TOKEN_REJECT, new StandardFeeModel(TOKEN_REJECT, "Reject a token")); |
133 | | - registry.put(TOKEN_AIRDROP, new StandardFeeModel(TOKEN_AIRDROP, "Airdrop one or more tokens")); |
134 | | - registry.put(TOKEN_CANCEL_AIRDROP, new StandardFeeModel(TOKEN_CANCEL_AIRDROP, "Cancel pending airdrops")); |
135 | | - registry.put(TOKEN_CLAIM_AIRDROP, new StandardFeeModel(TOKEN_CLAIM_AIRDROP, "Claim pending airdrops")); |
| 96 | + register(new StandardFeeModel(TOKEN_CREATE, "Create a token")); |
| 97 | + register(new StandardFeeModel(TOKEN_GET_INFO, "Get metadata for a token")); |
| 98 | + register(new StandardFeeModel(TOKEN_FREEZE_ACCOUNT, "Freeze a specific account with respect to a token")); |
| 99 | + register(new StandardFeeModel(TOKEN_UNFREEZE_ACCOUNT, "Unfreeze a specific account with respect to a token")); |
| 100 | + register(new StandardFeeModel( |
| 101 | + TOKEN_GRANT_KYC_TO_ACCOUNT, "Grant KYC status to an account for a specific token")); |
| 102 | + register(new StandardFeeModel( |
| 103 | + TOKEN_REVOKE_KYC_FROM_ACCOUNT, "Revoke KYC status from an account for a specific token")); |
| 104 | + register(new StandardFeeModel(TOKEN_DELETE, "Delete a specific token")); |
| 105 | + register(new StandardFeeModel(TOKEN_UPDATE, "Update a specific token")); |
| 106 | + register(new StandardFeeModel(TOKEN_MINT, "Mint tokens")); |
| 107 | + register(new StandardFeeModel(TOKEN_BURN, "Burn tokens")); |
| 108 | + register(new StandardFeeModel(TOKEN_ACCOUNT_WIPE, "Wipe all amounts for a specific token")); |
| 109 | + register(new StandardFeeModel(TOKEN_ASSOCIATE_TO_ACCOUNT, "Associate account to a specific token")); |
| 110 | + register(new StandardFeeModel(TOKEN_DISSOCIATE_FROM_ACCOUNT, "Dissociate account from a specific token")); |
| 111 | + register(new StandardFeeModel(TOKEN_PAUSE, "Pause a specific token")); |
| 112 | + register(new StandardFeeModel(TOKEN_UNPAUSE, "Unpause a specific token")); |
| 113 | + register(new StandardFeeModel(TOKEN_UPDATE_NFTS, "Update metadata of an NFT token")); |
| 114 | + register(new StandardFeeModel(TOKEN_REJECT, "Reject a token")); |
| 115 | + register(new StandardFeeModel(TOKEN_AIRDROP, "Airdrop one or more tokens")); |
| 116 | + register(new StandardFeeModel(TOKEN_CANCEL_AIRDROP, "Cancel pending airdrops")); |
| 117 | + register(new StandardFeeModel(TOKEN_CLAIM_AIRDROP, "Claim pending airdrops")); |
136 | 118 |
|
137 | | - registry.put(SCHEDULE_CREATE, new StandardFeeModel(SCHEDULE_CREATE, "Create a scheduled transaction")); |
138 | | - registry.put(SCHEDULE_DELETE, new StandardFeeModel(SCHEDULE_DELETE, "Delete a scheduled transaction")); |
139 | | - registry.put(SCHEDULE_SIGN, new StandardFeeModel(SCHEDULE_SIGN, "Sign a scheduled transaction")); |
140 | | - registry.put( |
141 | | - SCHEDULE_GET_INFO, new StandardFeeModel(SCHEDULE_GET_INFO, "Get metadata for a scheduled transaction")); |
| 119 | + register(new StandardFeeModel(SCHEDULE_CREATE, "Create a scheduled transaction")); |
| 120 | + register(new StandardFeeModel(SCHEDULE_DELETE, "Delete a scheduled transaction")); |
| 121 | + register(new StandardFeeModel(SCHEDULE_SIGN, "Sign a scheduled transaction")); |
| 122 | + register(new StandardFeeModel(SCHEDULE_GET_INFO, "Get metadata for a scheduled transaction")); |
142 | 123 | } |
143 | 124 |
|
144 | 125 | public static FeeModel lookupModel(HederaFunctionality service) { |
145 | 126 | if (!registry.containsKey(service)) { |
146 | | - throw new IllegalArgumentException("No registered model found for service " + service); |
| 127 | + throw new IllegalArgumentException("No registered model found for service " + service.protoName()); |
147 | 128 | } |
148 | 129 | return registry.get(service); |
149 | 130 | } |
|
0 commit comments