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

MESH-1817/ Allow capital distributions in the base asset #1235

Merged
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
1 change: 0 additions & 1 deletion errors_schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -315,7 +315,6 @@
"CANotBenefit",
"AlreadyExists",
"ExpiryBeforePayment",
"DistributingAsset",
"HolderAlreadyPaid",
"NoSuchDistribution",
"CannotClaimBeforeStart",
Expand Down
7 changes: 0 additions & 7 deletions pallets/corporate-actions/src/distribution/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,6 @@ decl_module! {
///
/// # Errors
/// - `UnauthorizedAgent` if `origin` is not agent-permissioned for `ticker`.
/// - `DistributingAsset` if `ca_id.ticker == currency`.
/// - `ExpiryBeforePayment` if `expires_at.unwrap() <= payment_at`.
/// - `NoSuchCA` if `ca_id` does not identify an existing CA.
/// - `NoRecordDate` if CA has no record date.
Expand Down Expand Up @@ -386,9 +385,6 @@ decl_error! {
/// A distributions provided expiry date was strictly before its payment date.
/// In other words, everything to distribute would immediately be forfeited.
ExpiryBeforePayment,
/// Currency that is distributed is the same as the CA's ticker.
/// Calling agent is attempting a form of stock split, which is not what the extrinsic is for.
DistributingAsset,
/// The token holder has already been paid their benefit.
HolderAlreadyPaid,
/// A capital distribution doesn't exist for this CA.
Expand Down Expand Up @@ -546,9 +542,6 @@ impl<T: Config> Module<T> {
payment_at: Moment,
expires_at: Option<Moment>,
) -> DispatchResult {
// Ensure CA's asset is distinct from the distributed currency.
ensure!(ca_id.ticker != currency, Error::<T>::DistributingAsset);

// Ensure that any expiry date doesn't come before the payment date.
ensure!(
!expired(expires_at, payment_at),
Expand Down
18 changes: 11 additions & 7 deletions pallets/runtime/tests/src/corporate_actions_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1764,13 +1764,17 @@ fn dist_distribute_works() {

Timestamp::set_timestamp(2);
let id2 = dist_ca(owner, ticker, Some(2)).unwrap();

// Test same-asset logic.
assert_noop!(
Dist::distribute(owner.origin(), id2, None, ticker, 0, 0, 0, None),
DistError::DistributingAsset
);
JMoore96 marked this conversation as resolved.
Show resolved Hide resolved

let id3 = dist_ca(owner, ticker, Some(2)).unwrap();
assert_ok!(Dist::distribute(
owner.origin(),
id3,
None,
ticker,
0,
0,
5,
None
));
// Test expiry.
for &(pay, expiry) in &[(5, 5), (6, 5)] {
assert_noop!(
Expand Down