Skip to content

signAndSendTransaction + signAndSendAllTransactions API#889

Open
0xproflupin wants to merge 7 commits into
anza-xyz:sign-and-send-all-transactionsfrom
0xproflupin:sign-and-send-all-transactions
Open

signAndSendTransaction + signAndSendAllTransactions API#889
0xproflupin wants to merge 7 commits into
anza-xyz:sign-and-send-all-transactionsfrom
0xproflupin:sign-and-send-all-transactions

Conversation

@0xproflupin

Copy link
Copy Markdown
Contributor

continued from #841

@socket-security

Copy link
Copy Markdown

@jordaaash jordaaash left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some of the changes are good, but I think we have to pay careful attention to the failure cases of the code, which will be common and varied.

Comment thread packages/core/base/src/adapter.ts Outdated
}

/** Mode for signing and sending transactions. */
export type SolanaSignAndSendTransactionMode = 'parallel' | 'serial';

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would prefer to re-export this from the @solana/wallet-standard-features package.

Comment thread packages/core/base/src/adapter.ts Outdated
connection: Connection,
options?: SignAndSendTransactionOptions
): Promise<(TransactionSignature | SignAndSendAllTransactionsError)[]>;
): Promise<(TransactionSignature | undefined)[]>;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Returning undefined is generally not ideal because the code may early return or simply return implicitly. Returning null is better because it's explicit.

Unfortunately returning either undefined or null isn't great, because it gives the caller no information about the failure.

What is an app supposed to do with this result? I don't think we can kick the can on having an error of some kind.

Comment thread packages/core/base/src/adapter.ts Outdated
code: result.reason.code,
message: result.reason.message,
};
return result.status === 'fulfilled' ? result.value : undefined;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here.

Comment thread packages/wallets/phantom/src/adapter.ts Outdated
);
sendOptions.preflightCommitment = sendOptions.preflightCommitment || connection.commitment;

const { signatures } = await wallet.signAndSendAllTransactions(transactions, sendOptions);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think we can call this without feature detection because there's no guarantee of what version of the wallet the user has that supports this method. If it's older, it'll just null reference with nothing for the app to do.

We should consider having/calling a super method for this that will do signAllTransactions and send them after, in the same way we have sendTransaction in the base class if only signTransaction is supported.

@0xproflupin 0xproflupin Feb 2, 2024

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suppose we don't even need to add an implementation for signAndSendAll in individual wallet adapters (other than the unsafe burner, where we won't have to do feature detection)?

@jordaaash jordaaash mentioned this pull request Jun 10, 2025
9 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants