@streamflow/stream 9.0.4 → 9.2.0-alpha.p0.5034440
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-BgGtpOPg.d.cts → index-ByMlPIUq.d.cts} +2 -2
- package/dist/cjs/index.cjs +124 -28
- package/dist/cjs/index.cjs.map +1 -1
- package/dist/cjs/index.d.cts +2 -2
- package/dist/cjs/solana/descriptor/streamflow_aligned_unlocks.d.cts +101 -1
- package/dist/cjs/solana/index.cjs +124 -28
- package/dist/cjs/solana/index.cjs.map +1 -1
- package/dist/cjs/solana/index.d.cts +1 -1
- package/dist/esm/{index-Dp5DXxr-.d.ts → index-DsFyl13W.d.ts} +2 -2
- package/dist/esm/index.d.ts +2 -2
- package/dist/esm/index.js +124 -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 +1 -1
- package/dist/esm/solana/index.js +124 -28
- package/dist/esm/solana/index.js.map +1 -1
- package/package.json +4 -4
|
@@ -495,8 +495,8 @@ declare class SolanaStreamClient extends BaseStreamClient {
|
|
|
495
495
|
*/
|
|
496
496
|
extractErrorCode(err: Error): string | null;
|
|
497
497
|
/**
|
|
498
|
-
|
|
499
|
-
|
|
498
|
+
* Utility function that checks whether the associated stream address is an aligned unlock contract, indicated by whether the sender/creator is a PDA
|
|
499
|
+
*/
|
|
500
500
|
isAlignedUnlock(streamPublicKey: PublicKey, senderPublicKey: PublicKey): boolean;
|
|
501
501
|
/**
|
|
502
502
|
* Utility function to generate metadata for a Contract or return existing Pubkey
|
package/dist/cjs/index.cjs
CHANGED
|
@@ -3494,7 +3494,7 @@ var streamflow_aligned_unlocks_default = {
|
|
|
3494
3494
|
address: "aSTRM2NKoKxNnkmLWk9sz3k74gKBk9t7bpPrTGxMszH",
|
|
3495
3495
|
metadata: {
|
|
3496
3496
|
name: "streamflow_aligned_unlocks",
|
|
3497
|
-
version: "1.
|
|
3497
|
+
version: "1.4.0",
|
|
3498
3498
|
spec: "0.1.0",
|
|
3499
3499
|
description: "Proxy to update unlock amount within Streamflow vesting protocol according to Token performance and other metrics"
|
|
3500
3500
|
},
|
|
@@ -4368,6 +4368,80 @@ var streamflow_aligned_unlocks_default = {
|
|
|
4368
4368
|
],
|
|
4369
4369
|
args: []
|
|
4370
4370
|
},
|
|
4371
|
+
{
|
|
4372
|
+
name: "update_contract",
|
|
4373
|
+
discriminator: [
|
|
4374
|
+
78,
|
|
4375
|
+
184,
|
|
4376
|
+
162,
|
|
4377
|
+
174,
|
|
4378
|
+
233,
|
|
4379
|
+
5,
|
|
4380
|
+
40,
|
|
4381
|
+
82
|
|
4382
|
+
],
|
|
4383
|
+
accounts: [
|
|
4384
|
+
{
|
|
4385
|
+
name: "sender",
|
|
4386
|
+
writable: true,
|
|
4387
|
+
signer: true
|
|
4388
|
+
},
|
|
4389
|
+
{
|
|
4390
|
+
name: "proxy_metadata",
|
|
4391
|
+
docs: [
|
|
4392
|
+
"Proxy Contract"
|
|
4393
|
+
],
|
|
4394
|
+
writable: true,
|
|
4395
|
+
pda: {
|
|
4396
|
+
seeds: [
|
|
4397
|
+
{
|
|
4398
|
+
kind: "const",
|
|
4399
|
+
value: [
|
|
4400
|
+
99,
|
|
4401
|
+
111,
|
|
4402
|
+
110,
|
|
4403
|
+
116,
|
|
4404
|
+
114,
|
|
4405
|
+
97,
|
|
4406
|
+
99,
|
|
4407
|
+
116
|
|
4408
|
+
]
|
|
4409
|
+
},
|
|
4410
|
+
{
|
|
4411
|
+
kind: "account",
|
|
4412
|
+
path: "stream_metadata"
|
|
4413
|
+
}
|
|
4414
|
+
]
|
|
4415
|
+
}
|
|
4416
|
+
},
|
|
4417
|
+
{
|
|
4418
|
+
name: "stream_metadata",
|
|
4419
|
+
writable: true
|
|
4420
|
+
},
|
|
4421
|
+
{
|
|
4422
|
+
name: "withdrawor",
|
|
4423
|
+
writable: true
|
|
4424
|
+
},
|
|
4425
|
+
{
|
|
4426
|
+
name: "streamflow_program",
|
|
4427
|
+
address: "strmRqUCoQUgGUan5YhzUZa6KqdzwX5L6FpUxfmKg5m"
|
|
4428
|
+
},
|
|
4429
|
+
{
|
|
4430
|
+
name: "system_program",
|
|
4431
|
+
address: "11111111111111111111111111111111"
|
|
4432
|
+
}
|
|
4433
|
+
],
|
|
4434
|
+
args: [
|
|
4435
|
+
{
|
|
4436
|
+
name: "params",
|
|
4437
|
+
type: {
|
|
4438
|
+
defined: {
|
|
4439
|
+
name: "UpdateContractParams"
|
|
4440
|
+
}
|
|
4441
|
+
}
|
|
4442
|
+
}
|
|
4443
|
+
]
|
|
4444
|
+
},
|
|
4371
4445
|
{
|
|
4372
4446
|
name: "update_test_oracle",
|
|
4373
4447
|
discriminator: [
|
|
@@ -4963,6 +5037,32 @@ var streamflow_aligned_unlocks_default = {
|
|
|
4963
5037
|
]
|
|
4964
5038
|
}
|
|
4965
5039
|
},
|
|
5040
|
+
{
|
|
5041
|
+
name: "UpdateContractParams",
|
|
5042
|
+
type: {
|
|
5043
|
+
kind: "struct",
|
|
5044
|
+
fields: [
|
|
5045
|
+
{
|
|
5046
|
+
name: "transferable_by_sender",
|
|
5047
|
+
type: {
|
|
5048
|
+
option: "bool"
|
|
5049
|
+
}
|
|
5050
|
+
},
|
|
5051
|
+
{
|
|
5052
|
+
name: "transferable_by_recipient",
|
|
5053
|
+
type: {
|
|
5054
|
+
option: "bool"
|
|
5055
|
+
}
|
|
5056
|
+
},
|
|
5057
|
+
{
|
|
5058
|
+
name: "cancelable_by_sender",
|
|
5059
|
+
type: {
|
|
5060
|
+
option: "bool"
|
|
5061
|
+
}
|
|
5062
|
+
}
|
|
5063
|
+
]
|
|
5064
|
+
}
|
|
5065
|
+
},
|
|
4966
5066
|
{
|
|
4967
5067
|
name: "UpdateTestOracleParams",
|
|
4968
5068
|
type: {
|
|
@@ -5188,7 +5288,10 @@ var SolanaStreamClient = class extends BaseStreamClient {
|
|
|
5188
5288
|
floorPrice
|
|
5189
5289
|
} = streamParams;
|
|
5190
5290
|
const { isNative, sender, computeLimit, computePrice, metadataPubKeys } = extParams;
|
|
5191
|
-
common.invariant(
|
|
5291
|
+
common.invariant(
|
|
5292
|
+
priceOracle || !oracleType || oracleType === "none",
|
|
5293
|
+
"Price oracle is required for the specified oracle type"
|
|
5294
|
+
);
|
|
5192
5295
|
common.assertHasPublicKey(sender, "Sender's PublicKey is not available, check passed wallet adapter!");
|
|
5193
5296
|
const recipientPublicKey = new web3_js.PublicKey(recipient);
|
|
5194
5297
|
const mintPublicKey = isNative ? splToken.NATIVE_MINT : new web3_js.PublicKey(mint);
|
|
@@ -5363,10 +5466,7 @@ var SolanaStreamClient = class extends BaseStreamClient {
|
|
|
5363
5466
|
* @returns Create result
|
|
5364
5467
|
*/
|
|
5365
5468
|
async createUnchecked(data, extParams) {
|
|
5366
|
-
const { ixs, metadata, metadataPubKey } = await this.prepareCreateUncheckedInstructions(
|
|
5367
|
-
data,
|
|
5368
|
-
extParams
|
|
5369
|
-
);
|
|
5469
|
+
const { ixs, metadata, metadataPubKey } = await this.prepareCreateUncheckedInstructions(data, extParams);
|
|
5370
5470
|
const { tx, hash, context } = await solana.prepareTransaction(
|
|
5371
5471
|
this.connection,
|
|
5372
5472
|
ixs,
|
|
@@ -5492,7 +5592,6 @@ var SolanaStreamClient = class extends BaseStreamClient {
|
|
|
5492
5592
|
const metadatas = [];
|
|
5493
5593
|
const metadataToRecipient = {};
|
|
5494
5594
|
const instructionsBatch = [];
|
|
5495
|
-
const metadataPubKeys = metadataPubKeysExt || [];
|
|
5496
5595
|
const partnerPublicKey = data.partner ? new web3_js.PublicKey(data.partner) : WITHDRAWOR_PUBLIC_KEY;
|
|
5497
5596
|
const mintPublicKey = new web3_js.PublicKey(data.tokenId);
|
|
5498
5597
|
if (recipients.length === 0) {
|
|
@@ -5502,8 +5601,8 @@ var SolanaStreamClient = class extends BaseStreamClient {
|
|
|
5502
5601
|
const recipientData = recipients[i];
|
|
5503
5602
|
const createStreamData = { ...streamParams, ...recipientData };
|
|
5504
5603
|
const createStreamExtParams = {
|
|
5505
|
-
|
|
5506
|
-
|
|
5604
|
+
...extParams,
|
|
5605
|
+
metadataPubKeys: metadataPubKeysExt?.[i] ? [metadataPubKeysExt[i]] : void 0
|
|
5507
5606
|
};
|
|
5508
5607
|
const { ixs, metadata, metadataPubKey } = await this.prepareCreateInstructions(
|
|
5509
5608
|
createStreamData,
|
|
@@ -5518,19 +5617,10 @@ var SolanaStreamClient = class extends BaseStreamClient {
|
|
|
5518
5617
|
recipient: recipientData.recipient
|
|
5519
5618
|
});
|
|
5520
5619
|
}
|
|
5521
|
-
const prepareInstructions = await this.getCreateATAInstructions(
|
|
5522
|
-
[partnerPublicKey],
|
|
5523
|
-
mintPublicKey,
|
|
5524
|
-
sender,
|
|
5525
|
-
true
|
|
5526
|
-
);
|
|
5620
|
+
const prepareInstructions = await this.getCreateATAInstructions([partnerPublicKey], mintPublicKey, sender, true);
|
|
5527
5621
|
if (isNative) {
|
|
5528
5622
|
const totalDepositedAmount = recipients.reduce((acc, recipient) => recipient.amount.add(acc), new BN7__default.default(0));
|
|
5529
|
-
const nativeInstructions = await solana.prepareWrappedAccount(
|
|
5530
|
-
this.connection,
|
|
5531
|
-
sender.publicKey,
|
|
5532
|
-
totalDepositedAmount
|
|
5533
|
-
);
|
|
5623
|
+
const nativeInstructions = await solana.prepareWrappedAccount(this.connection, sender.publicKey, totalDepositedAmount);
|
|
5534
5624
|
prepareInstructions.push(...nativeInstructions);
|
|
5535
5625
|
}
|
|
5536
5626
|
return {
|
|
@@ -5728,10 +5818,7 @@ var SolanaStreamClient = class extends BaseStreamClient {
|
|
|
5728
5818
|
async withdraw({ id, amount = WITHDRAW_AVAILABLE_AMOUNT }, extParams) {
|
|
5729
5819
|
const { invoker, customInstructions } = extParams;
|
|
5730
5820
|
common.assertHasPublicKey(invoker, "Invoker's PublicKey is not available, check passed wallet adapter!");
|
|
5731
|
-
const ixs = await this.prepareWithdrawInstructions(
|
|
5732
|
-
{ id, amount },
|
|
5733
|
-
extParams
|
|
5734
|
-
);
|
|
5821
|
+
const ixs = await this.prepareWithdrawInstructions({ id, amount }, extParams);
|
|
5735
5822
|
const metadata = new web3_js.PublicKey(id);
|
|
5736
5823
|
await this.applyCustomAfterInstructions(ixs, customInstructions, metadata);
|
|
5737
5824
|
const { tx, hash, context } = await solana.prepareTransaction(this.connection, ixs, invoker.publicKey);
|
|
@@ -6235,17 +6322,26 @@ var SolanaStreamClient = class extends BaseStreamClient {
|
|
|
6235
6322
|
const streamPublicKey = new web3_js.PublicKey(data.id);
|
|
6236
6323
|
const escrow = await this.connection.getAccountInfo(streamPublicKey);
|
|
6237
6324
|
common.invariant(escrow, "Couldn't get account info");
|
|
6325
|
+
const { sender: senderPublicKey } = decodeStream(escrow.data);
|
|
6326
|
+
const isAlignedUnlock = this.isAlignedUnlock(streamPublicKey, senderPublicKey);
|
|
6327
|
+
if (isAlignedUnlock && (data.enableAutomaticWithdrawal !== void 0 || data.amountPerPeriod !== void 0)) {
|
|
6328
|
+
throw new Error("Automatic withdrawal and rate update are not possible in price-based vesting!");
|
|
6329
|
+
}
|
|
6238
6330
|
const ixs = solana.prepareBaseInstructions(this.connection, {
|
|
6239
6331
|
computePrice,
|
|
6240
6332
|
computeLimit
|
|
6241
6333
|
});
|
|
6242
6334
|
ixs.push(
|
|
6243
|
-
await
|
|
6335
|
+
await (isAlignedUnlock ? this.alignedProxyProgram.methods.updateContract({
|
|
6336
|
+
transferableBySender: data.transferableBySender ?? null,
|
|
6337
|
+
transferableByRecipient: data.transferableByRecipient ?? null,
|
|
6338
|
+
cancelableBySender: data.cancelableBySender ?? null
|
|
6339
|
+
}).accounts({ sender: invoker.publicKey, streamMetadata: streamPublicKey, withdrawor: WITHDRAWOR_PUBLIC_KEY }).accountsPartial({ streamflowProgram: this.programId }).instruction() : updateStreamInstruction(data, this.programId, {
|
|
6244
6340
|
authority: invoker.publicKey,
|
|
6245
6341
|
metadata: streamPublicKey,
|
|
6246
6342
|
withdrawor: WITHDRAWOR_PUBLIC_KEY,
|
|
6247
6343
|
systemProgram: web3_js.SystemProgram.programId
|
|
6248
|
-
})
|
|
6344
|
+
}))
|
|
6249
6345
|
);
|
|
6250
6346
|
return ixs;
|
|
6251
6347
|
}
|
|
@@ -6290,8 +6386,8 @@ var SolanaStreamClient = class extends BaseStreamClient {
|
|
|
6290
6386
|
return extractSolanaErrorCode(err.toString() ?? "Unknown error!", logs);
|
|
6291
6387
|
}
|
|
6292
6388
|
/**
|
|
6293
|
-
|
|
6294
|
-
|
|
6389
|
+
* Utility function that checks whether the associated stream address is an aligned unlock contract, indicated by whether the sender/creator is a PDA
|
|
6390
|
+
*/
|
|
6295
6391
|
isAlignedUnlock(streamPublicKey, senderPublicKey) {
|
|
6296
6392
|
const pda = deriveContractPDA(this.alignedProxyProgram.programId, streamPublicKey);
|
|
6297
6393
|
return senderPublicKey.equals(pda);
|