|
1 | 1 | import BN from "bn.js"; |
2 | | -import { fromBase64 } from "@mysten/bcs"; |
3 | 2 | import { CoinStruct, SuiClient } from "@mysten/sui/client"; |
4 | 3 | import { Transaction, TransactionObjectArgument } from "@mysten/sui/transactions"; |
5 | 4 | import { SUI_CLOCK_OBJECT_ID, SUI_TYPE_ARG } from "@mysten/sui/utils"; |
@@ -109,40 +108,20 @@ export default class SuiStreamClient extends BaseStreamClient { |
109 | 108 | const errors: ICreateMultiError[] = []; |
110 | 109 |
|
111 | 110 | try { |
112 | | - const { digest, events, effects } = await wallet.signAndExecuteTransaction({ |
| 111 | + const executedTx = await wallet.signAndExecuteTransaction({ |
113 | 112 | transaction: tx, |
114 | 113 | options: { showEffects: true, showEvents: true }, |
115 | 114 | }); |
116 | | - txs.push(digest); |
117 | | - |
118 | | - // effects may be string according to Sui Wallet standard |
| 115 | + const digest = executedTx.digest; |
| 116 | + // effects may be string according to Sui Wallet standard, events won't even be returned |
119 | 117 | // 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 | | - } |
| 118 | + const { events, effects } = |
| 119 | + !executedTx.effects || typeof executedTx.effects === "string" |
| 120 | + ? await this.client.getTransactionBlock({ digest, options: { showEvents: true, showEffects: true } }) |
| 121 | + : executedTx; |
| 122 | + txs.push(digest); |
144 | 123 |
|
145 | | - if (effectsShort?.status === "failure") { |
| 124 | + if (effects!.status.status === "failure") { |
146 | 125 | multipleStreamData.recipients.forEach((recipient) => { |
147 | 126 | errors.push({ |
148 | 127 | error: effects!.status.error ?? "Unknown error!", |
|
0 commit comments