@streamflow/common 6.0.0-alpha.9 → 6.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -24,12 +24,6 @@ export declare function isSignerWallet(walletOrKeypair: Keypair | SignerWalletAd
24
24
  export declare function isSignerKeypair(walletOrKeypair: Keypair | SignerWalletAdapter): walletOrKeypair is Keypair;
25
25
  /**
26
26
  * Creates a Transaction with given instructions and optionally signs it.
27
- * Be careful when passing `commitment` as for `confirmed` blockhash it always returns blockheight + 300 in `lastValidBlockHeight`
28
- * And if you use this blockheight to confirm the transaction it could happen so that transaction is successfully executed
29
- * But because `confirmTransaction` waits for only a minute it considers tx as expired as it could be that 300 blocks won't pass in a minute
30
- * https://solana.stackexchange.com/questions/6238/why-is-lastvalidblockheight-300-blocks-ahead-than-current-blockheight-if-hashes
31
- * https://solana.com/docs/core/transactions/retry
32
- * It might be better to rely on `commitment` level that you pass to `Connection` instance of Solana client as it will be used when fetching blockheight on transaction confirmation
33
27
  * @param connection - Solana client connection
34
28
  * @param ixs - Instructions to add to the Transaction
35
29
  * @param payer - PublicKey of payer
@@ -44,6 +38,10 @@ export declare function prepareTransaction(connection: Connection, ixs: Transact
44
38
  export declare function signTransaction(invoker: Keypair | SignerWalletAdapter, tx: Transaction): Promise<Transaction>;
45
39
  /**
46
40
  * Signs, sends and confirms Transaction
41
+ * Confirmation strategy is not 100% reliable here as in times of congestion there can be a case that tx is executed,
42
+ * but is not in `commitment` state and so it's not considered executed by the `sendAndConfirmRawTransaction` method,
43
+ * and it raises an expiry error even though transaction may be executed soon.
44
+ * So we add additional 50 blocks for checks to account for such issues.
47
45
  * @param connection - Solana client connection
48
46
  * @param invoker - Keypair used as signer
49
47
  * @param tx - Transaction instance
@@ -69,7 +67,7 @@ export declare function ataBatchExist(connection: Connection, paramsBatch: AtaPa
69
67
  * Generates a Transaction to create ATA for an array of owners
70
68
  * @param connection - Solana client connection
71
69
  * @param payer - Transaction invoker, should be a signer
72
- * @param coparamsBatchnfigs - Array of Params for an each ATA account: {mint, owner}
70
+ * @param paramsBatch - Array of Params for an each ATA account: {mint, owner}
73
71
  * @returns Unsigned Transaction with create ATA instructions
74
72
  */
75
73
  export declare function generateCreateAtaBatchTx(connection: Connection, payer: PublicKey, paramsBatch: AtaParams[]): Promise<{
@@ -126,12 +126,6 @@ function isSignerKeypair(walletOrKeypair) {
126
126
  exports.isSignerKeypair = isSignerKeypair;
127
127
  /**
128
128
  * Creates a Transaction with given instructions and optionally signs it.
129
- * Be careful when passing `commitment` as for `confirmed` blockhash it always returns blockheight + 300 in `lastValidBlockHeight`
130
- * And if you use this blockheight to confirm the transaction it could happen so that transaction is successfully executed
131
- * But because `confirmTransaction` waits for only a minute it considers tx as expired as it could be that 300 blocks won't pass in a minute
132
- * https://solana.stackexchange.com/questions/6238/why-is-lastvalidblockheight-300-blocks-ahead-than-current-blockheight-if-hashes
133
- * https://solana.com/docs/core/transactions/retry
134
- * It might be better to rely on `commitment` level that you pass to `Connection` instance of Solana client as it will be used when fetching blockheight on transaction confirmation
135
129
  * @param connection - Solana client connection
136
130
  * @param ixs - Instructions to add to the Transaction
137
131
  * @param payer - PublicKey of payer
@@ -201,6 +195,10 @@ function signTransaction(invoker, tx) {
201
195
  exports.signTransaction = signTransaction;
202
196
  /**
203
197
  * Signs, sends and confirms Transaction
198
+ * Confirmation strategy is not 100% reliable here as in times of congestion there can be a case that tx is executed,
199
+ * but is not in `commitment` state and so it's not considered executed by the `sendAndConfirmRawTransaction` method,
200
+ * and it raises an expiry error even though transaction may be executed soon.
201
+ * So we add additional 50 blocks for checks to account for such issues.
204
202
  * @param connection - Solana client connection
205
203
  * @param invoker - Keypair used as signer
206
204
  * @param tx - Transaction instance
@@ -209,7 +207,7 @@ exports.signTransaction = signTransaction;
209
207
  */
210
208
  function signAndExecuteTransaction(connection, invoker, tx, hash) {
211
209
  return __awaiter(this, void 0, void 0, function () {
212
- var signedTx, rawTx, confirmationStrategy, signature;
210
+ var signedTx, rawTx, confirmationStrategy;
213
211
  return __generator(this, function (_a) {
214
212
  switch (_a.label) {
215
213
  case 0: return [4 /*yield*/, signTransaction(invoker, tx)];
@@ -219,14 +217,11 @@ function signAndExecuteTransaction(connection, invoker, tx, hash) {
219
217
  if (!hash.lastValidBlockHeight || !signedTx.signature || !hash.blockhash)
220
218
  throw Error("Error with transaction parameters.");
221
219
  confirmationStrategy = {
222
- lastValidBlockHeight: hash.lastValidBlockHeight,
220
+ lastValidBlockHeight: hash.lastValidBlockHeight + 50,
223
221
  signature: bs58_1.default.encode(signedTx.signature),
224
222
  blockhash: hash.blockhash,
225
223
  };
226
- return [4 /*yield*/, (0, web3_js_1.sendAndConfirmRawTransaction)(connection, rawTx, confirmationStrategy)];
227
- case 2:
228
- signature = _a.sent();
229
- return [2 /*return*/, signature];
224
+ return [2 /*return*/, (0, web3_js_1.sendAndConfirmRawTransaction)(connection, rawTx, confirmationStrategy)];
230
225
  }
231
226
  });
232
227
  });
@@ -283,7 +278,7 @@ exports.ataBatchExist = ataBatchExist;
283
278
  * Generates a Transaction to create ATA for an array of owners
284
279
  * @param connection - Solana client connection
285
280
  * @param payer - Transaction invoker, should be a signer
286
- * @param coparamsBatchnfigs - Array of Params for an each ATA account: {mint, owner}
281
+ * @param paramsBatch - Array of Params for an each ATA account: {mint, owner}
287
282
  * @returns Unsigned Transaction with create ATA instructions
288
283
  */
289
284
  function generateCreateAtaBatchTx(connection, payer, paramsBatch) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@streamflow/common",
3
- "version": "6.0.0-alpha.9",
3
+ "version": "6.0.1",
4
4
  "description": "Common utilities and types used by streamflow packages.",
5
5
  "homepage": "https://github.com/streamflow-finance/js-sdk/",
6
6
  "main": "dist/index.js",
@@ -23,9 +23,9 @@
23
23
  "lint-config": "eslint --print-config",
24
24
  "prepublishOnly": "npm run lint && npm run build"
25
25
  },
26
- "gitHead": "ced180a9f3c99ae6b5dab7f2dca3309390e35e59",
26
+ "gitHead": "07782122a48131b4589edd9c536bb7f29dcbe0c9",
27
27
  "devDependencies": {
28
- "@streamflow/eslint-config": "6.0.0-alpha.9",
28
+ "@streamflow/eslint-config": "6.0.0",
29
29
  "@types/bn.js": "5.1.1",
30
30
  "@types/jest": "29.2.4",
31
31
  "date-fns": "2.28.0",