@scallop-io/sui-kit 2.1.0 → 2.2.0
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/README.md +6 -6
- package/dist/index.cjs +11 -11
- package/dist/index.d.cts +69 -69
- package/dist/index.d.ts +69 -69
- package/dist/index.js +7 -7
- package/package.json +163 -164
- package/src/index.ts +11 -11
- package/src/libs/multiSig/client.ts +35 -35
- package/src/libs/multiSig/index.ts +1 -1
- package/src/libs/multiSig/publickey.ts +8 -8
- package/src/libs/suiAccountManager/crypto.ts +4 -4
- package/src/libs/suiAccountManager/index.ts +82 -82
- package/src/libs/suiAccountManager/keypair.ts +13 -13
- package/src/libs/suiAccountManager/util.ts +20 -20
- package/src/libs/suiInteractor/index.ts +6 -6
- package/src/libs/suiInteractor/suiInteractor.ts +279 -272
- package/src/libs/suiInteractor/util.ts +6 -6
- package/src/libs/suiModel/index.ts +2 -2
- package/src/libs/suiModel/suiOwnedObject.ts +57 -57
- package/src/libs/suiModel/suiSharedObject.ts +27 -27
- package/src/libs/suiTxBuilder/index.ts +303 -302
- package/src/libs/suiTxBuilder/util.ts +185 -183
- package/src/suiKit.ts +422 -410
- package/src/types/index.ts +71 -76
|
@@ -1,311 +1,312 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import type { bcs } from "@mysten/sui/bcs";
|
|
2
|
+
import type { ClientWithCoreApi } from "@mysten/sui/client";
|
|
3
|
+
import type { Keypair } from "@mysten/sui/cryptography";
|
|
3
4
|
import {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
partitionArray,
|
|
9
|
-
} from './util.js';
|
|
10
|
-
import type { ClientWithCoreApi } from '@mysten/sui/client';
|
|
11
|
-
import type { Keypair } from '@mysten/sui/cryptography';
|
|
5
|
+
Transaction,
|
|
6
|
+
type TransactionObjectInput,
|
|
7
|
+
} from "@mysten/sui/transactions";
|
|
8
|
+
import { SUI_SYSTEM_STATE_OBJECT_ID } from "@mysten/sui/utils";
|
|
12
9
|
import type {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
} from
|
|
19
|
-
import
|
|
10
|
+
SuiAddressArg,
|
|
11
|
+
SuiAmountsArg,
|
|
12
|
+
SuiObjectArg,
|
|
13
|
+
SuiTxArg,
|
|
14
|
+
SuiVecTxArg,
|
|
15
|
+
} from "../../types/index.js";
|
|
16
|
+
import {
|
|
17
|
+
convertAddressArg,
|
|
18
|
+
convertAmounts,
|
|
19
|
+
convertArgs,
|
|
20
|
+
convertObjArg,
|
|
21
|
+
partitionArray,
|
|
22
|
+
} from "./util.js";
|
|
20
23
|
|
|
21
24
|
// Object reference type
|
|
22
25
|
interface SuiObjectRef {
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
+
objectId: string;
|
|
27
|
+
version: number | string;
|
|
28
|
+
digest: string;
|
|
26
29
|
}
|
|
27
30
|
|
|
28
31
|
export class SuiTxBlock {
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
});
|
|
310
|
-
}
|
|
32
|
+
public txBlock: Transaction;
|
|
33
|
+
|
|
34
|
+
constructor(transaction?: Transaction) {
|
|
35
|
+
this.txBlock = transaction
|
|
36
|
+
? Transaction.from(transaction)
|
|
37
|
+
: new Transaction();
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
/* Directly wrap methods and properties of TransactionBlock */
|
|
41
|
+
get gas() {
|
|
42
|
+
return this.txBlock.gas;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
getData() {
|
|
46
|
+
return this.txBlock.getData();
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
address(value: string) {
|
|
50
|
+
return this.txBlock.pure.address(value);
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
get pure(): typeof this.txBlock.pure {
|
|
54
|
+
return this.txBlock.pure;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
object(value: string | TransactionObjectInput) {
|
|
58
|
+
return this.txBlock.object(value);
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
objectRef(ref: SuiObjectRef) {
|
|
62
|
+
return this.txBlock.objectRef(ref);
|
|
63
|
+
}
|
|
64
|
+
sharedObjectRef(ref: typeof bcs.SharedObjectRef.$inferType) {
|
|
65
|
+
return this.txBlock.sharedObjectRef(ref);
|
|
66
|
+
}
|
|
67
|
+
setSender(sender: string) {
|
|
68
|
+
return this.txBlock.setSender(sender);
|
|
69
|
+
}
|
|
70
|
+
setSenderIfNotSet(sender: string) {
|
|
71
|
+
return this.txBlock.setSenderIfNotSet(sender);
|
|
72
|
+
}
|
|
73
|
+
setExpiration(expiration?: Parameters<typeof this.txBlock.setExpiration>[0]) {
|
|
74
|
+
return this.txBlock.setExpiration(expiration);
|
|
75
|
+
}
|
|
76
|
+
setGasPrice(price: number | bigint) {
|
|
77
|
+
return this.txBlock.setGasPrice(price);
|
|
78
|
+
}
|
|
79
|
+
setGasBudget(budget: number | bigint) {
|
|
80
|
+
return this.txBlock.setGasBudget(budget);
|
|
81
|
+
}
|
|
82
|
+
setGasOwner(owner: string) {
|
|
83
|
+
return this.txBlock.setGasOwner(owner);
|
|
84
|
+
}
|
|
85
|
+
setGasPayment(payments: SuiObjectRef[]) {
|
|
86
|
+
return this.txBlock.setGasPayment(payments);
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* @deprecated Use toJSON instead.
|
|
90
|
+
* For synchronous serialization, you can use `getData()`
|
|
91
|
+
* */
|
|
92
|
+
serialize() {
|
|
93
|
+
// TODO: need to update this method to use the new serialize method
|
|
94
|
+
return this.txBlock.serialize();
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
toJSON() {
|
|
98
|
+
return this.txBlock.toJSON();
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
sign(params: {
|
|
102
|
+
signer: Keypair;
|
|
103
|
+
client?: ClientWithCoreApi;
|
|
104
|
+
onlyTransactionKind?: boolean;
|
|
105
|
+
}) {
|
|
106
|
+
return this.txBlock.sign(params);
|
|
107
|
+
}
|
|
108
|
+
build(
|
|
109
|
+
params: { client?: ClientWithCoreApi; onlyTransactionKind?: boolean } = {},
|
|
110
|
+
) {
|
|
111
|
+
return this.txBlock.build(params);
|
|
112
|
+
}
|
|
113
|
+
getDigest(params: { client?: ClientWithCoreApi } = {}) {
|
|
114
|
+
return this.txBlock.getDigest(params);
|
|
115
|
+
}
|
|
116
|
+
add(...args: Parameters<typeof this.txBlock.add>) {
|
|
117
|
+
return this.txBlock.add(...args);
|
|
118
|
+
}
|
|
119
|
+
publish({
|
|
120
|
+
modules,
|
|
121
|
+
dependencies,
|
|
122
|
+
}: {
|
|
123
|
+
modules: number[][] | string[];
|
|
124
|
+
dependencies: string[];
|
|
125
|
+
}) {
|
|
126
|
+
return this.txBlock.publish({ modules, dependencies });
|
|
127
|
+
}
|
|
128
|
+
upgrade(...args: Parameters<typeof this.txBlock.upgrade>) {
|
|
129
|
+
return this.txBlock.upgrade(...args);
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
makeMoveVec(...args: Parameters<typeof this.txBlock.makeMoveVec>) {
|
|
133
|
+
return this.txBlock.makeMoveVec(...args);
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
/* Override methods of TransactionBlock */
|
|
137
|
+
|
|
138
|
+
transferObjects(objects: SuiObjectArg[], address: SuiAddressArg) {
|
|
139
|
+
return this.txBlock.transferObjects(
|
|
140
|
+
objects.map((object) => convertObjArg(this.txBlock, object)),
|
|
141
|
+
convertAddressArg(this.txBlock, address),
|
|
142
|
+
);
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
splitCoins(coin: SuiObjectArg, amounts: SuiAmountsArg[]) {
|
|
146
|
+
const res = this.txBlock.splitCoins(
|
|
147
|
+
convertObjArg(this.txBlock, coin),
|
|
148
|
+
convertAmounts(this.txBlock, amounts),
|
|
149
|
+
);
|
|
150
|
+
return amounts.map((_, i) => res[i]);
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
mergeCoins(destination: SuiObjectArg, sources: SuiObjectArg[]) {
|
|
154
|
+
const destinationObject = convertObjArg(this.txBlock, destination);
|
|
155
|
+
const sourceObjects = sources.map((source) =>
|
|
156
|
+
convertObjArg(this.txBlock, source),
|
|
157
|
+
);
|
|
158
|
+
return this.txBlock.mergeCoins(destinationObject, sourceObjects);
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
/**
|
|
162
|
+
* @description Move call
|
|
163
|
+
* @param target `${string}::${string}::${string}`, e.g. `0x3::sui_system::request_add_stake`
|
|
164
|
+
* @param args the arguments of the move call, such as `['0x1', '0x2']`
|
|
165
|
+
* @param typeArgs the type arguments of the move call, such as `['0x2::sui::SUI']`
|
|
166
|
+
*/
|
|
167
|
+
moveCall(
|
|
168
|
+
target: string,
|
|
169
|
+
args: (SuiTxArg | SuiVecTxArg | SuiObjectArg | SuiAmountsArg)[] = [],
|
|
170
|
+
typeArgs: string[] = [],
|
|
171
|
+
) {
|
|
172
|
+
// a regex for pattern `${string}::${string}::${string}`
|
|
173
|
+
const regex =
|
|
174
|
+
/(?<package>[a-zA-Z0-9]+)::(?<module>[a-zA-Z0-9_]+)::(?<function>[a-zA-Z0-9_]+)/;
|
|
175
|
+
const match = target.match(regex);
|
|
176
|
+
if (match === null)
|
|
177
|
+
throw new Error(
|
|
178
|
+
// biome-ignore lint/suspicious/noTemplateCurlyInString: Intended error message format
|
|
179
|
+
"Invalid target format. Expected `${string}::${string}::${string}`",
|
|
180
|
+
);
|
|
181
|
+
const convertedArgs = convertArgs(this.txBlock, args);
|
|
182
|
+
return this.txBlock.moveCall({
|
|
183
|
+
target: target as `${string}::${string}::${string}`,
|
|
184
|
+
arguments: convertedArgs,
|
|
185
|
+
typeArguments: typeArgs,
|
|
186
|
+
});
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
/* Enhance methods of TransactionBlock */
|
|
190
|
+
transferSuiToMany(recipients: SuiAddressArg[], amounts: SuiAmountsArg[]) {
|
|
191
|
+
// require recipients.length === amounts.length
|
|
192
|
+
if (recipients.length !== amounts.length) {
|
|
193
|
+
throw new Error(
|
|
194
|
+
"transferSuiToMany: recipients.length !== amounts.length",
|
|
195
|
+
);
|
|
196
|
+
}
|
|
197
|
+
const coins = this.txBlock.splitCoins(
|
|
198
|
+
this.txBlock.gas,
|
|
199
|
+
convertAmounts(this.txBlock, amounts),
|
|
200
|
+
);
|
|
201
|
+
|
|
202
|
+
const recipientObjects = recipients.map((recipient) =>
|
|
203
|
+
convertAddressArg(this.txBlock, recipient),
|
|
204
|
+
);
|
|
205
|
+
|
|
206
|
+
// Transfer splitted coins to recipients
|
|
207
|
+
recipientObjects.forEach((address, index) => {
|
|
208
|
+
this.txBlock.transferObjects([coins[index]], address);
|
|
209
|
+
});
|
|
210
|
+
|
|
211
|
+
return this;
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
transferSui(address: SuiAddressArg, amount: SuiAmountsArg) {
|
|
215
|
+
return this.transferSuiToMany([address], [amount]);
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
takeAmountFromCoins(coins: SuiObjectArg[], amount: SuiAmountsArg) {
|
|
219
|
+
const { splitedCoins, mergedCoin } = this.splitMultiCoins(
|
|
220
|
+
coins,
|
|
221
|
+
convertAmounts(this.txBlock, [amount]),
|
|
222
|
+
);
|
|
223
|
+
|
|
224
|
+
return [splitedCoins, mergedCoin];
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
splitSUIFromGas(amounts: SuiAmountsArg[]) {
|
|
228
|
+
return this.txBlock.splitCoins(
|
|
229
|
+
this.txBlock.gas,
|
|
230
|
+
convertAmounts(this.txBlock, amounts),
|
|
231
|
+
);
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
splitMultiCoins(coins: SuiObjectArg[], amounts: SuiAmountsArg[]) {
|
|
235
|
+
if (coins.length === 0) {
|
|
236
|
+
throw new Error("takeAmountFromCoins: coins array is empty");
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
const partitions = partitionArray(coins.slice(1), 511);
|
|
240
|
+
const mergedCoin = convertObjArg(this.txBlock, coins[0]);
|
|
241
|
+
for (const partition of partitions) {
|
|
242
|
+
const coinObjects = partition.map((coin) =>
|
|
243
|
+
convertObjArg(this.txBlock, coin),
|
|
244
|
+
);
|
|
245
|
+
this.txBlock.mergeCoins(mergedCoin, coinObjects);
|
|
246
|
+
}
|
|
247
|
+
const splitedCoins = this.txBlock.splitCoins(
|
|
248
|
+
mergedCoin,
|
|
249
|
+
convertAmounts(this.txBlock, amounts),
|
|
250
|
+
);
|
|
251
|
+
return { splitedCoins, mergedCoin };
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
transferCoinToMany(
|
|
255
|
+
coins: SuiObjectArg[],
|
|
256
|
+
sender: SuiAddressArg,
|
|
257
|
+
recipients: SuiAddressArg[],
|
|
258
|
+
amounts: SuiAmountsArg[],
|
|
259
|
+
) {
|
|
260
|
+
// require recipients.length === amounts.length
|
|
261
|
+
if (recipients.length !== amounts.length) {
|
|
262
|
+
throw new Error(
|
|
263
|
+
"transferCoinToMany: recipients.length !== amounts.length",
|
|
264
|
+
);
|
|
265
|
+
}
|
|
266
|
+
const coinObjects = coins.map((coin) => convertObjArg(this.txBlock, coin));
|
|
267
|
+
const { splitedCoins, mergedCoin } = this.splitMultiCoins(
|
|
268
|
+
coinObjects,
|
|
269
|
+
convertAmounts(this.txBlock, amounts),
|
|
270
|
+
);
|
|
271
|
+
const recipientObjects = recipients.map((recipient) =>
|
|
272
|
+
convertAddressArg(this.txBlock, recipient),
|
|
273
|
+
);
|
|
274
|
+
|
|
275
|
+
// Transfer splitted coins to recipients
|
|
276
|
+
recipientObjects.forEach((address, index) => {
|
|
277
|
+
this.txBlock.transferObjects([splitedCoins[index]], address);
|
|
278
|
+
});
|
|
279
|
+
|
|
280
|
+
// Return the remaining coin back to sender
|
|
281
|
+
this.txBlock.transferObjects(
|
|
282
|
+
[mergedCoin],
|
|
283
|
+
convertAddressArg(this.txBlock, sender),
|
|
284
|
+
);
|
|
285
|
+
|
|
286
|
+
return this;
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
transferCoin(
|
|
290
|
+
coins: SuiObjectArg[],
|
|
291
|
+
sender: SuiAddressArg,
|
|
292
|
+
recipient: SuiAddressArg,
|
|
293
|
+
amount: SuiAmountsArg,
|
|
294
|
+
) {
|
|
295
|
+
return this.transferCoinToMany(coins, sender, [recipient], [amount]);
|
|
296
|
+
}
|
|
297
|
+
|
|
298
|
+
stakeSui(amount: SuiAmountsArg, validatorAddr: SuiAddressArg) {
|
|
299
|
+
const [stakeCoin] = this.txBlock.splitCoins(
|
|
300
|
+
this.txBlock.gas,
|
|
301
|
+
convertAmounts(this.txBlock, [amount]),
|
|
302
|
+
);
|
|
303
|
+
return this.txBlock.moveCall({
|
|
304
|
+
target: "0x3::sui_system::request_add_stake",
|
|
305
|
+
arguments: convertArgs(this.txBlock, [
|
|
306
|
+
this.txBlock.object(SUI_SYSTEM_STATE_OBJECT_ID),
|
|
307
|
+
stakeCoin,
|
|
308
|
+
convertAddressArg(this.txBlock, validatorAddr),
|
|
309
|
+
]),
|
|
310
|
+
});
|
|
311
|
+
}
|
|
311
312
|
}
|