@msafe/sui3-sdk 0.0.37 → 0.0.39
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.cjs +61 -6
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +10 -3
- package/dist/index.d.ts +10 -3
- package/dist/index.js +61 -7
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/src/backend/BackendImpl.ts +18 -4
- package/src/backend/interface.ts +4 -1
- package/src/core/MSafeAccount.ts +55 -3
|
@@ -33,6 +33,8 @@ import {
|
|
|
33
33
|
UserMSafeStatus,
|
|
34
34
|
IGetAddressBookModeResult,
|
|
35
35
|
ISetAddressBookModeReq,
|
|
36
|
+
IRejectTransactionRequest,
|
|
37
|
+
IProposeIntentionAndBuildAndVoteRequest,
|
|
36
38
|
} from '@msafe/sui3-utils';
|
|
37
39
|
import { SerializedSignature } from '@mysten/sui.js/cryptography';
|
|
38
40
|
import { PublicKey } from '@mysten/sui.js/src/cryptography';
|
|
@@ -202,10 +204,14 @@ export class BackendImpl implements IBackend {
|
|
|
202
204
|
return undefined;
|
|
203
205
|
}
|
|
204
206
|
|
|
205
|
-
async rejectCurrentTx(input:
|
|
206
|
-
await this.post(
|
|
207
|
-
|
|
208
|
-
|
|
207
|
+
async rejectCurrentTx(input: IRejectTransactionRequest) {
|
|
208
|
+
await this.post(
|
|
209
|
+
`/transaction/pending/reject`,
|
|
210
|
+
{ ...input, gasPrice: input.gasPrice.toString(), gasBudget: input.gasBudget.toString() },
|
|
211
|
+
{
|
|
212
|
+
headers: this.headers(),
|
|
213
|
+
},
|
|
214
|
+
);
|
|
209
215
|
}
|
|
210
216
|
|
|
211
217
|
async voteForTransaction(input: IVoteTransactionRequest) {
|
|
@@ -222,6 +228,14 @@ export class BackendImpl implements IBackend {
|
|
|
222
228
|
);
|
|
223
229
|
}
|
|
224
230
|
|
|
231
|
+
async proposeIntentionAndBuildVote(input: IProposeIntentionAndBuildAndVoteRequest): Promise<void> {
|
|
232
|
+
await this.post(
|
|
233
|
+
`/transaction/intention/build`,
|
|
234
|
+
{ ...input, gasPrice: input.gasPrice.toString(), gasBudget: input.gasBudget.toString() },
|
|
235
|
+
{ headers: this.headers() },
|
|
236
|
+
);
|
|
237
|
+
}
|
|
238
|
+
|
|
225
239
|
async skipNextFailedIntention(input: ISkipIntentionRequest) {
|
|
226
240
|
await this.post(`/transaction/pending/skip`, input, { headers: this.headers() });
|
|
227
241
|
}
|
package/src/backend/interface.ts
CHANGED
|
@@ -25,6 +25,8 @@ import {
|
|
|
25
25
|
TransactionIntentionItem,
|
|
26
26
|
IGetAddressBookModeResult,
|
|
27
27
|
ISetAddressBookModeReq,
|
|
28
|
+
IRejectTransactionRequest,
|
|
29
|
+
IProposeIntentionAndBuildAndVoteRequest,
|
|
28
30
|
} from '@msafe/sui3-utils';
|
|
29
31
|
import { PublicKey, SerializedSignature } from '@mysten/sui.js/cryptography';
|
|
30
32
|
|
|
@@ -59,10 +61,11 @@ export interface IBackend {
|
|
|
59
61
|
digest: string;
|
|
60
62
|
signature: SerializedSignature;
|
|
61
63
|
}): Promise<void>;
|
|
62
|
-
rejectCurrentTx(input:
|
|
64
|
+
rejectCurrentTx(input: IRejectTransactionRequest): Promise<void>;
|
|
63
65
|
voteForTransaction(input: IVoteTransactionRequest): Promise<void>;
|
|
64
66
|
buildNextIntentionAndAddToPending(input: IBuildTransactionRequest): Promise<void>;
|
|
65
67
|
skipNextFailedIntention(input: ISkipIntentionRequest): Promise<void>;
|
|
68
|
+
proposeIntentionAndBuildVote(input: IProposeIntentionAndBuildAndVoteRequest): Promise<void>;
|
|
66
69
|
|
|
67
70
|
getAddressBookEntries(pagination?: IPageOptions): Promise<IGetAddressBookResult>;
|
|
68
71
|
updateAddressBook(input: { updates: UpdateAddressBookEntry[]; signature: SerializedSignature }): Promise<void>;
|
package/src/core/MSafeAccount.ts
CHANGED
|
@@ -3,6 +3,7 @@ import {
|
|
|
3
3
|
CoinTransferIntention,
|
|
4
4
|
IGasOption,
|
|
5
5
|
IMSafeConfig,
|
|
6
|
+
IProposeIntentionAndBuildAndVoteRequest,
|
|
6
7
|
IProposeIntentionRequest,
|
|
7
8
|
MultiSigAccount,
|
|
8
9
|
ObjectTransferIntention,
|
|
@@ -12,7 +13,6 @@ import {
|
|
|
12
13
|
TransactionSubTypes,
|
|
13
14
|
TransactionType,
|
|
14
15
|
TxIntention,
|
|
15
|
-
buildObjectTransferTxb,
|
|
16
16
|
buildRejectTxb,
|
|
17
17
|
isSameAddress,
|
|
18
18
|
} from '@msafe/sui3-utils';
|
|
@@ -168,6 +168,25 @@ export class MSafeAccount {
|
|
|
168
168
|
});
|
|
169
169
|
}
|
|
170
170
|
|
|
171
|
+
async proposeIntentionAndBuildVote(
|
|
172
|
+
input: Omit<IProposeIntentionAndBuildAndVoteRequest, 'signature' | 'msafeAddress'>,
|
|
173
|
+
): Promise<void> {
|
|
174
|
+
const message = SigningMessageHelper.proposeIntentionMessage({
|
|
175
|
+
msafeAddress: this.address,
|
|
176
|
+
intention: input.intention,
|
|
177
|
+
sn: input.sequenceNumber,
|
|
178
|
+
});
|
|
179
|
+
const signature = await this.wallet.signPersonalMessage({
|
|
180
|
+
messageStr: message,
|
|
181
|
+
});
|
|
182
|
+
|
|
183
|
+
return this.backend.proposeIntentionAndBuildVote({
|
|
184
|
+
...input,
|
|
185
|
+
msafeAddress: this.address,
|
|
186
|
+
signature: signature.signature,
|
|
187
|
+
});
|
|
188
|
+
}
|
|
189
|
+
|
|
171
190
|
async simulateCoinTransferIntention(intention: CoinTransferIntention) {
|
|
172
191
|
const sn = await this.nextSequenceNumber();
|
|
173
192
|
return this.simulateIntention({
|
|
@@ -190,8 +209,18 @@ export class MSafeAccount {
|
|
|
190
209
|
});
|
|
191
210
|
}
|
|
192
211
|
|
|
212
|
+
async simulateObjectTransferIntention(intention: ObjectTransferIntention) {
|
|
213
|
+
const sn = await this.nextSequenceNumber();
|
|
214
|
+
return this.simulateIntention({
|
|
215
|
+
application: TransactionDefaultApplication,
|
|
216
|
+
txType: TransactionType.Assets,
|
|
217
|
+
txSubType: TransactionSubTypes.assets.object.send,
|
|
218
|
+
sequenceNumber: sn,
|
|
219
|
+
intention,
|
|
220
|
+
});
|
|
221
|
+
}
|
|
222
|
+
|
|
193
223
|
async proposeObjectTransferIntention(intention: ObjectTransferIntention) {
|
|
194
|
-
await buildObjectTransferTxb(this.suiClient, intention, this.address);
|
|
195
224
|
const sn = await this.nextSequenceNumber();
|
|
196
225
|
return this.proposeIntention({
|
|
197
226
|
application: TransactionDefaultApplication,
|
|
@@ -202,6 +231,17 @@ export class MSafeAccount {
|
|
|
202
231
|
});
|
|
203
232
|
}
|
|
204
233
|
|
|
234
|
+
async simulatePlainPayloadIntention(intention: PlainPayloadIntention) {
|
|
235
|
+
const sn = await this.nextSequenceNumber();
|
|
236
|
+
return this.simulateIntention({
|
|
237
|
+
application: TransactionDefaultApplication,
|
|
238
|
+
txType: TransactionType.Other,
|
|
239
|
+
txSubType: TransactionSubTypes.others.plain,
|
|
240
|
+
sequenceNumber: sn,
|
|
241
|
+
intention,
|
|
242
|
+
});
|
|
243
|
+
}
|
|
244
|
+
|
|
205
245
|
async proposePlainPayloadIntention(intention: PlainPayloadIntention) {
|
|
206
246
|
const sn = await this.nextSequenceNumber();
|
|
207
247
|
|
|
@@ -248,7 +288,18 @@ export class MSafeAccount {
|
|
|
248
288
|
});
|
|
249
289
|
}
|
|
250
290
|
|
|
251
|
-
async
|
|
291
|
+
async simulateRejectTx() {
|
|
292
|
+
const pendingTx = await this.pendingTransaction();
|
|
293
|
+
if (!pendingTx || pendingTx.rejectDigest !== '') {
|
|
294
|
+
throw new Error('Already rejected');
|
|
295
|
+
}
|
|
296
|
+
|
|
297
|
+
const payloadToReject = pendingTx.payload;
|
|
298
|
+
const txb = buildRejectTxb(this.address, payloadToReject);
|
|
299
|
+
return this.simulator.simulate({ txb, sender: this.address });
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
async rejectCurrentTx(input: IGasOption & { forceBuild: boolean }) {
|
|
252
303
|
const pendingTx = await this.pendingTransaction();
|
|
253
304
|
if (!pendingTx || pendingTx.rejectDigest !== '') {
|
|
254
305
|
throw new Error('Already rejected');
|
|
@@ -263,6 +314,7 @@ export class MSafeAccount {
|
|
|
263
314
|
msafeAddress: this.address,
|
|
264
315
|
digest,
|
|
265
316
|
signature: signature.signature,
|
|
317
|
+
...input,
|
|
266
318
|
});
|
|
267
319
|
}
|
|
268
320
|
|