Skip to content
This repository has been archived by the owner on Apr 4, 2024. It is now read-only.

Feat: Add feeFactory #27

Conversation

StanislawMazowieckiAriane
Copy link
Contributor

Description:

Related issue(s):

Fixes #25

Checklist

  • Documented (Code comments, README, etc.)
  • Tested (unit, integration, etc.)

Signed-off-by: Stanislaw Mazowiecki <[email protected]>
Comment on lines 7 to 9
beforeEach(async () => {
new HederaNFTSDK(myAccountId, myPrivateKey);
});
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this can be removed

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But I'm creating collections in this test. For this, I need to be logged in

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nftSDK is already created with these keys in test/e2e/e2eConsts.ts

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You're right, sorry

test/e2e/feeFactoryE2E.test.ts Show resolved Hide resolved
Comment on lines +15 to +25
if (hbarAmount) {
fixedFee.setHbarAmount(Hbar.fromString(hbarAmount.toString()));
}

if (amount) {
fixedFee.setAmount(amount);
}

if (denominatingTokenId) {
fixedFee.setDenominatingTokenId(denominatingTokenId);
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hbarAmount, amount and denominatingTokenId are related to each other.

Either hbarAmount is set and (amount and denominatingTokenId) are not set
OR
(amount and denominatingTokenId) are set and hbarAmount is not set

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

Comment on lines 15 to 23
if (fallbackFee) {
fixedFee = createFixedFeeFunction({
collectorAccountId: fallbackFee.collectorAccountId,
hbarAmount: fallbackFee.hbarAmount,
amount: fallbackFee.amount,
denominatingTokenId: fallbackFee.denominatingTokenId,
allCollectorsAreExempt: fallbackFee.allCollectorsAreExempt,
});
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if this was moved after the CustomRoyaltyFee creation this if and

  if (fixedFee) {
    royaltyFee.setFallbackFee(fixedFee);
  }

could be merge into one

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

customFees?: CustomFee[];
};

export type validateFixedFeeFunction = {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's not a function rename, this to something like: fixedFeeValidationProps

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

collectorAccountId?: string;
};

export type validateRoyaltyFeeFunction = validateFixedFeeFunction & {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's not a function rename, this to something like: royaltyFeeValidationProps

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

validateCollectorAccountId(props);
validateNumerator(props);
validateDenominator(props);
};

const validateNumerator = (props: validateRoyaltyFeeFunction) => {
const validateHbarAmountAmountAndDenominatingToken = (props: fixedFeeValidationProps) => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please write unit tests for all possible combinations

(false - not set, true - set)

hbarAmount amount denominatingTokenId expectedResult
false false false error
false false true error
false true false error
false true true valid
true false false valid
true false true error
true true false error
true true true error

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

(props.hbarAmount && (props.amount || props.denominatingTokenId)) ||
(!props.hbarAmount && (!props.amount || !props.denominatingTokenId))
) {
throw new Error(dictionary.createCollection.hbarAmountAmountAndDenominatingToken);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hbarAmountAmountAndDenominatingToken can be renamed to hbarAmountOrAmountAndDenominatingToken

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

…ollection

# Conflicts:
#	src/HederaNFTSDK.ts
#	src/types/validateProps.ts
#	src/utils/validateProps.ts
#	test/e2e/createCollectionE2E.test.ts
#	test/e2e/e2eConsts.ts
#	test/unit/validateProps.test.ts
@StanislawMazowieckiAriane StanislawMazowieckiAriane changed the title Feat: Add fixFactory Feat: Add feeFactory Feb 8, 2024
@StanislawMazowieckiAriane StanislawMazowieckiAriane merged commit 07353d2 into main Feb 8, 2024
1 check passed
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

As a User I want to define fees for the collection
3 participants