Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Add sign and send all transactions feature #69

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/empty-onions-lay.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@solana/wallet-standard-features': minor
---

Add solana:signAndSendAllTransactions feature
5 changes: 4 additions & 1 deletion packages/core/features/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,15 @@ import type { SolanaSignAndSendTransactionFeature } from './signAndSendTransacti
import type { SolanaSignInFeature } from './signIn.js';
import type { SolanaSignMessageFeature } from './signMessage.js';
import type { SolanaSignTransactionFeature } from './signTransaction.js';
import type { SolanaSignAndSendAllTransactionsFeature } from './signAndSendAllTransactions.js';

/** TODO: docs */
export type SolanaFeatures =
| SolanaSignAndSendTransactionFeature
| SolanaSignInFeature
| SolanaSignMessageFeature
| SolanaSignTransactionFeature;
| SolanaSignTransactionFeature
| SolanaSignAndSendAllTransactionsFeature;

/** TODO: docs */
export type WalletWithSolanaFeatures = WalletWithFeatures<SolanaFeatures>;
Expand All @@ -18,3 +20,4 @@ export * from './signAndSendTransaction.js';
export * from './signIn.js';
export * from './signMessage.js';
export * from './signTransaction.js';
export * from './signAndSendAllTransactions.js';
48 changes: 48 additions & 0 deletions packages/core/features/src/signAndSendAllTransactions.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
import type { SolanaTransactionVersion } from './signTransaction.js';
import type {
SolanaSignAndSendTransactionInput,
SolanaSignAndSendTransactionOutput,
} from './signAndSendTransaction.js';

/** Name of the feature */
export const SignAndSendAllTransactions = 'solana:signAndSendAllTransactions';

/** TODO: docs */
export type SolanaSignAndSendAllTransactionsFeature = {
/** Name of the feature. */
readonly [SignAndSendAllTransactions]: {
/** Version of the feature API. */
readonly version: SolanaSignAndSendAllTransactionsVersion;

/** TODO: docs */
readonly supportedTransactionVersions: readonly SolanaTransactionVersion[];

/**
* Sign transactions using the account's secret key and send them to the chain.
*
* @param inputs {SolanaSignAndSendTransactionInput[]} Inputs for signing and sending multiple transactions.
* @param options {SolanaSignAndSendAllTransactionsOptions} Options for signing and sending transactions.
*
* @return Outputs of signing and sending transactions.
*/
readonly signAndSendAllTransactions: SolanaSignAndSendAllTransactionsMethod;
};
};

/** Version of the feature. */
export type SolanaSignAndSendAllTransactionsVersion = '1.0.0';

/** TODO: docs */
export type SolanaSignAndSendAllTransactionsMethod = (
inputs: readonly SolanaSignAndSendTransactionInput[],
options?: SolanaSignAndSendAllTransactionsOptions
) => Promise<readonly PromiseSettledResult<SolanaSignAndSendTransactionOutput>[]>;

/** Options for signing and sending multiple transactions. */
export type SolanaSignAndSendAllTransactionsOptions = {
/** Mode for signing and sending transactions. */
readonly mode?: SolanaSignAndSendAllTransactionsMode;
};

/** Mode for signing and sending transactions. */
export type SolanaSignAndSendAllTransactionsMode = 'parallel' | 'serial';
6 changes: 0 additions & 6 deletions packages/core/features/src/signAndSendTransaction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,6 @@ export interface SolanaSignAndSendTransactionOutput {

/** Options for signing and sending a transaction. */
export type SolanaSignAndSendTransactionOptions = SolanaSignTransactionOptions & {
/** Mode for signing and sending transactions. */
readonly mode?: SolanaSignAndSendTransactionMode;

/** Desired commitment level. If provided, confirm the transaction after sending. */
readonly commitment?: SolanaTransactionCommitment;

Expand All @@ -67,6 +64,3 @@ export type SolanaSignAndSendTransactionOptions = SolanaSignTransactionOptions &
/** Maximum number of times for the RPC node to retry sending the transaction to the leader. */
readonly maxRetries?: number;
};

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