@@ -73,13 +73,15 @@ import {
7373 type IMultiTransactionResult ,
7474 type IPrepareCreateStreamExt ,
7575 type IPrepareStreamExt , type IPrepareTopUpstreamExt ,
76+ type IRequestCancelData ,
7677 type ISearchStreams ,
7778 type ITopUpData ,
7879 type ITopUpStreamExt ,
7980 type ITransactionExtWithInstructions ,
8081 type ITransactionResult ,
8182 type ITransferData ,
8283 type IUpdateData ,
84+ type IWithdrawCancelRequestData ,
8385 type IWithdrawData ,
8486 type MetadataRecipientHashMap ,
8587 type OracleType ,
@@ -122,9 +124,11 @@ import {
122124 createStreamV2Instruction ,
123125 createUncheckedStreamInstruction ,
124126 createUncheckedStreamV2Instruction ,
127+ requestCancelStreamInstruction ,
125128 topupStreamInstruction ,
126129 transferStreamInstruction ,
127130 updateStreamInstruction ,
131+ withdrawCancelRequestInstruction ,
128132 withdrawStreamInstruction ,
129133} from "./instructions.js" ;
130134import type { IPartnerLayout } from "./instructionTypes.js" ;
@@ -1468,6 +1472,114 @@ export class SolanaStreamClient {
14681472 return ixs ;
14691473 }
14701474
1475+ /**
1476+ * Requests cancellation of a stream by the fee partner authority.
1477+ * @param {IRequestCancelData } data - Request cancel parameters including stream ID
1478+ * @param {IInteractStreamExt } extParams - Transaction configuration including invoker wallet and compute settings
1479+ * @returns Transaction result
1480+ */
1481+ public async requestCancel (
1482+ data : IRequestCancelData ,
1483+ extParams : IInteractStreamExt ,
1484+ ) : Promise < ITransactionResult > {
1485+ const ixs = await this . prepareRequestCancelInstructions ( data , extParams ) ;
1486+ const { tx, hash, context } = await prepareTransaction ( this . connection , ixs , extParams . invoker . publicKey ) ;
1487+ const signature = await signAndExecuteTransaction (
1488+ this . connection ,
1489+ extParams . invoker ,
1490+ tx ,
1491+ {
1492+ hash,
1493+ context,
1494+ commitment : this . getCommitment ( ) ,
1495+ } ,
1496+ this . schedulingParams ,
1497+ ) ;
1498+
1499+ return { ixs, txId : signature } ;
1500+ }
1501+
1502+ /**
1503+ * Creates Transaction Instructions for request_cancel
1504+ * @param {IRequestCancelData } data - Request cancel parameters including stream ID
1505+ * @param {IPrepareStreamExt } extParams - Transaction configuration including invoker wallet and compute settings
1506+ * @returns Transaction instructions
1507+ */
1508+ public async prepareRequestCancelInstructions (
1509+ { id } : IRequestCancelData ,
1510+ { invoker, computePrice, computeLimit } : IPrepareStreamExt ,
1511+ ) : Promise < TransactionInstruction [ ] > {
1512+ assertHasPublicKey ( invoker , "Invoker's PublicKey is not available, check passed wallet adapter!" ) ;
1513+
1514+ const ixs : TransactionInstruction [ ] = prepareBaseInstructions ( this . connection , {
1515+ computePrice,
1516+ computeLimit,
1517+ } ) ;
1518+
1519+ ixs . push (
1520+ await requestCancelStreamInstruction ( this . programId , {
1521+ authority : invoker . publicKey ,
1522+ metadata : new PublicKey ( id ) ,
1523+ } ) ,
1524+ ) ;
1525+
1526+ return ixs ;
1527+ }
1528+
1529+ /**
1530+ * Withdraws a previously submitted cancel request.
1531+ * @param {IWithdrawCancelRequestData } data - Withdraw cancel request parameters including stream ID
1532+ * @param {IInteractStreamExt } extParams - Transaction configuration including invoker wallet and compute settings
1533+ * @returns Transaction result
1534+ */
1535+ public async withdrawCancelRequest (
1536+ data : IWithdrawCancelRequestData ,
1537+ extParams : IInteractStreamExt ,
1538+ ) : Promise < ITransactionResult > {
1539+ const ixs = await this . prepareWithdrawCancelRequestInstructions ( data , extParams ) ;
1540+ const { tx, hash, context } = await prepareTransaction ( this . connection , ixs , extParams . invoker . publicKey ) ;
1541+ const signature = await signAndExecuteTransaction (
1542+ this . connection ,
1543+ extParams . invoker ,
1544+ tx ,
1545+ {
1546+ hash,
1547+ context,
1548+ commitment : this . getCommitment ( ) ,
1549+ } ,
1550+ this . schedulingParams ,
1551+ ) ;
1552+
1553+ return { ixs, txId : signature } ;
1554+ }
1555+
1556+ /**
1557+ * Creates Transaction Instructions for withdraw_cancel_request
1558+ * @param {IWithdrawCancelRequestData } data - Withdraw cancel request parameters including stream ID
1559+ * @param {IPrepareStreamExt } extParams - Transaction configuration including invoker wallet and compute settings
1560+ * @returns Transaction instructions
1561+ */
1562+ public async prepareWithdrawCancelRequestInstructions (
1563+ { id } : IWithdrawCancelRequestData ,
1564+ { invoker, computePrice, computeLimit } : IPrepareStreamExt ,
1565+ ) : Promise < TransactionInstruction [ ] > {
1566+ assertHasPublicKey ( invoker , "Invoker's PublicKey is not available, check passed wallet adapter!" ) ;
1567+
1568+ const ixs : TransactionInstruction [ ] = prepareBaseInstructions ( this . connection , {
1569+ computePrice,
1570+ computeLimit,
1571+ } ) ;
1572+
1573+ ixs . push (
1574+ await withdrawCancelRequestInstruction ( this . programId , {
1575+ authority : invoker . publicKey ,
1576+ metadata : new PublicKey ( id ) ,
1577+ } ) ,
1578+ ) ;
1579+
1580+ return ixs ;
1581+ }
1582+
14711583 /**
14721584 * Attempts changing the stream/vesting contract's recipient (effectively transferring the stream/vesting contract).
14731585 * Potential associated token account rent fee (to make it rent-exempt) is paid by the transaction initiator.
0 commit comments