Comments (2)
1. 📝 Indexing
I'm indexing the files within your repository.
2. 🔎 Searching
I'm searching for relevant snippets in your repository.
I found the following snippets in your repository.
View Snippets
https://github.com/Sifchain/sifnode/blob/main/x/dispensation/claims.md#L0-L15
https://github.com/Sifchain/sifnode/blob/main/x/dispensation/claims.md#L15-L30
https://github.com/Sifchain/sifnode/blob/main/x/dispensation/claims.md#L30-L45
https://github.com/Sifchain/sifnode/blob/main/x/oracle/types/prophecy.go#L0-L32
https://github.com/Sifchain/sifnode/blob/main/x/oracle/types/prophecy.go#L0-L72
3. 🌐 Planning
I'm creating a plan for the discussion and coding steps.
I have created the following workflow as a basis for how the discussion and coding will be derived.
💡 Steps
Add Duration Parameter to AddLiquidityToRewardBucket Message
Action: modify
File: x/clp/types/message_add_liquidity_to_rewards_bucket.go
Lines: [1, 50]
Dependencies: []
Instructions: Add a new field 'Duration' of type 'time.Duration' to the 'MsgAddLiquidityToRewardBucket' struct. This field will represent the duration over which the added liquidity will be distributed. Update the 'NewMsgAddLiquidityToRewardBucket' function to accept this new parameter and assign it to the created message. Update the 'ValidateBasic' function to check that the duration is not negative.
Update AddLiquidityToRewardBucket Handler
Action: modify
File: x/clp/keeper/msg_server_add_liquidity_to_rewards_bucket.go
Lines: [1, 50]
Dependencies: ['Step 1']
Instructions: Update the 'AddLiquidityToRewardBucket' function to handle the new duration parameter. Instead of distributing the liquidity immediately, schedule it to be distributed gradually over the specified duration. This will likely involve creating a new function to handle the distribution, which will be called at regular intervals until the duration has passed.
Update CLI Command
Action: modify
File: x/clp/client/cli/tx_add_liquidity_to_rewards_bucket.go
Lines: [1, 50]
Dependencies: ['Step 1']
Instructions: Update the 'CmdAddLiquidityToRewardBucket' function to accept the new duration parameter from the command line. Pass this parameter when creating the 'MsgAddLiquidityToRewardBucket' message.
Update REST API
Action: modify
File: x/clp/client/rest/tx.go
Lines: [1, 50]
Dependencies: ['Step 1']
Instructions: Update the 'registerTxRoutes' function to accept the new duration parameter from the HTTP request. Pass this parameter when creating the 'MsgAddLiquidityToRewardBucket' message.
Update Unit Tests
Action: modify
File: x/clp/keeper/msg_server_add_liquidity_to_rewards_bucket_test.go
Lines: [1, 50]
Dependencies: ['Step 1', 'Step 2']
Instructions: Update the unit tests for the 'AddLiquidityToRewardBucket' message and handler to account for the new duration parameter. Ensure that the tests cover cases where the duration is zero (for immediate distribution), positive (for gradual distribution), and negative (which should be rejected).
I have created the following workflow as a basis for how the discussion and coding will be derived.
💡 Steps
Update ValidateBasic Function
Action: modify
File: x/clp/types/message_add_liquidity_to_rewards_bucket.go
Lines: [1, 50]
Dependencies: []
Instructions: In the 'ValidateBasic' function of the 'MsgAddLiquidityToRewardBucket' message, add a check to return an error if the 'Duration' field is negative. Import the 'errors' package from 'x/clp/types/errors.go' to use predefined error types.
Implement Time-based Job Scheduler
Action: create
File: x/clp/keeper/scheduler.go
Lines: [1, 100]
Dependencies: ['Step 1']
Instructions: Create a new file 'scheduler.go' in the 'x/clp/keeper' directory. Implement a time-based job scheduler that will handle the incremental distribution of liquidity over the specified duration. This scheduler should be able to queue jobs and execute them at the correct intervals based on the block time.
Update CLI for Duration Parameter
Action: modify
File: x/clp/client/cli/tx.go
Lines: [1, 200]
Dependencies: ['Step 2']
Instructions: Modify the CLI command for adding liquidity to a reward bucket to accept an optional 'duration' flag. Ensure that the flag is parsed correctly and passed to the message constructor. Use the 'flag' package to define the new flag.
Update REST API for Duration Parameter
Action: modify
File: x/clp/client/rest/tx.go
Lines: [1, 150]
Dependencies: ['Step 3']
Instructions: Update the REST API endpoint for adding liquidity to a reward bucket to parse the optional 'duration' parameter from the request body. Validate the input and ensure it is correctly included in the message that is created and signed.
Create Unit Tests for Duration Parameter
Action: create
File: x/clp/keeper/add_liquidity_to_rewards_bucket_test.go
Lines: [1, 200]
Dependencies: ['Step 4']
Instructions: Create comprehensive unit tests in 'add_liquidity_to_rewards_bucket_test.go' to cover the new duration parameter functionality. Test cases should include zero, negative, non-numeric, and out-of-range duration values. Use the 'testify' package for assertions.
from sifnode.
The workflow is well-structured but could use more detail in certain areas. For negative duration, the 'ValidateBasic' function should return an error. For the gradual distribution functionality, consider using a time-based job scheduler or a similar mechanism to distribute the liquidity over time. For the CLI command and REST API updates, include error handling for invalid inputs. For the unit tests, ensure coverage for edge cases such as zero, negative, and extremely large duration values, as well as non-numeric and out-of-range inputs for the CLI command and REST API.
from sifnode.
Related Issues (20)
- HAL-03 lack of validation on setblacklist message HOT 2
- HAL-04 sensitive information in environment variables HOT 2
- HAL-05 lack of validation of ethereum address formats HOT 7
- HAL-06 iteration over map source of non-determinism HOT 10
- HAL-07 downcasting of 64-bit integer HOT 4
- HAL-09 hardcoded mnemonic phrases in the repository HOT 1
- HAL-10 use of outdated solidity version HOT 4
- HAL-12 open todos HOT 2
- HAL-14 unused variables HOT 2
- HAL-13 panic is used for error handling HOT 3
- Add peggy2 test case for a token that does a reentrant lock/burn
- Peggy2 protobuf files need to be compatible with peggy1 HOT 2
- saw in the validator logs `module=x/ibc/channel sequence="marshaling error: json: unsupported type: func() uint64"`
- Add missing integration test to github action
- Enhance Non-Rowan Yield Reward Functionality with Optional Duration Feature HOT 3
- Enhance Non-Rowan Yield Reward Functionality with Optional Duration Feature
- Enhance Non-Rowan Yield Reward Functionality with Optional Duration Feature HOT 1
- Enhance Non-Rowan Yield Reward Functionality with Optional Duration Feature HOT 1
- The SifChain website should be revamped
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from sifnode.