feat: exposing merge command
Co-authored-by: Tyera Eulberg <teulberg@gmail.com>
This commit is contained in:
committed by
Tyera Eulberg
parent
414d904959
commit
c5eb3f1394
@ -166,6 +166,14 @@ export type DeactivateStakeParams = {
|
|||||||
authorizedPubkey: PublicKey;
|
authorizedPubkey: PublicKey;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Deactivate stake instruction params
|
||||||
|
*/
|
||||||
|
export type MergeStakeParams = {
|
||||||
|
stakePubkey: PublicKey;
|
||||||
|
sourceStakePubKey: PublicKey;
|
||||||
|
authorizedPubkey: PublicKey;
|
||||||
|
};
|
||||||
/**
|
/**
|
||||||
* Stake Instruction class
|
* Stake Instruction class
|
||||||
*/
|
*/
|
||||||
@ -399,7 +407,8 @@ export type StakeInstructionType =
|
|||||||
| 'Delegate'
|
| 'Delegate'
|
||||||
| 'Initialize'
|
| 'Initialize'
|
||||||
| 'Split'
|
| 'Split'
|
||||||
| 'Withdraw';
|
| 'Withdraw'
|
||||||
|
| 'Merge';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* An enumeration of valid stake InstructionType's
|
* An enumeration of valid stake InstructionType's
|
||||||
@ -446,6 +455,15 @@ export const STAKE_INSTRUCTION_LAYOUTS: {
|
|||||||
index: 5,
|
index: 5,
|
||||||
layout: BufferLayout.struct([BufferLayout.u32('instruction')]),
|
layout: BufferLayout.struct([BufferLayout.u32('instruction')]),
|
||||||
},
|
},
|
||||||
|
Merge: {
|
||||||
|
index: 7,
|
||||||
|
layout: BufferLayout.struct([
|
||||||
|
BufferLayout.u32('instruction'),
|
||||||
|
Layout.publicKey('stakePubKey'),
|
||||||
|
Layout.publicKey('sourceStakePubKey'),
|
||||||
|
Layout.publicKey('authorityOwner'),
|
||||||
|
]),
|
||||||
|
},
|
||||||
AuthorizeWithSeed: {
|
AuthorizeWithSeed: {
|
||||||
index: 8,
|
index: 8,
|
||||||
layout: BufferLayout.struct([
|
layout: BufferLayout.struct([
|
||||||
@ -706,6 +724,31 @@ export class StakeProgram {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Generate a Transaction that merges Stake accounts.
|
||||||
|
*/
|
||||||
|
static merge(params: MergeStakeParams): Transaction {
|
||||||
|
const {stakePubkey, authorizedPubkey, sourceStakePubKey} = params;
|
||||||
|
const type = STAKE_INSTRUCTION_LAYOUTS.Merge;
|
||||||
|
const data = encodeData(type);
|
||||||
|
|
||||||
|
return new Transaction().add({
|
||||||
|
keys: [
|
||||||
|
{pubkey: stakePubkey, isSigner: false, isWritable: true},
|
||||||
|
{pubkey: sourceStakePubKey, isSigner: false, isWritable: true},
|
||||||
|
{pubkey: SYSVAR_CLOCK_PUBKEY, isSigner: false, isWritable: false},
|
||||||
|
{
|
||||||
|
pubkey: SYSVAR_STAKE_HISTORY_PUBKEY,
|
||||||
|
isSigner: false,
|
||||||
|
isWritable: false,
|
||||||
|
},
|
||||||
|
{pubkey: authorizedPubkey, isSigner: true, isWritable: false},
|
||||||
|
],
|
||||||
|
programId: this.programId,
|
||||||
|
data,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Generate a Transaction that withdraws deactivated Stake tokens.
|
* Generate a Transaction that withdraws deactivated Stake tokens.
|
||||||
*/
|
*/
|
||||||
|
Reference in New Issue
Block a user