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

Add transcoder for Unlock stake txn type. Add support for approve UI for this new txn type #295

Closed
wants to merge 1 commit into from
Closed
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
12 changes: 12 additions & 0 deletions src/app/approve/approve.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ import {
TransactionMetadataUnregisterAsValidator,
TransactionMetadataStake,
TransactionMetadataUnstake,
TransactionMetadataUnlockStake,
} from '../../lib/deso/transaction';
import { ExtraData } from '../../types/identity';
import { AccountService } from '../account.service';
Expand Down Expand Up @@ -623,6 +624,17 @@ export class ApproveComponent implements OnInit {
);
description = `unstake ${unstakeAmountNanos} $DESO from ${unstakeValidatorPublicKey}`;
break;
case TransactionMetadataUnlockStake:
const unlockStakeMetadata = this.transaction
.metadata as TransactionMetadataUnlockStake;
const unlockStakeValidatorPublicKey = this.base58KeyCheck(
unlockStakeMetadata.validatorPublicKey
);
publicKeys = [unlockStakeValidatorPublicKey];
description =
`unlock stake from ${unlockStakeValidatorPublicKey}, ` +
`starting from epochs ${unlockStakeMetadata.startEpochNumber} to ${unlockStakeMetadata.endEpochNumber}`;
break;
}

// Set the transaction description based on the description populated with public keys.
Expand Down
2 changes: 2 additions & 0 deletions src/app/identity.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ import {
TransactionMetadataUnregisterAsValidator,
TransactionMetadataStake,
TransactionMetadataUnstake,
TransactionMetadataUnlockStake,
} from '../lib/deso/transaction';
import { SwalHelper } from '../lib/helpers/swal-helper';
import { AccessLevel, PublicUserInfo } from '../types/identity';
Expand Down Expand Up @@ -526,6 +527,7 @@ export class IdentityService {
case TransactionMetadataUnregisterAsValidator:
case TransactionMetadataStake:
case TransactionMetadataUnstake:
case TransactionMetadataUnlockStake:
return AccessLevel.Full;

case TransactionMetadataFollow:
Expand Down
12 changes: 12 additions & 0 deletions src/lib/deso/transaction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -631,6 +631,17 @@ export class TransactionMetadataUnstake extends TransactionMetadata {
unstakeAmountNanos: Buffer = Buffer.alloc(0);
}

export class TransactionMetadataUnlockStake extends TransactionMetadata {
@Transcode(VarBuffer)
validatorPublicKey: Buffer = Buffer.alloc(0);

@Transcode(Uvarint64)
startEpochNumber: number = 0;

@Transcode(Uvarint64)
endEpochNumber: number = 0;
}

export const TransactionTypeMetadataMap = {
1: TransactionMetadataBlockReward,
2: TransactionMetadataBasicTransfer,
Expand Down Expand Up @@ -668,6 +679,7 @@ export const TransactionTypeMetadataMap = {
35: TransactionMetadataUnregisterAsValidator,
36: TransactionMetadataStake,
37: TransactionMetadataUnstake,
38: TransactionMetadataUnlockStake,
};

export class Transaction extends BinaryRecord {
Expand Down
Loading