@streamflow/stream 9.0.3 → 9.1.0

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.
@@ -2,8 +2,8 @@ import { A as AptosStreamClient, I as ICreateStreamAptosExt, a as ITransactionAp
2
2
  export { i as StreamflowAptos } from './index-DYIamO0j.cjs';
3
3
  import { E as EvmStreamClient } from './index-BMZATAYa.cjs';
4
4
  export { i as StreamflowEVM } from './index-BMZATAYa.cjs';
5
- import { S as SolanaStreamClient, I as ICreateStreamSolanaExt, a as IInteractStreamSolanaExt, b as ITopUpStreamSolanaExt } from './index-BgGtpOPg.cjs';
6
- export { s as AIRDROP_AMOUNT, q as AIRDROP_TEST_TOKEN, j as ALIGNED_COMPUTE_LIMIT, A as ALIGNED_PRECISION_FACTOR_POW, h as ALIGNED_UNLOCKS_PROGRAM_ID, k as CONTRACT_DISCRIMINATOR, m as CONTRACT_SEED, C as CREATE_PARAMS_PADDING, D as DEFAULT_STREAMFLOW_FEE, E as ESCROW_SEED, r as FEES_METADATA_SEED, F as FEE_ORACLE_PUBLIC_KEY, O as ORIGINAL_CONTRACT_SENDER_OFFSET, u as PARTNERS_SCHEMA, o as PARTNER_ORACLE_PROGRAM_ID, t as PARTNER_SCHEMA, P as PROGRAM_ID, w as SOLANA_ERROR_MAP, v as SOLANA_ERROR_MATCH_REGEX, p as STREAMFLOW_TREASURY_PUBLIC_KEY, g as STREAM_STRUCT_OFFSETS, f as STREAM_STRUCT_OFFSET_CLOSED, e as STREAM_STRUCT_OFFSET_MINT, d as STREAM_STRUCT_OFFSET_RECIPIENT, c as STREAM_STRUCT_OFFSET_SENDER, i as StreamflowSolana, l as TEST_ORACLE_DISCRIMINATOR, n as TEST_ORACLE_SEED, T as TX_FINALITY_CONFIRMED, W as WITHDRAWOR_PUBLIC_KEY } from './index-BgGtpOPg.cjs';
5
+ import { S as SolanaStreamClient, I as ICreateStreamSolanaExt, a as IInteractStreamSolanaExt, b as ITopUpStreamSolanaExt } from './index-ByMlPIUq.cjs';
6
+ export { s as AIRDROP_AMOUNT, q as AIRDROP_TEST_TOKEN, j as ALIGNED_COMPUTE_LIMIT, A as ALIGNED_PRECISION_FACTOR_POW, h as ALIGNED_UNLOCKS_PROGRAM_ID, k as CONTRACT_DISCRIMINATOR, m as CONTRACT_SEED, C as CREATE_PARAMS_PADDING, D as DEFAULT_STREAMFLOW_FEE, E as ESCROW_SEED, r as FEES_METADATA_SEED, F as FEE_ORACLE_PUBLIC_KEY, O as ORIGINAL_CONTRACT_SENDER_OFFSET, u as PARTNERS_SCHEMA, o as PARTNER_ORACLE_PROGRAM_ID, t as PARTNER_SCHEMA, P as PROGRAM_ID, w as SOLANA_ERROR_MAP, v as SOLANA_ERROR_MATCH_REGEX, p as STREAMFLOW_TREASURY_PUBLIC_KEY, g as STREAM_STRUCT_OFFSETS, f as STREAM_STRUCT_OFFSET_CLOSED, e as STREAM_STRUCT_OFFSET_MINT, d as STREAM_STRUCT_OFFSET_RECIPIENT, c as STREAM_STRUCT_OFFSET_SENDER, i as StreamflowSolana, l as TEST_ORACLE_DISCRIMINATOR, n as TEST_ORACLE_SEED, T as TX_FINALITY_CONFIRMED, W as WITHDRAWOR_PUBLIC_KEY } from './index-ByMlPIUq.cjs';
7
7
  import { S as SuiStreamClient } from './index-Y0HH2ugY.cjs';
8
8
  export { i as StreamflowSui } from './index-Y0HH2ugY.cjs';
9
9
  import { S as Stream, A as AlignedStream, I as ICreateStreamData, a as ICreateAlignedStreamData, b as StreamType, B as BaseStreamClient, c as SolanaStreamClientOptions, d as AptosStreamClientOptions, e as SuiStreamClientOptions, E as EvmStreamClientOptions, f as ICreateStreamSuiExt, g as ICreateResult, h as ICreateMultipleStreamData, i as IMultiTransactionResult, j as IWithdrawData, k as ITransactionSuiExt, l as ITransactionResult, m as ICancelData, n as ITransferData, o as ITopUpData, p as IGetOneData, q as IGetAllData, r as IUpdateData, s as IGetFeesData, t as IFees } from './BaseStreamClient-DOyJqO7R.cjs';
@@ -8,7 +8,7 @@ type StreamflowAlignedUnlocks = {
8
8
  "address": "aSTRM2NKoKxNnkmLWk9sz3k74gKBk9t7bpPrTGxMszH";
9
9
  "metadata": {
10
10
  "name": "streamflowAlignedUnlocks";
11
- "version": "1.3.0";
11
+ "version": "1.4.0";
12
12
  "spec": "0.1.0";
13
13
  "description": "Proxy to update unlock amount within Streamflow vesting protocol according to Token performance and other metrics";
14
14
  };
@@ -882,6 +882,80 @@ type StreamflowAlignedUnlocks = {
882
882
  ];
883
883
  "args": [];
884
884
  },
885
+ {
886
+ "name": "updateContract";
887
+ "discriminator": [
888
+ 78,
889
+ 184,
890
+ 162,
891
+ 174,
892
+ 233,
893
+ 5,
894
+ 40,
895
+ 82
896
+ ];
897
+ "accounts": [
898
+ {
899
+ "name": "sender";
900
+ "writable": true;
901
+ "signer": true;
902
+ },
903
+ {
904
+ "name": "proxyMetadata";
905
+ "docs": [
906
+ "Proxy Contract"
907
+ ];
908
+ "writable": true;
909
+ "pda": {
910
+ "seeds": [
911
+ {
912
+ "kind": "const";
913
+ "value": [
914
+ 99,
915
+ 111,
916
+ 110,
917
+ 116,
918
+ 114,
919
+ 97,
920
+ 99,
921
+ 116
922
+ ];
923
+ },
924
+ {
925
+ "kind": "account";
926
+ "path": "streamMetadata";
927
+ }
928
+ ];
929
+ };
930
+ },
931
+ {
932
+ "name": "streamMetadata";
933
+ "writable": true;
934
+ },
935
+ {
936
+ "name": "withdrawor";
937
+ "writable": true;
938
+ },
939
+ {
940
+ "name": "streamflowProgram";
941
+ "address": "strmRqUCoQUgGUan5YhzUZa6KqdzwX5L6FpUxfmKg5m";
942
+ },
943
+ {
944
+ "name": "systemProgram";
945
+ "address": "11111111111111111111111111111111";
946
+ }
947
+ ];
948
+ "args": [
949
+ {
950
+ "name": "params";
951
+ "type": {
952
+ "defined": {
953
+ "name": "updateContractParams";
954
+ };
955
+ };
956
+ }
957
+ ];
958
+ },
885
959
  {
886
960
  "name": "updateTestOracle";
887
961
  "discriminator": [
@@ -1477,6 +1551,32 @@ type StreamflowAlignedUnlocks = {
1477
1551
  ];
1478
1552
  };
1479
1553
  },
1554
+ {
1555
+ "name": "updateContractParams";
1556
+ "type": {
1557
+ "kind": "struct";
1558
+ "fields": [
1559
+ {
1560
+ "name": "transferableBySender";
1561
+ "type": {
1562
+ "option": "bool";
1563
+ };
1564
+ },
1565
+ {
1566
+ "name": "transferableByRecipient";
1567
+ "type": {
1568
+ "option": "bool";
1569
+ };
1570
+ },
1571
+ {
1572
+ "name": "cancelableBySender";
1573
+ "type": {
1574
+ "option": "bool";
1575
+ };
1576
+ }
1577
+ ];
1578
+ };
1579
+ },
1480
1580
  {
1481
1581
  "name": "updateTestOracleParams";
1482
1582
  "type": {
@@ -900,7 +900,7 @@ var streamflow_aligned_unlocks_default = {
900
900
  address: "aSTRM2NKoKxNnkmLWk9sz3k74gKBk9t7bpPrTGxMszH",
901
901
  metadata: {
902
902
  name: "streamflow_aligned_unlocks",
903
- version: "1.3.0",
903
+ version: "1.4.0",
904
904
  spec: "0.1.0",
905
905
  description: "Proxy to update unlock amount within Streamflow vesting protocol according to Token performance and other metrics"
906
906
  },
@@ -1774,6 +1774,80 @@ var streamflow_aligned_unlocks_default = {
1774
1774
  ],
1775
1775
  args: []
1776
1776
  },
1777
+ {
1778
+ name: "update_contract",
1779
+ discriminator: [
1780
+ 78,
1781
+ 184,
1782
+ 162,
1783
+ 174,
1784
+ 233,
1785
+ 5,
1786
+ 40,
1787
+ 82
1788
+ ],
1789
+ accounts: [
1790
+ {
1791
+ name: "sender",
1792
+ writable: true,
1793
+ signer: true
1794
+ },
1795
+ {
1796
+ name: "proxy_metadata",
1797
+ docs: [
1798
+ "Proxy Contract"
1799
+ ],
1800
+ writable: true,
1801
+ pda: {
1802
+ seeds: [
1803
+ {
1804
+ kind: "const",
1805
+ value: [
1806
+ 99,
1807
+ 111,
1808
+ 110,
1809
+ 116,
1810
+ 114,
1811
+ 97,
1812
+ 99,
1813
+ 116
1814
+ ]
1815
+ },
1816
+ {
1817
+ kind: "account",
1818
+ path: "stream_metadata"
1819
+ }
1820
+ ]
1821
+ }
1822
+ },
1823
+ {
1824
+ name: "stream_metadata",
1825
+ writable: true
1826
+ },
1827
+ {
1828
+ name: "withdrawor",
1829
+ writable: true
1830
+ },
1831
+ {
1832
+ name: "streamflow_program",
1833
+ address: "strmRqUCoQUgGUan5YhzUZa6KqdzwX5L6FpUxfmKg5m"
1834
+ },
1835
+ {
1836
+ name: "system_program",
1837
+ address: "11111111111111111111111111111111"
1838
+ }
1839
+ ],
1840
+ args: [
1841
+ {
1842
+ name: "params",
1843
+ type: {
1844
+ defined: {
1845
+ name: "UpdateContractParams"
1846
+ }
1847
+ }
1848
+ }
1849
+ ]
1850
+ },
1777
1851
  {
1778
1852
  name: "update_test_oracle",
1779
1853
  discriminator: [
@@ -2369,6 +2443,32 @@ var streamflow_aligned_unlocks_default = {
2369
2443
  ]
2370
2444
  }
2371
2445
  },
2446
+ {
2447
+ name: "UpdateContractParams",
2448
+ type: {
2449
+ kind: "struct",
2450
+ fields: [
2451
+ {
2452
+ name: "transferable_by_sender",
2453
+ type: {
2454
+ option: "bool"
2455
+ }
2456
+ },
2457
+ {
2458
+ name: "transferable_by_recipient",
2459
+ type: {
2460
+ option: "bool"
2461
+ }
2462
+ },
2463
+ {
2464
+ name: "cancelable_by_sender",
2465
+ type: {
2466
+ option: "bool"
2467
+ }
2468
+ }
2469
+ ]
2470
+ }
2471
+ },
2372
2472
  {
2373
2473
  name: "UpdateTestOracleParams",
2374
2474
  type: {
@@ -2594,7 +2694,10 @@ var SolanaStreamClient = class extends BaseStreamClient {
2594
2694
  floorPrice
2595
2695
  } = streamParams;
2596
2696
  const { isNative, sender, computeLimit, computePrice, metadataPubKeys } = extParams;
2597
- common.invariant(priceOracle || !oracleType || oracleType === "none", "Price oracle is required for the specified oracle type");
2697
+ common.invariant(
2698
+ priceOracle || !oracleType || oracleType === "none",
2699
+ "Price oracle is required for the specified oracle type"
2700
+ );
2598
2701
  common.assertHasPublicKey(sender, "Sender's PublicKey is not available, check passed wallet adapter!");
2599
2702
  const recipientPublicKey = new web3_js.PublicKey(recipient);
2600
2703
  const mintPublicKey = isNative ? splToken.NATIVE_MINT : new web3_js.PublicKey(mint);
@@ -2769,10 +2872,7 @@ var SolanaStreamClient = class extends BaseStreamClient {
2769
2872
  * @returns Create result
2770
2873
  */
2771
2874
  async createUnchecked(data, extParams) {
2772
- const { ixs, metadata, metadataPubKey } = await this.prepareCreateUncheckedInstructions(
2773
- data,
2774
- extParams
2775
- );
2875
+ const { ixs, metadata, metadataPubKey } = await this.prepareCreateUncheckedInstructions(data, extParams);
2776
2876
  const { tx, hash, context } = await solana.prepareTransaction(
2777
2877
  this.connection,
2778
2878
  ixs,
@@ -2924,19 +3024,10 @@ var SolanaStreamClient = class extends BaseStreamClient {
2924
3024
  recipient: recipientData.recipient
2925
3025
  });
2926
3026
  }
2927
- const prepareInstructions = await this.getCreateATAInstructions(
2928
- [partnerPublicKey],
2929
- mintPublicKey,
2930
- sender,
2931
- true
2932
- );
3027
+ const prepareInstructions = await this.getCreateATAInstructions([partnerPublicKey], mintPublicKey, sender, true);
2933
3028
  if (isNative) {
2934
3029
  const totalDepositedAmount = recipients.reduce((acc, recipient) => recipient.amount.add(acc), new BN4__default.default(0));
2935
- const nativeInstructions = await solana.prepareWrappedAccount(
2936
- this.connection,
2937
- sender.publicKey,
2938
- totalDepositedAmount
2939
- );
3030
+ const nativeInstructions = await solana.prepareWrappedAccount(this.connection, sender.publicKey, totalDepositedAmount);
2940
3031
  prepareInstructions.push(...nativeInstructions);
2941
3032
  }
2942
3033
  return {
@@ -3134,10 +3225,7 @@ var SolanaStreamClient = class extends BaseStreamClient {
3134
3225
  async withdraw({ id, amount = WITHDRAW_AVAILABLE_AMOUNT }, extParams) {
3135
3226
  const { invoker, customInstructions } = extParams;
3136
3227
  common.assertHasPublicKey(invoker, "Invoker's PublicKey is not available, check passed wallet adapter!");
3137
- const ixs = await this.prepareWithdrawInstructions(
3138
- { id, amount },
3139
- extParams
3140
- );
3228
+ const ixs = await this.prepareWithdrawInstructions({ id, amount }, extParams);
3141
3229
  const metadata = new web3_js.PublicKey(id);
3142
3230
  await this.applyCustomAfterInstructions(ixs, customInstructions, metadata);
3143
3231
  const { tx, hash, context } = await solana.prepareTransaction(this.connection, ixs, invoker.publicKey);
@@ -3587,10 +3675,20 @@ var SolanaStreamClient = class extends BaseStreamClient {
3587
3675
  const accounts = await this.connection.getProgramAccounts(this.programId, {
3588
3676
  filters
3589
3677
  });
3590
- return accounts.map(({ pubkey, account }) => ({
3591
- publicKey: pubkey,
3592
- account: new Contract(decodeStream(account.data))
3593
- }));
3678
+ const mapped = await Promise.all(
3679
+ accounts.map(async ({ pubkey, account }) => {
3680
+ const stream = decodeStream(account.data);
3681
+ if (this.isAlignedUnlock(pubkey, stream.sender)) {
3682
+ const alignedProxy = await this.alignedProxyProgram.account.contract.fetch(
3683
+ deriveContractPDA(this.alignedProxyProgram.programId, pubkey)
3684
+ );
3685
+ common.invariant(alignedProxy, "Couldn't get aligned proxy account info");
3686
+ return { publicKey: pubkey, account: new AlignedContract(stream, alignedProxy) };
3687
+ }
3688
+ return { publicKey: pubkey, account: new Contract(stream) };
3689
+ })
3690
+ );
3691
+ return mapped;
3594
3692
  }
3595
3693
  /**
3596
3694
  * Attempts updating the stream auto withdrawal params and amount per period
@@ -3631,17 +3729,26 @@ var SolanaStreamClient = class extends BaseStreamClient {
3631
3729
  const streamPublicKey = new web3_js.PublicKey(data.id);
3632
3730
  const escrow = await this.connection.getAccountInfo(streamPublicKey);
3633
3731
  common.invariant(escrow, "Couldn't get account info");
3732
+ const { sender: senderPublicKey } = decodeStream(escrow.data);
3733
+ const isAlignedUnlock = this.isAlignedUnlock(streamPublicKey, senderPublicKey);
3734
+ if (isAlignedUnlock && (data.enableAutomaticWithdrawal !== void 0 || data.amountPerPeriod !== void 0)) {
3735
+ throw new Error("Automatic withdrawal and rate update are not possible in price-based vesting!");
3736
+ }
3634
3737
  const ixs = solana.prepareBaseInstructions(this.connection, {
3635
3738
  computePrice,
3636
3739
  computeLimit
3637
3740
  });
3638
3741
  ixs.push(
3639
- await updateStreamInstruction(data, this.programId, {
3742
+ await (isAlignedUnlock ? this.alignedProxyProgram.methods.updateContract({
3743
+ transferableBySender: data.transferableBySender ?? null,
3744
+ transferableByRecipient: data.transferableByRecipient ?? null,
3745
+ cancelableBySender: data.cancelableBySender ?? null
3746
+ }).accounts({ sender: invoker.publicKey, streamMetadata: streamPublicKey, withdrawor: WITHDRAWOR_PUBLIC_KEY }).accountsPartial({ streamflowProgram: this.programId }).instruction() : updateStreamInstruction(data, this.programId, {
3640
3747
  authority: invoker.publicKey,
3641
3748
  metadata: streamPublicKey,
3642
3749
  withdrawor: WITHDRAWOR_PUBLIC_KEY,
3643
3750
  systemProgram: web3_js.SystemProgram.programId
3644
- })
3751
+ }))
3645
3752
  );
3646
3753
  return ixs;
3647
3754
  }
@@ -3686,8 +3793,8 @@ var SolanaStreamClient = class extends BaseStreamClient {
3686
3793
  return extractSolanaErrorCode(err.toString() ?? "Unknown error!", logs);
3687
3794
  }
3688
3795
  /**
3689
- * Utility function that checks whether the associated stream address is an aligned unlock contract, indicated by whether the sender/creator is a PDA
3690
- */
3796
+ * Utility function that checks whether the associated stream address is an aligned unlock contract, indicated by whether the sender/creator is a PDA
3797
+ */
3691
3798
  isAlignedUnlock(streamPublicKey, senderPublicKey) {
3692
3799
  const pda = deriveContractPDA(this.alignedProxyProgram.programId, streamPublicKey);
3693
3800
  return senderPublicKey.equals(pda);