@streamflow/stream 11.1.0 → 11.2.0-alpha.p342.ccd18cf
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 +315 -97
- package/dist/cjs/index.cjs.map +1 -1
- package/dist/cjs/index.d.cts +1 -1
- package/dist/cjs/solana/index.cjs +315 -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 +313 -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 +313 -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.blob(4, "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.blob(4, "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,14 @@ 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
|
+
const nonceBuffer = Buffer.alloc(4);
|
|
2698
|
+
nonceBuffer.writeUInt32BE(nonce);
|
|
2699
|
+
return PublicKey.findProgramAddressSync(
|
|
2700
|
+
[METADATA_SEED, mint.toBuffer(), sender.toBuffer(), nonceBuffer],
|
|
2701
|
+
programId
|
|
2702
|
+
);
|
|
2703
|
+
};
|
|
2516
2704
|
var deriveRepopulatedMetadataPDA = (programId, streamMetadata) => {
|
|
2517
2705
|
return PublicKey.findProgramAddressSync([REPOPULATED_METADATA_SEED, streamMetadata.toBuffer()], programId)[0];
|
|
2518
2706
|
};
|
|
@@ -2571,6 +2759,7 @@ async function toDecodedStream(schema) {
|
|
|
2571
2759
|
const sender = pk(schema.sender);
|
|
2572
2760
|
const recipient = pk(schema.recipient);
|
|
2573
2761
|
const partner = schema.partner ? pk(schema.partner) : sender;
|
|
2762
|
+
const payer = schema.payer ? pk(schema.payer) : PublicKey.default;
|
|
2574
2763
|
const [senderTokens, recipientTokens, partnerTokens, streamflowTreasuryTokens] = await Promise.all([
|
|
2575
2764
|
ata(mint, sender),
|
|
2576
2765
|
ata(mint, recipient),
|
|
@@ -2615,12 +2804,16 @@ async function toDecodedStream(schema) {
|
|
|
2615
2804
|
canTopup: schema.canTopup,
|
|
2616
2805
|
name: schema.name,
|
|
2617
2806
|
withdrawFrequency: toBN(schema.autoClaimPeriod),
|
|
2807
|
+
isPda: schema.isPda,
|
|
2808
|
+
nonce: schema.nonce ? schema.nonce : 0,
|
|
2618
2809
|
closed: schema.isClosed,
|
|
2619
2810
|
currentPauseStart: toBN(0),
|
|
2620
2811
|
pauseCumulative: toBN(schema.pauseCumulative),
|
|
2621
2812
|
lastRateChangeTime: toBN(isoToUnix(schema.lastRateUpdateDt)),
|
|
2622
2813
|
fundsUnlockedAtLastRateChange: toBN(schema.amountUnlockedAtLastRateUpdate),
|
|
2623
|
-
oldMetadata: PublicKey.default
|
|
2814
|
+
oldMetadata: PublicKey.default,
|
|
2815
|
+
payer,
|
|
2816
|
+
bump: schema.bump ? schema.bump : 0
|
|
2624
2817
|
};
|
|
2625
2818
|
}
|
|
2626
2819
|
function toPrecisionBN(value, precision = ALIGNED_PRECISION_FACTOR_POW2) {
|
|
@@ -2948,7 +3141,8 @@ var SolanaStreamClient = class {
|
|
|
2948
3141
|
automaticWithdrawal = false,
|
|
2949
3142
|
withdrawalFrequency = 0,
|
|
2950
3143
|
partner,
|
|
2951
|
-
tokenProgramId: streamTokenProgramId
|
|
3144
|
+
tokenProgramId: streamTokenProgramId,
|
|
3145
|
+
nonce
|
|
2952
3146
|
}, { sender, metadataPubKeys, isNative = false, computePrice, computeLimit }) {
|
|
2953
3147
|
assertHasPublicKey(sender, "Sender's PublicKey is not available, check passed wallet adapter!");
|
|
2954
3148
|
const ixs = prepareBaseInstructions(this.connection, {
|
|
@@ -2957,7 +3151,13 @@ var SolanaStreamClient = class {
|
|
|
2957
3151
|
});
|
|
2958
3152
|
const mintPublicKey = isNative ? NATIVE_MINT : new PublicKey(mint);
|
|
2959
3153
|
const recipientPublicKey = new PublicKey(recipient);
|
|
2960
|
-
|
|
3154
|
+
let metadata;
|
|
3155
|
+
let metadataPubKey;
|
|
3156
|
+
if (nonce != null) {
|
|
3157
|
+
[metadataPubKey] = deriveStreamMetadataPDA(this.programId, mintPublicKey, sender.publicKey, nonce);
|
|
3158
|
+
} else {
|
|
3159
|
+
({ metadata, metadataPubKey } = this.getOrCreateStreamMetadata(metadataPubKeys));
|
|
3160
|
+
}
|
|
2961
3161
|
const [escrowTokens] = PublicKey.findProgramAddressSync(
|
|
2962
3162
|
[Buffer.from("strm"), metadataPubKey.toBuffer()],
|
|
2963
3163
|
this.programId
|
|
@@ -2971,49 +3171,49 @@ var SolanaStreamClient = class {
|
|
|
2971
3171
|
const streamflowTreasuryTokens = await ata(mintPublicKey, STREAMFLOW_TREASURY_PUBLIC_KEY, tokenProgramId);
|
|
2972
3172
|
const partnerPublicKey = partner ? new PublicKey(partner) : sender.publicKey;
|
|
2973
3173
|
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
|
-
|
|
3174
|
+
const accounts = {
|
|
3175
|
+
sender: sender.publicKey,
|
|
3176
|
+
senderTokens,
|
|
3177
|
+
recipient: new PublicKey(recipient),
|
|
3178
|
+
metadata: metadataPubKey,
|
|
3179
|
+
escrowTokens,
|
|
3180
|
+
recipientTokens,
|
|
3181
|
+
streamflowTreasury: STREAMFLOW_TREASURY_PUBLIC_KEY,
|
|
3182
|
+
streamflowTreasuryTokens,
|
|
3183
|
+
partner: partnerPublicKey,
|
|
3184
|
+
partnerTokens,
|
|
3185
|
+
mint: new PublicKey(mint),
|
|
3186
|
+
feeOracle: this.feeOraclePublicKey,
|
|
3187
|
+
rent: SYSVAR_RENT_PUBKEY,
|
|
3188
|
+
timelockProgram: this.programId,
|
|
3189
|
+
tokenProgram: tokenProgramId,
|
|
3190
|
+
associatedTokenProgram: ASSOCIATED_TOKEN_PROGRAM_ID,
|
|
3191
|
+
withdrawor: WITHDRAWOR_PUBLIC_KEY,
|
|
3192
|
+
systemProgram: SystemProgram.programId
|
|
3193
|
+
};
|
|
3194
|
+
const baseData = {
|
|
3195
|
+
start: new BN3(start),
|
|
3196
|
+
depositedAmount,
|
|
3197
|
+
period: new BN3(period),
|
|
3198
|
+
amountPerPeriod,
|
|
3199
|
+
cliff: new BN3(cliff),
|
|
3200
|
+
cliffAmount: new BN3(cliffAmount),
|
|
3201
|
+
cancelableBySender,
|
|
3202
|
+
cancelableByRecipient,
|
|
3203
|
+
automaticWithdrawal,
|
|
3204
|
+
transferableBySender,
|
|
3205
|
+
transferableByRecipient,
|
|
3206
|
+
canTopup,
|
|
3207
|
+
canUpdateRate: !!canUpdateRate,
|
|
3208
|
+
canPause: !!canPause,
|
|
3209
|
+
name,
|
|
3210
|
+
withdrawFrequency: new BN3(automaticWithdrawal ? withdrawalFrequency : period)
|
|
3211
|
+
};
|
|
3212
|
+
if (nonce != null) {
|
|
3213
|
+
ixs.push(await createStreamV2Instruction({ ...baseData, nonce }, this.programId, accounts));
|
|
3214
|
+
} else {
|
|
3215
|
+
ixs.push(await createStreamInstruction(baseData, this.programId, accounts));
|
|
3216
|
+
}
|
|
3017
3217
|
return { ixs, metadata, metadataPubKey };
|
|
3018
3218
|
}
|
|
3019
3219
|
/**
|
|
@@ -3073,20 +3273,19 @@ var SolanaStreamClient = class {
|
|
|
3073
3273
|
transferableByRecipient,
|
|
3074
3274
|
automaticWithdrawal = false,
|
|
3075
3275
|
withdrawalFrequency = 0,
|
|
3076
|
-
partner
|
|
3276
|
+
partner,
|
|
3277
|
+
nonce
|
|
3077
3278
|
}, { sender, metadataPubKeys, isNative = false, computePrice, computeLimit }) {
|
|
3078
3279
|
assertHasPublicKey(sender, "Sender's PublicKey is not available, check passed wallet adapter!");
|
|
3079
3280
|
const mintPublicKey = new PublicKey(mint);
|
|
3080
3281
|
const recipientPublicKey = new PublicKey(recipient);
|
|
3081
|
-
|
|
3082
|
-
|
|
3083
|
-
|
|
3084
|
-
|
|
3085
|
-
|
|
3086
|
-
|
|
3087
|
-
|
|
3088
|
-
newAccountPubkey: metadataPubKey
|
|
3089
|
-
});
|
|
3282
|
+
let metadata;
|
|
3283
|
+
let metadataPubKey;
|
|
3284
|
+
if (nonce != null) {
|
|
3285
|
+
[metadataPubKey] = deriveStreamMetadataPDA(this.programId, mintPublicKey, sender.publicKey, nonce);
|
|
3286
|
+
} else {
|
|
3287
|
+
({ metadata, metadataPubKey } = this.getOrCreateStreamMetadata(metadataPubKeys));
|
|
3288
|
+
}
|
|
3090
3289
|
const [escrowTokens] = PublicKey.findProgramAddressSync(
|
|
3091
3290
|
[Buffer.from("strm"), metadataPubKey.toBuffer()],
|
|
3092
3291
|
this.programId
|
|
@@ -3103,43 +3302,58 @@ var SolanaStreamClient = class {
|
|
|
3103
3302
|
const totalAmount = calculateTotalAmountToDeposit(depositedAmount, totalFee);
|
|
3104
3303
|
ixs.push(...await prepareWrappedAccount(this.connection, sender.publicKey, totalAmount));
|
|
3105
3304
|
}
|
|
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
|
-
|
|
3305
|
+
const accounts = {
|
|
3306
|
+
sender: sender.publicKey,
|
|
3307
|
+
senderTokens,
|
|
3308
|
+
metadata: metadataPubKey,
|
|
3309
|
+
escrowTokens,
|
|
3310
|
+
mint: new PublicKey(mint),
|
|
3311
|
+
feeOracle: this.feeOraclePublicKey,
|
|
3312
|
+
rent: SYSVAR_RENT_PUBKEY,
|
|
3313
|
+
timelockProgram: this.programId,
|
|
3314
|
+
tokenProgram: tokenProgramId,
|
|
3315
|
+
withdrawor: WITHDRAWOR_PUBLIC_KEY,
|
|
3316
|
+
systemProgram: SystemProgram.programId
|
|
3317
|
+
};
|
|
3318
|
+
const baseData = {
|
|
3319
|
+
start: new BN3(start),
|
|
3320
|
+
depositedAmount,
|
|
3321
|
+
period: new BN3(period),
|
|
3322
|
+
amountPerPeriod,
|
|
3323
|
+
cliff: new BN3(cliff),
|
|
3324
|
+
cliffAmount: new BN3(cliffAmount),
|
|
3325
|
+
cancelableBySender,
|
|
3326
|
+
cancelableByRecipient,
|
|
3327
|
+
automaticWithdrawal,
|
|
3328
|
+
transferableBySender,
|
|
3329
|
+
transferableByRecipient,
|
|
3330
|
+
canTopup,
|
|
3331
|
+
canUpdateRate: !!canUpdateRate,
|
|
3332
|
+
canPause: !!canPause,
|
|
3333
|
+
name,
|
|
3334
|
+
withdrawFrequency: new BN3(automaticWithdrawal ? withdrawalFrequency : period),
|
|
3335
|
+
recipient: recipientPublicKey,
|
|
3336
|
+
partner: partnerPublicKey
|
|
3337
|
+
};
|
|
3338
|
+
if (nonce != null) {
|
|
3339
|
+
const createInstruction = await createUncheckedStreamV2Instruction(
|
|
3340
|
+
{ ...baseData, nonce },
|
|
3341
|
+
this.programId,
|
|
3342
|
+
accounts
|
|
3343
|
+
);
|
|
3344
|
+
ixs.push(createInstruction);
|
|
3345
|
+
} else {
|
|
3346
|
+
const rentToExempt = await this.connection.getMinimumBalanceForRentExemption(METADATA_ACC_SIZE);
|
|
3347
|
+
const createMetadataInstruction = SystemProgram.createAccount({
|
|
3348
|
+
programId: this.programId,
|
|
3349
|
+
space: METADATA_ACC_SIZE,
|
|
3350
|
+
lamports: rentToExempt,
|
|
3351
|
+
fromPubkey: sender.publicKey,
|
|
3352
|
+
newAccountPubkey: metadataPubKey
|
|
3353
|
+
});
|
|
3354
|
+
const createInstruction = await createUncheckedStreamInstruction(baseData, this.programId, accounts);
|
|
3355
|
+
ixs.push(createMetadataInstruction, createInstruction);
|
|
3356
|
+
}
|
|
3143
3357
|
return { ixs, metadata, metadataPubKey };
|
|
3144
3358
|
}
|
|
3145
3359
|
/**
|
|
@@ -4543,6 +4757,6 @@ var timelockIDL_default = {
|
|
|
4543
4757
|
]
|
|
4544
4758
|
};
|
|
4545
4759
|
|
|
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 };
|
|
4760
|
+
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
4761
|
//# sourceMappingURL=index.js.map
|
|
4548
4762
|
//# sourceMappingURL=index.js.map
|