Skip to content
Snippets Groups Projects
Commit 2ab1e958 authored by Hugo Trentesaux's avatar Hugo Trentesaux
Browse files

mint UD instead of deposit + disable burn (!307)

* review txmn

* fix(#231): next_cert_issuable_on is not used (!308)

* fix(#231): next_cert_issuable_on is not used

cert_meta.next_issuable_on is computed on genesis without this variable

* apply clippy

* remove comment

(used at line 1236)

(cherry picked from commit a6e8ba19)

* document burn as disabled

* replace raw origin by runtime origin

* fix #284

* use mint instead of deposit
parent 582a46c2
No related branches found
No related tags found
1 merge request!307mint UD instead of deposit + disable burn
Pipeline #39548 waiting for manual action
......@@ -12,7 +12,7 @@ Calls are categorized according to the dispatch origin they require:
We only document user calls below.
There are **64** user calls from **17** pallets.
There are **63** user calls from **17** pallets.
## Account - 1
......@@ -105,28 +105,6 @@ The dispatch origin of this call must be Signed.
transfer everything except at least the existential deposit, which will guarantee to
keep the sender account alive (true).
### burn - 10
<details><summary><code>burn(value, keep_alive)</code></summary>
No weight available.
```rust
value: T::Balance
keep_alive: bool
```
</details>
Burn the specified liquid free balance from the origin account.
If the origin's account ends up below the existential deposit as a result
of the burn and `keep_alive` is false, the account will be reaped.
Unlike sending funds to a _burn_ address, which merely makes the funds inaccessible,
this `burn` operation will reduce total issuance by the amount _burned_.
## OneshotAccount - 7
### create_oneshot_account - 0
......
......@@ -187,8 +187,6 @@ struct IdentityV1 {
membership_revokes_on: TimestampV1,
/// whether the identity is revoked (manually or automatically)
revoked: bool,
/// timestamp at which the next cert can be emitted
next_cert_issuable_on: TimestampV1, // TODO: unused?
/// balance of the account of this identity
balance: u64,
/// certs received with their expiration timestamp
......@@ -212,8 +210,6 @@ struct IdentityV2 {
identity_revoke_on: u32,
/// whether the identity is revoked (manually or automatically)
revoked: bool,
/// block at which the next cert can be emitted
next_cert_issuable_on: u32,
/// balance of the account of this identity
balance: u64,
/// certs received with their expiration block
......@@ -1232,10 +1228,6 @@ fn genesis_data_to_identities_v2(
genesis_timestamp,
),
revoked: i.revoked,
next_cert_issuable_on: timestamp_to_relative_blocs(
i.next_cert_issuable_on,
genesis_timestamp,
),
balance: i.balance,
certs_received: i
.certs_received
......@@ -1276,7 +1268,6 @@ fn make_authority_exist<SessionKeys: Encode, SKP: SessionKeysProvider<SessionKey
membership_expire_on: common_parameters.membership_membership_period,
identity_revoke_on: common_parameters.membership_membership_period,
revoked: false,
next_cert_issuable_on: 0,
},
);
};
......
......@@ -331,10 +331,11 @@ pub mod pallet {
core::num::NonZeroU16::new(current_ud_index)
.expect("unreachable because current_ud_index is never zero."),
);
let _ = T::Currency::deposit(who, uds_total, Precision::Exact);
// Currency is issued here
let actual_total = T::Currency::mint_into(who, uds_total)?;
Self::deposit_event(Event::UdsClaimed {
count: uds_count,
total: uds_total,
total: actual_total,
who: who.clone(),
});
Ok(().into())
......
......@@ -62,6 +62,11 @@ fn test_claim_uds() {
total: 1_000,
who: 1,
}));
// the expected event from pallet balances is Minted
System::assert_has_event(RuntimeEvent::Balances(pallet_balances::Event::Minted {
who: 1,
amount: 1000,
}));
assert_eq!(Balances::free_balance(1), 1_000);
// Others members should not receive any UDs with Alice claim
assert_eq!(Balances::free_balance(2), 0);
......
......@@ -173,7 +173,12 @@ mod benches {
pub struct BaseCallFilter;
impl Contains<RuntimeCall> for BaseCallFilter {
fn contains(call: &RuntimeCall) -> bool {
!matches!(call, RuntimeCall::Session(_))
// not allowed to run session calls directly
// not allowed to burn currency
!matches!(
call,
RuntimeCall::Session(_) | RuntimeCall::Balances(pallet_balances::Call::burn { .. })
)
}
}
......
This diff is collapsed.
......@@ -180,7 +180,7 @@ fn test_refund_reaped_linked_account() {
// Ferdie's account can be linked to Alice identity
assert_ok!(Identity::link_account(
frame_system::RawOrigin::Signed(alice.clone()).into(),
RuntimeOrigin::signed(alice.clone()),
ferdie.clone(),
signature.into()
));
......
......@@ -232,6 +232,7 @@ impl CallCategory {
| "force_unreserve"
| "force_adjust_total_issuance",
) => Self::Root,
("Balances", "burn") => Self::Disabled,
("Sudo", _) => Self::Sudo,
("Treasury", "approve_proposal" | "reject_proposal") => Self::OtherOrigin,
("Utility", "dispatch_as" | "with_weight") => Self::Root,
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment