@unio-aggregator/unio-tx-sender 1.0.0 → 1.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.cts CHANGED
@@ -1,13 +1,11 @@
1
- import { Rpc, SolanaRpcApi, Instruction, TransactionSigner, Address, SendableTransaction, Transaction, TransactionWithLifetime, Commitment, Signature, KeyPairSigner } from '@solana/kit';
1
+ import { BlockhashLifetimeConstraint, Rpc, SolanaRpcApi, Instruction, TransactionSigner, Address, MaybeAccount, SendableTransaction, Transaction, TransactionWithLifetime, TransactionMessage, TransactionMessageWithFeePayer, Signature, Commitment, KeyPairSigner } from '@solana/kit';
2
+ import { AddressLookupTable } from '@solana-program/address-lookup-table';
2
3
 
3
4
  /**
4
5
  * Default compute unit margin multiplier used to ensure sufficient compute budget.
5
6
  */
6
7
  declare const DEFAULT_COMPUTE_UNIT_MARGIN_MULTIPLIER = 1.15;
7
- /**
8
- * Default prioritization settings, including priority fees and Jito tips.
9
- */
10
- declare const DEFAULT_TRANSACTION_CONFIG: TransactionConfig;
8
+ declare const DEFAULT_JITO_BLOCK_ENGINE_URL = "https://bundles.jito.wtf";
11
9
  type FeeSetting = {
12
10
  type: "dynamic";
13
11
  maxCapLamports?: bigint;
@@ -26,20 +24,18 @@ type JitoFeeSetting = FeeSetting & {
26
24
  type PriorityFeeSetting = FeeSetting & {
27
25
  priorityFeePercentile?: Percentile;
28
26
  };
29
- type TransactionConfig = {
30
- jito: JitoFeeSetting;
31
- priorityFee: PriorityFeeSetting;
32
- computeUnitMarginMultiplier: number;
33
- jitoBlockEngineUrl: string;
34
- };
35
27
  /**
36
28
  * Defines a percentile value for priority fee selection.
37
29
  */
38
30
  type Percentile = "25" | "50" | "75" | "95" | "99";
39
- /**
40
- * Represents a supported blockchain network chain ID.
41
- */
42
- type ChainId = "solana" | "eclipse" | "solana-devnet" | "eclipse-testnet" | "unknown";
31
+ type TransactionConfig = {
32
+ jito?: JitoFeeSetting;
33
+ priorityFee?: PriorityFeeSetting;
34
+ computeUnitMarginMultiplier?: number;
35
+ jitoBlockEngineUrl?: string;
36
+ skipSimulation?: boolean;
37
+ blockhash?: BlockhashLifetimeConstraint;
38
+ };
43
39
 
44
40
  /**
45
41
  * Builds and signs a transaction from the given instructions and configuration.
@@ -48,7 +44,7 @@ type ChainId = "solana" | "eclipse" | "solana-devnet" | "eclipse-testnet" | "unk
48
44
  * @param {TransactionConfig} config - The transaction config.
49
45
  * @param {Instruction[]} instructions - Array of instructions to include in the transaction
50
46
  * @param {TransactionSigner} feePayer - The signer that will pay for the transaction
51
- * @param {(Address | string)[]} [lookupTableAddresses] - Optional array of address lookup table addresses to compress the transaction
47
+ * @param {(Address | string)[]} [lookupTableAccounts] - Optional array of address lookup table accounts to compress the transaction
52
48
  *
53
49
  * @returns {Promise<Readonly<SendableTransaction & Transaction & TransactionWithLifetime>>} A signed and encoded transaction
54
50
  *
@@ -61,7 +57,95 @@ type ChainId = "solana" | "eclipse" | "solana-devnet" | "eclipse-testnet" | "unk
61
57
  * feePayer,
62
58
  * );
63
59
  */
64
- declare function buildTransaction(rpc: Rpc<SolanaRpcApi>, config: TransactionConfig, instructions: Instruction[], feePayer: TransactionSigner | Address, lookupTableAddresses?: Address[]): Promise<Readonly<SendableTransaction & Transaction & TransactionWithLifetime>>;
60
+ declare function buildTransaction(rpc: Rpc<SolanaRpcApi>, instructions: Instruction[], feePayer: TransactionSigner | Address, config: TransactionConfig, lookupTableAccounts?: MaybeAccount<AddressLookupTable>[]): Promise<Readonly<SendableTransaction & Transaction & TransactionWithLifetime>>;
61
+
62
+ type AccountConfig = {
63
+ accountIndex: number;
64
+ addresses: string[];
65
+ };
66
+ type JitoAccountInfo = {
67
+ executable: boolean;
68
+ owner: string;
69
+ lamports: number;
70
+ data: string;
71
+ rentEpoch: number;
72
+ };
73
+ type JitoRpcApi = SolanaRpcApi & {
74
+ simulateBundle: (params: {
75
+ encodedTransactions: string[];
76
+ }, config?: {
77
+ preExecutionAccountsConfigs?: AccountConfig;
78
+ postExecutionAccountsConfigs?: AccountConfig;
79
+ skipSigVerify?: boolean;
80
+ simulationBank?: {
81
+ commitment?: {
82
+ commitment: "processed" | "confirmed" | "finalized";
83
+ };
84
+ };
85
+ transactionEncoding?: "base64";
86
+ replaceRecentBlockhash?: boolean;
87
+ }) => SimulateBundleResponse;
88
+ sendBundle: (params: string[], config?: {
89
+ encoding?: "base64";
90
+ }) => string;
91
+ getBundleStatuses: (params: string[]) => GetBundleStatusesResponse;
92
+ };
93
+ type SimulateBundleResponse = {
94
+ context: {
95
+ slot: number;
96
+ apiVersion?: string;
97
+ };
98
+ value: {
99
+ summary: "succeeded" | {
100
+ failed: {
101
+ error: unknown;
102
+ tx_signature: string;
103
+ };
104
+ };
105
+ transactionResults: Array<{
106
+ err: unknown;
107
+ logs: string[] | null;
108
+ unitsConsumed?: number;
109
+ returnData: {
110
+ programId: string;
111
+ data: string;
112
+ } | null;
113
+ preExecutionAccounts: JitoAccountInfo[] | null;
114
+ postExecutionAccounts: JitoAccountInfo[] | null;
115
+ }>;
116
+ };
117
+ };
118
+ type GetBundleStatusesResponse = {
119
+ context: {
120
+ slot: number;
121
+ };
122
+ value: Array<{
123
+ bundleId: string;
124
+ transactions: string[];
125
+ slot: number;
126
+ confirmation_status: "processed" | "confirmed" | "finalized";
127
+ err: {
128
+ Ok: null;
129
+ } | {
130
+ Err: object;
131
+ };
132
+ }>;
133
+ };
134
+ declare enum JitoApiUrl {
135
+ Amsterdam = "https://amsterdam.mainnet.block-engine.jito.wtf",
136
+ Frankfurt = "https://frankfurt.mainnet.block-engine.jito.wtf",
137
+ London = "https://london.mainnet.block-engine.jito.wtf",
138
+ NY = "https://ny.mainnet.block-engine.jito.wtf",
139
+ Singapore = "https://singapore.mainnet.block-engine.jito.wtf",
140
+ SLC = "https://slc.mainnet.block-engine.jito.wtf",
141
+ Tokyo = "https://tokyo.mainnet.block-engine.jito.wtf",
142
+ Default = "https://mainnet.block-engine.jito.wtf"
143
+ }
144
+ declare function processJitoTipForTxMessage(message: TransactionMessage & TransactionMessageWithFeePayer, signer: TransactionSigner, config: TransactionConfig): Promise<TransactionMessage & TransactionMessageWithFeePayer<string>>;
145
+ declare function recentJitoTip(config: TransactionConfig): Promise<bigint>;
146
+ declare function sendJitoBundle(jitoApiUrl: JitoApiUrl, transactions: (SendableTransaction & Transaction & TransactionWithLifetime)[], jitoUUID?: string): Promise<string>;
147
+ declare function simulateBundle(rpc: Rpc<JitoRpcApi>, transactions: (SendableTransaction & Transaction & TransactionWithLifetime)[]): Promise<SimulateBundleResponse>;
148
+ declare function sendBundle(rpc: Rpc<JitoRpcApi>, transactions: (SendableTransaction & Transaction & TransactionWithLifetime)[]): Promise<string>;
65
149
 
66
150
  /**
67
151
  * Builds and sends a transaction with the given instructions, signers, and commitment level.
@@ -70,7 +154,7 @@ declare function buildTransaction(rpc: Rpc<SolanaRpcApi>, config: TransactionCon
70
154
  * @param {Instruction[]} instructions - Array of instructions to include in the transaction.
71
155
  * @param {KeyPairSigner} payer - The fee payer for the transaction.
72
156
  * @param {TransactionConfig} config - The transaction config.
73
- * @param {Address[]} [lookupTableAddresses] - Optional array of address lookup table addresses to use.
157
+ * @param {Address[]} [lookupTableAccounts] - Optional array of address lookup table accounts to use.
74
158
  * @param {Commitment} [commitment="confirmed"] - The commitment level for transaction confirmation.
75
159
  *
76
160
  * @returns {Promise<Signature>} A promise that resolves to the transaction signature.
@@ -88,12 +172,13 @@ declare function buildTransaction(rpc: Rpc<SolanaRpcApi>, config: TransactionCon
88
172
  * );
89
173
  * ```
90
174
  */
91
- declare function sendTransaction(rpc: Rpc<SolanaRpcApi>, instructions: Instruction[], payer: KeyPairSigner, config?: TransactionConfig, lookupTableAddresses?: Address[], commitment?: Commitment): Promise<Signature>;
175
+ declare function sendTransaction(rpc: Rpc<SolanaRpcApi>, instructions: Instruction[], payer: KeyPairSigner, config?: TransactionConfig, lookupTableAccounts?: MaybeAccount<AddressLookupTable>[], commitment?: Commitment): Promise<Signature>;
92
176
  /**
93
177
  * Sends a signed transaction message to the Solana network with a specified commitment level.
94
178
  *
95
179
  * @param {Rpc<SolanaRpcApi>} rpc - Rpc client.
96
180
  * @param {SendableTransaction & Transaction & TransactionWithLifetime} transaction - The fully signed transaction to send.
181
+ * @param {boolean} skipSimulation - True if skip simulation
97
182
  * @param {Commitment} [commitment="confirmed"] - The commitment level for transaction confirmation.
98
183
  *
99
184
  * @returns {Promise<Signature>} A promise that resolves to the transaction signature.
@@ -109,6 +194,7 @@ declare function sendTransaction(rpc: Rpc<SolanaRpcApi>, instructions: Instructi
109
194
  * );
110
195
  * ```
111
196
  */
112
- declare function sendSignedTransaction(rpc: Rpc<SolanaRpcApi>, transaction: SendableTransaction & Transaction & TransactionWithLifetime, commitment?: Commitment): Promise<Signature>;
197
+ declare function sendSignedTransaction(rpc: Rpc<SolanaRpcApi>, transaction: SendableTransaction & Transaction & TransactionWithLifetime, skipSimulation?: boolean, commitment?: Commitment): Promise<Signature>;
198
+ declare function getTxSignature(transaction: Transaction): Signature;
113
199
 
114
- export { type ChainId, DEFAULT_COMPUTE_UNIT_MARGIN_MULTIPLIER, DEFAULT_TRANSACTION_CONFIG, type JitoFeeSetting, type Percentile, type PriorityFeeSetting, type TransactionConfig, buildTransaction, sendSignedTransaction, sendTransaction };
200
+ export { type AccountConfig, DEFAULT_COMPUTE_UNIT_MARGIN_MULTIPLIER, DEFAULT_JITO_BLOCK_ENGINE_URL, type GetBundleStatusesResponse, type JitoAccountInfo, JitoApiUrl, type JitoFeeSetting, type JitoRpcApi, type Percentile, type PriorityFeeSetting, type SimulateBundleResponse, type TransactionConfig, buildTransaction, getTxSignature, processJitoTipForTxMessage, recentJitoTip, sendBundle, sendJitoBundle, sendSignedTransaction, sendTransaction, simulateBundle };
package/dist/index.d.ts CHANGED
@@ -1,13 +1,11 @@
1
- import { Rpc, SolanaRpcApi, Instruction, TransactionSigner, Address, SendableTransaction, Transaction, TransactionWithLifetime, Commitment, Signature, KeyPairSigner } from '@solana/kit';
1
+ import { BlockhashLifetimeConstraint, Rpc, SolanaRpcApi, Instruction, TransactionSigner, Address, MaybeAccount, SendableTransaction, Transaction, TransactionWithLifetime, TransactionMessage, TransactionMessageWithFeePayer, Signature, Commitment, KeyPairSigner } from '@solana/kit';
2
+ import { AddressLookupTable } from '@solana-program/address-lookup-table';
2
3
 
3
4
  /**
4
5
  * Default compute unit margin multiplier used to ensure sufficient compute budget.
5
6
  */
6
7
  declare const DEFAULT_COMPUTE_UNIT_MARGIN_MULTIPLIER = 1.15;
7
- /**
8
- * Default prioritization settings, including priority fees and Jito tips.
9
- */
10
- declare const DEFAULT_TRANSACTION_CONFIG: TransactionConfig;
8
+ declare const DEFAULT_JITO_BLOCK_ENGINE_URL = "https://bundles.jito.wtf";
11
9
  type FeeSetting = {
12
10
  type: "dynamic";
13
11
  maxCapLamports?: bigint;
@@ -26,20 +24,18 @@ type JitoFeeSetting = FeeSetting & {
26
24
  type PriorityFeeSetting = FeeSetting & {
27
25
  priorityFeePercentile?: Percentile;
28
26
  };
29
- type TransactionConfig = {
30
- jito: JitoFeeSetting;
31
- priorityFee: PriorityFeeSetting;
32
- computeUnitMarginMultiplier: number;
33
- jitoBlockEngineUrl: string;
34
- };
35
27
  /**
36
28
  * Defines a percentile value for priority fee selection.
37
29
  */
38
30
  type Percentile = "25" | "50" | "75" | "95" | "99";
39
- /**
40
- * Represents a supported blockchain network chain ID.
41
- */
42
- type ChainId = "solana" | "eclipse" | "solana-devnet" | "eclipse-testnet" | "unknown";
31
+ type TransactionConfig = {
32
+ jito?: JitoFeeSetting;
33
+ priorityFee?: PriorityFeeSetting;
34
+ computeUnitMarginMultiplier?: number;
35
+ jitoBlockEngineUrl?: string;
36
+ skipSimulation?: boolean;
37
+ blockhash?: BlockhashLifetimeConstraint;
38
+ };
43
39
 
44
40
  /**
45
41
  * Builds and signs a transaction from the given instructions and configuration.
@@ -48,7 +44,7 @@ type ChainId = "solana" | "eclipse" | "solana-devnet" | "eclipse-testnet" | "unk
48
44
  * @param {TransactionConfig} config - The transaction config.
49
45
  * @param {Instruction[]} instructions - Array of instructions to include in the transaction
50
46
  * @param {TransactionSigner} feePayer - The signer that will pay for the transaction
51
- * @param {(Address | string)[]} [lookupTableAddresses] - Optional array of address lookup table addresses to compress the transaction
47
+ * @param {(Address | string)[]} [lookupTableAccounts] - Optional array of address lookup table accounts to compress the transaction
52
48
  *
53
49
  * @returns {Promise<Readonly<SendableTransaction & Transaction & TransactionWithLifetime>>} A signed and encoded transaction
54
50
  *
@@ -61,7 +57,95 @@ type ChainId = "solana" | "eclipse" | "solana-devnet" | "eclipse-testnet" | "unk
61
57
  * feePayer,
62
58
  * );
63
59
  */
64
- declare function buildTransaction(rpc: Rpc<SolanaRpcApi>, config: TransactionConfig, instructions: Instruction[], feePayer: TransactionSigner | Address, lookupTableAddresses?: Address[]): Promise<Readonly<SendableTransaction & Transaction & TransactionWithLifetime>>;
60
+ declare function buildTransaction(rpc: Rpc<SolanaRpcApi>, instructions: Instruction[], feePayer: TransactionSigner | Address, config: TransactionConfig, lookupTableAccounts?: MaybeAccount<AddressLookupTable>[]): Promise<Readonly<SendableTransaction & Transaction & TransactionWithLifetime>>;
61
+
62
+ type AccountConfig = {
63
+ accountIndex: number;
64
+ addresses: string[];
65
+ };
66
+ type JitoAccountInfo = {
67
+ executable: boolean;
68
+ owner: string;
69
+ lamports: number;
70
+ data: string;
71
+ rentEpoch: number;
72
+ };
73
+ type JitoRpcApi = SolanaRpcApi & {
74
+ simulateBundle: (params: {
75
+ encodedTransactions: string[];
76
+ }, config?: {
77
+ preExecutionAccountsConfigs?: AccountConfig;
78
+ postExecutionAccountsConfigs?: AccountConfig;
79
+ skipSigVerify?: boolean;
80
+ simulationBank?: {
81
+ commitment?: {
82
+ commitment: "processed" | "confirmed" | "finalized";
83
+ };
84
+ };
85
+ transactionEncoding?: "base64";
86
+ replaceRecentBlockhash?: boolean;
87
+ }) => SimulateBundleResponse;
88
+ sendBundle: (params: string[], config?: {
89
+ encoding?: "base64";
90
+ }) => string;
91
+ getBundleStatuses: (params: string[]) => GetBundleStatusesResponse;
92
+ };
93
+ type SimulateBundleResponse = {
94
+ context: {
95
+ slot: number;
96
+ apiVersion?: string;
97
+ };
98
+ value: {
99
+ summary: "succeeded" | {
100
+ failed: {
101
+ error: unknown;
102
+ tx_signature: string;
103
+ };
104
+ };
105
+ transactionResults: Array<{
106
+ err: unknown;
107
+ logs: string[] | null;
108
+ unitsConsumed?: number;
109
+ returnData: {
110
+ programId: string;
111
+ data: string;
112
+ } | null;
113
+ preExecutionAccounts: JitoAccountInfo[] | null;
114
+ postExecutionAccounts: JitoAccountInfo[] | null;
115
+ }>;
116
+ };
117
+ };
118
+ type GetBundleStatusesResponse = {
119
+ context: {
120
+ slot: number;
121
+ };
122
+ value: Array<{
123
+ bundleId: string;
124
+ transactions: string[];
125
+ slot: number;
126
+ confirmation_status: "processed" | "confirmed" | "finalized";
127
+ err: {
128
+ Ok: null;
129
+ } | {
130
+ Err: object;
131
+ };
132
+ }>;
133
+ };
134
+ declare enum JitoApiUrl {
135
+ Amsterdam = "https://amsterdam.mainnet.block-engine.jito.wtf",
136
+ Frankfurt = "https://frankfurt.mainnet.block-engine.jito.wtf",
137
+ London = "https://london.mainnet.block-engine.jito.wtf",
138
+ NY = "https://ny.mainnet.block-engine.jito.wtf",
139
+ Singapore = "https://singapore.mainnet.block-engine.jito.wtf",
140
+ SLC = "https://slc.mainnet.block-engine.jito.wtf",
141
+ Tokyo = "https://tokyo.mainnet.block-engine.jito.wtf",
142
+ Default = "https://mainnet.block-engine.jito.wtf"
143
+ }
144
+ declare function processJitoTipForTxMessage(message: TransactionMessage & TransactionMessageWithFeePayer, signer: TransactionSigner, config: TransactionConfig): Promise<TransactionMessage & TransactionMessageWithFeePayer<string>>;
145
+ declare function recentJitoTip(config: TransactionConfig): Promise<bigint>;
146
+ declare function sendJitoBundle(jitoApiUrl: JitoApiUrl, transactions: (SendableTransaction & Transaction & TransactionWithLifetime)[], jitoUUID?: string): Promise<string>;
147
+ declare function simulateBundle(rpc: Rpc<JitoRpcApi>, transactions: (SendableTransaction & Transaction & TransactionWithLifetime)[]): Promise<SimulateBundleResponse>;
148
+ declare function sendBundle(rpc: Rpc<JitoRpcApi>, transactions: (SendableTransaction & Transaction & TransactionWithLifetime)[]): Promise<string>;
65
149
 
66
150
  /**
67
151
  * Builds and sends a transaction with the given instructions, signers, and commitment level.
@@ -70,7 +154,7 @@ declare function buildTransaction(rpc: Rpc<SolanaRpcApi>, config: TransactionCon
70
154
  * @param {Instruction[]} instructions - Array of instructions to include in the transaction.
71
155
  * @param {KeyPairSigner} payer - The fee payer for the transaction.
72
156
  * @param {TransactionConfig} config - The transaction config.
73
- * @param {Address[]} [lookupTableAddresses] - Optional array of address lookup table addresses to use.
157
+ * @param {Address[]} [lookupTableAccounts] - Optional array of address lookup table accounts to use.
74
158
  * @param {Commitment} [commitment="confirmed"] - The commitment level for transaction confirmation.
75
159
  *
76
160
  * @returns {Promise<Signature>} A promise that resolves to the transaction signature.
@@ -88,12 +172,13 @@ declare function buildTransaction(rpc: Rpc<SolanaRpcApi>, config: TransactionCon
88
172
  * );
89
173
  * ```
90
174
  */
91
- declare function sendTransaction(rpc: Rpc<SolanaRpcApi>, instructions: Instruction[], payer: KeyPairSigner, config?: TransactionConfig, lookupTableAddresses?: Address[], commitment?: Commitment): Promise<Signature>;
175
+ declare function sendTransaction(rpc: Rpc<SolanaRpcApi>, instructions: Instruction[], payer: KeyPairSigner, config?: TransactionConfig, lookupTableAccounts?: MaybeAccount<AddressLookupTable>[], commitment?: Commitment): Promise<Signature>;
92
176
  /**
93
177
  * Sends a signed transaction message to the Solana network with a specified commitment level.
94
178
  *
95
179
  * @param {Rpc<SolanaRpcApi>} rpc - Rpc client.
96
180
  * @param {SendableTransaction & Transaction & TransactionWithLifetime} transaction - The fully signed transaction to send.
181
+ * @param {boolean} skipSimulation - True if skip simulation
97
182
  * @param {Commitment} [commitment="confirmed"] - The commitment level for transaction confirmation.
98
183
  *
99
184
  * @returns {Promise<Signature>} A promise that resolves to the transaction signature.
@@ -109,6 +194,7 @@ declare function sendTransaction(rpc: Rpc<SolanaRpcApi>, instructions: Instructi
109
194
  * );
110
195
  * ```
111
196
  */
112
- declare function sendSignedTransaction(rpc: Rpc<SolanaRpcApi>, transaction: SendableTransaction & Transaction & TransactionWithLifetime, commitment?: Commitment): Promise<Signature>;
197
+ declare function sendSignedTransaction(rpc: Rpc<SolanaRpcApi>, transaction: SendableTransaction & Transaction & TransactionWithLifetime, skipSimulation?: boolean, commitment?: Commitment): Promise<Signature>;
198
+ declare function getTxSignature(transaction: Transaction): Signature;
113
199
 
114
- export { type ChainId, DEFAULT_COMPUTE_UNIT_MARGIN_MULTIPLIER, DEFAULT_TRANSACTION_CONFIG, type JitoFeeSetting, type Percentile, type PriorityFeeSetting, type TransactionConfig, buildTransaction, sendSignedTransaction, sendTransaction };
200
+ export { type AccountConfig, DEFAULT_COMPUTE_UNIT_MARGIN_MULTIPLIER, DEFAULT_JITO_BLOCK_ENGINE_URL, type GetBundleStatusesResponse, type JitoAccountInfo, JitoApiUrl, type JitoFeeSetting, type JitoRpcApi, type Percentile, type PriorityFeeSetting, type SimulateBundleResponse, type TransactionConfig, buildTransaction, getTxSignature, processJitoTipForTxMessage, recentJitoTip, sendBundle, sendJitoBundle, sendSignedTransaction, sendTransaction, simulateBundle };