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

fix: add data to dca scheduled event for UI #724

Merged
merged 5 commits into from
Dec 21, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion integration-tests/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "runtime-integration-tests"
version = "1.16.5"
version = "1.16.6"
description = "Integration tests"
authors = ["GalacticCouncil"]
edition = "2021"
Expand Down
9 changes: 8 additions & 1 deletion integration-tests/src/dca.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,11 @@ mod omnipool {
let schedule1 = schedule_fake_with_buy_order(PoolType::Omnipool, HDX, DAI, 100 * UNITS, budget);

//Act
assert_ok!(DCA::schedule(RuntimeOrigin::signed(ALICE.into()), schedule1, None));
assert_ok!(DCA::schedule(
RuntimeOrigin::signed(ALICE.into()),
schedule1.clone(),
None
));

//Assert
let schedule_id = 0;
Expand All @@ -64,6 +68,9 @@ mod omnipool {
expect_hydra_events(vec![pallet_dca::Event::Scheduled {
id: 0,
who: ALICE.into(),
period: schedule1.period.clone(),
total_amount: schedule1.total_amount.clone(),
order: schedule1.order.clone(),
}
.into()]);
});
Expand Down
2 changes: 1 addition & 1 deletion pallets/dca/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = 'pallet-dca'
version = "1.3.1"
version = "1.3.2"
description = 'A pallet to manage DCA scheduling'
authors = ['GalacticCouncil']
edition = '2021'
Expand Down
11 changes: 10 additions & 1 deletion pallets/dca/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,13 @@ pub mod pallet {
///The DCA execution is started
ExecutionStarted { id: ScheduleId, block: BlockNumberFor<T> },
///The DCA is scheduled for next execution
Scheduled { id: ScheduleId, who: T::AccountId },
Scheduled {
id: ScheduleId,
who: T::AccountId,
period: BlockNumberFor<T>,
total_amount: Balance,
order: Order<T::AssetId>,
},
///The DCA is planned for blocknumber
ExecutionPlanned {
id: ScheduleId,
Expand Down Expand Up @@ -500,6 +506,9 @@ pub mod pallet {
Self::deposit_event(Event::Scheduled {
id: next_schedule_id,
who,
period: schedule.period,
total_amount: schedule.total_amount,
order: schedule.order,
});

Ok(())
Expand Down
23 changes: 20 additions & 3 deletions pallets/dca/src/tests/schedule.rs
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,11 @@ fn schedule_should_emit_necessary_events() {

//Act
set_block_number(500);
assert_ok!(DCA::schedule(RuntimeOrigin::signed(ALICE), schedule, Option::None));
assert_ok!(DCA::schedule(
RuntimeOrigin::signed(ALICE),
schedule.clone(),
Option::None
));

//Assert
let schedule_id = 0;
Expand All @@ -275,6 +279,9 @@ fn schedule_should_emit_necessary_events() {
Event::Scheduled {
id: schedule_id,
who: ALICE,
period: schedule.period,
total_amount: schedule.total_amount,
order: schedule.order,
}
.into(),
]);
Expand All @@ -295,7 +302,11 @@ fn schedule_should_emit_necessary_events_when_multiple_schedules_are_created() {
set_block_number(500);

let schedule_id = 0;
assert_ok!(DCA::schedule(RuntimeOrigin::signed(ALICE), schedule, Option::None));
assert_ok!(DCA::schedule(
RuntimeOrigin::signed(ALICE),
schedule.clone(),
Option::None
));
expect_events(vec![
Event::ExecutionPlanned {
id: schedule_id,
Expand All @@ -306,6 +317,9 @@ fn schedule_should_emit_necessary_events_when_multiple_schedules_are_created() {
Event::Scheduled {
id: schedule_id,
who: ALICE,
period: schedule.period,
total_amount: schedule.total_amount,
order: schedule.order,
}
.into(),
]);
Expand All @@ -314,7 +328,7 @@ fn schedule_should_emit_necessary_events_when_multiple_schedules_are_created() {

assert_ok!(DCA::schedule(
RuntimeOrigin::signed(ALICE),
schedule2,
schedule2.clone(),
Option::Some(1000)
));
expect_events(vec![
Expand All @@ -327,6 +341,9 @@ fn schedule_should_emit_necessary_events_when_multiple_schedules_are_created() {
Event::Scheduled {
id: schedule_id2,
who: ALICE,
period: schedule2.period,
total_amount: schedule2.total_amount,
order: schedule2.order,
}
.into(),
]);
Expand Down
2 changes: 1 addition & 1 deletion runtime/hydradx/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "hydradx-runtime"
version = "196.0.0"
version = "197.0.0"
authors = ["GalacticCouncil"]
edition = "2021"
license = "Apache 2.0"
Expand Down
2 changes: 1 addition & 1 deletion runtime/hydradx/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ pub const VERSION: RuntimeVersion = RuntimeVersion {
spec_name: create_runtime_str!("hydradx"),
impl_name: create_runtime_str!("hydradx"),
authoring_version: 1,
spec_version: 196,
spec_version: 197,
impl_version: 0,
apis: RUNTIME_API_VERSIONS,
transaction_version: 1,
Expand Down
Loading