fix: align web3 stake split instruction constuction with rust

This commit is contained in:
Trent Nelson
2020-07-09 19:40:20 -06:00
committed by Trent Nelson
parent a8b1d71ae6
commit 19813b0ab2
2 changed files with 2 additions and 3 deletions

View File

@ -558,13 +558,12 @@ export class StakeProgram {
const {stakePubkey, authorizedPubkey, splitStakePubkey, lamports} = params; const {stakePubkey, authorizedPubkey, splitStakePubkey, lamports} = params;
let transaction = SystemProgram.createAccount({ let transaction = SystemProgram.createAccount({
fromPubkey: stakePubkey, fromPubkey: authorizedPubkey,
newAccountPubkey: splitStakePubkey, newAccountPubkey: splitStakePubkey,
lamports: 0, lamports: 0,
space: this.space, space: this.space,
programId: this.programId, programId: this.programId,
}); });
transaction.instructions[0].keys[0].isSigner = false;
const type = STAKE_INSTRUCTION_LAYOUTS.Split; const type = STAKE_INSTRUCTION_LAYOUTS.Split;
const data = encodeData(type, {lamports}); const data = encodeData(type, {lamports});

View File

@ -142,7 +142,7 @@ test('split', () => {
expect(transaction.instructions).toHaveLength(2); expect(transaction.instructions).toHaveLength(2);
const [systemInstruction, stakeInstruction] = transaction.instructions; const [systemInstruction, stakeInstruction] = transaction.instructions;
const systemParams = { const systemParams = {
fromPubkey: stakePubkey, fromPubkey: authorizedPubkey,
newAccountPubkey: splitStakePubkey, newAccountPubkey: splitStakePubkey,
lamports: 0, lamports: 0,
space: StakeProgram.space, space: StakeProgram.space,