web3.js: add accounts support to simulateTransaction (#19590)
* feat: add accounts support to simulateTransaction * feat: introduce test for simulateTransaction on Message objects * feat: populate transaction from message defaults to no signatures * fix: remove unused constant * fix: small formatting error * fix: eslint and prettier were fighting over ternary indentation * fix: make simulated transaction result accounts nullable
This commit is contained in:
@@ -666,7 +666,10 @@ export class Transaction {
|
||||
/**
|
||||
* Populate Transaction object from message and signatures
|
||||
*/
|
||||
static populate(message: Message, signatures: Array<string>): Transaction {
|
||||
static populate(
|
||||
message: Message,
|
||||
signatures: Array<string> = [],
|
||||
): Transaction {
|
||||
const transaction = new Transaction();
|
||||
transaction.recentBlockhash = message.recentBlockhash;
|
||||
if (message.header.numRequiredSignatures > 0) {
|
||||
@@ -688,9 +691,10 @@ export class Transaction {
|
||||
const pubkey = message.accountKeys[account];
|
||||
return {
|
||||
pubkey,
|
||||
isSigner: transaction.signatures.some(
|
||||
keyObj => keyObj.publicKey.toString() === pubkey.toString(),
|
||||
),
|
||||
isSigner:
|
||||
transaction.signatures.some(
|
||||
keyObj => keyObj.publicKey.toString() === pubkey.toString(),
|
||||
) || message.isAccountSigner(account),
|
||||
isWritable: message.isAccountWritable(account),
|
||||
};
|
||||
});
|
||||
|
Reference in New Issue
Block a user