@streamflow/stream 9.0.4 → 9.1.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/dist/cjs/{index-BgGtpOPg.d.cts → index-ByMlPIUq.d.cts} +2 -2
- package/dist/cjs/index.cjs +122 -25
- 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 +122 -25
- 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 +122 -25
- 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 +122 -25
- 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,
|
|
@@ -5518,19 +5618,10 @@ var SolanaStreamClient = class extends BaseStreamClient {
|
|
|
5518
5618
|
recipient: recipientData.recipient
|
|
5519
5619
|
});
|
|
5520
5620
|
}
|
|
5521
|
-
const prepareInstructions = await this.getCreateATAInstructions(
|
|
5522
|
-
[partnerPublicKey],
|
|
5523
|
-
mintPublicKey,
|
|
5524
|
-
sender,
|
|
5525
|
-
true
|
|
5526
|
-
);
|
|
5621
|
+
const prepareInstructions = await this.getCreateATAInstructions([partnerPublicKey], mintPublicKey, sender, true);
|
|
5527
5622
|
if (isNative) {
|
|
5528
5623
|
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
|
-
);
|
|
5624
|
+
const nativeInstructions = await solana.prepareWrappedAccount(this.connection, sender.publicKey, totalDepositedAmount);
|
|
5534
5625
|
prepareInstructions.push(...nativeInstructions);
|
|
5535
5626
|
}
|
|
5536
5627
|
return {
|
|
@@ -5728,10 +5819,7 @@ var SolanaStreamClient = class extends BaseStreamClient {
|
|
|
5728
5819
|
async withdraw({ id, amount = WITHDRAW_AVAILABLE_AMOUNT }, extParams) {
|
|
5729
5820
|
const { invoker, customInstructions } = extParams;
|
|
5730
5821
|
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
|
-
);
|
|
5822
|
+
const ixs = await this.prepareWithdrawInstructions({ id, amount }, extParams);
|
|
5735
5823
|
const metadata = new web3_js.PublicKey(id);
|
|
5736
5824
|
await this.applyCustomAfterInstructions(ixs, customInstructions, metadata);
|
|
5737
5825
|
const { tx, hash, context } = await solana.prepareTransaction(this.connection, ixs, invoker.publicKey);
|
|
@@ -6235,17 +6323,26 @@ var SolanaStreamClient = class extends BaseStreamClient {
|
|
|
6235
6323
|
const streamPublicKey = new web3_js.PublicKey(data.id);
|
|
6236
6324
|
const escrow = await this.connection.getAccountInfo(streamPublicKey);
|
|
6237
6325
|
common.invariant(escrow, "Couldn't get account info");
|
|
6326
|
+
const { sender: senderPublicKey } = decodeStream(escrow.data);
|
|
6327
|
+
const isAlignedUnlock = this.isAlignedUnlock(streamPublicKey, senderPublicKey);
|
|
6328
|
+
if (isAlignedUnlock && (data.enableAutomaticWithdrawal !== void 0 || data.amountPerPeriod !== void 0)) {
|
|
6329
|
+
throw new Error("Automatic withdrawal and rate update are not possible in price-based vesting!");
|
|
6330
|
+
}
|
|
6238
6331
|
const ixs = solana.prepareBaseInstructions(this.connection, {
|
|
6239
6332
|
computePrice,
|
|
6240
6333
|
computeLimit
|
|
6241
6334
|
});
|
|
6242
6335
|
ixs.push(
|
|
6243
|
-
await
|
|
6336
|
+
await (isAlignedUnlock ? this.alignedProxyProgram.methods.updateContract({
|
|
6337
|
+
transferableBySender: data.transferableBySender ?? null,
|
|
6338
|
+
transferableByRecipient: data.transferableByRecipient ?? null,
|
|
6339
|
+
cancelableBySender: data.cancelableBySender ?? null
|
|
6340
|
+
}).accounts({ sender: invoker.publicKey, streamMetadata: streamPublicKey, withdrawor: WITHDRAWOR_PUBLIC_KEY }).accountsPartial({ streamflowProgram: this.programId }).instruction() : updateStreamInstruction(data, this.programId, {
|
|
6244
6341
|
authority: invoker.publicKey,
|
|
6245
6342
|
metadata: streamPublicKey,
|
|
6246
6343
|
withdrawor: WITHDRAWOR_PUBLIC_KEY,
|
|
6247
6344
|
systemProgram: web3_js.SystemProgram.programId
|
|
6248
|
-
})
|
|
6345
|
+
}))
|
|
6249
6346
|
);
|
|
6250
6347
|
return ixs;
|
|
6251
6348
|
}
|
|
@@ -6290,8 +6387,8 @@ var SolanaStreamClient = class extends BaseStreamClient {
|
|
|
6290
6387
|
return extractSolanaErrorCode(err.toString() ?? "Unknown error!", logs);
|
|
6291
6388
|
}
|
|
6292
6389
|
/**
|
|
6293
|
-
|
|
6294
|
-
|
|
6390
|
+
* Utility function that checks whether the associated stream address is an aligned unlock contract, indicated by whether the sender/creator is a PDA
|
|
6391
|
+
*/
|
|
6295
6392
|
isAlignedUnlock(streamPublicKey, senderPublicKey) {
|
|
6296
6393
|
const pda = deriveContractPDA(this.alignedProxyProgram.programId, streamPublicKey);
|
|
6297
6394
|
return senderPublicKey.equals(pda);
|