Skip to content

Commit 56f6582

Browse files
authored
Merge pull request #246 from streamflow-finance/feat/expose-more-scheduling-options
Feat/expose more scheduling options
2 parents e56411e + 0a3fe98 commit 56f6582

File tree

11 files changed

+60
-49
lines changed

11 files changed

+60
-49
lines changed

lerna.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,6 @@
22
"packages": [
33
"packages/*"
44
],
5-
"version": "7.2.0",
5+
"version": "7.2.1",
66
"$schema": "node_modules/lerna/schemas/lerna-schema.json"
77
}

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": "7.2.0",
3+
"version": "7.2.1",
44
"description": "Common utilities and types used by streamflow packages.",
55
"homepage": "https://github.com/streamflow-finance/js-sdk/",
66
"main": "./dist/esm/index.js",

packages/common/solana/types.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ export interface ConfirmationParams {
3434
export interface ThrottleParams {
3535
sendRate?: number;
3636
sendThrottler?: PQueue;
37+
waitBeforeConfirming?: number | undefined;
3738
}
3839

3940
export interface IProgramAccount<T> {

packages/common/solana/utils.ts

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -221,14 +221,18 @@ export async function executeMultipleTransactions(
221221
connection: Connection,
222222
txs: (Transaction | VersionedTransaction)[],
223223
confirmationParams: ConfirmationParams,
224-
{ sendRate = 1, sendThrottler }: ThrottleParams,
224+
{ sendRate = 1, sendThrottler, ...throttlingParams }: ThrottleParams,
225225
): Promise<PromiseSettledResult<string>[]> {
226226
if (!sendThrottler) {
227227
sendThrottler = buildSendThrottler(sendRate);
228228
}
229229
return Promise.allSettled(
230230
txs.map((tx) =>
231-
executeTransaction(connection, tx, confirmationParams, { sendRate: sendRate, sendThrottler: sendThrottler }),
231+
executeTransaction(connection, tx, confirmationParams, {
232+
...throttlingParams,
233+
sendRate: sendRate,
234+
sendThrottler: sendThrottler,
235+
}),
232236
),
233237
);
234238
}
@@ -250,7 +254,7 @@ export async function sendAndConfirmTransaction(
250254
connection: Connection,
251255
tx: Transaction | VersionedTransaction,
252256
{ hash, context, commitment }: ConfirmationParams,
253-
{ sendRate = 1, sendThrottler }: ThrottleParams,
257+
{ sendRate = 1, sendThrottler, waitBeforeConfirming }: ThrottleParams,
254258
): Promise<string> {
255259
const isVersioned = isTransactionVersioned(tx);
256260

@@ -291,7 +295,8 @@ export async function sendAndConfirmTransaction(
291295
}
292296
throw e;
293297
}
294-
await sleep(500);
298+
// Wait at least 5 slots (~400ms before confirming)
299+
await sleep(waitBeforeConfirming ?? 2000);
295300
try {
296301
const value = await confirmAndEnsureTransaction(connection, signature);
297302
if (value) {

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": "7.2.0",
3+
"version": "7.2.1",
44
"description": "JavaScript SDK to interact with Streamflow Airdrop protocol.",
55
"homepage": "https://github.com/streamflow-finance/js-sdk/",
66
"main": "dist/esm/index.js",

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": "7.2.0",
3+
"version": "7.2.1",
44
"license": "ISC",
55
"main": "index.js",
66
"files": [

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": "7.2.0",
3+
"version": "7.2.1",
44
"description": "JavaScript SDK to interact with Streamflow Launchpad protocol.",
55
"homepage": "https://github.com/streamflow-finance/js-sdk/",
66
"main": "dist/esm/index.js",

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": "7.2.0",
3+
"version": "7.2.1",
44
"description": "JavaScript SDK to interact with Streamflow Staking protocol.",
55
"homepage": "https://github.com/streamflow-finance/js-sdk/",
66
"main": "dist/esm/index.js",

packages/stream/common/types.ts

Lines changed: 19 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -340,6 +340,24 @@ export enum SolanaAlignedProxyErrorCode {
340340
AllFundsUnlocked = "AllFundsUnlocked",
341341
}
342342

343+
/**
344+
* @interface
345+
*/
346+
export interface SolanaTransactionSchedulingOptions {
347+
/**
348+
* concurrency rate for scheduling
349+
*/
350+
sendRate: number;
351+
/**
352+
* time interval between consecutive sends
353+
*/
354+
sendInterval?: number;
355+
/**
356+
* time interval before confirming the transaction
357+
*/
358+
waitBeforeConfirming?: number;
359+
}
360+
343361
/**
344362
* @interface
345363
*/
@@ -351,18 +369,7 @@ export interface SolanaStreamClientOptions {
351369
commitment?: Commitment | ConnectionConfig;
352370
sendRate?: number;
353371
sendThrottler?: PQueue;
354-
sendScheduler?:
355-
| PQueue
356-
| {
357-
/**
358-
* concurrency rate for scheduling
359-
*/
360-
sendRate: number;
361-
/**
362-
* time interval between consecutive sends
363-
*/
364-
sendInterval?: number;
365-
};
372+
sendScheduler?: PQueue | SolanaTransactionSchedulingOptions;
366373
}
367374

368375
/**

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": "7.2.0",
3+
"version": "7.2.1",
44
"description": "JavaScript SDK to interact with Streamflow protocol.",
55
"homepage": "https://github.com/streamflow-finance/js-sdk/",
66
"main": "./dist/esm/index.js",

0 commit comments

Comments
 (0)