@streamflow/stream 11.0.0 → 11.0.2
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/dist/cjs/index.cjs +70 -29
- package/dist/cjs/index.cjs.map +1 -1
- package/dist/cjs/index.d.cts +1 -1
- package/dist/cjs/solana/index.cjs +70 -29
- package/dist/cjs/solana/index.cjs.map +1 -1
- package/dist/cjs/solana/index.d.cts +19 -5
- package/dist/esm/index.d.ts +1 -1
- package/dist/esm/index.js +70 -31
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/solana/index.d.ts +19 -5
- package/dist/esm/solana/index.js +70 -31
- 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_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';
|
|
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';
|
|
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) {
|
|
145
|
+
constructor(stream, metadata) {
|
|
146
146
|
this.magic = stream.magic.toNumber();
|
|
147
147
|
this.version = stream.version.toNumber();
|
|
148
148
|
this.createdAt = stream.createdAt.toNumber();
|
|
@@ -185,6 +185,8 @@ var Contract = class {
|
|
|
185
185
|
this.pauseCumulative = stream.pauseCumulative;
|
|
186
186
|
this.lastRateChangeTime = stream.lastRateChangeTime.toNumber();
|
|
187
187
|
this.fundsUnlockedAtLastRateChange = stream.fundsUnlockedAtLastRateChange;
|
|
188
|
+
this.oldMetadata = stream.oldMetadata;
|
|
189
|
+
this.metadata = metadata;
|
|
188
190
|
this.type = buildStreamType(this);
|
|
189
191
|
this.isAligned = false;
|
|
190
192
|
}
|
|
@@ -199,8 +201,8 @@ var Contract = class {
|
|
|
199
201
|
}
|
|
200
202
|
};
|
|
201
203
|
var AlignedContract = class extends Contract {
|
|
202
|
-
constructor(stream, alignedProxy) {
|
|
203
|
-
super(stream);
|
|
204
|
+
constructor(stream, metadata, alignedProxy) {
|
|
205
|
+
super(stream, metadata);
|
|
204
206
|
this.minPrice = common.getNumberFromBN(alignedProxy.minPrice, ALIGNED_PRECISION_FACTOR_POW);
|
|
205
207
|
this.maxPrice = common.getNumberFromBN(alignedProxy.maxPrice, ALIGNED_PRECISION_FACTOR_POW);
|
|
206
208
|
this.minPercentage = common.getNumberFromBN(alignedProxy.minPercentage, ALIGNED_PRECISION_FACTOR_POW);
|
|
@@ -229,6 +231,7 @@ var STREAM_STRUCT_OFFSET_SENDER = 49;
|
|
|
229
231
|
var STREAM_STRUCT_OFFSET_RECIPIENT = 113;
|
|
230
232
|
var STREAM_STRUCT_OFFSET_MINT = 177;
|
|
231
233
|
var STREAM_STRUCT_OFFSET_CLOSED = 671;
|
|
234
|
+
var STREAM_STRUCT_OFFSET_OLD_METADATA_KEY = 714;
|
|
232
235
|
var MAX_SAFE_UNIX_TIME_VALUE2 = 864e10;
|
|
233
236
|
var WITHDRAW_AVAILABLE_AMOUNT = new BN3__default.default("18446744073709551615");
|
|
234
237
|
var ALIGNED_PRECISION_FACTOR_POW2 = 9;
|
|
@@ -377,7 +380,12 @@ var streamLayout = BufferLayout__namespace.struct([
|
|
|
377
380
|
BufferLayout__namespace.blob(8, "current_pause_start"),
|
|
378
381
|
BufferLayout__namespace.blob(8, "pause_cumulative"),
|
|
379
382
|
BufferLayout__namespace.blob(8, "last_rate_change_time"),
|
|
380
|
-
BufferLayout__namespace.blob(8, "funds_unlocked_at_last_rate_change")
|
|
383
|
+
BufferLayout__namespace.blob(8, "funds_unlocked_at_last_rate_change"),
|
|
384
|
+
BufferLayout__namespace.u32("creation_fee"),
|
|
385
|
+
BufferLayout__namespace.u8("creation_fee_claimed"),
|
|
386
|
+
BufferLayout__namespace.u32("auto_claim_fee"),
|
|
387
|
+
BufferLayout__namespace.u8("auto_claim_fee_claimed"),
|
|
388
|
+
BufferLayout__namespace.blob(32, "old_metadata")
|
|
381
389
|
]);
|
|
382
390
|
BufferLayout__namespace.struct([
|
|
383
391
|
BufferLayout__namespace.blob(32, "pubkey"),
|
|
@@ -488,6 +496,12 @@ var encodeUpdateStream = (values, data) => {
|
|
|
488
496
|
var topupStreamLayout = BufferLayout__namespace.struct([
|
|
489
497
|
BufferLayout__namespace.blob(8, "amount")
|
|
490
498
|
]);
|
|
499
|
+
var getOriginalMetadataKey = (streamPubkey, oldMetadata) => {
|
|
500
|
+
if (web3_js.PublicKey.default.equals(oldMetadata)) {
|
|
501
|
+
return streamPubkey;
|
|
502
|
+
}
|
|
503
|
+
return oldMetadata;
|
|
504
|
+
};
|
|
491
505
|
var FEE_PRECISION = 4;
|
|
492
506
|
var FEE_NORMALIZER = 10 ** FEE_PRECISION;
|
|
493
507
|
var FEE_MULTIPLIER = new BN3__default.default(10 ** 6);
|
|
@@ -541,7 +555,8 @@ var decodeStream = (buf) => {
|
|
|
541
555
|
currentPauseStart: new BN3__default.default(raw.current_pause_start, LE),
|
|
542
556
|
pauseCumulative: new BN3__default.default(raw.pause_cumulative, LE),
|
|
543
557
|
lastRateChangeTime: new BN3__default.default(raw.last_rate_change_time, LE),
|
|
544
|
-
fundsUnlockedAtLastRateChange: new BN3__default.default(raw.funds_unlocked_at_last_rate_change, LE)
|
|
558
|
+
fundsUnlockedAtLastRateChange: new BN3__default.default(raw.funds_unlocked_at_last_rate_change, LE),
|
|
559
|
+
oldMetadata: new web3_js.PublicKey(raw.old_metadata)
|
|
545
560
|
};
|
|
546
561
|
};
|
|
547
562
|
async function signAllTransactionWithRecipients(sender, items) {
|
|
@@ -3345,8 +3360,8 @@ var SolanaStreamClient = class {
|
|
|
3345
3360
|
if (!account) {
|
|
3346
3361
|
throw new Error("Impossible to cancel a stream contract that does not exist");
|
|
3347
3362
|
}
|
|
3348
|
-
const
|
|
3349
|
-
const isAlignedUnlock = this.isAlignedUnlock(streamPublicKey,
|
|
3363
|
+
const decoded = decodeStream(account.data);
|
|
3364
|
+
const isAlignedUnlock = this.isAlignedUnlock(streamPublicKey, decoded.sender, decoded.oldMetadata);
|
|
3350
3365
|
const ixs = isAlignedUnlock ? await this.prepareCancelAlignedUnlockInstructions(cancelData, extParams) : await this.prepareCancelLinearStream(cancelData, extParams);
|
|
3351
3366
|
return ixs;
|
|
3352
3367
|
}
|
|
@@ -3568,20 +3583,38 @@ var SolanaStreamClient = class {
|
|
|
3568
3583
|
async getOne({ id }) {
|
|
3569
3584
|
const streamPublicKey = new web3_js.PublicKey(id);
|
|
3570
3585
|
const escrow = await this.connection.getAccountInfo(streamPublicKey, TX_FINALITY_CONFIRMED);
|
|
3571
|
-
if (
|
|
3586
|
+
if (escrow?.data) {
|
|
3587
|
+
return this.decodeStreamAccount(streamPublicKey, escrow.data);
|
|
3588
|
+
}
|
|
3589
|
+
const migrated = await this.connection.getProgramAccounts(this.programId, {
|
|
3590
|
+
filters: [
|
|
3591
|
+
{ dataSize: METADATA_ACC_SIZE },
|
|
3592
|
+
{
|
|
3593
|
+
memcmp: {
|
|
3594
|
+
offset: STREAM_STRUCT_OFFSET_OLD_METADATA_KEY,
|
|
3595
|
+
bytes: id
|
|
3596
|
+
}
|
|
3597
|
+
}
|
|
3598
|
+
]
|
|
3599
|
+
});
|
|
3600
|
+
if (migrated.length === 0) {
|
|
3572
3601
|
throw new Error("Couldn't get account info.");
|
|
3573
3602
|
}
|
|
3574
|
-
|
|
3575
|
-
|
|
3603
|
+
return this.decodeStreamAccount(migrated[0].pubkey, migrated[0].account.data);
|
|
3604
|
+
}
|
|
3605
|
+
async decodeStreamAccount(pubkey, data) {
|
|
3606
|
+
const stream = decodeStream(data);
|
|
3607
|
+
const metadataKey = getOriginalMetadataKey(pubkey, stream.oldMetadata);
|
|
3608
|
+
if (this.isAlignedUnlock(pubkey, stream.sender, stream.oldMetadata)) {
|
|
3576
3609
|
const alignedProxy = await this.alignedProxyProgram.account.contract.fetch(
|
|
3577
|
-
deriveContractPDA(this.alignedProxyProgram.programId,
|
|
3610
|
+
deriveContractPDA(this.alignedProxyProgram.programId, metadataKey)
|
|
3578
3611
|
);
|
|
3579
3612
|
if (!alignedProxy) {
|
|
3580
3613
|
throw new Error("Couldn't get proxy account info.");
|
|
3581
3614
|
}
|
|
3582
|
-
return new AlignedContract(stream, alignedProxy);
|
|
3615
|
+
return new AlignedContract(stream, common.pk(pubkey), alignedProxy);
|
|
3583
3616
|
}
|
|
3584
|
-
return new Contract(stream);
|
|
3617
|
+
return new Contract(stream, common.pk(pubkey));
|
|
3585
3618
|
}
|
|
3586
3619
|
/**
|
|
3587
3620
|
* Fetch all aligned outgoing streams/contracts by the provided public key.
|
|
@@ -3606,7 +3639,7 @@ var SolanaStreamClient = class {
|
|
|
3606
3639
|
streamAccounts.forEach((account, index) => {
|
|
3607
3640
|
if (account) {
|
|
3608
3641
|
const alignedData = alignedOutgoingProgramAccounts[index].account;
|
|
3609
|
-
streams[streamPubKeys[index].toBase58()] = new AlignedContract(decodeStream(account.data), alignedData);
|
|
3642
|
+
streams[streamPubKeys[index].toBase58()] = new AlignedContract(decodeStream(account.data), common.pk(streamPubKeys[index]), alignedData);
|
|
3610
3643
|
}
|
|
3611
3644
|
});
|
|
3612
3645
|
return streams;
|
|
@@ -3614,15 +3647,18 @@ var SolanaStreamClient = class {
|
|
|
3614
3647
|
async getIncomingAlignedStreams(streamRecord) {
|
|
3615
3648
|
const streams = {};
|
|
3616
3649
|
const alignedStreamsPubKeys = Object.keys(streamRecord);
|
|
3617
|
-
const alignedProxyPDAs = alignedStreamsPubKeys.map(
|
|
3618
|
-
|
|
3619
|
-
|
|
3650
|
+
const alignedProxyPDAs = alignedStreamsPubKeys.map((streamPubKey) => {
|
|
3651
|
+
const pubkey = new web3_js.PublicKey(streamPubKey);
|
|
3652
|
+
const metadataKey = getOriginalMetadataKey(pubkey, streamRecord[streamPubKey].oldMetadata);
|
|
3653
|
+
return deriveContractPDA(this.alignedProxyProgram.programId, metadataKey);
|
|
3654
|
+
});
|
|
3620
3655
|
const alignedProxyAccounts = await common.getMultipleAccountsInfoBatched(this.connection, alignedProxyPDAs);
|
|
3621
3656
|
alignedProxyAccounts.forEach((account, index) => {
|
|
3622
3657
|
if (account && account.data.length === ALIGNED_METADATA_ACC_SIZE) {
|
|
3623
3658
|
const alignedData = streamRecord[alignedStreamsPubKeys[index]];
|
|
3624
3659
|
streams[alignedStreamsPubKeys[index]] = new AlignedContract(
|
|
3625
3660
|
alignedData,
|
|
3661
|
+
common.pk(alignedStreamsPubKeys[index]),
|
|
3626
3662
|
this.alignedProxyProgram.account.contract.coder.accounts.decode("contract", account.data)
|
|
3627
3663
|
);
|
|
3628
3664
|
}
|
|
@@ -3651,7 +3687,7 @@ var SolanaStreamClient = class {
|
|
|
3651
3687
|
this.programId
|
|
3652
3688
|
);
|
|
3653
3689
|
outgoingStreamAccounts.forEach((account) => {
|
|
3654
|
-
streams[account.pubkey.toBase58()] = new Contract(decodeStream(account.account.data));
|
|
3690
|
+
streams[account.pubkey.toBase58()] = new Contract(decodeStream(account.account.data), common.pk(account.pubkey));
|
|
3655
3691
|
});
|
|
3656
3692
|
if (shouldFetchAligned) {
|
|
3657
3693
|
const alignedStreams = await this.getOutgoingAlignedStreams(address);
|
|
@@ -3668,10 +3704,10 @@ var SolanaStreamClient = class {
|
|
|
3668
3704
|
const allIncomingStreams = allIncomingAccounts.map((account) => decodeStream(account.account.data));
|
|
3669
3705
|
const alignedDecoded = {};
|
|
3670
3706
|
allIncomingAccounts.forEach((account, index) => {
|
|
3671
|
-
if (this.isAlignedUnlock(account.pubkey, allIncomingStreams[index].sender)) {
|
|
3707
|
+
if (this.isAlignedUnlock(account.pubkey, allIncomingStreams[index].sender, allIncomingStreams[index].oldMetadata)) {
|
|
3672
3708
|
alignedDecoded[account.pubkey.toBase58()] = allIncomingStreams[index];
|
|
3673
3709
|
} else {
|
|
3674
|
-
streams[account.pubkey.toBase58()] = new Contract(allIncomingStreams[index]);
|
|
3710
|
+
streams[account.pubkey.toBase58()] = new Contract(allIncomingStreams[index], common.pk(account.pubkey));
|
|
3675
3711
|
}
|
|
3676
3712
|
});
|
|
3677
3713
|
if (shouldFetchAligned) {
|
|
@@ -3713,8 +3749,9 @@ var SolanaStreamClient = class {
|
|
|
3713
3749
|
collectAlignedEntries(decoded) {
|
|
3714
3750
|
const entries = [];
|
|
3715
3751
|
decoded.forEach(({ pubkey, stream }, index) => {
|
|
3716
|
-
if (this.isAlignedUnlock(pubkey, stream.sender)) {
|
|
3717
|
-
|
|
3752
|
+
if (this.isAlignedUnlock(pubkey, stream.sender, stream.oldMetadata)) {
|
|
3753
|
+
const metadataKey = getOriginalMetadataKey(pubkey, stream.oldMetadata);
|
|
3754
|
+
entries.push({ index, pda: deriveContractPDA(this.alignedProxyProgram.programId, metadataKey) });
|
|
3718
3755
|
}
|
|
3719
3756
|
});
|
|
3720
3757
|
return entries;
|
|
@@ -3730,9 +3767,9 @@ var SolanaStreamClient = class {
|
|
|
3730
3767
|
if (alignedIdx !== -1) {
|
|
3731
3768
|
const alignedProxy = alignedProxies[alignedIdx];
|
|
3732
3769
|
common.invariant(alignedProxy, "Couldn't get aligned proxy account info");
|
|
3733
|
-
return { publicKey: pubkey, account: new AlignedContract(stream, alignedProxy) };
|
|
3770
|
+
return { publicKey: pubkey, account: new AlignedContract(stream, common.pk(pubkey), alignedProxy) };
|
|
3734
3771
|
}
|
|
3735
|
-
return { publicKey: pubkey, account: new Contract(stream) };
|
|
3772
|
+
return { publicKey: pubkey, account: new Contract(stream, common.pk(pubkey)) };
|
|
3736
3773
|
});
|
|
3737
3774
|
}
|
|
3738
3775
|
/**
|
|
@@ -3774,8 +3811,8 @@ var SolanaStreamClient = class {
|
|
|
3774
3811
|
const streamPublicKey = new web3_js.PublicKey(data.id);
|
|
3775
3812
|
const escrow = await this.connection.getAccountInfo(streamPublicKey);
|
|
3776
3813
|
common.invariant(escrow, "Couldn't get account info");
|
|
3777
|
-
const
|
|
3778
|
-
const isAlignedUnlock = this.isAlignedUnlock(streamPublicKey,
|
|
3814
|
+
const decoded = decodeStream(escrow.data);
|
|
3815
|
+
const isAlignedUnlock = this.isAlignedUnlock(streamPublicKey, decoded.sender, decoded.oldMetadata);
|
|
3779
3816
|
if (isAlignedUnlock && (data.enableAutomaticWithdrawal !== void 0 || data.amountPerPeriod !== void 0)) {
|
|
3780
3817
|
throw new Error("Automatic withdrawal and rate update are not possible in price-based vesting!");
|
|
3781
3818
|
}
|
|
@@ -3866,10 +3903,12 @@ var SolanaStreamClient = class {
|
|
|
3866
3903
|
return extractSolanaErrorCode(err.toString() ?? "Unknown error!", logs);
|
|
3867
3904
|
}
|
|
3868
3905
|
/**
|
|
3869
|
-
* Utility function that checks whether the associated stream address is an aligned unlock contract, indicated by whether the sender/creator is a PDA
|
|
3906
|
+
* Utility function that checks whether the associated stream address is an aligned unlock contract, indicated by whether the sender/creator is a PDA.
|
|
3907
|
+
* For migrated streams, the PDA was derived from the old metadata key.
|
|
3870
3908
|
*/
|
|
3871
|
-
isAlignedUnlock(streamPublicKey, senderPublicKey) {
|
|
3872
|
-
const
|
|
3909
|
+
isAlignedUnlock(streamPublicKey, senderPublicKey, oldMetadata) {
|
|
3910
|
+
const metadataKey = oldMetadata ? getOriginalMetadataKey(streamPublicKey, oldMetadata) : streamPublicKey;
|
|
3911
|
+
const pda = deriveContractPDA(this.alignedProxyProgram.programId, metadataKey);
|
|
3873
3912
|
return senderPublicKey.equals(pda);
|
|
3874
3913
|
}
|
|
3875
3914
|
async flatBuildCreateMultipleTransactionInstructions(data, extParams) {
|
|
@@ -4392,6 +4431,7 @@ exports.STREAMFLOW_TREASURY_PUBLIC_KEY = STREAMFLOW_TREASURY_PUBLIC_KEY;
|
|
|
4392
4431
|
exports.STREAM_STRUCT_OFFSETS = STREAM_STRUCT_OFFSETS;
|
|
4393
4432
|
exports.STREAM_STRUCT_OFFSET_CLOSED = STREAM_STRUCT_OFFSET_CLOSED;
|
|
4394
4433
|
exports.STREAM_STRUCT_OFFSET_MINT = STREAM_STRUCT_OFFSET_MINT;
|
|
4434
|
+
exports.STREAM_STRUCT_OFFSET_OLD_METADATA_KEY = STREAM_STRUCT_OFFSET_OLD_METADATA_KEY;
|
|
4395
4435
|
exports.STREAM_STRUCT_OFFSET_RECIPIENT = STREAM_STRUCT_OFFSET_RECIPIENT;
|
|
4396
4436
|
exports.STREAM_STRUCT_OFFSET_SENDER = STREAM_STRUCT_OFFSET_SENDER;
|
|
4397
4437
|
exports.SolanaStreamClient = SolanaStreamClient;
|
|
@@ -4415,6 +4455,7 @@ exports.deriveContractPDA = deriveContractPDA;
|
|
|
4415
4455
|
exports.deriveEscrowPDA = deriveEscrowPDA;
|
|
4416
4456
|
exports.deriveTestOraclePDA = deriveTestOraclePDA;
|
|
4417
4457
|
exports.extractSolanaErrorCode = extractSolanaErrorCode;
|
|
4458
|
+
exports.getOriginalMetadataKey = getOriginalMetadataKey;
|
|
4418
4459
|
exports.handleContractError = handleContractError;
|
|
4419
4460
|
exports.isAligned = isAligned;
|
|
4420
4461
|
exports.isCliffCloseToDepositedAmount = isCliffCloseToDepositedAmount;
|