@msafe/sui3-sdk 0.0.15-pre-3e855d9.0 → 0.0.15
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 +78 -91
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +97 -113
- package/dist/index.d.ts +97 -113
- package/dist/index.js +82 -93
- package/dist/index.js.map +1 -1
- package/package.json +8 -10
- package/src/backend/BackendImpl.ts +48 -86
- package/src/backend/interface.ts +25 -30
- package/src/core/MSafeAccount.ts +62 -45
- package/src/types/msafe.ts +6 -2
|
@@ -1,23 +1,32 @@
|
|
|
1
1
|
import {
|
|
2
|
-
|
|
2
|
+
GetHistoryTransactionsResponse,
|
|
3
|
+
GetPendingTransactionResponse,
|
|
4
|
+
GetTransactionIntentionsResponse,
|
|
3
5
|
IAuthLoginReq,
|
|
4
6
|
IAuthLoginResp,
|
|
7
|
+
IBuildTransactionRequest,
|
|
5
8
|
ICreateMSafeReq,
|
|
9
|
+
IGetAddressBookResult,
|
|
10
|
+
IGetHistoryTransactionsRequest,
|
|
11
|
+
IGetIntentionsRequest,
|
|
6
12
|
IGetMSafeQuery,
|
|
7
13
|
IGetMSafesQuery,
|
|
14
|
+
IGetPendingTransactionRequest,
|
|
8
15
|
IGetPublicKeyBatchQuery,
|
|
9
16
|
IGetPublicKeyBatchResp,
|
|
17
|
+
IMSafeConfig,
|
|
10
18
|
IMSafeInfoResp,
|
|
11
|
-
IPagedResult,
|
|
12
19
|
IPageOptions,
|
|
20
|
+
IPagedResult,
|
|
21
|
+
IProposeIntentionRequest,
|
|
22
|
+
ISkipIntentionRequest,
|
|
13
23
|
IUpdateMSafeStatusReq,
|
|
14
24
|
IUserInfoResp,
|
|
25
|
+
IVoteTransactionRequest,
|
|
15
26
|
JWTToken,
|
|
16
27
|
PublicKeySerde,
|
|
17
|
-
UserMSafeStatus,
|
|
18
|
-
IGetAddressBookResult,
|
|
19
28
|
UpdateAddressBookEntry,
|
|
20
|
-
|
|
29
|
+
UserMSafeStatus,
|
|
21
30
|
} from '@msafe/sui3-utils';
|
|
22
31
|
import { SerializedSignature } from '@mysten/sui.js/cryptography';
|
|
23
32
|
import { PublicKey } from '@mysten/sui.js/src/cryptography';
|
|
@@ -25,7 +34,6 @@ import axios from 'axios';
|
|
|
25
34
|
|
|
26
35
|
import { IBackend } from '@/backend/interface';
|
|
27
36
|
import { TxIntention } from '@/transactions/intention';
|
|
28
|
-
import { FutureIntention, PendingTx, ProposeIntention } from '@/types/msafe';
|
|
29
37
|
|
|
30
38
|
export class BackendImpl implements IBackend {
|
|
31
39
|
private _token: JWTToken;
|
|
@@ -137,8 +145,9 @@ export class BackendImpl implements IBackend {
|
|
|
137
145
|
}
|
|
138
146
|
}
|
|
139
147
|
|
|
140
|
-
async getPendingTransactions(
|
|
141
|
-
const res = await axios.get<
|
|
148
|
+
async getPendingTransactions(input: IGetPendingTransactionRequest): Promise<GetPendingTransactionResponse> {
|
|
149
|
+
const res = await axios.get<GetPendingTransactionResponse>(`${this.apiURL}/transaction/pending`, {
|
|
150
|
+
params: input,
|
|
142
151
|
headers: this.headers(),
|
|
143
152
|
});
|
|
144
153
|
if (res.status !== 200 && res.status !== 201) {
|
|
@@ -147,35 +156,20 @@ export class BackendImpl implements IBackend {
|
|
|
147
156
|
return res.data;
|
|
148
157
|
}
|
|
149
158
|
|
|
150
|
-
async getHistoryTransactions(
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
`${this.apiURL}/transaction/history?address=${msafeAddress}`,
|
|
156
|
-
{
|
|
157
|
-
params: {
|
|
158
|
-
page: paginationOption?.page,
|
|
159
|
-
limit: paginationOption?.limit,
|
|
160
|
-
},
|
|
161
|
-
headers: this.headers(),
|
|
162
|
-
},
|
|
163
|
-
);
|
|
159
|
+
async getHistoryTransactions(input: IGetHistoryTransactionsRequest): Promise<GetHistoryTransactionsResponse> {
|
|
160
|
+
const res = await axios.get<GetHistoryTransactionsResponse>(`${this.apiURL}/transaction/history`, {
|
|
161
|
+
params: input,
|
|
162
|
+
headers: this.headers(),
|
|
163
|
+
});
|
|
164
164
|
if (res.status !== 200 && res.status !== 201) {
|
|
165
165
|
throw new Error(`invalid getCurrentSequenceNumber return: ${res}`);
|
|
166
166
|
}
|
|
167
167
|
return res.data;
|
|
168
168
|
}
|
|
169
169
|
|
|
170
|
-
async getFutureIntentions(
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
): Promise<IPagedResult<FutureIntention>> {
|
|
174
|
-
const res = await axios.get<IPagedResult<FutureIntention>>(`${this.apiURL}/transaction/intention/${msafeAddress}`, {
|
|
175
|
-
params: {
|
|
176
|
-
page: paginationOption?.page,
|
|
177
|
-
limit: paginationOption?.limit,
|
|
178
|
-
},
|
|
170
|
+
async getFutureIntentions(input: IGetIntentionsRequest): Promise<GetTransactionIntentionsResponse> {
|
|
171
|
+
const res = await axios.get<GetTransactionIntentionsResponse>(`${this.apiURL}/transaction/intention`, {
|
|
172
|
+
params: input,
|
|
179
173
|
headers: this.headers(),
|
|
180
174
|
});
|
|
181
175
|
if (res.status !== 200 && res.status !== 201) {
|
|
@@ -184,8 +178,11 @@ export class BackendImpl implements IBackend {
|
|
|
184
178
|
return res.data;
|
|
185
179
|
}
|
|
186
180
|
|
|
187
|
-
async getCurrentSequenceNumber(
|
|
188
|
-
const res = await axios.get<number>(`${this.apiURL}/transaction/sn/current
|
|
181
|
+
async getCurrentSequenceNumber(address: string): Promise<number> {
|
|
182
|
+
const res = await axios.get<number>(`${this.apiURL}/transaction/sn/current`, {
|
|
183
|
+
params: {
|
|
184
|
+
msafeAddress: address,
|
|
185
|
+
},
|
|
189
186
|
headers: this.headers(),
|
|
190
187
|
});
|
|
191
188
|
if (res.status !== 200 && res.status !== 201) {
|
|
@@ -194,8 +191,11 @@ export class BackendImpl implements IBackend {
|
|
|
194
191
|
return res.data;
|
|
195
192
|
}
|
|
196
193
|
|
|
197
|
-
async getNextSequenceNumber(
|
|
198
|
-
const res = await axios.get<number>(`${this.apiURL}/transaction/sn/next
|
|
194
|
+
async getNextSequenceNumber(address: string): Promise<number> {
|
|
195
|
+
const res = await axios.get<number>(`${this.apiURL}/transaction/sn/next`, {
|
|
196
|
+
params: {
|
|
197
|
+
msafeAddress: address,
|
|
198
|
+
},
|
|
199
199
|
headers: this.headers(),
|
|
200
200
|
});
|
|
201
201
|
if (res.status !== 200 && res.status !== 201) {
|
|
@@ -213,7 +213,7 @@ export class BackendImpl implements IBackend {
|
|
|
213
213
|
}
|
|
214
214
|
}
|
|
215
215
|
|
|
216
|
-
async proposeIntention(input:
|
|
216
|
+
async proposeIntention(input: IProposeIntentionRequest): Promise<void> {
|
|
217
217
|
const res = await axios.post(`${this.apiURL}/transaction/intention`, input, { headers: this.headers() });
|
|
218
218
|
if (res.status !== 200 && res.status !== 201) {
|
|
219
219
|
throw new Error(`invalid proposeIntention return: ${res}`);
|
|
@@ -232,71 +232,33 @@ export class BackendImpl implements IBackend {
|
|
|
232
232
|
return undefined;
|
|
233
233
|
}
|
|
234
234
|
|
|
235
|
-
async rejectCurrentTx(input: {
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
signature: SerializedSignature;
|
|
240
|
-
}) {
|
|
241
|
-
const res = await axios.post(
|
|
242
|
-
`${this.apiURL}/transaction/pending/reject`,
|
|
243
|
-
{
|
|
244
|
-
address: input.msafeAddress,
|
|
245
|
-
digest: input.digest,
|
|
246
|
-
signature: input.signature,
|
|
247
|
-
},
|
|
248
|
-
{
|
|
249
|
-
headers: this.headers(),
|
|
250
|
-
},
|
|
251
|
-
);
|
|
235
|
+
async rejectCurrentTx(input: IVoteTransactionRequest) {
|
|
236
|
+
const res = await axios.post(`${this.apiURL}/transaction/pending/reject`, input, {
|
|
237
|
+
headers: this.headers(),
|
|
238
|
+
});
|
|
252
239
|
if (res.status !== 200 && res.status !== 201) {
|
|
253
240
|
throw new Error(`invalid voteForTransaction return: ${res}`);
|
|
254
241
|
}
|
|
255
242
|
}
|
|
256
243
|
|
|
257
|
-
async voteForTransaction(input: {
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
signature: SerializedSignature;
|
|
262
|
-
}) {
|
|
263
|
-
const res = await axios.post(
|
|
264
|
-
`${this.apiURL}/transaction/pending/vote`,
|
|
265
|
-
{
|
|
266
|
-
address: input.msafeAddress,
|
|
267
|
-
digest: input.txDigest,
|
|
268
|
-
signature: input.signature,
|
|
269
|
-
},
|
|
270
|
-
{
|
|
271
|
-
headers: this.headers(),
|
|
272
|
-
},
|
|
273
|
-
);
|
|
244
|
+
async voteForTransaction(input: IVoteTransactionRequest) {
|
|
245
|
+
const res = await axios.post(`${this.apiURL}/transaction/pending/vote`, input, {
|
|
246
|
+
headers: this.headers(),
|
|
247
|
+
});
|
|
274
248
|
if (res.status !== 200 && res.status !== 201) {
|
|
275
249
|
throw new Error(`invalid voteForTransaction return: ${res}`);
|
|
276
250
|
}
|
|
277
251
|
}
|
|
278
252
|
|
|
279
|
-
async buildNextIntentionAndAddToPending(input:
|
|
280
|
-
const res = await axios.post(
|
|
281
|
-
`${this.apiURL}/transaction/pending/build`,
|
|
282
|
-
{
|
|
283
|
-
address: input.msafeAddress,
|
|
284
|
-
},
|
|
285
|
-
{ headers: this.headers() },
|
|
286
|
-
);
|
|
253
|
+
async buildNextIntentionAndAddToPending(input: IBuildTransactionRequest) {
|
|
254
|
+
const res = await axios.post(`${this.apiURL}/transaction/pending/build`, input, { headers: this.headers() });
|
|
287
255
|
if (res.status !== 200 && res.status !== 201) {
|
|
288
256
|
throw new Error(`invalid buildNextIntentionAndAddToPending return: ${res}`);
|
|
289
257
|
}
|
|
290
258
|
}
|
|
291
259
|
|
|
292
|
-
async skipNextFailedIntention(input:
|
|
293
|
-
const res = await axios.post(
|
|
294
|
-
`${this.apiURL}/transaction/pending/skip`,
|
|
295
|
-
{
|
|
296
|
-
msafeAddress: input.msafeAddress,
|
|
297
|
-
},
|
|
298
|
-
{ headers: this.headers() },
|
|
299
|
-
);
|
|
260
|
+
async skipNextFailedIntention(input: ISkipIntentionRequest) {
|
|
261
|
+
const res = await axios.post(`${this.apiURL}/transaction/pending/skip`, input, { headers: this.headers() });
|
|
300
262
|
if (res.status !== 200 && res.status !== 201) {
|
|
301
263
|
throw new Error(`invalid skipNextFailedIntention return: ${res}`);
|
|
302
264
|
}
|
package/src/backend/interface.ts
CHANGED
|
@@ -1,20 +1,28 @@
|
|
|
1
1
|
import {
|
|
2
|
-
|
|
2
|
+
GetHistoryTransactionsResponse,
|
|
3
|
+
GetPendingTransactionResponse,
|
|
4
|
+
GetTransactionIntentionsResponse,
|
|
3
5
|
IAuthLoginReq,
|
|
6
|
+
IBuildTransactionRequest,
|
|
4
7
|
ICreateMSafeReq,
|
|
5
|
-
IPageOptions,
|
|
6
|
-
IUserInfoResp,
|
|
7
|
-
UserMSafeStatus,
|
|
8
8
|
IGetAddressBookResult,
|
|
9
|
+
IGetHistoryTransactionsRequest,
|
|
10
|
+
IGetIntentionsRequest,
|
|
11
|
+
IGetPendingTransactionRequest,
|
|
12
|
+
IMSafeConfig,
|
|
13
|
+
IPageOptions,
|
|
9
14
|
IPagedResult,
|
|
10
|
-
|
|
15
|
+
IProposeIntentionRequest,
|
|
16
|
+
ISkipIntentionRequest,
|
|
17
|
+
IUserInfoResp,
|
|
18
|
+
IVoteTransactionRequest,
|
|
11
19
|
JWTToken,
|
|
12
|
-
|
|
20
|
+
UpdateAddressBookEntry,
|
|
21
|
+
UserMSafeStatus,
|
|
13
22
|
} from '@msafe/sui3-utils';
|
|
14
23
|
import { PublicKey, SerializedSignature } from '@mysten/sui.js/cryptography';
|
|
15
24
|
|
|
16
25
|
import { TxIntention } from '@/transactions/intention';
|
|
17
|
-
import { FutureIntention, PendingTx, ProposeIntention } from '@/types/msafe';
|
|
18
26
|
|
|
19
27
|
export interface IBackend {
|
|
20
28
|
authSign(input: IAuthLoginReq): Promise<JWTToken>;
|
|
@@ -31,17 +39,14 @@ export interface IBackend {
|
|
|
31
39
|
}): Promise<IPagedResult<IMSafeConfig>>;
|
|
32
40
|
updateMSafeStatus(input: { msafeAddress: string; status: UserMSafeStatus }): Promise<void>;
|
|
33
41
|
|
|
34
|
-
getPendingTransactions(
|
|
35
|
-
getHistoryTransactions(
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
): Promise<
|
|
39
|
-
getFutureIntentions(msafeAddress: string, paginationOption?: IPageOptions): Promise<IPagedResult<FutureIntention>>;
|
|
40
|
-
getCurrentSequenceNumber(msafeAddress: string): Promise<number>;
|
|
41
|
-
getNextSequenceNumber(msafeAddress: string): Promise<number>;
|
|
42
|
+
getPendingTransactions(input: IGetPendingTransactionRequest): Promise<GetPendingTransactionResponse>;
|
|
43
|
+
getHistoryTransactions(input: IGetHistoryTransactionsRequest): Promise<GetHistoryTransactionsResponse>;
|
|
44
|
+
getFutureIntentions(input: IGetIntentionsRequest): Promise<GetTransactionIntentionsResponse>;
|
|
45
|
+
getCurrentSequenceNumber(address: string): Promise<number>;
|
|
46
|
+
getNextSequenceNumber(address: string): Promise<number>;
|
|
42
47
|
|
|
43
48
|
createMSafeAccount(input: ICreateMSafeReq): Promise<void>;
|
|
44
|
-
proposeIntention(input:
|
|
49
|
+
proposeIntention(input: IProposeIntentionRequest): Promise<void>;
|
|
45
50
|
proposePendingTransaction(input: {
|
|
46
51
|
intention: TxIntention;
|
|
47
52
|
userAddress: string;
|
|
@@ -49,20 +54,10 @@ export interface IBackend {
|
|
|
49
54
|
digest: string;
|
|
50
55
|
signature: SerializedSignature;
|
|
51
56
|
}): Promise<void>;
|
|
52
|
-
rejectCurrentTx(input:
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
signature: SerializedSignature;
|
|
57
|
-
}): Promise<void>;
|
|
58
|
-
voteForTransaction(input: {
|
|
59
|
-
txDigest: string;
|
|
60
|
-
msafeAddress: string;
|
|
61
|
-
userAddress: string;
|
|
62
|
-
signature: SerializedSignature;
|
|
63
|
-
}): Promise<void>;
|
|
64
|
-
buildNextIntentionAndAddToPending(input: { msafeAddress: string }): Promise<void>;
|
|
65
|
-
skipNextFailedIntention(input: { msafeAddress: string; userAddress: string }): Promise<void>;
|
|
57
|
+
rejectCurrentTx(input: IVoteTransactionRequest): Promise<void>;
|
|
58
|
+
voteForTransaction(input: IVoteTransactionRequest): Promise<void>;
|
|
59
|
+
buildNextIntentionAndAddToPending(input: IBuildTransactionRequest): Promise<void>;
|
|
60
|
+
skipNextFailedIntention(input: ISkipIntentionRequest): Promise<void>;
|
|
66
61
|
processExecutedTransaction(digest: string): Promise<void>;
|
|
67
62
|
|
|
68
63
|
getAddressBookEntries(pagination?: IPageOptions): Promise<IGetAddressBookResult>;
|
package/src/core/MSafeAccount.ts
CHANGED
|
@@ -1,19 +1,24 @@
|
|
|
1
1
|
import {
|
|
2
|
-
|
|
2
|
+
CoinTransferIntention,
|
|
3
3
|
IMSafeConfig,
|
|
4
|
-
|
|
4
|
+
IProposeIntentionRequest,
|
|
5
5
|
MultiSigAccount,
|
|
6
|
+
ObjectTransferIntention,
|
|
6
7
|
SigningMessageHelper,
|
|
8
|
+
TransactionDefaultApplication,
|
|
9
|
+
TransactionSubTypes,
|
|
10
|
+
TransactionType,
|
|
7
11
|
} from '@msafe/sui3-utils';
|
|
8
12
|
import { SuiObjectData } from '@mysten/sui.js/client';
|
|
9
13
|
import { SerializedSignature } from '@mysten/sui.js/cryptography';
|
|
10
14
|
import { SuiObjectResponse } from '@mysten/sui.js/src/client';
|
|
15
|
+
import { TransactionBlock } from '@mysten/sui.js/transactions';
|
|
11
16
|
import { normalizeStructTag } from '@mysten/sui.js/utils';
|
|
12
17
|
|
|
13
18
|
import { MSafeGlobals } from '@/globals/MSafeGlobals';
|
|
14
19
|
import { IntentionHelper, TxIntention } from '@/transactions/intention';
|
|
15
20
|
import { OwnedCoin } from '@/types/assets';
|
|
16
|
-
import { PendingTx, SimulationResult } from '@/types/msafe';
|
|
21
|
+
import { Pagination, PendingTx, SimulationResult } from '@/types/msafe';
|
|
17
22
|
import { CoinHelper } from '@/utils';
|
|
18
23
|
import { HexToUint8Array } from '@/utils/buffer';
|
|
19
24
|
import { BatchObjectOptions, getAllOwnedObjects } from '@/utils/iter/object';
|
|
@@ -70,32 +75,38 @@ export class MSafeAccount {
|
|
|
70
75
|
}
|
|
71
76
|
|
|
72
77
|
async pendingTransaction(): Promise<PendingTx | undefined> {
|
|
73
|
-
const
|
|
74
|
-
if (
|
|
75
|
-
throw new Error(`invalid backend getPendingTransactions resp, length should not > 2: ${pendings}`);
|
|
76
|
-
}
|
|
77
|
-
if (pendings.length === 0) {
|
|
78
|
+
const res = await this.backend.getPendingTransactions({ msafeAddress: this.address });
|
|
79
|
+
if (!res.pending) {
|
|
78
80
|
return undefined;
|
|
79
81
|
}
|
|
80
82
|
|
|
81
|
-
const pendingTx =
|
|
82
|
-
const rejectPending =
|
|
83
|
+
const pendingTx = res.pending;
|
|
84
|
+
const rejectPending = res.reject;
|
|
83
85
|
|
|
84
86
|
return {
|
|
85
|
-
|
|
87
|
+
createdAt: pendingTx.createAt,
|
|
88
|
+
creator: pendingTx.creator,
|
|
89
|
+
digest: pendingTx.digest,
|
|
90
|
+
intention: pendingTx.intention,
|
|
91
|
+
sequenceNumber: pendingTx.sequenceNumber,
|
|
92
|
+
payload: pendingTx.payload,
|
|
93
|
+
votes: pendingTx.votes,
|
|
94
|
+
msafeAddress: pendingTx.msafeAddress,
|
|
86
95
|
rejectDigest: rejectPending?.digest ?? '',
|
|
87
96
|
rejectPayload: rejectPending?.payload ?? '',
|
|
88
97
|
rejectVotes: rejectPending?.votes ?? [],
|
|
89
98
|
};
|
|
90
99
|
}
|
|
91
100
|
|
|
92
|
-
async historyTransaction(
|
|
93
|
-
return this.backend.getHistoryTransactions(
|
|
101
|
+
async historyTransaction(pagination?: Pagination) {
|
|
102
|
+
return this.backend.getHistoryTransactions({
|
|
103
|
+
msafeAddress: this.address,
|
|
104
|
+
...pagination,
|
|
105
|
+
});
|
|
94
106
|
}
|
|
95
107
|
|
|
96
|
-
async futureIntentions(
|
|
97
|
-
|
|
98
|
-
return paginatedIntentions.data;
|
|
108
|
+
async futureIntentions(pagination?: Pagination) {
|
|
109
|
+
return this.backend.getFutureIntentions({ msafeAddress: this.address, ...pagination });
|
|
99
110
|
}
|
|
100
111
|
|
|
101
112
|
async currentSequenceNumber() {
|
|
@@ -106,13 +117,7 @@ export class MSafeAccount {
|
|
|
106
117
|
return this.backend.getNextSequenceNumber(this.address);
|
|
107
118
|
}
|
|
108
119
|
|
|
109
|
-
async proposeIntention(input: {
|
|
110
|
-
application: string;
|
|
111
|
-
txType: string;
|
|
112
|
-
txSubType: string;
|
|
113
|
-
intention: TxIntention;
|
|
114
|
-
sequenceNumber: number;
|
|
115
|
-
}) {
|
|
120
|
+
async proposeIntention(input: Omit<IProposeIntentionRequest, 'signature' | 'msafeAddress'>) {
|
|
116
121
|
const message = SigningMessageHelper.proposeIntentionMessage({
|
|
117
122
|
msafeAddress: this.address,
|
|
118
123
|
intention: input.intention,
|
|
@@ -122,22 +127,41 @@ export class MSafeAccount {
|
|
|
122
127
|
messageStr: message,
|
|
123
128
|
});
|
|
124
129
|
|
|
125
|
-
// TODO get application from common utils
|
|
126
130
|
await this.backend.proposeIntention({
|
|
127
131
|
...input,
|
|
128
132
|
msafeAddress: this.address,
|
|
129
|
-
userAddress: await this.userAddress(),
|
|
130
133
|
signature: signature.signature,
|
|
131
134
|
});
|
|
132
135
|
}
|
|
133
136
|
|
|
137
|
+
async proposeCoinTransferIntention(intention: CoinTransferIntention) {
|
|
138
|
+
const sn = await this.nextSequenceNumber();
|
|
139
|
+
return this.proposeIntention({
|
|
140
|
+
application: TransactionDefaultApplication,
|
|
141
|
+
txType: TransactionType.Assets,
|
|
142
|
+
txSubType: TransactionSubTypes.assets.coin.send,
|
|
143
|
+
sequenceNumber: sn,
|
|
144
|
+
intention,
|
|
145
|
+
});
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
async proposeObjectTransferIntention(intention: ObjectTransferIntention) {
|
|
149
|
+
const sn = await this.nextSequenceNumber();
|
|
150
|
+
return this.proposeIntention({
|
|
151
|
+
application: TransactionDefaultApplication,
|
|
152
|
+
txType: TransactionType.Assets,
|
|
153
|
+
txSubType: TransactionSubTypes.assets.object.send,
|
|
154
|
+
sequenceNumber: sn,
|
|
155
|
+
intention,
|
|
156
|
+
});
|
|
157
|
+
}
|
|
158
|
+
|
|
134
159
|
async voteForTransaction(digest: string, payload: string) {
|
|
135
160
|
const payloadBytes = HexToUint8Array(payload);
|
|
136
161
|
const signature = await this.wallet.signTransactionBlock({ transactionBlock: payloadBytes });
|
|
137
162
|
return this.backend.voteForTransaction({
|
|
138
163
|
msafeAddress: this.address,
|
|
139
|
-
|
|
140
|
-
txDigest: digest,
|
|
164
|
+
digest,
|
|
141
165
|
signature: signature.signature,
|
|
142
166
|
});
|
|
143
167
|
}
|
|
@@ -162,21 +186,13 @@ export class MSafeAccount {
|
|
|
162
186
|
});
|
|
163
187
|
}
|
|
164
188
|
|
|
165
|
-
async rejectCurrentTx(
|
|
166
|
-
|
|
167
|
-
if (
|
|
168
|
-
|
|
169
|
-
throw new Error('Pending not reject transaction');
|
|
170
|
-
}
|
|
171
|
-
payloadToReject = pending.payload;
|
|
172
|
-
} else {
|
|
173
|
-
const pendingTx = await this.pendingTransaction();
|
|
174
|
-
if (!pendingTx || pendingTx.rejectDigest !== '') {
|
|
175
|
-
throw new Error('Already rejected');
|
|
176
|
-
}
|
|
177
|
-
|
|
178
|
-
payloadToReject = pendingTx.payload;
|
|
189
|
+
async rejectCurrentTx() {
|
|
190
|
+
const pendingTx = await this.pendingTransaction();
|
|
191
|
+
if (!pendingTx || pendingTx.rejectDigest !== '') {
|
|
192
|
+
throw new Error('Already rejected');
|
|
179
193
|
}
|
|
194
|
+
|
|
195
|
+
const payloadToReject = pendingTx.payload;
|
|
180
196
|
const rejectTxb = await IntentionHelper.buildRejectTransaction({
|
|
181
197
|
msafeAddress: this.address,
|
|
182
198
|
payloadToReject,
|
|
@@ -186,7 +202,6 @@ export class MSafeAccount {
|
|
|
186
202
|
const signature = await this.wallet.signTransactionBlock({ transactionBlock: payload });
|
|
187
203
|
return this.backend.rejectCurrentTx({
|
|
188
204
|
msafeAddress: this.address,
|
|
189
|
-
userAddress: await this.userAddress(),
|
|
190
205
|
digest,
|
|
191
206
|
signature: signature.signature,
|
|
192
207
|
});
|
|
@@ -197,11 +212,13 @@ export class MSafeAccount {
|
|
|
197
212
|
}
|
|
198
213
|
|
|
199
214
|
async skipNextFailedIntention() {
|
|
200
|
-
return this.backend.skipNextFailedIntention({ msafeAddress: this.address
|
|
215
|
+
return this.backend.skipNextFailedIntention({ msafeAddress: this.address });
|
|
201
216
|
}
|
|
202
217
|
|
|
203
|
-
async simulateIntention(intention:
|
|
204
|
-
|
|
218
|
+
async simulateIntention(intention: any): Promise<SimulationResult> {
|
|
219
|
+
// Todo, move to API
|
|
220
|
+
const txb = new TransactionBlock(); // await buildIntentionTransaction(this.suiClient, intention, this.address);
|
|
221
|
+
txb.setSender(this.address);
|
|
205
222
|
if (!txb.blockData.gasConfig.price) {
|
|
206
223
|
const refGas = await this.suiClient.getReferenceGasPrice();
|
|
207
224
|
txb.setGasPrice(refGas);
|
package/src/types/msafe.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { DryRunTransactionBlockResponse, GasCostSummary } from '@mysten/sui.js/client';
|
|
2
2
|
import { SerializedSignature } from '@mysten/sui.js/cryptography';
|
|
3
3
|
|
|
4
4
|
import { TxIntention } from '@/transactions/intention';
|
|
@@ -7,7 +7,6 @@ export interface PendingTx {
|
|
|
7
7
|
digest: string;
|
|
8
8
|
payload: string;
|
|
9
9
|
msafeAddress: string;
|
|
10
|
-
isRejectTx: boolean;
|
|
11
10
|
intention: TxIntention;
|
|
12
11
|
creator: string;
|
|
13
12
|
createdAt: Date;
|
|
@@ -86,3 +85,8 @@ export interface SimulationResult {
|
|
|
86
85
|
gasUsed: GasCostSummary;
|
|
87
86
|
dryRunResult: DryRunTransactionBlockResponse;
|
|
88
87
|
}
|
|
88
|
+
|
|
89
|
+
export interface Pagination {
|
|
90
|
+
page?: string;
|
|
91
|
+
limit?: string;
|
|
92
|
+
}
|