@solana/kora 0.2.0 → 0.2.1

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.
@@ -1,4 +1,4 @@
1
- import { assertIsAddress, createNoopSigner } from '@solana/kit';
1
+ import { assertIsAddress, isTransactionSigner } from '@solana/kit';
2
2
  import { findAssociatedTokenPda, getTransferInstruction, TOKEN_PROGRAM_ADDRESS } from '@solana-program/token';
3
3
  import crypto from 'crypto';
4
4
  import { getInstructionsFromBase64Message } from './utils/transaction.js';
@@ -101,7 +101,9 @@ export class KoraClient {
101
101
  * ```
102
102
  */
103
103
  async getPaymentInstruction({ transaction, fee_token, source_wallet, token_program_id = TOKEN_PROGRAM_ADDRESS, signer_key, sig_verify, }) {
104
- assertIsAddress(source_wallet);
104
+ const sourceIsSigner = typeof source_wallet !== 'string' && isTransactionSigner(source_wallet);
105
+ const walletAddress = sourceIsSigner ? source_wallet.address : source_wallet;
106
+ assertIsAddress(walletAddress);
105
107
  assertIsAddress(fee_token);
106
108
  assertIsAddress(token_program_id);
107
109
  const { fee_in_token, payment_address, signer_pubkey } = await this.estimateTransactionFee({
@@ -113,7 +115,7 @@ export class KoraClient {
113
115
  assertIsAddress(payment_address);
114
116
  const [sourceTokenAccount] = await findAssociatedTokenPda({
115
117
  mint: fee_token,
116
- owner: source_wallet,
118
+ owner: walletAddress,
117
119
  tokenProgram: token_program_id,
118
120
  });
119
121
  const [destinationTokenAccount] = await findAssociatedTokenPda({
@@ -121,10 +123,9 @@ export class KoraClient {
121
123
  owner: payment_address,
122
124
  tokenProgram: token_program_id,
123
125
  });
124
- const signer = createNoopSigner(source_wallet);
125
126
  const paymentInstruction = getTransferInstruction({
126
127
  amount: fee_in_token,
127
- authority: signer,
128
+ authority: sourceIsSigner ? source_wallet : walletAddress,
128
129
  destination: destinationTokenAccount,
129
130
  source: sourceTokenAccount,
130
131
  });
@@ -134,7 +135,6 @@ export class KoraClient {
134
135
  payment_amount: fee_in_token,
135
136
  payment_instruction: paymentInstruction,
136
137
  payment_token: fee_token,
137
- signer,
138
138
  signer_address: signer_pubkey,
139
139
  };
140
140
  }
@@ -62,8 +62,11 @@ export interface GetPaymentInstructionRequest {
62
62
  sig_verify?: boolean;
63
63
  /** Optional signer address for the transaction */
64
64
  signer_key?: string;
65
- /** The wallet owner (not token account) that will be making the token payment */
66
- source_wallet: string;
65
+ /** The wallet owner that will be making the token payment.
66
+ * Accepts a plain address string or a TransactionSigner. When a TransactionSigner is provided,
67
+ * it is used as the transfer authority on the payment instruction, preserving signer identity
68
+ * and avoiding conflicts with other instructions that reference the same address. */
69
+ source_wallet: TransactionSigner | string;
67
70
  /** The token program id to use for the payment (defaults to TOKEN_PROGRAM_ID) */
68
71
  token_program_id?: string;
69
72
  /** Base64-encoded transaction to estimate fees for */
@@ -159,8 +162,6 @@ export interface GetPaymentInstructionResponse {
159
162
  payment_instruction: Instruction;
160
163
  /** Mint address of the token used for payment */
161
164
  payment_token: string;
162
- /** NoopSigner for the source wallet authority — reuse this in your transaction to avoid duplicate signer conflicts */
163
- signer: TransactionSigner;
164
165
  /** Public key of the payer signer */
165
166
  signer_address: string;
166
167
  }
@@ -391,11 +391,8 @@ describe('KoraClient Unit Tests', () => {
391
391
  role: 1, // writable
392
392
  }), // Destination token account
393
393
  expect.objectContaining({
394
- role: 2, // readonly-signer
394
+ role: 0, // readonly (plain address, no signer attached)
395
395
  address: validRequest.source_wallet,
396
- signer: expect.objectContaining({
397
- address: validRequest.source_wallet,
398
- }),
399
396
  }), // Authority
400
397
  ],
401
398
  data: expect.any(Uint8Array),
@@ -404,12 +401,7 @@ describe('KoraClient Unit Tests', () => {
404
401
  payment_token: validRequest.fee_token,
405
402
  payment_address: mockFeeEstimate.payment_address,
406
403
  signer_address: mockFeeEstimate.signer_pubkey,
407
- signer: expect.objectContaining({
408
- address: validRequest.source_wallet,
409
- }),
410
404
  });
411
- expect(result.signer).toBeDefined();
412
- expect(result.signer.address).toBe(validRequest.source_wallet);
413
405
  // Verify only estimateTransactionFee was called
414
406
  expect(mockFetch).toHaveBeenCalledTimes(1);
415
407
  expect(mockFetch).toHaveBeenCalledWith(mockRpcUrl, {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@solana/kora",
3
- "version": "0.2.0",
3
+ "version": "0.2.1",
4
4
  "description": "TypeScript SDK for Kora RPC",
5
5
  "main": "dist/src/index.js",
6
6
  "type": "module",