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

Token vesting #48

Merged
merged 24 commits into from
Jul 24, 2023
Merged

Token vesting #48

merged 24 commits into from
Jul 24, 2023

Conversation

jgimeno
Copy link
Contributor

@jgimeno jgimeno commented Jul 18, 2023

No description provided.

- Refactored `VestingSchedule::vested_amount` for better readability
- Added missing error handling for multiplication and division operations
- Updated variable names for clarity and consistency
- Removed unnecessary parentheses in arithmetic expressions
- Added missing test cases for the `VestingSchedule::LinearVestingWithCliff` variant
- Updated version number to `0.1.0` and edition to `2021` in `Cargo.toml`
- Removed `authors` field from `Cargo.toml`
- Added new dependencies `cw-utils` (`1.0.1`) and `thiserror` (`1.0.23`)
- Removed `dev-dependencies` section from `Cargo.toml`
- Updated import statements in `state.rs`
- Changed `cw20::Denom` to `cosmwasm_std::Denom` in `state.rs`
- Added `#[cw_serde]` attribute for `VestingAccount` struct in `state.rs`
- Added `test_denom_to_key` function in `state.rs`
- Modified `test_denom_to_key` function to use `Uint64` and `Uint128` from `cosmwasm_std`
- Modified `vesting_amount` value in `test_denom_to_key` function to `Uint128::zero()`
- Modified `claimed_amount` value in `vesting_account` to `Uint128::zero()`
- Remove the "license" field from the `Cargo.toml` file in `contracts/token-vesting`
- Omitted other large changes in the file diff summaries
- High level description: Updated `Cargo.toml` file in `contracts/token-vesting` by removing the "license" field
- Remove unused imports and unnecessary print statements in `msg.rs`
- Add additional properties and definitions to JSON schemas in `schema/`
- Add and update `.wasm` files in `artifacts/`
- Update the version of `cosmwasm-std` in `Cargo.toml`
- Change import statement in `state.rs`
- Modify `.wasm` files in `artifacts/`
- Add tests for registering cliff vesting account with native token in `contracts/token-vesting/src/testing.rs`
- Add tests for proper initialization in `contracts/token-vesting/src/testing.rs`
- Lower numeric tolerance for test files in `contracts/token-vesting/src/testing.rs`
- Add validation for `cliff_amount` in `VestingSchedule::LinearVestingWithCliff` in `contracts/token-vesting/src/contract.rs`
- Add validation for `vesting_amount` in `VestingSchedule::LinearVestingWithCliff` in `contracts/token-vesting/src/contract.rs`
- Add validation for `cliff_time` in `VestingSchedule::LinearVestingWithCliff` in `contracts/token-vesting/src/contract.rs`
- Remove `todo!("LinearVestingWithCliff")` in `register_vesting_account` function in `contracts/token-vesting/src/contract.rs`
- Refactor: Create `create_msg` helper function in `testing.rs` to generate `ExecuteMsg` object
- Fix assertion comparing cliff_time in `register_cliff_vesting_account_with_native_token` test in testing.rs
- Fix assertions in contract.rs related to cliff_time, end_time, start_time, and cliff_amount
- Improve code consistency and correctness in token-vesting module
}

if block_time == cliff_time.u64() {
return Ok(*cliff_amount);
Copy link
Contributor

Choose a reason for hiding this comment

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

That's pretty much unreachable lol

end_time: Uint64::new(110),
vesting_amount: Uint128::new(1_000_000_u128),
cliff_amount: Uint128::new(100_000_u128),
cliff_time: Uint64::new(105),
Copy link
Contributor

Choose a reason for hiding this comment

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

start_time is useless then in this implementation. We could just use start_time instead of cliff_time right?

@codecov
Copy link

codecov bot commented Jul 20, 2023

Codecov Report

Patch coverage: 91.82% and project coverage change: +4.63 🎉

Comparison is base (20b2eba) 79.65% compared to head (2e2a4d9) 84.28%.

Additional details and impacted files
@@            Coverage Diff             @@
##             main      #48      +/-   ##
==========================================
+ Coverage   79.65%   84.28%   +4.63%     
==========================================
  Files          41       39       -2     
  Lines        3161     4723    +1562     
==========================================
+ Hits         2518     3981    +1463     
- Misses        643      742      +99     
Impacted Files Coverage Δ
packages/bindings/src/querier.rs 0.00% <0.00%> (ø)
packages/bindings/src/query.rs 100.00% <ø> (ø)
packages/bindings/src/state.rs 100.00% <ø> (ø)
contracts/bindings-perp/src/msg.rs 63.95% <66.66%> (-1.53%) ⬇️
contracts/token-vesting/src/contract.rs 73.88% <73.88%> (ø)
contracts/token-vesting/src/msg.rs 93.88% <93.88%> (ø)
contracts/bindings-perp/src/contract.rs 90.30% <95.12%> (+1.41%) ⬆️
contracts/controller/src/contract.rs 78.76% <96.36%> (+7.29%) ⬆️
contracts/shifter/src/contract.rs 89.85% <96.36%> (+6.63%) ⬆️
contracts/token-vesting/src/testing.rs 98.95% <98.95%> (ø)
... and 4 more

... and 9 files with indirect coverage changes

☔ View full report in Codecov by Sentry.
📢 Do you have feedback about the report comment? Let us know in this issue.

@Unique-Divine
Copy link
Member

Spinning off an epic ticket with changes from when I audited/reviewed this

@Unique-Divine Unique-Divine merged commit 7fc0865 into main Jul 24, 2023
5 checks passed
@Unique-Divine Unique-Divine deleted the token-vesting branch July 24, 2023 15:16
Unique-Divine added a commit that referenced this pull request Oct 10, 2023
* Include TokenVesting contract.

* update dependencies

* some refactor

* some refactor for block time

* dont need to clone

* add new vesting option

* remove periodic vesting option

* add linear vesting with cliff

* now works, starting point

* refactor times to Uint64, half baked

* refactor times to Uint64 done

* add linear vesting with cliff

* refactor: Refactor token vesting contract and dependencies

- Refactored `VestingSchedule::vested_amount` for better readability
- Added missing error handling for multiplication and division operations
- Updated variable names for clarity and consistency
- Removed unnecessary parentheses in arithmetic expressions
- Added missing test cases for the `VestingSchedule::LinearVestingWithCliff` variant
- Updated version number to `0.1.0` and edition to `2021` in `Cargo.toml`
- Removed `authors` field from `Cargo.toml`
- Added new dependencies `cw-utils` (`1.0.1`) and `thiserror` (`1.0.23`)
- Removed `dev-dependencies` section from `Cargo.toml`
- Updated import statements in `state.rs`
- Changed `cw20::Denom` to `cosmwasm_std::Denom` in `state.rs`
- Added `#[cw_serde]` attribute for `VestingAccount` struct in `state.rs`
- Added `test_denom_to_key` function in `state.rs`
- Modified `test_denom_to_key` function to use `Uint64` and `Uint128` from `cosmwasm_std`
- Modified `vesting_amount` value in `test_denom_to_key` function to `Uint128::zero()`
- Modified `claimed_amount` value in `vesting_account` to `Uint128::zero()`

* Refactor codebase for improved performance

* chore: Remove license field from Cargo.toml

- Remove the "license" field from the `Cargo.toml` file in `contracts/token-vesting`
- Omitted other large changes in the file diff summaries
- High level description: Updated `Cargo.toml` file in `contracts/token-vesting` by removing the "license" field

* refactor: Refactor and update code, schemas, and artifacts

- Remove unused imports and unnecessary print statements in `msg.rs`
- Add additional properties and definitions to JSON schemas in `schema/`
- Add and update `.wasm` files in `artifacts/`
- Update the version of `cosmwasm-std` in `Cargo.toml`
- Change import statement in `state.rs`
- Modify `.wasm` files in `artifacts/`

* feat: Refactor token vesting tests and validation

- Add tests for registering cliff vesting account with native token in `contracts/token-vesting/src/testing.rs`
- Add tests for proper initialization in `contracts/token-vesting/src/testing.rs`
- Lower numeric tolerance for test files in `contracts/token-vesting/src/testing.rs`
- Add validation for `cliff_amount` in `VestingSchedule::LinearVestingWithCliff` in `contracts/token-vesting/src/contract.rs`
- Add validation for `vesting_amount` in `VestingSchedule::LinearVestingWithCliff` in `contracts/token-vesting/src/contract.rs`
- Add validation for `cliff_time` in `VestingSchedule::LinearVestingWithCliff` in `contracts/token-vesting/src/contract.rs`
- Remove `todo!("LinearVestingWithCliff")` in `register_vesting_account` function in `contracts/token-vesting/src/contract.rs`

* feat: Improve validation checks for token vesting contracts

- Refactor: Create `create_msg` helper function in `testing.rs` to generate `ExecuteMsg` object

* fix: Fix assertion errors in token-vesting contract

- Fix assertion comparing cliff_time in `register_cliff_vesting_account_with_native_token` test in testing.rs
- Fix assertions in contract.rs related to cliff_time, end_time, start_time, and cliff_amount
- Improve code consistency and correctness in token-vesting module

* epic(contracts): token vesting first version

* (token-vesting): fn docs + move validation to type impl statements

* .editorconfig + DRY improvements + docs

* refactor: simply msg send construction

---------

Co-authored-by: Unique-Divine <[email protected]>
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.

4 participants