diff --git a/web3.js/src/stake-program.js b/web3.js/src/stake-program.js index 183c65d03f..6c0468dd12 100644 --- a/web3.js/src/stake-program.js +++ b/web3.js/src/stake-program.js @@ -381,6 +381,7 @@ export class StakeProgram { this.space, this.programId, ); + transaction.instructions[0].keys[0].isSigner = false; const type = StakeInstructionLayout.Split; const data = encodeData(type, {lamports}); diff --git a/web3.js/test/stake-program.test.js b/web3.js/test/stake-program.test.js index 09d9cf8186..c0f9d149f2 100644 --- a/web3.js/test/stake-program.test.js +++ b/web3.js/test/stake-program.test.js @@ -266,7 +266,7 @@ test('live staking actions', async () => { seed, new Authorized(authorized.publicKey, authorized.publicKey), new Lockup(0, 0, new PublicKey('0x00')), - 2 * minimumAmount + 42, + 3 * minimumAmount + 42, ); await sendAndConfirmRecentTransaction( @@ -275,7 +275,7 @@ test('live staking actions', async () => { from, ); let originalStakeBalance = await connection.getBalance(newAccountPubkey); - expect(originalStakeBalance).toEqual(2 * minimumAmount + 42); + expect(originalStakeBalance).toEqual(3 * minimumAmount + 42); let delegation = StakeProgram.delegate( newAccountPubkey, @@ -296,6 +296,21 @@ test('live staking actions', async () => { sendAndConfirmRecentTransaction(connection, withdraw, authorized), ).rejects.toThrow(); + // Split stake + const newStake = new Account(); + let split = StakeProgram.split( + newAccountPubkey, + authorized.publicKey, + minimumAmount + 20, + newStake.publicKey, + ); + await sendAndConfirmRecentTransaction( + connection, + split, + authorized, + newStake, + ); + // Authorize to new account const newAuthorized = new Account(); await connection.requestAirdrop(newAuthorized.publicKey, LAMPORTS_PER_SOL); @@ -344,7 +359,7 @@ test('live staking actions', async () => { ); await sendAndConfirmRecentTransaction(connection, withdraw, newAuthorized); const balance = await connection.getBalance(newAccountPubkey); - expect(balance).toEqual(minimumAmount + 22); + expect(balance).toEqual(minimumAmount + 2); const recipientBalance = await connection.getBalance(recipient.publicKey); expect(recipientBalance).toEqual(minimumAmount + 20); });