@msafe/sui3-sdk 1.0.20 → 1.0.21

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/dist/index.d.cts CHANGED
@@ -467,6 +467,13 @@ declare class MSafeAccount {
467
467
  events: true;
468
468
  }>>;
469
469
  dashboard(): Promise<_msafe_sui3_utils.IGetDashboardResp>;
470
+ /**
471
+ * Resolve a Transaction from propose/simulate input.
472
+ * 1. Caller-supplied `txb` (generic store path — do not rebuild).
473
+ * 2. Registered app helper `build`.
474
+ * 3. Unregistered app: restore from `intention.content` (JSON or hex).
475
+ */
476
+ private buildTxFromIntention;
470
477
  private calculateWeightFromVotes;
471
478
  private calculateWeight;
472
479
  get address(): string;
@@ -595,5 +602,11 @@ declare function createCoinReservationRef(reservedBalance: bigint, owner: string
595
602
  * (V1 drops CallArg::FundsWithdrawal).
596
603
  */
597
604
  declare function toSuiTransaction(txb: Transaction | unknown): Transaction;
605
+ declare function getIntentionContent(intention: unknown): unknown;
606
+ /**
607
+ * Restore a Transaction from plain-tx `intention.content`.
608
+ * Accepts V2 JSON (`tx.toJSON()`), hex BCS bytes, or a JSON object.
609
+ */
610
+ declare function transactionFromContent(content: unknown): Transaction;
598
611
 
599
- export { AddressBookSDK, COIN_RESERVATION_MAGIC, COIN_TYPE_ARG_REGEX, Coin, CoinHelper, CreateHelper, type CreateMSafeInfo, DEV_API_URL, DEV_SYNCING_URL, ENV_CONFIGS, Formatter, type FutureIntention, type GasFundingMode, type GasFundingResult, type GasObjectReference, HexToUint8Array, type HistorySendTx, type HistoryVote, type IWallet, InfoTypeEnabledDto, InfoTypeKey, InsufficientGasFundsError, LOCAL_API_URL, LOCAL_SYNCING_URL, MAINNET_RPC_URL, MSafeAccount, MSafeClient, type MSafeConfig, type MSafeConfigOptions, MSafeEnabledDto, MSafeEnv, MSafeGlobals, type NotificationData, type NotificationInfo, NotificationSubscribeDto, NotificationUpdateDto, PREV_API_URL, PROD_API_URL, type Pagination, type PendingTx, type PendingVote, type ProposeIntention, type ReceiveTransaction, SUI_COIN, SignatureVerifier, type SimulateDryRunResponse, type SimulationFailedResult, type SimulationOption, type SimulationResult, type SimulationSuccessResult, TESTNET_RPC_URL, Uint8ArrayToHex, addPrefix, computeGasBudget, createCoinReservationRef, estimateGasBudget, getAllCoins, getMSafeConfig, getPublicKeyFromChain, httpUrlToGrpcBaseUrl, isCoinReservationDigest, msafeChainToSuiNetwork, preferClassicGasPayment, prepareGasFunding, selectGasFunding, stringToBuffer, toSuiTransaction };
612
+ export { AddressBookSDK, COIN_RESERVATION_MAGIC, COIN_TYPE_ARG_REGEX, Coin, CoinHelper, CreateHelper, type CreateMSafeInfo, DEV_API_URL, DEV_SYNCING_URL, ENV_CONFIGS, Formatter, type FutureIntention, type GasFundingMode, type GasFundingResult, type GasObjectReference, HexToUint8Array, type HistorySendTx, type HistoryVote, type IWallet, InfoTypeEnabledDto, InfoTypeKey, InsufficientGasFundsError, LOCAL_API_URL, LOCAL_SYNCING_URL, MAINNET_RPC_URL, MSafeAccount, MSafeClient, type MSafeConfig, type MSafeConfigOptions, MSafeEnabledDto, MSafeEnv, MSafeGlobals, type NotificationData, type NotificationInfo, NotificationSubscribeDto, NotificationUpdateDto, PREV_API_URL, PROD_API_URL, type Pagination, type PendingTx, type PendingVote, type ProposeIntention, type ReceiveTransaction, SUI_COIN, SignatureVerifier, type SimulateDryRunResponse, type SimulationFailedResult, type SimulationOption, type SimulationResult, type SimulationSuccessResult, TESTNET_RPC_URL, Uint8ArrayToHex, addPrefix, computeGasBudget, createCoinReservationRef, estimateGasBudget, getAllCoins, getIntentionContent, getMSafeConfig, getPublicKeyFromChain, httpUrlToGrpcBaseUrl, isCoinReservationDigest, msafeChainToSuiNetwork, preferClassicGasPayment, prepareGasFunding, selectGasFunding, stringToBuffer, toSuiTransaction, transactionFromContent };
package/dist/index.d.ts CHANGED
@@ -467,6 +467,13 @@ declare class MSafeAccount {
467
467
  events: true;
468
468
  }>>;
469
469
  dashboard(): Promise<_msafe_sui3_utils.IGetDashboardResp>;
470
+ /**
471
+ * Resolve a Transaction from propose/simulate input.
472
+ * 1. Caller-supplied `txb` (generic store path — do not rebuild).
473
+ * 2. Registered app helper `build`.
474
+ * 3. Unregistered app: restore from `intention.content` (JSON or hex).
475
+ */
476
+ private buildTxFromIntention;
470
477
  private calculateWeightFromVotes;
471
478
  private calculateWeight;
472
479
  get address(): string;
@@ -595,5 +602,11 @@ declare function createCoinReservationRef(reservedBalance: bigint, owner: string
595
602
  * (V1 drops CallArg::FundsWithdrawal).
596
603
  */
597
604
  declare function toSuiTransaction(txb: Transaction | unknown): Transaction;
605
+ declare function getIntentionContent(intention: unknown): unknown;
606
+ /**
607
+ * Restore a Transaction from plain-tx `intention.content`.
608
+ * Accepts V2 JSON (`tx.toJSON()`), hex BCS bytes, or a JSON object.
609
+ */
610
+ declare function transactionFromContent(content: unknown): Transaction;
598
611
 
599
- export { AddressBookSDK, COIN_RESERVATION_MAGIC, COIN_TYPE_ARG_REGEX, Coin, CoinHelper, CreateHelper, type CreateMSafeInfo, DEV_API_URL, DEV_SYNCING_URL, ENV_CONFIGS, Formatter, type FutureIntention, type GasFundingMode, type GasFundingResult, type GasObjectReference, HexToUint8Array, type HistorySendTx, type HistoryVote, type IWallet, InfoTypeEnabledDto, InfoTypeKey, InsufficientGasFundsError, LOCAL_API_URL, LOCAL_SYNCING_URL, MAINNET_RPC_URL, MSafeAccount, MSafeClient, type MSafeConfig, type MSafeConfigOptions, MSafeEnabledDto, MSafeEnv, MSafeGlobals, type NotificationData, type NotificationInfo, NotificationSubscribeDto, NotificationUpdateDto, PREV_API_URL, PROD_API_URL, type Pagination, type PendingTx, type PendingVote, type ProposeIntention, type ReceiveTransaction, SUI_COIN, SignatureVerifier, type SimulateDryRunResponse, type SimulationFailedResult, type SimulationOption, type SimulationResult, type SimulationSuccessResult, TESTNET_RPC_URL, Uint8ArrayToHex, addPrefix, computeGasBudget, createCoinReservationRef, estimateGasBudget, getAllCoins, getMSafeConfig, getPublicKeyFromChain, httpUrlToGrpcBaseUrl, isCoinReservationDigest, msafeChainToSuiNetwork, preferClassicGasPayment, prepareGasFunding, selectGasFunding, stringToBuffer, toSuiTransaction };
612
+ export { AddressBookSDK, COIN_RESERVATION_MAGIC, COIN_TYPE_ARG_REGEX, Coin, CoinHelper, CreateHelper, type CreateMSafeInfo, DEV_API_URL, DEV_SYNCING_URL, ENV_CONFIGS, Formatter, type FutureIntention, type GasFundingMode, type GasFundingResult, type GasObjectReference, HexToUint8Array, type HistorySendTx, type HistoryVote, type IWallet, InfoTypeEnabledDto, InfoTypeKey, InsufficientGasFundsError, LOCAL_API_URL, LOCAL_SYNCING_URL, MAINNET_RPC_URL, MSafeAccount, MSafeClient, type MSafeConfig, type MSafeConfigOptions, MSafeEnabledDto, MSafeEnv, MSafeGlobals, type NotificationData, type NotificationInfo, NotificationSubscribeDto, NotificationUpdateDto, PREV_API_URL, PROD_API_URL, type Pagination, type PendingTx, type PendingVote, type ProposeIntention, type ReceiveTransaction, SUI_COIN, SignatureVerifier, type SimulateDryRunResponse, type SimulationFailedResult, type SimulationOption, type SimulationResult, type SimulationSuccessResult, TESTNET_RPC_URL, Uint8ArrayToHex, addPrefix, computeGasBudget, createCoinReservationRef, estimateGasBudget, getAllCoins, getIntentionContent, getMSafeConfig, getPublicKeyFromChain, httpUrlToGrpcBaseUrl, isCoinReservationDigest, msafeChainToSuiNetwork, preferClassicGasPayment, prepareGasFunding, selectGasFunding, stringToBuffer, toSuiTransaction, transactionFromContent };
package/dist/index.js CHANGED
@@ -134,7 +134,7 @@ import {
134
134
  isSameAddress as isSameAddress2
135
135
  } from "@msafe/sui3-utils";
136
136
  import { Transaction as Transaction4 } from "@mysten/sui/transactions";
137
- import { fromHex as fromHex2, normalizeStructTag as normalizeStructTag4, toHex as toHex2 } from "@mysten/sui/utils";
137
+ import { fromHex as fromHex3, normalizeStructTag as normalizeStructTag4, toHex as toHex2 } from "@mysten/sui/utils";
138
138
  import { SUI_MAINNET_CHAIN, SUI_TESTNET_CHAIN } from "@mysten/wallet-standard";
139
139
 
140
140
  // src/simulate/simulator.ts
@@ -802,6 +802,7 @@ var SignatureVerifier = class _SignatureVerifier {
802
802
 
803
803
  // src/utils/transaction.ts
804
804
  import { Transaction as Transaction3, isTransaction } from "@mysten/sui/transactions";
805
+ import { fromHex as fromHex2 } from "@mysten/sui/utils";
805
806
  function toSuiTransaction(txb) {
806
807
  if (isTransaction(txb)) {
807
808
  return txb;
@@ -815,6 +816,30 @@ function toSuiTransaction(txb) {
815
816
  }
816
817
  throw new Error("Unsupported transaction value for toSuiTransaction");
817
818
  }
819
+ function isHex(str) {
820
+ return /^[0-9a-fA-F]+$/.test(str);
821
+ }
822
+ function getIntentionContent(intention) {
823
+ if (intention && typeof intention === "object" && "content" in intention) {
824
+ return intention.content;
825
+ }
826
+ return void 0;
827
+ }
828
+ function transactionFromContent(content) {
829
+ if (content instanceof Uint8Array) {
830
+ return Transaction3.from(content);
831
+ }
832
+ if (typeof content === "string") {
833
+ if (isHex(content)) {
834
+ return Transaction3.from(fromHex2(content));
835
+ }
836
+ return Transaction3.from(content);
837
+ }
838
+ if (content && typeof content === "object") {
839
+ return Transaction3.from(JSON.stringify(content));
840
+ }
841
+ throw new Error("Invalid transaction content");
842
+ }
818
843
 
819
844
  // src/utils/iter/iterator.ts
820
845
  var REQUEST_PAGE_SIZE = 25;
@@ -1037,30 +1062,7 @@ var MSafeAccount = class _MSafeAccount {
1037
1062
  return this.backend.getNextSequenceNumber(this.address);
1038
1063
  }
1039
1064
  async simulateIntention(request) {
1040
- let txb;
1041
- if (request.txb) {
1042
- txb = request.txb;
1043
- } else {
1044
- const appHelper = appHelpers.getAppHelper(request.application);
1045
- if (!appHelper) {
1046
- throw new Error(`Can't find app helper for application ${request.application}`);
1047
- }
1048
- txb = toSuiTransaction(
1049
- await appHelper.build({
1050
- network: this.globals.config.network,
1051
- intentionData: request.intention,
1052
- txType: request.txType,
1053
- txSubType: request.txSubType,
1054
- clientUrl: this.globals.config.suiClient.url,
1055
- account: {
1056
- address: this.address,
1057
- publicKey: fromHex2(this.address),
1058
- chains: [SUI_MAINNET_CHAIN, SUI_TESTNET_CHAIN],
1059
- features: []
1060
- }
1061
- })
1062
- );
1063
- }
1065
+ const txb = await this.buildTxFromIntention(request);
1064
1066
  txb.setSender(this.address);
1065
1067
  return this.simulator.simulate({ txb, sender: this.address });
1066
1068
  }
@@ -1080,30 +1082,7 @@ var MSafeAccount = class _MSafeAccount {
1080
1082
  });
1081
1083
  }
1082
1084
  async proposeIntentionAndBuildVote(input) {
1083
- let txb;
1084
- if (input.txb) {
1085
- txb = input.txb;
1086
- } else {
1087
- const appHelper = appHelpers.getAppHelper(input.application);
1088
- if (!appHelper) {
1089
- throw new Error(`Can't find app helper for application ${input.application}`);
1090
- }
1091
- txb = toSuiTransaction(
1092
- await appHelper.build({
1093
- network: this.globals.config.network,
1094
- intentionData: input.intention,
1095
- txType: input.txType,
1096
- txSubType: input.txSubType,
1097
- clientUrl: this.globals.config.suiClient.url,
1098
- account: {
1099
- address: this.address,
1100
- publicKey: fromHex2(this.address),
1101
- chains: [SUI_MAINNET_CHAIN, SUI_TESTNET_CHAIN],
1102
- features: []
1103
- }
1104
- })
1105
- );
1106
- }
1085
+ const txb = await this.buildTxFromIntention(input);
1107
1086
  txb.setGasPrice(input.gasPrice);
1108
1087
  txb.setSender(this.address);
1109
1088
  await prepareGasFunding({
@@ -1225,25 +1204,12 @@ var MSafeAccount = class _MSafeAccount {
1225
1204
  }
1226
1205
  async simulateBuildTransaction() {
1227
1206
  const intention = await this.backend.getNextIntention({ msafeAddress: this.address });
1228
- const appHelper = appHelpers.getAppHelper(intention.application);
1229
- if (!appHelper) {
1230
- throw new Error(`Can't find app helper for application ${intention.application}`);
1231
- }
1232
- const txb = toSuiTransaction(
1233
- await appHelper.build({
1234
- network: this.globals.config.network,
1235
- intentionData: intention.intention,
1236
- txType: intention.txType,
1237
- txSubType: intention.txSubType,
1238
- clientUrl: this.globals.config.suiClient.url,
1239
- account: {
1240
- address: this.address,
1241
- publicKey: fromHex2(this.address),
1242
- chains: [SUI_MAINNET_CHAIN, SUI_TESTNET_CHAIN],
1243
- features: []
1244
- }
1245
- })
1246
- );
1207
+ const txb = await this.buildTxFromIntention({
1208
+ application: intention.application,
1209
+ intention: intention.intention,
1210
+ txType: intention.txType,
1211
+ txSubType: intention.txSubType
1212
+ });
1247
1213
  txb.setSender(this.address);
1248
1214
  return this.simulator.simulate({ txb, sender: this.address });
1249
1215
  }
@@ -1288,6 +1254,45 @@ var MSafeAccount = class _MSafeAccount {
1288
1254
  msafeAddress: this.address
1289
1255
  });
1290
1256
  }
1257
+ /**
1258
+ * Resolve a Transaction from propose/simulate input.
1259
+ * 1. Caller-supplied `txb` (generic store path — do not rebuild).
1260
+ * 2. Registered app helper `build`.
1261
+ * 3. Unregistered app: restore from `intention.content` (JSON or hex).
1262
+ */
1263
+ async buildTxFromIntention(input) {
1264
+ if (input.txb) {
1265
+ return input.txb;
1266
+ }
1267
+ let appHelper;
1268
+ try {
1269
+ appHelper = appHelpers.getAppHelper(input.application);
1270
+ } catch {
1271
+ appHelper = void 0;
1272
+ }
1273
+ if (appHelper) {
1274
+ return toSuiTransaction(
1275
+ await appHelper.build({
1276
+ network: this.globals.config.network,
1277
+ intentionData: input.intention,
1278
+ txType: input.txType,
1279
+ txSubType: input.txSubType,
1280
+ clientUrl: this.globals.config.suiClient.url,
1281
+ account: {
1282
+ address: this.address,
1283
+ publicKey: fromHex3(this.address),
1284
+ chains: [SUI_MAINNET_CHAIN, SUI_TESTNET_CHAIN],
1285
+ features: []
1286
+ }
1287
+ })
1288
+ );
1289
+ }
1290
+ const content = getIntentionContent(input.intention);
1291
+ if (content != null) {
1292
+ return transactionFromContent(content);
1293
+ }
1294
+ throw new Error(`Can't find app helper for application ${input.application}`);
1295
+ }
1291
1296
  calculateWeightFromVotes(votes) {
1292
1297
  return this.calculateWeight(votes.map((vote) => vote.userAddress));
1293
1298
  }
@@ -2022,6 +2027,7 @@ export {
2022
2027
  createCoinReservationRef,
2023
2028
  estimateGasBudget,
2024
2029
  getAllCoins,
2030
+ getIntentionContent,
2025
2031
  getMSafeConfig,
2026
2032
  getPublicKeyFromChain,
2027
2033
  httpUrlToGrpcBaseUrl,
@@ -2031,6 +2037,7 @@ export {
2031
2037
  prepareGasFunding,
2032
2038
  selectGasFunding,
2033
2039
  stringToBuffer,
2034
- toSuiTransaction
2040
+ toSuiTransaction,
2041
+ transactionFromContent
2035
2042
  };
2036
2043
  //# sourceMappingURL=index.js.map