@msafe/sui3-sdk 0.0.82 → 0.0.84

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.
@@ -15,7 +15,7 @@ import {
15
15
  buildRejectTxb,
16
16
  isSameAddress,
17
17
  } from '@msafe/sui3-utils';
18
- import { SuiObjectData, SuiObjectResponse, SuiClient } from '@mysten/sui.js/client';
18
+ import { SuiObjectData, SuiObjectResponse } from '@mysten/sui.js/client';
19
19
  import { SerializedSignature } from '@mysten/sui.js/cryptography';
20
20
  import { TransactionBlock } from '@mysten/sui.js/transactions';
21
21
  import { fromHEX, normalizeStructTag, toHEX } from '@mysten/sui.js/utils';
@@ -131,25 +131,33 @@ export class MSafeAccount {
131
131
  return this.backend.getNextSequenceNumber(this.address);
132
132
  }
133
133
 
134
- async simulateIntention(request: Omit<IProposeIntentionRequest, 'msafeAddress' | 'signature'>) {
135
- const appHelper = appHelpers.getAppHelper(request.application);
136
- if (!appHelper) {
137
- throw new Error(`Can't find app helper for application ${request.application}`);
134
+ async simulateIntention(
135
+ request: Omit<IProposeIntentionRequest, 'msafeAddress' | 'signature'> & {
136
+ txb?: TransactionBlock;
137
+ },
138
+ ) {
139
+ let txb: TransactionBlock;
140
+ if (request.txb) {
141
+ txb = request.txb;
142
+ } else {
143
+ const appHelper = appHelpers.getAppHelper(request.application);
144
+ if (!appHelper) {
145
+ throw new Error(`Can't find app helper for application ${request.application}`);
146
+ }
147
+ txb = await appHelper.build({
148
+ network: this.globals.config.network,
149
+ intentionData: request.intention,
150
+ txType: request.txType,
151
+ txSubType: request.txSubType,
152
+ clientUrl: this.globals.config.suiClient.url,
153
+ account: {
154
+ address: this.address,
155
+ publicKey: fromHEX(this.address),
156
+ chains: [SUI_MAINNET_CHAIN, SUI_TESTNET_CHAIN],
157
+ features: [],
158
+ },
159
+ });
138
160
  }
139
- // const config = getMSafeConfig(env, options);
140
- const txb = await appHelper.build({
141
- network: this.globals.config.network,
142
- intentionData: request.intention,
143
- txType: request.txType,
144
- txSubType: request.txSubType,
145
- clientUrl: this.globals.config.suiClient.url,
146
- account: {
147
- address: this.address,
148
- publicKey: fromHEX(this.address),
149
- chains: [SUI_MAINNET_CHAIN, SUI_TESTNET_CHAIN],
150
- features: [],
151
- },
152
- });
153
161
  txb.setSender(this.address);
154
162
  return this.simulator.simulate({ txb, sender: this.address });
155
163
  }
@@ -172,26 +180,32 @@ export class MSafeAccount {
172
180
  }
173
181
 
174
182
  async proposeIntentionAndBuildVote(
175
- input: Omit<IProposeIntentionAndBuildAndVoteRequest, 'signature' | 'msafeAddress' | 'payload' | 'digest'>,
183
+ input: Omit<IProposeIntentionAndBuildAndVoteRequest, 'signature' | 'msafeAddress' | 'payload' | 'digest'> & {
184
+ txb?: TransactionBlock;
185
+ },
176
186
  ): Promise<void> {
177
- const appHelper = appHelpers.getAppHelper(input.application);
178
- if (!appHelper) {
179
- throw new Error(`Can't find app helper for application ${input.application}`);
187
+ let txb: TransactionBlock;
188
+ if (input.txb) {
189
+ txb = input.txb;
190
+ } else {
191
+ const appHelper = appHelpers.getAppHelper(input.application);
192
+ if (!appHelper) {
193
+ throw new Error(`Can't find app helper for application ${input.application}`);
194
+ }
195
+ txb = await appHelper.build({
196
+ network: this.globals.config.network,
197
+ intentionData: input.intention,
198
+ txType: input.txType,
199
+ txSubType: input.txSubType,
200
+ clientUrl: this.globals.config.suiClient.url,
201
+ account: {
202
+ address: this.address,
203
+ publicKey: fromHEX(this.address),
204
+ chains: [SUI_MAINNET_CHAIN, SUI_TESTNET_CHAIN],
205
+ features: [],
206
+ },
207
+ });
180
208
  }
181
-
182
- const txb = await appHelper.build({
183
- network: this.globals.config.network,
184
- intentionData: input.intention,
185
- txType: input.txType,
186
- txSubType: input.txSubType,
187
- clientUrl: this.globals.config.suiClient.url,
188
- account: {
189
- address: this.address,
190
- publicKey: fromHEX(this.address),
191
- chains: [SUI_MAINNET_CHAIN, SUI_TESTNET_CHAIN],
192
- features: [],
193
- },
194
- });
195
209
  txb.setGasPrice(input.gasPrice);
196
210
  txb.setGasBudget(input.gasBudget);
197
211
  txb.setSender(this.address);