@streamflow/stream 10.0.0-alpha.p313.fe3720a → 10.0.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.
- package/README.md +146 -1
- package/dist/cjs/index.cjs +123 -52
- package/dist/cjs/index.cjs.map +1 -1
- package/dist/cjs/index.d.cts +1 -1
- package/dist/cjs/solana/index.cjs +123 -52
- package/dist/cjs/solana/index.cjs.map +1 -1
- package/dist/cjs/solana/index.d.cts +59 -14
- package/dist/esm/index.d.ts +1 -1
- package/dist/esm/index.js +121 -53
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/solana/index.d.ts +59 -14
- package/dist/esm/solana/index.js +121 -53
- package/dist/esm/solana/index.js.map +1 -1
- package/package.json +4 -4
package/dist/cjs/index.d.cts
CHANGED
|
@@ -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_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_RECIPIENT, STREAM_STRUCT_OFFSET_SENDER, SolanaStreamClient, Stream, StreamClientOptions, StreamDirection, StreamType, TEST_ORACLE_DISCRIMINATOR, TEST_ORACLE_SEED, TX_FINALITY_CONFIRMED, TestOracle, TransactionSchedulingOptions, UpdateTestOracleParams, WITHDRAWOR_PUBLIC_KEY, WITHDRAW_AVAILABLE_AMOUNT, buildStreamType, calculateTotalAmountToDeposit, calculateUnlockedAmount, cancelStreamInstruction, createStreamInstruction, createUncheckedStreamInstruction, decodeEndTime, decodeStream, deriveContractPDA, deriveEscrowPDA, deriveTestOraclePDA, extractSolanaErrorCode, 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, 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_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, 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';
|
|
@@ -63,7 +63,7 @@ var isVesting = (streamData) => {
|
|
|
63
63
|
return !isCliffCloseToDepositedAmount(streamData) && !isDynamicLock(streamData.minPrice, streamData.maxPrice, streamData.minPercentage, streamData.maxPercentage);
|
|
64
64
|
};
|
|
65
65
|
var isAligned = (stream) => {
|
|
66
|
-
return
|
|
66
|
+
return stream.isAligned;
|
|
67
67
|
};
|
|
68
68
|
var isCreateAlignedStreamData = (obj) => {
|
|
69
69
|
return "minPrice" in obj && "maxPrice" in obj && "minPercentage" in obj && "maxPercentage" in obj;
|
|
@@ -251,25 +251,40 @@ var ALIGNED_UNLOCKS_PROGRAM_ID = {
|
|
|
251
251
|
[common.ICluster.Testnet]: "aSTRM2NKoKxNnkmLWk9sz3k74gKBk9t7bpPrTGxMszH",
|
|
252
252
|
[common.ICluster.Local]: "aSTRM2NKoKxNnkmLWk9sz3k74gKBk9t7bpPrTGxMszH"
|
|
253
253
|
};
|
|
254
|
+
var PARTNER_ORACLE_PROGRAM_ID = {
|
|
255
|
+
[common.ICluster.Devnet]: "pardoTarcc6HKsPcbXkVycxsJsoN9QEzrdHgVdHAGY3",
|
|
256
|
+
[common.ICluster.Mainnet]: "pardpVtPjC8nLj1Dwncew62mUzfChdCX1EaoZe8oCAa",
|
|
257
|
+
[common.ICluster.Testnet]: "pardoTarcc6HKsPcbXkVycxsJsoN9QEzrdHgVdHAGY3",
|
|
258
|
+
[common.ICluster.Local]: "pardoTarcc6HKsPcbXkVycxsJsoN9QEzrdHgVdHAGY3"
|
|
259
|
+
};
|
|
260
|
+
var FEE_ORACLE_PUBLIC_KEY = {
|
|
261
|
+
[common.ICluster.Devnet]: "Aa2JJfFzUN3V54DXUHRBJowFw416xfZHpPk9DaNy3iYs",
|
|
262
|
+
[common.ICluster.Mainnet]: "B743wFVk2pCYhV91cn287e1xY7f1vt4gdY48hhNiuQmT",
|
|
263
|
+
[common.ICluster.Testnet]: "Aa2JJfFzUN3V54DXUHRBJowFw416xfZHpPk9DaNy3iYs",
|
|
264
|
+
[common.ICluster.Local]: "Aa2JJfFzUN3V54DXUHRBJowFw416xfZHpPk9DaNy3iYs"
|
|
265
|
+
};
|
|
254
266
|
var ALIGNED_COMPUTE_LIMIT = 3e5;
|
|
255
267
|
var CONTRACT_DISCRIMINATOR = [172, 138, 115, 242, 121, 67, 183, 26];
|
|
256
268
|
var TEST_ORACLE_DISCRIMINATOR = [198, 49, 63, 134, 232, 251, 168, 28];
|
|
257
269
|
var CONTRACT_SEED = buffer.Buffer.from("contract", "utf-8");
|
|
258
270
|
var ESCROW_SEED = buffer.Buffer.from("strm", "utf-8");
|
|
259
271
|
var TEST_ORACLE_SEED = buffer.Buffer.from("test-oracle", "utf-8");
|
|
260
|
-
var PARTNER_ORACLE_PROGRAM_ID = "pardpVtPjC8nLj1Dwncew62mUzfChdCX1EaoZe8oCAa";
|
|
261
272
|
var STREAMFLOW_TREASURY_PUBLIC_KEY = new web3_js.PublicKey("5SEpbdjFK5FxwTvfsGMXVQTD2v4M2c5tyRTxhdsPkgDw");
|
|
262
|
-
var
|
|
263
|
-
var
|
|
273
|
+
var WITHDRAWOR = "wdrwhnCv4pzW8beKsbPa4S2UDZrXenjg16KJdKSpb5u";
|
|
274
|
+
var WITHDRAWOR_PUBLIC_KEY = new web3_js.PublicKey(WITHDRAWOR);
|
|
264
275
|
var AIRDROP_TEST_TOKEN = "Gssm3vfi8s65R31SBdmQRq6cKeYojGgup7whkw4VCiQj";
|
|
265
276
|
var FEES_METADATA_SEED = buffer.Buffer.from("strm_fees");
|
|
266
|
-
var
|
|
277
|
+
var DEFAULT_CREATION_FEE_SOL = 9e7;
|
|
278
|
+
var DEFAULT_AUTO_CLAIM_FEE_SOL = 19e7;
|
|
279
|
+
var DEFAULT_STREAMFLOW_FEE = 0.19;
|
|
267
280
|
var AIRDROP_AMOUNT = 1;
|
|
268
281
|
var PARTNER_SCHEMA = {
|
|
269
282
|
struct: {
|
|
270
283
|
pubkey: { array: { type: "u8", len: 32 } },
|
|
271
|
-
|
|
272
|
-
|
|
284
|
+
creation_fee: "u32",
|
|
285
|
+
auto_claim_fee: "u32",
|
|
286
|
+
token_fee_percent: "f32",
|
|
287
|
+
buffer: { array: { type: "u8", len: 16 } }
|
|
273
288
|
}
|
|
274
289
|
};
|
|
275
290
|
var PARTNERS_SCHEMA = { array: { type: PARTNER_SCHEMA } };
|
|
@@ -2522,6 +2537,8 @@ var SolanaStreamClient = class {
|
|
|
2522
2537
|
this.commitment = commitment;
|
|
2523
2538
|
this.connection = new web3_js.Connection(optionsOrClusterUrl, this.commitment);
|
|
2524
2539
|
this.programId = programId !== "" ? new web3_js.PublicKey(programId) : new web3_js.PublicKey(PROGRAM_ID[cluster]);
|
|
2540
|
+
this.partnerOracleProgramId = new web3_js.PublicKey(PARTNER_ORACLE_PROGRAM_ID[cluster]);
|
|
2541
|
+
this.feeOraclePublicKey = new web3_js.PublicKey(FEE_ORACLE_PUBLIC_KEY[cluster]);
|
|
2525
2542
|
this.schedulingParams = {
|
|
2526
2543
|
sendThrottler: sendThrottler ?? common.buildSendThrottler(sendRate)
|
|
2527
2544
|
};
|
|
@@ -2536,6 +2553,8 @@ var SolanaStreamClient = class {
|
|
|
2536
2553
|
this.commitment = commitment2;
|
|
2537
2554
|
this.connection = new web3_js.Connection(clusterUrl, this.commitment);
|
|
2538
2555
|
this.programId = programId2 !== "" ? new web3_js.PublicKey(programId2) : new web3_js.PublicKey(PROGRAM_ID[cluster2]);
|
|
2556
|
+
this.partnerOracleProgramId = new web3_js.PublicKey(PARTNER_ORACLE_PROGRAM_ID[cluster2]);
|
|
2557
|
+
this.feeOraclePublicKey = new web3_js.PublicKey(FEE_ORACLE_PUBLIC_KEY[cluster2]);
|
|
2539
2558
|
const schedulingOptions = sendScheduler && "sendRate" in sendScheduler ? sendScheduler : void 0;
|
|
2540
2559
|
const sendThrottler2 = !sendScheduler ? common.buildSendThrottler(1) : "sendRate" in sendScheduler ? common.buildSendThrottler(sendScheduler.sendRate ?? 1, sendScheduler.sendInterval) : sendScheduler;
|
|
2541
2560
|
this.schedulingParams = {
|
|
@@ -2576,7 +2595,7 @@ var SolanaStreamClient = class {
|
|
|
2576
2595
|
const { partner, amount, tokenProgramId } = data;
|
|
2577
2596
|
const { isNative, sender, customInstructions } = extParams;
|
|
2578
2597
|
common.assertHasPublicKey(sender, "Sender's PublicKey is not available, check passed wallet adapter!");
|
|
2579
|
-
const partnerPublicKey = partner ? new web3_js.PublicKey(partner) :
|
|
2598
|
+
const partnerPublicKey = partner ? new web3_js.PublicKey(partner) : sender.publicKey;
|
|
2580
2599
|
const mintPublicKey = new web3_js.PublicKey(data.tokenId);
|
|
2581
2600
|
const ixs = await this.getCreateATAInstructions(
|
|
2582
2601
|
[partnerPublicKey],
|
|
@@ -2712,7 +2731,7 @@ var SolanaStreamClient = class {
|
|
|
2712
2731
|
if (!tokenProgramId) {
|
|
2713
2732
|
tokenProgramId = (await common.getMintAndProgram(this.connection, mintPublicKey)).tokenProgramId;
|
|
2714
2733
|
}
|
|
2715
|
-
const partnerPublicKey = partner ? new web3_js.PublicKey(partner) :
|
|
2734
|
+
const partnerPublicKey = partner ? new web3_js.PublicKey(partner) : sender.publicKey;
|
|
2716
2735
|
const streamflowProgramPublicKey = new web3_js.PublicKey(this.programId);
|
|
2717
2736
|
const escrowPDA = deriveEscrowPDA(streamflowProgramPublicKey, metadataPubKey);
|
|
2718
2737
|
const oracle = priceOracle ?? deriveTestOraclePDA(this.alignedProxyProgram.programId, mintPublicKey, sender.publicKey);
|
|
@@ -2759,7 +2778,7 @@ var SolanaStreamClient = class {
|
|
|
2759
2778
|
partner: partnerPublicKey,
|
|
2760
2779
|
recipient: recipientPublicKey,
|
|
2761
2780
|
withdrawor: WITHDRAWOR_PUBLIC_KEY,
|
|
2762
|
-
feeOracle:
|
|
2781
|
+
feeOracle: this.feeOraclePublicKey,
|
|
2763
2782
|
priceOracle: oracle,
|
|
2764
2783
|
tokenProgram: tokenProgramId,
|
|
2765
2784
|
streamflowProgram: this.programId
|
|
@@ -2815,7 +2834,7 @@ var SolanaStreamClient = class {
|
|
|
2815
2834
|
const senderTokens = await common.ata(mintPublicKey, sender.publicKey, tokenProgramId);
|
|
2816
2835
|
const recipientTokens = await common.ata(mintPublicKey, recipientPublicKey, tokenProgramId);
|
|
2817
2836
|
const streamflowTreasuryTokens = await common.ata(mintPublicKey, STREAMFLOW_TREASURY_PUBLIC_KEY, tokenProgramId);
|
|
2818
|
-
const partnerPublicKey = partner ? new web3_js.PublicKey(partner) :
|
|
2837
|
+
const partnerPublicKey = partner ? new web3_js.PublicKey(partner) : sender.publicKey;
|
|
2819
2838
|
const partnerTokens = await common.ata(mintPublicKey, partnerPublicKey, tokenProgramId);
|
|
2820
2839
|
ixs.push(
|
|
2821
2840
|
await createStreamInstruction(
|
|
@@ -2850,7 +2869,7 @@ var SolanaStreamClient = class {
|
|
|
2850
2869
|
partner: partnerPublicKey,
|
|
2851
2870
|
partnerTokens,
|
|
2852
2871
|
mint: new web3_js.PublicKey(mint),
|
|
2853
|
-
feeOracle:
|
|
2872
|
+
feeOracle: this.feeOraclePublicKey,
|
|
2854
2873
|
rent: web3_js.SYSVAR_RENT_PUBKEY,
|
|
2855
2874
|
timelockProgram: this.programId,
|
|
2856
2875
|
tokenProgram: tokenProgramId,
|
|
@@ -2939,7 +2958,7 @@ var SolanaStreamClient = class {
|
|
|
2939
2958
|
);
|
|
2940
2959
|
const { tokenProgramId } = await common.getMintAndProgram(this.connection, mintPublicKey);
|
|
2941
2960
|
const senderTokens = await common.ata(mintPublicKey, sender.publicKey, tokenProgramId);
|
|
2942
|
-
const partnerPublicKey = partner ? new web3_js.PublicKey(partner) :
|
|
2961
|
+
const partnerPublicKey = partner ? new web3_js.PublicKey(partner) : sender.publicKey;
|
|
2943
2962
|
const ixs = common.prepareBaseInstructions(this.connection, {
|
|
2944
2963
|
computePrice,
|
|
2945
2964
|
computeLimit
|
|
@@ -2977,7 +2996,7 @@ var SolanaStreamClient = class {
|
|
|
2977
2996
|
metadata: metadataPubKey,
|
|
2978
2997
|
escrowTokens,
|
|
2979
2998
|
mint: new web3_js.PublicKey(mint),
|
|
2980
|
-
feeOracle:
|
|
2999
|
+
feeOracle: this.feeOraclePublicKey,
|
|
2981
3000
|
rent: web3_js.SYSVAR_RENT_PUBKEY,
|
|
2982
3001
|
timelockProgram: this.programId,
|
|
2983
3002
|
tokenProgram: tokenProgramId,
|
|
@@ -2995,15 +3014,14 @@ var SolanaStreamClient = class {
|
|
|
2995
3014
|
* @param {IPrepareCreateStreamExt} extParams - Transaction configuration including sender public key, native token handling, and custom instructions
|
|
2996
3015
|
* @returns Create multiple transaction instructions
|
|
2997
3016
|
*/
|
|
2998
|
-
async buildCreateMultipleTransactionInstructions(data, extParams) {
|
|
3017
|
+
async buildCreateMultipleTransactionInstructions(data, extParams, applyCustomAfterInstructions = true) {
|
|
2999
3018
|
const { recipients, ...streamParams } = data;
|
|
3000
3019
|
const { sender, metadataPubKeys: metadataPubKeysExt, isNative, customInstructions } = extParams;
|
|
3001
3020
|
common.assertHasPublicKey(sender, "Sender's PublicKey is not available, check passed wallet adapter!");
|
|
3002
3021
|
const metadatas = [];
|
|
3003
3022
|
const metadataToRecipient = {};
|
|
3004
3023
|
const instructionsBatch = [];
|
|
3005
|
-
const
|
|
3006
|
-
const partnerPublicKey = data.partner ? new web3_js.PublicKey(data.partner) : WITHDRAWOR_PUBLIC_KEY;
|
|
3024
|
+
const partnerPublicKey = data.partner ? new web3_js.PublicKey(data.partner) : sender.publicKey;
|
|
3007
3025
|
const mintPublicKey = new web3_js.PublicKey(data.tokenId);
|
|
3008
3026
|
if (recipients.length === 0) {
|
|
3009
3027
|
throw new Error("Recipients array is empty!");
|
|
@@ -3012,14 +3030,16 @@ var SolanaStreamClient = class {
|
|
|
3012
3030
|
const recipientData = recipients[i];
|
|
3013
3031
|
const createStreamData = { ...streamParams, ...recipientData };
|
|
3014
3032
|
const createStreamExtParams = {
|
|
3015
|
-
|
|
3016
|
-
|
|
3033
|
+
...extParams,
|
|
3034
|
+
metadataPubKeys: metadataPubKeysExt?.[i] ? [metadataPubKeysExt[i]] : void 0
|
|
3017
3035
|
};
|
|
3018
3036
|
const { ixs, metadata, metadataPubKey } = await this.prepareCreateInstructions(
|
|
3019
3037
|
createStreamData,
|
|
3020
3038
|
createStreamExtParams
|
|
3021
3039
|
);
|
|
3022
|
-
|
|
3040
|
+
if (applyCustomAfterInstructions) {
|
|
3041
|
+
await this.applyCustomAfterInstructions(ixs, customInstructions, metadataPubKey);
|
|
3042
|
+
}
|
|
3023
3043
|
metadataToRecipient[metadataPubKey.toBase58()] = recipientData;
|
|
3024
3044
|
metadatas.push(metadataPubKey.toBase58());
|
|
3025
3045
|
instructionsBatch.push({
|
|
@@ -3067,9 +3087,9 @@ var SolanaStreamClient = class {
|
|
|
3067
3087
|
* @param {IPrepareCreateStreamExt} extParams - Transaction configuration including sender public key, native token handling, and custom instructions
|
|
3068
3088
|
* @returns Multiple transaction information
|
|
3069
3089
|
*/
|
|
3070
|
-
async buildCreateMultipleTransactions(data, extParams) {
|
|
3090
|
+
async buildCreateMultipleTransactions(data, extParams, applyCustomAfterInstructions = true) {
|
|
3071
3091
|
const { sender } = extParams;
|
|
3072
|
-
const { instructionsBatch, metadatas, metadataToRecipient, prepareInstructions } = await this.buildCreateMultipleTransactionInstructions(data, extParams);
|
|
3092
|
+
const { instructionsBatch, metadatas, metadataToRecipient, prepareInstructions } = await this.buildCreateMultipleTransactionInstructions(data, extParams, applyCustomAfterInstructions);
|
|
3073
3093
|
const { value: hash, context } = await this.connection.getLatestBlockhashAndContext();
|
|
3074
3094
|
const batch = [];
|
|
3075
3095
|
for (const { ixs, metadata, recipient } of instructionsBatch) {
|
|
@@ -3100,7 +3120,7 @@ var SolanaStreamClient = class {
|
|
|
3100
3120
|
if (!sender.publicKey) {
|
|
3101
3121
|
throw new Error("Sender's PublicKey is not available, check passed wallet adapter!");
|
|
3102
3122
|
}
|
|
3103
|
-
const { instructionsBatch, metadatas,
|
|
3123
|
+
const { instructionsBatch, metadatas, prepareInstructions, metadataToRecipient } = await this.flatBuildCreateMultipleTransactionInstructions(data, extParams);
|
|
3104
3124
|
const errors = [];
|
|
3105
3125
|
const signatures = [];
|
|
3106
3126
|
const metadataPubKeys = metadataPubKeysExt || [];
|
|
@@ -3165,7 +3185,7 @@ var SolanaStreamClient = class {
|
|
|
3165
3185
|
if (!sender.publicKey) {
|
|
3166
3186
|
throw new Error("Sender's PublicKey is not available, check passed wallet adapter!");
|
|
3167
3187
|
}
|
|
3168
|
-
const { instructionsBatch, metadatas,
|
|
3188
|
+
const { instructionsBatch, metadatas, prepareInstructions, metadataToRecipient } = await this.flatBuildCreateMultipleTransactionInstructions(data, extParams);
|
|
3169
3189
|
const errors = [];
|
|
3170
3190
|
const signatures = [];
|
|
3171
3191
|
const batch = [];
|
|
@@ -3679,20 +3699,41 @@ var SolanaStreamClient = class {
|
|
|
3679
3699
|
const accounts = await this.connection.getProgramAccounts(this.programId, {
|
|
3680
3700
|
filters
|
|
3681
3701
|
});
|
|
3682
|
-
const
|
|
3683
|
-
|
|
3684
|
-
|
|
3685
|
-
|
|
3686
|
-
|
|
3687
|
-
|
|
3688
|
-
|
|
3689
|
-
|
|
3690
|
-
|
|
3691
|
-
|
|
3692
|
-
|
|
3693
|
-
|
|
3694
|
-
|
|
3695
|
-
|
|
3702
|
+
const decoded = this.decodeStreamsFromAccounts(accounts);
|
|
3703
|
+
const alignedEntries = this.collectAlignedEntries(decoded);
|
|
3704
|
+
const alignedProxies = await this.fetchAlignedProxiesByEntries(alignedEntries);
|
|
3705
|
+
return this.mapDecodedToProgramAccounts(decoded, alignedEntries, alignedProxies);
|
|
3706
|
+
}
|
|
3707
|
+
decodeStreamsFromAccounts(accounts) {
|
|
3708
|
+
return accounts.map(({ pubkey, account }) => ({
|
|
3709
|
+
pubkey,
|
|
3710
|
+
stream: decodeStream(account.data)
|
|
3711
|
+
}));
|
|
3712
|
+
}
|
|
3713
|
+
collectAlignedEntries(decoded) {
|
|
3714
|
+
const entries = [];
|
|
3715
|
+
decoded.forEach(({ pubkey, stream }, index) => {
|
|
3716
|
+
if (this.isAlignedUnlock(pubkey, stream.sender)) {
|
|
3717
|
+
entries.push({ index, pda: deriveContractPDA(this.alignedProxyProgram.programId, pubkey) });
|
|
3718
|
+
}
|
|
3719
|
+
});
|
|
3720
|
+
return entries;
|
|
3721
|
+
}
|
|
3722
|
+
async fetchAlignedProxiesByEntries(aligned) {
|
|
3723
|
+
if (aligned.length === 0) return [];
|
|
3724
|
+
const res = await this.alignedProxyProgram.account.contract.fetchMultiple(aligned.map((a) => a.pda));
|
|
3725
|
+
return res;
|
|
3726
|
+
}
|
|
3727
|
+
mapDecodedToProgramAccounts(decoded, alignedEntries, alignedProxies) {
|
|
3728
|
+
return decoded.map(({ pubkey, stream }, idx) => {
|
|
3729
|
+
const alignedIdx = alignedEntries.findIndex((a) => a.index === idx);
|
|
3730
|
+
if (alignedIdx !== -1) {
|
|
3731
|
+
const alignedProxy = alignedProxies[alignedIdx];
|
|
3732
|
+
common.invariant(alignedProxy, "Couldn't get aligned proxy account info");
|
|
3733
|
+
return { publicKey: pubkey, account: new AlignedContract(stream, alignedProxy) };
|
|
3734
|
+
}
|
|
3735
|
+
return { publicKey: pubkey, account: new Contract(stream) };
|
|
3736
|
+
});
|
|
3696
3737
|
}
|
|
3697
3738
|
/**
|
|
3698
3739
|
* Attempts updating the stream auto withdrawal params and amount per period
|
|
@@ -3762,35 +3803,47 @@ var SolanaStreamClient = class {
|
|
|
3762
3803
|
* @returns Fees
|
|
3763
3804
|
*/
|
|
3764
3805
|
async getFees({ address }) {
|
|
3765
|
-
const
|
|
3766
|
-
[buffer.Buffer.from(FEES_METADATA_SEED)],
|
|
3767
|
-
new web3_js.PublicKey(PARTNER_ORACLE_PROGRAM_ID)
|
|
3768
|
-
);
|
|
3769
|
-
const data = await this.connection.getAccountInfo(metadataPubKey);
|
|
3806
|
+
const data = await this.connection.getAccountInfo(this.feeOraclePublicKey);
|
|
3770
3807
|
if (!data) {
|
|
3771
3808
|
return null;
|
|
3772
3809
|
}
|
|
3773
3810
|
const partners = borsh__namespace.deserialize(PARTNERS_SCHEMA, data.data);
|
|
3774
|
-
const
|
|
3775
|
-
|
|
3776
|
-
|
|
3811
|
+
for (const partner of partners) {
|
|
3812
|
+
const partnerAddress = new web3_js.PublicKey(partner.pubkey).toString();
|
|
3813
|
+
if (partnerAddress === address) {
|
|
3814
|
+
return {
|
|
3815
|
+
creationFeeSol: Number(partner.creation_fee),
|
|
3816
|
+
autoClaimFeeSol: Number(partner.auto_claim_fee),
|
|
3817
|
+
streamflowFee: Number(partner.token_fee_percent.toFixed(4)),
|
|
3818
|
+
partnerFee: 0
|
|
3819
|
+
};
|
|
3820
|
+
}
|
|
3777
3821
|
}
|
|
3778
|
-
return
|
|
3779
|
-
streamflowFee: Number(filteredPartners[0].strm_fee.toFixed(4)),
|
|
3780
|
-
partnerFee: Number(filteredPartners[0].partner_fee.toFixed(4))
|
|
3781
|
-
};
|
|
3822
|
+
return null;
|
|
3782
3823
|
}
|
|
3783
3824
|
/**
|
|
3784
3825
|
* Gets default streamflow fee
|
|
3785
3826
|
* @returns Default streamflow fee
|
|
3786
3827
|
*/
|
|
3787
3828
|
async getDefaultStreamflowFee() {
|
|
3788
|
-
return
|
|
3829
|
+
return (await this.getDefaultFees()).streamflowFee;
|
|
3830
|
+
}
|
|
3831
|
+
/**
|
|
3832
|
+
* Get all defaults fees applied by the protocol.
|
|
3833
|
+
*
|
|
3834
|
+
* Protocol will use fees set for WITHDRAWOR as default if they are set.
|
|
3835
|
+
*/
|
|
3836
|
+
async getDefaultFees() {
|
|
3837
|
+
return await this.getFees({ address: WITHDRAWOR }) || {
|
|
3838
|
+
creationFeeSol: DEFAULT_CREATION_FEE_SOL,
|
|
3839
|
+
autoClaimFeeSol: DEFAULT_AUTO_CLAIM_FEE_SOL,
|
|
3840
|
+
streamflowFee: DEFAULT_STREAMFLOW_FEE,
|
|
3841
|
+
partnerFee: 0
|
|
3842
|
+
};
|
|
3789
3843
|
}
|
|
3790
3844
|
/**
|
|
3791
3845
|
* Returns total fee percent, streamflow fees + partner fees
|
|
3792
3846
|
* @param getFeesData structure with address for which we need to derive fee, either sender or partner usually
|
|
3793
|
-
* @param chainSpecificParams additional parameters required by chain client
|
|
3794
3847
|
* @returns fee as floating number, so if fee is 0.99%, it will return 0.99
|
|
3795
3848
|
*/
|
|
3796
3849
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
@@ -3817,6 +3870,21 @@ var SolanaStreamClient = class {
|
|
|
3817
3870
|
const pda = deriveContractPDA(this.alignedProxyProgram.programId, streamPublicKey);
|
|
3818
3871
|
return senderPublicKey.equals(pda);
|
|
3819
3872
|
}
|
|
3873
|
+
async flatBuildCreateMultipleTransactionInstructions(data, extParams) {
|
|
3874
|
+
const dataArray = Array.isArray(data) ? data : [data];
|
|
3875
|
+
const results = await Promise.all(
|
|
3876
|
+
dataArray.map((item, index) => this.buildCreateMultipleTransactionInstructions(item, extParams, index === 0))
|
|
3877
|
+
);
|
|
3878
|
+
return {
|
|
3879
|
+
instructionsBatch: results.flatMap((r) => r.instructionsBatch),
|
|
3880
|
+
metadatas: results.flatMap((r) => r.metadatas),
|
|
3881
|
+
prepareInstructions: results.flatMap((r) => r.prepareInstructions),
|
|
3882
|
+
metadataToRecipient: results.reduce(
|
|
3883
|
+
(acc, r) => Object.assign(acc, r.metadataToRecipient),
|
|
3884
|
+
{}
|
|
3885
|
+
)
|
|
3886
|
+
};
|
|
3887
|
+
}
|
|
3820
3888
|
/**
|
|
3821
3889
|
* Utility function to generate metadata for a Contract or return existing Pubkey
|
|
3822
3890
|
*/
|
|
@@ -4304,6 +4372,8 @@ exports.CONTRACT_SEED = CONTRACT_SEED;
|
|
|
4304
4372
|
exports.CREATE_PARAMS_PADDING = CREATE_PARAMS_PADDING;
|
|
4305
4373
|
exports.Contract = Contract;
|
|
4306
4374
|
exports.ContractErrorCode = ContractErrorCode;
|
|
4375
|
+
exports.DEFAULT_AUTO_CLAIM_FEE_SOL = DEFAULT_AUTO_CLAIM_FEE_SOL;
|
|
4376
|
+
exports.DEFAULT_CREATION_FEE_SOL = DEFAULT_CREATION_FEE_SOL;
|
|
4307
4377
|
exports.DEFAULT_STREAMFLOW_FEE = DEFAULT_STREAMFLOW_FEE;
|
|
4308
4378
|
exports.ESCROW_SEED = ESCROW_SEED;
|
|
4309
4379
|
exports.FEES_METADATA_SEED = FEES_METADATA_SEED;
|
|
@@ -4328,6 +4398,7 @@ exports.StreamType = StreamType;
|
|
|
4328
4398
|
exports.TEST_ORACLE_DISCRIMINATOR = TEST_ORACLE_DISCRIMINATOR;
|
|
4329
4399
|
exports.TEST_ORACLE_SEED = TEST_ORACLE_SEED;
|
|
4330
4400
|
exports.TX_FINALITY_CONFIRMED = TX_FINALITY_CONFIRMED;
|
|
4401
|
+
exports.WITHDRAWOR = WITHDRAWOR;
|
|
4331
4402
|
exports.WITHDRAWOR_PUBLIC_KEY = WITHDRAWOR_PUBLIC_KEY;
|
|
4332
4403
|
exports.WITHDRAW_AVAILABLE_AMOUNT = WITHDRAW_AVAILABLE_AMOUNT;
|
|
4333
4404
|
exports.buildStreamType = buildStreamType;
|