@mysten/sui 2.11.0 → 2.12.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 +14 -0
- package/dist/bcs/index.d.mts +20 -20
- package/dist/client/types.d.mts +8 -0
- package/dist/client/types.d.mts.map +1 -1
- package/dist/cryptography/signature.d.mts +6 -6
- package/dist/graphql/core.d.mts.map +1 -1
- package/dist/graphql/core.mjs +2 -1
- package/dist/graphql/core.mjs.map +1 -1
- package/dist/grpc/core.d.mts.map +1 -1
- package/dist/grpc/core.mjs +3 -1
- package/dist/grpc/core.mjs.map +1 -1
- 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 +34 -21
- package/dist/jsonRpc/core.mjs.map +1 -1
- package/dist/transactions/Transaction.d.mts +9 -9
- package/dist/transactions/Transaction.d.mts.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/docs/clients/core.md +15 -0
- package/docs/migrations/sui-2.0/json-rpc-migration.md +17 -1
- package/docs/utils/derived_objects.md +21 -0
- package/package.json +3 -3
- package/src/client/types.ts +8 -0
- package/src/graphql/core.ts +1 -0
- package/src/grpc/core.ts +5 -0
- package/src/jsonRpc/core.ts +51 -30
- package/src/version.ts +1 -1
package/src/jsonRpc/core.ts
CHANGED
|
@@ -5,6 +5,8 @@ import { fromBase64, type InferBcsInput } from '@mysten/bcs';
|
|
|
5
5
|
|
|
6
6
|
import { bcs, TypeTagSerializer } from '../bcs/index.js';
|
|
7
7
|
import type {
|
|
8
|
+
DevInspectResults,
|
|
9
|
+
DryRunTransactionBlockResponse,
|
|
8
10
|
ExecutionStatus as JsonRpcExecutionStatus,
|
|
9
11
|
ObjectOwner,
|
|
10
12
|
SuiMoveAbilitySet,
|
|
@@ -334,7 +336,7 @@ export class JSONRpcCoreClient extends CoreClient {
|
|
|
334
336
|
options: SuiClientTypes.SimulateTransactionOptions<Include>,
|
|
335
337
|
): Promise<SuiClientTypes.SimulateTransactionResult<Include>> {
|
|
336
338
|
if (!(options.transaction instanceof Uint8Array)) {
|
|
337
|
-
await options.transaction.
|
|
339
|
+
await options.transaction.build({ client: this, onlyTransactionKind: true });
|
|
338
340
|
}
|
|
339
341
|
|
|
340
342
|
const tx = Transaction.from(options.transaction);
|
|
@@ -356,14 +358,44 @@ export class JSONRpcCoreClient extends CoreClient {
|
|
|
356
358
|
})
|
|
357
359
|
: (options.transaction as Uint8Array);
|
|
358
360
|
|
|
359
|
-
const
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
361
|
+
const sender = tx.getData().sender ?? normalizeSuiAddress('0x0');
|
|
362
|
+
const checksDisabled = options.checksEnabled === false;
|
|
363
|
+
|
|
364
|
+
let dryRunResult: DryRunTransactionBlockResponse | null = null;
|
|
365
|
+
try {
|
|
366
|
+
dryRunResult = await this.#jsonRpcClient.dryRunTransactionBlock({
|
|
367
|
+
transactionBlock: transactionBytes,
|
|
368
|
+
signal: options.signal,
|
|
369
|
+
});
|
|
370
|
+
} catch (e) {
|
|
371
|
+
if (!checksDisabled) {
|
|
372
|
+
throw e;
|
|
373
|
+
}
|
|
374
|
+
}
|
|
375
|
+
|
|
376
|
+
let devInspectResult: DevInspectResults | null = null;
|
|
377
|
+
if (options.include?.commandResults || checksDisabled) {
|
|
378
|
+
try {
|
|
379
|
+
devInspectResult = await this.#jsonRpcClient.devInspectTransactionBlock({
|
|
380
|
+
sender,
|
|
381
|
+
transactionBlock: tx,
|
|
382
|
+
signal: options.signal,
|
|
383
|
+
});
|
|
384
|
+
} catch {}
|
|
385
|
+
}
|
|
386
|
+
|
|
387
|
+
const dryRunFailed = !dryRunResult || dryRunResult.effects.status.status !== 'success';
|
|
388
|
+
const effectsSource =
|
|
389
|
+
checksDisabled && dryRunFailed && devInspectResult
|
|
390
|
+
? devInspectResult
|
|
391
|
+
: (dryRunResult ?? devInspectResult);
|
|
392
|
+
if (!effectsSource) {
|
|
393
|
+
throw new Error('simulateTransaction failed: no results from dryRun or devInspect');
|
|
394
|
+
}
|
|
363
395
|
|
|
364
396
|
const { effects, objectTypes } = parseTransactionEffectsJson({
|
|
365
|
-
effects:
|
|
366
|
-
objectChanges:
|
|
397
|
+
effects: effectsSource.effects,
|
|
398
|
+
objectChanges: dryRunResult?.objectChanges ?? [],
|
|
367
399
|
});
|
|
368
400
|
|
|
369
401
|
const transactionData: SuiClientTypes.Transaction<Include> = {
|
|
@@ -391,15 +423,15 @@ export class JSONRpcCoreClient extends CoreClient {
|
|
|
391
423
|
bcs: (options.include?.bcs
|
|
392
424
|
? transactionBytes
|
|
393
425
|
: undefined) as SuiClientTypes.Transaction<Include>['bcs'],
|
|
394
|
-
balanceChanges: (options.include?.balanceChanges
|
|
395
|
-
?
|
|
426
|
+
balanceChanges: (options.include?.balanceChanges && dryRunResult
|
|
427
|
+
? dryRunResult.balanceChanges.map((change) => ({
|
|
396
428
|
coinType: normalizeStructTag(change.coinType),
|
|
397
429
|
address: parseOwnerAddress(change.owner)!,
|
|
398
430
|
amount: change.amount,
|
|
399
431
|
}))
|
|
400
432
|
: undefined) as SuiClientTypes.Transaction<Include>['balanceChanges'],
|
|
401
433
|
events: (options.include?.events
|
|
402
|
-
? (
|
|
434
|
+
? (effectsSource.events?.map((event) => ({
|
|
403
435
|
packageId: event.packageId,
|
|
404
436
|
module: event.transactionModule,
|
|
405
437
|
sender: event.sender,
|
|
@@ -411,26 +443,15 @@ export class JSONRpcCoreClient extends CoreClient {
|
|
|
411
443
|
};
|
|
412
444
|
|
|
413
445
|
let commandResults: SuiClientTypes.CommandResult[] | undefined;
|
|
414
|
-
if (options.include?.commandResults) {
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
})
|
|
422
|
-
|
|
423
|
-
if (devInspectResult.results) {
|
|
424
|
-
commandResults = devInspectResult.results.map((result) => ({
|
|
425
|
-
returnValues: (result.returnValues ?? []).map(([bytes]) => ({
|
|
426
|
-
bcs: new Uint8Array(bytes),
|
|
427
|
-
})),
|
|
428
|
-
mutatedReferences: (result.mutableReferenceOutputs ?? []).map(([, bytes]) => ({
|
|
429
|
-
bcs: new Uint8Array(bytes),
|
|
430
|
-
})),
|
|
431
|
-
}));
|
|
432
|
-
}
|
|
433
|
-
} catch {}
|
|
446
|
+
if (options.include?.commandResults && devInspectResult?.results) {
|
|
447
|
+
commandResults = devInspectResult.results.map((result) => ({
|
|
448
|
+
returnValues: (result.returnValues ?? []).map(([bytes]) => ({
|
|
449
|
+
bcs: new Uint8Array(bytes),
|
|
450
|
+
})),
|
|
451
|
+
mutatedReferences: (result.mutableReferenceOutputs ?? []).map(([, bytes]) => ({
|
|
452
|
+
bcs: new Uint8Array(bytes),
|
|
453
|
+
})),
|
|
454
|
+
}));
|
|
434
455
|
}
|
|
435
456
|
|
|
436
457
|
return effects.status.success
|
package/src/version.ts
CHANGED