@0xobelisk/sui-client 0.5.3 → 0.5.5
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.ts +3 -1
- package/dist/index.js +343 -238
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +331 -245
- package/dist/index.mjs.map +1 -1
- package/dist/libs/multiSig/client.d.ts +15 -0
- package/dist/libs/multiSig/index.d.ts +1 -0
- package/dist/libs/multiSig/publickey.d.ts +2 -0
- package/dist/libs/suiAccountManager/index.d.ts +1 -1
- package/dist/libs/suiAccountManager/keypair.d.ts +1 -1
- package/dist/libs/suiContractFactory/index.d.ts +1 -1
- package/dist/libs/suiContractFactory/types.d.ts +1 -1
- package/dist/libs/suiInteractor/index.d.ts +0 -1
- package/dist/libs/suiInteractor/suiInteractor.d.ts +17 -177
- package/dist/libs/suiModel/suiOwnedObject.d.ts +4 -4
- package/dist/libs/suiModel/suiSharedObject.d.ts +4 -5
- package/dist/libs/suiTxBuilder/index.d.ts +178 -374
- package/dist/libs/suiTxBuilder/util.d.ts +41 -59
- package/dist/metadata/index.d.ts +2 -33
- package/dist/obelisk.d.ts +20 -2454
- package/dist/types/index.d.ts +28 -6
- package/package.json +22 -19
- package/src/index.ts +3 -1
- package/src/libs/multiSig/client.ts +44 -0
- package/src/libs/multiSig/index.ts +1 -0
- package/src/libs/multiSig/publickey.ts +11 -0
- package/src/libs/suiAccountManager/index.ts +1 -1
- package/src/libs/suiAccountManager/keypair.ts +1 -1
- package/src/libs/suiAccountManager/util.ts +1 -1
- package/src/libs/suiContractFactory/index.ts +1 -1
- package/src/libs/suiContractFactory/types.ts +2 -2
- package/src/libs/suiInteractor/index.ts +1 -1
- package/src/libs/suiInteractor/suiInteractor.ts +106 -111
- package/src/libs/suiModel/suiOwnedObject.ts +5 -10
- package/src/libs/suiModel/suiSharedObject.ts +4 -7
- package/src/libs/suiTxBuilder/index.ts +146 -100
- package/src/libs/suiTxBuilder/util.ts +145 -31
- package/src/metadata/index.ts +5 -3
- package/src/obelisk.ts +52 -37
- package/src/types/index.ts +53 -24
- package/dist/libs/suiInteractor/defaultConfig.d.ts +0 -10
- package/src/libs/suiInteractor/defaultConfig.ts +0 -32
package/dist/index.mjs
CHANGED
|
@@ -13,21 +13,22 @@ var __privateAdd = (obj, member, value) => {
|
|
|
13
13
|
};
|
|
14
14
|
|
|
15
15
|
// src/index.ts
|
|
16
|
-
export * from "@mysten/sui.js";
|
|
16
|
+
export * from "@mysten/sui.js/utils";
|
|
17
|
+
export * from "@mysten/sui.js/transactions";
|
|
17
18
|
import { Ed25519Keypair as Ed25519Keypair3 } from "@mysten/sui.js/keypairs/ed25519";
|
|
18
19
|
import { BCS as BCS2, getSuiMoveConfig as getSuiMoveConfig2 } from "@mysten/bcs";
|
|
19
20
|
|
|
20
21
|
// src/obelisk.ts
|
|
22
|
+
import { getFullnodeUrl } from "@mysten/sui.js/client";
|
|
21
23
|
import {
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
} from "@mysten/sui.js";
|
|
24
|
+
TransactionBlock as TransactionBlock2
|
|
25
|
+
} from "@mysten/sui.js/transactions";
|
|
25
26
|
|
|
26
27
|
// src/libs/suiAccountManager/index.ts
|
|
27
|
-
import { Ed25519Keypair as Ed25519Keypair2 } from "@mysten/sui.js";
|
|
28
|
+
import { Ed25519Keypair as Ed25519Keypair2 } from "@mysten/sui.js/keypairs/ed25519";
|
|
28
29
|
|
|
29
30
|
// src/libs/suiAccountManager/keypair.ts
|
|
30
|
-
import { Ed25519Keypair } from "@mysten/sui.js";
|
|
31
|
+
import { Ed25519Keypair } from "@mysten/sui.js/keypairs/ed25519";
|
|
31
32
|
var getDerivePathForSUI = (derivePathParams = {}) => {
|
|
32
33
|
const {
|
|
33
34
|
accountIndex = 0,
|
|
@@ -42,7 +43,7 @@ var getKeyPair = (mnemonics, derivePathParams = {}) => {
|
|
|
42
43
|
};
|
|
43
44
|
|
|
44
45
|
// src/libs/suiAccountManager/util.ts
|
|
45
|
-
import { fromB64
|
|
46
|
+
import { fromB64 } from "@mysten/sui.js/utils";
|
|
46
47
|
var isHex = (str) => /^0x[0-9a-fA-F]+$|^[0-9a-fA-F]+$/.test(str);
|
|
47
48
|
var isBase64 = (str) => /^[a-zA-Z0-9+/]+={0,2}$/g.test(str);
|
|
48
49
|
var fromHEX = (hexStr) => {
|
|
@@ -59,7 +60,7 @@ var hexOrBase64ToUint8Array = (str) => {
|
|
|
59
60
|
if (isHex(str)) {
|
|
60
61
|
return fromHEX(str);
|
|
61
62
|
} else if (isBase64(str)) {
|
|
62
|
-
return
|
|
63
|
+
return fromB64(str);
|
|
63
64
|
} else {
|
|
64
65
|
throw new Error("The string is not a valid hex or base64 string.");
|
|
65
66
|
}
|
|
@@ -140,66 +141,123 @@ var SuiAccountManager = class {
|
|
|
140
141
|
};
|
|
141
142
|
|
|
142
143
|
// src/libs/suiTxBuilder/index.ts
|
|
143
|
-
import {
|
|
144
|
-
|
|
145
|
-
SUI_SYSTEM_STATE_OBJECT_ID
|
|
146
|
-
} from "@mysten/sui.js";
|
|
144
|
+
import { TransactionBlock } from "@mysten/sui.js/transactions";
|
|
145
|
+
import { SUI_SYSTEM_STATE_OBJECT_ID } from "@mysten/sui.js/utils";
|
|
147
146
|
|
|
148
147
|
// src/libs/suiTxBuilder/util.ts
|
|
149
148
|
import {
|
|
150
|
-
normalizeSuiObjectId
|
|
151
|
-
|
|
149
|
+
normalizeSuiObjectId,
|
|
150
|
+
normalizeSuiAddress,
|
|
151
|
+
isValidSuiObjectId,
|
|
152
|
+
isValidSuiAddress
|
|
153
|
+
} from "@mysten/sui.js/utils";
|
|
154
|
+
import { Inputs } from "@mysten/sui.js/transactions";
|
|
155
|
+
import { isPureArg } from "@mysten/sui.js/bcs";
|
|
156
|
+
import { isSerializedBcs } from "@mysten/bcs";
|
|
152
157
|
var getDefaultSuiInputType = (value) => {
|
|
153
|
-
if (typeof value === "string" && value
|
|
158
|
+
if (typeof value === "string" && isValidSuiObjectId(value)) {
|
|
154
159
|
return "object";
|
|
155
160
|
} else if (typeof value === "number" || typeof value === "bigint") {
|
|
156
161
|
return "u64";
|
|
157
162
|
} else if (typeof value === "boolean") {
|
|
158
163
|
return "bool";
|
|
159
164
|
} else {
|
|
160
|
-
return
|
|
165
|
+
return void 0;
|
|
161
166
|
}
|
|
162
167
|
};
|
|
163
168
|
function makeVecParam(txBlock, args, type) {
|
|
164
169
|
if (args.length === 0)
|
|
165
170
|
throw new Error("Transaction builder error: Empty array is not allowed");
|
|
166
171
|
const defaultSuiType = getDefaultSuiInputType(args[0]);
|
|
167
|
-
|
|
172
|
+
const VECTOR_REGEX = /^vector<(.+)>$/;
|
|
173
|
+
const STRUCT_REGEX = /^([^:]+)::([^:]+)::([^<]+)(<(.+)>)?/;
|
|
174
|
+
type = type || defaultSuiType;
|
|
175
|
+
if (type === "object") {
|
|
168
176
|
const objects = args.map(
|
|
169
|
-
(arg) => typeof arg === "string" ? txBlock.object(normalizeSuiObjectId(arg)) : arg
|
|
177
|
+
(arg) => typeof arg === "string" && isValidSuiObjectId(arg) ? txBlock.object(normalizeSuiObjectId(arg)) : convertObjArg(txBlock, arg)
|
|
170
178
|
);
|
|
171
179
|
return txBlock.makeMoveVec({ objects });
|
|
180
|
+
} else if (typeof type === "string" && !VECTOR_REGEX.test(type) && !STRUCT_REGEX.test(type)) {
|
|
181
|
+
return txBlock.pure(args, `vector<${type}>`);
|
|
172
182
|
} else {
|
|
173
|
-
const
|
|
174
|
-
|
|
183
|
+
const objects = args.map(
|
|
184
|
+
(arg) => convertObjArg(txBlock, arg)
|
|
185
|
+
);
|
|
186
|
+
return txBlock.makeMoveVec({ objects, type });
|
|
175
187
|
}
|
|
176
188
|
}
|
|
177
189
|
function isMoveVecArg(arg) {
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
190
|
+
if (typeof arg === "object" && "vecType" in arg && "value" in arg) {
|
|
191
|
+
return true;
|
|
192
|
+
} else if (Array.isArray(arg)) {
|
|
193
|
+
return true;
|
|
194
|
+
}
|
|
195
|
+
return false;
|
|
181
196
|
}
|
|
182
197
|
function convertArgs(txBlock, args) {
|
|
183
198
|
return args.map((arg) => {
|
|
184
|
-
if (typeof arg === "string" && arg
|
|
199
|
+
if (typeof arg === "string" && isValidSuiObjectId(arg)) {
|
|
185
200
|
return txBlock.object(normalizeSuiObjectId(arg));
|
|
201
|
+
} else if (typeof arg == "object" && !isSerializedBcs(arg) && !isPureArg(arg) && !isMoveVecArg(arg)) {
|
|
202
|
+
return convertObjArg(txBlock, arg);
|
|
186
203
|
} else if (isMoveVecArg(arg)) {
|
|
187
|
-
const vecType =
|
|
188
|
-
return vecType ? makeVecParam(txBlock, arg.value, vecType) : makeVecParam(txBlock, arg);
|
|
189
|
-
} else if (
|
|
190
|
-
return txBlock.pure(arg);
|
|
191
|
-
} else {
|
|
204
|
+
const vecType = "vecType" in arg;
|
|
205
|
+
return vecType ? makeVecParam(txBlock, arg.value, arg.vecType) : makeVecParam(txBlock, arg);
|
|
206
|
+
} else if (isSerializedBcs(arg)) {
|
|
192
207
|
return arg;
|
|
208
|
+
} else {
|
|
209
|
+
return txBlock.pure(arg);
|
|
193
210
|
}
|
|
194
211
|
});
|
|
195
212
|
}
|
|
213
|
+
function convertAddressArg(txBlock, arg) {
|
|
214
|
+
if (typeof arg === "string" && isValidSuiAddress(arg)) {
|
|
215
|
+
return txBlock.pure.address(normalizeSuiAddress(arg));
|
|
216
|
+
} else if (typeof arg == "object" && !isSerializedBcs(arg) && !isPureArg(arg)) {
|
|
217
|
+
return convertObjArg(txBlock, arg);
|
|
218
|
+
} else if (isPureArg(arg)) {
|
|
219
|
+
return txBlock.pure(arg);
|
|
220
|
+
} else {
|
|
221
|
+
return arg;
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
function convertObjArg(txb, arg) {
|
|
225
|
+
if (typeof arg === "string") {
|
|
226
|
+
return txb.object(arg);
|
|
227
|
+
}
|
|
228
|
+
if ("digest" in arg && "version" in arg && "objectId" in arg) {
|
|
229
|
+
return txb.objectRef(arg);
|
|
230
|
+
}
|
|
231
|
+
if ("objectId" in arg && "initialSharedVersion" in arg && "mutable" in arg) {
|
|
232
|
+
return txb.sharedObjectRef(arg);
|
|
233
|
+
}
|
|
234
|
+
if ("Object" in arg) {
|
|
235
|
+
if ("ImmOrOwned" in arg.Object) {
|
|
236
|
+
return txb.object(Inputs.ObjectRef(arg.Object.ImmOrOwned));
|
|
237
|
+
} else if ("Shared" in arg.Object) {
|
|
238
|
+
return txb.object(Inputs.SharedObjectRef(arg.Object.Shared));
|
|
239
|
+
} else {
|
|
240
|
+
throw new Error("Invalid argument type");
|
|
241
|
+
}
|
|
242
|
+
}
|
|
243
|
+
if ("kind" in arg) {
|
|
244
|
+
return arg;
|
|
245
|
+
}
|
|
246
|
+
throw new Error("Invalid argument type");
|
|
247
|
+
}
|
|
196
248
|
|
|
197
249
|
// src/libs/suiTxBuilder/index.ts
|
|
198
250
|
var SuiTxBlock = class {
|
|
199
251
|
constructor(transaction) {
|
|
200
|
-
this.txBlock = new
|
|
252
|
+
this.txBlock = new TransactionBlock(transaction);
|
|
253
|
+
}
|
|
254
|
+
/* Directly wrap methods and properties of TransactionBlock */
|
|
255
|
+
get gas() {
|
|
256
|
+
return this.txBlock.gas;
|
|
257
|
+
}
|
|
258
|
+
get blockData() {
|
|
259
|
+
return this.txBlock.blockData;
|
|
201
260
|
}
|
|
202
|
-
//======== override methods of TransactionBlock ============
|
|
203
261
|
address(value) {
|
|
204
262
|
return this.txBlock.pure(value, "address");
|
|
205
263
|
}
|
|
@@ -236,59 +294,69 @@ var SuiTxBlock = class {
|
|
|
236
294
|
setGasPayment(payments) {
|
|
237
295
|
return this.txBlock.setGasPayment(payments);
|
|
238
296
|
}
|
|
239
|
-
add(transaction) {
|
|
240
|
-
return this.txBlock.add(transaction);
|
|
241
|
-
}
|
|
242
297
|
serialize() {
|
|
243
298
|
return this.txBlock.serialize();
|
|
244
299
|
}
|
|
300
|
+
sign(params) {
|
|
301
|
+
return this.txBlock.sign(params);
|
|
302
|
+
}
|
|
245
303
|
build(params = {}) {
|
|
246
304
|
return this.txBlock.build(params);
|
|
247
305
|
}
|
|
248
|
-
getDigest(
|
|
249
|
-
return this.txBlock.getDigest(
|
|
306
|
+
getDigest(params = {}) {
|
|
307
|
+
return this.txBlock.getDigest(params);
|
|
250
308
|
}
|
|
251
|
-
|
|
252
|
-
return this.txBlock.
|
|
309
|
+
add(...args) {
|
|
310
|
+
return this.txBlock.add(...args);
|
|
253
311
|
}
|
|
254
|
-
|
|
255
|
-
|
|
312
|
+
publish({
|
|
313
|
+
modules,
|
|
314
|
+
dependencies
|
|
315
|
+
}) {
|
|
316
|
+
return this.txBlock.publish({ modules, dependencies });
|
|
256
317
|
}
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
318
|
+
upgrade({
|
|
319
|
+
modules,
|
|
320
|
+
dependencies,
|
|
321
|
+
packageId,
|
|
322
|
+
ticket
|
|
323
|
+
}) {
|
|
324
|
+
return this.txBlock.upgrade({ modules, dependencies, packageId, ticket });
|
|
325
|
+
}
|
|
326
|
+
makeMoveVec({
|
|
327
|
+
objects,
|
|
328
|
+
type
|
|
329
|
+
}) {
|
|
330
|
+
return this.txBlock.makeMoveVec({ objects, type });
|
|
331
|
+
}
|
|
332
|
+
/* Override methods of TransactionBlock */
|
|
333
|
+
transferObjects(objects, address) {
|
|
334
|
+
return this.txBlock.transferObjects(
|
|
335
|
+
objects.map((object) => convertObjArg(this.txBlock, object)),
|
|
336
|
+
convertAddressArg(this.txBlock, address)
|
|
337
|
+
);
|
|
261
338
|
}
|
|
262
339
|
splitCoins(coin, amounts) {
|
|
263
|
-
const
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
coinObject,
|
|
267
|
-
amounts.map((m) => tx.pure(m))
|
|
340
|
+
const res = this.txBlock.splitCoins(
|
|
341
|
+
convertObjArg(this.txBlock, coin),
|
|
342
|
+
convertArgs(this.txBlock, amounts)
|
|
268
343
|
);
|
|
269
344
|
return amounts.map((_, i) => res[i]);
|
|
270
345
|
}
|
|
271
346
|
mergeCoins(destination, sources) {
|
|
272
|
-
const destinationObject =
|
|
273
|
-
const sourceObjects =
|
|
347
|
+
const destinationObject = convertObjArg(this.txBlock, destination);
|
|
348
|
+
const sourceObjects = sources.map(
|
|
349
|
+
(source) => convertObjArg(this.txBlock, source)
|
|
350
|
+
);
|
|
274
351
|
return this.txBlock.mergeCoins(destinationObject, sourceObjects);
|
|
275
352
|
}
|
|
276
|
-
publish(...args) {
|
|
277
|
-
return this.txBlock.publish(...args);
|
|
278
|
-
}
|
|
279
|
-
upgrade(...args) {
|
|
280
|
-
return this.txBlock.upgrade(...args);
|
|
281
|
-
}
|
|
282
|
-
makeMoveVec(...args) {
|
|
283
|
-
return this.txBlock.makeMoveVec(...args);
|
|
284
|
-
}
|
|
285
353
|
/**
|
|
286
354
|
* @description Move call
|
|
287
355
|
* @param target `${string}::${string}::${string}`, e.g. `0x3::sui_system::request_add_stake`
|
|
288
356
|
* @param args the arguments of the move call, such as `['0x1', '0x2']`
|
|
289
|
-
* @param
|
|
357
|
+
* @param typeArgs the type arguments of the move call, such as `['0x2::sui::SUI']`
|
|
290
358
|
*/
|
|
291
|
-
moveCall(target, args = [],
|
|
359
|
+
moveCall(target, args = [], typeArgs = []) {
|
|
292
360
|
const regex = /(?<package>[a-zA-Z0-9]+)::(?<module>[a-zA-Z0-9_]+)::(?<function>[a-zA-Z0-9_]+)/;
|
|
293
361
|
const match = target.match(regex);
|
|
294
362
|
if (match === null)
|
|
@@ -296,115 +364,111 @@ var SuiTxBlock = class {
|
|
|
296
364
|
"Invalid target format. Expected `${string}::${string}::${string}`"
|
|
297
365
|
);
|
|
298
366
|
const convertedArgs = convertArgs(this.txBlock, args);
|
|
299
|
-
|
|
300
|
-
return tx.moveCall({
|
|
367
|
+
return this.txBlock.moveCall({
|
|
301
368
|
target,
|
|
302
369
|
arguments: convertedArgs,
|
|
303
|
-
typeArguments
|
|
370
|
+
typeArguments: typeArgs
|
|
304
371
|
});
|
|
305
372
|
}
|
|
306
|
-
|
|
373
|
+
/* Enhance methods of TransactionBlock */
|
|
307
374
|
transferSuiToMany(recipients, amounts) {
|
|
308
375
|
if (recipients.length !== amounts.length) {
|
|
309
376
|
throw new Error(
|
|
310
377
|
"transferSuiToMany: recipients.length !== amounts.length"
|
|
311
378
|
);
|
|
312
379
|
}
|
|
313
|
-
const
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
380
|
+
const coins = this.txBlock.splitCoins(
|
|
381
|
+
this.txBlock.gas,
|
|
382
|
+
convertArgs(this.txBlock, amounts)
|
|
383
|
+
);
|
|
384
|
+
const recipientObjects = recipients.map(
|
|
385
|
+
(recipient) => convertAddressArg(this.txBlock, recipient)
|
|
317
386
|
);
|
|
318
|
-
|
|
319
|
-
|
|
387
|
+
recipientObjects.forEach((address, index) => {
|
|
388
|
+
this.txBlock.transferObjects([coins[index]], address);
|
|
320
389
|
});
|
|
321
390
|
return this;
|
|
322
391
|
}
|
|
323
|
-
transferSui(
|
|
324
|
-
return this.transferSuiToMany([
|
|
392
|
+
transferSui(address, amount) {
|
|
393
|
+
return this.transferSuiToMany([address], [amount]);
|
|
325
394
|
}
|
|
326
395
|
takeAmountFromCoins(coins, amount) {
|
|
327
|
-
const
|
|
328
|
-
const coinObjects = convertArgs(this.txBlock, coins);
|
|
396
|
+
const coinObjects = coins.map((coin) => convertObjArg(this.txBlock, coin));
|
|
329
397
|
const mergedCoin = coinObjects[0];
|
|
330
398
|
if (coins.length > 1) {
|
|
331
|
-
|
|
399
|
+
this.txBlock.mergeCoins(mergedCoin, coinObjects.slice(1));
|
|
332
400
|
}
|
|
333
|
-
const [sendCoin] =
|
|
401
|
+
const [sendCoin] = this.txBlock.splitCoins(
|
|
402
|
+
mergedCoin,
|
|
403
|
+
convertArgs(this.txBlock, [amount])
|
|
404
|
+
);
|
|
334
405
|
return [sendCoin, mergedCoin];
|
|
335
406
|
}
|
|
336
407
|
splitSUIFromGas(amounts) {
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
amounts.map((m) => tx.pure(m))
|
|
408
|
+
return this.txBlock.splitCoins(
|
|
409
|
+
this.txBlock.gas,
|
|
410
|
+
convertArgs(this.txBlock, amounts)
|
|
341
411
|
);
|
|
342
412
|
}
|
|
343
413
|
splitMultiCoins(coins, amounts) {
|
|
344
|
-
const
|
|
345
|
-
const coinObjects = convertArgs(this.txBlock, coins);
|
|
414
|
+
const coinObjects = coins.map((coin) => convertObjArg(this.txBlock, coin));
|
|
346
415
|
const mergedCoin = coinObjects[0];
|
|
347
416
|
if (coins.length > 1) {
|
|
348
|
-
|
|
417
|
+
this.txBlock.mergeCoins(mergedCoin, coinObjects.slice(1));
|
|
349
418
|
}
|
|
350
|
-
const splitedCoins =
|
|
419
|
+
const splitedCoins = this.txBlock.splitCoins(
|
|
351
420
|
mergedCoin,
|
|
352
|
-
|
|
421
|
+
convertArgs(this.txBlock, amounts)
|
|
353
422
|
);
|
|
354
423
|
return { splitedCoins, mergedCoin };
|
|
355
424
|
}
|
|
356
|
-
transferCoinToMany(
|
|
425
|
+
transferCoinToMany(coins, sender, recipients, amounts) {
|
|
357
426
|
if (recipients.length !== amounts.length) {
|
|
358
427
|
throw new Error(
|
|
359
428
|
"transferSuiToMany: recipients.length !== amounts.length"
|
|
360
429
|
);
|
|
361
430
|
}
|
|
362
|
-
const
|
|
431
|
+
const coinObjects = coins.map((coin) => convertObjArg(this.txBlock, coin));
|
|
363
432
|
const { splitedCoins, mergedCoin } = this.splitMultiCoins(
|
|
364
|
-
|
|
433
|
+
coinObjects,
|
|
365
434
|
amounts
|
|
366
435
|
);
|
|
367
|
-
recipients.
|
|
368
|
-
|
|
436
|
+
const recipientObjects = recipients.map(
|
|
437
|
+
(recipient) => convertAddressArg(this.txBlock, recipient)
|
|
438
|
+
);
|
|
439
|
+
recipientObjects.forEach((address, index) => {
|
|
440
|
+
this.txBlock.transferObjects([splitedCoins[index]], address);
|
|
369
441
|
});
|
|
370
|
-
|
|
442
|
+
this.txBlock.transferObjects(
|
|
443
|
+
[mergedCoin],
|
|
444
|
+
convertAddressArg(this.txBlock, sender)
|
|
445
|
+
);
|
|
371
446
|
return this;
|
|
372
447
|
}
|
|
373
|
-
transferCoin(
|
|
374
|
-
return this.transferCoinToMany(
|
|
448
|
+
transferCoin(coins, sender, recipient, amount) {
|
|
449
|
+
return this.transferCoinToMany(coins, sender, [recipient], [amount]);
|
|
375
450
|
}
|
|
376
451
|
stakeSui(amount, validatorAddr) {
|
|
377
|
-
const
|
|
378
|
-
|
|
379
|
-
|
|
452
|
+
const [stakeCoin] = this.txBlock.splitCoins(
|
|
453
|
+
this.txBlock.gas,
|
|
454
|
+
convertArgs(this.txBlock, [amount])
|
|
455
|
+
);
|
|
456
|
+
return this.txBlock.moveCall({
|
|
380
457
|
target: "0x3::sui_system::request_add_stake",
|
|
381
|
-
arguments: [
|
|
382
|
-
|
|
458
|
+
arguments: convertArgs(this.txBlock, [
|
|
459
|
+
SUI_SYSTEM_STATE_OBJECT_ID,
|
|
383
460
|
stakeCoin,
|
|
384
|
-
|
|
385
|
-
]
|
|
461
|
+
this.txBlock.pure(validatorAddr)
|
|
462
|
+
])
|
|
386
463
|
});
|
|
387
|
-
return tx;
|
|
388
464
|
}
|
|
389
465
|
};
|
|
390
466
|
|
|
391
467
|
// src/libs/suiInteractor/suiInteractor.ts
|
|
392
|
-
import {
|
|
393
|
-
JsonRpcProvider as JsonRpcProvider2,
|
|
394
|
-
Connection,
|
|
395
|
-
getObjectDisplay,
|
|
396
|
-
getObjectFields,
|
|
397
|
-
getObjectId,
|
|
398
|
-
getObjectType,
|
|
399
|
-
getObjectVersion,
|
|
400
|
-
getSharedObjectInitialVersion
|
|
401
|
-
} from "@mysten/sui.js";
|
|
468
|
+
import { SuiClient } from "@mysten/sui.js/client";
|
|
402
469
|
import { requestSuiFromFaucetV0, getFaucetHost } from "@mysten/sui.js/faucet";
|
|
403
470
|
|
|
404
471
|
// src/libs/suiModel/suiOwnedObject.ts
|
|
405
|
-
import {
|
|
406
|
-
getObjectChanges
|
|
407
|
-
} from "@mysten/sui.js";
|
|
408
472
|
var SuiOwnedObject = class {
|
|
409
473
|
constructor(param) {
|
|
410
474
|
this.objectId = param.objectId;
|
|
@@ -438,7 +502,7 @@ var SuiOwnedObject = class {
|
|
|
438
502
|
* @param txResponse
|
|
439
503
|
*/
|
|
440
504
|
updateFromTxResponse(txResponse) {
|
|
441
|
-
const changes =
|
|
505
|
+
const changes = txResponse.objectChanges;
|
|
442
506
|
if (!changes) {
|
|
443
507
|
throw new Error("Bad transaction response!");
|
|
444
508
|
}
|
|
@@ -483,15 +547,16 @@ var SuiInteractor = class {
|
|
|
483
547
|
constructor(fullNodeUrls, network) {
|
|
484
548
|
if (fullNodeUrls.length === 0)
|
|
485
549
|
throw new Error("fullNodeUrls must not be empty");
|
|
486
|
-
this.
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
this.
|
|
550
|
+
this.fullNodes = fullNodeUrls;
|
|
551
|
+
this.clients = fullNodeUrls.map((url) => new SuiClient({ url }));
|
|
552
|
+
this.currentFullNode = fullNodeUrls[0];
|
|
553
|
+
this.currentClient = this.clients[0];
|
|
490
554
|
this.network = network;
|
|
491
555
|
}
|
|
492
|
-
|
|
493
|
-
const
|
|
494
|
-
this.
|
|
556
|
+
switchToNextClient() {
|
|
557
|
+
const currentClientIdx = this.clients.indexOf(this.currentClient);
|
|
558
|
+
this.currentClient = this.clients[(currentClientIdx + 1) % this.clients.length];
|
|
559
|
+
this.currentFullNode = this.fullNodes[(currentClientIdx + 1) % this.clients.length];
|
|
495
560
|
}
|
|
496
561
|
async sendTx(transactionBlock, signature) {
|
|
497
562
|
const txResOptions = {
|
|
@@ -500,56 +565,43 @@ var SuiInteractor = class {
|
|
|
500
565
|
showObjectChanges: true,
|
|
501
566
|
showBalanceChanges: true
|
|
502
567
|
};
|
|
503
|
-
for (const
|
|
568
|
+
for (const clientIdx in this.clients) {
|
|
504
569
|
try {
|
|
505
|
-
|
|
570
|
+
return await this.clients[clientIdx].executeTransactionBlock({
|
|
506
571
|
transactionBlock,
|
|
507
572
|
signature,
|
|
508
573
|
options: txResOptions
|
|
509
574
|
});
|
|
510
|
-
return res;
|
|
511
575
|
} catch (err) {
|
|
512
576
|
console.warn(
|
|
513
|
-
`Failed to send transaction with fullnode ${
|
|
577
|
+
`Failed to send transaction with fullnode ${this.fullNodes[clientIdx]}: ${err}`
|
|
514
578
|
);
|
|
515
579
|
await delay(2e3);
|
|
516
580
|
}
|
|
517
581
|
}
|
|
518
582
|
throw new Error("Failed to send transaction with all fullnodes");
|
|
519
583
|
}
|
|
520
|
-
async getObjects(ids) {
|
|
521
|
-
const
|
|
584
|
+
async getObjects(ids, options) {
|
|
585
|
+
const opts = options ?? {
|
|
522
586
|
showContent: true,
|
|
523
587
|
showDisplay: true,
|
|
524
588
|
showType: true,
|
|
525
589
|
showOwner: true
|
|
526
590
|
};
|
|
527
|
-
for (const
|
|
591
|
+
for (const clientIdx in this.clients) {
|
|
528
592
|
try {
|
|
529
|
-
const objects = await
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
const objectType = getObjectType(object);
|
|
533
|
-
const objectVersion = getObjectVersion(object);
|
|
534
|
-
const objectDigest = object.data ? object.data.digest : void 0;
|
|
535
|
-
const initialSharedVersion = getSharedObjectInitialVersion(object);
|
|
536
|
-
const objectFields = getObjectFields(object);
|
|
537
|
-
const objectDisplay = getObjectDisplay(object);
|
|
538
|
-
return {
|
|
539
|
-
objectId,
|
|
540
|
-
objectType,
|
|
541
|
-
objectVersion,
|
|
542
|
-
objectDigest,
|
|
543
|
-
objectFields,
|
|
544
|
-
objectDisplay,
|
|
545
|
-
initialSharedVersion
|
|
546
|
-
};
|
|
593
|
+
const objects = await this.clients[clientIdx].multiGetObjects({
|
|
594
|
+
ids,
|
|
595
|
+
options: opts
|
|
547
596
|
});
|
|
597
|
+
const parsedObjects = objects.map((object) => {
|
|
598
|
+
return object.data;
|
|
599
|
+
}).filter((object) => object !== null && object !== void 0);
|
|
548
600
|
return parsedObjects;
|
|
549
601
|
} catch (err) {
|
|
550
602
|
await delay(2e3);
|
|
551
603
|
console.warn(
|
|
552
|
-
`Failed to get objects with fullnode ${
|
|
604
|
+
`Failed to get objects with fullnode ${this.fullNodes[clientIdx]}: ${err}`
|
|
553
605
|
);
|
|
554
606
|
}
|
|
555
607
|
}
|
|
@@ -559,84 +611,88 @@ var SuiInteractor = class {
|
|
|
559
611
|
const objects = await this.getObjects([id]);
|
|
560
612
|
return objects[0];
|
|
561
613
|
}
|
|
562
|
-
// async getEntitiesObjects(ids: string[]) {
|
|
563
|
-
// const options = {
|
|
564
|
-
// showContent: true,
|
|
565
|
-
// showType: true,
|
|
566
|
-
// };
|
|
567
|
-
// for (const provider of this.providers) {
|
|
568
|
-
// try {
|
|
569
|
-
// const objects = await provider.multiGetObjects({ ids, options });
|
|
570
|
-
// const parsedObjects = objects.map((object) => {
|
|
571
|
-
// const objectId = getObjectId(object);
|
|
572
|
-
// const objectFields = getObjectFields(object) as ObjectFieldType;
|
|
573
|
-
// const index = objectFields.name;
|
|
574
|
-
// const key = objectFields.value;
|
|
575
|
-
// return {
|
|
576
|
-
// objectId,
|
|
577
|
-
// index,
|
|
578
|
-
// key,
|
|
579
|
-
// };
|
|
580
|
-
// });
|
|
581
|
-
// return parsedObjects as EntityData[];
|
|
582
|
-
// } catch (err) {
|
|
583
|
-
// await delay(2000);
|
|
584
|
-
// console.warn(
|
|
585
|
-
// `Failed to get EntitiesObjects with fullnode ${provider.connection.fullnode}: ${err}`
|
|
586
|
-
// );
|
|
587
|
-
// }
|
|
588
|
-
// }
|
|
589
|
-
// throw new Error('Failed to get EntitiesObjects with all fullnodes');
|
|
590
|
-
// }
|
|
591
614
|
async getDynamicFieldObject(parentId, name) {
|
|
592
|
-
for (const
|
|
615
|
+
for (const clientIdx in this.clients) {
|
|
593
616
|
try {
|
|
594
|
-
return
|
|
617
|
+
return await this.clients[clientIdx].getDynamicFieldObject({
|
|
618
|
+
parentId,
|
|
619
|
+
name
|
|
620
|
+
});
|
|
595
621
|
} catch (err) {
|
|
596
622
|
await delay(2e3);
|
|
597
623
|
console.warn(
|
|
598
|
-
`Failed to get DynamicFieldObject with fullnode ${
|
|
624
|
+
`Failed to get DynamicFieldObject with fullnode ${this.fullNodes[clientIdx]}: ${err}`
|
|
599
625
|
);
|
|
600
626
|
}
|
|
601
627
|
}
|
|
602
628
|
throw new Error("Failed to get DynamicFieldObject with all fullnodes");
|
|
603
629
|
}
|
|
604
630
|
async getDynamicFields(parentId, cursor, limit) {
|
|
605
|
-
for (const
|
|
631
|
+
for (const clientIdx in this.clients) {
|
|
606
632
|
try {
|
|
607
|
-
return
|
|
633
|
+
return await this.clients[clientIdx].getDynamicFields({
|
|
634
|
+
parentId,
|
|
635
|
+
cursor,
|
|
636
|
+
limit
|
|
637
|
+
});
|
|
608
638
|
} catch (err) {
|
|
609
639
|
await delay(2e3);
|
|
610
640
|
console.warn(
|
|
611
|
-
`Failed to get DynamicFields with fullnode ${
|
|
641
|
+
`Failed to get DynamicFields with fullnode ${this.fullNodes[clientIdx]}: ${err}`
|
|
612
642
|
);
|
|
613
643
|
}
|
|
614
644
|
}
|
|
615
645
|
throw new Error("Failed to get DynamicFields with all fullnodes");
|
|
616
646
|
}
|
|
647
|
+
async getTxDetails(digest) {
|
|
648
|
+
for (const clientIdx in this.clients) {
|
|
649
|
+
try {
|
|
650
|
+
const txResOptions = {
|
|
651
|
+
showEvents: true,
|
|
652
|
+
showEffects: true,
|
|
653
|
+
showObjectChanges: true,
|
|
654
|
+
showBalanceChanges: true
|
|
655
|
+
};
|
|
656
|
+
return await this.clients[clientIdx].getTransactionBlock({
|
|
657
|
+
digest,
|
|
658
|
+
options: txResOptions
|
|
659
|
+
});
|
|
660
|
+
} catch (err) {
|
|
661
|
+
await delay(2e3);
|
|
662
|
+
console.warn(
|
|
663
|
+
`Failed to get TransactionBlocks with fullnode ${this.fullNodes[clientIdx]}: ${err}`
|
|
664
|
+
);
|
|
665
|
+
}
|
|
666
|
+
}
|
|
667
|
+
throw new Error("Failed to get TransactionBlocks with all fullnodes");
|
|
668
|
+
}
|
|
617
669
|
async getOwnedObjects(owner, cursor, limit) {
|
|
618
|
-
for (const
|
|
670
|
+
for (const clientIdx in this.clients) {
|
|
619
671
|
try {
|
|
620
|
-
return await
|
|
672
|
+
return await this.clients[clientIdx].getOwnedObjects({
|
|
673
|
+
owner,
|
|
674
|
+
cursor,
|
|
675
|
+
limit
|
|
676
|
+
});
|
|
621
677
|
} catch (err) {
|
|
622
678
|
await delay(2e3);
|
|
623
679
|
console.warn(
|
|
624
|
-
`Failed to get OwnedObjects with fullnode ${
|
|
680
|
+
`Failed to get OwnedObjects with fullnode ${this.fullNodes[clientIdx]}: ${err}`
|
|
625
681
|
);
|
|
626
682
|
}
|
|
627
683
|
}
|
|
628
684
|
throw new Error("Failed to get OwnedObjects with all fullnodes");
|
|
629
685
|
}
|
|
630
686
|
async getNormalizedMoveModulesByPackage(packageId) {
|
|
631
|
-
for (const
|
|
687
|
+
for (const clientIdx in this.clients) {
|
|
632
688
|
try {
|
|
633
|
-
return
|
|
689
|
+
return await this.clients[clientIdx].getNormalizedMoveModulesByPackage({
|
|
634
690
|
package: packageId
|
|
635
691
|
});
|
|
636
692
|
} catch (err) {
|
|
637
693
|
await delay(2e3);
|
|
638
694
|
console.warn(
|
|
639
|
-
`Failed to get NormalizedMoveModules with fullnode ${
|
|
695
|
+
`Failed to get NormalizedMoveModules with fullnode ${this.fullNodes[clientIdx]}: ${err}`
|
|
640
696
|
);
|
|
641
697
|
}
|
|
642
698
|
}
|
|
@@ -651,13 +707,17 @@ var SuiInteractor = class {
|
|
|
651
707
|
const objects = await this.getObjects(objectIds);
|
|
652
708
|
for (const object of objects) {
|
|
653
709
|
const suiObject = suiObjects.find(
|
|
654
|
-
(obj) => obj.objectId === object
|
|
710
|
+
(obj) => obj.objectId === object?.objectId
|
|
655
711
|
);
|
|
656
712
|
if (suiObject instanceof SuiSharedObject) {
|
|
657
|
-
|
|
713
|
+
if (object.owner && typeof object.owner === "object" && "Shared" in object.owner) {
|
|
714
|
+
suiObject.initialSharedVersion = object.owner.Shared.initial_shared_version;
|
|
715
|
+
} else {
|
|
716
|
+
suiObject.initialSharedVersion = void 0;
|
|
717
|
+
}
|
|
658
718
|
} else if (suiObject instanceof SuiOwnedObject) {
|
|
659
|
-
suiObject.version = object
|
|
660
|
-
suiObject.digest = object
|
|
719
|
+
suiObject.version = object?.version;
|
|
720
|
+
suiObject.digest = object?.digest;
|
|
661
721
|
}
|
|
662
722
|
}
|
|
663
723
|
}
|
|
@@ -672,7 +732,7 @@ var SuiInteractor = class {
|
|
|
672
732
|
let totalAmount = 0;
|
|
673
733
|
let hasNext = true, nextCursor = null;
|
|
674
734
|
while (hasNext && totalAmount < amount) {
|
|
675
|
-
const coins = await this.
|
|
735
|
+
const coins = await this.currentClient.getCoins({
|
|
676
736
|
owner: addr,
|
|
677
737
|
coinType,
|
|
678
738
|
cursor: nextCursor
|
|
@@ -705,29 +765,6 @@ var SuiInteractor = class {
|
|
|
705
765
|
}
|
|
706
766
|
};
|
|
707
767
|
|
|
708
|
-
// src/libs/suiInteractor/defaultConfig.ts
|
|
709
|
-
import {
|
|
710
|
-
localnetConnection,
|
|
711
|
-
devnetConnection,
|
|
712
|
-
testnetConnection,
|
|
713
|
-
mainnetConnection
|
|
714
|
-
} from "@mysten/sui.js";
|
|
715
|
-
var defaultGasBudget = 10 ** 8;
|
|
716
|
-
var getDefaultConnection = (networkType = "devnet") => {
|
|
717
|
-
switch (networkType) {
|
|
718
|
-
case "localnet":
|
|
719
|
-
return localnetConnection;
|
|
720
|
-
case "devnet":
|
|
721
|
-
return devnetConnection;
|
|
722
|
-
case "testnet":
|
|
723
|
-
return testnetConnection;
|
|
724
|
-
case "mainnet":
|
|
725
|
-
return mainnetConnection;
|
|
726
|
-
default:
|
|
727
|
-
return devnetConnection;
|
|
728
|
-
}
|
|
729
|
-
};
|
|
730
|
-
|
|
731
768
|
// src/libs/suiContractFactory/index.ts
|
|
732
769
|
var SuiContractFactory = class {
|
|
733
770
|
// readonly #query: MapMessageQuery<ApiTypes> = {};
|
|
@@ -906,7 +943,7 @@ var Obelisk = class {
|
|
|
906
943
|
return await this.inspectTxn(tx);
|
|
907
944
|
});
|
|
908
945
|
this.accountManager = new SuiAccountManager({ mnemonics, secretKey });
|
|
909
|
-
fullnodeUrls = fullnodeUrls || [
|
|
946
|
+
fullnodeUrls = fullnodeUrls || [getFullnodeUrl(networkType ?? "mainnet")];
|
|
910
947
|
this.suiInteractor = new SuiInteractor(fullnodeUrls, networkType);
|
|
911
948
|
this.packageId = packageId;
|
|
912
949
|
if (metadata !== void 0) {
|
|
@@ -951,14 +988,13 @@ var Obelisk = class {
|
|
|
951
988
|
return __privateGet(this, _tx);
|
|
952
989
|
}
|
|
953
990
|
/**
|
|
954
|
-
* if derivePathParams is not provided or mnemonics is empty, it will return the
|
|
991
|
+
* if derivePathParams is not provided or mnemonics is empty, it will return the keypair.
|
|
955
992
|
* else:
|
|
956
993
|
* it will generate signer from the mnemonic with the given derivePathParams.
|
|
957
994
|
* @param derivePathParams, such as { accountIndex: 2, isExternal: false, addressIndex: 10 }, comply with the BIP44 standard
|
|
958
995
|
*/
|
|
959
|
-
|
|
960
|
-
|
|
961
|
-
return new RawSigner(keyPair, this.suiInteractor.currentProvider);
|
|
996
|
+
getKeypair(derivePathParams) {
|
|
997
|
+
return this.accountManager.getKeyPair(derivePathParams);
|
|
962
998
|
}
|
|
963
999
|
/**
|
|
964
1000
|
* @description Switch the current account with the given derivePathParams
|
|
@@ -977,9 +1013,6 @@ var Obelisk = class {
|
|
|
977
1013
|
currentAddress() {
|
|
978
1014
|
return this.accountManager.currentAddress;
|
|
979
1015
|
}
|
|
980
|
-
provider() {
|
|
981
|
-
return this.suiInteractor.currentProvider;
|
|
982
|
-
}
|
|
983
1016
|
getPackageId() {
|
|
984
1017
|
return this.contractFactory.packageId;
|
|
985
1018
|
}
|
|
@@ -995,7 +1028,10 @@ var Obelisk = class {
|
|
|
995
1028
|
}
|
|
996
1029
|
async getBalance(coinType, derivePathParams) {
|
|
997
1030
|
const owner = this.accountManager.getAddress(derivePathParams);
|
|
998
|
-
return this.suiInteractor.
|
|
1031
|
+
return this.suiInteractor.currentClient.getBalance({ owner, coinType });
|
|
1032
|
+
}
|
|
1033
|
+
client() {
|
|
1034
|
+
return this.suiInteractor.currentClient;
|
|
999
1035
|
}
|
|
1000
1036
|
async getObject(objectId) {
|
|
1001
1037
|
return this.suiInteractor.getObject(objectId);
|
|
@@ -1004,16 +1040,17 @@ var Obelisk = class {
|
|
|
1004
1040
|
return this.suiInteractor.getObjects(objectIds);
|
|
1005
1041
|
}
|
|
1006
1042
|
async signTxn(tx, derivePathParams) {
|
|
1007
|
-
|
|
1008
|
-
|
|
1009
|
-
|
|
1043
|
+
if (tx instanceof SuiTxBlock) {
|
|
1044
|
+
tx.setSender(this.getAddress(derivePathParams));
|
|
1045
|
+
}
|
|
1046
|
+
const txBlock = tx instanceof SuiTxBlock ? tx.txBlock : tx;
|
|
1047
|
+
const txBytes = txBlock instanceof TransactionBlock2 ? await txBlock.build({ client: this.client() }) : txBlock;
|
|
1048
|
+
const keyPair = this.getKeypair(derivePathParams);
|
|
1049
|
+
return await keyPair.signTransactionBlock(txBytes);
|
|
1010
1050
|
}
|
|
1011
1051
|
async signAndSendTxn(tx, derivePathParams) {
|
|
1012
|
-
const {
|
|
1013
|
-
|
|
1014
|
-
derivePathParams
|
|
1015
|
-
);
|
|
1016
|
-
return this.suiInteractor.sendTx(transactionBlockBytes, signature);
|
|
1052
|
+
const { bytes, signature } = await this.signTxn(tx, derivePathParams);
|
|
1053
|
+
return this.suiInteractor.sendTx(bytes, signature);
|
|
1017
1054
|
}
|
|
1018
1055
|
/**
|
|
1019
1056
|
* Transfer the given amount of SUI to the recipient
|
|
@@ -1115,9 +1152,9 @@ var Obelisk = class {
|
|
|
1115
1152
|
* @returns the effects and events of the transaction, such as object changes, gas cost, event emitted.
|
|
1116
1153
|
*/
|
|
1117
1154
|
async inspectTxn(tx, derivePathParams) {
|
|
1118
|
-
|
|
1119
|
-
return this.suiInteractor.
|
|
1120
|
-
transactionBlock:
|
|
1155
|
+
const txBlock = tx instanceof SuiTxBlock ? tx.txBlock : tx;
|
|
1156
|
+
return this.suiInteractor.currentClient.devInspectTransactionBlock({
|
|
1157
|
+
transactionBlock: txBlock,
|
|
1121
1158
|
sender: this.getAddress(derivePathParams)
|
|
1122
1159
|
});
|
|
1123
1160
|
}
|
|
@@ -1126,12 +1163,18 @@ var Obelisk = class {
|
|
|
1126
1163
|
}
|
|
1127
1164
|
async listSchemaNames(worldId) {
|
|
1128
1165
|
const worldObject = await this.getObject(worldId);
|
|
1129
|
-
const newObjectContent = worldObject.
|
|
1130
|
-
|
|
1166
|
+
const newObjectContent = worldObject.content;
|
|
1167
|
+
if (newObjectContent != null) {
|
|
1168
|
+
const objectContent = newObjectContent;
|
|
1169
|
+
const objectFields = objectContent.fields;
|
|
1170
|
+
return objectFields["schema_names"];
|
|
1171
|
+
} else {
|
|
1172
|
+
return [];
|
|
1173
|
+
}
|
|
1131
1174
|
}
|
|
1132
1175
|
async getEntity(worldId, schemaName, entityId) {
|
|
1133
1176
|
const schemaModuleName = `${schemaName}_schema`;
|
|
1134
|
-
const tx = new
|
|
1177
|
+
const tx = new TransactionBlock2();
|
|
1135
1178
|
const params = [tx.pure(worldId)];
|
|
1136
1179
|
if (entityId !== void 0) {
|
|
1137
1180
|
params.push(tx.pure(entityId));
|
|
@@ -1157,7 +1200,7 @@ var Obelisk = class {
|
|
|
1157
1200
|
}
|
|
1158
1201
|
async containEntity(worldId, schemaName, entityId) {
|
|
1159
1202
|
const schemaModuleName = `${schemaName}_schema`;
|
|
1160
|
-
const tx = new
|
|
1203
|
+
const tx = new TransactionBlock2();
|
|
1161
1204
|
const params = [tx.pure(worldId)];
|
|
1162
1205
|
if (entityId !== void 0) {
|
|
1163
1206
|
params.push(tx.pure(entityId));
|
|
@@ -1214,7 +1257,7 @@ var Obelisk = class {
|
|
|
1214
1257
|
const ownedObjectsRes = [];
|
|
1215
1258
|
for (const object of ownedObjects.data) {
|
|
1216
1259
|
const objectDetail = await this.getObject(object.data.objectId);
|
|
1217
|
-
if (objectDetail.
|
|
1260
|
+
if (objectDetail.type.split("::")[0] === this.contractFactory.packageId) {
|
|
1218
1261
|
ownedObjectsRes.push(objectDetail);
|
|
1219
1262
|
}
|
|
1220
1263
|
}
|
|
@@ -1274,9 +1317,51 @@ _tx = new WeakMap();
|
|
|
1274
1317
|
_exec = new WeakMap();
|
|
1275
1318
|
_read = new WeakMap();
|
|
1276
1319
|
|
|
1320
|
+
// src/libs/multiSig/client.ts
|
|
1321
|
+
import { MultiSigPublicKey } from "@mysten/sui.js/multisig";
|
|
1322
|
+
|
|
1323
|
+
// src/libs/multiSig/publickey.ts
|
|
1324
|
+
import { Ed25519PublicKey } from "@mysten/sui.js/keypairs/ed25519";
|
|
1325
|
+
import { fromB64 as fromB642 } from "@mysten/sui.js/utils";
|
|
1326
|
+
function ed25519PublicKeyFromBase64(rawPubkey) {
|
|
1327
|
+
let bytes = fromB642(rawPubkey);
|
|
1328
|
+
if (bytes.length !== 32 && bytes.length !== 33)
|
|
1329
|
+
throw "invalid pubkey length";
|
|
1330
|
+
bytes = bytes.length === 33 ? bytes.slice(1) : bytes;
|
|
1331
|
+
return new Ed25519PublicKey(bytes);
|
|
1332
|
+
}
|
|
1333
|
+
|
|
1334
|
+
// src/libs/multiSig/client.ts
|
|
1335
|
+
var MultiSigClient = class _MultiSigClient {
|
|
1336
|
+
constructor(pks, threshold) {
|
|
1337
|
+
this.pksWeightPairs = pks;
|
|
1338
|
+
this.threshold = threshold;
|
|
1339
|
+
this.multiSigPublicKey = MultiSigPublicKey.fromPublicKeys({
|
|
1340
|
+
threshold: this.threshold,
|
|
1341
|
+
publicKeys: this.pksWeightPairs
|
|
1342
|
+
});
|
|
1343
|
+
}
|
|
1344
|
+
static fromRawEd25519PublicKeys(rawPublicKeys, weights, threshold) {
|
|
1345
|
+
const pks = rawPublicKeys.map((rawPublicKey, i) => {
|
|
1346
|
+
return {
|
|
1347
|
+
publicKey: ed25519PublicKeyFromBase64(rawPublicKey),
|
|
1348
|
+
weight: weights[i]
|
|
1349
|
+
};
|
|
1350
|
+
});
|
|
1351
|
+
return new _MultiSigClient(pks, threshold);
|
|
1352
|
+
}
|
|
1353
|
+
multiSigAddress() {
|
|
1354
|
+
return this.multiSigPublicKey.toSuiAddress();
|
|
1355
|
+
}
|
|
1356
|
+
combinePartialSigs(sigs) {
|
|
1357
|
+
return this.multiSigPublicKey.combinePartialSignatures(sigs);
|
|
1358
|
+
}
|
|
1359
|
+
};
|
|
1360
|
+
|
|
1277
1361
|
// src/metadata/index.ts
|
|
1362
|
+
import { getFullnodeUrl as getFullnodeUrl2 } from "@mysten/sui.js/client";
|
|
1278
1363
|
async function loadMetadata(networkType, packageId) {
|
|
1279
|
-
const fullnodeUrls = [
|
|
1364
|
+
const fullnodeUrls = [getFullnodeUrl2(networkType)];
|
|
1280
1365
|
const suiInteractor = new SuiInteractor(fullnodeUrls);
|
|
1281
1366
|
if (packageId !== void 0) {
|
|
1282
1367
|
const jsonData = await suiInteractor.getNormalizedMoveModulesByPackage(
|
|
@@ -1290,6 +1375,7 @@ async function loadMetadata(networkType, packageId) {
|
|
|
1290
1375
|
export {
|
|
1291
1376
|
BCS2 as BCS,
|
|
1292
1377
|
Ed25519Keypair3 as Ed25519Keypair,
|
|
1378
|
+
MultiSigClient,
|
|
1293
1379
|
Obelisk,
|
|
1294
1380
|
SuiAccountManager,
|
|
1295
1381
|
SuiContractFactory,
|