Skip to content
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

feat: dry ticket length, increase ticket length from 5 to 6, make max holders configurable #55

Merged
merged 37 commits into from
Dec 30, 2021

Conversation

Ruborcalor
Copy link
Collaborator

@Ruborcalor Ruborcalor commented Dec 13, 2021

What's This

  • refactor: avoid hardcoding things that are dependent on ticket length. This makes it easier to adjust the ticket length.
  • feat: increase ticket length from 5 to 6
  • feat: configurable max holders
  • build: update schema and build artifacts

Notable Changes

  • Add TICKET_LENGTH and NUM_PRIZE_BUCKETS as public consts to glow_protocol::lotto and import them when relevant.
  • Change MAX_LIMIT to 10000 from 100.
  • Update tests in a way that makes them more agnostic to ticket length changes.

Changes To Error Types

Update InvalidDepositInstantiation to take a Uint128 which specifies the invalid deposit amount.

(https://github.com/elevenyellow/glow-protocol/pull/55/files#diff-5163afc26d70ac053dac70e5c837917724f85cbd0091ff376fee9d744cec48b5L9-R12)

Rename InvalidDepositAmount to ZeroDepositAmount.

(https://github.com/elevenyellow/glow-protocol/pull/55/files#diff-5163afc26d70ac053dac70e5c837917724f85cbd0091ff376fee9d744cec48b5L9-R12)

Update InvalidSequence text and to specify the sequence that was invalid.

(https://github.com/elevenyellow/glow-protocol/pull/55/files#diff-5163afc26d70ac053dac70e5c837917724f85cbd0091ff376fee9d744cec48b5L9-R12)

Update InvalidHolder text and to specify the sequence that was invalid.

(https://github.com/elevenyellow/glow-protocol/pull/55/files#diff-5163afc26d70ac053dac70e5c837917724f85cbd0091ff376fee9d744cec48b5L9-R12)

Rename InvalidGift to GiftToSelf

(https://github.com/elevenyellow/glow-protocol/pull/55/files#diff-5163afc26d70ac053dac70e5c837917724f85cbd0091ff376fee9d744cec48b5L9-R12)

Rename InvalidGiftAmount to ZeroGiftAmount

(https://github.com/elevenyellow/glow-protocol/pull/55/files#diff-5163afc26d70ac053dac70e5c837917724f85cbd0091ff376fee9d744cec48b5L9-R12)

Rename InvalidSponsorshipAmount to ZeroSponsorshipAmount

(https://github.com/elevenyellow/glow-protocol/pull/55/files#diff-5163afc26d70ac053dac70e5c837917724f85cbd0091ff376fee9d744cec48b5L9-R12)

Update LotteryNotReady to specify when the lottery will be ready.

(https://github.com/elevenyellow/glow-protocol/pull/55/files#diff-5163afc26d70ac053dac70e5c837917724f85cbd0091ff376fee9d744cec48b5L9-R12)

Update SpecifiedWithdrawAmountTooSmall, SpecifiedWithdrawAmountTooBig, WithdrawingTooManyTickets and InsufficientFunds to specify the requested value and its corresponding limit that was exceeded.

https://github.com/elevenyellow/glow-protocol/pull/55/files#diff-5163afc26d70ac053dac70e5c837917724f85cbd0091ff376fee9d744cec48b5L49-R69

Update InsufficientPoolFunds with more information.

(https://github.com/elevenyellow/glow-protocol/pull/55/files#diff-5163afc26d70ac053dac70e5c837917724f85cbd0091ff376fee9d744cec48b5L9-R12)

Update text for InsufficientLotteryFunds

(https://github.com/elevenyellow/glow-protocol/pull/55/files#diff-5163afc26d70ac053dac70e5c837917724f85cbd0091ff376fee9d744cec48b5L9-R12)

Update InvalidClaimLotteryNotAwarded with more information

(https://github.com/elevenyellow/glow-protocol/pull/55/files#diff-5163afc26d70ac053dac70e5c837917724f85cbd0091ff376fee9d744cec48b5L9-R12)

Update InvalidClaimPrizeAlreadyClaimed with more information

(https://github.com/elevenyellow/glow-protocol/pull/55/files#diff-5163afc26d70ac053dac70e5c837917724f85cbd0091ff376fee9d744cec48b5L9-R12)

Remove InsufficientSponsorFunds, InvalidClaimAmount, InvalidLotteryFundsExecution, InvalidLotteryTicketsExecution, InvalidLotteryExecution.

They weren't being used.

instead of using current_prize_buckets, use lottery_balance to account for the appreciation since the last lottery
this way you can call calculate_lottery_balance from query_lottery_balance
@Ruborcalor Ruborcalor marked this pull request as ready for review December 23, 2021 20:56

#[error("Insufficient deposit amount for {0} tickets")]
InsufficientDepositAmount(u64),

#[error("Sequence must be 5 digits between 0-9")]
InvalidSequence {},
#[error("Sequence must be 5 digits between 0-f but instead it was: {0}")]
Copy link
Collaborator

Choose a reason for hiding this comment

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

We should remove the hard-coded "5 digits" here

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I ended up hard-codeding it to "6" instead, do you think that works? It seems const formatting is not supported by std: rust-lang/rust#69133. If we wanted we could add const format as a dependency: https://github.com/rodrimati1992/const_format_crates

Copy link
Collaborator

Choose a reason for hiding this comment

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

let's keep with the hard-coded 6 then, didn't know that. It's not a big deal anyway

@@ -1021,8 +1041,11 @@ pub fn execute_claim_lottery(
config.stable_denom.clone(),
)?;

if net_send > balance.into() {
return Err(ContractError::InsufficientFunds {});
if to_send > balance.into() {
Copy link
Collaborator

Choose a reason for hiding this comment

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

makes sense!

Copy link
Collaborator

@aesmonty aesmonty left a comment

Choose a reason for hiding this comment

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

LGTM!

@Ruborcalor Ruborcalor changed the title refactor: dry ticket length feat: dry ticket length, increase ticket length from 5 to 6, make max holders configurable Dec 30, 2021
* feat: increase ticket length to 6

* feat: configurable max holders (#59)

* feat: make max_holders configurable

* test: add test for max_holders configuration

* build: build wasm and schema json artifacts

* fix: add max holders bounds, make sure that max holders only increases

* fix: add tests for max_holders

* build: update build artifacts

* Trigger actions

* build: empty commit to trigger github actions
@aesmonty aesmonty merged commit ddb4693 into main Dec 30, 2021
Ruborcalor added a commit that referenced this pull request Apr 28, 2022
## What's This

Fix unnecessary duplication of `MigrateOldDepositors` and `UpdateConfig` messages.

Also update `migrate_old_depositors` function to throw an error if there are no lotteries left to migrate.

* fix: unnecessary duplication of execute msgs

Unnecessary duplication of MigrateOldDepositors and UpdateConfig messages
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants