Skip to content

Commit

Permalink
feat(core): add voting and proposing RedeemerTags
Browse files Browse the repository at this point in the history
  • Loading branch information
mirceahasegan committed Mar 21, 2024
1 parent dd3a95b commit f21e68d
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 2 deletions.
4 changes: 3 additions & 1 deletion packages/core/src/Cardano/types/Transaction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,9 @@ export enum RedeemerPurpose {
mint = 'mint',
certificate = 'certificate',
withdrawal = 'withdrawal',
delegateRepresentative = 'representative'
delegateRepresentative = 'representative',
propose = 'propose',
vote = 'vote'
}

export interface Redeemer {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,12 @@ export class Redeemer {
case RedeemerTag.Reward:
purpose = Cardano.RedeemerPurpose.withdrawal;
break;
case RedeemerTag.Voting:
purpose = Cardano.RedeemerPurpose.vote;
break;
case RedeemerTag.Proposing:
purpose = Cardano.RedeemerPurpose.propose;
break;
default:
throw new InvalidStateError(`Invalid redeemer type ${this.#tag}`);
}
Expand Down Expand Up @@ -140,6 +146,12 @@ export class Redeemer {
case Cardano.RedeemerPurpose.withdrawal:
tag = RedeemerTag.Reward;
break;
case Cardano.RedeemerPurpose.vote:
tag = RedeemerTag.Voting;
break;
case Cardano.RedeemerPurpose.propose:
tag = RedeemerTag.Proposing;
break;
default:
throw new InvalidStateError(`Invalid redeemer type ${redeemer.purpose}`);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,13 @@
* redeemer in a transaction. When a Plutus script is executed, the specific action
* type related to the redeemer can be identified using these tags, allowing the
* script to respond appropriately.
* redeemer_tag =
* 0 ; Spending
* / 1 ; Minting
* / 2 ; Certifying
* / 3 ; Rewarding
* / 4 ; Voting
* / 5 ; Proposing
*/
export enum RedeemerTag {
/** Indicates the redeemer is for spending a UTxO. */
Expand All @@ -12,5 +19,7 @@ export enum RedeemerTag {
/** Indicates the redeemer is related to a certificate action within a transaction. */
Cert = 2,
/** Indicates the redeemer is for withdrawing rewards from staking. */
Reward = 3
Reward = 3,
Voting = 4,
Proposing = 5
}

0 comments on commit f21e68d

Please sign in to comment.