@streamflow/stream 7.4.3 → 7.4.5

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.
@@ -65,7 +65,7 @@ class SuiStreamClient extends BaseStreamClient_js_1.BaseStreamClient {
65
65
  // effects may be string according to Sui Wallet standard, events won't even be returned
66
66
  // https://github.com/MystenLabs/ts-sdks/blob/main/packages/wallet-standard/src/features/suiSignAndExecuteTransaction.ts#L34
67
67
  const { events, effects } = !executedTx.effects || typeof executedTx.effects === "string"
68
- ? await this.client.getTransactionBlock({ digest, options: { showEvents: true, showEffects: true } })
68
+ ? await (0, utils_js_1.getTransactionBlock)(this.client, { digest, options: { showEvents: true, showEffects: true } })
69
69
  : executedTx;
70
70
  txs.push(digest);
71
71
  if (effects.status.status === "failure") {
@@ -1,6 +1,11 @@
1
1
  "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
2
5
  Object.defineProperty(exports, "__esModule", { value: true });
3
6
  exports.extractSuiErrorInfo = extractSuiErrorInfo;
7
+ exports.getTransactionBlock = getTransactionBlock;
8
+ const p_retry_1 = __importDefault(require("p-retry"));
4
9
  const constants_js_1 = require("./constants.js");
5
10
  function extractSuiErrorInfo(errorText) {
6
11
  const error = { text: errorText };
@@ -24,3 +29,18 @@ function extractSuiErrorInfo(errorText) {
24
29
  }
25
30
  return error;
26
31
  }
32
+ /**
33
+ * Fetches transaction block with a retry:
34
+ * retries `Could not find the referenced transaction` error as it could be that some validators still don't have the tx;
35
+ *
36
+ * @param client sui client to use
37
+ * @param input transaction fetch payload,
38
+ */
39
+ function getTransactionBlock(client, input) {
40
+ return (0, p_retry_1.default)(() => client.getTransactionBlock(input), {
41
+ retries: 5,
42
+ shouldRetry: (error) => error.message.includes("Could not find the referenced transaction"),
43
+ minTimeout: 500,
44
+ maxTimeout: 1000,
45
+ });
46
+ }
@@ -6,7 +6,7 @@ import { BaseStreamClient } from "../common/BaseStreamClient.js";
6
6
  import { ICluster, } from "../common/types.js";
7
7
  import { SUI_PROGRAM_IDS, SUI_FEE_TABLE_IDS, SUI_CONFIG_IDS } from "./constants.js";
8
8
  import { Contract, } from "./types.js";
9
- import { extractSuiErrorInfo } from "./utils.js";
9
+ import { extractSuiErrorInfo, getTransactionBlock } from "./utils.js";
10
10
  import { SuiWalletWrapper } from "./wallet.js";
11
11
  import { calculateTotalAmountToDeposit } from "../common/utils.js";
12
12
  import { WITHDRAW_AVAILABLE_AMOUNT } from "../common/constants.js";
@@ -67,7 +67,7 @@ export default class SuiStreamClient extends BaseStreamClient {
67
67
  // effects may be string according to Sui Wallet standard, events won't even be returned
68
68
  // https://github.com/MystenLabs/ts-sdks/blob/main/packages/wallet-standard/src/features/suiSignAndExecuteTransaction.ts#L34
69
69
  const { events, effects } = !executedTx.effects || typeof executedTx.effects === "string"
70
- ? await this.client.getTransactionBlock({ digest, options: { showEvents: true, showEffects: true } })
70
+ ? await getTransactionBlock(this.client, { digest, options: { showEvents: true, showEffects: true } })
71
71
  : executedTx;
72
72
  txs.push(digest);
73
73
  if (effects.status.status === "failure") {
@@ -1,2 +1,11 @@
1
+ import { GetTransactionBlockParams, SuiClient, SuiTransactionBlockResponse } from "@mysten/sui/client";
1
2
  import { SuiErrorInfo } from "./types.js";
2
3
  export declare function extractSuiErrorInfo(errorText: string): SuiErrorInfo;
4
+ /**
5
+ * Fetches transaction block with a retry:
6
+ * retries `Could not find the referenced transaction` error as it could be that some validators still don't have the tx;
7
+ *
8
+ * @param client sui client to use
9
+ * @param input transaction fetch payload,
10
+ */
11
+ export declare function getTransactionBlock(client: SuiClient, input: GetTransactionBlockParams): Promise<SuiTransactionBlockResponse>;
@@ -1,3 +1,4 @@
1
+ import pRetry from "p-retry";
1
2
  import { SUI_ERROR_MATCH_REGEX, SUI_MODULE_ERROR_MAP } from "./constants.js";
2
3
  export function extractSuiErrorInfo(errorText) {
3
4
  const error = { text: errorText };
@@ -21,3 +22,18 @@ export function extractSuiErrorInfo(errorText) {
21
22
  }
22
23
  return error;
23
24
  }
25
+ /**
26
+ * Fetches transaction block with a retry:
27
+ * retries `Could not find the referenced transaction` error as it could be that some validators still don't have the tx;
28
+ *
29
+ * @param client sui client to use
30
+ * @param input transaction fetch payload,
31
+ */
32
+ export function getTransactionBlock(client, input) {
33
+ return pRetry(() => client.getTransactionBlock(input), {
34
+ retries: 5,
35
+ shouldRetry: (error) => error.message.includes("Could not find the referenced transaction"),
36
+ minTimeout: 500,
37
+ maxTimeout: 1000,
38
+ });
39
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@streamflow/stream",
3
- "version": "7.4.3",
3
+ "version": "7.4.5",
4
4
  "description": "JavaScript SDK to interact with Streamflow protocol.",
5
5
  "homepage": "https://github.com/streamflow-finance/js-sdk/",
6
6
  "main": "./dist/esm/index.js",
@@ -42,9 +42,9 @@
42
42
  "lint": "eslint --fix .",
43
43
  "prepublishOnly": "pnpm run lint && pnpm run test run && pnpm run build"
44
44
  },
45
- "gitHead": "e22bbb3f9755ab0c1824b35f1781da39dea690a7",
45
+ "gitHead": "7d8607909df7a3bad5b620efdf3f35b3d831c109",
46
46
  "devDependencies": {
47
- "@streamflow/eslint-config": "7.4.3",
47
+ "@streamflow/eslint-config": "7.4.5",
48
48
  "@types/bn.js": "5.1.1",
49
49
  "@types/ethereum-checksum-address": "^0.0.0",
50
50
  "date-fns": "2.28.0",
@@ -59,7 +59,7 @@
59
59
  "@solana/spl-token": "0.4.9",
60
60
  "@solana/wallet-adapter-base": "0.9.19",
61
61
  "@solana/web3.js": "1.95.4",
62
- "@streamflow/common": "7.4.3",
62
+ "@streamflow/common": "7.4.5",
63
63
  "@suiet/wallet-kit": "^0.3.3",
64
64
  "aptos": "1.21.0",
65
65
  "bn.js": "5.2.1",
@@ -67,6 +67,7 @@
67
67
  "bs58": "5.0.0",
68
68
  "ethereum-checksum-address": "0.0.8",
69
69
  "ethers": "5.7.2",
70
- "p-queue": "^8.0.1"
70
+ "p-queue": "^8.0.1",
71
+ "p-retry": "^6.2.1"
71
72
  }
72
73
  }