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

Burn roles tokens #844

Merged
merged 18 commits into from
Apr 11, 2024
Merged

Burn roles tokens #844

merged 18 commits into from
Apr 11, 2024

Conversation

nhenin
Copy link
Contributor

@nhenin nhenin commented Mar 20, 2024

  -- | Construct a transaction that burns all role tokens in a wallet which match
  -- the given filter.
  Burn
    :: WalletAddresses
    -- ^ The wallet addresses to use when constructing the transaction
    -> RoleTokenFilter
    -- ^ Which role tokens to burn
    -> MarloweTxCommand Void BurnError BurnTx

type RoleTokenFilter = RoleTokenFilter' ContractId PolicyId AssetId

data BurnError
  = BurnEraUnsupported AnyCardanoEra
  | BurnRolesActive (Set PolicyId)
  | BurnInvalidPolicyId (Set PolicyId)
  | BurnNoTokens
  | BurnFromCardanoError
  | -- FIXME most of this error is not relevant to burning, but due to the current
    -- constraint solving being too marlowe-specific, and because we use the
    -- final balancing pipeline for burning, we sadly need to use this type here.
    BurnConstraintError ConstraintError
  deriving stock (Show, Eq, Ord, Generic)
  deriving anyclass (Binary, ToJSON, Variations)

-- | Represents different filters for role tokens.
data RoleTokenFilter' contract policyId token
  = -- | Represents a filter that matches if either of the two sub-filters match.
    RoleTokensOr (RoleTokenFilter' contract policyId token) (RoleTokenFilter' contract policyId token)
  | -- | Represents a filter that matches if both of the two sub-filters match.
    RoleTokensAnd (RoleTokenFilter' contract policyId token) (RoleTokenFilter' contract policyId token)
  | -- | Represents a filter that matches if the sub-filter does not match.
    RoleTokensNot (RoleTokenFilter' contract policyId token)
  | -- | Represents a filter that matches any role token.
    RoleTokenFilterAny
  | -- | Represents a filter that matches no role tokens.
    RoleTokenFilterNone
  | -- | Represents a filter that matches role tokens based on a set of contracts.
    RoleTokenFilterByContracts (Set contract)
  | -- | Represents a filter that matches role tokens based on a set of policy IDs.
    RoleTokenFilterByPolicyIds (Set policyId)
  | -- | Represents a filter that matches role tokens based on a set of tokens.
    RoleTokenFilterByTokens (Set token)
  deriving stock (Show, Eq, Ord, Generic)
  deriving anyclass (Binary)

@nhenin nhenin marked this pull request as draft March 20, 2024 09:02
@nhenin nhenin self-assigned this Mar 20, 2024
@nhenin nhenin added this to the v1.0.0 Release milestone Mar 20, 2024
Base automatically changed from nhenin/sanchonet to main March 22, 2024 10:00
@nhenin nhenin force-pushed the nhenin/burn-roletokens branch 2 times, most recently from 5281d6d to ee57169 Compare March 26, 2024 09:04
@zeme-wana zeme-wana force-pushed the nhenin/burn-roletokens branch 2 times, most recently from 11d5e3c to 6810cb0 Compare March 26, 2024 19:06
@nhenin nhenin marked this pull request as ready for review April 10, 2024 12:16
@nhenin nhenin requested a review from paluh April 10, 2024 12:16
@nhenin nhenin merged commit 642ebc0 into main Apr 11, 2024
6 checks passed
@nhenin nhenin deleted the nhenin/burn-roletokens branch April 11, 2024 06:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants