@streamflow/stream 10.0.0-alpha.p313.4470e29 → 10.0.0-alpha.p313.e531e2c
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 +2 -2
- package/dist/cjs/index.cjs +132 -27
- package/dist/cjs/index.cjs.map +1 -1
- package/dist/cjs/index.d.cts +1 -1
- package/dist/cjs/solana/descriptor/streamflow_aligned_unlocks.d.cts +101 -1
- package/dist/cjs/solana/index.cjs +132 -27
- package/dist/cjs/solana/index.cjs.map +1 -1
- package/dist/cjs/solana/index.d.cts +8 -3
- package/dist/esm/index.d.ts +1 -1
- package/dist/esm/index.js +132 -28
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/solana/descriptor/idl/streamflow_aligned_unlocks.json +101 -1
- package/dist/esm/solana/descriptor/streamflow_aligned_unlocks.d.ts +101 -1
- package/dist/esm/solana/index.d.ts +8 -3
- package/dist/esm/solana/index.js +132 -28
- 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_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, isPayment, 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';
|
|
@@ -8,7 +8,7 @@ type StreamflowAlignedUnlocks = {
|
|
|
8
8
|
"address": "aSTRM2NKoKxNnkmLWk9sz3k74gKBk9t7bpPrTGxMszH";
|
|
9
9
|
"metadata": {
|
|
10
10
|
"name": "streamflowAlignedUnlocks";
|
|
11
|
-
"version": "1.
|
|
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": {
|
|
@@ -59,8 +59,11 @@ var calculateUnlockedAmount = ({
|
|
|
59
59
|
var isCliffCloseToDepositedAmount = (streamData) => {
|
|
60
60
|
return streamData.cliffAmount.gte(streamData.depositedAmount.sub(new BN3__default.default(1)));
|
|
61
61
|
};
|
|
62
|
+
var isPayment = (streamData) => {
|
|
63
|
+
return streamData.canTopup;
|
|
64
|
+
};
|
|
62
65
|
var isVesting = (streamData) => {
|
|
63
|
-
return !isCliffCloseToDepositedAmount(streamData) && !isDynamicLock(streamData.minPrice, streamData.maxPrice, streamData.minPercentage, streamData.maxPercentage);
|
|
66
|
+
return !streamData.canTopup && !isCliffCloseToDepositedAmount(streamData) && !isDynamicLock(streamData.minPrice, streamData.maxPrice, streamData.minPercentage, streamData.maxPercentage);
|
|
64
67
|
};
|
|
65
68
|
var isAligned = (stream) => {
|
|
66
69
|
return "minPrice" in stream && "maxPrice" in stream && "minPercentage" in stream && "maxPercentage" in stream;
|
|
@@ -75,10 +78,13 @@ var isTokenLock = (streamData) => {
|
|
|
75
78
|
return !streamData.canTopup && !streamData.automaticWithdrawal && !streamData.cancelableBySender && !streamData.cancelableByRecipient && !streamData.transferableBySender && (isCliffCloseToDepositedAmount(streamData) || isDynamicLock(streamData.minPrice, streamData.maxPrice, streamData.minPercentage, streamData.maxPercentage));
|
|
76
79
|
};
|
|
77
80
|
var buildStreamType = (streamData) => {
|
|
81
|
+
if (isVesting(streamData)) {
|
|
82
|
+
return "vesting" /* Vesting */;
|
|
83
|
+
}
|
|
78
84
|
if (isTokenLock(streamData)) {
|
|
79
85
|
return "lock" /* Lock */;
|
|
80
86
|
}
|
|
81
|
-
return "
|
|
87
|
+
return "payment" /* Payment */;
|
|
82
88
|
};
|
|
83
89
|
var decodeEndTime = (endTime) => {
|
|
84
90
|
if (endTime.gt(new BN3__default.default(MAX_SAFE_UNIX_TIME_VALUE))) {
|
|
@@ -95,6 +101,7 @@ var StreamDirection = /* @__PURE__ */ ((StreamDirection2) => {
|
|
|
95
101
|
})(StreamDirection || {});
|
|
96
102
|
var StreamType = /* @__PURE__ */ ((StreamType2) => {
|
|
97
103
|
StreamType2["All"] = "all";
|
|
104
|
+
StreamType2["Payment"] = "payment";
|
|
98
105
|
StreamType2["Vesting"] = "vesting";
|
|
99
106
|
StreamType2["Lock"] = "lock";
|
|
100
107
|
return StreamType2;
|
|
@@ -905,7 +912,7 @@ var streamflow_aligned_unlocks_default = {
|
|
|
905
912
|
address: "aSTRM2NKoKxNnkmLWk9sz3k74gKBk9t7bpPrTGxMszH",
|
|
906
913
|
metadata: {
|
|
907
914
|
name: "streamflow_aligned_unlocks",
|
|
908
|
-
version: "1.
|
|
915
|
+
version: "1.4.0",
|
|
909
916
|
spec: "0.1.0",
|
|
910
917
|
description: "Proxy to update unlock amount within Streamflow vesting protocol according to Token performance and other metrics"
|
|
911
918
|
},
|
|
@@ -1779,6 +1786,80 @@ var streamflow_aligned_unlocks_default = {
|
|
|
1779
1786
|
],
|
|
1780
1787
|
args: []
|
|
1781
1788
|
},
|
|
1789
|
+
{
|
|
1790
|
+
name: "update_contract",
|
|
1791
|
+
discriminator: [
|
|
1792
|
+
78,
|
|
1793
|
+
184,
|
|
1794
|
+
162,
|
|
1795
|
+
174,
|
|
1796
|
+
233,
|
|
1797
|
+
5,
|
|
1798
|
+
40,
|
|
1799
|
+
82
|
|
1800
|
+
],
|
|
1801
|
+
accounts: [
|
|
1802
|
+
{
|
|
1803
|
+
name: "sender",
|
|
1804
|
+
writable: true,
|
|
1805
|
+
signer: true
|
|
1806
|
+
},
|
|
1807
|
+
{
|
|
1808
|
+
name: "proxy_metadata",
|
|
1809
|
+
docs: [
|
|
1810
|
+
"Proxy Contract"
|
|
1811
|
+
],
|
|
1812
|
+
writable: true,
|
|
1813
|
+
pda: {
|
|
1814
|
+
seeds: [
|
|
1815
|
+
{
|
|
1816
|
+
kind: "const",
|
|
1817
|
+
value: [
|
|
1818
|
+
99,
|
|
1819
|
+
111,
|
|
1820
|
+
110,
|
|
1821
|
+
116,
|
|
1822
|
+
114,
|
|
1823
|
+
97,
|
|
1824
|
+
99,
|
|
1825
|
+
116
|
|
1826
|
+
]
|
|
1827
|
+
},
|
|
1828
|
+
{
|
|
1829
|
+
kind: "account",
|
|
1830
|
+
path: "stream_metadata"
|
|
1831
|
+
}
|
|
1832
|
+
]
|
|
1833
|
+
}
|
|
1834
|
+
},
|
|
1835
|
+
{
|
|
1836
|
+
name: "stream_metadata",
|
|
1837
|
+
writable: true
|
|
1838
|
+
},
|
|
1839
|
+
{
|
|
1840
|
+
name: "withdrawor",
|
|
1841
|
+
writable: true
|
|
1842
|
+
},
|
|
1843
|
+
{
|
|
1844
|
+
name: "streamflow_program",
|
|
1845
|
+
address: "strmRqUCoQUgGUan5YhzUZa6KqdzwX5L6FpUxfmKg5m"
|
|
1846
|
+
},
|
|
1847
|
+
{
|
|
1848
|
+
name: "system_program",
|
|
1849
|
+
address: "11111111111111111111111111111111"
|
|
1850
|
+
}
|
|
1851
|
+
],
|
|
1852
|
+
args: [
|
|
1853
|
+
{
|
|
1854
|
+
name: "params",
|
|
1855
|
+
type: {
|
|
1856
|
+
defined: {
|
|
1857
|
+
name: "UpdateContractParams"
|
|
1858
|
+
}
|
|
1859
|
+
}
|
|
1860
|
+
}
|
|
1861
|
+
]
|
|
1862
|
+
},
|
|
1782
1863
|
{
|
|
1783
1864
|
name: "update_test_oracle",
|
|
1784
1865
|
discriminator: [
|
|
@@ -2374,6 +2455,32 @@ var streamflow_aligned_unlocks_default = {
|
|
|
2374
2455
|
]
|
|
2375
2456
|
}
|
|
2376
2457
|
},
|
|
2458
|
+
{
|
|
2459
|
+
name: "UpdateContractParams",
|
|
2460
|
+
type: {
|
|
2461
|
+
kind: "struct",
|
|
2462
|
+
fields: [
|
|
2463
|
+
{
|
|
2464
|
+
name: "transferable_by_sender",
|
|
2465
|
+
type: {
|
|
2466
|
+
option: "bool"
|
|
2467
|
+
}
|
|
2468
|
+
},
|
|
2469
|
+
{
|
|
2470
|
+
name: "transferable_by_recipient",
|
|
2471
|
+
type: {
|
|
2472
|
+
option: "bool"
|
|
2473
|
+
}
|
|
2474
|
+
},
|
|
2475
|
+
{
|
|
2476
|
+
name: "cancelable_by_sender",
|
|
2477
|
+
type: {
|
|
2478
|
+
option: "bool"
|
|
2479
|
+
}
|
|
2480
|
+
}
|
|
2481
|
+
]
|
|
2482
|
+
}
|
|
2483
|
+
},
|
|
2377
2484
|
{
|
|
2378
2485
|
name: "UpdateTestOracleParams",
|
|
2379
2486
|
type: {
|
|
@@ -2598,7 +2705,10 @@ var SolanaStreamClient = class {
|
|
|
2598
2705
|
floorPrice
|
|
2599
2706
|
} = streamParams;
|
|
2600
2707
|
const { isNative, sender, computeLimit, computePrice, metadataPubKeys } = extParams;
|
|
2601
|
-
common.invariant(
|
|
2708
|
+
common.invariant(
|
|
2709
|
+
priceOracle || !oracleType || oracleType === "none",
|
|
2710
|
+
"Price oracle is required for the specified oracle type"
|
|
2711
|
+
);
|
|
2602
2712
|
common.assertHasPublicKey(sender, "Sender's PublicKey is not available, check passed wallet adapter!");
|
|
2603
2713
|
const recipientPublicKey = new web3_js.PublicKey(recipient);
|
|
2604
2714
|
const mintPublicKey = isNative ? splToken.NATIVE_MINT : new web3_js.PublicKey(mint);
|
|
@@ -2773,10 +2883,7 @@ var SolanaStreamClient = class {
|
|
|
2773
2883
|
* @returns Create result
|
|
2774
2884
|
*/
|
|
2775
2885
|
async createUnchecked(data, extParams) {
|
|
2776
|
-
const { ixs, metadata, metadataPubKey } = await this.prepareCreateUncheckedInstructions(
|
|
2777
|
-
data,
|
|
2778
|
-
extParams
|
|
2779
|
-
);
|
|
2886
|
+
const { ixs, metadata, metadataPubKey } = await this.prepareCreateUncheckedInstructions(data, extParams);
|
|
2780
2887
|
const { tx, hash, context } = await common.prepareTransaction(
|
|
2781
2888
|
this.connection,
|
|
2782
2889
|
ixs,
|
|
@@ -2928,19 +3035,10 @@ var SolanaStreamClient = class {
|
|
|
2928
3035
|
recipient: recipientData.recipient
|
|
2929
3036
|
});
|
|
2930
3037
|
}
|
|
2931
|
-
const prepareInstructions = await this.getCreateATAInstructions(
|
|
2932
|
-
[partnerPublicKey],
|
|
2933
|
-
mintPublicKey,
|
|
2934
|
-
sender,
|
|
2935
|
-
true
|
|
2936
|
-
);
|
|
3038
|
+
const prepareInstructions = await this.getCreateATAInstructions([partnerPublicKey], mintPublicKey, sender, true);
|
|
2937
3039
|
if (isNative) {
|
|
2938
3040
|
const totalDepositedAmount = recipients.reduce((acc, recipient) => recipient.amount.add(acc), new BN3__default.default(0));
|
|
2939
|
-
const nativeInstructions = await common.prepareWrappedAccount(
|
|
2940
|
-
this.connection,
|
|
2941
|
-
sender.publicKey,
|
|
2942
|
-
totalDepositedAmount
|
|
2943
|
-
);
|
|
3041
|
+
const nativeInstructions = await common.prepareWrappedAccount(this.connection, sender.publicKey, totalDepositedAmount);
|
|
2944
3042
|
prepareInstructions.push(...nativeInstructions);
|
|
2945
3043
|
}
|
|
2946
3044
|
return {
|
|
@@ -3138,10 +3236,7 @@ var SolanaStreamClient = class {
|
|
|
3138
3236
|
async withdraw({ id, amount = WITHDRAW_AVAILABLE_AMOUNT }, extParams) {
|
|
3139
3237
|
const { invoker, customInstructions } = extParams;
|
|
3140
3238
|
common.assertHasPublicKey(invoker, "Invoker's PublicKey is not available, check passed wallet adapter!");
|
|
3141
|
-
const ixs = await this.prepareWithdrawInstructions(
|
|
3142
|
-
{ id, amount },
|
|
3143
|
-
extParams
|
|
3144
|
-
);
|
|
3239
|
+
const ixs = await this.prepareWithdrawInstructions({ id, amount }, extParams);
|
|
3145
3240
|
const metadata = new web3_js.PublicKey(id);
|
|
3146
3241
|
await this.applyCustomAfterInstructions(ixs, customInstructions, metadata);
|
|
3147
3242
|
const { tx, hash, context } = await common.prepareTransaction(this.connection, ixs, invoker.publicKey);
|
|
@@ -3645,17 +3740,26 @@ var SolanaStreamClient = class {
|
|
|
3645
3740
|
const streamPublicKey = new web3_js.PublicKey(data.id);
|
|
3646
3741
|
const escrow = await this.connection.getAccountInfo(streamPublicKey);
|
|
3647
3742
|
common.invariant(escrow, "Couldn't get account info");
|
|
3743
|
+
const { sender: senderPublicKey } = decodeStream(escrow.data);
|
|
3744
|
+
const isAlignedUnlock = this.isAlignedUnlock(streamPublicKey, senderPublicKey);
|
|
3745
|
+
if (isAlignedUnlock && (data.enableAutomaticWithdrawal !== void 0 || data.amountPerPeriod !== void 0)) {
|
|
3746
|
+
throw new Error("Automatic withdrawal and rate update are not possible in price-based vesting!");
|
|
3747
|
+
}
|
|
3648
3748
|
const ixs = common.prepareBaseInstructions(this.connection, {
|
|
3649
3749
|
computePrice,
|
|
3650
3750
|
computeLimit
|
|
3651
3751
|
});
|
|
3652
3752
|
ixs.push(
|
|
3653
|
-
await
|
|
3753
|
+
await (isAlignedUnlock ? this.alignedProxyProgram.methods.updateContract({
|
|
3754
|
+
transferableBySender: data.transferableBySender ?? null,
|
|
3755
|
+
transferableByRecipient: data.transferableByRecipient ?? null,
|
|
3756
|
+
cancelableBySender: data.cancelableBySender ?? null
|
|
3757
|
+
}).accounts({ sender: invoker.publicKey, streamMetadata: streamPublicKey, withdrawor: WITHDRAWOR_PUBLIC_KEY }).accountsPartial({ streamflowProgram: this.programId }).instruction() : updateStreamInstruction(data, this.programId, {
|
|
3654
3758
|
authority: invoker.publicKey,
|
|
3655
3759
|
metadata: streamPublicKey,
|
|
3656
3760
|
withdrawor: WITHDRAWOR_PUBLIC_KEY,
|
|
3657
3761
|
systemProgram: web3_js.SystemProgram.programId
|
|
3658
|
-
})
|
|
3762
|
+
}))
|
|
3659
3763
|
);
|
|
3660
3764
|
return ixs;
|
|
3661
3765
|
}
|
|
@@ -3714,8 +3818,8 @@ var SolanaStreamClient = class {
|
|
|
3714
3818
|
return extractSolanaErrorCode(err.toString() ?? "Unknown error!", logs);
|
|
3715
3819
|
}
|
|
3716
3820
|
/**
|
|
3717
|
-
|
|
3718
|
-
|
|
3821
|
+
* Utility function that checks whether the associated stream address is an aligned unlock contract, indicated by whether the sender/creator is a PDA
|
|
3822
|
+
*/
|
|
3719
3823
|
isAlignedUnlock(streamPublicKey, senderPublicKey) {
|
|
3720
3824
|
const pda = deriveContractPDA(this.alignedProxyProgram.programId, streamPublicKey);
|
|
3721
3825
|
return senderPublicKey.equals(pda);
|
|
@@ -4250,6 +4354,7 @@ exports.isAligned = isAligned;
|
|
|
4250
4354
|
exports.isCliffCloseToDepositedAmount = isCliffCloseToDepositedAmount;
|
|
4251
4355
|
exports.isCreateAlignedStreamData = isCreateAlignedStreamData;
|
|
4252
4356
|
exports.isDynamicLock = isDynamicLock;
|
|
4357
|
+
exports.isPayment = isPayment;
|
|
4253
4358
|
exports.isTokenLock = isTokenLock;
|
|
4254
4359
|
exports.isVesting = isVesting;
|
|
4255
4360
|
exports.sendAndConfirmStreamRawTransaction = sendAndConfirmStreamRawTransaction;
|