@0xobelisk/sui-client 1.1.1 → 1.1.3
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/dubhe.d.ts +6 -1
- package/dist/index.js +42 -16
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +42 -16
- package/dist/index.mjs.map +1 -1
- package/dist/types/index.d.ts +3 -1
- package/package.json +1 -1
- package/src/dubhe.ts +65 -33
- package/src/types/index.ts +4 -0
package/dist/index.mjs
CHANGED
|
@@ -1451,9 +1451,11 @@ function createTx(meta, fn) {
|
|
|
1451
1451
|
tx,
|
|
1452
1452
|
params,
|
|
1453
1453
|
typeArguments,
|
|
1454
|
-
isRaw
|
|
1454
|
+
isRaw,
|
|
1455
|
+
onSuccess,
|
|
1456
|
+
onError
|
|
1455
1457
|
}) => {
|
|
1456
|
-
return await fn(tx, params, typeArguments, isRaw);
|
|
1458
|
+
return await fn(tx, params, typeArguments, isRaw, onSuccess, onError);
|
|
1457
1459
|
}
|
|
1458
1460
|
);
|
|
1459
1461
|
}
|
|
@@ -1574,7 +1576,7 @@ var Dubhe = class {
|
|
|
1574
1576
|
value: bcs2.u64()
|
|
1575
1577
|
})
|
|
1576
1578
|
});
|
|
1577
|
-
__privateAdd(this, _exec, async (meta, tx, params, typeArguments, isRaw) => {
|
|
1579
|
+
__privateAdd(this, _exec, async (meta, tx, params, typeArguments, isRaw, onSuccess, onError) => {
|
|
1578
1580
|
if (isRaw === true) {
|
|
1579
1581
|
return tx.moveCall({
|
|
1580
1582
|
target: `${this.contractFactory.packageId}::${meta.moduleName}::${meta.funcName}`,
|
|
@@ -1587,7 +1589,7 @@ var Dubhe = class {
|
|
|
1587
1589
|
arguments: params,
|
|
1588
1590
|
typeArguments
|
|
1589
1591
|
});
|
|
1590
|
-
return await this.signAndSendTxn(tx);
|
|
1592
|
+
return await this.signAndSendTxn({ tx, onSuccess, onError });
|
|
1591
1593
|
});
|
|
1592
1594
|
__privateAdd(this, _read, async (meta, tx, params, typeArguments, isRaw) => {
|
|
1593
1595
|
if (isRaw === true) {
|
|
@@ -1984,7 +1986,7 @@ var Dubhe = class {
|
|
|
1984
1986
|
(moudlevalue) => {
|
|
1985
1987
|
const data = moudlevalue;
|
|
1986
1988
|
const moduleName = data.name;
|
|
1987
|
-
const objMoudleId = `${packageId}::${moduleName}`;
|
|
1989
|
+
const objMoudleId = `${this.packageId}::${moduleName}`;
|
|
1988
1990
|
if (data.enums) {
|
|
1989
1991
|
Object.entries(data.enums).forEach(([enumName, enumType]) => {
|
|
1990
1992
|
const objectId = `${objMoudleId}::${enumName}`;
|
|
@@ -2046,7 +2048,7 @@ var Dubhe = class {
|
|
|
2046
2048
|
if (isUndefined(__privateGet(this, _tx)[moduleName][funcName])) {
|
|
2047
2049
|
__privateGet(this, _tx)[moduleName][funcName] = createTx(
|
|
2048
2050
|
meta,
|
|
2049
|
-
(tx, p, typeArguments, isRaw) => __privateGet(this, _exec).call(this, meta, tx, p, typeArguments, isRaw)
|
|
2051
|
+
(tx, p, typeArguments, isRaw, onSuccess, onError) => __privateGet(this, _exec).call(this, meta, tx, p, typeArguments, isRaw, onSuccess, onError)
|
|
2050
2052
|
);
|
|
2051
2053
|
}
|
|
2052
2054
|
}
|
|
@@ -2058,7 +2060,7 @@ var Dubhe = class {
|
|
|
2058
2060
|
}
|
|
2059
2061
|
}
|
|
2060
2062
|
this.contractFactory = new SuiContractFactory({
|
|
2061
|
-
packageId,
|
|
2063
|
+
packageId: this.packageId,
|
|
2062
2064
|
metadata
|
|
2063
2065
|
});
|
|
2064
2066
|
}
|
|
@@ -2431,9 +2433,33 @@ var Dubhe = class {
|
|
|
2431
2433
|
const keyPair = this.getSigner(derivePathParams);
|
|
2432
2434
|
return await keyPair.signTransaction(txBytes);
|
|
2433
2435
|
}
|
|
2434
|
-
async signAndSendTxn(
|
|
2435
|
-
|
|
2436
|
-
|
|
2436
|
+
async signAndSendTxn({
|
|
2437
|
+
tx,
|
|
2438
|
+
derivePathParams,
|
|
2439
|
+
onSuccess,
|
|
2440
|
+
onError
|
|
2441
|
+
}) {
|
|
2442
|
+
try {
|
|
2443
|
+
const { bytes, signature } = await this.signTxn(tx, derivePathParams);
|
|
2444
|
+
const result = await this.sendTx(bytes, signature);
|
|
2445
|
+
if (result.effects?.status.status === "success") {
|
|
2446
|
+
if (onSuccess) {
|
|
2447
|
+
await onSuccess(result);
|
|
2448
|
+
}
|
|
2449
|
+
} else {
|
|
2450
|
+
if (onError) {
|
|
2451
|
+
await onError(
|
|
2452
|
+
new Error(`Transaction failed: ${result.effects?.status.error}`)
|
|
2453
|
+
);
|
|
2454
|
+
}
|
|
2455
|
+
}
|
|
2456
|
+
return result;
|
|
2457
|
+
} catch (error) {
|
|
2458
|
+
if (onError) {
|
|
2459
|
+
await onError(error);
|
|
2460
|
+
}
|
|
2461
|
+
throw error;
|
|
2462
|
+
}
|
|
2437
2463
|
}
|
|
2438
2464
|
async sendTx(transaction, signature) {
|
|
2439
2465
|
return this.suiInteractor.sendTx(transaction, signature);
|
|
@@ -2450,7 +2476,7 @@ var Dubhe = class {
|
|
|
2450
2476
|
async transferSui(recipient, amount, derivePathParams) {
|
|
2451
2477
|
const tx = new SuiTx();
|
|
2452
2478
|
tx.transferSui(recipient, amount);
|
|
2453
|
-
return this.signAndSendTxn(tx, derivePathParams);
|
|
2479
|
+
return this.signAndSendTxn({ tx, derivePathParams });
|
|
2454
2480
|
}
|
|
2455
2481
|
/**
|
|
2456
2482
|
* Transfer to mutliple recipients
|
|
@@ -2461,7 +2487,7 @@ var Dubhe = class {
|
|
|
2461
2487
|
async transferSuiToMany(recipients, amounts, derivePathParams) {
|
|
2462
2488
|
const tx = new SuiTx();
|
|
2463
2489
|
tx.transferSuiToMany(recipients, amounts);
|
|
2464
|
-
return this.signAndSendTxn(tx, derivePathParams);
|
|
2490
|
+
return this.signAndSendTxn({ tx, derivePathParams });
|
|
2465
2491
|
}
|
|
2466
2492
|
/**
|
|
2467
2493
|
* Transfer the given amounts of coin to multiple recipients
|
|
@@ -2485,7 +2511,7 @@ var Dubhe = class {
|
|
|
2485
2511
|
recipients,
|
|
2486
2512
|
amounts
|
|
2487
2513
|
);
|
|
2488
|
-
return this.signAndSendTxn(tx, derivePathParams);
|
|
2514
|
+
return this.signAndSendTxn({ tx, derivePathParams });
|
|
2489
2515
|
}
|
|
2490
2516
|
async transferCoin(recipient, amount, coinType, derivePathParams) {
|
|
2491
2517
|
return this.transferCoinToMany(
|
|
@@ -2498,7 +2524,7 @@ var Dubhe = class {
|
|
|
2498
2524
|
async transferObjects(objects, recipient, derivePathParams) {
|
|
2499
2525
|
const tx = new SuiTx();
|
|
2500
2526
|
tx.transferObjects(objects, recipient);
|
|
2501
|
-
return this.signAndSendTxn(tx, derivePathParams);
|
|
2527
|
+
return this.signAndSendTxn({ tx, derivePathParams });
|
|
2502
2528
|
}
|
|
2503
2529
|
async moveCall(callParams) {
|
|
2504
2530
|
const {
|
|
@@ -2509,7 +2535,7 @@ var Dubhe = class {
|
|
|
2509
2535
|
} = callParams;
|
|
2510
2536
|
const tx = new SuiTx();
|
|
2511
2537
|
tx.moveCall(target, args, typeArguments);
|
|
2512
|
-
return this.signAndSendTxn(tx, derivePathParams);
|
|
2538
|
+
return this.signAndSendTxn({ tx, derivePathParams });
|
|
2513
2539
|
}
|
|
2514
2540
|
/**
|
|
2515
2541
|
* Select coins with the given amount and coin type, the total amount is greater than or equal to the given amount
|
|
@@ -2536,7 +2562,7 @@ var Dubhe = class {
|
|
|
2536
2562
|
async stakeSui(amount, validatorAddr, derivePathParams) {
|
|
2537
2563
|
const tx = new SuiTx();
|
|
2538
2564
|
tx.stakeSui(amount, validatorAddr);
|
|
2539
|
-
return this.signAndSendTxn(tx, derivePathParams);
|
|
2565
|
+
return this.signAndSendTxn({ tx, derivePathParams });
|
|
2540
2566
|
}
|
|
2541
2567
|
/**
|
|
2542
2568
|
* Execute the transaction with on-chain data but without really submitting. Useful for querying the effects of a transaction.
|