@tradeport/sui-trading-sdk 0.4.13 → 0.4.14

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.
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@tradeport/sui-trading-sdk",
3
3
  "license": "MIT",
4
- "version": "0.4.13",
4
+ "version": "0.4.14",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",
7
7
  "types": "dist/index.d.ts",
@@ -1,6 +1,4 @@
1
1
  import { getNativeKioskTransferPolicies } from './kiosk/getNativeKioskTransferPolicies';
2
2
 
3
- export const hasNativeKioskTransferPolicyRules = (transferPolicies: any): boolean => {
4
- const nativeKioskTransferPolicies = getNativeKioskTransferPolicies(transferPolicies);
5
- return nativeKioskTransferPolicies?.some((policy: any) => policy?.rules?.length > 0);
6
- };
3
+ export const hasNativeKioskTransferPolicyRules = (transferPolicies: any): boolean =>
4
+ getNativeKioskTransferPolicies(transferPolicies)?.length > 0;
@@ -27,14 +27,20 @@ export class SuiWallet {
27
27
  return 1;
28
28
  }
29
29
 
30
- async simulateCall(tx: Transaction): Promise<any> {
31
- tx.setSenderIfNotSet(this.keypair.toSuiAddress());
32
- const rawTransaction = await tx.build({ client: this.suiClient });
33
- const result = await this.suiClient.dryRunTransactionBlock({
34
- transactionBlock: rawTransaction,
30
+ async simulateCall(tx: Transaction, sender?: string): Promise<any> {
31
+ const result = await this.suiClient.devInspectTransactionBlock({
32
+ transactionBlock: tx,
33
+ sender: sender ?? this.keypair.toSuiAddress(),
35
34
  });
36
- if (result.balanceChanges.length === 0) {
37
- throw new Error('No balance changes were found');
35
+
36
+ if (result?.effects?.status?.status === 'failure') {
37
+ throw new Error(
38
+ `Error on transaction simulation (from effect): ${result.effects.status.error}`,
39
+ ); // result.effects.status.error
40
+ }
41
+
42
+ if (result?.error) {
43
+ throw new Error(`Error on transaction simulation: ${result.error}`); // result.error
38
44
  }
39
45
 
40
46
  return result;