@mysten/sui 2.34.0 → 2.35.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/CHANGELOG.md +8 -0
- package/dist/client/core-resolver.mjs +1 -1
- package/dist/client/types.d.mts +18 -1
- package/dist/client/types.d.mts.map +1 -1
- package/dist/client/utils.d.mts.map +1 -1
- package/dist/client/utils.mjs +10 -1
- package/dist/client/utils.mjs.map +1 -1
- package/dist/cryptography/signature.d.mts +6 -6
- package/dist/graphql/client.d.mts +4 -3
- package/dist/graphql/client.d.mts.map +1 -1
- package/dist/graphql/client.mjs.map +1 -1
- package/dist/graphql/core.d.mts.map +1 -1
- package/dist/graphql/core.mjs +7 -4
- package/dist/graphql/core.mjs.map +1 -1
- package/dist/graphql/generated/queries.mjs +7 -0
- package/dist/graphql/generated/queries.mjs.map +1 -1
- package/dist/grpc/client.d.mts +4 -3
- package/dist/grpc/client.d.mts.map +1 -1
- package/dist/grpc/client.mjs.map +1 -1
- package/dist/grpc/core.d.mts.map +1 -1
- package/dist/grpc/core.mjs +8 -4
- package/dist/grpc/core.mjs.map +1 -1
- package/dist/grpc/proto/sui/forking/v1alpha/forking_service.client.d.mts +4 -4
- package/dist/grpc/proto/sui/rpc/v2/ledger_service.client.d.mts +4 -4
- package/dist/grpc/proto/sui/rpc/v2/move_package_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_execution_service.client.d.mts +4 -4
- package/dist/jsonRpc/core.d.mts.map +1 -1
- package/dist/jsonRpc/core.mjs +7 -4
- package/dist/jsonRpc/core.mjs.map +1 -1
- package/dist/transactions/Transaction.d.mts +10 -8
- package/dist/transactions/Transaction.d.mts.map +1 -1
- package/dist/transactions/Transaction.mjs +4 -2
- package/dist/transactions/Transaction.mjs.map +1 -1
- package/dist/utils/constants.d.mts +6 -1
- package/dist/utils/constants.d.mts.map +1 -1
- package/dist/utils/constants.mjs +6 -1
- package/dist/utils/constants.mjs.map +1 -1
- package/dist/utils/index.d.mts +2 -2
- package/dist/utils/index.mjs +2 -2
- package/dist/version.mjs +1 -1
- package/dist/version.mjs.map +1 -1
- package/dist/zklogin/bcs.d.mts +14 -14
- package/docs/clients/executing.md +7 -1
- package/package.json +1 -1
- package/src/client/types.ts +18 -1
- package/src/client/utils.ts +10 -0
- package/src/graphql/client.ts +4 -3
- package/src/graphql/core.ts +9 -3
- package/src/graphql/generated/queries.ts +8 -1
- package/src/graphql/queries/transactions.graphql +7 -0
- package/src/grpc/client.ts +4 -3
- package/src/grpc/core.ts +11 -4
- package/src/jsonRpc/core.ts +5 -0
- package/src/transactions/Transaction.ts +4 -2
- package/src/utils/constants.ts +6 -0
- package/src/utils/index.ts +1 -0
- package/src/version.ts +1 -1
package/src/graphql/core.ts
CHANGED
|
@@ -43,6 +43,7 @@ import { chunk, fromBase64, toBase64 } from '@mysten/utils';
|
|
|
43
43
|
import { normalizeStructTag, normalizeSuiAddress } from '../utils/sui-types.js';
|
|
44
44
|
import {
|
|
45
45
|
formatMoveAbortMessage,
|
|
46
|
+
isMockedGasObjectId,
|
|
46
47
|
parseTransactionEffectsBcs,
|
|
47
48
|
transactionBytesHaveEmptyGasPayment,
|
|
48
49
|
} from '../client/utils.js';
|
|
@@ -422,9 +423,9 @@ export class GraphQLCoreClient extends CoreClient {
|
|
|
422
423
|
await options.transaction.prepareForSerialization({ client: this });
|
|
423
424
|
}
|
|
424
425
|
|
|
425
|
-
// A gas payment explicitly set to an empty list means
|
|
426
|
-
//
|
|
427
|
-
//
|
|
426
|
+
// A gas payment explicitly set to an empty list means the server should select real gas
|
|
427
|
+
// (from the sender's address balance or coin objects) rather than simulating with a
|
|
428
|
+
// mocked gas coin.
|
|
428
429
|
const doGasSelection =
|
|
429
430
|
options.doGasSelection ??
|
|
430
431
|
(options.transaction instanceof Uint8Array
|
|
@@ -459,6 +460,9 @@ export class GraphQLCoreClient extends CoreClient {
|
|
|
459
460
|
);
|
|
460
461
|
|
|
461
462
|
const transactionResult = parseTransaction(result.effects?.transaction!, options.include);
|
|
463
|
+
const gasPaymentMocked = isMockedGasObjectId(
|
|
464
|
+
result.effects?.transaction?.effects?.gasEffects?.gasObject?.address,
|
|
465
|
+
);
|
|
462
466
|
|
|
463
467
|
const commandResults =
|
|
464
468
|
options.include?.commandResults && result.outputs
|
|
@@ -478,6 +482,7 @@ export class GraphQLCoreClient extends CoreClient {
|
|
|
478
482
|
Transaction: transactionResult.Transaction,
|
|
479
483
|
commandResults:
|
|
480
484
|
commandResults as SuiClientTypes.SimulateTransactionResult<Include>['commandResults'],
|
|
485
|
+
gasPaymentMocked,
|
|
481
486
|
};
|
|
482
487
|
} else {
|
|
483
488
|
return {
|
|
@@ -485,6 +490,7 @@ export class GraphQLCoreClient extends CoreClient {
|
|
|
485
490
|
FailedTransaction: transactionResult.FailedTransaction,
|
|
486
491
|
commandResults:
|
|
487
492
|
commandResults as SuiClientTypes.SimulateTransactionResult<Include>['commandResults'],
|
|
493
|
+
gasPaymentMocked,
|
|
488
494
|
};
|
|
489
495
|
}
|
|
490
496
|
}
|
|
@@ -380,7 +380,7 @@ export type SimulateTransactionQueryVariables = Exact<{
|
|
|
380
380
|
}>;
|
|
381
381
|
|
|
382
382
|
|
|
383
|
-
export type SimulateTransactionQuery = { simulateTransaction: { effects: { transaction: { digest: string, transactionJson?: unknown, transactionBcs?: string | null,
|
|
383
|
+
export type SimulateTransactionQuery = { simulateTransaction: { effects: { transaction: { digest: string, transactionJson?: unknown, transactionBcs?: string | null, effects: { status: ExecutionStatus | null, timestamp: string | null, effectsBcs?: string | null, effectsJson?: unknown, balanceChangesJson?: unknown, gasEffects: { gasObject: { address: string } | null } | null, checkpoint: { sequenceNumber: number } | null, executionError: { message: string, abortCode: string | null, identifier: string | null, constant: string | null, sourceLineNumber: number | null, instructionOffset: number | null, module: { name: string, package: { address: string } | null } | null, function: { name: string } | null } | null, epoch: { epochId: number } | null, objectChanges?: { nodes: Array<{ address: string, outputState: { asMoveObject: { contents: { type: { repr: string } | null } | null } | null } | null }> } | null, events?: { pageInfo: { hasNextPage: boolean }, nodes: Array<{ transactionModule: { name: string, package: { address: string } | null } | null, sender: { address: string } | null, contents: { bcs: string | null, json: unknown, type: { repr: string } | null } | null }> } | null } | null, signatures: Array<{ signatureBytes: string | null }> } | null } | null, outputs?: Array<{ returnValues: Array<{ value: { bcs: string | null } | null }> | null, mutatedReferences: Array<{ value: { bcs: string | null } | null }> | null }> | null } };
|
|
384
384
|
|
|
385
385
|
export type ExecuteTransactionMutationVariables = Exact<{
|
|
386
386
|
transactionDataBcs: string;
|
|
@@ -1047,6 +1047,13 @@ export const SimulateTransactionDocument = new TypedDocumentString(`
|
|
|
1047
1047
|
effects {
|
|
1048
1048
|
transaction {
|
|
1049
1049
|
...TRANSACTION_FIELDS
|
|
1050
|
+
effects {
|
|
1051
|
+
gasEffects {
|
|
1052
|
+
gasObject {
|
|
1053
|
+
address
|
|
1054
|
+
}
|
|
1055
|
+
}
|
|
1056
|
+
}
|
|
1050
1057
|
}
|
|
1051
1058
|
}
|
|
1052
1059
|
outputs @include(if: $includeCommandResults) {
|
package/src/grpc/client.ts
CHANGED
|
@@ -130,9 +130,10 @@ export interface GrpcSimulateTransactionOptions<
|
|
|
130
130
|
* Overrides whether the server selects gas payment during simulation.
|
|
131
131
|
*
|
|
132
132
|
* When not set, gas selection is enabled only when the transaction's gas payment is explicitly
|
|
133
|
-
* set to an empty list (`[]`)
|
|
134
|
-
* Transactions with gas coins set are simulated as-is, and transactions without a
|
|
135
|
-
* are simulated with a mocked gas coin
|
|
133
|
+
* set to an empty list (`[]`); the server then pays gas from the sender's address balance or
|
|
134
|
+
* coin objects. Transactions with gas coins set are simulated as-is, and transactions without a
|
|
135
|
+
* gas payment are simulated with a mocked gas coin (reported as `gasPaymentMocked` on the
|
|
136
|
+
* result).
|
|
136
137
|
*/
|
|
137
138
|
doGasSelection?: boolean;
|
|
138
139
|
}
|
package/src/grpc/core.ts
CHANGED
|
@@ -50,7 +50,7 @@ import {
|
|
|
50
50
|
grpcTransactionToTransactionData,
|
|
51
51
|
} from '../client/transaction-resolver.js';
|
|
52
52
|
import { setAddressBalanceTransactionExpirationFromSimulatedEpoch } from '../client/address-balance-transaction-expiration.js';
|
|
53
|
-
import { transactionBytesHaveEmptyGasPayment } from '../client/utils.js';
|
|
53
|
+
import { isMockedGasObjectId, transactionBytesHaveEmptyGasPayment } from '../client/utils.js';
|
|
54
54
|
import { Value } from './proto/google/protobuf/struct.js';
|
|
55
55
|
import { ExecutedTransaction } from './proto/sui/rpc/v2/executed_transaction.js';
|
|
56
56
|
import {
|
|
@@ -457,14 +457,18 @@ export class GrpcCoreClient extends CoreClient {
|
|
|
457
457
|
if (options.include?.commandResults) {
|
|
458
458
|
paths.push('command_outputs');
|
|
459
459
|
}
|
|
460
|
+
if (!options.include?.effects) {
|
|
461
|
+
// The gas object ID is always needed to report whether a mocked gas coin was used
|
|
462
|
+
paths.push('transaction.effects.gas_object.object_id');
|
|
463
|
+
}
|
|
460
464
|
|
|
461
465
|
if (!(options.transaction instanceof Uint8Array)) {
|
|
462
466
|
await options.transaction.prepareForSerialization({ client: this });
|
|
463
467
|
}
|
|
464
468
|
|
|
465
|
-
// A gas payment explicitly set to an empty list means
|
|
466
|
-
//
|
|
467
|
-
//
|
|
469
|
+
// A gas payment explicitly set to an empty list means the server should select real gas
|
|
470
|
+
// (from the sender's address balance or coin objects) rather than simulating with a
|
|
471
|
+
// mocked gas coin.
|
|
468
472
|
const doGasSelection =
|
|
469
473
|
options.doGasSelection ??
|
|
470
474
|
(options.transaction instanceof Uint8Array
|
|
@@ -1621,6 +1625,7 @@ export function parseGrpcSimulateTransactionResponse<
|
|
|
1621
1625
|
): SuiClientTypes.SimulateTransactionResult<Include> {
|
|
1622
1626
|
const include = options?.include;
|
|
1623
1627
|
const transactionResult = parseGrpcTransactionResponse(response.transaction!, { include });
|
|
1628
|
+
const gasPaymentMocked = isMockedGasObjectId(response.transaction?.effects?.gasObject?.objectId);
|
|
1624
1629
|
|
|
1625
1630
|
const commandResults =
|
|
1626
1631
|
include?.commandResults && response.commandOutputs
|
|
@@ -1640,6 +1645,7 @@ export function parseGrpcSimulateTransactionResponse<
|
|
|
1640
1645
|
Transaction: transactionResult.Transaction,
|
|
1641
1646
|
commandResults:
|
|
1642
1647
|
commandResults as SuiClientTypes.SimulateTransactionResult<Include>['commandResults'],
|
|
1648
|
+
gasPaymentMocked,
|
|
1643
1649
|
};
|
|
1644
1650
|
}
|
|
1645
1651
|
|
|
@@ -1648,6 +1654,7 @@ export function parseGrpcSimulateTransactionResponse<
|
|
|
1648
1654
|
FailedTransaction: transactionResult.FailedTransaction,
|
|
1649
1655
|
commandResults:
|
|
1650
1656
|
commandResults as SuiClientTypes.SimulateTransactionResult<Include>['commandResults'],
|
|
1657
|
+
gasPaymentMocked,
|
|
1651
1658
|
};
|
|
1652
1659
|
}
|
|
1653
1660
|
|
package/src/jsonRpc/core.ts
CHANGED
|
@@ -43,6 +43,7 @@ import {
|
|
|
43
43
|
parseTransactionBcs,
|
|
44
44
|
parseTransactionEffectsBcs,
|
|
45
45
|
} from '../client/index.js';
|
|
46
|
+
import { isMockedGasObjectId } from '../client/utils.js';
|
|
46
47
|
import type { SuiJsonRpcClient } from './client.js';
|
|
47
48
|
import { JsonRpcError } from './errors.js';
|
|
48
49
|
|
|
@@ -576,18 +577,22 @@ export class JSONRpcCoreClient extends CoreClient {
|
|
|
576
577
|
}));
|
|
577
578
|
}
|
|
578
579
|
|
|
580
|
+
const gasPaymentMocked = isMockedGasObjectId(effects.gasObject?.objectId);
|
|
581
|
+
|
|
579
582
|
return effects.status.success
|
|
580
583
|
? {
|
|
581
584
|
$kind: 'Transaction',
|
|
582
585
|
Transaction: transactionData,
|
|
583
586
|
commandResults:
|
|
584
587
|
commandResults as SuiClientTypes.SimulateTransactionResult<Include>['commandResults'],
|
|
588
|
+
gasPaymentMocked,
|
|
585
589
|
}
|
|
586
590
|
: {
|
|
587
591
|
$kind: 'FailedTransaction',
|
|
588
592
|
FailedTransaction: transactionData,
|
|
589
593
|
commandResults:
|
|
590
594
|
commandResults as SuiClientTypes.SimulateTransactionResult<Include>['commandResults'],
|
|
595
|
+
gasPaymentMocked,
|
|
591
596
|
};
|
|
592
597
|
}
|
|
593
598
|
/**
|
|
@@ -355,7 +355,8 @@ export class Transaction {
|
|
|
355
355
|
|
|
356
356
|
/**
|
|
357
357
|
* Creates a Coin<T> of the specified type and amount (defaults to SUI).
|
|
358
|
-
* Sourced from address balance when available, falling back to owned coins.
|
|
358
|
+
* Sourced from address balance when available, falling back to owned coins. For SUI, falls back
|
|
359
|
+
* to the gas coin instead unless `useGasCoin` is `false`.
|
|
359
360
|
* With `allowance`, spends only from the funder's address balance under that allowance.
|
|
360
361
|
* Allowance IDs are resolved using the build client; app-bound allowances also require an app type and SpendPermit.
|
|
361
362
|
*/
|
|
@@ -370,7 +371,8 @@ export class Transaction {
|
|
|
370
371
|
|
|
371
372
|
/**
|
|
372
373
|
* Creates a Balance<T> of the specified type and amount (defaults to SUI).
|
|
373
|
-
* Sourced from address balance when available, falling back to owned coins.
|
|
374
|
+
* Sourced from address balance when available, falling back to owned coins. For SUI, falls back
|
|
375
|
+
* to the gas coin instead unless `useGasCoin` is `false`.
|
|
374
376
|
* With `allowance`, spends only from the funder's address balance under that allowance.
|
|
375
377
|
* Allowance IDs are resolved using the build client; app-bound allowances also require an app type and SpendPermit.
|
|
376
378
|
*/
|
package/src/utils/constants.ts
CHANGED
|
@@ -22,3 +22,9 @@ export const SUI_COIN_REGISTRY_OBJECT_ID =
|
|
|
22
22
|
'0x000000000000000000000000000000000000000000000000000000000000000c';
|
|
23
23
|
export const SUI_DENY_LIST_OBJECT_ID =
|
|
24
24
|
'0x0000000000000000000000000000000000000000000000000000000000000403';
|
|
25
|
+
/**
|
|
26
|
+
* Object ID of the gas coin the node substitutes when a transaction is simulated without a gas
|
|
27
|
+
* payment. See `gasPaymentMocked` on `SimulateTransactionResult`.
|
|
28
|
+
*/
|
|
29
|
+
export const MOCKED_GAS_OBJECT_ID =
|
|
30
|
+
'0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff';
|
package/src/utils/index.ts
CHANGED
package/src/version.ts
CHANGED