-
Notifications
You must be signed in to change notification settings - Fork 112
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
HIP-18 enhancement #2419
HIP-18 enhancement #2419
Conversation
- add sql script to add missing token-treasury association Signed-off-by: Xin Li <[email protected]>
…andling Signed-off-by: Xin Li <[email protected]>
Signed-off-by: Xin Li <[email protected]>
Signed-off-by: Xin Li <[email protected]>
… the same way for treasury and auto enabled fee collectors Signed-off-by: Xin Li <[email protected]>
…ssociated Signed-off-by: Xin Li <[email protected]>
Signed-off-by: Xin Li <[email protected]>
Signed-off-by: Xin Li <[email protected]>
Signed-off-by: Xin Li <[email protected]>
Signed-off-by: Xin Li <[email protected]>
Signed-off-by: Xin Li <[email protected]>
Signed-off-by: Xin Li <[email protected]>
Signed-off-by: Xin Li <[email protected]>
Signed-off-by: Xin Li <[email protected]>
Signed-off-by: Xin Li <[email protected]>
Signed-off-by: Xin Li <[email protected]>
Signed-off-by: Xin Li <[email protected]>
Codecov Report
@@ Coverage Diff @@
## main #2419 +/- ##
============================================
+ Coverage 84.42% 84.49% +0.07%
- Complexity 2335 2346 +11
============================================
Files 440 441 +1
Lines 12018 12073 +55
Branches 1024 1029 +5
============================================
+ Hits 10146 10201 +55
Misses 1554 1554
Partials 318 318
Continue to review full report at Codecov.
|
@@ -61,7 +61,7 @@ | |||
"custom_fees": { | |||
"created_timestamp": "1234567890.000000002", | |||
"fixed_fees": [], | |||
"fractional_fees": [] | |||
"royalty_fees": [] |
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 is indeed a bug: nft
token type won't have fractional_fees
Signed-off-by: Xin Li <[email protected]>
…tests Signed-off-by: Xin Li <[email protected]>
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.
1st pass, moving onto OpenAPI with newly pushed commit
* @param tokenId the attached token id | ||
* @return whether the fee is paid in the attached token | ||
*/ | ||
private boolean parseFixedFee(CustomFee customFee, FixedFee fixedFee, EntityId tokenId) { |
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.
function is doing 2 things.
Better to simplify by removing return logic and moving check to it's own method in the CustomFee
class
private boolean isChargedInToken(EntityId tokenId) {
return !EntityId.isEmpty(tokenId) && denominatingTokenId.equals(tokenId);
}
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.
made the change to encapsulate the logic: the function parseFixedFee
does the parsing and so it surely knows whether the fixed fee's denominating token is the attached token.
For the other two types of fees the answer to the question 'do you charge in the attached token' is rather obvious, so doesn't need to follow the pattern.
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.
I see the change here.
Not fully what I was suggesting as I was suggesting move the logic to the CustomFee domain class so that this method returned void. Then in the FIXED FEE case above you'd update the call flow.
Highlighted the example below.
parseFixedFee(customFee, protoCustomFee.getFixedFee(), tokenId);
chargedInAttachedToken = customFee.isChargedInToken(tokenId);
In fact if we passed along the protoCustomFee.getFeeCase()
to the CustomFee domain it would further simplify and centralize the chargedInAttachedToken
logic.
No need to change it here though
.../src/main/java/com/hedera/mirror/importer/parser/record/entity/EntityRecordItemListener.java
Outdated
Show resolved
Hide resolved
if (token.type === 'NON_FUNGIBLE_UNIQUE') { | ||
token.decimals = 0; | ||
token.initial_supply = 0; | ||
} |
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.
NFTs must have decimals = 0 and initial_supply = 0 according to HAPI spec
Signed-off-by: Xin Li <[email protected]>
docs/design/custom-fees.md
Outdated
amount bigint not null, | ||
collector_account_id bigint not null, | ||
consensus_timestamp bigint not null, | ||
effective_payer_account_id bigint, |
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 duplicates all info for each effective payer account. We should normalize this out into another table assessed_custom_fee_payer
to reduce the duplication.
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'll actually create more duplication since that table will be the same as the new assessed_custom_fee
table: only (amount, collector_account_id, consensus_timestamp, token_id) uniquely identifies one assessed custom fee in a transaction paid by a list of payers to the same collector in the same denominating token (or hbar)...
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.
postgresql supports arrays, we can alternatively have such a single column effective_payer_account_ids
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.
I like the array idea
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.
If we don't use the array, the idea would be to add a generated ID (UUID preferrably) as primary key to assessed_custom_fee and have a foreign key. Then the other table only needs foreign ID and payer account. We kind of need a primary key anyway as there's none now and distributed sqls need one.
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.
changed to bigint[]
array, had to workaround the entityid to long conversion though.
.../src/main/java/com/hedera/mirror/importer/parser/record/entity/EntityRecordItemListener.java
Outdated
Show resolved
Hide resolved
Signed-off-by: Xin Li <[email protected]>
@EmbeddedId | ||
@JsonUnwrapped | ||
private Id id; | ||
|
||
private long amount; | ||
|
||
@Type(type = "com.vladmihalcea.hibernate.type.array.ListArrayType") | ||
@JsonSerialize(using = LongListToStringSerializer.class) | ||
private List<Long> effectivePayerAccountIds = Collections.emptyList(); |
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.
can't use AccountIdConverter
with hibernate-types ListArrayType
@Override | ||
public void serialize(List<Long> longs, JsonGenerator gen, SerializerProvider serializers) throws IOException { | ||
if (longs != null) { | ||
gen.writeString("{" + StringUtils.join(longs, ",") + "}"); |
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.
the encoding to insert array to postgresql
...-importer/src/main/java/com/hedera/mirror/importer/converter/LongListToStringSerializer.java
Show resolved
Hide resolved
hedera-mirror-importer/src/main/java/com/hedera/mirror/importer/domain/AssessedCustomFee.java
Outdated
Show resolved
Hide resolved
.../src/main/java/com/hedera/mirror/importer/parser/record/entity/EntityRecordItemListener.java
Show resolved
Hide resolved
hedera-mirror-importer/src/main/resources/db/migration/v2/V2.0.0__time_scale_init.sql
Show resolved
Hide resolved
Signed-off-by: Xin Li <[email protected]>
Signed-off-by: Xin Li <[email protected]>
Kudos, SonarCloud Quality Gate passed! 0 Bugs No Coverage information |
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.
LGTM
Had some suggestions around CustomFee types and dependent logic but no need for additional code churn right now
* @param tokenId the attached token id | ||
* @return whether the fee is paid in the attached token | ||
*/ | ||
private boolean parseFixedFee(CustomFee customFee, FixedFee fixedFee, EntityId tokenId) { |
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.
I see the change here.
Not fully what I was suggesting as I was suggesting move the logic to the CustomFee domain class so that this method returned void. Then in the FIXED FEE case above you'd update the call flow.
Highlighted the example below.
parseFixedFee(customFee, protoCustomFee.getFixedFee(), tokenId);
chargedInAttachedToken = customFee.isChargedInToken(tokenId);
In fact if we passed along the protoCustomFee.getFeeCase()
to the CustomFee domain it would further simplify and centralize the chargedInAttachedToken
logic.
No need to change it here though
"description": "Token info api call for a given non-fungible token with custom fees", | ||
"extendedDescription": [ | ||
"The token has 3 custom fees schedules: an empty schedule at creation, a single custom fee schedule at", | ||
"1234567899999999001, and a 4 custom fees schedule at 1234567899999999007. Without the timestamp filter, the query", |
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.
nit:
"1234567899999999001, and a 4 custom fees schedule at 1234567899999999007. Without the timestamp filter, the query", | |
"1234567899999999001, and a 5 custom fees schedule at 1234567899999999007. Without the timestamp filter, the query", |
@@ -61,8 +69,23 @@ class CustomFeeViewModel { | |||
return !!this.amount; | |||
} | |||
|
|||
isFixedFee() { |
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.
nit: connected to my other comment if we passed along the type these checks would be simpler.
Although it would require persistence with an additional type
column in `custom_fee table
Description:
This PR adds support for several HIP-18 enhancement.
Related issue(s):
Fixes #2377
Fixes #2378
Fixes #2379
Notes for reviewer:
protobuf response code changes:
Checklist