@streamflow/stream 12.0.0 → 12.1.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.
@@ -203,6 +203,8 @@ var Contract = class {
203
203
  this.oldMetadata = stream.oldMetadata;
204
204
  this.payer = stream.payer.toBase58();
205
205
  this.bump = stream.bump;
206
+ this.feePartner = stream.feePartner.toBase58();
207
+ this.cancelRequestTime = stream.cancelRequestTime.toNumber();
206
208
  this.type = buildStreamType(this);
207
209
  this.isAligned = false;
208
210
  }
@@ -407,7 +409,9 @@ var streamLayout = BufferLayout__namespace.struct([
407
409
  BufferLayout__namespace.u8("auto_claim_fee_claimed"),
408
410
  BufferLayout__namespace.blob(32, "old_metadata"),
409
411
  BufferLayout__namespace.blob(32, "payer"),
410
- BufferLayout__namespace.u8("bump")
412
+ BufferLayout__namespace.u8("bump"),
413
+ BufferLayout__namespace.blob(32, "fee_partner"),
414
+ BufferLayout__namespace.blob(8, "cancel_request_time")
411
415
  ]);
412
416
  BufferLayout__namespace.struct([
413
417
  BufferLayout__namespace.blob(32, "pubkey"),
@@ -622,7 +626,9 @@ var decodeStream = (buf) => {
622
626
  fundsUnlockedAtLastRateChange: new BN3__default.default(raw.funds_unlocked_at_last_rate_change, LE),
623
627
  oldMetadata: new web3_js.PublicKey(raw.old_metadata),
624
628
  payer: new web3_js.PublicKey(raw.payer),
625
- bump: raw.bump
629
+ bump: raw.bump,
630
+ feePartner: new web3_js.PublicKey(raw.fee_partner),
631
+ cancelRequestTime: new BN3__default.default(raw.cancel_request_time, LE)
626
632
  };
627
633
  };
628
634
  async function signAllTransactionWithRecipients(sender, items) {
@@ -1091,6 +1097,33 @@ var transferStreamInstruction = async (programId, {
1091
1097
  data
1092
1098
  });
1093
1099
  };
1100
+ var requestCancelStreamInstruction = async (programId, { authority, metadata }) => {
1101
+ const keys = [
1102
+ { pubkey: authority, isSigner: true, isWritable: false },
1103
+ { pubkey: metadata, isSigner: false, isWritable: true }
1104
+ ];
1105
+ const data = buffer.Buffer.concat([buffer.Buffer.from(await sha256.digest("global:request_cancel")).slice(0, 8), buffer.Buffer.alloc(10)]);
1106
+ return new web3_js.TransactionInstruction({
1107
+ keys,
1108
+ programId,
1109
+ data
1110
+ });
1111
+ };
1112
+ var withdrawCancelRequestInstruction = async (programId, { authority, metadata }) => {
1113
+ const keys = [
1114
+ { pubkey: authority, isSigner: true, isWritable: false },
1115
+ { pubkey: metadata, isSigner: false, isWritable: true }
1116
+ ];
1117
+ const data = buffer.Buffer.concat([
1118
+ buffer.Buffer.from(await sha256.digest("global:withdraw_cancel_request")).slice(0, 8),
1119
+ buffer.Buffer.alloc(10)
1120
+ ]);
1121
+ return new web3_js.TransactionInstruction({
1122
+ keys,
1123
+ programId,
1124
+ data
1125
+ });
1126
+ };
1094
1127
  var topupStreamInstruction = async (amount, programId, {
1095
1128
  sender,
1096
1129
  senderTokens,
@@ -1140,7 +1173,7 @@ var streamflow_aligned_unlocks_default = {
1140
1173
  address: "aSTRM2NKoKxNnkmLWk9sz3k74gKBk9t7bpPrTGxMszH",
1141
1174
  metadata: {
1142
1175
  name: "streamflow_aligned_unlocks",
1143
- version: "1.4.0",
1176
+ version: "1.7.0",
1144
1177
  spec: "0.1.0",
1145
1178
  description: "Proxy to update unlock amount within Streamflow vesting protocol according to Token performance and other metrics"
1146
1179
  },
@@ -1523,6 +1556,388 @@ var streamflow_aligned_unlocks_default = {
1523
1556
  ],
1524
1557
  args: []
1525
1558
  },
1559
+ {
1560
+ name: "cancel_v2",
1561
+ discriminator: [
1562
+ 160,
1563
+ 58,
1564
+ 112,
1565
+ 172,
1566
+ 233,
1567
+ 228,
1568
+ 38,
1569
+ 140
1570
+ ],
1571
+ accounts: [
1572
+ {
1573
+ name: "caller",
1574
+ writable: true,
1575
+ signer: true
1576
+ },
1577
+ {
1578
+ name: "sender",
1579
+ writable: true
1580
+ },
1581
+ {
1582
+ name: "sender_tokens",
1583
+ docs: [
1584
+ "Associated token account address of `sender`."
1585
+ ],
1586
+ writable: true,
1587
+ pda: {
1588
+ seeds: [
1589
+ {
1590
+ kind: "account",
1591
+ path: "sender"
1592
+ },
1593
+ {
1594
+ kind: "account",
1595
+ path: "token_program"
1596
+ },
1597
+ {
1598
+ kind: "account",
1599
+ path: "mint"
1600
+ }
1601
+ ],
1602
+ program: {
1603
+ kind: "const",
1604
+ value: [
1605
+ 140,
1606
+ 151,
1607
+ 37,
1608
+ 143,
1609
+ 78,
1610
+ 36,
1611
+ 137,
1612
+ 241,
1613
+ 187,
1614
+ 61,
1615
+ 16,
1616
+ 41,
1617
+ 20,
1618
+ 142,
1619
+ 13,
1620
+ 131,
1621
+ 11,
1622
+ 90,
1623
+ 19,
1624
+ 153,
1625
+ 218,
1626
+ 255,
1627
+ 16,
1628
+ 132,
1629
+ 4,
1630
+ 142,
1631
+ 123,
1632
+ 216,
1633
+ 219,
1634
+ 233,
1635
+ 248,
1636
+ 89
1637
+ ]
1638
+ }
1639
+ }
1640
+ },
1641
+ {
1642
+ name: "recipient",
1643
+ writable: true
1644
+ },
1645
+ {
1646
+ name: "recipient_tokens",
1647
+ docs: [
1648
+ "CHECK; Associated token account address of `recipient`."
1649
+ ],
1650
+ writable: true,
1651
+ pda: {
1652
+ seeds: [
1653
+ {
1654
+ kind: "account",
1655
+ path: "recipient"
1656
+ },
1657
+ {
1658
+ kind: "account",
1659
+ path: "token_program"
1660
+ },
1661
+ {
1662
+ kind: "account",
1663
+ path: "mint"
1664
+ }
1665
+ ],
1666
+ program: {
1667
+ kind: "const",
1668
+ value: [
1669
+ 140,
1670
+ 151,
1671
+ 37,
1672
+ 143,
1673
+ 78,
1674
+ 36,
1675
+ 137,
1676
+ 241,
1677
+ 187,
1678
+ 61,
1679
+ 16,
1680
+ 41,
1681
+ 20,
1682
+ 142,
1683
+ 13,
1684
+ 131,
1685
+ 11,
1686
+ 90,
1687
+ 19,
1688
+ 153,
1689
+ 218,
1690
+ 255,
1691
+ 16,
1692
+ 132,
1693
+ 4,
1694
+ 142,
1695
+ 123,
1696
+ 216,
1697
+ 219,
1698
+ 233,
1699
+ 248,
1700
+ 89
1701
+ ]
1702
+ }
1703
+ }
1704
+ },
1705
+ {
1706
+ name: "proxy_metadata",
1707
+ docs: [
1708
+ "Proxy Contract"
1709
+ ],
1710
+ writable: true,
1711
+ pda: {
1712
+ seeds: [
1713
+ {
1714
+ kind: "const",
1715
+ value: [
1716
+ 99,
1717
+ 111,
1718
+ 110,
1719
+ 116,
1720
+ 114,
1721
+ 97,
1722
+ 99,
1723
+ 116
1724
+ ]
1725
+ },
1726
+ {
1727
+ kind: "account",
1728
+ path: "stream_metadata"
1729
+ }
1730
+ ]
1731
+ }
1732
+ },
1733
+ {
1734
+ name: "proxy_tokens",
1735
+ writable: true,
1736
+ pda: {
1737
+ seeds: [
1738
+ {
1739
+ kind: "account",
1740
+ path: "proxy_metadata"
1741
+ },
1742
+ {
1743
+ kind: "account",
1744
+ path: "token_program"
1745
+ },
1746
+ {
1747
+ kind: "account",
1748
+ path: "mint"
1749
+ }
1750
+ ],
1751
+ program: {
1752
+ kind: "const",
1753
+ value: [
1754
+ 140,
1755
+ 151,
1756
+ 37,
1757
+ 143,
1758
+ 78,
1759
+ 36,
1760
+ 137,
1761
+ 241,
1762
+ 187,
1763
+ 61,
1764
+ 16,
1765
+ 41,
1766
+ 20,
1767
+ 142,
1768
+ 13,
1769
+ 131,
1770
+ 11,
1771
+ 90,
1772
+ 19,
1773
+ 153,
1774
+ 218,
1775
+ 255,
1776
+ 16,
1777
+ 132,
1778
+ 4,
1779
+ 142,
1780
+ 123,
1781
+ 216,
1782
+ 219,
1783
+ 233,
1784
+ 248,
1785
+ 89
1786
+ ]
1787
+ }
1788
+ }
1789
+ },
1790
+ {
1791
+ name: "stream_metadata",
1792
+ writable: true
1793
+ },
1794
+ {
1795
+ name: "escrow_tokens",
1796
+ writable: true
1797
+ },
1798
+ {
1799
+ name: "streamflow_treasury",
1800
+ writable: true
1801
+ },
1802
+ {
1803
+ name: "streamflow_treasury_tokens",
1804
+ writable: true,
1805
+ pda: {
1806
+ seeds: [
1807
+ {
1808
+ kind: "account",
1809
+ path: "streamflow_treasury"
1810
+ },
1811
+ {
1812
+ kind: "account",
1813
+ path: "token_program"
1814
+ },
1815
+ {
1816
+ kind: "account",
1817
+ path: "mint"
1818
+ }
1819
+ ],
1820
+ program: {
1821
+ kind: "const",
1822
+ value: [
1823
+ 140,
1824
+ 151,
1825
+ 37,
1826
+ 143,
1827
+ 78,
1828
+ 36,
1829
+ 137,
1830
+ 241,
1831
+ 187,
1832
+ 61,
1833
+ 16,
1834
+ 41,
1835
+ 20,
1836
+ 142,
1837
+ 13,
1838
+ 131,
1839
+ 11,
1840
+ 90,
1841
+ 19,
1842
+ 153,
1843
+ 218,
1844
+ 255,
1845
+ 16,
1846
+ 132,
1847
+ 4,
1848
+ 142,
1849
+ 123,
1850
+ 216,
1851
+ 219,
1852
+ 233,
1853
+ 248,
1854
+ 89
1855
+ ]
1856
+ }
1857
+ }
1858
+ },
1859
+ {
1860
+ name: "partner",
1861
+ writable: true
1862
+ },
1863
+ {
1864
+ name: "partner_tokens",
1865
+ writable: true,
1866
+ pda: {
1867
+ seeds: [
1868
+ {
1869
+ kind: "account",
1870
+ path: "partner"
1871
+ },
1872
+ {
1873
+ kind: "account",
1874
+ path: "token_program"
1875
+ },
1876
+ {
1877
+ kind: "account",
1878
+ path: "mint"
1879
+ }
1880
+ ],
1881
+ program: {
1882
+ kind: "const",
1883
+ value: [
1884
+ 140,
1885
+ 151,
1886
+ 37,
1887
+ 143,
1888
+ 78,
1889
+ 36,
1890
+ 137,
1891
+ 241,
1892
+ 187,
1893
+ 61,
1894
+ 16,
1895
+ 41,
1896
+ 20,
1897
+ 142,
1898
+ 13,
1899
+ 131,
1900
+ 11,
1901
+ 90,
1902
+ 19,
1903
+ 153,
1904
+ 218,
1905
+ 255,
1906
+ 16,
1907
+ 132,
1908
+ 4,
1909
+ 142,
1910
+ 123,
1911
+ 216,
1912
+ 219,
1913
+ 233,
1914
+ 248,
1915
+ 89
1916
+ ]
1917
+ }
1918
+ }
1919
+ },
1920
+ {
1921
+ name: "mint",
1922
+ docs: [
1923
+ "The SPL token mint account."
1924
+ ],
1925
+ writable: true
1926
+ },
1927
+ {
1928
+ name: "streamflow_program",
1929
+ address: "strmRqUCoQUgGUan5YhzUZa6KqdzwX5L6FpUxfmKg5m"
1930
+ },
1931
+ {
1932
+ name: "token_program",
1933
+ docs: [
1934
+ "The SPL program needed in case an associated account",
1935
+ "for the new recipient is being created."
1936
+ ]
1937
+ }
1938
+ ],
1939
+ args: []
1940
+ },
1526
1941
  {
1527
1942
  name: "change_oracle",
1528
1943
  discriminator: [
@@ -1810,7 +2225,8 @@ var streamflow_aligned_unlocks_default = {
1810
2225
  name: "mint"
1811
2226
  },
1812
2227
  {
1813
- name: "fee_oracle"
2228
+ name: "fee_oracle",
2229
+ address: "B743wFVk2pCYhV91cn287e1xY7f1vt4gdY48hhNiuQmT"
1814
2230
  },
1815
2231
  {
1816
2232
  name: "price_oracle"
@@ -2236,6 +2652,21 @@ var streamflow_aligned_unlocks_default = {
2236
2652
  code: 6016,
2237
2653
  name: "InvalidFloorPrice",
2238
2654
  msg: "Provided floor price is invalid, should be less than minimum price"
2655
+ },
2656
+ {
2657
+ code: 6017,
2658
+ name: "AmountNotUpdated",
2659
+ msg: "Update won't lead to any changes in unlock schedule"
2660
+ },
2661
+ {
2662
+ code: 6018,
2663
+ name: "OldMetadataNotDrained",
2664
+ msg: "Old metadata account must be drained"
2665
+ },
2666
+ {
2667
+ code: 6019,
2668
+ name: "NewMetadataMissing",
2669
+ msg: "New metadata account does not exist"
2239
2670
  }
2240
2671
  ],
2241
2672
  types: [
@@ -2746,7 +3177,7 @@ var deriveTestOraclePDA = (programId, mint, creator) => {
2746
3177
  };
2747
3178
  var deriveStreamMetadataPDA = (programId, mint, sender, nonce) => {
2748
3179
  return web3_js.PublicKey.findProgramAddressSync(
2749
- [METADATA_SEED, mint.toBuffer(), sender.toBuffer(), new BN3__default.default(nonce).toArrayLike(buffer.Buffer, "le", 4)],
3180
+ [METADATA_SEED, mint.toBuffer(), sender.toBuffer(), new BN3__default.default(nonce).toArrayLike(buffer.Buffer, "be", 4)],
2750
3181
  programId
2751
3182
  )[0];
2752
3183
  };
@@ -2862,7 +3293,9 @@ async function toDecodedStream(schema) {
2862
3293
  fundsUnlockedAtLastRateChange: toBN(schema.amountUnlockedAtLastRateUpdate),
2863
3294
  oldMetadata: web3_js.PublicKey.default,
2864
3295
  payer,
2865
- bump: schema.bump ? schema.bump : 0
3296
+ bump: schema.bump ? schema.bump : 0,
3297
+ feePartner: partner,
3298
+ cancelRequestTime: toBN(isoToUnix(schema.cancelRequestDt))
2866
3299
  };
2867
3300
  }
2868
3301
  function toPrecisionBN(value, precision = ALIGNED_PRECISION_FACTOR_POW2) {
@@ -3910,6 +4343,90 @@ var SolanaStreamClient = class {
3910
4343
  ixs.push(...ixsAta, cancelIx);
3911
4344
  return ixs;
3912
4345
  }
4346
+ /**
4347
+ * Requests cancellation of a stream by the fee partner authority.
4348
+ * @param {IRequestCancelData} data - Request cancel parameters including stream ID
4349
+ * @param {IInteractStreamExt} extParams - Transaction configuration including invoker wallet and compute settings
4350
+ * @returns Transaction result
4351
+ */
4352
+ async requestCancel(data, extParams) {
4353
+ const ixs = await this.prepareRequestCancelInstructions(data, extParams);
4354
+ const { tx, hash, context } = await common.prepareTransaction(this.connection, ixs, extParams.invoker.publicKey);
4355
+ const signature = await common.signAndExecuteTransaction(
4356
+ this.connection,
4357
+ extParams.invoker,
4358
+ tx,
4359
+ {
4360
+ hash,
4361
+ context,
4362
+ commitment: this.getCommitment()
4363
+ },
4364
+ this.schedulingParams
4365
+ );
4366
+ return { ixs, txId: signature };
4367
+ }
4368
+ /**
4369
+ * Creates Transaction Instructions for request_cancel
4370
+ * @param {IRequestCancelData} data - Request cancel parameters including stream ID
4371
+ * @param {IPrepareStreamExt} extParams - Transaction configuration including invoker wallet and compute settings
4372
+ * @returns Transaction instructions
4373
+ */
4374
+ async prepareRequestCancelInstructions({ id }, { invoker, computePrice, computeLimit }) {
4375
+ common.assertHasPublicKey(invoker, "Invoker's PublicKey is not available, check passed wallet adapter!");
4376
+ const ixs = common.prepareBaseInstructions(this.connection, {
4377
+ computePrice,
4378
+ computeLimit
4379
+ });
4380
+ ixs.push(
4381
+ await requestCancelStreamInstruction(this.programId, {
4382
+ authority: invoker.publicKey,
4383
+ metadata: new web3_js.PublicKey(id)
4384
+ })
4385
+ );
4386
+ return ixs;
4387
+ }
4388
+ /**
4389
+ * Withdraws a previously submitted cancel request.
4390
+ * @param {IWithdrawCancelRequestData} data - Withdraw cancel request parameters including stream ID
4391
+ * @param {IInteractStreamExt} extParams - Transaction configuration including invoker wallet and compute settings
4392
+ * @returns Transaction result
4393
+ */
4394
+ async withdrawCancelRequest(data, extParams) {
4395
+ const ixs = await this.prepareWithdrawCancelRequestInstructions(data, extParams);
4396
+ const { tx, hash, context } = await common.prepareTransaction(this.connection, ixs, extParams.invoker.publicKey);
4397
+ const signature = await common.signAndExecuteTransaction(
4398
+ this.connection,
4399
+ extParams.invoker,
4400
+ tx,
4401
+ {
4402
+ hash,
4403
+ context,
4404
+ commitment: this.getCommitment()
4405
+ },
4406
+ this.schedulingParams
4407
+ );
4408
+ return { ixs, txId: signature };
4409
+ }
4410
+ /**
4411
+ * Creates Transaction Instructions for withdraw_cancel_request
4412
+ * @param {IWithdrawCancelRequestData} data - Withdraw cancel request parameters including stream ID
4413
+ * @param {IPrepareStreamExt} extParams - Transaction configuration including invoker wallet and compute settings
4414
+ * @returns Transaction instructions
4415
+ */
4416
+ async prepareWithdrawCancelRequestInstructions({ id }, { invoker, computePrice, computeLimit }) {
4417
+ common.assertHasPublicKey(invoker, "Invoker's PublicKey is not available, check passed wallet adapter!");
4418
+ const ixs = common.prepareBaseInstructions(this.connection, {
4419
+ computePrice,
4420
+ computeLimit
4421
+ });
4422
+ ixs.push(
4423
+ await withdrawCancelRequestInstruction(this.programId, {
4424
+ authority: invoker.publicKey,
4425
+ metadata: new web3_js.PublicKey(id)
4426
+ })
4427
+ );
4428
+ return ixs;
4429
+ }
3913
4430
  /**
3914
4431
  * Attempts changing the stream/vesting contract's recipient (effectively transferring the stream/vesting contract).
3915
4432
  * Potential associated token account rent fee (to make it rent-exempt) is paid by the transaction initiator.
@@ -5008,6 +5525,7 @@ exports.isCreateAlignedStreamData = isCreateAlignedStreamData;
5008
5525
  exports.isDynamicLock = isDynamicLock;
5009
5526
  exports.isTokenLock = isTokenLock;
5010
5527
  exports.isVesting = isVesting;
5528
+ exports.requestCancelStreamInstruction = requestCancelStreamInstruction;
5011
5529
  exports.sendAndConfirmStreamRawTransaction = sendAndConfirmStreamRawTransaction;
5012
5530
  exports.signAllTransactionWithRecipients = signAllTransactionWithRecipients;
5013
5531
  exports.timelockIDL = timelockIDL_default;
@@ -5015,6 +5533,7 @@ exports.topupStreamInstruction = topupStreamInstruction;
5015
5533
  exports.transferStreamInstruction = transferStreamInstruction;
5016
5534
  exports.transformContract = transformContract;
5017
5535
  exports.updateStreamInstruction = updateStreamInstruction;
5536
+ exports.withdrawCancelRequestInstruction = withdrawCancelRequestInstruction;
5018
5537
  exports.withdrawStreamInstruction = withdrawStreamInstruction;
5019
5538
  //# sourceMappingURL=index.cjs.map
5020
5539
  //# sourceMappingURL=index.cjs.map