@@ -55,7 +55,9 @@ import type {
5555 IGetClaimData ,
5656 IGetDistributors ,
5757 IInteractExt ,
58+ IRequestClawbackData ,
5859 ISearchDistributors ,
60+ IWithdrawClawbackRequestData ,
5961 ClawbackAccounts ,
6062 NewDistributorAccounts ,
6163 Fees ,
@@ -521,7 +523,7 @@ export default abstract class BaseDistributorClient {
521523 distributor : distributorPublicKey ,
522524 from : distributor . tokenVault ,
523525 to : distributor . clawbackReceiver ,
524- admin : extParams . invoker . publicKey ,
526+ authority : extParams . invoker . publicKey ,
525527 mint : distributor . mint ,
526528 tokenProgram : tokenProgramId ,
527529 } ;
@@ -557,6 +559,114 @@ export default abstract class BaseDistributorClient {
557559 return { ixs, txId : signature } ;
558560 }
559561
562+ /**
563+ * Requests delayed clawback by the configured fee partner authority.
564+ * Once the request is recorded on-chain, clawback can be executed after the
565+ * configured delay elapses.
566+ */
567+ public async requestClawback (
568+ data : IRequestClawbackData ,
569+ extParams : IInteractExt ,
570+ ) : Promise < ITransactionResult > {
571+ const executionParams = this . unwrapExecutionParams ( extParams ) ;
572+ const invoker = executionParams . invoker . publicKey ;
573+ invariant ( invoker , "Invoker's PublicKey is not available, check passed wallet adapter!" ) ;
574+ const ixs = await createAndEstimateTransaction (
575+ ( params ) => this . prepareRequestClawbackInstructions ( data , params ) ,
576+ executionParams ,
577+ ) ;
578+ const { tx, hash, context } = await prepareTransaction ( this . connection , ixs , invoker ) ;
579+ const signature = await wrappedSignAndExecuteTransaction (
580+ this . connection ,
581+ executionParams . invoker ,
582+ tx ,
583+ {
584+ hash,
585+ context,
586+ commitment : this . getCommitment ( ) ,
587+ } ,
588+ { sendThrottler : this . sendThrottler , skipSimulation : executionParams . skipSimulation } ,
589+ ) ;
590+
591+ return { ixs, txId : signature } ;
592+ }
593+
594+ public async prepareRequestClawbackInstructions (
595+ data : IRequestClawbackData ,
596+ extParams : ITransactionExtResolved < IInteractExt > ,
597+ ) : Promise < TransactionInstruction [ ] > {
598+ if ( ! extParams . invoker . publicKey ) {
599+ throw new Error ( "Invoker's PublicKey is not available, check passed wallet adapter!" ) ;
600+ }
601+
602+ const ixs : TransactionInstruction [ ] = prepareBaseInstructions ( this . connection , extParams ) ;
603+
604+ ixs . push (
605+ await this . merkleDistributorProgram . methods
606+ . requestClawback ( )
607+ . accounts ( {
608+ distributor : new PublicKey ( data . id ) ,
609+ authority : extParams . invoker . publicKey ,
610+ } )
611+ . instruction ( ) ,
612+ ) ;
613+
614+ return ixs ;
615+ }
616+
617+ /**
618+ * Withdraws a previously submitted clawback request, cancelling the delayed clawback flow.
619+ */
620+ public async withdrawClawbackRequest (
621+ data : IWithdrawClawbackRequestData ,
622+ extParams : IInteractExt ,
623+ ) : Promise < ITransactionResult > {
624+ const executionParams = this . unwrapExecutionParams ( extParams ) ;
625+ const invoker = executionParams . invoker . publicKey ;
626+ invariant ( invoker , "Invoker's PublicKey is not available, check passed wallet adapter!" ) ;
627+ const ixs = await createAndEstimateTransaction (
628+ ( params ) => this . prepareWithdrawClawbackRequestInstructions ( data , params ) ,
629+ executionParams ,
630+ ) ;
631+ const { tx, hash, context } = await prepareTransaction ( this . connection , ixs , invoker ) ;
632+ const signature = await wrappedSignAndExecuteTransaction (
633+ this . connection ,
634+ executionParams . invoker ,
635+ tx ,
636+ {
637+ hash,
638+ context,
639+ commitment : this . getCommitment ( ) ,
640+ } ,
641+ { sendThrottler : this . sendThrottler , skipSimulation : executionParams . skipSimulation } ,
642+ ) ;
643+
644+ return { ixs, txId : signature } ;
645+ }
646+
647+ public async prepareWithdrawClawbackRequestInstructions (
648+ data : IWithdrawClawbackRequestData ,
649+ extParams : ITransactionExtResolved < IInteractExt > ,
650+ ) : Promise < TransactionInstruction [ ] > {
651+ if ( ! extParams . invoker . publicKey ) {
652+ throw new Error ( "Invoker's PublicKey is not available, check passed wallet adapter!" ) ;
653+ }
654+
655+ const ixs : TransactionInstruction [ ] = prepareBaseInstructions ( this . connection , extParams ) ;
656+
657+ ixs . push (
658+ await this . merkleDistributorProgram . methods
659+ . withdrawClawbackRequest ( )
660+ . accounts ( {
661+ distributor : new PublicKey ( data . id ) ,
662+ authority : extParams . invoker . publicKey ,
663+ } )
664+ . instruction ( ) ,
665+ ) ;
666+
667+ return ixs ;
668+ }
669+
560670 public async getClaim ( claimStatus : string | PublicKey ) : Promise < AnyClaimStatus | null > {
561671 return this . connection . getAccountInfo ( pk ( claimStatus ) ) . then ( ( account ) => this . decodeClaimStatus ( account ) ) ;
562672 }
0 commit comments