@streamflow/stream 9.0.4 → 9.2.0-alpha.p0.5034440

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,
@@ -2898,7 +2998,6 @@ var SolanaStreamClient = class extends BaseStreamClient {
2898
2998
  const metadatas = [];
2899
2999
  const metadataToRecipient = {};
2900
3000
  const instructionsBatch = [];
2901
- const metadataPubKeys = metadataPubKeysExt || [];
2902
3001
  const partnerPublicKey = data.partner ? new web3_js.PublicKey(data.partner) : WITHDRAWOR_PUBLIC_KEY;
2903
3002
  const mintPublicKey = new web3_js.PublicKey(data.tokenId);
2904
3003
  if (recipients.length === 0) {
@@ -2908,8 +3007,8 @@ var SolanaStreamClient = class extends BaseStreamClient {
2908
3007
  const recipientData = recipients[i];
2909
3008
  const createStreamData = { ...streamParams, ...recipientData };
2910
3009
  const createStreamExtParams = {
2911
- metadataPubKeys: metadataPubKeys[i] ? [metadataPubKeys[i]] : void 0,
2912
- ...extParams
3010
+ ...extParams,
3011
+ metadataPubKeys: metadataPubKeysExt?.[i] ? [metadataPubKeysExt[i]] : void 0
2913
3012
  };
2914
3013
  const { ixs, metadata, metadataPubKey } = await this.prepareCreateInstructions(
2915
3014
  createStreamData,
@@ -2924,19 +3023,10 @@ var SolanaStreamClient = class extends BaseStreamClient {
2924
3023
  recipient: recipientData.recipient
2925
3024
  });
2926
3025
  }
2927
- const prepareInstructions = await this.getCreateATAInstructions(
2928
- [partnerPublicKey],
2929
- mintPublicKey,
2930
- sender,
2931
- true
2932
- );
3026
+ const prepareInstructions = await this.getCreateATAInstructions([partnerPublicKey], mintPublicKey, sender, true);
2933
3027
  if (isNative) {
2934
3028
  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
- );
3029
+ const nativeInstructions = await solana.prepareWrappedAccount(this.connection, sender.publicKey, totalDepositedAmount);
2940
3030
  prepareInstructions.push(...nativeInstructions);
2941
3031
  }
2942
3032
  return {
@@ -3134,10 +3224,7 @@ var SolanaStreamClient = class extends BaseStreamClient {
3134
3224
  async withdraw({ id, amount = WITHDRAW_AVAILABLE_AMOUNT }, extParams) {
3135
3225
  const { invoker, customInstructions } = extParams;
3136
3226
  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
- );
3227
+ const ixs = await this.prepareWithdrawInstructions({ id, amount }, extParams);
3141
3228
  const metadata = new web3_js.PublicKey(id);
3142
3229
  await this.applyCustomAfterInstructions(ixs, customInstructions, metadata);
3143
3230
  const { tx, hash, context } = await solana.prepareTransaction(this.connection, ixs, invoker.publicKey);
@@ -3641,17 +3728,26 @@ var SolanaStreamClient = class extends BaseStreamClient {
3641
3728
  const streamPublicKey = new web3_js.PublicKey(data.id);
3642
3729
  const escrow = await this.connection.getAccountInfo(streamPublicKey);
3643
3730
  common.invariant(escrow, "Couldn't get account info");
3731
+ const { sender: senderPublicKey } = decodeStream(escrow.data);
3732
+ const isAlignedUnlock = this.isAlignedUnlock(streamPublicKey, senderPublicKey);
3733
+ if (isAlignedUnlock && (data.enableAutomaticWithdrawal !== void 0 || data.amountPerPeriod !== void 0)) {
3734
+ throw new Error("Automatic withdrawal and rate update are not possible in price-based vesting!");
3735
+ }
3644
3736
  const ixs = solana.prepareBaseInstructions(this.connection, {
3645
3737
  computePrice,
3646
3738
  computeLimit
3647
3739
  });
3648
3740
  ixs.push(
3649
- await updateStreamInstruction(data, this.programId, {
3741
+ await (isAlignedUnlock ? this.alignedProxyProgram.methods.updateContract({
3742
+ transferableBySender: data.transferableBySender ?? null,
3743
+ transferableByRecipient: data.transferableByRecipient ?? null,
3744
+ cancelableBySender: data.cancelableBySender ?? null
3745
+ }).accounts({ sender: invoker.publicKey, streamMetadata: streamPublicKey, withdrawor: WITHDRAWOR_PUBLIC_KEY }).accountsPartial({ streamflowProgram: this.programId }).instruction() : updateStreamInstruction(data, this.programId, {
3650
3746
  authority: invoker.publicKey,
3651
3747
  metadata: streamPublicKey,
3652
3748
  withdrawor: WITHDRAWOR_PUBLIC_KEY,
3653
3749
  systemProgram: web3_js.SystemProgram.programId
3654
- })
3750
+ }))
3655
3751
  );
3656
3752
  return ixs;
3657
3753
  }
@@ -3696,8 +3792,8 @@ var SolanaStreamClient = class extends BaseStreamClient {
3696
3792
  return extractSolanaErrorCode(err.toString() ?? "Unknown error!", logs);
3697
3793
  }
3698
3794
  /**
3699
- * Utility function that checks whether the associated stream address is an aligned unlock contract, indicated by whether the sender/creator is a PDA
3700
- */
3795
+ * Utility function that checks whether the associated stream address is an aligned unlock contract, indicated by whether the sender/creator is a PDA
3796
+ */
3701
3797
  isAlignedUnlock(streamPublicKey, senderPublicKey) {
3702
3798
  const pda = deriveContractPDA(this.alignedProxyProgram.programId, streamPublicKey);
3703
3799
  return senderPublicKey.equals(pda);