@mysten/sui 2.2.0 → 2.3.1
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/CHANGELOG.md +20 -0
- package/dist/bcs/index.d.mts +20 -20
- package/dist/client/client.d.mts.map +1 -1
- package/dist/client/client.mjs +3 -2
- package/dist/client/client.mjs.map +1 -1
- package/dist/client/core-resolver.d.mts.map +1 -1
- package/dist/client/core-resolver.mjs +6 -2
- package/dist/client/core-resolver.mjs.map +1 -1
- package/dist/client/errors.d.mts +15 -0
- package/dist/client/errors.d.mts.map +1 -0
- package/dist/client/errors.mjs +7 -1
- package/dist/client/errors.mjs.map +1 -1
- package/dist/client/index.d.mts +2 -1
- package/dist/client/index.mjs +2 -1
- package/dist/client/utils.d.mts.map +1 -1
- package/dist/client/utils.mjs +20 -14
- package/dist/client/utils.mjs.map +1 -1
- package/dist/graphql/core.mjs +41 -16
- package/dist/graphql/core.mjs.map +1 -1
- package/dist/graphql/generated/queries.mjs +20 -0
- package/dist/graphql/generated/queries.mjs.map +1 -1
- package/dist/grpc/core.mjs +9 -6
- package/dist/grpc/core.mjs.map +1 -1
- package/dist/grpc/proto/sui/rpc/v2/move_package_service.client.d.mts +4 -4
- package/dist/grpc/proto/sui/rpc/v2/name_service.client.d.mts +4 -4
- package/dist/grpc/proto/sui/rpc/v2/signature_verification_service.client.d.mts +4 -4
- package/dist/grpc/proto/sui/rpc/v2/state_service.client.d.mts +4 -4
- package/dist/grpc/proto/sui/rpc/v2/subscription_service.client.d.mts +4 -4
- package/dist/grpc/proto/sui/rpc/v2/transaction.d.mts.map +1 -1
- package/dist/grpc/proto/sui/rpc/v2/transaction_execution_service.client.d.mts +4 -4
- package/dist/jsonRpc/core.mjs +1 -1
- package/dist/transactions/Transaction.d.mts +22 -10
- package/dist/transactions/Transaction.d.mts.map +1 -1
- package/dist/transactions/Transaction.mjs +18 -2
- package/dist/transactions/Transaction.mjs.map +1 -1
- package/dist/transactions/data/internal.d.mts +109 -109
- package/dist/transactions/data/internal.d.mts.map +1 -1
- package/dist/transactions/data/v1.d.mts +220 -220
- package/dist/transactions/data/v1.d.mts.map +1 -1
- package/dist/transactions/data/v2.d.mts +16 -16
- package/dist/transactions/data/v2.d.mts.map +1 -1
- package/dist/transactions/executor/serial.d.mts.map +1 -1
- package/dist/transactions/executor/serial.mjs +4 -0
- package/dist/transactions/executor/serial.mjs.map +1 -1
- package/dist/transactions/index.mjs +1 -1
- package/dist/transactions/intents/CoinWithBalance.d.mts +2 -0
- package/dist/transactions/intents/CoinWithBalance.d.mts.map +1 -1
- package/dist/transactions/intents/CoinWithBalance.mjs +1 -1
- package/dist/transactions/intents/CoinWithBalance.mjs.map +1 -1
- package/dist/version.mjs +1 -1
- package/dist/version.mjs.map +1 -1
- package/dist/zklogin/bcs.d.mts +14 -14
- package/package.json +3 -3
- package/src/client/client.ts +5 -2
- package/src/client/core-resolver.ts +7 -7
- package/src/client/errors.ts +13 -0
- package/src/client/index.ts +2 -0
- package/src/client/utils.ts +26 -19
- package/src/graphql/core.ts +47 -11
- package/src/graphql/generated/queries.ts +21 -1
- package/src/graphql/queries/transactions.graphql +20 -0
- package/src/grpc/core.ts +20 -4
- package/src/transactions/Transaction.ts +38 -6
- package/src/transactions/executor/serial.ts +4 -0
- package/src/transactions/intents/CoinWithBalance.ts +2 -2
- package/src/version.ts +1 -1
|
@@ -31,6 +31,7 @@ import { createPure } from './pure.js';
|
|
|
31
31
|
import { TransactionDataBuilder } from './TransactionData.js';
|
|
32
32
|
import { getIdFromCallArg } from './utils.js';
|
|
33
33
|
import { namedPackagesPlugin } from './plugins/NamedPackagesPlugin.js';
|
|
34
|
+
import { COIN_WITH_BALANCE, resolveCoinBalance } from './intents/CoinWithBalance.js';
|
|
34
35
|
import type { ClientWithCoreApi } from '../client/core.js';
|
|
35
36
|
|
|
36
37
|
export type TransactionObjectArgument =
|
|
@@ -189,6 +190,16 @@ export class Transaction {
|
|
|
189
190
|
newTransaction.#commandSection = newTransaction.#data.commands.slice();
|
|
190
191
|
newTransaction.#availableResults = new Set(newTransaction.#commandSection.map((_, i) => i));
|
|
191
192
|
|
|
193
|
+
if (!newTransaction.isPreparedForSerialization({ supportedIntents: [COIN_WITH_BALANCE] })) {
|
|
194
|
+
throw new Error(
|
|
195
|
+
'Transaction has unresolved intents or async thunks. Call `prepareForSerialization` before copying.',
|
|
196
|
+
);
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
if (newTransaction.#data.commands.some((cmd) => cmd.$Intent?.name === COIN_WITH_BALANCE)) {
|
|
200
|
+
newTransaction.addIntentResolver(COIN_WITH_BALANCE, resolveCoinBalance);
|
|
201
|
+
}
|
|
202
|
+
|
|
192
203
|
return newTransaction;
|
|
193
204
|
}
|
|
194
205
|
|
|
@@ -661,6 +672,31 @@ export class Transaction {
|
|
|
661
672
|
return signer.signTransaction(bytes);
|
|
662
673
|
}
|
|
663
674
|
|
|
675
|
+
/**
|
|
676
|
+
* Checks if the transaction is prepared for serialization to JSON.
|
|
677
|
+
* This means:
|
|
678
|
+
* - All async thunks have been fully resolved
|
|
679
|
+
* - All transaction intents have been resolved (unless in supportedIntents)
|
|
680
|
+
*
|
|
681
|
+
* Unlike `isFullyResolved()`, this does not require the sender, gas payment,
|
|
682
|
+
* budget, or object versions to be set.
|
|
683
|
+
*/
|
|
684
|
+
isPreparedForSerialization(options: { supportedIntents?: string[] } = {}) {
|
|
685
|
+
if (this.#pendingPromises.size > 0) {
|
|
686
|
+
return false;
|
|
687
|
+
}
|
|
688
|
+
|
|
689
|
+
if (
|
|
690
|
+
this.#data.commands.some(
|
|
691
|
+
(cmd) => cmd.$Intent && !options.supportedIntents?.includes(cmd.$Intent.name),
|
|
692
|
+
)
|
|
693
|
+
) {
|
|
694
|
+
return false;
|
|
695
|
+
}
|
|
696
|
+
|
|
697
|
+
return true;
|
|
698
|
+
}
|
|
699
|
+
|
|
664
700
|
/**
|
|
665
701
|
* Ensures that:
|
|
666
702
|
* - All objects have been fully resolved to a specific version
|
|
@@ -673,15 +709,11 @@ export class Transaction {
|
|
|
673
709
|
* When true, the transaction will always be built to the same bytes and digest (unless the transaction is mutated)
|
|
674
710
|
*/
|
|
675
711
|
isFullyResolved() {
|
|
676
|
-
if (!this
|
|
677
|
-
return false;
|
|
678
|
-
}
|
|
679
|
-
|
|
680
|
-
if (this.#pendingPromises.size > 0) {
|
|
712
|
+
if (!this.isPreparedForSerialization()) {
|
|
681
713
|
return false;
|
|
682
714
|
}
|
|
683
715
|
|
|
684
|
-
if (this.#data.
|
|
716
|
+
if (!this.#data.sender) {
|
|
685
717
|
return false;
|
|
686
718
|
}
|
|
687
719
|
|
|
@@ -79,6 +79,10 @@ export class SerialTransactionExecutor {
|
|
|
79
79
|
}
|
|
80
80
|
|
|
81
81
|
#buildTransaction = async (transaction: Transaction) => {
|
|
82
|
+
await transaction.prepareForSerialization({
|
|
83
|
+
client: this.#client,
|
|
84
|
+
supportedIntents: ['CoinWithBalance'],
|
|
85
|
+
});
|
|
82
86
|
const copy = Transaction.from(transaction);
|
|
83
87
|
|
|
84
88
|
if (this.#gasMode === 'addressBalance') {
|
|
@@ -14,7 +14,7 @@ import type { Transaction, TransactionResult } from '../Transaction.js';
|
|
|
14
14
|
import type { TransactionDataBuilder } from '../TransactionData.js';
|
|
15
15
|
import type { ClientWithCoreApi, SuiClientTypes } from '../../client/index.js';
|
|
16
16
|
|
|
17
|
-
const COIN_WITH_BALANCE = 'CoinWithBalance';
|
|
17
|
+
export const COIN_WITH_BALANCE = 'CoinWithBalance';
|
|
18
18
|
const SUI_TYPE = normalizeStructTag('0x2::sui::SUI');
|
|
19
19
|
|
|
20
20
|
export function coinWithBalance({
|
|
@@ -56,7 +56,7 @@ const CoinWithBalanceData = object({
|
|
|
56
56
|
balance: bigint(),
|
|
57
57
|
});
|
|
58
58
|
|
|
59
|
-
async function resolveCoinBalance(
|
|
59
|
+
export async function resolveCoinBalance(
|
|
60
60
|
transactionData: TransactionDataBuilder,
|
|
61
61
|
buildOptions: BuildTransactionOptions,
|
|
62
62
|
next: () => Promise<void>,
|
package/src/version.ts
CHANGED