Skip to content

Commit

Permalink
refetch transaction after confirming on sui (#249)
Browse files Browse the repository at this point in the history
* refetch transaction after confirming on sui

* v7.3.2
  • Loading branch information
Yolley authored Jan 17, 2025
1 parent 1c65f9a commit a7e696a
Show file tree
Hide file tree
Showing 8 changed files with 16 additions and 38 deletions.
2 changes: 1 addition & 1 deletion lerna.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@
"packages": [
"packages/*"
],
"version": "7.3.1",
"version": "7.3.2",
"$schema": "node_modules/lerna/schemas/lerna-schema.json"
}
2 changes: 1 addition & 1 deletion packages/common/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@streamflow/common",
"version": "7.3.1",
"version": "7.3.2",
"description": "Common utilities and types used by streamflow packages.",
"homepage": "https://github.com/streamflow-finance/js-sdk/",
"main": "./dist/esm/index.js",
Expand Down
2 changes: 1 addition & 1 deletion packages/distributor/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@streamflow/distributor",
"version": "7.3.1",
"version": "7.3.2",
"description": "JavaScript SDK to interact with Streamflow Airdrop protocol.",
"homepage": "https://github.com/streamflow-finance/js-sdk/",
"main": "dist/esm/index.js",
Expand Down
2 changes: 1 addition & 1 deletion packages/eslint-config/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@streamflow/eslint-config",
"version": "7.3.1",
"version": "7.3.2",
"license": "ISC",
"main": "index.js",
"files": [
Expand Down
2 changes: 1 addition & 1 deletion packages/launchpad/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@streamflow/launchpad",
"version": "7.3.1",
"version": "7.3.2",
"description": "JavaScript SDK to interact with Streamflow Launchpad protocol.",
"homepage": "https://github.com/streamflow-finance/js-sdk/",
"main": "dist/esm/index.js",
Expand Down
2 changes: 1 addition & 1 deletion packages/staking/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@streamflow/staking",
"version": "7.3.1",
"version": "7.3.2",
"description": "JavaScript SDK to interact with Streamflow Staking protocol.",
"homepage": "https://github.com/streamflow-finance/js-sdk/",
"main": "dist/esm/index.js",
Expand Down
3 changes: 1 addition & 2 deletions packages/stream/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@streamflow/stream",
"version": "7.3.1",
"version": "7.3.2",
"description": "JavaScript SDK to interact with Streamflow protocol.",
"homepage": "https://github.com/streamflow-finance/js-sdk/",
"main": "./dist/esm/index.js",
Expand Down Expand Up @@ -54,7 +54,6 @@
"@coral-xyz/anchor": "^0.30.1",
"@coral-xyz/borsh": "0.30.1",
"@manahippo/aptos-wallet-adapter": "1.0.10",
"@mysten/bcs": "1.1.0",
"@mysten/sui": "1.12.0",
"@solana/buffer-layout": "4.0.1",
"@solana/spl-token": "0.4.9",
Expand Down
39 changes: 9 additions & 30 deletions packages/stream/sui/StreamClient.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import BN from "bn.js";
import { fromBase64 } from "@mysten/bcs";
import { CoinStruct, SuiClient } from "@mysten/sui/client";
import { Transaction, TransactionObjectArgument } from "@mysten/sui/transactions";
import { SUI_CLOCK_OBJECT_ID, SUI_TYPE_ARG } from "@mysten/sui/utils";
Expand Down Expand Up @@ -109,40 +108,20 @@ export default class SuiStreamClient extends BaseStreamClient {
const errors: ICreateMultiError[] = [];

try {
const { digest, events, effects } = await wallet.signAndExecuteTransaction({
const executedTx = await wallet.signAndExecuteTransaction({
transaction: tx,
options: { showEffects: true, showEvents: true },
});
txs.push(digest);

// effects may be string according to Sui Wallet standard
const digest = executedTx.digest;
// effects may be string according to Sui Wallet standard, events won't even be returned
// https://github.com/MystenLabs/ts-sdks/blob/main/packages/wallet-standard/src/features/suiSignAndExecuteTransaction.ts#L34
// Loosely ported from https://github.com/MystenLabs/ts-sdks/blob/main/packages/graphql-transport/src/mappers/transaction-block.ts#L376
let effectsShort: { status: "success" | "failure"; error?: string } | undefined = undefined;
if (typeof effects === "string") {
const parsedEffects = bcs.TransactionEffects.parse(fromBase64(effects));
const currentEffects = parsedEffects.V2 || parsedEffects.V1;
if (currentEffects) {
effectsShort = currentEffects.status.Success
? {
status: "success",
}
: {
status: "failure",
error: currentEffects.status.$kind,
};
}
} else if (effects && effects.status) {
effectsShort = {
status: effects.status.status,
error: effects.status.error,
};
}
if (!effectsShort) {
console.warn(`Got no effects from the transaction ${digest}, raw: ${effects}`);
}
const { events, effects } =
!executedTx.effects || typeof executedTx.effects === "string"
? await this.client.getTransactionBlock({ digest, options: { showEvents: true, showEffects: true } })
: executedTx;
txs.push(digest);

if (effectsShort?.status === "failure") {
if (effects!.status.status === "failure") {
multipleStreamData.recipients.forEach((recipient) => {
errors.push({
error: effects!.status.error ?? "Unknown error!",
Expand Down

0 comments on commit a7e696a

Please sign in to comment.