@mysten/sui 2.6.0 → 2.8.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.
Files changed (99) hide show
  1. package/CHANGELOG.md +22 -0
  2. package/dist/bcs/bcs.d.mts +6 -6
  3. package/dist/bcs/index.d.mts +20 -20
  4. package/dist/client/types.d.mts +17 -0
  5. package/dist/client/types.d.mts.map +1 -1
  6. package/dist/cryptography/signature.d.mts +14 -14
  7. package/dist/graphql/core.d.mts.map +1 -1
  8. package/dist/graphql/core.mjs +21 -8
  9. package/dist/graphql/core.mjs.map +1 -1
  10. package/dist/graphql/generated/queries.d.mts.map +1 -1
  11. package/dist/graphql/generated/queries.mjs +18 -3
  12. package/dist/graphql/generated/queries.mjs.map +1 -1
  13. package/dist/graphql/generated/tada-env.d.mts +703 -73
  14. package/dist/grpc/core.d.mts.map +1 -1
  15. package/dist/grpc/core.mjs +15 -2
  16. package/dist/grpc/core.mjs.map +1 -1
  17. package/dist/grpc/proto/sui/rpc/v2/move_package_service.client.d.mts +4 -4
  18. package/dist/grpc/proto/sui/rpc/v2/object.d.mts +38 -1
  19. package/dist/grpc/proto/sui/rpc/v2/object.d.mts.map +1 -1
  20. package/dist/grpc/proto/sui/rpc/v2/object.mjs +26 -1
  21. package/dist/grpc/proto/sui/rpc/v2/object.mjs.map +1 -1
  22. package/dist/grpc/proto/sui/rpc/v2/signature_verification_service.client.d.mts +4 -4
  23. package/dist/grpc/proto/sui/rpc/v2/state_service.client.d.mts +4 -4
  24. package/dist/grpc/proto/sui/rpc/v2/subscription_service.client.d.mts +4 -4
  25. package/dist/grpc/proto/sui/rpc/v2/transaction_execution_service.client.d.mts +4 -4
  26. package/dist/grpc/proto/sui/rpc/v2/transaction_execution_service.d.mts +8 -0
  27. package/dist/grpc/proto/sui/rpc/v2/transaction_execution_service.d.mts.map +1 -1
  28. package/dist/grpc/proto/sui/rpc/v2/transaction_execution_service.mjs +23 -12
  29. package/dist/grpc/proto/sui/rpc/v2/transaction_execution_service.mjs.map +1 -1
  30. package/dist/grpc/proto/types.d.mts +2 -2
  31. package/dist/grpc/proto/types.mjs +2 -1
  32. package/dist/jsonRpc/core.d.mts.map +1 -1
  33. package/dist/jsonRpc/core.mjs +10 -3
  34. package/dist/jsonRpc/core.mjs.map +1 -1
  35. package/dist/keypairs/passkey/keypair.d.mts +11 -4
  36. package/dist/keypairs/passkey/keypair.d.mts.map +1 -1
  37. package/dist/keypairs/passkey/keypair.mjs +19 -6
  38. package/dist/keypairs/passkey/keypair.mjs.map +1 -1
  39. package/dist/transactions/Transaction.d.mts +9 -9
  40. package/dist/transactions/Transaction.d.mts.map +1 -1
  41. package/dist/version.mjs +2 -2
  42. package/dist/version.mjs.map +1 -1
  43. package/dist/zklogin/bcs.d.mts +14 -14
  44. package/docs/bcs.md +131 -0
  45. package/docs/clients/core.md +601 -0
  46. package/docs/clients/graphql.md +99 -0
  47. package/docs/clients/grpc.md +152 -0
  48. package/docs/clients/index.md +93 -0
  49. package/docs/clients/json-rpc.md +235 -0
  50. package/docs/cryptography/keypairs.md +258 -0
  51. package/docs/cryptography/multisig.md +192 -0
  52. package/docs/cryptography/passkey.md +111 -0
  53. package/docs/cryptography/webcrypto-signer.md +81 -0
  54. package/docs/executors.md +147 -0
  55. package/docs/faucet.md +26 -0
  56. package/docs/hello-sui.md +114 -0
  57. package/docs/index.md +54 -0
  58. package/docs/install.md +61 -0
  59. package/docs/llm-docs.md +32 -0
  60. package/docs/llms-index.md +60 -0
  61. package/docs/migrations/0.38.md +57 -0
  62. package/docs/migrations/sui-1.0.md +453 -0
  63. package/docs/migrations/sui-2.0/agent-prompt.md +42 -0
  64. package/docs/migrations/sui-2.0/dapp-kit.md +350 -0
  65. package/docs/migrations/sui-2.0/deepbook-v3.md +33 -0
  66. package/docs/migrations/sui-2.0/index.md +157 -0
  67. package/docs/migrations/sui-2.0/json-rpc-migration.md +383 -0
  68. package/docs/migrations/sui-2.0/kiosk.md +120 -0
  69. package/docs/migrations/sui-2.0/sdk-maintainers.md +90 -0
  70. package/docs/migrations/sui-2.0/seal.md +14 -0
  71. package/docs/migrations/sui-2.0/sui.md +341 -0
  72. package/docs/migrations/sui-2.0/suins.md +42 -0
  73. package/docs/migrations/sui-2.0/wallet-builders.md +66 -0
  74. package/docs/migrations/sui-2.0/walrus.md +41 -0
  75. package/docs/migrations/sui-2.0/zksend.md +94 -0
  76. package/docs/plugins.md +255 -0
  77. package/docs/sdk-building.md +340 -0
  78. package/docs/transaction-building/basics.md +297 -0
  79. package/docs/transaction-building/gas.md +62 -0
  80. package/docs/transaction-building/intents.md +61 -0
  81. package/docs/transaction-building/offline.md +71 -0
  82. package/docs/transaction-building/sponsored-transactions.md +22 -0
  83. package/docs/utils/derived_objects.md +59 -0
  84. package/docs/utils/index.md +52 -0
  85. package/docs/zklogin.md +78 -0
  86. package/package.json +5 -3
  87. package/src/client/types.ts +16 -0
  88. package/src/graphql/core.ts +34 -13
  89. package/src/graphql/generated/queries.ts +252 -14
  90. package/src/graphql/generated/schema.graphql +324 -8
  91. package/src/graphql/generated/tada-env.ts +844 -99
  92. package/src/graphql/queries/objects.graphql +10 -0
  93. package/src/graphql/queries/verifyZkLoginSignature.graphql +0 -1
  94. package/src/grpc/core.ts +34 -0
  95. package/src/grpc/proto/sui/rpc/v2/object.ts +44 -0
  96. package/src/grpc/proto/sui/rpc/v2/transaction_execution_service.ts +16 -0
  97. package/src/jsonRpc/core.ts +9 -0
  98. package/src/keypairs/passkey/keypair.ts +20 -6
  99. package/src/version.ts +2 -2
@@ -0,0 +1,78 @@
1
+ # ZkLogin
2
+
3
+ > Zero-knowledge authentication with OAuth providers on Sui
4
+
5
+ Utilities for working with zkLogin. Currently contains functionality to create and parse zkLogin
6
+ signatures and compute zkLogin addresses.
7
+
8
+ To parse a serialized zkLogin signature
9
+
10
+ ```typescript
11
+ const parsedSignature = await parseZkLoginSignature('BQNNMTY4NjAxMzAyO....');
12
+ ```
13
+
14
+ Use `getZkLoginSignature` to serialize a zkLogin signature.
15
+
16
+ ```typescript
17
+ const serializedSignature = await getZkLoginSignature({ inputs, maxEpoch, userSignature });
18
+ ```
19
+
20
+ To compute the address for a given address seed and iss you can use `computeZkLoginAddressFromSeed`
21
+
22
+ ```typescript
23
+ const address = computeZkLoginAddressFromSeed(0n, 'https://accounts.google.com');
24
+ ```
25
+
26
+ To compute an address from jwt:
27
+
28
+ ```typescript
29
+ const address = jwtToAddress(jwtAsString, salt);
30
+ ```
31
+
32
+ To compute an address from a parsed jwt:
33
+
34
+ ```typescript
35
+ const address = computeZkLoginAddress({
36
+ claimName,
37
+ claimValue,
38
+ iss,
39
+ aud,
40
+ userSalt: BigInt(salt),
41
+ });
42
+ ```
43
+
44
+ To use zkLogin inside a multisig, see the [Multisig Guide](../sui/cryptography/multisig) for more
45
+ details.
46
+
47
+ ## Legacy addresses
48
+
49
+ When zklogin was first introduced, there was an inconsistency in how the address seed was computed.
50
+ For backwards compatibility reasons there are 2 valid addresses for a given set of inputs. Methods
51
+ that produce zklogin addresses all accept a `legacyAddress` boolean flag, either as their last
52
+ parameter, or in their options argument.
53
+
54
+ ```typescript
55
+
56
+ computeZkLoginAddress,
57
+ computeZkLoginAddressFromSeed,
58
+ jwtToAddress,
59
+ toZkLoginPublicIdentifier,
60
+ genAddressSeed,
61
+ } from '@mysten/sui/zklogin';
62
+
63
+ const address = jwtToAddress(jwtAsString, salt, true);
64
+ const address = computeZkLoginAddressFromSeed(0n, 'https://accounts.google.com', true);
65
+ const address = computeZkLoginAddress({
66
+ claimName,
67
+ claimValue,
68
+ iss,
69
+ aud,
70
+ userSalt: BigInt(salt),
71
+ legacyAddress: true,
72
+ });
73
+ const address = toZkLoginPublicIdentifier(
74
+ genAddressSeed(userSalt, claimName, claimValue, aud),
75
+ iss,
76
+ { legacyAddress: true },
77
+ ).toSuiAddress();
78
+ ```
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.6.0",
6
+ "version": "2.8.0",
7
7
  "license": "Apache-2.0",
8
8
  "sideEffects": false,
9
9
  "files": [
@@ -15,6 +15,7 @@
15
15
  "client",
16
16
  "cryptography",
17
17
  "dist",
18
+ "docs",
18
19
  "experimental",
19
20
  "faucet",
20
21
  "graphql",
@@ -168,8 +169,8 @@
168
169
  "graphql": "^16.12.0",
169
170
  "poseidon-lite": "0.2.1",
170
171
  "valibot": "^1.2.0",
171
- "@mysten/bcs": "^2.0.2",
172
- "@mysten/utils": "^0.3.1"
172
+ "@mysten/utils": "^0.3.1",
173
+ "@mysten/bcs": "^2.0.3"
173
174
  },
174
175
  "scripts": {
175
176
  "clean": "rm -rf tsconfig.tsbuildinfo ./dist",
@@ -182,6 +183,7 @@
182
183
  "codegen:grpc-header": "find src/grpc/proto -type f -exec sh -c 'echo \"// Copyright (c) Mysten Labs, Inc.\\n// SPDX-License-Identifier: Apache-2.0\\n\" | cat - {} > temp && mv temp {}' \\;",
183
184
  "codegen:grpc-extensions": "find src/grpc/proto -name '*.ts' | xargs sed -i '' -E 's/from \"(\\.[^\"]+)\"/from \"\\1.js\"/g'",
184
185
  "build": "rm -rf dist && node genversion.mjs && tsc --noEmit && tsdown",
186
+ "build:docs": "tsx ../docs/scripts/build-docs.ts",
185
187
  "vitest": "vitest",
186
188
  "test": "pnpm test:typecheck && pnpm test:unit",
187
189
  "test:typecheck": "tsc -p ./test",
@@ -85,6 +85,13 @@ export namespace SuiClientTypes {
85
85
  * use the `content` field and parse the BCS data directly.
86
86
  */
87
87
  json?: boolean;
88
+ /**
89
+ * Include the Display v2 rendered output for the object.
90
+ *
91
+ * Returns a map of display field names to their rendered string values.
92
+ * Returns `null` if the object's type does not have an associated Display template.
93
+ */
94
+ display?: boolean;
88
95
  }
89
96
 
90
97
  export interface GetObjectsOptions<
@@ -169,6 +176,15 @@ export namespace SuiClientTypes {
169
176
  * the `content` field and parse the BCS data directly.
170
177
  */
171
178
  json: Include extends { json: true } ? Record<string, unknown> | null : undefined;
179
+ /** Display rendered output. `null` if the type has no Display template. */
180
+ display: Include extends { display: true } ? Display | null : undefined;
181
+ }
182
+
183
+ export interface Display {
184
+ /** Successfully rendered display field values, keyed by field name. */
185
+ output: Record<string, string> | null;
186
+ /** Per-field rendering errors, keyed by field name. `null` if all fields succeeded. */
187
+ errors: Record<string, string> | null;
172
188
  }
173
189
 
174
190
  export interface Coin {
@@ -100,6 +100,7 @@ export class GraphQLCoreClient extends CoreClient {
100
100
  includePreviousTransaction: options.include?.previousTransaction ?? false,
101
101
  includeObjectBcs: options.include?.objectBcs ?? false,
102
102
  includeJson: options.include?.json ?? false,
103
+ includeDisplay: options.include?.display ?? false,
103
104
  },
104
105
  },
105
106
  (result) => result.multiGetObjects,
@@ -139,6 +140,11 @@ export class GraphQLCoreClient extends CoreClient {
139
140
  : null
140
141
  : undefined;
141
142
 
143
+ const displayData = mapDisplay(
144
+ options.include?.display,
145
+ obj.asMoveObject?.contents?.display,
146
+ );
147
+
142
148
  return {
143
149
  objectId: obj.address,
144
150
  version: obj.version?.toString()!,
@@ -150,6 +156,7 @@ export class GraphQLCoreClient extends CoreClient {
150
156
  undefined) as SuiClientTypes.Object<Include>['previousTransaction'],
151
157
  objectBcs: objectBcs as SuiClientTypes.Object<Include>['objectBcs'],
152
158
  json: jsonContent as SuiClientTypes.Object<Include>['json'],
159
+ display: displayData as SuiClientTypes.Object<Include>['display'],
153
160
  };
154
161
  }),
155
162
  );
@@ -176,6 +183,7 @@ export class GraphQLCoreClient extends CoreClient {
176
183
  includePreviousTransaction: options.include?.previousTransaction ?? false,
177
184
  includeObjectBcs: options.include?.objectBcs ?? false,
178
185
  includeJson: options.include?.json ?? false,
186
+ includeDisplay: options.include?.display ?? false,
179
187
  },
180
188
  },
181
189
  (result) => result.address?.objects,
@@ -202,6 +210,10 @@ export class GraphQLCoreClient extends CoreClient {
202
210
  ? (obj.contents.json as Record<string, unknown>)
203
211
  : null
204
212
  : undefined) as SuiClientTypes.Object<Include>['json'],
213
+ display: mapDisplay(
214
+ options.include?.display,
215
+ obj.contents?.display,
216
+ ) as SuiClientTypes.Object<Include>['display'],
205
217
  }),
206
218
  ),
207
219
  hasNextPage: objects.pageInfo.hasNextPage,
@@ -556,22 +568,19 @@ export class GraphQLCoreClient extends CoreClient {
556
568
  ? ZkLoginIntentScope.TransactionData
557
569
  : ZkLoginIntentScope.PersonalMessage;
558
570
 
559
- const result = await this.#graphqlQuery(
560
- {
561
- query: VerifyZkLoginSignatureDocument,
562
- variables: {
563
- bytes: options.bytes,
564
- signature: options.signature,
565
- intentScope,
566
- author: options.address,
567
- },
571
+ const { data } = await this.#graphqlClient.query({
572
+ query: VerifyZkLoginSignatureDocument,
573
+ variables: {
574
+ bytes: options.bytes,
575
+ signature: options.signature,
576
+ intentScope,
577
+ author: options.address,
568
578
  },
569
- (result) => result.verifyZkLoginSignature,
570
- );
579
+ });
571
580
 
572
581
  return {
573
- success: result.success ?? false,
574
- errors: result.error ? [result.error] : [],
582
+ success: data?.verifyZkLoginSignature?.success ?? false,
583
+ errors: [],
575
584
  };
576
585
  }
577
586
 
@@ -748,6 +757,18 @@ export type GraphQLResponseErrors = Array<{
748
757
  path?: (string | number)[];
749
758
  }>;
750
759
 
760
+ function mapDisplay(
761
+ include: boolean | undefined,
762
+ display: { output?: unknown | null; errors?: unknown | null } | null | undefined,
763
+ ): SuiClientTypes.Display | null | undefined {
764
+ if (!include) return undefined;
765
+ if (!display) return null;
766
+ return {
767
+ output: (display.output as Record<string, string> | null) ?? null,
768
+ errors: (display.errors as Record<string, string> | null) ?? null,
769
+ };
770
+ }
771
+
751
772
  function handleGraphQLErrors(errors: GraphQLResponseErrors | undefined): void {
752
773
  if (!errors || errors.length === 0) return;
753
774