@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/cjs/index.cjs
CHANGED
|
@@ -180,12 +180,16 @@ var Contract = class {
|
|
|
180
180
|
this.canTopup = stream.canTopup;
|
|
181
181
|
this.name = stream.name;
|
|
182
182
|
this.withdrawalFrequency = stream.withdrawFrequency.toNumber();
|
|
183
|
+
this.isPda = stream.isPda;
|
|
184
|
+
this.nonce = stream.nonce;
|
|
183
185
|
this.closed = stream.closed;
|
|
184
186
|
this.currentPauseStart = stream.currentPauseStart.toNumber();
|
|
185
187
|
this.pauseCumulative = stream.pauseCumulative;
|
|
186
188
|
this.lastRateChangeTime = stream.lastRateChangeTime.toNumber();
|
|
187
189
|
this.fundsUnlockedAtLastRateChange = stream.fundsUnlockedAtLastRateChange;
|
|
188
190
|
this.oldMetadata = stream.oldMetadata;
|
|
191
|
+
this.payer = stream.payer.toBase58();
|
|
192
|
+
this.bump = stream.bump;
|
|
189
193
|
this.type = buildStreamType(this);
|
|
190
194
|
this.isAligned = false;
|
|
191
195
|
}
|
|
@@ -240,7 +244,7 @@ var STREAM_STRUCT_OFFSETS = {
|
|
|
240
244
|
sender: STREAM_STRUCT_OFFSET_SENDER,
|
|
241
245
|
closed: STREAM_STRUCT_OFFSET_CLOSED
|
|
242
246
|
};
|
|
243
|
-
var CREATE_PARAMS_PADDING =
|
|
247
|
+
var CREATE_PARAMS_PADDING = 121;
|
|
244
248
|
var PROGRAM_ID = {
|
|
245
249
|
[common.ICluster.Devnet]: "HqDGZjaVRXJ9MGRQEw7qDc2rAr6iH1n1kAQdCZaCMfMZ",
|
|
246
250
|
[common.ICluster.Mainnet]: "strmRqUCoQUgGUan5YhzUZa6KqdzwX5L6FpUxfmKg5m",
|
|
@@ -271,6 +275,7 @@ var TEST_ORACLE_DISCRIMINATOR = [198, 49, 63, 134, 232, 251, 168, 28];
|
|
|
271
275
|
var CONTRACT_SEED = buffer.Buffer.from("contract", "utf-8");
|
|
272
276
|
var ESCROW_SEED = buffer.Buffer.from("strm", "utf-8");
|
|
273
277
|
var TEST_ORACLE_SEED = buffer.Buffer.from("test-oracle", "utf-8");
|
|
278
|
+
var METADATA_SEED = buffer.Buffer.from("strm-met", "utf-8");
|
|
274
279
|
var REPOPULATED_METADATA_SEED = buffer.Buffer.from("strm-rep", "utf-8");
|
|
275
280
|
var STREAMFLOW_TREASURY_PUBLIC_KEY = new web3_js.PublicKey("5SEpbdjFK5FxwTvfsGMXVQTD2v4M2c5tyRTxhdsPkgDw");
|
|
276
281
|
var WITHDRAWOR = "wdrwhnCv4pzW8beKsbPa4S2UDZrXenjg16KJdKSpb5u";
|
|
@@ -374,7 +379,9 @@ var streamLayout = BufferLayout__namespace.struct([
|
|
|
374
379
|
BufferLayout__namespace.blob(4, "ghost"),
|
|
375
380
|
BufferLayout__namespace.u8("pausable"),
|
|
376
381
|
BufferLayout__namespace.u8("can_update_rate"),
|
|
377
|
-
BufferLayout__namespace.blob(4, "
|
|
382
|
+
BufferLayout__namespace.blob(4, "ghost2"),
|
|
383
|
+
BufferLayout__namespace.u8("is_pda"),
|
|
384
|
+
BufferLayout__namespace.u32("nonce"),
|
|
378
385
|
BufferLayout__namespace.seq(BufferLayout__namespace.u8(), CREATE_PARAMS_PADDING, "create_params_padding"),
|
|
379
386
|
BufferLayout__namespace.u8("closed"),
|
|
380
387
|
BufferLayout__namespace.blob(8, "current_pause_start"),
|
|
@@ -385,7 +392,9 @@ var streamLayout = BufferLayout__namespace.struct([
|
|
|
385
392
|
BufferLayout__namespace.u8("creation_fee_claimed"),
|
|
386
393
|
BufferLayout__namespace.u32("auto_claim_fee"),
|
|
387
394
|
BufferLayout__namespace.u8("auto_claim_fee_claimed"),
|
|
388
|
-
BufferLayout__namespace.blob(32, "old_metadata")
|
|
395
|
+
BufferLayout__namespace.blob(32, "old_metadata"),
|
|
396
|
+
BufferLayout__namespace.blob(32, "payer"),
|
|
397
|
+
BufferLayout__namespace.u8("bump")
|
|
389
398
|
]);
|
|
390
399
|
BufferLayout__namespace.struct([
|
|
391
400
|
BufferLayout__namespace.blob(32, "pubkey"),
|
|
@@ -414,6 +423,25 @@ var createStreamLayout = BufferLayout__namespace.struct([
|
|
|
414
423
|
BufferLayout__namespace.u8("_can_update_rate_discriminator"),
|
|
415
424
|
BufferLayout__namespace.u8("can_update_rate")
|
|
416
425
|
]);
|
|
426
|
+
var createStreamV2Layout = BufferLayout__namespace.struct([
|
|
427
|
+
BufferLayout__namespace.blob(8, "start_time"),
|
|
428
|
+
BufferLayout__namespace.blob(8, "net_amount_deposited"),
|
|
429
|
+
BufferLayout__namespace.blob(8, "period"),
|
|
430
|
+
BufferLayout__namespace.blob(8, "amount_per_period"),
|
|
431
|
+
BufferLayout__namespace.blob(8, "cliff"),
|
|
432
|
+
BufferLayout__namespace.blob(8, "cliff_amount"),
|
|
433
|
+
BufferLayout__namespace.u8("cancelable_by_sender"),
|
|
434
|
+
BufferLayout__namespace.u8("cancelable_by_recipient"),
|
|
435
|
+
BufferLayout__namespace.u8("automatic_withdrawal"),
|
|
436
|
+
BufferLayout__namespace.u8("transferable_by_sender"),
|
|
437
|
+
BufferLayout__namespace.u8("transferable_by_recipient"),
|
|
438
|
+
BufferLayout__namespace.u8("can_topup"),
|
|
439
|
+
BufferLayout__namespace.blob(64, "stream_name"),
|
|
440
|
+
BufferLayout__namespace.blob(8, "withdraw_frequency"),
|
|
441
|
+
BufferLayout__namespace.u8("pausable"),
|
|
442
|
+
BufferLayout__namespace.u8("can_update_rate"),
|
|
443
|
+
BufferLayout__namespace.blob(4, "nonce")
|
|
444
|
+
]);
|
|
417
445
|
var createUncheckedStreamLayout = BufferLayout__namespace.struct([
|
|
418
446
|
BufferLayout__namespace.blob(8, "start_time"),
|
|
419
447
|
BufferLayout__namespace.blob(8, "net_amount_deposited"),
|
|
@@ -434,6 +462,27 @@ var createUncheckedStreamLayout = BufferLayout__namespace.struct([
|
|
|
434
462
|
BufferLayout__namespace.u8("pausable"),
|
|
435
463
|
BufferLayout__namespace.u8("can_update_rate")
|
|
436
464
|
]);
|
|
465
|
+
var createUncheckedStreamV2Layout = BufferLayout__namespace.struct([
|
|
466
|
+
BufferLayout__namespace.blob(8, "start_time"),
|
|
467
|
+
BufferLayout__namespace.blob(8, "net_amount_deposited"),
|
|
468
|
+
BufferLayout__namespace.blob(8, "period"),
|
|
469
|
+
BufferLayout__namespace.blob(8, "amount_per_period"),
|
|
470
|
+
BufferLayout__namespace.blob(8, "cliff"),
|
|
471
|
+
BufferLayout__namespace.blob(8, "cliff_amount"),
|
|
472
|
+
BufferLayout__namespace.u8("cancelable_by_sender"),
|
|
473
|
+
BufferLayout__namespace.u8("cancelable_by_recipient"),
|
|
474
|
+
BufferLayout__namespace.u8("automatic_withdrawal"),
|
|
475
|
+
BufferLayout__namespace.u8("transferable_by_sender"),
|
|
476
|
+
BufferLayout__namespace.u8("transferable_by_recipient"),
|
|
477
|
+
BufferLayout__namespace.u8("can_topup"),
|
|
478
|
+
BufferLayout__namespace.blob(64, "stream_name"),
|
|
479
|
+
BufferLayout__namespace.blob(8, "withdraw_frequency"),
|
|
480
|
+
BufferLayout__namespace.blob(32, "recipient"),
|
|
481
|
+
BufferLayout__namespace.blob(32, "partner"),
|
|
482
|
+
BufferLayout__namespace.u8("pausable"),
|
|
483
|
+
BufferLayout__namespace.u8("can_update_rate"),
|
|
484
|
+
BufferLayout__namespace.blob(4, "nonce")
|
|
485
|
+
]);
|
|
437
486
|
var withdrawStreamLayout = BufferLayout__namespace.struct([
|
|
438
487
|
BufferLayout__namespace.blob(8, "amount")
|
|
439
488
|
]);
|
|
@@ -551,12 +600,16 @@ var decodeStream = (buf) => {
|
|
|
551
600
|
canTopup: Boolean(raw.can_topup),
|
|
552
601
|
name: decoder.decode(raw.stream_name),
|
|
553
602
|
withdrawFrequency: new BN3__default.default(raw.withdraw_frequency, LE),
|
|
603
|
+
isPda: Boolean(raw.is_pda),
|
|
604
|
+
nonce: raw.nonce,
|
|
554
605
|
closed: Boolean(raw.closed),
|
|
555
606
|
currentPauseStart: new BN3__default.default(raw.current_pause_start, LE),
|
|
556
607
|
pauseCumulative: new BN3__default.default(raw.pause_cumulative, LE),
|
|
557
608
|
lastRateChangeTime: new BN3__default.default(raw.last_rate_change_time, LE),
|
|
558
609
|
fundsUnlockedAtLastRateChange: new BN3__default.default(raw.funds_unlocked_at_last_rate_change, LE),
|
|
559
|
-
oldMetadata: new web3_js.PublicKey(raw.old_metadata)
|
|
610
|
+
oldMetadata: new web3_js.PublicKey(raw.old_metadata),
|
|
611
|
+
payer: new web3_js.PublicKey(raw.payer),
|
|
612
|
+
bump: raw.bump
|
|
560
613
|
};
|
|
561
614
|
};
|
|
562
615
|
async function signAllTransactionWithRecipients(sender, items) {
|
|
@@ -747,6 +800,133 @@ var createUncheckedStreamInstruction = async (data, programId, accounts) => {
|
|
|
747
800
|
data: bufferData
|
|
748
801
|
});
|
|
749
802
|
};
|
|
803
|
+
var createStreamV2Instruction = async (data, programId, accounts) => {
|
|
804
|
+
const keys = [
|
|
805
|
+
{ pubkey: accounts.sender, isSigner: true, isWritable: true },
|
|
806
|
+
{ pubkey: accounts.senderTokens, isSigner: false, isWritable: true },
|
|
807
|
+
{ pubkey: accounts.recipient, isSigner: false, isWritable: true },
|
|
808
|
+
{ pubkey: accounts.metadata, isSigner: false, isWritable: true },
|
|
809
|
+
{ pubkey: accounts.escrowTokens, isSigner: false, isWritable: true },
|
|
810
|
+
{ pubkey: accounts.recipientTokens, isSigner: false, isWritable: true },
|
|
811
|
+
{
|
|
812
|
+
pubkey: accounts.streamflowTreasury,
|
|
813
|
+
isSigner: false,
|
|
814
|
+
isWritable: true
|
|
815
|
+
},
|
|
816
|
+
{
|
|
817
|
+
pubkey: accounts.streamflowTreasuryTokens,
|
|
818
|
+
isSigner: false,
|
|
819
|
+
isWritable: true
|
|
820
|
+
},
|
|
821
|
+
{ pubkey: accounts.withdrawor, isSigner: false, isWritable: true },
|
|
822
|
+
{ pubkey: accounts.partner, isSigner: false, isWritable: true },
|
|
823
|
+
{ pubkey: accounts.partnerTokens, isSigner: false, isWritable: true },
|
|
824
|
+
{ pubkey: accounts.mint, isSigner: false, isWritable: false },
|
|
825
|
+
{ pubkey: accounts.feeOracle, isSigner: false, isWritable: false },
|
|
826
|
+
{ pubkey: accounts.rent, isSigner: false, isWritable: false },
|
|
827
|
+
{ pubkey: accounts.timelockProgram, isSigner: false, isWritable: false },
|
|
828
|
+
{ pubkey: accounts.tokenProgram, isSigner: false, isWritable: false },
|
|
829
|
+
{
|
|
830
|
+
pubkey: accounts.associatedTokenProgram,
|
|
831
|
+
isSigner: false,
|
|
832
|
+
isWritable: false
|
|
833
|
+
},
|
|
834
|
+
{ pubkey: accounts.systemProgram, isSigner: false, isWritable: false }
|
|
835
|
+
];
|
|
836
|
+
let bufferData = buffer.Buffer.alloc(createStreamV2Layout.span);
|
|
837
|
+
const encodedUIntArray = new TextEncoder().encode(data.name);
|
|
838
|
+
const streamNameBuffer = buffer.Buffer.alloc(64).fill(encodedUIntArray, 0, encodedUIntArray.byteLength);
|
|
839
|
+
const nonceBuffer = buffer.Buffer.alloc(4);
|
|
840
|
+
nonceBuffer.writeUInt32LE(data.nonce);
|
|
841
|
+
const decodedData = {
|
|
842
|
+
start_time: data.start.toArrayLike(buffer.Buffer, "le", 8),
|
|
843
|
+
net_amount_deposited: data.depositedAmount.toArrayLike(buffer.Buffer, "le", 8),
|
|
844
|
+
period: data.period.toArrayLike(buffer.Buffer, "le", 8),
|
|
845
|
+
amount_per_period: data.amountPerPeriod.toArrayLike(buffer.Buffer, "le", 8),
|
|
846
|
+
cliff: data.cliff.toArrayLike(buffer.Buffer, "le", 8),
|
|
847
|
+
cliff_amount: data.cliffAmount.toArrayLike(buffer.Buffer, "le", 8),
|
|
848
|
+
cancelable_by_sender: Number(data.cancelableBySender),
|
|
849
|
+
cancelable_by_recipient: Number(data.cancelableByRecipient),
|
|
850
|
+
automatic_withdrawal: Number(data.automaticWithdrawal),
|
|
851
|
+
transferable_by_sender: Number(data.transferableBySender),
|
|
852
|
+
transferable_by_recipient: Number(data.transferableByRecipient),
|
|
853
|
+
can_topup: Number(data.canTopup),
|
|
854
|
+
stream_name: streamNameBuffer,
|
|
855
|
+
withdraw_frequency: data.withdrawFrequency.toArrayLike(buffer.Buffer, "le", 8),
|
|
856
|
+
pausable: Number(data.canPause),
|
|
857
|
+
can_update_rate: Number(data.canUpdateRate),
|
|
858
|
+
nonce: nonceBuffer
|
|
859
|
+
};
|
|
860
|
+
const encodeLength = createStreamV2Layout.encode(decodedData, bufferData);
|
|
861
|
+
bufferData = bufferData.slice(0, encodeLength);
|
|
862
|
+
bufferData = buffer.Buffer.concat([
|
|
863
|
+
buffer.Buffer.from(await sha256.digest("global:create_v2")).slice(0, 8),
|
|
864
|
+
bufferData,
|
|
865
|
+
buffer.Buffer.alloc(10)
|
|
866
|
+
]);
|
|
867
|
+
return new web3_js.TransactionInstruction({
|
|
868
|
+
keys,
|
|
869
|
+
programId,
|
|
870
|
+
data: bufferData
|
|
871
|
+
});
|
|
872
|
+
};
|
|
873
|
+
var createUncheckedStreamV2Instruction = async (data, programId, accounts) => {
|
|
874
|
+
const keys = [
|
|
875
|
+
{ pubkey: accounts.sender, isSigner: true, isWritable: true },
|
|
876
|
+
{ pubkey: accounts.senderTokens, isSigner: false, isWritable: true },
|
|
877
|
+
{ pubkey: accounts.metadata, isSigner: false, isWritable: true },
|
|
878
|
+
{ pubkey: accounts.escrowTokens, isSigner: false, isWritable: true },
|
|
879
|
+
{ pubkey: accounts.withdrawor, isSigner: false, isWritable: true },
|
|
880
|
+
{ pubkey: accounts.mint, isSigner: false, isWritable: false },
|
|
881
|
+
{ pubkey: accounts.feeOracle, isSigner: false, isWritable: false },
|
|
882
|
+
{ pubkey: accounts.rent, isSigner: false, isWritable: false },
|
|
883
|
+
{ pubkey: accounts.timelockProgram, isSigner: false, isWritable: false },
|
|
884
|
+
{ pubkey: accounts.tokenProgram, isSigner: false, isWritable: false },
|
|
885
|
+
{ pubkey: accounts.systemProgram, isSigner: false, isWritable: false }
|
|
886
|
+
];
|
|
887
|
+
if (accounts.payer) {
|
|
888
|
+
keys.unshift({
|
|
889
|
+
pubkey: accounts.payer,
|
|
890
|
+
isSigner: true,
|
|
891
|
+
isWritable: true
|
|
892
|
+
});
|
|
893
|
+
}
|
|
894
|
+
let bufferData = buffer.Buffer.alloc(createUncheckedStreamV2Layout.span);
|
|
895
|
+
const encodedUIntArray = new TextEncoder().encode(data.name);
|
|
896
|
+
const streamNameBuffer = buffer.Buffer.alloc(64).fill(encodedUIntArray, 0, encodedUIntArray.byteLength);
|
|
897
|
+
const nonceBuffer = buffer.Buffer.alloc(4);
|
|
898
|
+
nonceBuffer.writeUInt32LE(data.nonce);
|
|
899
|
+
const decodedData = {
|
|
900
|
+
start_time: data.start.toArrayLike(buffer.Buffer, "le", 8),
|
|
901
|
+
net_amount_deposited: data.depositedAmount.toArrayLike(buffer.Buffer, "le", 8),
|
|
902
|
+
period: data.period.toArrayLike(buffer.Buffer, "le", 8),
|
|
903
|
+
amount_per_period: data.amountPerPeriod.toArrayLike(buffer.Buffer, "le", 8),
|
|
904
|
+
cliff: data.cliff.toArrayLike(buffer.Buffer, "le", 8),
|
|
905
|
+
cliff_amount: data.cliffAmount.toArrayLike(buffer.Buffer, "le", 8),
|
|
906
|
+
cancelable_by_sender: Number(data.cancelableBySender),
|
|
907
|
+
cancelable_by_recipient: Number(data.cancelableByRecipient),
|
|
908
|
+
automatic_withdrawal: Number(data.automaticWithdrawal),
|
|
909
|
+
transferable_by_sender: Number(data.transferableBySender),
|
|
910
|
+
transferable_by_recipient: Number(data.transferableByRecipient),
|
|
911
|
+
can_topup: Number(data.canTopup),
|
|
912
|
+
stream_name: streamNameBuffer,
|
|
913
|
+
withdraw_frequency: data.withdrawFrequency.toArrayLike(buffer.Buffer, "le", 8),
|
|
914
|
+
recipient: data.recipient.toBuffer(),
|
|
915
|
+
partner: data.partner.toBuffer(),
|
|
916
|
+
pausable: Number(data.canPause),
|
|
917
|
+
can_update_rate: Number(data.canUpdateRate),
|
|
918
|
+
nonce: nonceBuffer
|
|
919
|
+
};
|
|
920
|
+
const encodeLength = createUncheckedStreamV2Layout.encode(decodedData, bufferData);
|
|
921
|
+
bufferData = bufferData.slice(0, encodeLength);
|
|
922
|
+
const digest = accounts.payer ? await sha256.digest("global:create_unchecked_with_payer_v2") : await sha256.digest("global:create_unchecked_v2");
|
|
923
|
+
bufferData = buffer.Buffer.concat([buffer.Buffer.from(digest).slice(0, 8), bufferData, buffer.Buffer.alloc(10)]);
|
|
924
|
+
return new web3_js.TransactionInstruction({
|
|
925
|
+
keys,
|
|
926
|
+
programId,
|
|
927
|
+
data: bufferData
|
|
928
|
+
});
|
|
929
|
+
};
|
|
750
930
|
var withdrawStreamInstruction = async (amount, programId, {
|
|
751
931
|
authority,
|
|
752
932
|
recipient,
|
|
@@ -2539,6 +2719,14 @@ var deriveEscrowPDA = (programId, streamMetadata) => {
|
|
|
2539
2719
|
var deriveTestOraclePDA = (programId, mint, creator) => {
|
|
2540
2720
|
return web3_js.PublicKey.findProgramAddressSync([TEST_ORACLE_SEED, mint.toBuffer(), creator.toBuffer()], programId)[0];
|
|
2541
2721
|
};
|
|
2722
|
+
var deriveStreamMetadataPDA = (programId, mint, sender, nonce) => {
|
|
2723
|
+
const nonceBuffer = buffer.Buffer.alloc(4);
|
|
2724
|
+
nonceBuffer.writeUInt32BE(nonce);
|
|
2725
|
+
return web3_js.PublicKey.findProgramAddressSync(
|
|
2726
|
+
[METADATA_SEED, mint.toBuffer(), sender.toBuffer(), nonceBuffer],
|
|
2727
|
+
programId
|
|
2728
|
+
);
|
|
2729
|
+
};
|
|
2542
2730
|
var deriveRepopulatedMetadataPDA = (programId, streamMetadata) => {
|
|
2543
2731
|
return web3_js.PublicKey.findProgramAddressSync([REPOPULATED_METADATA_SEED, streamMetadata.toBuffer()], programId)[0];
|
|
2544
2732
|
};
|
|
@@ -2597,6 +2785,7 @@ async function toDecodedStream(schema) {
|
|
|
2597
2785
|
const sender = common.pk(schema.sender);
|
|
2598
2786
|
const recipient = common.pk(schema.recipient);
|
|
2599
2787
|
const partner = schema.partner ? common.pk(schema.partner) : sender;
|
|
2788
|
+
const payer = schema.payer ? common.pk(schema.payer) : web3_js.PublicKey.default;
|
|
2600
2789
|
const [senderTokens, recipientTokens, partnerTokens, streamflowTreasuryTokens] = await Promise.all([
|
|
2601
2790
|
common.ata(mint, sender),
|
|
2602
2791
|
common.ata(mint, recipient),
|
|
@@ -2641,12 +2830,16 @@ async function toDecodedStream(schema) {
|
|
|
2641
2830
|
canTopup: schema.canTopup,
|
|
2642
2831
|
name: schema.name,
|
|
2643
2832
|
withdrawFrequency: toBN(schema.autoClaimPeriod),
|
|
2833
|
+
isPda: schema.isPda,
|
|
2834
|
+
nonce: schema.nonce ? schema.nonce : 0,
|
|
2644
2835
|
closed: schema.isClosed,
|
|
2645
2836
|
currentPauseStart: toBN(0),
|
|
2646
2837
|
pauseCumulative: toBN(schema.pauseCumulative),
|
|
2647
2838
|
lastRateChangeTime: toBN(isoToUnix(schema.lastRateUpdateDt)),
|
|
2648
2839
|
fundsUnlockedAtLastRateChange: toBN(schema.amountUnlockedAtLastRateUpdate),
|
|
2649
|
-
oldMetadata: web3_js.PublicKey.default
|
|
2840
|
+
oldMetadata: web3_js.PublicKey.default,
|
|
2841
|
+
payer,
|
|
2842
|
+
bump: schema.bump ? schema.bump : 0
|
|
2650
2843
|
};
|
|
2651
2844
|
}
|
|
2652
2845
|
function toPrecisionBN(value, precision = ALIGNED_PRECISION_FACTOR_POW2) {
|
|
@@ -2974,7 +3167,8 @@ var SolanaStreamClient = class {
|
|
|
2974
3167
|
automaticWithdrawal = false,
|
|
2975
3168
|
withdrawalFrequency = 0,
|
|
2976
3169
|
partner,
|
|
2977
|
-
tokenProgramId: streamTokenProgramId
|
|
3170
|
+
tokenProgramId: streamTokenProgramId,
|
|
3171
|
+
nonce
|
|
2978
3172
|
}, { sender, metadataPubKeys, isNative = false, computePrice, computeLimit }) {
|
|
2979
3173
|
common.assertHasPublicKey(sender, "Sender's PublicKey is not available, check passed wallet adapter!");
|
|
2980
3174
|
const ixs = common.prepareBaseInstructions(this.connection, {
|
|
@@ -2983,7 +3177,13 @@ var SolanaStreamClient = class {
|
|
|
2983
3177
|
});
|
|
2984
3178
|
const mintPublicKey = isNative ? splToken.NATIVE_MINT : new web3_js.PublicKey(mint);
|
|
2985
3179
|
const recipientPublicKey = new web3_js.PublicKey(recipient);
|
|
2986
|
-
|
|
3180
|
+
let metadata;
|
|
3181
|
+
let metadataPubKey;
|
|
3182
|
+
if (nonce != null) {
|
|
3183
|
+
[metadataPubKey] = deriveStreamMetadataPDA(this.programId, mintPublicKey, sender.publicKey, nonce);
|
|
3184
|
+
} else {
|
|
3185
|
+
({ metadata, metadataPubKey } = this.getOrCreateStreamMetadata(metadataPubKeys));
|
|
3186
|
+
}
|
|
2987
3187
|
const [escrowTokens] = web3_js.PublicKey.findProgramAddressSync(
|
|
2988
3188
|
[buffer.Buffer.from("strm"), metadataPubKey.toBuffer()],
|
|
2989
3189
|
this.programId
|
|
@@ -2997,49 +3197,49 @@ var SolanaStreamClient = class {
|
|
|
2997
3197
|
const streamflowTreasuryTokens = await common.ata(mintPublicKey, STREAMFLOW_TREASURY_PUBLIC_KEY, tokenProgramId);
|
|
2998
3198
|
const partnerPublicKey = partner ? new web3_js.PublicKey(partner) : sender.publicKey;
|
|
2999
3199
|
const partnerTokens = await common.ata(mintPublicKey, partnerPublicKey, tokenProgramId);
|
|
3000
|
-
|
|
3001
|
-
|
|
3002
|
-
|
|
3003
|
-
|
|
3004
|
-
|
|
3005
|
-
|
|
3006
|
-
|
|
3007
|
-
|
|
3008
|
-
|
|
3009
|
-
|
|
3010
|
-
|
|
3011
|
-
|
|
3012
|
-
|
|
3013
|
-
|
|
3014
|
-
|
|
3015
|
-
|
|
3016
|
-
|
|
3017
|
-
|
|
3018
|
-
|
|
3019
|
-
|
|
3020
|
-
|
|
3021
|
-
|
|
3022
|
-
|
|
3023
|
-
|
|
3024
|
-
|
|
3025
|
-
|
|
3026
|
-
|
|
3027
|
-
|
|
3028
|
-
|
|
3029
|
-
|
|
3030
|
-
|
|
3031
|
-
|
|
3032
|
-
|
|
3033
|
-
|
|
3034
|
-
|
|
3035
|
-
|
|
3036
|
-
|
|
3037
|
-
|
|
3038
|
-
|
|
3039
|
-
|
|
3040
|
-
|
|
3041
|
-
)
|
|
3042
|
-
|
|
3200
|
+
const accounts = {
|
|
3201
|
+
sender: sender.publicKey,
|
|
3202
|
+
senderTokens,
|
|
3203
|
+
recipient: new web3_js.PublicKey(recipient),
|
|
3204
|
+
metadata: metadataPubKey,
|
|
3205
|
+
escrowTokens,
|
|
3206
|
+
recipientTokens,
|
|
3207
|
+
streamflowTreasury: STREAMFLOW_TREASURY_PUBLIC_KEY,
|
|
3208
|
+
streamflowTreasuryTokens,
|
|
3209
|
+
partner: partnerPublicKey,
|
|
3210
|
+
partnerTokens,
|
|
3211
|
+
mint: new web3_js.PublicKey(mint),
|
|
3212
|
+
feeOracle: this.feeOraclePublicKey,
|
|
3213
|
+
rent: web3_js.SYSVAR_RENT_PUBKEY,
|
|
3214
|
+
timelockProgram: this.programId,
|
|
3215
|
+
tokenProgram: tokenProgramId,
|
|
3216
|
+
associatedTokenProgram: splToken.ASSOCIATED_TOKEN_PROGRAM_ID,
|
|
3217
|
+
withdrawor: WITHDRAWOR_PUBLIC_KEY,
|
|
3218
|
+
systemProgram: web3_js.SystemProgram.programId
|
|
3219
|
+
};
|
|
3220
|
+
const baseData = {
|
|
3221
|
+
start: new BN3__default.default(start),
|
|
3222
|
+
depositedAmount,
|
|
3223
|
+
period: new BN3__default.default(period),
|
|
3224
|
+
amountPerPeriod,
|
|
3225
|
+
cliff: new BN3__default.default(cliff),
|
|
3226
|
+
cliffAmount: new BN3__default.default(cliffAmount),
|
|
3227
|
+
cancelableBySender,
|
|
3228
|
+
cancelableByRecipient,
|
|
3229
|
+
automaticWithdrawal,
|
|
3230
|
+
transferableBySender,
|
|
3231
|
+
transferableByRecipient,
|
|
3232
|
+
canTopup,
|
|
3233
|
+
canUpdateRate: !!canUpdateRate,
|
|
3234
|
+
canPause: !!canPause,
|
|
3235
|
+
name,
|
|
3236
|
+
withdrawFrequency: new BN3__default.default(automaticWithdrawal ? withdrawalFrequency : period)
|
|
3237
|
+
};
|
|
3238
|
+
if (nonce != null) {
|
|
3239
|
+
ixs.push(await createStreamV2Instruction({ ...baseData, nonce }, this.programId, accounts));
|
|
3240
|
+
} else {
|
|
3241
|
+
ixs.push(await createStreamInstruction(baseData, this.programId, accounts));
|
|
3242
|
+
}
|
|
3043
3243
|
return { ixs, metadata, metadataPubKey };
|
|
3044
3244
|
}
|
|
3045
3245
|
/**
|
|
@@ -3099,20 +3299,19 @@ var SolanaStreamClient = class {
|
|
|
3099
3299
|
transferableByRecipient,
|
|
3100
3300
|
automaticWithdrawal = false,
|
|
3101
3301
|
withdrawalFrequency = 0,
|
|
3102
|
-
partner
|
|
3302
|
+
partner,
|
|
3303
|
+
nonce
|
|
3103
3304
|
}, { sender, metadataPubKeys, isNative = false, computePrice, computeLimit }) {
|
|
3104
3305
|
common.assertHasPublicKey(sender, "Sender's PublicKey is not available, check passed wallet adapter!");
|
|
3105
3306
|
const mintPublicKey = new web3_js.PublicKey(mint);
|
|
3106
3307
|
const recipientPublicKey = new web3_js.PublicKey(recipient);
|
|
3107
|
-
|
|
3108
|
-
|
|
3109
|
-
|
|
3110
|
-
|
|
3111
|
-
|
|
3112
|
-
|
|
3113
|
-
|
|
3114
|
-
newAccountPubkey: metadataPubKey
|
|
3115
|
-
});
|
|
3308
|
+
let metadata;
|
|
3309
|
+
let metadataPubKey;
|
|
3310
|
+
if (nonce != null) {
|
|
3311
|
+
[metadataPubKey] = deriveStreamMetadataPDA(this.programId, mintPublicKey, sender.publicKey, nonce);
|
|
3312
|
+
} else {
|
|
3313
|
+
({ metadata, metadataPubKey } = this.getOrCreateStreamMetadata(metadataPubKeys));
|
|
3314
|
+
}
|
|
3116
3315
|
const [escrowTokens] = web3_js.PublicKey.findProgramAddressSync(
|
|
3117
3316
|
[buffer.Buffer.from("strm"), metadataPubKey.toBuffer()],
|
|
3118
3317
|
this.programId
|
|
@@ -3129,43 +3328,58 @@ var SolanaStreamClient = class {
|
|
|
3129
3328
|
const totalAmount = calculateTotalAmountToDeposit(depositedAmount, totalFee);
|
|
3130
3329
|
ixs.push(...await common.prepareWrappedAccount(this.connection, sender.publicKey, totalAmount));
|
|
3131
3330
|
}
|
|
3132
|
-
const
|
|
3133
|
-
|
|
3134
|
-
|
|
3135
|
-
|
|
3136
|
-
|
|
3137
|
-
|
|
3138
|
-
|
|
3139
|
-
|
|
3140
|
-
|
|
3141
|
-
|
|
3142
|
-
|
|
3143
|
-
|
|
3144
|
-
|
|
3145
|
-
|
|
3146
|
-
|
|
3147
|
-
|
|
3148
|
-
|
|
3149
|
-
|
|
3150
|
-
|
|
3151
|
-
|
|
3152
|
-
|
|
3153
|
-
|
|
3154
|
-
|
|
3155
|
-
|
|
3156
|
-
|
|
3157
|
-
|
|
3158
|
-
|
|
3159
|
-
|
|
3160
|
-
|
|
3161
|
-
|
|
3162
|
-
|
|
3163
|
-
|
|
3164
|
-
|
|
3165
|
-
|
|
3166
|
-
|
|
3167
|
-
|
|
3168
|
-
|
|
3331
|
+
const accounts = {
|
|
3332
|
+
sender: sender.publicKey,
|
|
3333
|
+
senderTokens,
|
|
3334
|
+
metadata: metadataPubKey,
|
|
3335
|
+
escrowTokens,
|
|
3336
|
+
mint: new web3_js.PublicKey(mint),
|
|
3337
|
+
feeOracle: this.feeOraclePublicKey,
|
|
3338
|
+
rent: web3_js.SYSVAR_RENT_PUBKEY,
|
|
3339
|
+
timelockProgram: this.programId,
|
|
3340
|
+
tokenProgram: tokenProgramId,
|
|
3341
|
+
withdrawor: WITHDRAWOR_PUBLIC_KEY,
|
|
3342
|
+
systemProgram: web3_js.SystemProgram.programId
|
|
3343
|
+
};
|
|
3344
|
+
const baseData = {
|
|
3345
|
+
start: new BN3__default.default(start),
|
|
3346
|
+
depositedAmount,
|
|
3347
|
+
period: new BN3__default.default(period),
|
|
3348
|
+
amountPerPeriod,
|
|
3349
|
+
cliff: new BN3__default.default(cliff),
|
|
3350
|
+
cliffAmount: new BN3__default.default(cliffAmount),
|
|
3351
|
+
cancelableBySender,
|
|
3352
|
+
cancelableByRecipient,
|
|
3353
|
+
automaticWithdrawal,
|
|
3354
|
+
transferableBySender,
|
|
3355
|
+
transferableByRecipient,
|
|
3356
|
+
canTopup,
|
|
3357
|
+
canUpdateRate: !!canUpdateRate,
|
|
3358
|
+
canPause: !!canPause,
|
|
3359
|
+
name,
|
|
3360
|
+
withdrawFrequency: new BN3__default.default(automaticWithdrawal ? withdrawalFrequency : period),
|
|
3361
|
+
recipient: recipientPublicKey,
|
|
3362
|
+
partner: partnerPublicKey
|
|
3363
|
+
};
|
|
3364
|
+
if (nonce != null) {
|
|
3365
|
+
const createInstruction = await createUncheckedStreamV2Instruction(
|
|
3366
|
+
{ ...baseData, nonce },
|
|
3367
|
+
this.programId,
|
|
3368
|
+
accounts
|
|
3369
|
+
);
|
|
3370
|
+
ixs.push(createInstruction);
|
|
3371
|
+
} else {
|
|
3372
|
+
const rentToExempt = await this.connection.getMinimumBalanceForRentExemption(METADATA_ACC_SIZE);
|
|
3373
|
+
const createMetadataInstruction = web3_js.SystemProgram.createAccount({
|
|
3374
|
+
programId: this.programId,
|
|
3375
|
+
space: METADATA_ACC_SIZE,
|
|
3376
|
+
lamports: rentToExempt,
|
|
3377
|
+
fromPubkey: sender.publicKey,
|
|
3378
|
+
newAccountPubkey: metadataPubKey
|
|
3379
|
+
});
|
|
3380
|
+
const createInstruction = await createUncheckedStreamInstruction(baseData, this.programId, accounts);
|
|
3381
|
+
ixs.push(createMetadataInstruction, createInstruction);
|
|
3382
|
+
}
|
|
3169
3383
|
return { ixs, metadata, metadataPubKey };
|
|
3170
3384
|
}
|
|
3171
3385
|
/**
|
|
@@ -4604,6 +4818,7 @@ exports.ESCROW_SEED = ESCROW_SEED;
|
|
|
4604
4818
|
exports.FEES_METADATA_SEED = FEES_METADATA_SEED;
|
|
4605
4819
|
exports.FEE_ORACLE_PUBLIC_KEY = FEE_ORACLE_PUBLIC_KEY;
|
|
4606
4820
|
exports.MAX_SAFE_UNIX_TIME_VALUE = MAX_SAFE_UNIX_TIME_VALUE2;
|
|
4821
|
+
exports.METADATA_SEED = METADATA_SEED;
|
|
4607
4822
|
exports.ORIGINAL_CONTRACT_SENDER_OFFSET = ORIGINAL_CONTRACT_SENDER_OFFSET;
|
|
4608
4823
|
exports.PARTNERS_SCHEMA = PARTNERS_SCHEMA;
|
|
4609
4824
|
exports.PARTNER_ORACLE_PROGRAM_ID = PARTNER_ORACLE_PROGRAM_ID;
|
|
@@ -4634,12 +4849,15 @@ exports.calculateUnlockedAmount = calculateUnlockedAmount;
|
|
|
4634
4849
|
exports.cancelStreamInstruction = cancelStreamInstruction;
|
|
4635
4850
|
exports.createClient = createClient;
|
|
4636
4851
|
exports.createStreamInstruction = createStreamInstruction;
|
|
4852
|
+
exports.createStreamV2Instruction = createStreamV2Instruction;
|
|
4637
4853
|
exports.createUncheckedStreamInstruction = createUncheckedStreamInstruction;
|
|
4854
|
+
exports.createUncheckedStreamV2Instruction = createUncheckedStreamV2Instruction;
|
|
4638
4855
|
exports.decodeEndTime = decodeEndTime;
|
|
4639
4856
|
exports.decodeStream = decodeStream;
|
|
4640
4857
|
exports.deriveContractPDA = deriveContractPDA;
|
|
4641
4858
|
exports.deriveEscrowPDA = deriveEscrowPDA;
|
|
4642
4859
|
exports.deriveRepopulatedMetadataPDA = deriveRepopulatedMetadataPDA;
|
|
4860
|
+
exports.deriveStreamMetadataPDA = deriveStreamMetadataPDA;
|
|
4643
4861
|
exports.deriveTestOraclePDA = deriveTestOraclePDA;
|
|
4644
4862
|
exports.extractSolanaErrorCode = extractSolanaErrorCode;
|
|
4645
4863
|
exports.getMetadataKey = getMetadataKey;
|