diff --git a/lerna.json b/lerna.json index 2a3dbcbb..ccd9dbe0 100644 --- a/lerna.json +++ b/lerna.json @@ -2,6 +2,6 @@ "packages": [ "packages/*" ], - "version": "6.3.5", + "version": "6.3.6", "$schema": "node_modules/lerna/schemas/lerna-schema.json" } diff --git a/packages/common/package.json b/packages/common/package.json index c282dfae..d329bade 100644 --- a/packages/common/package.json +++ b/packages/common/package.json @@ -1,6 +1,6 @@ { "name": "@streamflow/common", - "version": "6.3.5", + "version": "6.3.6", "description": "Common utilities and types used by streamflow packages.", "homepage": "https://github.com/streamflow-finance/js-sdk/", "main": "dist/index.js", diff --git a/packages/distributor/package.json b/packages/distributor/package.json index 3fb8d219..e317a237 100644 --- a/packages/distributor/package.json +++ b/packages/distributor/package.json @@ -1,6 +1,6 @@ { "name": "@streamflow/distributor", - "version": "6.3.5", + "version": "6.3.6", "description": "JavaScript SDK to interact with Streamflow Airdrop protocol.", "homepage": "https://github.com/streamflow-finance/js-sdk/", "main": "dist/index.js", diff --git a/packages/distributor/solana/client.ts b/packages/distributor/solana/client.ts index 4c3547fa..afca9e26 100644 --- a/packages/distributor/solana/client.ts +++ b/packages/distributor/solana/client.ts @@ -91,6 +91,31 @@ export default class SolanaDistributorClient { } public async create(data: ICreateDistributorData, extParams: ICreateSolanaExt): Promise { + const { ixs, distributorPublicKey } = await this.prepareCreateInstructions(data, extParams); + const { tx, hash, context } = await prepareTransaction(this.connection, ixs, extParams.invoker.publicKey); + const signature = await wrappedSignAndExecuteTransaction( + this.connection, + extParams.invoker, + tx, + { + hash, + context, + commitment: this.getCommitment(), + }, + { sendThrottler: this.sendThrottler }, + ); + + return { + ixs, + txId: signature, + metadataId: distributorPublicKey.toBase58(), + }; + } + + public async prepareCreateInstructions( + data: ICreateDistributorData, + extParams: ICreateSolanaExt, + ): Promise<{ distributorPublicKey: PublicKey; ixs: TransactionInstruction[] }> { if (!extParams.invoker.publicKey) { throw new Error("Invoker's PublicKey is not available, check passed wallet adapter!"); } @@ -149,6 +174,11 @@ export default class SolanaDistributorClient { ), ); + return { distributorPublicKey, ixs }; + } + + public async claim(data: IClaimData, extParams: IInteractSolanaExt): Promise { + const ixs = await this.prepareClaimInstructions(data, extParams); const { tx, hash, context } = await prepareTransaction(this.connection, ixs, extParams.invoker.publicKey); const signature = await wrappedSignAndExecuteTransaction( this.connection, @@ -162,14 +192,13 @@ export default class SolanaDistributorClient { { sendThrottler: this.sendThrottler }, ); - return { - ixs, - txId: signature, - metadataId: distributorPublicKey.toBase58(), - }; + return { ixs, txId: signature }; } - public async claim(data: IClaimData, extParams: IInteractSolanaExt): Promise { + public async prepareClaimInstructions( + data: IClaimData, + extParams: IInteractSolanaExt, + ): Promise { if (!extParams.invoker.publicKey) { throw new Error("Invoker's PublicKey is not available, check passed wallet adapter!"); } @@ -228,6 +257,11 @@ export default class SolanaDistributorClient { ixs.push(claimLocked(accounts, this.programId)); } + return ixs; + } + + public async clawback(data: IClawbackData, extParams: IInteractSolanaExt): Promise { + const ixs = await this.prepareClawbackInstructions(data, extParams); const { tx, hash, context } = await prepareTransaction(this.connection, ixs, extParams.invoker.publicKey); const signature = await wrappedSignAndExecuteTransaction( this.connection, @@ -244,7 +278,10 @@ export default class SolanaDistributorClient { return { ixs, txId: signature }; } - public async clawback(data: IClawbackData, extParams: IInteractSolanaExt): Promise { + public async prepareClawbackInstructions( + data: IClawbackData, + extParams: IInteractSolanaExt, + ): Promise { if (!extParams.invoker.publicKey) { throw new Error("Invoker's PublicKey is not available, check passed wallet adapter!"); } @@ -279,20 +316,7 @@ export default class SolanaDistributorClient { ixs.push(clawback(accounts, this.programId)); - const { tx, hash, context } = await prepareTransaction(this.connection, ixs, extParams.invoker.publicKey); - const signature = await wrappedSignAndExecuteTransaction( - this.connection, - extParams.invoker, - tx, - { - hash, - context, - commitment: this.getCommitment(), - }, - { sendThrottler: this.sendThrottler }, - ); - - return { ixs, txId: signature }; + return ixs; } public async getClaims(data: IGetClaimData[]): Promise<(ClaimStatus | null)[]> { diff --git a/packages/eslint-config/package.json b/packages/eslint-config/package.json index 559faf4c..f0754e50 100644 --- a/packages/eslint-config/package.json +++ b/packages/eslint-config/package.json @@ -1,6 +1,6 @@ { "name": "@streamflow/eslint-config", - "version": "6.3.5", + "version": "6.3.6", "license": "ISC", "main": "index.js", "files": [ diff --git a/packages/stream/package.json b/packages/stream/package.json index 2196a95e..059618fe 100644 --- a/packages/stream/package.json +++ b/packages/stream/package.json @@ -1,6 +1,6 @@ { "name": "@streamflow/stream", - "version": "6.3.5", + "version": "6.3.6", "description": "JavaScript SDK to interact with Streamflow protocol.", "homepage": "https://github.com/streamflow-finance/js-sdk/", "main": "dist/index.js",