Skip to content

Commit

Permalink
Added amount parameter to farming pallet for deposit extrinsic (#3581) (
Browse files Browse the repository at this point in the history
#3589)

This PR introduced additional parameter `amount` to allow user `deposit`
to specify any amount of LP tokens.

- upgrade runtime
- no node update

@kkast



- [ ] PR title is my best effort to provide summary of changes and has
clear text to be part of release notes
- [ ] I marked PR by `misc` label if it should not be in release notes
- [ ] I have linked Zenhub/Github or any other reference item if one
exists
- [ ] I was clear on what type of deployment required to release my
changes (node, runtime, contract, indexer, on chain operation, frontend,
infrastructure) if any in PR title or description
- [ ] I waited and did best effort for `Effect gate, automatically
merged if passed`(effects-job) to finish with success(green check mark)
with my changes
- [ ] I have added at least one reviewer in reviewers list
- [ ] I tagged(@) or used other form of notification of one person who I
think can handle best review of this PR

---------

Co-authored-by: Rust Ninja <[email protected]>
  • Loading branch information
dzmitry-lahoda and RustNinja authored May 10, 2023
1 parent f43f532 commit 8741b94
Show file tree
Hide file tree
Showing 8 changed files with 42 additions and 15 deletions.
Original file line number Diff line number Diff line change
@@ -1,14 +1,10 @@
name: "Build, Test, Deploy"
name: "build-test-deploy-flaky"
on:
push:
branches:
- release-*
- main

# For regular PRs.
pull_request_target:

# For PRs that need to run in the monorepo context.
pull_request:

permissions:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,20 +1,19 @@
name: "pr"
name: "pr-workflow-check"
concurrency:
group: ${{ github.workflow }}-pr-${{ github.event.pull_request.number || github.ref }}
group: ${{ github.workflow }}-pr-workflow-check-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true

on:
push:
branches:
- release-*
- main
pull_request_target:
pull_request:
merge_group:
types: [checks_requested]

jobs:
pr-workflow:
pr-workflow-check:
uses: ./.github/workflows/pr-workflow.yml
with:
github_event_name: ${{ github.event_name }}
Expand Down
22 changes: 22 additions & 0 deletions .github/workflows/pr-workflow-fork.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
name: "pr-workflow-fork"
concurrency:
group: ${{ github.workflow }}-pr-workflow-fork-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true

on:
pull_request_target:

jobs:
pr-workflow-fork:
uses: ./.github/workflows/pr-workflow.yml
with:
github_event_name: ${{ github.event_name }}
github_event_pull_request_head_repo_id : ${{ github.event.pull_request.head.repo.id }}
github_workflow: $ {{ github.workflow }}
github_event_pull_request_head_sha: ${{ github.event.pull_request.head.sha }}
secrets:
CACHIX_AUTH_TOKEN: ${{ secrets.CACHIX_AUTH_TOKEN }}
DOCKER_HUB_USERNAME: ${{ secrets.DOCKER_HUB_USERNAME }}
DOCKER_HUB_ACCESS_TOKEN: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }}
PABLO_PROJ_JSON: ${{ secrets.PABLO_PROJ_JSON }}
VERCEL_TOKEN: ${{ secrets.VERCEL_TOKEN }}
8 changes: 7 additions & 1 deletion .github/workflows/pr-workflow.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
name: "build-test-deploy"
name: "pr-workflow"
concurrency:
group: ${{ github.workflow }}-pr-workflow-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
on:
workflow_call:
inputs:
Expand Down Expand Up @@ -507,6 +510,9 @@ jobs:
steps:
- run: |
echo "probably no bugs"
- if: ${{ cancelled() }}
run: |
exit 42
draft-release-artifacts:
name: "draft-release-artifacts"
Expand Down
3 changes: 2 additions & 1 deletion code/parachain/frame/farming/src/benchmarking.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ fn deposit_lp_tokens<T: Config>(
assert_ok!(Farming::<T>::deposit(
RawOrigin::Signed(account_id.clone()).into(),
pool_currency_id.into(),
amount
));
}

Expand Down Expand Up @@ -104,7 +105,7 @@ benchmarks! {
100u32.into(),
));

}: _(RawOrigin::Signed(origin), pool_currency_id.into())
}: _(RawOrigin::Signed(origin), pool_currency_id.into(), 100u32.into())

withdraw {
let origin: T::AccountId = account("Origin", 0, 0);
Expand Down
7 changes: 5 additions & 2 deletions code/parachain/frame/farming/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -323,10 +323,13 @@ pub mod pallet {
#[pallet::call_index(2)]
#[pallet::weight(T::WeightInfo::deposit())]
#[transactional]
pub fn deposit(origin: OriginFor<T>, pool_currency_id: AssetIdOf<T>) -> DispatchResult {
pub fn deposit(
origin: OriginFor<T>,
pool_currency_id: AssetIdOf<T>,
amount: BalanceOf<T>,
) -> DispatchResult {
let who = ensure_signed(origin)?;
// reserve lp tokens to prevent spending
let amount = T::MultiCurrency::free_balance(pool_currency_id, &who);
T::MultiCurrency::reserve(pool_currency_id, &who, amount)?;

// deposit lp tokens as stake
Expand Down
2 changes: 1 addition & 1 deletion code/parachain/frame/farming/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ fn should_overwrite_existing_schedule() {
fn mint_and_deposit(account_id: AccountId, amount: Balance) {
assert_ok!(Tokens::set_balance(RuntimeOrigin::root(), account_id, POOL_CURRENCY_ID, amount, 0));

assert_ok!(Farming::deposit(RuntimeOrigin::signed(account_id), POOL_CURRENCY_ID,));
assert_ok!(Farming::deposit(RuntimeOrigin::signed(account_id), POOL_CURRENCY_ID, amount));
}

#[test]
Expand Down
2 changes: 1 addition & 1 deletion terraform/github.com/branches.tf
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ resource "github_branch_protection" "main" {
# Require branches to be up to date before merging
strict = false
# Status checks that are required.
contexts = ["pr-workflow / draft-release-check"]
contexts = ["pr-workflow-check"]
}

# Require a pull request before merging
Expand Down

0 comments on commit 8741b94

Please sign in to comment.