diff --git a/lerna.json b/lerna.json index 08742307..d559659e 100644 --- a/lerna.json +++ b/lerna.json @@ -2,6 +2,6 @@ "packages": [ "packages/*" ], - "version": "6.3.8", + "version": "6.3.9", "$schema": "node_modules/lerna/schemas/lerna-schema.json" } diff --git a/packages/common/package.json b/packages/common/package.json index 89a3515b..75872df4 100644 --- a/packages/common/package.json +++ b/packages/common/package.json @@ -1,6 +1,6 @@ { "name": "@streamflow/common", - "version": "6.3.8", + "version": "6.3.9", "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 eb07479c..08363b4e 100644 --- a/packages/distributor/package.json +++ b/packages/distributor/package.json @@ -1,6 +1,6 @@ { "name": "@streamflow/distributor", - "version": "6.3.8", + "version": "6.3.9", "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/eslint-config/package.json b/packages/eslint-config/package.json index e670e4f7..2d5b4ada 100644 --- a/packages/eslint-config/package.json +++ b/packages/eslint-config/package.json @@ -1,6 +1,6 @@ { "name": "@streamflow/eslint-config", - "version": "6.3.8", + "version": "6.3.9", "license": "ISC", "main": "index.js", "files": [ diff --git a/packages/stream/README.md b/packages/stream/README.md index 01766106..b0fbdf81 100644 --- a/packages/stream/README.md +++ b/packages/stream/README.md @@ -150,6 +150,7 @@ const createStreamParams: Types.ICreateStreamData = { amountPerPeriod: getBN(5, 9), // Release rate: how many tokens are unlocked per each period. name: "Transfer to Jane Doe.", // The stream name or subject. canTopup: false, // setting to FALSE will effectively create a vesting contract. + canUpdateRate: false, // settings to TRUE allows sender to update amountPerPeriod cancelableBySender: true, // Whether or not sender can cancel the stream. cancelableByRecipient: false, // Whether or not recipient can cancel the stream. transferableBySender: true, // Whether or not sender can transfer the stream. @@ -161,7 +162,7 @@ const createStreamParams: Types.ICreateStreamData = { const solanaParams = { sender: wallet, // SignerWalletAdapter or Keypair of Sender account - isNative: // [optional] [WILL CREATE A wSOL STREAM] Wether Stream or Vesting should be paid with Solana native token or not + isNative: false // [optional] [WILL CREATE A wSOL STREAM] Wether Stream or Vesting should be paid with Solana native token or not }; const aptosParams = { @@ -371,6 +372,37 @@ try { } ``` +## Update a stream + +```javascript +const updateStreamParams: Types.IUpdateData = { + id: "AAAAyotqTZZMAAAAmsD1JAgksT8NVAAAASfrGB5RAAAA", // Identifier of a stream to update. + enableAutomaticWithdrawal: true, // [optional], allows to enable AW if it wasn't, disable is not possible + withdrawFrequency: 60, // [optional], allows to update withdrawal frequency, may result in additional AW fees + amountPerPeriod: getBN(10, 9), // [optional], allows to update release amount effective on next unlock +} + +const solanaParams = { + invoker: wallet, // SignerWalletAdapter or Keypair signing the transaction +}; + +const aptosParams = { + senderWallet: wallet, // AptosWalletAdapter Wallet of wallet signing the transaction +}; + +const suiParams = { + senderWallet: wallet, // WalletContextState | Keypair +}; + +const ethereumParams = undefined; + +try { + const { ixs, tx } = await client.update(updateStreamParams, solanaParams); +} catch (exception) { + // handle exception +} +``` + ## Get one stream by its ID ```javascript diff --git a/packages/stream/package.json b/packages/stream/package.json index 738283cb..fa35b277 100644 --- a/packages/stream/package.json +++ b/packages/stream/package.json @@ -1,6 +1,6 @@ { "name": "@streamflow/stream", - "version": "6.3.8", + "version": "6.3.9", "description": "JavaScript SDK to interact with Streamflow protocol.", "homepage": "https://github.com/streamflow-finance/js-sdk/", "main": "dist/index.js", diff --git a/packages/stream/solana/StreamClient.ts b/packages/stream/solana/StreamClient.ts index 68cc688c..4c27c4f5 100644 --- a/packages/stream/solana/StreamClient.ts +++ b/packages/stream/solana/StreamClient.ts @@ -181,6 +181,8 @@ export default class SolanaStreamClient extends BaseStreamClient { cliffAmount, amountPerPeriod, name, + canPause, + canUpdateRate, canTopup, cancelableBySender, cancelableByRecipient, @@ -245,6 +247,8 @@ export default class SolanaStreamClient extends BaseStreamClient { transferableBySender, transferableByRecipient, canTopup, + canUpdateRate: !!canUpdateRate, + canPause: !!canPause, name, withdrawFrequency: new BN(automaticWithdrawal ? withdrawalFrequency : period), }, @@ -324,6 +328,8 @@ export default class SolanaStreamClient extends BaseStreamClient { amountPerPeriod, name, canTopup, + canUpdateRate, + canPause, cancelableBySender, cancelableByRecipient, transferableBySender, @@ -389,6 +395,8 @@ export default class SolanaStreamClient extends BaseStreamClient { transferableBySender, transferableByRecipient, canTopup, + canUpdateRate: !!canUpdateRate, + canPause: !!canPause, name, withdrawFrequency: new BN(automaticWithdrawal ? withdrawalFrequency : period), recipient: recipientPublicKey, @@ -986,6 +994,8 @@ export default class SolanaStreamClient extends BaseStreamClient { period, cliff, canTopup, + canUpdateRate, + canPause, cancelableBySender, cancelableByRecipient, transferableBySender, @@ -1035,6 +1045,8 @@ export default class SolanaStreamClient extends BaseStreamClient { transferableBySender, transferableByRecipient, canTopup, + canUpdateRate: !!canUpdateRate, + canPause: !!canPause, name: recipient.name, withdrawFrequency: new BN(automaticWithdrawal ? withdrawalFrequency : period), }, diff --git a/packages/stream/solana/instructions.ts b/packages/stream/solana/instructions.ts index 0d69fc7d..22041151 100644 --- a/packages/stream/solana/instructions.ts +++ b/packages/stream/solana/instructions.ts @@ -19,6 +19,8 @@ interface CreateStreamData { transferableBySender: boolean; transferableByRecipient: boolean; canTopup: boolean; + canUpdateRate: boolean; + canPause: boolean; name: string; withdrawFrequency: BN; } @@ -100,6 +102,10 @@ export const createStreamInstruction = ( transferable_by_sender: Number(data.transferableBySender), transferable_by_recipient: Number(data.transferableByRecipient), can_topup: Number(data.canTopup), + _pausable_discriminator: 1, + can_update_rate: Number(data.canUpdateRate), + _can_update_rate_discriminator: 1, + pausable: Number(data.canPause), stream_name: streamNameBuffer, withdraw_frequency: data.withdrawFrequency.toArrayLike(Buffer, "le", 8), }; @@ -127,6 +133,8 @@ interface CreateUncheckedStreamData { transferableBySender: boolean; transferableByRecipient: boolean; canTopup: boolean; + canUpdateRate: boolean; + canPause: boolean; name: string; withdrawFrequency: BN; recipient: PublicKey; @@ -197,8 +205,8 @@ export const createUncheckedStreamInstruction = ( withdraw_frequency: data.withdrawFrequency.toArrayLike(Buffer, "le", 8), recipient: data.recipient.toBuffer(), partner: data.partner.toBuffer(), - pausable: 1, - can_update_rate: 1, + pausable: Number(data.canPause), + can_update_rate: Number(data.canUpdateRate), }; const encodeLength = Layout.createUncheckedStreamLayout.encode(decodedData, bufferData); bufferData = bufferData.slice(0, encodeLength); diff --git a/packages/stream/solana/layout.ts b/packages/stream/solana/layout.ts index 685dc2b2..89e5867f 100644 --- a/packages/stream/solana/layout.ts +++ b/packages/stream/solana/layout.ts @@ -91,6 +91,12 @@ export const createStreamLayout: BufferLayout.Structure = B BufferLayout.u8("can_topup"), BufferLayout.blob(64, "stream_name"), BufferLayout.blob(8, "withdraw_frequency"), + // discriminator for optional field + BufferLayout.u8("_pausable_discriminator"), + BufferLayout.u8("pausable"), + // discriminator for optional field + BufferLayout.u8("_can_update_rate_discriminator"), + BufferLayout.u8("can_update_rate"), ]); /**