@streamflow/stream 11.1.0-alpha.p335.6615f0a → 11.1.0-alpha.p335.775cce7
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 +245 -16
- package/dist/cjs/index.cjs.map +1 -1
- package/dist/cjs/index.d.cts +1 -1
- package/dist/cjs/solana/index.cjs +245 -16
- package/dist/cjs/solana/index.cjs.map +1 -1
- package/dist/cjs/solana/index.d.cts +193 -3
- package/dist/esm/index.d.ts +1 -1
- package/dist/esm/index.js +241 -18
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/solana/index.d.ts +193 -3
- package/dist/esm/solana/index.js +241 -18
- package/dist/esm/solana/index.js.map +1 -1
- package/package.json +5 -4
package/dist/cjs/index.cjs
CHANGED
|
@@ -185,6 +185,7 @@ 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;
|
|
188
189
|
this.type = buildStreamType(this);
|
|
189
190
|
this.isAligned = false;
|
|
190
191
|
}
|
|
@@ -229,6 +230,7 @@ var STREAM_STRUCT_OFFSET_SENDER = 49;
|
|
|
229
230
|
var STREAM_STRUCT_OFFSET_RECIPIENT = 113;
|
|
230
231
|
var STREAM_STRUCT_OFFSET_MINT = 177;
|
|
231
232
|
var STREAM_STRUCT_OFFSET_CLOSED = 671;
|
|
233
|
+
var STREAM_STRUCT_OFFSET_OLD_METADATA_KEY = 714;
|
|
232
234
|
var MAX_SAFE_UNIX_TIME_VALUE2 = 864e10;
|
|
233
235
|
var WITHDRAW_AVAILABLE_AMOUNT = new BN3__default.default("18446744073709551615");
|
|
234
236
|
var ALIGNED_PRECISION_FACTOR_POW2 = 9;
|
|
@@ -269,6 +271,7 @@ var TEST_ORACLE_DISCRIMINATOR = [198, 49, 63, 134, 232, 251, 168, 28];
|
|
|
269
271
|
var CONTRACT_SEED = buffer.Buffer.from("contract", "utf-8");
|
|
270
272
|
var ESCROW_SEED = buffer.Buffer.from("strm", "utf-8");
|
|
271
273
|
var TEST_ORACLE_SEED = buffer.Buffer.from("test-oracle", "utf-8");
|
|
274
|
+
var REPOPULATED_METADATA_SEED = buffer.Buffer.from("strm-rep", "utf-8");
|
|
272
275
|
var STREAMFLOW_TREASURY_PUBLIC_KEY = new web3_js.PublicKey("5SEpbdjFK5FxwTvfsGMXVQTD2v4M2c5tyRTxhdsPkgDw");
|
|
273
276
|
var WITHDRAWOR = "wdrwhnCv4pzW8beKsbPa4S2UDZrXenjg16KJdKSpb5u";
|
|
274
277
|
var WITHDRAWOR_PUBLIC_KEY = new web3_js.PublicKey(WITHDRAWOR);
|
|
@@ -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 getMetadataKey = (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) {
|
|
@@ -2524,6 +2539,149 @@ var deriveEscrowPDA = (programId, streamMetadata) => {
|
|
|
2524
2539
|
var deriveTestOraclePDA = (programId, mint, creator) => {
|
|
2525
2540
|
return web3_js.PublicKey.findProgramAddressSync([TEST_ORACLE_SEED, mint.toBuffer(), creator.toBuffer()], programId)[0];
|
|
2526
2541
|
};
|
|
2542
|
+
var deriveRepopulatedMetadataPDA = (programId, streamMetadata) => {
|
|
2543
|
+
return web3_js.PublicKey.findProgramAddressSync([REPOPULATED_METADATA_SEED, streamMetadata.toBuffer()], programId)[0];
|
|
2544
|
+
};
|
|
2545
|
+
|
|
2546
|
+
// solana/api-public/client.ts
|
|
2547
|
+
var DEFAULT_API_URL = "https://api-public.streamflow.finance";
|
|
2548
|
+
var DEFAULT_DEVNET_API_URL = "https://api-public-staging.streamflow.finance";
|
|
2549
|
+
var createClient = (options) => {
|
|
2550
|
+
const apiUrl = options?.apiUrl ?? options?.cluster === "mainnet" ? DEFAULT_API_URL : DEFAULT_DEVNET_API_URL;
|
|
2551
|
+
const fetchFn = options?.fetchFn ?? fetch;
|
|
2552
|
+
const fetchResource = async (url, options2) => {
|
|
2553
|
+
const res = await fetchFn(url, {
|
|
2554
|
+
method: "GET",
|
|
2555
|
+
headers: { "Content-Type": "application/json" },
|
|
2556
|
+
...{}
|
|
2557
|
+
});
|
|
2558
|
+
if (!res.ok) {
|
|
2559
|
+
const text = await res.text().catch(() => "");
|
|
2560
|
+
throw new Error(`Tabularium API error`, {
|
|
2561
|
+
cause: new Error(`: ${res.status} ${res.statusText}${text ? ` - ${text}` : ""}`)
|
|
2562
|
+
});
|
|
2563
|
+
}
|
|
2564
|
+
return res.json();
|
|
2565
|
+
};
|
|
2566
|
+
return {
|
|
2567
|
+
getContracts: async (opts) => {
|
|
2568
|
+
const params = new URLSearchParams();
|
|
2569
|
+
if (opts?.sender) params.set("sender", opts.sender);
|
|
2570
|
+
if (opts?.recipient) params.set("recipient", opts.recipient);
|
|
2571
|
+
const url = `${apiUrl}/v2/api/contracts/tabularium/${params.toString() ? `?${params.toString()}` : ""}`;
|
|
2572
|
+
return fetchResource(url);
|
|
2573
|
+
},
|
|
2574
|
+
getContract: async (address) => {
|
|
2575
|
+
const url = `${apiUrl}/v2/api/contracts/tabularium/${encodeURIComponent(address)}`;
|
|
2576
|
+
return fetchResource(url);
|
|
2577
|
+
}
|
|
2578
|
+
};
|
|
2579
|
+
};
|
|
2580
|
+
var isoToUnix = (iso) => {
|
|
2581
|
+
if (!iso) return 0;
|
|
2582
|
+
const time = new Date(iso).getTime();
|
|
2583
|
+
return Number.isNaN(time) ? 0 : Math.floor(time / 1e3);
|
|
2584
|
+
};
|
|
2585
|
+
var toBN = (value) => new BN3__default.default(value);
|
|
2586
|
+
var mapOracleType = (apiType) => {
|
|
2587
|
+
if (!apiType) return { none: {} };
|
|
2588
|
+
const mapping = {
|
|
2589
|
+
TEST: { test: {} },
|
|
2590
|
+
PYTH: { pyth: {} },
|
|
2591
|
+
SWITCHBOARD: { switchboard: {} }
|
|
2592
|
+
};
|
|
2593
|
+
return mapping[apiType] ?? { none: {} };
|
|
2594
|
+
};
|
|
2595
|
+
async function toDecodedStream(schema) {
|
|
2596
|
+
const mint = common.pk(schema.mint);
|
|
2597
|
+
const sender = common.pk(schema.sender);
|
|
2598
|
+
const recipient = common.pk(schema.recipient);
|
|
2599
|
+
const partner = schema.partner ? common.pk(schema.partner) : sender;
|
|
2600
|
+
const [senderTokens, recipientTokens, partnerTokens, streamflowTreasuryTokens] = await Promise.all([
|
|
2601
|
+
common.ata(mint, sender),
|
|
2602
|
+
common.ata(mint, recipient),
|
|
2603
|
+
common.ata(mint, partner),
|
|
2604
|
+
common.ata(mint, STREAMFLOW_TREASURY_PUBLIC_KEY)
|
|
2605
|
+
]);
|
|
2606
|
+
return {
|
|
2607
|
+
magic: toBN(4),
|
|
2608
|
+
version: toBN(4),
|
|
2609
|
+
createdAt: toBN(isoToUnix(schema.createdDt)),
|
|
2610
|
+
withdrawnAmount: toBN(schema.claimedAmount),
|
|
2611
|
+
canceledAt: toBN(isoToUnix(schema.canceledDt)),
|
|
2612
|
+
end: toBN(isoToUnix(schema.endDt)),
|
|
2613
|
+
lastWithdrawnAt: toBN(isoToUnix(schema.lastClaimedDt)),
|
|
2614
|
+
sender,
|
|
2615
|
+
senderTokens,
|
|
2616
|
+
recipient,
|
|
2617
|
+
recipientTokens,
|
|
2618
|
+
mint,
|
|
2619
|
+
escrowTokens: schema.escrow ? common.pk(schema.escrow) : web3_js.PublicKey.default,
|
|
2620
|
+
streamflowTreasury: STREAMFLOW_TREASURY_PUBLIC_KEY,
|
|
2621
|
+
streamflowTreasuryTokens,
|
|
2622
|
+
streamflowFeeTotal: toBN(schema.streamflowFee),
|
|
2623
|
+
streamflowFeeWithdrawn: toBN(schema.streamflowFeeWithdrawn),
|
|
2624
|
+
streamflowFeePercent: parseFloat(schema.streamflowFeePercentage) || 0,
|
|
2625
|
+
partnerFeeTotal: toBN(schema.partnerFee),
|
|
2626
|
+
partnerFeeWithdrawn: toBN(schema.partnerFeeWithdrawn),
|
|
2627
|
+
partnerFeePercent: parseFloat(schema.partnerFeePercentage) || 0,
|
|
2628
|
+
partner,
|
|
2629
|
+
partnerTokens,
|
|
2630
|
+
start: toBN(isoToUnix(schema.startDt)),
|
|
2631
|
+
depositedAmount: toBN(schema.amount),
|
|
2632
|
+
period: toBN(schema.period),
|
|
2633
|
+
amountPerPeriod: toBN(schema.amountPerPeriod),
|
|
2634
|
+
cliff: toBN(isoToUnix(schema.startDt)),
|
|
2635
|
+
cliffAmount: toBN(schema.cliffAmount),
|
|
2636
|
+
cancelableBySender: schema.isCancelableBySender,
|
|
2637
|
+
cancelableByRecipient: schema.isCancelableByRecipient,
|
|
2638
|
+
automaticWithdrawal: schema.hasAutoClaim,
|
|
2639
|
+
transferableBySender: schema.isTransferableBySender,
|
|
2640
|
+
transferableByRecipient: schema.isTransferableByRecipient,
|
|
2641
|
+
canTopup: schema.canTopup,
|
|
2642
|
+
name: schema.name,
|
|
2643
|
+
withdrawFrequency: toBN(schema.autoClaimPeriod),
|
|
2644
|
+
closed: schema.isClosed,
|
|
2645
|
+
currentPauseStart: toBN(0),
|
|
2646
|
+
pauseCumulative: toBN(schema.pauseCumulative),
|
|
2647
|
+
lastRateChangeTime: toBN(isoToUnix(schema.lastRateUpdateDt)),
|
|
2648
|
+
fundsUnlockedAtLastRateChange: toBN(schema.amountUnlockedAtLastRateUpdate),
|
|
2649
|
+
oldMetadata: web3_js.PublicKey.default
|
|
2650
|
+
};
|
|
2651
|
+
}
|
|
2652
|
+
function toPrecisionBN(value, precision = ALIGNED_PRECISION_FACTOR_POW2) {
|
|
2653
|
+
return common.getBN(typeof value === "number" ? value : parseFloat(value), precision);
|
|
2654
|
+
}
|
|
2655
|
+
function toAlignedProxy(dynamic) {
|
|
2656
|
+
const proxy = {
|
|
2657
|
+
sender: common.pk(dynamic.sender),
|
|
2658
|
+
minPrice: toPrecisionBN(dynamic.minPrice),
|
|
2659
|
+
maxPrice: toPrecisionBN(dynamic.maxPrice),
|
|
2660
|
+
minPercentage: toPrecisionBN(dynamic.minPercentage),
|
|
2661
|
+
maxPercentage: toPrecisionBN(dynamic.maxPercentage),
|
|
2662
|
+
priceOracleType: mapOracleType(dynamic.priceOracleType),
|
|
2663
|
+
priceOracle: dynamic.priceOracleAddress ? common.pk(dynamic.priceOracleAddress) : web3_js.PublicKey.default,
|
|
2664
|
+
tickSize: toPrecisionBN(dynamic.tickSize),
|
|
2665
|
+
initialAmountPerPeriod: toBN(dynamic.initialAmountPerPeriod),
|
|
2666
|
+
initialPrice: toPrecisionBN(dynamic.initialPrice),
|
|
2667
|
+
lastPrice: toPrecisionBN(dynamic.lastPrice),
|
|
2668
|
+
lastAmountUpdateTime: toBN(isoToUnix(dynamic.expiryDt)),
|
|
2669
|
+
initialNetAmount: toBN(dynamic.initialAmount),
|
|
2670
|
+
expiryTime: toBN(isoToUnix(dynamic.expiryDt)),
|
|
2671
|
+
expiryPercentage: toPrecisionBN(dynamic.expiryPercentage),
|
|
2672
|
+
floorPrice: toPrecisionBN(dynamic.floorPrice),
|
|
2673
|
+
streamCanceledTime: dynamic.streamCanceledTime ? toBN(dynamic.streamCanceledTime) : toBN(0)
|
|
2674
|
+
};
|
|
2675
|
+
return proxy;
|
|
2676
|
+
}
|
|
2677
|
+
var transformContract = async (schema) => {
|
|
2678
|
+
const decodedStream = await toDecodedStream(schema);
|
|
2679
|
+
if (schema.dynamicContract) {
|
|
2680
|
+
const alignedProxy = toAlignedProxy(schema.dynamicContract);
|
|
2681
|
+
return new AlignedContract(decodedStream, alignedProxy);
|
|
2682
|
+
}
|
|
2683
|
+
return new Contract(decodedStream);
|
|
2684
|
+
};
|
|
2527
2685
|
|
|
2528
2686
|
// solana/StreamClient.ts
|
|
2529
2687
|
var METADATA_ACC_SIZE = 1104;
|
|
@@ -2567,6 +2725,9 @@ var SolanaStreamClient = class {
|
|
|
2567
2725
|
address: streamflow_aligned_unlocks_default.address
|
|
2568
2726
|
};
|
|
2569
2727
|
this.alignedProxyProgram = new anchor.Program(alignedUnlocksProgram, { connection: this.connection });
|
|
2728
|
+
this.apiClient = createClient(
|
|
2729
|
+
typeof optionsOrClusterUrl === "object" && optionsOrClusterUrl.cluster !== common.ICluster.Mainnet ? { cluster: "devnet" } : { cluster: "mainnet" }
|
|
2730
|
+
);
|
|
2570
2731
|
}
|
|
2571
2732
|
getConnection() {
|
|
2572
2733
|
return this.connection;
|
|
@@ -3345,8 +3506,8 @@ var SolanaStreamClient = class {
|
|
|
3345
3506
|
if (!account) {
|
|
3346
3507
|
throw new Error("Impossible to cancel a stream contract that does not exist");
|
|
3347
3508
|
}
|
|
3348
|
-
const
|
|
3349
|
-
const isAlignedUnlock = this.isAlignedUnlock(streamPublicKey,
|
|
3509
|
+
const decoded = decodeStream(account.data);
|
|
3510
|
+
const isAlignedUnlock = this.isAlignedUnlock(streamPublicKey, decoded.sender);
|
|
3350
3511
|
const ixs = isAlignedUnlock ? await this.prepareCancelAlignedUnlockInstructions(cancelData, extParams) : await this.prepareCancelLinearStream(cancelData, extParams);
|
|
3351
3512
|
return ixs;
|
|
3352
3513
|
}
|
|
@@ -3568,13 +3729,35 @@ var SolanaStreamClient = class {
|
|
|
3568
3729
|
async getOne({ id }) {
|
|
3569
3730
|
const streamPublicKey = new web3_js.PublicKey(id);
|
|
3570
3731
|
const escrow = await this.connection.getAccountInfo(streamPublicKey, TX_FINALITY_CONFIRMED);
|
|
3571
|
-
if (
|
|
3572
|
-
|
|
3732
|
+
if (escrow?.data) {
|
|
3733
|
+
return this.decodeStreamAccount(streamPublicKey, escrow.data);
|
|
3573
3734
|
}
|
|
3574
|
-
const
|
|
3575
|
-
|
|
3735
|
+
const migrated = await this.connection.getProgramAccounts(this.programId, {
|
|
3736
|
+
filters: [
|
|
3737
|
+
{ dataSize: METADATA_ACC_SIZE },
|
|
3738
|
+
{
|
|
3739
|
+
memcmp: {
|
|
3740
|
+
offset: STREAM_STRUCT_OFFSET_OLD_METADATA_KEY,
|
|
3741
|
+
bytes: id
|
|
3742
|
+
}
|
|
3743
|
+
}
|
|
3744
|
+
]
|
|
3745
|
+
});
|
|
3746
|
+
if (migrated.length > 0) {
|
|
3747
|
+
return this.decodeStreamAccount(migrated[0].pubkey, migrated[0].account.data);
|
|
3748
|
+
}
|
|
3749
|
+
try {
|
|
3750
|
+
const contract = await this.apiClient.getContract(id);
|
|
3751
|
+
return await transformContract(contract);
|
|
3752
|
+
} catch (cause) {
|
|
3753
|
+
throw new Error(`Couldn't get account info from chain or Tabularium`, { cause });
|
|
3754
|
+
}
|
|
3755
|
+
}
|
|
3756
|
+
async decodeStreamAccount(pubkey, data) {
|
|
3757
|
+
const stream = decodeStream(data);
|
|
3758
|
+
if (this.isAlignedUnlock(pubkey, stream.sender)) {
|
|
3576
3759
|
const alignedProxy = await this.alignedProxyProgram.account.contract.fetch(
|
|
3577
|
-
deriveContractPDA(this.alignedProxyProgram.programId,
|
|
3760
|
+
deriveContractPDA(this.alignedProxyProgram.programId, pubkey)
|
|
3578
3761
|
);
|
|
3579
3762
|
if (!alignedProxy) {
|
|
3580
3763
|
throw new Error("Couldn't get proxy account info.");
|
|
@@ -3614,9 +3797,9 @@ var SolanaStreamClient = class {
|
|
|
3614
3797
|
async getIncomingAlignedStreams(streamRecord) {
|
|
3615
3798
|
const streams = {};
|
|
3616
3799
|
const alignedStreamsPubKeys = Object.keys(streamRecord);
|
|
3617
|
-
const alignedProxyPDAs = alignedStreamsPubKeys.map(
|
|
3618
|
-
|
|
3619
|
-
);
|
|
3800
|
+
const alignedProxyPDAs = alignedStreamsPubKeys.map((streamPubKey) => {
|
|
3801
|
+
return deriveContractPDA(this.alignedProxyProgram.programId, new web3_js.PublicKey(streamPubKey));
|
|
3802
|
+
});
|
|
3620
3803
|
const alignedProxyAccounts = await common.getMultipleAccountsInfoBatched(this.connection, alignedProxyPDAs);
|
|
3621
3804
|
alignedProxyAccounts.forEach((account, index) => {
|
|
3622
3805
|
if (account && account.data.length === ALIGNED_METADATA_ACC_SIZE) {
|
|
@@ -3638,7 +3821,8 @@ var SolanaStreamClient = class {
|
|
|
3638
3821
|
async get({
|
|
3639
3822
|
address,
|
|
3640
3823
|
type = "all" /* All */,
|
|
3641
|
-
direction = "all" /* All
|
|
3824
|
+
direction = "all" /* All */,
|
|
3825
|
+
filters
|
|
3642
3826
|
}) {
|
|
3643
3827
|
const publicKey = new web3_js.PublicKey(address);
|
|
3644
3828
|
let streams = {};
|
|
@@ -3679,6 +3863,10 @@ var SolanaStreamClient = class {
|
|
|
3679
3863
|
streams = { ...streams, ...incomingAlignedStreams };
|
|
3680
3864
|
}
|
|
3681
3865
|
}
|
|
3866
|
+
if (filters?.closed) {
|
|
3867
|
+
const closedStreams = await this.getClosedStreams(address, direction);
|
|
3868
|
+
streams = { ...streams, ...closedStreams };
|
|
3869
|
+
}
|
|
3682
3870
|
const sortedStreams = Object.entries(streams).sort(([, stream1], [, stream2]) => stream2.start - stream1.start);
|
|
3683
3871
|
if (type === "all" /* All */) return sortedStreams;
|
|
3684
3872
|
return sortedStreams.filter((stream) => stream[1].type === type);
|
|
@@ -3774,8 +3962,8 @@ var SolanaStreamClient = class {
|
|
|
3774
3962
|
const streamPublicKey = new web3_js.PublicKey(data.id);
|
|
3775
3963
|
const escrow = await this.connection.getAccountInfo(streamPublicKey);
|
|
3776
3964
|
common.invariant(escrow, "Couldn't get account info");
|
|
3777
|
-
const
|
|
3778
|
-
const isAlignedUnlock = this.isAlignedUnlock(streamPublicKey,
|
|
3965
|
+
const decoded = decodeStream(escrow.data);
|
|
3966
|
+
const isAlignedUnlock = this.isAlignedUnlock(streamPublicKey, decoded.sender);
|
|
3779
3967
|
if (isAlignedUnlock && (data.enableAutomaticWithdrawal !== void 0 || data.amountPerPeriod !== void 0)) {
|
|
3780
3968
|
throw new Error("Automatic withdrawal and rate update are not possible in price-based vesting!");
|
|
3781
3969
|
}
|
|
@@ -3866,7 +4054,8 @@ var SolanaStreamClient = class {
|
|
|
3866
4054
|
return extractSolanaErrorCode(err.toString() ?? "Unknown error!", logs);
|
|
3867
4055
|
}
|
|
3868
4056
|
/**
|
|
3869
|
-
* Utility function that checks whether the associated stream address is an aligned unlock contract, indicated by whether the sender/creator is a PDA
|
|
4057
|
+
* Utility function that checks whether the associated stream address is an aligned unlock contract, indicated by whether the sender/creator is a PDA.
|
|
4058
|
+
* For migrated streams, the PDA was derived from the old metadata key.
|
|
3870
4059
|
*/
|
|
3871
4060
|
isAlignedUnlock(streamPublicKey, senderPublicKey) {
|
|
3872
4061
|
const pda = deriveContractPDA(this.alignedProxyProgram.programId, streamPublicKey);
|
|
@@ -3887,6 +4076,40 @@ var SolanaStreamClient = class {
|
|
|
3887
4076
|
)
|
|
3888
4077
|
};
|
|
3889
4078
|
}
|
|
4079
|
+
/**
|
|
4080
|
+
* Gets closed streams for a given owner and direction
|
|
4081
|
+
* @param owner - Owner address
|
|
4082
|
+
* @param direction - Stream direction
|
|
4083
|
+
* @returns Record of closed streams
|
|
4084
|
+
*/
|
|
4085
|
+
async getClosedStreams(owner, direction = "all" /* All */) {
|
|
4086
|
+
const streams = {};
|
|
4087
|
+
try {
|
|
4088
|
+
const tabulariumContracts = await this.apiClient.getContracts({
|
|
4089
|
+
sender: direction !== "incoming" /* Incoming */ ? owner : void 0,
|
|
4090
|
+
recipient: direction !== "outgoing" /* Outgoing */ ? owner : void 0
|
|
4091
|
+
});
|
|
4092
|
+
for (const contract of tabulariumContracts) {
|
|
4093
|
+
if (!streams[contract.address]) {
|
|
4094
|
+
try {
|
|
4095
|
+
const transformed = await transformContract(contract);
|
|
4096
|
+
streams[contract.address] = transformed;
|
|
4097
|
+
} catch (cause) {
|
|
4098
|
+
if (common.isDev) {
|
|
4099
|
+
throw new Error(`Failed to transform contract ${contract.address}:`, { cause });
|
|
4100
|
+
}
|
|
4101
|
+
console.warn(new Error(`Failed to transform contract ${contract.address}:`, { cause }));
|
|
4102
|
+
}
|
|
4103
|
+
}
|
|
4104
|
+
}
|
|
4105
|
+
} catch (cause) {
|
|
4106
|
+
if (common.isDev) {
|
|
4107
|
+
throw new Error("Failed to get data from the service", { cause });
|
|
4108
|
+
}
|
|
4109
|
+
console.warn(new Error("Failed to get data from the service", { cause }));
|
|
4110
|
+
}
|
|
4111
|
+
return streams;
|
|
4112
|
+
}
|
|
3890
4113
|
/**
|
|
3891
4114
|
* Utility function to generate metadata for a Contract or return existing Pubkey
|
|
3892
4115
|
*/
|
|
@@ -4386,12 +4609,14 @@ exports.PARTNERS_SCHEMA = PARTNERS_SCHEMA;
|
|
|
4386
4609
|
exports.PARTNER_ORACLE_PROGRAM_ID = PARTNER_ORACLE_PROGRAM_ID;
|
|
4387
4610
|
exports.PARTNER_SCHEMA = PARTNER_SCHEMA;
|
|
4388
4611
|
exports.PROGRAM_ID = PROGRAM_ID;
|
|
4612
|
+
exports.REPOPULATED_METADATA_SEED = REPOPULATED_METADATA_SEED;
|
|
4389
4613
|
exports.SOLANA_ERROR_MAP = SOLANA_ERROR_MAP;
|
|
4390
4614
|
exports.SOLANA_ERROR_MATCH_REGEX = SOLANA_ERROR_MATCH_REGEX;
|
|
4391
4615
|
exports.STREAMFLOW_TREASURY_PUBLIC_KEY = STREAMFLOW_TREASURY_PUBLIC_KEY;
|
|
4392
4616
|
exports.STREAM_STRUCT_OFFSETS = STREAM_STRUCT_OFFSETS;
|
|
4393
4617
|
exports.STREAM_STRUCT_OFFSET_CLOSED = STREAM_STRUCT_OFFSET_CLOSED;
|
|
4394
4618
|
exports.STREAM_STRUCT_OFFSET_MINT = STREAM_STRUCT_OFFSET_MINT;
|
|
4619
|
+
exports.STREAM_STRUCT_OFFSET_OLD_METADATA_KEY = STREAM_STRUCT_OFFSET_OLD_METADATA_KEY;
|
|
4395
4620
|
exports.STREAM_STRUCT_OFFSET_RECIPIENT = STREAM_STRUCT_OFFSET_RECIPIENT;
|
|
4396
4621
|
exports.STREAM_STRUCT_OFFSET_SENDER = STREAM_STRUCT_OFFSET_SENDER;
|
|
4397
4622
|
exports.SolanaStreamClient = SolanaStreamClient;
|
|
@@ -4407,14 +4632,17 @@ exports.buildStreamType = buildStreamType;
|
|
|
4407
4632
|
exports.calculateTotalAmountToDeposit = calculateTotalAmountToDeposit;
|
|
4408
4633
|
exports.calculateUnlockedAmount = calculateUnlockedAmount;
|
|
4409
4634
|
exports.cancelStreamInstruction = cancelStreamInstruction;
|
|
4635
|
+
exports.createClient = createClient;
|
|
4410
4636
|
exports.createStreamInstruction = createStreamInstruction;
|
|
4411
4637
|
exports.createUncheckedStreamInstruction = createUncheckedStreamInstruction;
|
|
4412
4638
|
exports.decodeEndTime = decodeEndTime;
|
|
4413
4639
|
exports.decodeStream = decodeStream;
|
|
4414
4640
|
exports.deriveContractPDA = deriveContractPDA;
|
|
4415
4641
|
exports.deriveEscrowPDA = deriveEscrowPDA;
|
|
4642
|
+
exports.deriveRepopulatedMetadataPDA = deriveRepopulatedMetadataPDA;
|
|
4416
4643
|
exports.deriveTestOraclePDA = deriveTestOraclePDA;
|
|
4417
4644
|
exports.extractSolanaErrorCode = extractSolanaErrorCode;
|
|
4645
|
+
exports.getMetadataKey = getMetadataKey;
|
|
4418
4646
|
exports.handleContractError = handleContractError;
|
|
4419
4647
|
exports.isAligned = isAligned;
|
|
4420
4648
|
exports.isCliffCloseToDepositedAmount = isCliffCloseToDepositedAmount;
|
|
@@ -4427,6 +4655,7 @@ exports.signAllTransactionWithRecipients = signAllTransactionWithRecipients;
|
|
|
4427
4655
|
exports.timelockIDL = timelockIDL_default;
|
|
4428
4656
|
exports.topupStreamInstruction = topupStreamInstruction;
|
|
4429
4657
|
exports.transferStreamInstruction = transferStreamInstruction;
|
|
4658
|
+
exports.transformContract = transformContract;
|
|
4430
4659
|
exports.updateStreamInstruction = updateStreamInstruction;
|
|
4431
4660
|
exports.withdrawStreamInstruction = withdrawStreamInstruction;
|
|
4432
4661
|
//# sourceMappingURL=index.cjs.map
|