@mysten/sui 2.20.0 → 2.20.2

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.
Files changed (47) hide show
  1. package/CHANGELOG.md +21 -0
  2. package/dist/bcs/bcs.d.mts +6 -6
  3. package/dist/bcs/index.d.mts +20 -20
  4. package/dist/graphql/core.d.mts.map +1 -1
  5. package/dist/graphql/core.mjs +5 -1
  6. package/dist/graphql/core.mjs.map +1 -1
  7. package/dist/grpc/core.d.mts.map +1 -1
  8. package/dist/grpc/core.mjs +1 -0
  9. package/dist/grpc/core.mjs.map +1 -1
  10. package/dist/grpc/proto/sui/rpc/v2/ledger_service.client.d.mts +4 -4
  11. package/dist/grpc/proto/sui/rpc/v2/move_package_service.client.d.mts +4 -4
  12. package/dist/grpc/proto/sui/rpc/v2/name_service.client.d.mts +4 -4
  13. package/dist/grpc/proto/sui/rpc/v2/signature_verification_service.client.d.mts +4 -4
  14. package/dist/grpc/proto/sui/rpc/v2/state_service.client.d.mts +4 -4
  15. package/dist/grpc/proto/sui/rpc/v2/subscription_service.client.d.mts +4 -4
  16. package/dist/grpc/proto/sui/rpc/v2/transaction_execution_service.client.d.mts +4 -4
  17. package/dist/transactions/Transaction.d.mts +9 -9
  18. package/dist/transactions/Transaction.d.mts.map +1 -1
  19. package/dist/transactions/data/v1.d.mts +220 -220
  20. package/dist/transactions/data/v1.d.mts.map +1 -1
  21. package/dist/transactions/data/v2.d.mts +16 -16
  22. package/dist/transactions/data/v2.d.mts.map +1 -1
  23. package/dist/transactions/intents/CoinWithBalance.d.mts.map +1 -1
  24. package/dist/transactions/intents/CoinWithBalance.mjs +7 -3
  25. package/dist/transactions/intents/CoinWithBalance.mjs.map +1 -1
  26. package/dist/version.mjs +1 -1
  27. package/dist/version.mjs.map +1 -1
  28. package/dist/zklogin/bcs.d.mts +14 -14
  29. package/dist/zklogin/bcs.d.mts.map +1 -1
  30. package/docs/cryptography/index.md +225 -0
  31. package/docs/cryptography/keypairs.md +36 -143
  32. package/docs/cryptography/signers/aws-kms.md +110 -0
  33. package/docs/cryptography/signers/gcp-kms.md +91 -0
  34. package/docs/cryptography/signers/index.md +78 -0
  35. package/docs/cryptography/signers/ledger.md +76 -0
  36. package/docs/cryptography/{multisig.md → signers/multisig.md} +2 -2
  37. package/docs/cryptography/{passkey.md → signers/passkey.md} +1 -1
  38. package/docs/cryptography/{webcrypto-signer.md → signers/webcrypto.md} +6 -6
  39. package/docs/index.md +4 -5
  40. package/docs/llms-index.md +9 -4
  41. package/docs/migrations/sui-2.0/index.md +14 -1
  42. package/docs/zklogin.md +2 -2
  43. package/package.json +1 -1
  44. package/src/graphql/core.ts +5 -1
  45. package/src/grpc/core.ts +1 -0
  46. package/src/transactions/intents/CoinWithBalance.ts +21 -6
  47. package/src/version.ts +1 -1
@@ -13,10 +13,15 @@
13
13
  - [Coins and Balances](./transactions/coins-and-balances.md): Work with coin objects and address balances in transactions
14
14
  - [Commands and Inputs Reference](./transactions/reference.md): Complete reference for transaction commands and input types
15
15
  - [Building Offline](./transactions/offline.md): Build transactions without a network connection
16
- - [Key pairs](./cryptography/keypairs.md): Create and manage Ed25519, Secp256k1, and Secp256r1 keypairs for Sui transaction signing.
17
- - [Multi-Signature Transactions](./cryptography/multisig.md): Create multi-signature transactions with multiple signers on Sui.
18
- - [Passkey](./cryptography/passkey.md): Use WebAuthn passkeys for Sui transaction signing.
19
- - [Web Crypto Signer](./cryptography/webcrypto-signer.md): Sign transactions using the Web Crypto API for secure browser-based key management.
16
+ - [Cryptography](./cryptography.md): Sign and verify Sui transactions and messages with keypairs and external signers
17
+ - [Key pairs](./cryptography/keypairs.md): Create Ed25519, Secp256k1, and Secp256r1 keypairs and derive them from mnemonics and secret keys
18
+ - [Signers](./cryptography/signers.md): Signer implementations beyond keypairs cloud KMS, Ledger, Web Crypto, passkeys, and multisig
19
+ - [AWS KMS Signer](./cryptography/signers/aws-kms.md): Sign Sui transactions with a key stored in AWS Key Management Service
20
+ - [GCP KMS Signer](./cryptography/signers/gcp-kms.md): Sign Sui transactions with a key stored in Google Cloud Key Management Service
21
+ - [Ledger Signer](./cryptography/signers/ledger.md): Sign Sui transactions with a Ledger hardware wallet
22
+ - [Web Crypto Signer](./cryptography/signers/webcrypto.md): Sign transactions using the Web Crypto API for secure browser-based key management
23
+ - [Passkey](./cryptography/signers/passkey.md): Use WebAuthn passkeys for Sui transaction signing.
24
+ - [Multi-Signature Transactions](./cryptography/signers/multisig.md): Create multi-signature transactions with multiple signers on Sui.
20
25
  - [The `@mysten/sui/utils` package](./utils.md): Utility functions for addresses, coins, and common operations in the Sui TypeScript SDK.
21
26
  - [Derived Objects](./utils/derived_objects.md): Compute derived object IDs from parent objects for deterministic offline derivation.
22
27
  - [BCS](./bcs.md): Binary Canonical Serialization for encoding Sui Move types.
@@ -155,4 +155,17 @@ For wallet builders and SDK maintainers building on the Sui ecosystem:
155
155
  - **[Wallet builders](/sui/migrations/sui-2.0/wallet-builders):** Guide for wallet implementations
156
156
  adapting to `reportTransactionEffects` removal and new core API response format
157
157
  - **[SDK maintainers](/sui/migrations/sui-2.0/sdk-maintainers):** Guide for SDK authors migrating to
158
- `ClientWithCoreApi` and the new transport-agnostic architecture
158
+ `ClientWithCoreApi` and the new transport-agnostic architecture
159
+
160
+ ## Non-existent objects
161
+
162
+ When migrating from the v1 SDK to the v2 SDK, review any code paths that read objects or dynamic
163
+ fields that may not exist.
164
+
165
+ In v1, methods such as `core.getObject` and `getDynamicField` return `null` when the requested
166
+ object or field does not exist. In v2, the same operations throw an exception instead. Applications
167
+ that previously relied on `null` checks should be updated to handle exceptions appropriately, either
168
+ through try/catch blocks or by validating object existence before attempting to read it.
169
+
170
+ This behavioral change may require updates to error handling logic to avoid unexpected runtime
171
+ failures after migration.
package/docs/zklogin.md CHANGED
@@ -46,8 +46,8 @@ const address = computeZkLoginAddress({
46
46
  });
47
47
  ```
48
48
 
49
- To use zkLogin inside a multisig, see the [Multisig Guide](../sui/cryptography/multisig) for more
50
- details.
49
+ To use zkLogin inside a multisig, see the [Multisig Guide](../sui/cryptography/signers/multisig) for
50
+ more details.
51
51
 
52
52
  ## Legacy addresses
53
53
 
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "author": "Mysten Labs <build@mystenlabs.com>",
4
4
  "description": "Sui TypeScript API",
5
5
  "homepage": "https://sdk.mystenlabs.com",
6
- "version": "2.20.0",
6
+ "version": "2.20.2",
7
7
  "license": "Apache-2.0",
8
8
  "sideEffects": false,
9
9
  "files": [
@@ -317,7 +317,11 @@ export class GraphQLCoreClient extends CoreClient {
317
317
  const balances = await this.#graphqlQuery(
318
318
  {
319
319
  query: GetAllBalancesDocument,
320
- variables: { owner: options.owner },
320
+ variables: {
321
+ owner: options.owner,
322
+ limit: options.limit,
323
+ cursor: options.cursor,
324
+ },
321
325
  },
322
326
  (result) => result.address?.balances,
323
327
  );
package/src/grpc/core.ts CHANGED
@@ -211,6 +211,7 @@ export class GrpcCoreClient extends CoreClient {
211
211
  owner: options.owner,
212
212
  objectType: `0x2::coin::Coin<${(await this.mvr.resolveType({ type: coinType })).type}>`,
213
213
  pageToken: options.cursor ? fromBase64(options.cursor) : undefined,
214
+ pageSize: options.limit,
214
215
  readMask: {
215
216
  paths,
216
217
  },
@@ -2,7 +2,19 @@
2
2
  // SPDX-License-Identifier: Apache-2.0
3
3
 
4
4
  import type { InferInput } from 'valibot';
5
- import { bigint, object, optional, parse, picklist, string } from 'valibot';
5
+ import {
6
+ bigint,
7
+ integer,
8
+ number,
9
+ object,
10
+ optional,
11
+ parse,
12
+ picklist,
13
+ pipe,
14
+ string,
15
+ transform,
16
+ union,
17
+ } from 'valibot';
6
18
 
7
19
  import { bcs } from '../../bcs/index.js';
8
20
  import { normalizeStructTag } from '../../utils/sui-types.js';
@@ -87,9 +99,15 @@ export function createBalance({
87
99
  };
88
100
  }
89
101
 
102
+ // `balance` is a bigint in memory, but serializing a transaction to JSON converts it to a
103
+ // string. When that JSON is deserialized with `Transaction.from`, the value stays a string
104
+ // (the intent `data` is opaque to the transaction schema), so coerce it back to a bigint here.
90
105
  const CoinWithBalanceData = object({
91
106
  type: string(),
92
- balance: bigint(),
107
+ balance: pipe(
108
+ union([bigint(), string(), pipe(number(), integer())]),
109
+ transform((value) => BigInt(value)),
110
+ ),
93
111
  outputKind: optional(picklist(['coin', 'balance'])),
94
112
  });
95
113
 
@@ -208,10 +226,7 @@ export async function resolveCoinBalance(
208
226
  continue;
209
227
  }
210
228
 
211
- const { type, balance } = transaction.$Intent.data as {
212
- type: string;
213
- balance: bigint;
214
- };
229
+ const { type, balance } = parse(CoinWithBalanceData, transaction.$Intent.data);
215
230
  const coinType = type === 'gas' ? SUI_TYPE : type;
216
231
  const totalRequired = totalByType.get(type)!;
217
232
  const addressBalance = addressBalanceByType.get(type) ?? 0n;
package/src/version.ts CHANGED
@@ -3,4 +3,4 @@
3
3
 
4
4
  // This file is generated by genversion.mjs. Do not edit it directly.
5
5
 
6
- export const PACKAGE_VERSION = '2.20.0';
6
+ export const PACKAGE_VERSION = '2.20.2';