@streamflow/stream 11.0.2 → 11.0.3

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.
@@ -1,4 +1,4 @@
1
- export { AIRDROP_AMOUNT, AIRDROP_TEST_TOKEN, ALIGNED_COMPUTE_LIMIT, ALIGNED_PRECISION_FACTOR_POW, ALIGNED_UNLOCKS_PROGRAM_ID, Account, AlignedContract, AlignedProxyErrorCode, AlignedStream, AlignedStreamData, AlignedUnlocksContract, BatchItem, BatchItemError, BatchItemResult, BatchItemSuccess, CONTRACT_DISCRIMINATOR, CONTRACT_SEED, CREATE_PARAMS_PADDING, ChangeOracleParams, ClientCreationOptions, Contract, ContractErrorCode, CreateParams, CreateTestOracleParams, DEFAULT_AUTO_CLAIM_FEE_SOL, DEFAULT_CREATION_FEE_SOL, DEFAULT_STREAMFLOW_FEE, DecodedStream, ESCROW_SEED, FEES_METADATA_SEED, FEE_ORACLE_PUBLIC_KEY, IAlignedStreamConfig, IBaseStreamConfig, ICancelData, ICreateAlignedStreamData, ICreateExt, ICreateLinearStreamData, ICreateMultiError, ICreateMultipleAlignedStreamData, ICreateMultipleLinearStreamData, ICreateMultipleStreamData, ICreateResult, ICreateStreamData, ICreateStreamExt, ICreateStreamInstructions, IFees, IGetAllData, IGetFeesData, IGetOneData, IInteractData, IInteractStreamExt, IMultiTransactionResult, IPrepareCreateStreamExt, IPrepareStreamExt, IRecipient, ISearchStreams, ITopUpData, ITopUpStreamExt, ITransactionExtWithInstructions, ITransactionResult, ITransferData, IUpdateData, IWithdrawData, InstructionGenerator, LinearStream, MAX_SAFE_UNIX_TIME_VALUE, MetadataRecipientHashMap, ORIGINAL_CONTRACT_SENDER_OFFSET, OracleType, OracleTypeName, PARTNERS_SCHEMA, PARTNER_ORACLE_PROGRAM_ID, PARTNER_SCHEMA, PROGRAM_ID, SOLANA_ERROR_MAP, SOLANA_ERROR_MATCH_REGEX, STREAMFLOW_TREASURY_PUBLIC_KEY, STREAM_STRUCT_OFFSETS, STREAM_STRUCT_OFFSET_CLOSED, STREAM_STRUCT_OFFSET_MINT, STREAM_STRUCT_OFFSET_OLD_METADATA_KEY, STREAM_STRUCT_OFFSET_RECIPIENT, STREAM_STRUCT_OFFSET_SENDER, SolanaStreamClient, Stream, StreamClientOptions, StreamDirection, StreamType, TEST_ORACLE_DISCRIMINATOR, TEST_ORACLE_SEED, TX_FINALITY_CONFIRMED, TestOracle, TransactionSchedulingOptions, UpdateTestOracleParams, WITHDRAWOR, WITHDRAWOR_PUBLIC_KEY, WITHDRAW_AVAILABLE_AMOUNT, buildStreamType, calculateTotalAmountToDeposit, calculateUnlockedAmount, cancelStreamInstruction, createStreamInstruction, createUncheckedStreamInstruction, decodeEndTime, decodeStream, deriveContractPDA, deriveEscrowPDA, deriveTestOraclePDA, extractSolanaErrorCode, getOriginalMetadataKey, handleContractError, isAligned, isCliffCloseToDepositedAmount, isCreateAlignedStreamData, isDynamicLock, isTokenLock, isVesting, sendAndConfirmStreamRawTransaction, signAllTransactionWithRecipients, timelockIDL, topupStreamInstruction, transferStreamInstruction, updateStreamInstruction, withdrawStreamInstruction } from './solana/index.cjs';
1
+ export { AIRDROP_AMOUNT, AIRDROP_TEST_TOKEN, ALIGNED_COMPUTE_LIMIT, ALIGNED_PRECISION_FACTOR_POW, ALIGNED_UNLOCKS_PROGRAM_ID, Account, AlignedContract, AlignedProxyErrorCode, AlignedStream, AlignedStreamData, AlignedUnlocksContract, BatchItem, BatchItemError, BatchItemResult, BatchItemSuccess, CONTRACT_DISCRIMINATOR, CONTRACT_SEED, CREATE_PARAMS_PADDING, ChangeOracleParams, ClientCreationOptions, Contract, ContractErrorCode, CreateParams, CreateTestOracleParams, DEFAULT_AUTO_CLAIM_FEE_SOL, DEFAULT_CREATION_FEE_SOL, DEFAULT_STREAMFLOW_FEE, DecodedStream, ESCROW_SEED, FEES_METADATA_SEED, FEE_ORACLE_PUBLIC_KEY, IAlignedStreamConfig, IBaseStreamConfig, ICancelData, ICreateAlignedStreamData, ICreateExt, ICreateLinearStreamData, ICreateMultiError, ICreateMultipleAlignedStreamData, ICreateMultipleLinearStreamData, ICreateMultipleStreamData, ICreateResult, ICreateStreamData, ICreateStreamExt, ICreateStreamInstructions, IFees, IGetAllData, IGetFeesData, IGetOneData, IInteractData, IInteractStreamExt, IMultiTransactionResult, IPrepareCreateStreamExt, IPrepareStreamExt, IRecipient, ISearchStreams, ITopUpData, ITopUpStreamExt, ITransactionExtWithInstructions, ITransactionResult, ITransferData, IUpdateData, IWithdrawData, InstructionGenerator, LinearStream, MAX_SAFE_UNIX_TIME_VALUE, MetadataRecipientHashMap, ORIGINAL_CONTRACT_SENDER_OFFSET, OracleType, OracleTypeName, PARTNERS_SCHEMA, PARTNER_ORACLE_PROGRAM_ID, PARTNER_SCHEMA, PROGRAM_ID, REPOPULATED_METADATA_SEED, SOLANA_ERROR_MAP, SOLANA_ERROR_MATCH_REGEX, STREAMFLOW_TREASURY_PUBLIC_KEY, STREAM_STRUCT_OFFSETS, STREAM_STRUCT_OFFSET_CLOSED, STREAM_STRUCT_OFFSET_MINT, STREAM_STRUCT_OFFSET_OLD_METADATA_KEY, STREAM_STRUCT_OFFSET_RECIPIENT, STREAM_STRUCT_OFFSET_SENDER, SolanaStreamClient, Stream, StreamClientOptions, StreamDirection, StreamType, TEST_ORACLE_DISCRIMINATOR, TEST_ORACLE_SEED, TX_FINALITY_CONFIRMED, TestOracle, TransactionSchedulingOptions, UpdateTestOracleParams, WITHDRAWOR, WITHDRAWOR_PUBLIC_KEY, WITHDRAW_AVAILABLE_AMOUNT, buildStreamType, calculateTotalAmountToDeposit, calculateUnlockedAmount, cancelStreamInstruction, createStreamInstruction, createUncheckedStreamInstruction, decodeEndTime, decodeStream, deriveContractPDA, deriveEscrowPDA, deriveRepopulatedMetadataPDA, deriveTestOraclePDA, extractSolanaErrorCode, getMetadataKey, handleContractError, isAligned, isCliffCloseToDepositedAmount, isCreateAlignedStreamData, isDynamicLock, isTokenLock, isVesting, sendAndConfirmStreamRawTransaction, signAllTransactionWithRecipients, timelockIDL, topupStreamInstruction, transferStreamInstruction, updateStreamInstruction, withdrawStreamInstruction } from './solana/index.cjs';
2
2
  export { ContractError, ICluster, getBN, getNumberFromBN } from '@streamflow/common';
3
3
  import 'p-queue';
4
4
  import '@solana/web3.js';
@@ -142,7 +142,7 @@ var AlignedProxyErrorCode = /* @__PURE__ */ ((AlignedProxyErrorCode2) => {
142
142
  return AlignedProxyErrorCode2;
143
143
  })(AlignedProxyErrorCode || {});
144
144
  var Contract = class {
145
- constructor(stream, metadata) {
145
+ constructor(stream) {
146
146
  this.magic = stream.magic.toNumber();
147
147
  this.version = stream.version.toNumber();
148
148
  this.createdAt = stream.createdAt.toNumber();
@@ -186,7 +186,6 @@ var Contract = class {
186
186
  this.lastRateChangeTime = stream.lastRateChangeTime.toNumber();
187
187
  this.fundsUnlockedAtLastRateChange = stream.fundsUnlockedAtLastRateChange;
188
188
  this.oldMetadata = stream.oldMetadata;
189
- this.metadata = metadata;
190
189
  this.type = buildStreamType(this);
191
190
  this.isAligned = false;
192
191
  }
@@ -201,8 +200,8 @@ var Contract = class {
201
200
  }
202
201
  };
203
202
  var AlignedContract = class extends Contract {
204
- constructor(stream, metadata, alignedProxy) {
205
- super(stream, metadata);
203
+ constructor(stream, alignedProxy) {
204
+ super(stream);
206
205
  this.minPrice = common.getNumberFromBN(alignedProxy.minPrice, ALIGNED_PRECISION_FACTOR_POW);
207
206
  this.maxPrice = common.getNumberFromBN(alignedProxy.maxPrice, ALIGNED_PRECISION_FACTOR_POW);
208
207
  this.minPercentage = common.getNumberFromBN(alignedProxy.minPercentage, ALIGNED_PRECISION_FACTOR_POW);
@@ -272,6 +271,7 @@ var TEST_ORACLE_DISCRIMINATOR = [198, 49, 63, 134, 232, 251, 168, 28];
272
271
  var CONTRACT_SEED = buffer.Buffer.from("contract", "utf-8");
273
272
  var ESCROW_SEED = buffer.Buffer.from("strm", "utf-8");
274
273
  var TEST_ORACLE_SEED = buffer.Buffer.from("test-oracle", "utf-8");
274
+ var REPOPULATED_METADATA_SEED = buffer.Buffer.from("strm-rep", "utf-8");
275
275
  var STREAMFLOW_TREASURY_PUBLIC_KEY = new web3_js.PublicKey("5SEpbdjFK5FxwTvfsGMXVQTD2v4M2c5tyRTxhdsPkgDw");
276
276
  var WITHDRAWOR = "wdrwhnCv4pzW8beKsbPa4S2UDZrXenjg16KJdKSpb5u";
277
277
  var WITHDRAWOR_PUBLIC_KEY = new web3_js.PublicKey(WITHDRAWOR);
@@ -496,7 +496,7 @@ var encodeUpdateStream = (values, data) => {
496
496
  var topupStreamLayout = BufferLayout__namespace.struct([
497
497
  BufferLayout__namespace.blob(8, "amount")
498
498
  ]);
499
- var getOriginalMetadataKey = (streamPubkey, oldMetadata) => {
499
+ var getMetadataKey = (streamPubkey, oldMetadata) => {
500
500
  if (web3_js.PublicKey.default.equals(oldMetadata)) {
501
501
  return streamPubkey;
502
502
  }
@@ -2539,6 +2539,9 @@ var deriveEscrowPDA = (programId, streamMetadata) => {
2539
2539
  var deriveTestOraclePDA = (programId, mint, creator) => {
2540
2540
  return web3_js.PublicKey.findProgramAddressSync([TEST_ORACLE_SEED, mint.toBuffer(), creator.toBuffer()], programId)[0];
2541
2541
  };
2542
+ var deriveRepopulatedMetadataPDA = (programId, streamMetadata) => {
2543
+ return web3_js.PublicKey.findProgramAddressSync([REPOPULATED_METADATA_SEED, streamMetadata.toBuffer()], programId)[0];
2544
+ };
2542
2545
 
2543
2546
  // solana/StreamClient.ts
2544
2547
  var METADATA_ACC_SIZE = 1104;
@@ -3604,7 +3607,7 @@ var SolanaStreamClient = class {
3604
3607
  }
3605
3608
  async decodeStreamAccount(pubkey, data) {
3606
3609
  const stream = decodeStream(data);
3607
- const metadataKey = getOriginalMetadataKey(pubkey, stream.oldMetadata);
3610
+ const metadataKey = getMetadataKey(pubkey, stream.oldMetadata);
3608
3611
  if (this.isAlignedUnlock(pubkey, stream.sender, stream.oldMetadata)) {
3609
3612
  const alignedProxy = await this.alignedProxyProgram.account.contract.fetch(
3610
3613
  deriveContractPDA(this.alignedProxyProgram.programId, metadataKey)
@@ -3612,9 +3615,9 @@ var SolanaStreamClient = class {
3612
3615
  if (!alignedProxy) {
3613
3616
  throw new Error("Couldn't get proxy account info.");
3614
3617
  }
3615
- return new AlignedContract(stream, common.pk(pubkey), alignedProxy);
3618
+ return new AlignedContract(stream, alignedProxy);
3616
3619
  }
3617
- return new Contract(stream, common.pk(pubkey));
3620
+ return new Contract(stream);
3618
3621
  }
3619
3622
  /**
3620
3623
  * Fetch all aligned outgoing streams/contracts by the provided public key.
@@ -3639,7 +3642,7 @@ var SolanaStreamClient = class {
3639
3642
  streamAccounts.forEach((account, index) => {
3640
3643
  if (account) {
3641
3644
  const alignedData = alignedOutgoingProgramAccounts[index].account;
3642
- streams[streamPubKeys[index].toBase58()] = new AlignedContract(decodeStream(account.data), common.pk(streamPubKeys[index]), alignedData);
3645
+ streams[streamPubKeys[index].toBase58()] = new AlignedContract(decodeStream(account.data), alignedData);
3643
3646
  }
3644
3647
  });
3645
3648
  return streams;
@@ -3649,7 +3652,7 @@ var SolanaStreamClient = class {
3649
3652
  const alignedStreamsPubKeys = Object.keys(streamRecord);
3650
3653
  const alignedProxyPDAs = alignedStreamsPubKeys.map((streamPubKey) => {
3651
3654
  const pubkey = new web3_js.PublicKey(streamPubKey);
3652
- const metadataKey = getOriginalMetadataKey(pubkey, streamRecord[streamPubKey].oldMetadata);
3655
+ const metadataKey = getMetadataKey(pubkey, streamRecord[streamPubKey].oldMetadata);
3653
3656
  return deriveContractPDA(this.alignedProxyProgram.programId, metadataKey);
3654
3657
  });
3655
3658
  const alignedProxyAccounts = await common.getMultipleAccountsInfoBatched(this.connection, alignedProxyPDAs);
@@ -3658,7 +3661,6 @@ var SolanaStreamClient = class {
3658
3661
  const alignedData = streamRecord[alignedStreamsPubKeys[index]];
3659
3662
  streams[alignedStreamsPubKeys[index]] = new AlignedContract(
3660
3663
  alignedData,
3661
- common.pk(alignedStreamsPubKeys[index]),
3662
3664
  this.alignedProxyProgram.account.contract.coder.accounts.decode("contract", account.data)
3663
3665
  );
3664
3666
  }
@@ -3687,7 +3689,7 @@ var SolanaStreamClient = class {
3687
3689
  this.programId
3688
3690
  );
3689
3691
  outgoingStreamAccounts.forEach((account) => {
3690
- streams[account.pubkey.toBase58()] = new Contract(decodeStream(account.account.data), common.pk(account.pubkey));
3692
+ streams[account.pubkey.toBase58()] = new Contract(decodeStream(account.account.data));
3691
3693
  });
3692
3694
  if (shouldFetchAligned) {
3693
3695
  const alignedStreams = await this.getOutgoingAlignedStreams(address);
@@ -3707,7 +3709,7 @@ var SolanaStreamClient = class {
3707
3709
  if (this.isAlignedUnlock(account.pubkey, allIncomingStreams[index].sender, allIncomingStreams[index].oldMetadata)) {
3708
3710
  alignedDecoded[account.pubkey.toBase58()] = allIncomingStreams[index];
3709
3711
  } else {
3710
- streams[account.pubkey.toBase58()] = new Contract(allIncomingStreams[index], common.pk(account.pubkey));
3712
+ streams[account.pubkey.toBase58()] = new Contract(allIncomingStreams[index]);
3711
3713
  }
3712
3714
  });
3713
3715
  if (shouldFetchAligned) {
@@ -3750,7 +3752,7 @@ var SolanaStreamClient = class {
3750
3752
  const entries = [];
3751
3753
  decoded.forEach(({ pubkey, stream }, index) => {
3752
3754
  if (this.isAlignedUnlock(pubkey, stream.sender, stream.oldMetadata)) {
3753
- const metadataKey = getOriginalMetadataKey(pubkey, stream.oldMetadata);
3755
+ const metadataKey = getMetadataKey(pubkey, stream.oldMetadata);
3754
3756
  entries.push({ index, pda: deriveContractPDA(this.alignedProxyProgram.programId, metadataKey) });
3755
3757
  }
3756
3758
  });
@@ -3767,9 +3769,9 @@ var SolanaStreamClient = class {
3767
3769
  if (alignedIdx !== -1) {
3768
3770
  const alignedProxy = alignedProxies[alignedIdx];
3769
3771
  common.invariant(alignedProxy, "Couldn't get aligned proxy account info");
3770
- return { publicKey: pubkey, account: new AlignedContract(stream, common.pk(pubkey), alignedProxy) };
3772
+ return { publicKey: pubkey, account: new AlignedContract(stream, alignedProxy) };
3771
3773
  }
3772
- return { publicKey: pubkey, account: new Contract(stream, common.pk(pubkey)) };
3774
+ return { publicKey: pubkey, account: new Contract(stream) };
3773
3775
  });
3774
3776
  }
3775
3777
  /**
@@ -3907,7 +3909,7 @@ var SolanaStreamClient = class {
3907
3909
  * For migrated streams, the PDA was derived from the old metadata key.
3908
3910
  */
3909
3911
  isAlignedUnlock(streamPublicKey, senderPublicKey, oldMetadata) {
3910
- const metadataKey = oldMetadata ? getOriginalMetadataKey(streamPublicKey, oldMetadata) : streamPublicKey;
3912
+ const metadataKey = oldMetadata ? getMetadataKey(streamPublicKey, oldMetadata) : streamPublicKey;
3911
3913
  const pda = deriveContractPDA(this.alignedProxyProgram.programId, metadataKey);
3912
3914
  return senderPublicKey.equals(pda);
3913
3915
  }
@@ -4425,6 +4427,7 @@ exports.PARTNERS_SCHEMA = PARTNERS_SCHEMA;
4425
4427
  exports.PARTNER_ORACLE_PROGRAM_ID = PARTNER_ORACLE_PROGRAM_ID;
4426
4428
  exports.PARTNER_SCHEMA = PARTNER_SCHEMA;
4427
4429
  exports.PROGRAM_ID = PROGRAM_ID;
4430
+ exports.REPOPULATED_METADATA_SEED = REPOPULATED_METADATA_SEED;
4428
4431
  exports.SOLANA_ERROR_MAP = SOLANA_ERROR_MAP;
4429
4432
  exports.SOLANA_ERROR_MATCH_REGEX = SOLANA_ERROR_MATCH_REGEX;
4430
4433
  exports.STREAMFLOW_TREASURY_PUBLIC_KEY = STREAMFLOW_TREASURY_PUBLIC_KEY;
@@ -4453,9 +4456,10 @@ exports.decodeEndTime = decodeEndTime;
4453
4456
  exports.decodeStream = decodeStream;
4454
4457
  exports.deriveContractPDA = deriveContractPDA;
4455
4458
  exports.deriveEscrowPDA = deriveEscrowPDA;
4459
+ exports.deriveRepopulatedMetadataPDA = deriveRepopulatedMetadataPDA;
4456
4460
  exports.deriveTestOraclePDA = deriveTestOraclePDA;
4457
4461
  exports.extractSolanaErrorCode = extractSolanaErrorCode;
4458
- exports.getOriginalMetadataKey = getOriginalMetadataKey;
4462
+ exports.getMetadataKey = getMetadataKey;
4459
4463
  exports.handleContractError = handleContractError;
4460
4464
  exports.isAligned = isAligned;
4461
4465
  exports.isCliffCloseToDepositedAmount = isCliffCloseToDepositedAmount;