@streamflow/stream 11.1.0 → 11.2.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.cjs +313 -97
- package/dist/cjs/index.cjs.map +1 -1
- package/dist/cjs/index.d.cts +1 -1
- package/dist/cjs/solana/index.cjs +313 -97
- package/dist/cjs/solana/index.cjs.map +1 -1
- package/dist/cjs/solana/index.d.cts +65 -4
- package/dist/esm/index.d.ts +1 -1
- package/dist/esm/index.js +311 -99
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/solana/descriptor/idl/streamflow.json +1440 -0
- package/dist/esm/solana/index.d.ts +65 -4
- package/dist/esm/solana/index.js +311 -99
- package/dist/esm/solana/index.js.map +1 -1
- package/package.json +4 -4
package/dist/esm/solana/index.js
CHANGED
|
@@ -2,7 +2,7 @@ import BN3 from 'bn.js';
|
|
|
2
2
|
import bs58 from 'bs58';
|
|
3
3
|
import { Buffer } from 'buffer';
|
|
4
4
|
import { NATIVE_MINT, ASSOCIATED_TOKEN_PROGRAM_ID } from '@solana/spl-token';
|
|
5
|
-
import { PublicKey, TransactionInstruction, Connection, Keypair,
|
|
5
|
+
import { PublicKey, TransactionInstruction, Connection, Keypair, SystemProgram, SYSVAR_RENT_PUBKEY, TransactionMessage, VersionedTransaction } from '@solana/web3.js';
|
|
6
6
|
import { ICluster, getNumberFromBN, isSignerKeypair, isSignerWallet, executeTransaction, ContractError, buildSendThrottler, assertHasPublicKey, prepareWrappedAccount, prepareTransaction, signAndExecuteTransaction, invariant, getMintAndProgram, prepareBaseInstructions, getBN, ata, createVersionedTransaction, executeMultipleTransactions, getMultipleAccountsInfoBatched, getProgramAccounts, isDev, checkOrCreateAtaBatch, pk } from '@streamflow/common';
|
|
7
7
|
export { ContractError, ICluster, getBN, getNumberFromBN } from '@streamflow/common';
|
|
8
8
|
import * as borsh from 'borsh';
|
|
@@ -154,12 +154,16 @@ var Contract = class {
|
|
|
154
154
|
this.canTopup = stream.canTopup;
|
|
155
155
|
this.name = stream.name;
|
|
156
156
|
this.withdrawalFrequency = stream.withdrawFrequency.toNumber();
|
|
157
|
+
this.isPda = stream.isPda;
|
|
158
|
+
this.nonce = stream.nonce;
|
|
157
159
|
this.closed = stream.closed;
|
|
158
160
|
this.currentPauseStart = stream.currentPauseStart.toNumber();
|
|
159
161
|
this.pauseCumulative = stream.pauseCumulative;
|
|
160
162
|
this.lastRateChangeTime = stream.lastRateChangeTime.toNumber();
|
|
161
163
|
this.fundsUnlockedAtLastRateChange = stream.fundsUnlockedAtLastRateChange;
|
|
162
164
|
this.oldMetadata = stream.oldMetadata;
|
|
165
|
+
this.payer = stream.payer.toBase58();
|
|
166
|
+
this.bump = stream.bump;
|
|
163
167
|
this.type = buildStreamType(this);
|
|
164
168
|
this.isAligned = false;
|
|
165
169
|
}
|
|
@@ -214,7 +218,7 @@ var STREAM_STRUCT_OFFSETS = {
|
|
|
214
218
|
sender: STREAM_STRUCT_OFFSET_SENDER,
|
|
215
219
|
closed: STREAM_STRUCT_OFFSET_CLOSED
|
|
216
220
|
};
|
|
217
|
-
var CREATE_PARAMS_PADDING =
|
|
221
|
+
var CREATE_PARAMS_PADDING = 121;
|
|
218
222
|
var PROGRAM_ID = {
|
|
219
223
|
[ICluster.Devnet]: "HqDGZjaVRXJ9MGRQEw7qDc2rAr6iH1n1kAQdCZaCMfMZ",
|
|
220
224
|
[ICluster.Mainnet]: "strmRqUCoQUgGUan5YhzUZa6KqdzwX5L6FpUxfmKg5m",
|
|
@@ -245,6 +249,7 @@ var TEST_ORACLE_DISCRIMINATOR = [198, 49, 63, 134, 232, 251, 168, 28];
|
|
|
245
249
|
var CONTRACT_SEED = Buffer.from("contract", "utf-8");
|
|
246
250
|
var ESCROW_SEED = Buffer.from("strm", "utf-8");
|
|
247
251
|
var TEST_ORACLE_SEED = Buffer.from("test-oracle", "utf-8");
|
|
252
|
+
var METADATA_SEED = Buffer.from("strm-met", "utf-8");
|
|
248
253
|
var REPOPULATED_METADATA_SEED = Buffer.from("strm-rep", "utf-8");
|
|
249
254
|
var STREAMFLOW_TREASURY_PUBLIC_KEY = new PublicKey("5SEpbdjFK5FxwTvfsGMXVQTD2v4M2c5tyRTxhdsPkgDw");
|
|
250
255
|
var WITHDRAWOR = "wdrwhnCv4pzW8beKsbPa4S2UDZrXenjg16KJdKSpb5u";
|
|
@@ -348,7 +353,9 @@ var streamLayout = BufferLayout.struct([
|
|
|
348
353
|
BufferLayout.blob(4, "ghost"),
|
|
349
354
|
BufferLayout.u8("pausable"),
|
|
350
355
|
BufferLayout.u8("can_update_rate"),
|
|
351
|
-
BufferLayout.blob(4, "
|
|
356
|
+
BufferLayout.blob(4, "ghost2"),
|
|
357
|
+
BufferLayout.u8("is_pda"),
|
|
358
|
+
BufferLayout.u32("nonce"),
|
|
352
359
|
BufferLayout.seq(BufferLayout.u8(), CREATE_PARAMS_PADDING, "create_params_padding"),
|
|
353
360
|
BufferLayout.u8("closed"),
|
|
354
361
|
BufferLayout.blob(8, "current_pause_start"),
|
|
@@ -359,7 +366,9 @@ var streamLayout = BufferLayout.struct([
|
|
|
359
366
|
BufferLayout.u8("creation_fee_claimed"),
|
|
360
367
|
BufferLayout.u32("auto_claim_fee"),
|
|
361
368
|
BufferLayout.u8("auto_claim_fee_claimed"),
|
|
362
|
-
BufferLayout.blob(32, "old_metadata")
|
|
369
|
+
BufferLayout.blob(32, "old_metadata"),
|
|
370
|
+
BufferLayout.blob(32, "payer"),
|
|
371
|
+
BufferLayout.u8("bump")
|
|
363
372
|
]);
|
|
364
373
|
BufferLayout.struct([
|
|
365
374
|
BufferLayout.blob(32, "pubkey"),
|
|
@@ -388,6 +397,25 @@ var createStreamLayout = BufferLayout.struct([
|
|
|
388
397
|
BufferLayout.u8("_can_update_rate_discriminator"),
|
|
389
398
|
BufferLayout.u8("can_update_rate")
|
|
390
399
|
]);
|
|
400
|
+
var createStreamV2Layout = BufferLayout.struct([
|
|
401
|
+
BufferLayout.blob(8, "start_time"),
|
|
402
|
+
BufferLayout.blob(8, "net_amount_deposited"),
|
|
403
|
+
BufferLayout.blob(8, "period"),
|
|
404
|
+
BufferLayout.blob(8, "amount_per_period"),
|
|
405
|
+
BufferLayout.blob(8, "cliff"),
|
|
406
|
+
BufferLayout.blob(8, "cliff_amount"),
|
|
407
|
+
BufferLayout.u8("cancelable_by_sender"),
|
|
408
|
+
BufferLayout.u8("cancelable_by_recipient"),
|
|
409
|
+
BufferLayout.u8("automatic_withdrawal"),
|
|
410
|
+
BufferLayout.u8("transferable_by_sender"),
|
|
411
|
+
BufferLayout.u8("transferable_by_recipient"),
|
|
412
|
+
BufferLayout.u8("can_topup"),
|
|
413
|
+
BufferLayout.blob(64, "stream_name"),
|
|
414
|
+
BufferLayout.blob(8, "withdraw_frequency"),
|
|
415
|
+
BufferLayout.u8("pausable"),
|
|
416
|
+
BufferLayout.u8("can_update_rate"),
|
|
417
|
+
BufferLayout.u32("nonce")
|
|
418
|
+
]);
|
|
391
419
|
var createUncheckedStreamLayout = BufferLayout.struct([
|
|
392
420
|
BufferLayout.blob(8, "start_time"),
|
|
393
421
|
BufferLayout.blob(8, "net_amount_deposited"),
|
|
@@ -408,6 +436,27 @@ var createUncheckedStreamLayout = BufferLayout.struct([
|
|
|
408
436
|
BufferLayout.u8("pausable"),
|
|
409
437
|
BufferLayout.u8("can_update_rate")
|
|
410
438
|
]);
|
|
439
|
+
var createUncheckedStreamV2Layout = BufferLayout.struct([
|
|
440
|
+
BufferLayout.blob(8, "start_time"),
|
|
441
|
+
BufferLayout.blob(8, "net_amount_deposited"),
|
|
442
|
+
BufferLayout.blob(8, "period"),
|
|
443
|
+
BufferLayout.blob(8, "amount_per_period"),
|
|
444
|
+
BufferLayout.blob(8, "cliff"),
|
|
445
|
+
BufferLayout.blob(8, "cliff_amount"),
|
|
446
|
+
BufferLayout.u8("cancelable_by_sender"),
|
|
447
|
+
BufferLayout.u8("cancelable_by_recipient"),
|
|
448
|
+
BufferLayout.u8("automatic_withdrawal"),
|
|
449
|
+
BufferLayout.u8("transferable_by_sender"),
|
|
450
|
+
BufferLayout.u8("transferable_by_recipient"),
|
|
451
|
+
BufferLayout.u8("can_topup"),
|
|
452
|
+
BufferLayout.blob(64, "stream_name"),
|
|
453
|
+
BufferLayout.blob(8, "withdraw_frequency"),
|
|
454
|
+
BufferLayout.blob(32, "recipient"),
|
|
455
|
+
BufferLayout.blob(32, "partner"),
|
|
456
|
+
BufferLayout.u8("pausable"),
|
|
457
|
+
BufferLayout.u8("can_update_rate"),
|
|
458
|
+
BufferLayout.u32("nonce")
|
|
459
|
+
]);
|
|
411
460
|
var withdrawStreamLayout = BufferLayout.struct([
|
|
412
461
|
BufferLayout.blob(8, "amount")
|
|
413
462
|
]);
|
|
@@ -525,12 +574,16 @@ var decodeStream = (buf) => {
|
|
|
525
574
|
canTopup: Boolean(raw.can_topup),
|
|
526
575
|
name: decoder.decode(raw.stream_name),
|
|
527
576
|
withdrawFrequency: new BN3(raw.withdraw_frequency, LE),
|
|
577
|
+
isPda: Boolean(raw.is_pda),
|
|
578
|
+
nonce: raw.nonce,
|
|
528
579
|
closed: Boolean(raw.closed),
|
|
529
580
|
currentPauseStart: new BN3(raw.current_pause_start, LE),
|
|
530
581
|
pauseCumulative: new BN3(raw.pause_cumulative, LE),
|
|
531
582
|
lastRateChangeTime: new BN3(raw.last_rate_change_time, LE),
|
|
532
583
|
fundsUnlockedAtLastRateChange: new BN3(raw.funds_unlocked_at_last_rate_change, LE),
|
|
533
|
-
oldMetadata: new PublicKey(raw.old_metadata)
|
|
584
|
+
oldMetadata: new PublicKey(raw.old_metadata),
|
|
585
|
+
payer: new PublicKey(raw.payer),
|
|
586
|
+
bump: raw.bump
|
|
534
587
|
};
|
|
535
588
|
};
|
|
536
589
|
async function signAllTransactionWithRecipients(sender, items) {
|
|
@@ -721,6 +774,133 @@ var createUncheckedStreamInstruction = async (data, programId, accounts) => {
|
|
|
721
774
|
data: bufferData
|
|
722
775
|
});
|
|
723
776
|
};
|
|
777
|
+
var createStreamV2Instruction = async (data, programId, accounts) => {
|
|
778
|
+
const keys = [
|
|
779
|
+
{ pubkey: accounts.sender, isSigner: true, isWritable: true },
|
|
780
|
+
{ pubkey: accounts.senderTokens, isSigner: false, isWritable: true },
|
|
781
|
+
{ pubkey: accounts.recipient, isSigner: false, isWritable: true },
|
|
782
|
+
{ pubkey: accounts.metadata, isSigner: false, isWritable: true },
|
|
783
|
+
{ pubkey: accounts.escrowTokens, isSigner: false, isWritable: true },
|
|
784
|
+
{ pubkey: accounts.recipientTokens, isSigner: false, isWritable: true },
|
|
785
|
+
{
|
|
786
|
+
pubkey: accounts.streamflowTreasury,
|
|
787
|
+
isSigner: false,
|
|
788
|
+
isWritable: true
|
|
789
|
+
},
|
|
790
|
+
{
|
|
791
|
+
pubkey: accounts.streamflowTreasuryTokens,
|
|
792
|
+
isSigner: false,
|
|
793
|
+
isWritable: true
|
|
794
|
+
},
|
|
795
|
+
{ pubkey: accounts.withdrawor, isSigner: false, isWritable: true },
|
|
796
|
+
{ pubkey: accounts.partner, isSigner: false, isWritable: true },
|
|
797
|
+
{ pubkey: accounts.partnerTokens, isSigner: false, isWritable: true },
|
|
798
|
+
{ pubkey: accounts.mint, isSigner: false, isWritable: false },
|
|
799
|
+
{ pubkey: accounts.feeOracle, isSigner: false, isWritable: false },
|
|
800
|
+
{ pubkey: accounts.rent, isSigner: false, isWritable: false },
|
|
801
|
+
{ pubkey: accounts.timelockProgram, isSigner: false, isWritable: false },
|
|
802
|
+
{ pubkey: accounts.tokenProgram, isSigner: false, isWritable: false },
|
|
803
|
+
{
|
|
804
|
+
pubkey: accounts.associatedTokenProgram,
|
|
805
|
+
isSigner: false,
|
|
806
|
+
isWritable: false
|
|
807
|
+
},
|
|
808
|
+
{ pubkey: accounts.systemProgram, isSigner: false, isWritable: false }
|
|
809
|
+
];
|
|
810
|
+
let bufferData = Buffer.alloc(createStreamV2Layout.span);
|
|
811
|
+
const encodedUIntArray = new TextEncoder().encode(data.name);
|
|
812
|
+
const streamNameBuffer = Buffer.alloc(64).fill(encodedUIntArray, 0, encodedUIntArray.byteLength);
|
|
813
|
+
const nonceBuffer = Buffer.alloc(4);
|
|
814
|
+
nonceBuffer.writeUInt32LE(data.nonce);
|
|
815
|
+
const decodedData = {
|
|
816
|
+
start_time: data.start.toArrayLike(Buffer, "le", 8),
|
|
817
|
+
net_amount_deposited: data.depositedAmount.toArrayLike(Buffer, "le", 8),
|
|
818
|
+
period: data.period.toArrayLike(Buffer, "le", 8),
|
|
819
|
+
amount_per_period: data.amountPerPeriod.toArrayLike(Buffer, "le", 8),
|
|
820
|
+
cliff: data.cliff.toArrayLike(Buffer, "le", 8),
|
|
821
|
+
cliff_amount: data.cliffAmount.toArrayLike(Buffer, "le", 8),
|
|
822
|
+
cancelable_by_sender: Number(data.cancelableBySender),
|
|
823
|
+
cancelable_by_recipient: Number(data.cancelableByRecipient),
|
|
824
|
+
automatic_withdrawal: Number(data.automaticWithdrawal),
|
|
825
|
+
transferable_by_sender: Number(data.transferableBySender),
|
|
826
|
+
transferable_by_recipient: Number(data.transferableByRecipient),
|
|
827
|
+
can_topup: Number(data.canTopup),
|
|
828
|
+
stream_name: streamNameBuffer,
|
|
829
|
+
withdraw_frequency: data.withdrawFrequency.toArrayLike(Buffer, "le", 8),
|
|
830
|
+
pausable: Number(data.canPause),
|
|
831
|
+
can_update_rate: Number(data.canUpdateRate),
|
|
832
|
+
nonce: nonceBuffer
|
|
833
|
+
};
|
|
834
|
+
const encodeLength = createStreamV2Layout.encode(decodedData, bufferData);
|
|
835
|
+
bufferData = bufferData.slice(0, encodeLength);
|
|
836
|
+
bufferData = Buffer.concat([
|
|
837
|
+
Buffer.from(await sha256.digest("global:create_v2")).slice(0, 8),
|
|
838
|
+
bufferData,
|
|
839
|
+
Buffer.alloc(10)
|
|
840
|
+
]);
|
|
841
|
+
return new TransactionInstruction({
|
|
842
|
+
keys,
|
|
843
|
+
programId,
|
|
844
|
+
data: bufferData
|
|
845
|
+
});
|
|
846
|
+
};
|
|
847
|
+
var createUncheckedStreamV2Instruction = async (data, programId, accounts) => {
|
|
848
|
+
const keys = [
|
|
849
|
+
{ pubkey: accounts.sender, isSigner: true, isWritable: true },
|
|
850
|
+
{ pubkey: accounts.senderTokens, isSigner: false, isWritable: true },
|
|
851
|
+
{ pubkey: accounts.metadata, isSigner: false, isWritable: true },
|
|
852
|
+
{ pubkey: accounts.escrowTokens, isSigner: false, isWritable: true },
|
|
853
|
+
{ pubkey: accounts.withdrawor, isSigner: false, isWritable: true },
|
|
854
|
+
{ pubkey: accounts.mint, isSigner: false, isWritable: false },
|
|
855
|
+
{ pubkey: accounts.feeOracle, isSigner: false, isWritable: false },
|
|
856
|
+
{ pubkey: accounts.rent, isSigner: false, isWritable: false },
|
|
857
|
+
{ pubkey: accounts.timelockProgram, isSigner: false, isWritable: false },
|
|
858
|
+
{ pubkey: accounts.tokenProgram, isSigner: false, isWritable: false },
|
|
859
|
+
{ pubkey: accounts.systemProgram, isSigner: false, isWritable: false }
|
|
860
|
+
];
|
|
861
|
+
if (accounts.payer) {
|
|
862
|
+
keys.unshift({
|
|
863
|
+
pubkey: accounts.payer,
|
|
864
|
+
isSigner: true,
|
|
865
|
+
isWritable: true
|
|
866
|
+
});
|
|
867
|
+
}
|
|
868
|
+
let bufferData = Buffer.alloc(createUncheckedStreamV2Layout.span);
|
|
869
|
+
const encodedUIntArray = new TextEncoder().encode(data.name);
|
|
870
|
+
const streamNameBuffer = Buffer.alloc(64).fill(encodedUIntArray, 0, encodedUIntArray.byteLength);
|
|
871
|
+
const nonceBuffer = Buffer.alloc(4);
|
|
872
|
+
nonceBuffer.writeUInt32LE(data.nonce);
|
|
873
|
+
const decodedData = {
|
|
874
|
+
start_time: data.start.toArrayLike(Buffer, "le", 8),
|
|
875
|
+
net_amount_deposited: data.depositedAmount.toArrayLike(Buffer, "le", 8),
|
|
876
|
+
period: data.period.toArrayLike(Buffer, "le", 8),
|
|
877
|
+
amount_per_period: data.amountPerPeriod.toArrayLike(Buffer, "le", 8),
|
|
878
|
+
cliff: data.cliff.toArrayLike(Buffer, "le", 8),
|
|
879
|
+
cliff_amount: data.cliffAmount.toArrayLike(Buffer, "le", 8),
|
|
880
|
+
cancelable_by_sender: Number(data.cancelableBySender),
|
|
881
|
+
cancelable_by_recipient: Number(data.cancelableByRecipient),
|
|
882
|
+
automatic_withdrawal: Number(data.automaticWithdrawal),
|
|
883
|
+
transferable_by_sender: Number(data.transferableBySender),
|
|
884
|
+
transferable_by_recipient: Number(data.transferableByRecipient),
|
|
885
|
+
can_topup: Number(data.canTopup),
|
|
886
|
+
stream_name: streamNameBuffer,
|
|
887
|
+
withdraw_frequency: data.withdrawFrequency.toArrayLike(Buffer, "le", 8),
|
|
888
|
+
recipient: data.recipient.toBuffer(),
|
|
889
|
+
partner: data.partner.toBuffer(),
|
|
890
|
+
pausable: Number(data.canPause),
|
|
891
|
+
can_update_rate: Number(data.canUpdateRate),
|
|
892
|
+
nonce: nonceBuffer
|
|
893
|
+
};
|
|
894
|
+
const encodeLength = createUncheckedStreamV2Layout.encode(decodedData, bufferData);
|
|
895
|
+
bufferData = bufferData.slice(0, encodeLength);
|
|
896
|
+
const digest = accounts.payer ? await sha256.digest("global:create_unchecked_with_payer_v2") : await sha256.digest("global:create_unchecked_v2");
|
|
897
|
+
bufferData = Buffer.concat([Buffer.from(digest).slice(0, 8), bufferData, Buffer.alloc(10)]);
|
|
898
|
+
return new TransactionInstruction({
|
|
899
|
+
keys,
|
|
900
|
+
programId,
|
|
901
|
+
data: bufferData
|
|
902
|
+
});
|
|
903
|
+
};
|
|
724
904
|
var withdrawStreamInstruction = async (amount, programId, {
|
|
725
905
|
authority,
|
|
726
906
|
recipient,
|
|
@@ -2513,6 +2693,12 @@ var deriveEscrowPDA = (programId, streamMetadata) => {
|
|
|
2513
2693
|
var deriveTestOraclePDA = (programId, mint, creator) => {
|
|
2514
2694
|
return PublicKey.findProgramAddressSync([TEST_ORACLE_SEED, mint.toBuffer(), creator.toBuffer()], programId)[0];
|
|
2515
2695
|
};
|
|
2696
|
+
var deriveStreamMetadataPDA = (programId, mint, sender, nonce) => {
|
|
2697
|
+
return PublicKey.findProgramAddressSync(
|
|
2698
|
+
[METADATA_SEED, mint.toBuffer(), sender.toBuffer(), new BN3(nonce).toArrayLike(Buffer, "le", 4)],
|
|
2699
|
+
programId
|
|
2700
|
+
)[0];
|
|
2701
|
+
};
|
|
2516
2702
|
var deriveRepopulatedMetadataPDA = (programId, streamMetadata) => {
|
|
2517
2703
|
return PublicKey.findProgramAddressSync([REPOPULATED_METADATA_SEED, streamMetadata.toBuffer()], programId)[0];
|
|
2518
2704
|
};
|
|
@@ -2571,6 +2757,7 @@ async function toDecodedStream(schema) {
|
|
|
2571
2757
|
const sender = pk(schema.sender);
|
|
2572
2758
|
const recipient = pk(schema.recipient);
|
|
2573
2759
|
const partner = schema.partner ? pk(schema.partner) : sender;
|
|
2760
|
+
const payer = schema.payer ? pk(schema.payer) : PublicKey.default;
|
|
2574
2761
|
const [senderTokens, recipientTokens, partnerTokens, streamflowTreasuryTokens] = await Promise.all([
|
|
2575
2762
|
ata(mint, sender),
|
|
2576
2763
|
ata(mint, recipient),
|
|
@@ -2615,12 +2802,16 @@ async function toDecodedStream(schema) {
|
|
|
2615
2802
|
canTopup: schema.canTopup,
|
|
2616
2803
|
name: schema.name,
|
|
2617
2804
|
withdrawFrequency: toBN(schema.autoClaimPeriod),
|
|
2805
|
+
isPda: schema.isPda,
|
|
2806
|
+
nonce: schema.nonce ? schema.nonce : 0,
|
|
2618
2807
|
closed: schema.isClosed,
|
|
2619
2808
|
currentPauseStart: toBN(0),
|
|
2620
2809
|
pauseCumulative: toBN(schema.pauseCumulative),
|
|
2621
2810
|
lastRateChangeTime: toBN(isoToUnix(schema.lastRateUpdateDt)),
|
|
2622
2811
|
fundsUnlockedAtLastRateChange: toBN(schema.amountUnlockedAtLastRateUpdate),
|
|
2623
|
-
oldMetadata: PublicKey.default
|
|
2812
|
+
oldMetadata: PublicKey.default,
|
|
2813
|
+
payer,
|
|
2814
|
+
bump: schema.bump ? schema.bump : 0
|
|
2624
2815
|
};
|
|
2625
2816
|
}
|
|
2626
2817
|
function toPrecisionBN(value, precision = ALIGNED_PRECISION_FACTOR_POW2) {
|
|
@@ -2948,7 +3139,8 @@ var SolanaStreamClient = class {
|
|
|
2948
3139
|
automaticWithdrawal = false,
|
|
2949
3140
|
withdrawalFrequency = 0,
|
|
2950
3141
|
partner,
|
|
2951
|
-
tokenProgramId: streamTokenProgramId
|
|
3142
|
+
tokenProgramId: streamTokenProgramId,
|
|
3143
|
+
nonce
|
|
2952
3144
|
}, { sender, metadataPubKeys, isNative = false, computePrice, computeLimit }) {
|
|
2953
3145
|
assertHasPublicKey(sender, "Sender's PublicKey is not available, check passed wallet adapter!");
|
|
2954
3146
|
const ixs = prepareBaseInstructions(this.connection, {
|
|
@@ -2957,7 +3149,13 @@ var SolanaStreamClient = class {
|
|
|
2957
3149
|
});
|
|
2958
3150
|
const mintPublicKey = isNative ? NATIVE_MINT : new PublicKey(mint);
|
|
2959
3151
|
const recipientPublicKey = new PublicKey(recipient);
|
|
2960
|
-
|
|
3152
|
+
let metadata;
|
|
3153
|
+
let metadataPubKey;
|
|
3154
|
+
if (nonce != null) {
|
|
3155
|
+
metadataPubKey = deriveStreamMetadataPDA(this.programId, mintPublicKey, sender.publicKey, nonce);
|
|
3156
|
+
} else {
|
|
3157
|
+
({ metadata, metadataPubKey } = this.getOrCreateStreamMetadata(metadataPubKeys));
|
|
3158
|
+
}
|
|
2961
3159
|
const [escrowTokens] = PublicKey.findProgramAddressSync(
|
|
2962
3160
|
[Buffer.from("strm"), metadataPubKey.toBuffer()],
|
|
2963
3161
|
this.programId
|
|
@@ -2971,49 +3169,49 @@ var SolanaStreamClient = class {
|
|
|
2971
3169
|
const streamflowTreasuryTokens = await ata(mintPublicKey, STREAMFLOW_TREASURY_PUBLIC_KEY, tokenProgramId);
|
|
2972
3170
|
const partnerPublicKey = partner ? new PublicKey(partner) : sender.publicKey;
|
|
2973
3171
|
const partnerTokens = await ata(mintPublicKey, partnerPublicKey, tokenProgramId);
|
|
2974
|
-
|
|
2975
|
-
|
|
2976
|
-
|
|
2977
|
-
|
|
2978
|
-
|
|
2979
|
-
|
|
2980
|
-
|
|
2981
|
-
|
|
2982
|
-
|
|
2983
|
-
|
|
2984
|
-
|
|
2985
|
-
|
|
2986
|
-
|
|
2987
|
-
|
|
2988
|
-
|
|
2989
|
-
|
|
2990
|
-
|
|
2991
|
-
|
|
2992
|
-
|
|
2993
|
-
|
|
2994
|
-
|
|
2995
|
-
|
|
2996
|
-
|
|
2997
|
-
|
|
2998
|
-
|
|
2999
|
-
|
|
3000
|
-
|
|
3001
|
-
|
|
3002
|
-
|
|
3003
|
-
|
|
3004
|
-
|
|
3005
|
-
|
|
3006
|
-
|
|
3007
|
-
|
|
3008
|
-
|
|
3009
|
-
|
|
3010
|
-
|
|
3011
|
-
|
|
3012
|
-
|
|
3013
|
-
|
|
3014
|
-
|
|
3015
|
-
)
|
|
3016
|
-
|
|
3172
|
+
const accounts = {
|
|
3173
|
+
sender: sender.publicKey,
|
|
3174
|
+
senderTokens,
|
|
3175
|
+
recipient: new PublicKey(recipient),
|
|
3176
|
+
metadata: metadataPubKey,
|
|
3177
|
+
escrowTokens,
|
|
3178
|
+
recipientTokens,
|
|
3179
|
+
streamflowTreasury: STREAMFLOW_TREASURY_PUBLIC_KEY,
|
|
3180
|
+
streamflowTreasuryTokens,
|
|
3181
|
+
partner: partnerPublicKey,
|
|
3182
|
+
partnerTokens,
|
|
3183
|
+
mint: new PublicKey(mint),
|
|
3184
|
+
feeOracle: this.feeOraclePublicKey,
|
|
3185
|
+
rent: SYSVAR_RENT_PUBKEY,
|
|
3186
|
+
timelockProgram: this.programId,
|
|
3187
|
+
tokenProgram: tokenProgramId,
|
|
3188
|
+
associatedTokenProgram: ASSOCIATED_TOKEN_PROGRAM_ID,
|
|
3189
|
+
withdrawor: WITHDRAWOR_PUBLIC_KEY,
|
|
3190
|
+
systemProgram: SystemProgram.programId
|
|
3191
|
+
};
|
|
3192
|
+
const baseData = {
|
|
3193
|
+
start: new BN3(start),
|
|
3194
|
+
depositedAmount,
|
|
3195
|
+
period: new BN3(period),
|
|
3196
|
+
amountPerPeriod,
|
|
3197
|
+
cliff: new BN3(cliff),
|
|
3198
|
+
cliffAmount: new BN3(cliffAmount),
|
|
3199
|
+
cancelableBySender,
|
|
3200
|
+
cancelableByRecipient,
|
|
3201
|
+
automaticWithdrawal,
|
|
3202
|
+
transferableBySender,
|
|
3203
|
+
transferableByRecipient,
|
|
3204
|
+
canTopup,
|
|
3205
|
+
canUpdateRate: !!canUpdateRate,
|
|
3206
|
+
canPause: !!canPause,
|
|
3207
|
+
name,
|
|
3208
|
+
withdrawFrequency: new BN3(automaticWithdrawal ? withdrawalFrequency : period)
|
|
3209
|
+
};
|
|
3210
|
+
if (nonce != null) {
|
|
3211
|
+
ixs.push(await createStreamV2Instruction({ ...baseData, nonce }, this.programId, accounts));
|
|
3212
|
+
} else {
|
|
3213
|
+
ixs.push(await createStreamInstruction(baseData, this.programId, accounts));
|
|
3214
|
+
}
|
|
3017
3215
|
return { ixs, metadata, metadataPubKey };
|
|
3018
3216
|
}
|
|
3019
3217
|
/**
|
|
@@ -3073,20 +3271,19 @@ var SolanaStreamClient = class {
|
|
|
3073
3271
|
transferableByRecipient,
|
|
3074
3272
|
automaticWithdrawal = false,
|
|
3075
3273
|
withdrawalFrequency = 0,
|
|
3076
|
-
partner
|
|
3274
|
+
partner,
|
|
3275
|
+
nonce
|
|
3077
3276
|
}, { sender, metadataPubKeys, isNative = false, computePrice, computeLimit }) {
|
|
3078
3277
|
assertHasPublicKey(sender, "Sender's PublicKey is not available, check passed wallet adapter!");
|
|
3079
3278
|
const mintPublicKey = new PublicKey(mint);
|
|
3080
3279
|
const recipientPublicKey = new PublicKey(recipient);
|
|
3081
|
-
|
|
3082
|
-
|
|
3083
|
-
|
|
3084
|
-
|
|
3085
|
-
|
|
3086
|
-
|
|
3087
|
-
|
|
3088
|
-
newAccountPubkey: metadataPubKey
|
|
3089
|
-
});
|
|
3280
|
+
let metadata;
|
|
3281
|
+
let metadataPubKey;
|
|
3282
|
+
if (nonce != null) {
|
|
3283
|
+
metadataPubKey = deriveStreamMetadataPDA(this.programId, mintPublicKey, sender.publicKey, nonce);
|
|
3284
|
+
} else {
|
|
3285
|
+
({ metadata, metadataPubKey } = this.getOrCreateStreamMetadata(metadataPubKeys));
|
|
3286
|
+
}
|
|
3090
3287
|
const [escrowTokens] = PublicKey.findProgramAddressSync(
|
|
3091
3288
|
[Buffer.from("strm"), metadataPubKey.toBuffer()],
|
|
3092
3289
|
this.programId
|
|
@@ -3103,43 +3300,58 @@ var SolanaStreamClient = class {
|
|
|
3103
3300
|
const totalAmount = calculateTotalAmountToDeposit(depositedAmount, totalFee);
|
|
3104
3301
|
ixs.push(...await prepareWrappedAccount(this.connection, sender.publicKey, totalAmount));
|
|
3105
3302
|
}
|
|
3106
|
-
const
|
|
3107
|
-
|
|
3108
|
-
|
|
3109
|
-
|
|
3110
|
-
|
|
3111
|
-
|
|
3112
|
-
|
|
3113
|
-
|
|
3114
|
-
|
|
3115
|
-
|
|
3116
|
-
|
|
3117
|
-
|
|
3118
|
-
|
|
3119
|
-
|
|
3120
|
-
|
|
3121
|
-
|
|
3122
|
-
|
|
3123
|
-
|
|
3124
|
-
|
|
3125
|
-
|
|
3126
|
-
|
|
3127
|
-
|
|
3128
|
-
|
|
3129
|
-
|
|
3130
|
-
|
|
3131
|
-
|
|
3132
|
-
|
|
3133
|
-
|
|
3134
|
-
|
|
3135
|
-
|
|
3136
|
-
|
|
3137
|
-
|
|
3138
|
-
|
|
3139
|
-
|
|
3140
|
-
|
|
3141
|
-
|
|
3142
|
-
|
|
3303
|
+
const accounts = {
|
|
3304
|
+
sender: sender.publicKey,
|
|
3305
|
+
senderTokens,
|
|
3306
|
+
metadata: metadataPubKey,
|
|
3307
|
+
escrowTokens,
|
|
3308
|
+
mint: new PublicKey(mint),
|
|
3309
|
+
feeOracle: this.feeOraclePublicKey,
|
|
3310
|
+
rent: SYSVAR_RENT_PUBKEY,
|
|
3311
|
+
timelockProgram: this.programId,
|
|
3312
|
+
tokenProgram: tokenProgramId,
|
|
3313
|
+
withdrawor: WITHDRAWOR_PUBLIC_KEY,
|
|
3314
|
+
systemProgram: SystemProgram.programId
|
|
3315
|
+
};
|
|
3316
|
+
const baseData = {
|
|
3317
|
+
start: new BN3(start),
|
|
3318
|
+
depositedAmount,
|
|
3319
|
+
period: new BN3(period),
|
|
3320
|
+
amountPerPeriod,
|
|
3321
|
+
cliff: new BN3(cliff),
|
|
3322
|
+
cliffAmount: new BN3(cliffAmount),
|
|
3323
|
+
cancelableBySender,
|
|
3324
|
+
cancelableByRecipient,
|
|
3325
|
+
automaticWithdrawal,
|
|
3326
|
+
transferableBySender,
|
|
3327
|
+
transferableByRecipient,
|
|
3328
|
+
canTopup,
|
|
3329
|
+
canUpdateRate: !!canUpdateRate,
|
|
3330
|
+
canPause: !!canPause,
|
|
3331
|
+
name,
|
|
3332
|
+
withdrawFrequency: new BN3(automaticWithdrawal ? withdrawalFrequency : period),
|
|
3333
|
+
recipient: recipientPublicKey,
|
|
3334
|
+
partner: partnerPublicKey
|
|
3335
|
+
};
|
|
3336
|
+
if (nonce != null) {
|
|
3337
|
+
const createInstruction = await createUncheckedStreamV2Instruction(
|
|
3338
|
+
{ ...baseData, nonce },
|
|
3339
|
+
this.programId,
|
|
3340
|
+
accounts
|
|
3341
|
+
);
|
|
3342
|
+
ixs.push(createInstruction);
|
|
3343
|
+
} else {
|
|
3344
|
+
const rentToExempt = await this.connection.getMinimumBalanceForRentExemption(METADATA_ACC_SIZE);
|
|
3345
|
+
const createMetadataInstruction = SystemProgram.createAccount({
|
|
3346
|
+
programId: this.programId,
|
|
3347
|
+
space: METADATA_ACC_SIZE,
|
|
3348
|
+
lamports: rentToExempt,
|
|
3349
|
+
fromPubkey: sender.publicKey,
|
|
3350
|
+
newAccountPubkey: metadataPubKey
|
|
3351
|
+
});
|
|
3352
|
+
const createInstruction = await createUncheckedStreamInstruction(baseData, this.programId, accounts);
|
|
3353
|
+
ixs.push(createMetadataInstruction, createInstruction);
|
|
3354
|
+
}
|
|
3143
3355
|
return { ixs, metadata, metadataPubKey };
|
|
3144
3356
|
}
|
|
3145
3357
|
/**
|
|
@@ -4543,6 +4755,6 @@ var timelockIDL_default = {
|
|
|
4543
4755
|
]
|
|
4544
4756
|
};
|
|
4545
4757
|
|
|
4546
|
-
export { AIRDROP_AMOUNT, AIRDROP_TEST_TOKEN, ALIGNED_COMPUTE_LIMIT, ALIGNED_PRECISION_FACTOR_POW2 as ALIGNED_PRECISION_FACTOR_POW, ALIGNED_UNLOCKS_PROGRAM_ID, AlignedContract, AlignedProxyErrorCode, CONTRACT_DISCRIMINATOR, CONTRACT_SEED, CREATE_PARAMS_PADDING, Contract, ContractErrorCode, DEFAULT_AUTO_CLAIM_FEE_SOL, DEFAULT_CREATION_FEE_SOL, DEFAULT_STREAMFLOW_FEE, ESCROW_SEED, FEES_METADATA_SEED, FEE_ORACLE_PUBLIC_KEY, MAX_SAFE_UNIX_TIME_VALUE2 as MAX_SAFE_UNIX_TIME_VALUE, ORIGINAL_CONTRACT_SENDER_OFFSET, PARTNERS_SCHEMA, PARTNER_ORACLE_PROGRAM_ID, PARTNER_SCHEMA, PROGRAM_ID, REPOPULATED_METADATA_SEED, 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, StreamDirection, StreamType, TEST_ORACLE_DISCRIMINATOR, TEST_ORACLE_SEED, TX_FINALITY_CONFIRMED, WITHDRAWOR, WITHDRAWOR_PUBLIC_KEY, WITHDRAW_AVAILABLE_AMOUNT, buildStreamType, calculateTotalAmountToDeposit, calculateUnlockedAmount, cancelStreamInstruction, createClient, createStreamInstruction, createUncheckedStreamInstruction, decodeEndTime, decodeStream, deriveContractPDA, deriveEscrowPDA, deriveRepopulatedMetadataPDA, deriveTestOraclePDA, extractSolanaErrorCode, getMetadataKey, handleContractError, isAligned, isCliffCloseToDepositedAmount, isCreateAlignedStreamData, isDynamicLock, isTokenLock, isVesting, sendAndConfirmStreamRawTransaction, signAllTransactionWithRecipients, timelockIDL_default as timelockIDL, topupStreamInstruction, transferStreamInstruction, transformContract, updateStreamInstruction, withdrawStreamInstruction };
|
|
4758
|
+
export { AIRDROP_AMOUNT, AIRDROP_TEST_TOKEN, ALIGNED_COMPUTE_LIMIT, ALIGNED_PRECISION_FACTOR_POW2 as ALIGNED_PRECISION_FACTOR_POW, ALIGNED_UNLOCKS_PROGRAM_ID, AlignedContract, AlignedProxyErrorCode, CONTRACT_DISCRIMINATOR, CONTRACT_SEED, CREATE_PARAMS_PADDING, Contract, ContractErrorCode, DEFAULT_AUTO_CLAIM_FEE_SOL, DEFAULT_CREATION_FEE_SOL, DEFAULT_STREAMFLOW_FEE, ESCROW_SEED, FEES_METADATA_SEED, FEE_ORACLE_PUBLIC_KEY, MAX_SAFE_UNIX_TIME_VALUE2 as MAX_SAFE_UNIX_TIME_VALUE, METADATA_SEED, ORIGINAL_CONTRACT_SENDER_OFFSET, PARTNERS_SCHEMA, PARTNER_ORACLE_PROGRAM_ID, PARTNER_SCHEMA, PROGRAM_ID, REPOPULATED_METADATA_SEED, 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, StreamDirection, StreamType, TEST_ORACLE_DISCRIMINATOR, TEST_ORACLE_SEED, TX_FINALITY_CONFIRMED, WITHDRAWOR, WITHDRAWOR_PUBLIC_KEY, WITHDRAW_AVAILABLE_AMOUNT, buildStreamType, calculateTotalAmountToDeposit, calculateUnlockedAmount, cancelStreamInstruction, createClient, createStreamInstruction, createStreamV2Instruction, createUncheckedStreamInstruction, createUncheckedStreamV2Instruction, decodeEndTime, decodeStream, deriveContractPDA, deriveEscrowPDA, deriveRepopulatedMetadataPDA, deriveStreamMetadataPDA, deriveTestOraclePDA, extractSolanaErrorCode, getMetadataKey, handleContractError, isAligned, isCliffCloseToDepositedAmount, isCreateAlignedStreamData, isDynamicLock, isTokenLock, isVesting, sendAndConfirmStreamRawTransaction, signAllTransactionWithRecipients, timelockIDL_default as timelockIDL, topupStreamInstruction, transferStreamInstruction, transformContract, updateStreamInstruction, withdrawStreamInstruction };
|
|
4547
4759
|
//# sourceMappingURL=index.js.map
|
|
4548
4760
|
//# sourceMappingURL=index.js.map
|