@solana/kora 0.2.0-beta.1 → 0.2.0-beta.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/src/client.d.ts +20 -1
- package/dist/src/client.js +24 -0
- package/dist/src/types/index.d.ts +32 -2
- package/dist/test/unit.test.js +2 -0
- package/package.json +1 -1
package/dist/src/client.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Config, EstimateTransactionFeeRequest, EstimateTransactionFeeResponse, GetBlockhashResponse, GetSupportedTokensResponse, GetVersionResponse, SignAndSendTransactionRequest, SignAndSendTransactionResponse, SignTransactionRequest, SignTransactionResponse, SignBundleRequest, SignBundleResponse, SignAndSendBundleRequest, SignAndSendBundleResponse, TransferTransactionRequest, TransferTransactionResponse, KoraClientOptions, GetPayerSignerResponse, GetPaymentInstructionRequest, GetPaymentInstructionResponse } from './types/index.js';
|
|
1
|
+
import { Config, EstimateTransactionFeeRequest, EstimateTransactionFeeResponse, EstimateBundleFeeRequest, EstimateBundleFeeResponse, GetBlockhashResponse, GetSupportedTokensResponse, GetVersionResponse, SignAndSendTransactionRequest, SignAndSendTransactionResponse, SignTransactionRequest, SignTransactionResponse, SignBundleRequest, SignBundleResponse, SignAndSendBundleRequest, SignAndSendBundleResponse, TransferTransactionRequest, TransferTransactionResponse, KoraClientOptions, GetPayerSignerResponse, GetPaymentInstructionRequest, GetPaymentInstructionResponse } from './types/index.js';
|
|
2
2
|
/**
|
|
3
3
|
* Kora RPC client for interacting with the Kora paymaster service.
|
|
4
4
|
*
|
|
@@ -111,6 +111,25 @@ export declare class KoraClient {
|
|
|
111
111
|
* ```
|
|
112
112
|
*/
|
|
113
113
|
estimateTransactionFee(request: EstimateTransactionFeeRequest): Promise<EstimateTransactionFeeResponse>;
|
|
114
|
+
/**
|
|
115
|
+
* Estimates the bundle fee in both lamports and the specified token.
|
|
116
|
+
* @param request - Bundle fee estimation request parameters
|
|
117
|
+
* @param request.transactions - Array of base64-encoded transactions to estimate fees for
|
|
118
|
+
* @param request.fee_token - Mint address of the token to calculate fees in
|
|
119
|
+
* @returns Total fee amounts across all transactions in both lamports and the specified token
|
|
120
|
+
* @throws {Error} When the RPC call fails, the bundle is invalid, or the token is not supported
|
|
121
|
+
*
|
|
122
|
+
* @example
|
|
123
|
+
* ```typescript
|
|
124
|
+
* const fees = await client.estimateBundleFee({
|
|
125
|
+
* transactions: ['base64EncodedTransaction1', 'base64EncodedTransaction2'],
|
|
126
|
+
* fee_token: 'EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v' // USDC
|
|
127
|
+
* });
|
|
128
|
+
* console.log('Total fee in lamports:', fees.fee_in_lamports);
|
|
129
|
+
* console.log('Total fee in USDC:', fees.fee_in_token);
|
|
130
|
+
* ```
|
|
131
|
+
*/
|
|
132
|
+
estimateBundleFee(request: EstimateBundleFeeRequest): Promise<EstimateBundleFeeResponse>;
|
|
114
133
|
/**
|
|
115
134
|
* Signs a transaction with the Kora fee payer without broadcasting it.
|
|
116
135
|
* @param request - Sign request parameters
|
package/dist/src/client.js
CHANGED
|
@@ -167,6 +167,27 @@ export class KoraClient {
|
|
|
167
167
|
async estimateTransactionFee(request) {
|
|
168
168
|
return this.rpcRequest('estimateTransactionFee', request);
|
|
169
169
|
}
|
|
170
|
+
/**
|
|
171
|
+
* Estimates the bundle fee in both lamports and the specified token.
|
|
172
|
+
* @param request - Bundle fee estimation request parameters
|
|
173
|
+
* @param request.transactions - Array of base64-encoded transactions to estimate fees for
|
|
174
|
+
* @param request.fee_token - Mint address of the token to calculate fees in
|
|
175
|
+
* @returns Total fee amounts across all transactions in both lamports and the specified token
|
|
176
|
+
* @throws {Error} When the RPC call fails, the bundle is invalid, or the token is not supported
|
|
177
|
+
*
|
|
178
|
+
* @example
|
|
179
|
+
* ```typescript
|
|
180
|
+
* const fees = await client.estimateBundleFee({
|
|
181
|
+
* transactions: ['base64EncodedTransaction1', 'base64EncodedTransaction2'],
|
|
182
|
+
* fee_token: 'EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v' // USDC
|
|
183
|
+
* });
|
|
184
|
+
* console.log('Total fee in lamports:', fees.fee_in_lamports);
|
|
185
|
+
* console.log('Total fee in USDC:', fees.fee_in_token);
|
|
186
|
+
* ```
|
|
187
|
+
*/
|
|
188
|
+
async estimateBundleFee(request) {
|
|
189
|
+
return this.rpcRequest('estimateBundleFee', request);
|
|
190
|
+
}
|
|
170
191
|
/**
|
|
171
192
|
* Signs a transaction with the Kora fee payer without broadcasting it.
|
|
172
193
|
* @param request - Sign request parameters
|
|
@@ -326,6 +347,9 @@ export class KoraClient {
|
|
|
326
347
|
tokenProgram: token_program_id,
|
|
327
348
|
mint: fee_token,
|
|
328
349
|
});
|
|
350
|
+
if (fee_in_token === undefined) {
|
|
351
|
+
throw new Error('Fee token was specified but fee_in_token was not returned from server');
|
|
352
|
+
}
|
|
329
353
|
const paymentInstruction = getTransferInstruction({
|
|
330
354
|
source: sourceTokenAccount,
|
|
331
355
|
destination: destinationTokenAccount,
|
|
@@ -69,12 +69,25 @@ export interface EstimateTransactionFeeRequest {
|
|
|
69
69
|
/** Base64-encoded transaction to estimate fees for */
|
|
70
70
|
transaction: string;
|
|
71
71
|
/** Mint address of the token to calculate fees in */
|
|
72
|
-
fee_token
|
|
72
|
+
fee_token?: string;
|
|
73
73
|
/** Optional signer address for the transaction */
|
|
74
74
|
signer_key?: string;
|
|
75
75
|
/** Optional signer verification during transaction simulation (defaults to false) */
|
|
76
76
|
sig_verify?: boolean;
|
|
77
77
|
}
|
|
78
|
+
/**
|
|
79
|
+
* Parameters for estimating bundle fees.
|
|
80
|
+
*/
|
|
81
|
+
export interface EstimateBundleFeeRequest {
|
|
82
|
+
/** Array of base64-encoded transactions to estimate fees for */
|
|
83
|
+
transactions: string[];
|
|
84
|
+
/** Mint address of the token to calculate fees in */
|
|
85
|
+
fee_token?: string;
|
|
86
|
+
/** Optional signer address for the transactions */
|
|
87
|
+
signer_key?: string;
|
|
88
|
+
/** Optional signer verification during transaction simulation (defaults to false) */
|
|
89
|
+
sig_verify?: boolean;
|
|
90
|
+
}
|
|
78
91
|
/**
|
|
79
92
|
* Parameters for getting a payment instruction.
|
|
80
93
|
*/
|
|
@@ -182,7 +195,22 @@ export interface EstimateTransactionFeeResponse {
|
|
|
182
195
|
/**
|
|
183
196
|
* Transaction fee in the requested token (in decimals value of the token, e.g. 10^6 for USDC)
|
|
184
197
|
*/
|
|
185
|
-
fee_in_token
|
|
198
|
+
fee_in_token?: number;
|
|
199
|
+
/** Public key of the signer used to estimate the fee */
|
|
200
|
+
signer_pubkey: string;
|
|
201
|
+
/** Public key of the payment destination */
|
|
202
|
+
payment_address: string;
|
|
203
|
+
}
|
|
204
|
+
/**
|
|
205
|
+
* Response containing estimated bundle fees.
|
|
206
|
+
*/
|
|
207
|
+
export interface EstimateBundleFeeResponse {
|
|
208
|
+
/** Total bundle fee in lamports across all transactions */
|
|
209
|
+
fee_in_lamports: number;
|
|
210
|
+
/**
|
|
211
|
+
* Total bundle fee in the requested token (in decimals value of the token, e.g. 10^6 for USDC)
|
|
212
|
+
*/
|
|
213
|
+
fee_in_token?: number;
|
|
186
214
|
/** Public key of the signer used to estimate the fee */
|
|
187
215
|
signer_pubkey: string;
|
|
188
216
|
/** Public key of the payment destination */
|
|
@@ -278,6 +306,8 @@ export interface EnabledMethods {
|
|
|
278
306
|
liveness: boolean;
|
|
279
307
|
/** Whether the estimate_transaction_fee method is enabled */
|
|
280
308
|
estimate_transaction_fee: boolean;
|
|
309
|
+
/** Whether the estimate_bundle_fee method is enabled (requires bundle.enabled = true) */
|
|
310
|
+
estimate_bundle_fee: boolean;
|
|
281
311
|
/** Whether the get_supported_tokens method is enabled */
|
|
282
312
|
get_supported_tokens: boolean;
|
|
283
313
|
/** Whether the get_payer_signer method is enabled */
|
package/dist/test/unit.test.js
CHANGED
|
@@ -141,6 +141,7 @@ describe('KoraClient Unit Tests', () => {
|
|
|
141
141
|
enabled_methods: {
|
|
142
142
|
liveness: true,
|
|
143
143
|
estimate_transaction_fee: true,
|
|
144
|
+
estimate_bundle_fee: true,
|
|
144
145
|
get_supported_tokens: true,
|
|
145
146
|
get_payer_signer: true,
|
|
146
147
|
sign_transaction: true,
|
|
@@ -361,6 +362,7 @@ describe('KoraClient Unit Tests', () => {
|
|
|
361
362
|
enabled_methods: {
|
|
362
363
|
liveness: true,
|
|
363
364
|
estimate_transaction_fee: true,
|
|
365
|
+
estimate_bundle_fee: true,
|
|
364
366
|
get_supported_tokens: true,
|
|
365
367
|
get_payer_signer: true,
|
|
366
368
|
sign_transaction: true,
|