Skip to content

Commit

Permalink
support compute params in createMultiple, fix withdraw ext params
Browse files Browse the repository at this point in the history
  • Loading branch information
Yolley committed Mar 13, 2024
1 parent 67681d9 commit 707516c
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 57 deletions.
2 changes: 1 addition & 1 deletion lerna.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@
"packages": [
"packages/*"
],
"version": "5.11.0",
"version": "5.11.1",
"$schema": "node_modules/lerna/schemas/lerna-schema.json"
}
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion packages/stream/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@streamflow/stream",
"version": "5.11.0",
"version": "5.11.1",
"description": "JavaScript SDK to interact with Streamflow protocol.",
"homepage": "https://github.com/streamflow-finance/js-sdk/",
"main": "dist/index.js",
Expand Down
93 changes: 39 additions & 54 deletions packages/stream/solana/StreamClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -139,20 +139,17 @@ export default class SolanaStreamClient extends BaseStreamClient {
*/
public async create(
data: ICreateStreamData,
extensions: ICreateStreamSolanaExt
extParams: ICreateStreamSolanaExt
): Promise<ICreateResult> {
const { ixs, metadata, metadataPubKey } = await this.prepareCreateInstructions(
data,
extensions
);
const { ixs, metadata, metadataPubKey } = await this.prepareCreateInstructions(data, extParams);
const { tx, hash } = await prepareTransaction(
this.connection,
ixs,
extensions.sender.publicKey,
extParams.sender.publicKey,
this.getCommitment(),
metadata
);
const signature = await signAndExecuteTransaction(this.connection, extensions.sender, tx, hash);
const signature = await signAndExecuteTransaction(this.connection, extParams.sender, tx, hash);

return { ixs, txId: signature, metadataId: metadataPubKey.toBase58() };
}
Expand Down Expand Up @@ -281,20 +278,20 @@ export default class SolanaStreamClient extends BaseStreamClient {
*/
public async createUnchecked(
data: ICreateStreamData,
extensions: ICreateStreamSolanaExt
extParams: ICreateStreamSolanaExt
): Promise<ICreateResult> {
const { ixs, metadata, metadataPubKey } = await this.prepareCreateUncheckedInstructions(
data,
extensions
extParams
);
const { tx, hash } = await prepareTransaction(
this.connection,
ixs,
extensions.sender.publicKey,
extParams.sender.publicKey,
this.getCommitment(),
metadata
);
const signature = await signAndExecuteTransaction(this.connection, extensions.sender, tx, hash);
const signature = await signAndExecuteTransaction(this.connection, extParams.sender, tx, hash);

return { ixs, txId: signature, metadataId: metadataPubKey.toBase58() };
}
Expand Down Expand Up @@ -415,7 +412,13 @@ export default class SolanaStreamClient extends BaseStreamClient {
*/
public async createMultiple(
data: ICreateMultipleStreamData,
{ sender, metadataPubKeys, isNative = false }: ICreateStreamSolanaExt
{
sender,
metadataPubKeys,
isNative = false,
computePrice,
computeLimit,
}: ICreateStreamSolanaExt
): Promise<IMultiTransactionResult> {
const { recipients } = data;

Expand Down Expand Up @@ -443,6 +446,8 @@ export default class SolanaStreamClient extends BaseStreamClient {
{
sender,
metadataPubKeys: metadataPubKeys[i] ? [metadataPubKeys[i]] : undefined,
computePrice,
computeLimit,
}
);

Expand Down Expand Up @@ -540,19 +545,19 @@ export default class SolanaStreamClient extends BaseStreamClient {
*/
public async withdraw(
{ id, amount = WITHDRAW_AVAILABLE_AMOUNT }: IWithdrawData,
{ invoker, checkTokenAccounts }: IInteractStreamSolanaExt
extParams: IInteractStreamSolanaExt
): Promise<ITransactionResult> {
const ixs: TransactionInstruction[] = await this.prepareWithdawInstructions(
{ id, amount },
{ invoker, checkTokenAccounts }
extParams
);
const { tx, hash } = await prepareTransaction(
this.connection,
ixs,
invoker.publicKey,
extParams.invoker.publicKey,
this.getCommitment()
);
const signature = await signAndExecuteTransaction(this.connection, invoker, tx, hash);
const signature = await signAndExecuteTransaction(this.connection, extParams.invoker, tx, hash);

return { ixs, txId: signature };
}
Expand Down Expand Up @@ -608,21 +613,16 @@ export default class SolanaStreamClient extends BaseStreamClient {
*/
public async cancel(
{ id }: ICancelData,
extensions: IInteractStreamSolanaExt
extParams: IInteractStreamSolanaExt
): Promise<ITransactionResult> {
const ixs = await this.prepareCancelInstructions({ id }, extensions);
const ixs = await this.prepareCancelInstructions({ id }, extParams);
const { tx, hash } = await prepareTransaction(
this.connection,
ixs,
extensions.invoker.publicKey,
extParams.invoker.publicKey,
this.getCommitment()
);
const signature = await signAndExecuteTransaction(
this.connection,
extensions.invoker,
tx,
hash
);
const signature = await signAndExecuteTransaction(this.connection, extParams.invoker, tx, hash);

return { ixs, txId: signature };
}
Expand Down Expand Up @@ -682,24 +682,19 @@ export default class SolanaStreamClient extends BaseStreamClient {
*/
public async transfer(
{ id, newRecipient }: ITransferData,
extensions: IInteractStreamSolanaExt
extParams: IInteractStreamSolanaExt
): Promise<ITransactionResult> {
const ixs: TransactionInstruction[] = await this.prepareTransferInstructions(
{ id, newRecipient },
extensions
extParams
);
const { tx, hash } = await prepareTransaction(
this.connection,
ixs,
extensions.invoker.publicKey,
extParams.invoker.publicKey,
this.getCommitment()
);
const signature = await signAndExecuteTransaction(
this.connection,
extensions.invoker,
tx,
hash
);
const signature = await signAndExecuteTransaction(this.connection, extParams.invoker, tx, hash);

return { ixs, txId: signature };
}
Expand Down Expand Up @@ -752,24 +747,19 @@ export default class SolanaStreamClient extends BaseStreamClient {
*/
public async topup(
{ id, amount }: ITopUpData,
extensions: ITopUpStreamSolanaExt
extParams: ITopUpStreamSolanaExt
): Promise<ITransactionResult> {
const ixs: TransactionInstruction[] = await this.prepareTopupInstructions(
{ id, amount },
extensions
extParams
);
const { tx, hash } = await prepareTransaction(
this.connection,
ixs,
extensions.invoker.publicKey,
extParams.invoker.publicKey,
this.getCommitment()
);
const signature = await signAndExecuteTransaction(
this.connection,
extensions.invoker,
tx,
hash
);
const signature = await signAndExecuteTransaction(this.connection, extParams.invoker, tx, hash);

return { ixs, txId: signature };
}
Expand Down Expand Up @@ -888,21 +878,16 @@ export default class SolanaStreamClient extends BaseStreamClient {
*/
public async update(
data: IUpdateData,
extensions: IInteractStreamSolanaExt
extParams: IInteractStreamSolanaExt
): Promise<ITransactionResult> {
const ixs = await this.prepareUpdateInstructions(data, extensions);
const ixs = await this.prepareUpdateInstructions(data, extParams);
const { tx, hash } = await prepareTransaction(
this.connection,
ixs,
extensions.invoker.publicKey,
extParams.invoker.publicKey,
this.getCommitment()
);
const signature = await signAndExecuteTransaction(
this.connection,
extensions.invoker,
tx,
hash
);
const signature = await signAndExecuteTransaction(this.connection, extParams.invoker, tx, hash);

return {
ixs,
Expand Down Expand Up @@ -979,7 +964,7 @@ export default class SolanaStreamClient extends BaseStreamClient {
private async prepareStreamInstructions(
recipient: IRecipient,
streamParams: IStreamConfig,
solanaExtendedConfig: ICreateStreamSolanaExt
extParams: ICreateStreamSolanaExt
): Promise<{
ixs: TransactionInstruction[];
metadata: Keypair | undefined;
Expand All @@ -1000,7 +985,7 @@ export default class SolanaStreamClient extends BaseStreamClient {
partner,
} = streamParams;

const { sender, metadataPubKeys } = solanaExtendedConfig;
const { sender, metadataPubKeys } = extParams;

if (!sender.publicKey) {
throw new Error("Sender's PublicKey is not available, check passed wallet adapter!");
Expand Down

0 comments on commit 707516c

Please sign in to comment.