Skip to content

Commit 38484e7

Browse files
authored
pass expiry time, percentage (#292)
* pass expiry time, percentage
1 parent 4ed9a80 commit 38484e7

File tree

12 files changed

+1467
-723
lines changed

12 files changed

+1467
-723
lines changed

lerna.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"packages": [
33
"packages/*"
44
],
5-
"version": "8.1.1",
5+
"version": "8.2.0",
66
"$schema": "node_modules/lerna/schemas/lerna-schema.json",
77
"command": {
88
"run": {

packages/common/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@streamflow/common",
3-
"version": "8.1.1",
3+
"version": "8.2.0",
44
"description": "Common utilities and types used by streamflow packages.",
55
"homepage": "https://github.com/streamflow-finance/js-sdk/",
66
"type": "module",

packages/distributor/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@streamflow/distributor",
3-
"version": "8.1.1",
3+
"version": "8.2.0",
44
"description": "JavaScript SDK to interact with Streamflow Airdrop protocol.",
55
"homepage": "https://github.com/streamflow-finance/js-sdk/",
66
"main": "./dist/cjs/index.cjs",

packages/distributor/solana/clients/BaseDistributorClient.ts

Lines changed: 30 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ export default abstract class BaseDistributorClient {
128128

129129
public async prepareCreateInstructions(
130130
data: ICreateDistributorData | ICreateAlignedDistributorData,
131-
extParams: ITransactionSolanaExtResolved<ICreateSolanaExt>
131+
extParams: ITransactionSolanaExtResolved<ICreateSolanaExt>,
132132
): Promise<{ distributorPublicKey: PublicKey; ixs: TransactionInstruction[] }> {
133133
if (!extParams.invoker.publicKey) {
134134
throw new Error("Invoker's PublicKey is not available, check passed wallet adapter!");
@@ -156,7 +156,7 @@ export default abstract class BaseDistributorClient {
156156

157157
if (extParams.isNative) {
158158
ixs.push(
159-
...(await prepareWrappedAccount(this.connection, extParams.invoker.publicKey, new BN(data.maxTotalClaim)))
159+
...(await prepareWrappedAccount(this.connection, extParams.invoker.publicKey, new BN(data.maxTotalClaim))),
160160
);
161161
}
162162

@@ -168,7 +168,7 @@ export default abstract class BaseDistributorClient {
168168
const { transferAmount, feeCharged } = await calculateAmountWithTransferFees(
169169
this.connection,
170170
transferFeeConfig,
171-
BigInt(data.maxTotalClaim.toString())
171+
BigInt(data.maxTotalClaim.toString()),
172172
);
173173

174174
ixs.push(
@@ -181,8 +181,8 @@ export default abstract class BaseDistributorClient {
181181
mintAccount.decimals,
182182
feeCharged,
183183
undefined,
184-
tokenProgramId
185-
)
184+
tokenProgramId,
185+
),
186186
);
187187
} else {
188188
ixs.push(
@@ -194,8 +194,8 @@ export default abstract class BaseDistributorClient {
194194
BigInt(data.maxTotalClaim.toString()),
195195
mintAccount.decimals,
196196
undefined,
197-
tokenProgramId
198-
)
197+
tokenProgramId,
198+
),
199199
);
200200
}
201201

@@ -204,15 +204,15 @@ export default abstract class BaseDistributorClient {
204204

205205
public async create(
206206
data: ICreateDistributorData | ICreateAlignedDistributorData,
207-
extParams: ICreateSolanaExt
207+
extParams: ICreateSolanaExt,
208208
): Promise<ICreateDistributorResult> {
209209
const invoker = extParams.invoker.publicKey;
210210
invariant(invoker, "Invoker's PublicKey is not available, check passed wallet adapter!");
211211
const executionParams = this.unwrapExecutionParams(extParams);
212212
const { ixs, distributorPublicKey } = await createAndEstimateTransaction(
213213
(params) => this.prepareCreateInstructions(data, params),
214214
executionParams,
215-
(q) => q.ixs
215+
(q) => q.ixs,
216216
);
217217
const { tx, hash, context } = await prepareTransaction(this.connection, ixs, extParams.invoker.publicKey);
218218
const signature = await wrappedSignAndExecuteTransaction(
@@ -224,7 +224,7 @@ export default abstract class BaseDistributorClient {
224224
context,
225225
commitment: this.getCommitment(),
226226
},
227-
{ sendThrottler: this.sendThrottler, skipSimulation: executionParams.skipSimulation }
227+
{ sendThrottler: this.sendThrottler, skipSimulation: executionParams.skipSimulation },
228228
);
229229

230230
return {
@@ -251,14 +251,14 @@ export default abstract class BaseDistributorClient {
251251
public async claim(
252252
data: IClaimData,
253253
extParams: IInteractSolanaExt,
254-
_serviceTransfer?: unknown
254+
_serviceTransfer?: unknown,
255255
): Promise<ITransactionResult> {
256256
const executionParams = this.unwrapExecutionParams(extParams);
257257
const invoker = executionParams.invoker.publicKey;
258258
invariant(invoker, "Invoker's PublicKey is not available, check passed wallet adapter!");
259259
const ixs = await createAndEstimateTransaction(
260260
(params) => this.prepareClaimInstructions(data, params, _serviceTransfer),
261-
executionParams
261+
executionParams,
262262
);
263263
const { tx, hash, context } = await prepareTransaction(this.connection, ixs, invoker);
264264
const signature = await wrappedSignAndExecuteTransaction(
@@ -270,7 +270,7 @@ export default abstract class BaseDistributorClient {
270270
context,
271271
commitment: this.getCommitment(),
272272
},
273-
{ sendThrottler: this.sendThrottler, skipSimulation: executionParams.skipSimulation }
273+
{ sendThrottler: this.sendThrottler, skipSimulation: executionParams.skipSimulation },
274274
);
275275

276276
return { ixs, txId: signature };
@@ -296,7 +296,7 @@ export default abstract class BaseDistributorClient {
296296
public async prepareClaimInstructions(
297297
data: IClaimData,
298298
extParams: ITransactionSolanaExtResolved<IInteractSolanaExt>,
299-
_serviceTransfer?: unknown
299+
_serviceTransfer?: unknown,
300300
): Promise<TransactionInstruction[]> {
301301
if (!extParams.invoker.publicKey) {
302302
throw new Error("Invoker's PublicKey is not available, check passed wallet adapter!");
@@ -317,14 +317,14 @@ export default abstract class BaseDistributorClient {
317317
[extParams.invoker.publicKey],
318318
distributor.mint,
319319
extParams.invoker,
320-
tokenProgramId
321-
))
320+
tokenProgramId,
321+
)),
322322
);
323323
const invokerTokens = await ata(distributor.mint, extParams.invoker.publicKey, tokenProgramId);
324324
const claimStatusPublicKey = getClaimantStatusPda(
325325
this.programId,
326326
distributorPublicKey,
327-
extParams.invoker.publicKey
327+
extParams.invoker.publicKey,
328328
);
329329
const eventAuthorityPublicKey = getEventAuthorityPda(this.programId);
330330
const claimStatus = await this.getClaim(claimStatusPublicKey);
@@ -362,8 +362,8 @@ export default abstract class BaseDistributorClient {
362362
ixs.push(
363363
this.prepareClaimFeeInstruction(
364364
extParams.invoker.publicKey,
365-
typeof _serviceTransfer === "bigint" ? _serviceTransfer : undefined
366-
)
365+
typeof _serviceTransfer === "bigint" ? _serviceTransfer : undefined,
366+
),
367367
);
368368

369369
return ixs;
@@ -375,7 +375,7 @@ export default abstract class BaseDistributorClient {
375375
invariant(invoker, "Invoker's PublicKey is not available, check passed wallet adapter!");
376376
const ixs = await createAndEstimateTransaction(
377377
(params) => this.prepareCloseClaimInstructions(data, params),
378-
executionParams
378+
executionParams,
379379
);
380380
const { tx, hash, context } = await prepareTransaction(this.connection, ixs, invoker);
381381
const signature = await wrappedSignAndExecuteTransaction(
@@ -387,15 +387,15 @@ export default abstract class BaseDistributorClient {
387387
context,
388388
commitment: this.getCommitment(),
389389
},
390-
{ sendThrottler: this.sendThrottler, skipSimulation: executionParams.skipSimulation }
390+
{ sendThrottler: this.sendThrottler, skipSimulation: executionParams.skipSimulation },
391391
);
392392

393393
return { ixs, txId: signature };
394394
}
395395

396396
public async prepareCloseClaimInstructions(
397397
data: ICloseClaimData,
398-
extParams: ITransactionSolanaExtResolved<IInteractSolanaExt>
398+
extParams: ITransactionSolanaExtResolved<IInteractSolanaExt>,
399399
): Promise<TransactionInstruction[]> {
400400
if (!extParams.invoker.publicKey) {
401401
throw new Error("Invoker's PublicKey is not available, check passed wallet adapter!");
@@ -438,7 +438,7 @@ export default abstract class BaseDistributorClient {
438438

439439
public async prepareClawbackInstructions(
440440
data: IClawbackData,
441-
extParams: ITransactionSolanaExtResolved<IInteractSolanaExt>
441+
extParams: ITransactionSolanaExtResolved<IInteractSolanaExt>,
442442
): Promise<TransactionInstruction[]> {
443443
if (!extParams.invoker.publicKey) {
444444
throw new Error("Invoker's PublicKey is not available, check passed wallet adapter!");
@@ -459,8 +459,8 @@ export default abstract class BaseDistributorClient {
459459
[extParams.invoker.publicKey],
460460
distributor.mint,
461461
extParams.invoker,
462-
tokenProgramId
463-
))
462+
tokenProgramId,
463+
)),
464464
);
465465

466466
const accounts: ClawbackAccounts = {
@@ -486,7 +486,7 @@ export default abstract class BaseDistributorClient {
486486
invariant(invoker, "Invoker's PublicKey is not available, check passed wallet adapter!");
487487
const ixs = await createAndEstimateTransaction(
488488
(params) => this.prepareClawbackInstructions(data, params),
489-
executionParams
489+
executionParams,
490490
);
491491
const { tx, hash, context } = await prepareTransaction(this.connection, ixs, invoker);
492492
const signature = await wrappedSignAndExecuteTransaction(
@@ -498,7 +498,7 @@ export default abstract class BaseDistributorClient {
498498
context,
499499
commitment: this.getCommitment(),
500500
},
501-
{ sendThrottler: this.sendThrottler, skipSimulation: executionParams.skipSimulation }
501+
{ sendThrottler: this.sendThrottler, skipSimulation: executionParams.skipSimulation },
502502
);
503503

504504
return { ixs, txId: signature };
@@ -583,7 +583,7 @@ export default abstract class BaseDistributorClient {
583583
}
584584

585585
protected unwrapExecutionParams<T extends IInteractSolanaExt>(
586-
extParams: T
586+
extParams: T,
587587
): ReturnType<typeof unwrapExecutionParams<T>> {
588588
return unwrapExecutionParams(extParams, this.connection);
589589
}
@@ -612,14 +612,14 @@ function decode<T extends Idl, AccountName extends keyof IdlAccounts<T>>(
612612
program: Program<T>,
613613
accountName: AccountName,
614614
accInfo: Parameters<AccountsCoder["decode"]>[1],
615-
programKey?: string
615+
programKey?: string,
616616
): IdlAccounts<T>[AccountName] {
617617
const programId = programKey ?? program.programId?.toBase58() ?? "N/A";
618618
invariant(program, `Decoding program with key ${programId} is not available`);
619619
const accountEntity = program.idl.accounts?.find((acc) => acc.name === accountName);
620620
invariant(
621621
!!accountEntity,
622-
`Decoding program with key ${programId} doesn't specify account with name ${String(accountName)}`
622+
`Decoding program with key ${programId} doesn't specify account with name ${String(accountName)}`,
623623
);
624624
return program.coder.accounts.decode(accountName as string, accInfo) as IdlAccounts<T>[AccountName];
625625
}

packages/eslint-config/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@streamflow/eslint-config",
3-
"version": "8.1.1",
3+
"version": "8.2.0",
44
"description": "ESLint configuration for Streamflow protocol.",
55
"homepage": "https://github.com/streamflow-finance/js-sdk/",
66
"engines": {

packages/launchpad/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@streamflow/launchpad",
3-
"version": "8.1.1",
3+
"version": "8.2.0",
44
"description": "JavaScript SDK to interact with Streamflow Launchpad protocol.",
55
"homepage": "https://github.com/streamflow-finance/js-sdk/",
66
"main": "./dist/cjs/index.cjs",

packages/staking/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@streamflow/staking",
3-
"version": "8.1.1",
3+
"version": "8.2.0",
44
"description": "JavaScript SDK to interact with Streamflow Staking protocol.",
55
"homepage": "https://github.com/streamflow-finance/js-sdk/",
66
"main": "./dist/cjs/index.cjs",

packages/stream/common/types.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,8 @@ export type IAlignedStreamConfig = {
4646
priceOracle?: Address;
4747
skipInitial?: boolean;
4848
tickSize?: number;
49+
expiryTime?: number;
50+
expiryPercentage?: number | BN;
4951
};
5052

5153
export type ICreateLinearStreamData = IBaseStreamConfig & IRecipient;

packages/stream/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@streamflow/stream",
3-
"version": "8.1.1",
3+
"version": "8.2.0",
44
"description": "JavaScript SDK to interact with Streamflow protocol.",
55
"homepage": "https://github.com/streamflow-finance/js-sdk/",
66
"main": "./dist/cjs/index.cjs",

packages/stream/solana/StreamClient.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -313,6 +313,8 @@ export class SolanaStreamClient extends BaseStreamClient {
313313
priceOracle,
314314
oracleType,
315315
tokenProgramId: streamTokenProgramId,
316+
expiryTime,
317+
expiryPercentage,
316318
} = streamParams;
317319
const { isNative, sender, computeLimit, computePrice, metadataPubKeys } = extParams;
318320

@@ -380,6 +382,8 @@ export class SolanaStreamClient extends BaseStreamClient {
380382
maxPercentage: maxPercentage instanceof BN ? maxPercentage : getBN(maxPercentage, ALIGNED_PRECISION_FACTOR_POW),
381383
tickSize: new BN(tickSize || 1),
382384
skipInitial: skipInitial ?? false,
385+
expiryTime: new BN(expiryTime ?? 0),
386+
expiryPercentage: expiryPercentage instanceof BN ? expiryPercentage : getBN(expiryPercentage ?? 0, ALIGNED_PRECISION_FACTOR_POW),
383387
})
384388
.accountsPartial({
385389
payer: sender.publicKey,

0 commit comments

Comments
 (0)