-
Notifications
You must be signed in to change notification settings - Fork 118
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Daniel Akhterov <[email protected]>
- Loading branch information
1 parent
812cca5
commit 57e8427
Showing
103 changed files
with
581 additions
and
535 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
91 changes: 91 additions & 0 deletions
91
src/main/java/com/hedera/hashgraph/sdk/token/CustomRoyaltyFee.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,91 @@ | ||
package com.hedera.hashgraph.sdk.token; | ||
|
||
import com.google.common.base.MoreObjects; | ||
import com.hedera.hashgraph.proto.FixedFee; | ||
import com.hedera.hashgraph.proto.Fraction; | ||
import com.hedera.hashgraph.proto.RoyaltyFee; | ||
import com.hedera.hashgraph.sdk.account.AccountId; | ||
|
||
import javax.annotation.Nullable; | ||
import java.util.Objects; | ||
|
||
public class CustomRoyaltyFee extends CustomFee { | ||
private long numerator = 0; | ||
private long denominator = 1; | ||
@Nullable | ||
private CustomFixedFee fallbackFee = null; | ||
|
||
public CustomRoyaltyFee() { | ||
} | ||
|
||
CustomRoyaltyFee(com.hedera.hashgraph.proto.CustomFee customFee) { | ||
RoyaltyFee royaltyFee = customFee.getRoyaltyFee(); | ||
|
||
this.feeCollectorAccountId = customFee.hasFeeCollectorAccountId() ? | ||
new AccountId(customFee.getFeeCollectorAccountId()) : null; | ||
this.denominator = royaltyFee.hasExchangeValueFraction() ? royaltyFee.getExchangeValueFraction().getDenominator() : 0; | ||
this.numerator = royaltyFee.hasExchangeValueFraction() ? royaltyFee.getExchangeValueFraction().getNumerator() : 0; | ||
this.fallbackFee = royaltyFee.hasFallbackFee() ? | ||
new CustomFixedFee(com.hedera.hashgraph.proto.CustomFee.newBuilder() | ||
.setFixedFee(royaltyFee.getFallbackFee()) | ||
.build() | ||
) : null; | ||
} | ||
|
||
public CustomRoyaltyFee setFeeCollectorAccountId(AccountId feeCollectorAccountId) { | ||
doSetFeeCollectorAccountId(feeCollectorAccountId); | ||
return this; | ||
} | ||
|
||
public long getNumerator() { | ||
return numerator; | ||
} | ||
|
||
public CustomRoyaltyFee setNumerator(long numerator) { | ||
this.numerator = numerator; | ||
return this; | ||
} | ||
|
||
public long getDenominator() { | ||
return denominator; | ||
} | ||
|
||
public CustomRoyaltyFee setDenominator(long denominator) { | ||
this.denominator = denominator; | ||
return this; | ||
} | ||
|
||
public CustomRoyaltyFee setFallbackFee(CustomFixedFee fallbackFee) { | ||
Objects.requireNonNull(fallbackFee); | ||
this.fallbackFee = fallbackFee; | ||
return this; | ||
} | ||
|
||
@Override | ||
com.hedera.hashgraph.proto.CustomFee toProto() { | ||
RoyaltyFee.Builder builder = RoyaltyFee.newBuilder() | ||
.setExchangeValueFraction( | ||
Fraction.newBuilder() | ||
.setNumerator(numerator) | ||
.setDenominator(denominator) | ||
); | ||
|
||
if (fallbackFee != null) { | ||
builder.setFallbackFee(fallbackFee.toProto().getFixedFee()); | ||
} | ||
|
||
return com.hedera.hashgraph.proto.CustomFee.newBuilder() | ||
.setRoyaltyFee(builder) | ||
.build(); | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return MoreObjects.toStringHelper(this) | ||
.add("feeCollectorAccountId", getFeeCollectorAccountId()) | ||
.add("numerator", getNumerator()) | ||
.add("denominator", getDenominator()) | ||
.add("fallbackFee", fallbackFee) | ||
.toString(); | ||
} | ||
} |
21 changes: 21 additions & 0 deletions
21
src/main/java/com/hedera/hashgraph/sdk/token/FeeAssessmentMethod.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,21 @@ | ||
package com.hedera.hashgraph.sdk.token; | ||
|
||
public enum FeeAssessmentMethod { | ||
INCLUSIVE(false), | ||
EXCLUSIVE(true); | ||
|
||
final boolean code; | ||
|
||
FeeAssessmentMethod(boolean code) { | ||
this.code = code; | ||
} | ||
|
||
static FeeAssessmentMethod valueOf(boolean code) { | ||
return code ? EXCLUSIVE : INCLUSIVE; | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return code ? "EXCLUSIVE" : "INCLUSIVE"; | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.