@streamflow/stream 7.3.0 → 7.3.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.
@@ -1,9 +1,10 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ const bcs_1 = require("@mysten/bcs");
3
4
  const client_1 = require("@mysten/sui/client");
4
5
  const transactions_1 = require("@mysten/sui/transactions");
5
6
  const utils_1 = require("@mysten/sui/utils");
6
- const bcs_1 = require("@mysten/sui/bcs");
7
+ const bcs_2 = require("@mysten/sui/bcs");
7
8
  const BaseStreamClient_js_1 = require("../common/BaseStreamClient.js");
8
9
  const types_js_1 = require("../common/types.js");
9
10
  const constants_js_1 = require("./constants.js");
@@ -62,7 +63,34 @@ class SuiStreamClient extends BaseStreamClient_js_1.BaseStreamClient {
62
63
  options: { showEffects: true, showEvents: true },
63
64
  });
64
65
  txs.push(digest);
65
- if (effects.status.status === "failure") {
66
+ // effects may be string according to Sui Wallet standard
67
+ // https://github.com/MystenLabs/ts-sdks/blob/main/packages/wallet-standard/src/features/suiSignAndExecuteTransaction.ts#L34
68
+ // Loosely ported from https://github.com/MystenLabs/ts-sdks/blob/main/packages/graphql-transport/src/mappers/transaction-block.ts#L376
69
+ let effectsShort = undefined;
70
+ if (typeof effects === "string") {
71
+ const parsedEffects = bcs_2.bcs.TransactionEffects.parse((0, bcs_1.fromBase64)(effects));
72
+ const currentEffects = parsedEffects.V2 || parsedEffects.V1;
73
+ if (currentEffects) {
74
+ effectsShort = currentEffects.status.Success
75
+ ? {
76
+ status: "success",
77
+ }
78
+ : {
79
+ status: "failure",
80
+ error: currentEffects.status.$kind,
81
+ };
82
+ }
83
+ }
84
+ else if (effects && effects.status) {
85
+ effectsShort = {
86
+ status: effects.status.status,
87
+ error: effects.status.error,
88
+ };
89
+ }
90
+ if (!effectsShort) {
91
+ console.warn(`Got no effects from the transaction ${digest}, raw: ${effects}`);
92
+ }
93
+ if (effectsShort?.status === "failure") {
66
94
  multipleStreamData.recipients.forEach((recipient) => {
67
95
  errors.push({
68
96
  error: effects.status.error ?? "Unknown error!",
@@ -228,14 +256,14 @@ class SuiStreamClient extends BaseStreamClient_js_1.BaseStreamClient {
228
256
  tx.object(this.configId),
229
257
  tx.object(utils_1.SUI_CLOCK_OBJECT_ID),
230
258
  tx.gas,
231
- bcs_1.bcs
232
- .vector(bcs_1.bcs.bool())
259
+ bcs_2.bcs
260
+ .vector(bcs_2.bcs.bool())
233
261
  .serialize(updateData.enableAutomaticWithdrawal !== undefined ? [updateData.enableAutomaticWithdrawal] : []),
234
- bcs_1.bcs
235
- .vector(bcs_1.bcs.u64())
262
+ bcs_2.bcs
263
+ .vector(bcs_2.bcs.u64())
236
264
  .serialize(updateData.withdrawFrequency !== undefined ? [updateData.withdrawFrequency.toString()] : []),
237
- bcs_1.bcs
238
- .vector(bcs_1.bcs.u64())
265
+ bcs_2.bcs
266
+ .vector(bcs_2.bcs.u64())
239
267
  .serialize(updateData.amountPerPeriod !== undefined ? [updateData.amountPerPeriod.toString()] : []),
240
268
  ],
241
269
  });
@@ -1,3 +1,4 @@
1
+ import { fromBase64 } from "@mysten/bcs";
1
2
  import { SuiClient } from "@mysten/sui/client";
2
3
  import { Transaction } from "@mysten/sui/transactions";
3
4
  import { SUI_CLOCK_OBJECT_ID, SUI_TYPE_ARG } from "@mysten/sui/utils";
@@ -64,7 +65,34 @@ export default class SuiStreamClient extends BaseStreamClient {
64
65
  options: { showEffects: true, showEvents: true },
65
66
  });
66
67
  txs.push(digest);
67
- if (effects.status.status === "failure") {
68
+ // effects may be string according to Sui Wallet standard
69
+ // https://github.com/MystenLabs/ts-sdks/blob/main/packages/wallet-standard/src/features/suiSignAndExecuteTransaction.ts#L34
70
+ // Loosely ported from https://github.com/MystenLabs/ts-sdks/blob/main/packages/graphql-transport/src/mappers/transaction-block.ts#L376
71
+ let effectsShort = undefined;
72
+ if (typeof effects === "string") {
73
+ const parsedEffects = bcs.TransactionEffects.parse(fromBase64(effects));
74
+ const currentEffects = parsedEffects.V2 || parsedEffects.V1;
75
+ if (currentEffects) {
76
+ effectsShort = currentEffects.status.Success
77
+ ? {
78
+ status: "success",
79
+ }
80
+ : {
81
+ status: "failure",
82
+ error: currentEffects.status.$kind,
83
+ };
84
+ }
85
+ }
86
+ else if (effects && effects.status) {
87
+ effectsShort = {
88
+ status: effects.status.status,
89
+ error: effects.status.error,
90
+ };
91
+ }
92
+ if (!effectsShort) {
93
+ console.warn(`Got no effects from the transaction ${digest}, raw: ${effects}`);
94
+ }
95
+ if (effectsShort?.status === "failure") {
68
96
  multipleStreamData.recipients.forEach((recipient) => {
69
97
  errors.push({
70
98
  error: effects.status.error ?? "Unknown error!",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@streamflow/stream",
3
- "version": "7.3.0",
3
+ "version": "7.3.1",
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": "3c9abdd18e875a64cbd7d1ba4b14ee4bcb094b11",
45
+ "gitHead": "1c65f9af2f486790e926beb8a6103f42ea805311",
46
46
  "devDependencies": {
47
- "@streamflow/eslint-config": "7.3.0",
47
+ "@streamflow/eslint-config": "7.3.1",
48
48
  "@types/bn.js": "5.1.1",
49
49
  "@types/ethereum-checksum-address": "^0.0.0",
50
50
  "date-fns": "2.28.0",
@@ -54,12 +54,13 @@
54
54
  "@coral-xyz/anchor": "^0.30.1",
55
55
  "@coral-xyz/borsh": "0.30.1",
56
56
  "@manahippo/aptos-wallet-adapter": "1.0.10",
57
+ "@mysten/bcs": "1.1.0",
57
58
  "@mysten/sui": "1.12.0",
58
59
  "@solana/buffer-layout": "4.0.1",
59
60
  "@solana/spl-token": "0.4.9",
60
61
  "@solana/wallet-adapter-base": "0.9.19",
61
62
  "@solana/web3.js": "1.95.4",
62
- "@streamflow/common": "7.3.0",
63
+ "@streamflow/common": "7.3.1",
63
64
  "@suiet/wallet-kit": "^0.3.3",
64
65
  "aptos": "1.21.0",
65
66
  "bn.js": "5.2.1",