Skip to content

Commit 1c65f9a

Browse files
authored
support bcs effects parsing (#248)
* support bcs effects parsing
1 parent 3c9abdd commit 1c65f9a

File tree

10 files changed

+41
-9
lines changed

10 files changed

+41
-9
lines changed

lerna.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,6 @@
22
"packages": [
33
"packages/*"
44
],
5-
"version": "7.3.0",
5+
"version": "7.3.1",
66
"$schema": "node_modules/lerna/schemas/lerna-schema.json"
77
}

packages/common/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@streamflow/common",
3-
"version": "7.3.0",
3+
"version": "7.3.1",
44
"description": "Common utilities and types used by streamflow packages.",
55
"homepage": "https://github.com/streamflow-finance/js-sdk/",
66
"main": "./dist/esm/index.js",

packages/distributor/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@streamflow/distributor",
3-
"version": "7.3.0",
3+
"version": "7.3.1",
44
"description": "JavaScript SDK to interact with Streamflow Airdrop protocol.",
55
"homepage": "https://github.com/streamflow-finance/js-sdk/",
66
"main": "dist/esm/index.js",

packages/eslint-config/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ module.exports = {
3636
"react/jsx-filename-extension": "off",
3737
"@typescript-eslint/no-throw-literal": "off",
3838
"no-debugger": "warn",
39-
"no-console": "warn",
39+
"no-console": ["warn", { allow: ["warn"] }],
4040
"import/prefer-default-export": "off",
4141
"import/no-unresolved": "warn",
4242
"no-plusplus": "off",

packages/eslint-config/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@streamflow/eslint-config",
3-
"version": "7.3.0",
3+
"version": "7.3.1",
44
"license": "ISC",
55
"main": "index.js",
66
"files": [

packages/launchpad/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@streamflow/launchpad",
3-
"version": "7.3.0",
3+
"version": "7.3.1",
44
"description": "JavaScript SDK to interact with Streamflow Launchpad protocol.",
55
"homepage": "https://github.com/streamflow-finance/js-sdk/",
66
"main": "dist/esm/index.js",

packages/staking/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@streamflow/staking",
3-
"version": "7.3.0",
3+
"version": "7.3.1",
44
"description": "JavaScript SDK to interact with Streamflow Staking protocol.",
55
"homepage": "https://github.com/streamflow-finance/js-sdk/",
66
"main": "dist/esm/index.js",

packages/stream/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@streamflow/stream",
3-
"version": "7.3.0",
3+
"version": "7.3.1",
44
"description": "JavaScript SDK to interact with Streamflow protocol.",
55
"homepage": "https://github.com/streamflow-finance/js-sdk/",
66
"main": "./dist/esm/index.js",
@@ -54,6 +54,7 @@
5454
"@coral-xyz/anchor": "^0.30.1",
5555
"@coral-xyz/borsh": "0.30.1",
5656
"@manahippo/aptos-wallet-adapter": "1.0.10",
57+
"@mysten/bcs": "1.1.0",
5758
"@mysten/sui": "1.12.0",
5859
"@solana/buffer-layout": "4.0.1",
5960
"@solana/spl-token": "0.4.9",

packages/stream/sui/StreamClient.ts

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import BN from "bn.js";
2+
import { fromBase64 } from "@mysten/bcs";
23
import { CoinStruct, SuiClient } from "@mysten/sui/client";
34
import { Transaction, TransactionObjectArgument } from "@mysten/sui/transactions";
45
import { SUI_CLOCK_OBJECT_ID, SUI_TYPE_ARG } from "@mysten/sui/utils";
@@ -114,7 +115,34 @@ export default class SuiStreamClient extends BaseStreamClient {
114115
});
115116
txs.push(digest);
116117

117-
if (effects!.status.status === "failure") {
118+
// effects may be string according to Sui Wallet standard
119+
// https://github.com/MystenLabs/ts-sdks/blob/main/packages/wallet-standard/src/features/suiSignAndExecuteTransaction.ts#L34
120+
// Loosely ported from https://github.com/MystenLabs/ts-sdks/blob/main/packages/graphql-transport/src/mappers/transaction-block.ts#L376
121+
let effectsShort: { status: "success" | "failure"; error?: string } | undefined = undefined;
122+
if (typeof effects === "string") {
123+
const parsedEffects = bcs.TransactionEffects.parse(fromBase64(effects));
124+
const currentEffects = parsedEffects.V2 || parsedEffects.V1;
125+
if (currentEffects) {
126+
effectsShort = currentEffects.status.Success
127+
? {
128+
status: "success",
129+
}
130+
: {
131+
status: "failure",
132+
error: currentEffects.status.$kind,
133+
};
134+
}
135+
} else if (effects && effects.status) {
136+
effectsShort = {
137+
status: effects.status.status,
138+
error: effects.status.error,
139+
};
140+
}
141+
if (!effectsShort) {
142+
console.warn(`Got no effects from the transaction ${digest}, raw: ${effects}`);
143+
}
144+
145+
if (effectsShort?.status === "failure") {
118146
multipleStreamData.recipients.forEach((recipient) => {
119147
errors.push({
120148
error: effects!.status.error ?? "Unknown error!",

pnpm-lock.yaml

Lines changed: 3 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)