Skip to content

Commit

Permalink
feat: debug stake account creation
Browse files Browse the repository at this point in the history
  • Loading branch information
icfor committed Mar 19, 2024
1 parent 1eb2322 commit 33c21f0
Showing 1 changed file with 30 additions and 16 deletions.
46 changes: 30 additions & 16 deletions src/screens/staking/lib/staking_sdk/wallet_operations/solana.ts
Original file line number Diff line number Diff line change
Expand Up @@ -178,22 +178,12 @@ export const stakeAmountSolana = async ({
};
}

const newTx = new Transaction()
.add(
StakeProgram.createAccount({
authorized: new Authorized(accountKey, accountKey),
fromPubkey: accountKey,
lamports: amountToStake,
stakePubkey: stakeKeyPair.publicKey,
}),
)
.add(
StakeProgram.delegate({
authorizedPubkey: accountKey,
stakePubkey: stakeKeyPair.publicKey,
votePubkey: new PublicKey(validatorAddress),
}),
);
const newTx = StakeProgram.createAccount({
authorized: new Authorized(accountKey, accountKey),
fromPubkey: accountKey,
lamports: amountToStake,
stakePubkey: stakeKeyPair.publicKey,
});

newTx.recentBlockhash = (info as any).blockhash;
newTx.feePayer = accountKey;
Expand All @@ -205,6 +195,30 @@ export const stakeAmountSolana = async ({
// eslint-disable-next-line no-console
console.log("debug: solana.ts: result", stakeAccountResult);

await new Promise((resolve) => setTimeout(resolve, 10000));

const newInfo = await stakingClient.stake(
account.networkId,
account.address,
amount,
);

const newTx2 = StakeProgram.delegate({
authorizedPubkey: accountKey,
stakePubkey: stakeKeyPair.publicKey,
votePubkey: new PublicKey(validatorAddress),
});

newTx2.recentBlockhash = (newInfo as any).blockhash;
newTx2.feePayer = accountKey;

// newTx2.sign(stakeKeyPair);

const stakeAccountResult2 = await wallet.signAndSendTransaction(newTx2);

// eslint-disable-next-line no-console
console.log("debug: solana.ts: result", stakeAccountResult2);

return { success: true } as const;
}

Expand Down

0 comments on commit 33c21f0

Please sign in to comment.