@nosana/kit 1.0.9 → 1.0.10

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.
@@ -98,4 +98,18 @@ export declare class MerkleDistributorProgram extends BaseProgram {
98
98
  target: ClaimTarget;
99
99
  claimant?: KeyPairSigner;
100
100
  }): Promise<ReturnType<typeof programClient.getNewClaimInstruction>>;
101
+ /**
102
+ * Clawback tokens from a merkle distributor.
103
+ * This function creates a clawback instruction to transfer tokens from the distributor's token vault to the clawback receiver.
104
+ *
105
+ * @param params Parameters for clawback
106
+ * @param params.distributor The address of the merkle distributor
107
+ * @param params.claimant Optional claimant signer. If not provided, uses the wallet.
108
+ * @returns The clawback instruction
109
+ * @throws Error if wallet is not set and claimant is not provided
110
+ */
111
+ clawback(params: {
112
+ distributor: Address;
113
+ claimant?: KeyPairSigner;
114
+ }): Promise<ReturnType<typeof programClient.getClawbackInstruction>>;
101
115
  }
@@ -293,4 +293,45 @@ export class MerkleDistributorProgram extends BaseProgram {
293
293
  throw err;
294
294
  }
295
295
  }
296
+ /**
297
+ * Clawback tokens from a merkle distributor.
298
+ * This function creates a clawback instruction to transfer tokens from the distributor's token vault to the clawback receiver.
299
+ *
300
+ * @param params Parameters for clawback
301
+ * @param params.distributor The address of the merkle distributor
302
+ * @param params.claimant Optional claimant signer. If not provided, uses the wallet.
303
+ * @returns The clawback instruction
304
+ * @throws Error if wallet is not set and claimant is not provided
305
+ */
306
+ async clawback(params) {
307
+ // Determine claimant signer
308
+ let claimantSigner;
309
+ if (params.claimant) {
310
+ claimantSigner = params.claimant;
311
+ }
312
+ else {
313
+ if (!this.sdk.wallet) {
314
+ throw new Error('Wallet not set. Please set a wallet or provide a claimant signer.');
315
+ }
316
+ claimantSigner = this.sdk.wallet;
317
+ }
318
+ try {
319
+ // Get the distributor account to find tokenVault and clawbackReceiver
320
+ const distributorAccount = await this.client.fetchMerkleDistributor(this.sdk.solana.rpc, params.distributor);
321
+ // Create clawback instruction
322
+ const clawbackInstruction = this.client.getClawbackInstruction({
323
+ distributor: params.distributor,
324
+ from: distributorAccount.data.tokenVault,
325
+ to: distributorAccount.data.clawbackReceiver,
326
+ claimant: claimantSigner,
327
+ tokenProgram: TOKEN_PROGRAM_ADDRESS,
328
+ systemProgram: SYSTEM_PROGRAM_ADDRESS,
329
+ }, { programAddress: this.getProgramId() });
330
+ return clawbackInstruction;
331
+ }
332
+ catch (err) {
333
+ this.sdk.logger.error(`Failed to create clawback instruction: ${err}`);
334
+ throw err;
335
+ }
336
+ }
296
337
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nosana/kit",
3
- "version": "1.0.9",
3
+ "version": "1.0.10",
4
4
  "description": "Nosana KIT",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",