@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
@@ -10,6 +10,7 @@ query getOwnedObjects(
10
10
  $includePreviousTransaction: Boolean = false
11
11
  $includeObjectBcs: Boolean = false
12
12
  $includeJson: Boolean = false
13
+ $includeDisplay: Boolean = false
13
14
  ) {
14
15
  address(address: $owner) {
15
16
  objects(first: $limit, after: $cursor, filter: $filter) {
@@ -30,6 +31,7 @@ query multiGetObjects(
30
31
  $includePreviousTransaction: Boolean = false
31
32
  $includeObjectBcs: Boolean = false
32
33
  $includeJson: Boolean = false
34
+ $includeDisplay: Boolean = false
33
35
  ) {
34
36
  multiGetObjects(keys: $objectKeys) {
35
37
  ...OBJECT_FIELDS
@@ -45,6 +47,10 @@ fragment OBJECT_FIELDS on Object {
45
47
  contents {
46
48
  bcs @include(if: $includeContent)
47
49
  json @include(if: $includeJson)
50
+ display @include(if: $includeDisplay) {
51
+ output
52
+ errors
53
+ }
48
54
  type {
49
55
  repr
50
56
  }
@@ -69,6 +75,10 @@ fragment MOVE_OBJECT_FIELDS on MoveObject {
69
75
  contents {
70
76
  bcs @include(if: $includeContent)
71
77
  json @include(if: $includeJson)
78
+ display @include(if: $includeDisplay) {
79
+ output
80
+ errors
81
+ }
72
82
  type {
73
83
  repr
74
84
  }
@@ -11,6 +11,5 @@ query verifyZkLoginSignature(
11
11
  author: $author
12
12
  ) {
13
13
  success
14
- error
15
14
  }
16
15
  }
package/src/grpc/core.ts CHANGED
@@ -74,6 +74,9 @@ export class GrpcCoreClient extends CoreClient {
74
74
  if (options.include?.json) {
75
75
  paths.push('json');
76
76
  }
77
+ if (options.include?.display) {
78
+ paths.push('display');
79
+ }
77
80
 
78
81
  for (const batch of batches) {
79
82
  const response = await this.#client.ledgerService.batchGetObjects({
@@ -110,6 +113,11 @@ export class GrpcCoreClient extends CoreClient {
110
113
  : null
111
114
  : undefined;
112
115
 
116
+ const displayData = mapDisplayProto(
117
+ options.include?.display,
118
+ object.result.object.display,
119
+ );
120
+
113
121
  return {
114
122
  objectId: object.result.object.objectId!,
115
123
  version: object.result.object.version?.toString()!,
@@ -121,6 +129,7 @@ export class GrpcCoreClient extends CoreClient {
121
129
  undefined) as SuiClientTypes.Object<Include>['previousTransaction'],
122
130
  objectBcs: objectBcs as SuiClientTypes.Object<Include>['objectBcs'],
123
131
  json: jsonContent as SuiClientTypes.Object<Include>['json'],
132
+ display: displayData as SuiClientTypes.Object<Include>['display'],
124
133
  };
125
134
  }),
126
135
  );
@@ -146,6 +155,9 @@ export class GrpcCoreClient extends CoreClient {
146
155
  if (options.include?.json) {
147
156
  paths.push('json');
148
157
  }
158
+ if (options.include?.display) {
159
+ paths.push('display');
160
+ }
149
161
 
150
162
  const response = await this.#client.stateService.listOwnedObjects({
151
163
  owner: options.owner,
@@ -175,6 +187,10 @@ export class GrpcCoreClient extends CoreClient {
175
187
  ? (Value.toJson(object.json) as Record<string, unknown>)
176
188
  : null
177
189
  : undefined) as SuiClientTypes.Object<Include>['json'],
190
+ display: mapDisplayProto(
191
+ options.include?.display,
192
+ object.display,
193
+ ) as SuiClientTypes.Object<Include>['display'],
178
194
  }),
179
195
  );
180
196
 
@@ -752,6 +768,24 @@ export class GrpcCoreClient extends CoreClient {
752
768
  }
753
769
  }
754
770
 
771
+ function mapDisplayProto(
772
+ include: boolean | undefined,
773
+ display: { output?: Value; errors?: Value } | undefined,
774
+ ): SuiClientTypes.Display | null | undefined {
775
+ if (!include) return undefined;
776
+ if (display === undefined) return null;
777
+ return {
778
+ output:
779
+ display.output !== undefined
780
+ ? (Value.toJson(display.output) as Record<string, string> | null)
781
+ : null,
782
+ errors:
783
+ display.errors !== undefined
784
+ ? (Value.toJson(display.errors) as Record<string, string> | null)
785
+ : null,
786
+ };
787
+ }
788
+
755
789
  function mapOwner(owner: Owner | null | undefined): SuiClientTypes.ObjectOwner | null {
756
790
  if (!owner) {
757
791
  return null;
@@ -107,6 +107,13 @@ export interface Object {
107
107
  * @generated from protobuf field: optional uint64 balance = 101;
108
108
  */
109
109
  balance?: bigint;
110
+ /**
111
+ * JSON rendering of the object based on an on-chain template.
112
+ * This will not be set if the value's type does not have an associated `Display` template.
113
+ *
114
+ * @generated from protobuf field: optional sui.rpc.v2.Display display = 102;
115
+ */
116
+ display?: Display;
110
117
  }
111
118
  /**
112
119
  * Set of Objects
@@ -121,6 +128,29 @@ export interface ObjectSet {
121
128
  */
122
129
  objects: Object[];
123
130
  }
131
+ /**
132
+ * A rendered JSON blob based on an on-chain template.
133
+ *
134
+ * @generated from protobuf message sui.rpc.v2.Display
135
+ */
136
+ export interface Display {
137
+ /**
138
+ * Output for all successfully substituted display fields. Unsuccessful
139
+ * fields will be `null`, and will be accompanied by a field in `errors`,
140
+ * explaining the error.
141
+ *
142
+ * @generated from protobuf field: optional google.protobuf.Value output = 1;
143
+ */
144
+ output?: Value;
145
+ /**
146
+ * If any fields failed to render, this will contain a mapping from failed
147
+ * field names to error messages. If all fields succeed, this will either be
148
+ * `null` or not set.
149
+ *
150
+ * @generated from protobuf field: optional google.protobuf.Value errors = 2;
151
+ */
152
+ errors?: Value;
153
+ }
124
154
  // @generated message type with reflection information, may provide speed optimized methods
125
155
  class Object$Type extends MessageType<Object> {
126
156
  constructor() {
@@ -165,6 +195,7 @@ class Object$Type extends MessageType<Object> {
165
195
  T: 4 /*ScalarType.UINT64*/,
166
196
  L: 0 /*LongType.BIGINT*/,
167
197
  },
198
+ { no: 102, name: 'display', kind: 'message', T: () => Display },
168
199
  ]);
169
200
  }
170
201
  }
@@ -184,3 +215,16 @@ class ObjectSet$Type extends MessageType<ObjectSet> {
184
215
  * @generated MessageType for protobuf message sui.rpc.v2.ObjectSet
185
216
  */
186
217
  export const ObjectSet = new ObjectSet$Type();
218
+ // @generated message type with reflection information, may provide speed optimized methods
219
+ class Display$Type extends MessageType<Display> {
220
+ constructor() {
221
+ super('sui.rpc.v2.Display', [
222
+ { no: 1, name: 'output', kind: 'message', T: () => Value },
223
+ { no: 2, name: 'errors', kind: 'message', T: () => Value },
224
+ ]);
225
+ }
226
+ }
227
+ /**
228
+ * @generated MessageType for protobuf message sui.rpc.v2.Display
229
+ */
230
+ export const Display = new Display$Type();
@@ -111,6 +111,14 @@ export interface SimulateTransactionResponse {
111
111
  * @generated from protobuf field: repeated sui.rpc.v2.CommandResult command_outputs = 2;
112
112
  */
113
113
  commandOutputs: CommandResult[];
114
+ /**
115
+ * A suggested gas price to use, that is above RGP, in order to provide a
116
+ * better chance of the transaction being included in the presence of
117
+ * congested objects.
118
+ *
119
+ * @generated from protobuf field: optional uint64 suggested_gas_price = 3;
120
+ */
121
+ suggestedGasPrice?: bigint;
114
122
  }
115
123
  /**
116
124
  * An intermediate result/output from the execution of a single command
@@ -214,6 +222,14 @@ class SimulateTransactionResponse$Type extends MessageType<SimulateTransactionRe
214
222
  repeat: 1 /*RepeatType.PACKED*/,
215
223
  T: () => CommandResult,
216
224
  },
225
+ {
226
+ no: 3,
227
+ name: 'suggested_gas_price',
228
+ kind: 'scalar',
229
+ opt: true,
230
+ T: 4 /*ScalarType.UINT64*/,
231
+ L: 0 /*LongType.BIGINT*/,
232
+ },
217
233
  ]);
218
234
  }
219
235
  }
@@ -131,6 +131,7 @@ export class JSONRpcCoreClient extends CoreClient {
131
131
  options.include?.previousTransaction || options.include?.objectBcs ? true : false,
132
132
  showStorageRebate: options.include?.objectBcs ?? false,
133
133
  showContent: options.include?.json ?? false,
134
+ showDisplay: options.include?.display ?? false,
134
135
  },
135
136
  signal: options.signal,
136
137
  });
@@ -175,6 +176,7 @@ export class JSONRpcCoreClient extends CoreClient {
175
176
  options.include?.previousTransaction || options.include?.objectBcs ? true : false,
176
177
  showStorageRebate: options.include?.objectBcs ?? false,
177
178
  showContent: options.include?.json ?? false,
179
+ showDisplay: options.include?.display ?? false,
178
180
  },
179
181
  filter,
180
182
  signal: options.signal,
@@ -687,6 +689,12 @@ function parseObject<Include extends SuiClientTypes.ObjectInclude = {}>(
687
689
  ? null
688
690
  : undefined;
689
691
 
692
+ const displayData = include?.display
693
+ ? object.display?.data != null
694
+ ? { output: object.display.data as Record<string, string>, errors: null }
695
+ : null
696
+ : undefined;
697
+
690
698
  return {
691
699
  objectId: object.objectId,
692
700
  version: object.version,
@@ -701,6 +709,7 @@ function parseObject<Include extends SuiClientTypes.ObjectInclude = {}>(
701
709
  : undefined) as SuiClientTypes.Object<Include>['previousTransaction'],
702
710
  objectBcs: objectBcs as SuiClientTypes.Object<Include>['objectBcs'],
703
711
  json: jsonContent as SuiClientTypes.Object<Include>['json'],
712
+ display: displayData as SuiClientTypes.Object<Include>['display'],
704
713
  };
705
714
  }
706
715
 
@@ -39,7 +39,7 @@ export type BrowserPasswordProviderOptions = Pick<
39
39
 
40
40
  export interface PasskeyProvider {
41
41
  create(): Promise<RegistrationCredential>;
42
- get(challenge: Uint8Array): Promise<AuthenticationCredential>;
42
+ get(challenge: Uint8Array, credentialId?: Uint8Array): Promise<AuthenticationCredential>;
43
43
  }
44
44
 
45
45
  // Default browser implementation
@@ -80,12 +80,15 @@ export class BrowserPasskeyProvider implements PasskeyProvider {
80
80
  })) as RegistrationCredential;
81
81
  }
82
82
 
83
- async get(challenge: Uint8Array): Promise<AuthenticationCredential> {
83
+ async get(challenge: Uint8Array, credentialId?: Uint8Array): Promise<AuthenticationCredential> {
84
84
  return (await navigator.credentials.get({
85
85
  publicKey: {
86
86
  challenge: challenge as BufferSource,
87
87
  userVerification: this.#options.authenticatorSelection?.userVerification || 'required',
88
88
  timeout: this.#options.timeout ?? 60000,
89
+ ...(credentialId && {
90
+ allowCredentials: [{ type: 'public-key' as const, id: credentialId as BufferSource }],
91
+ }),
89
92
  },
90
93
  })) as AuthenticationCredential;
91
94
  }
@@ -98,6 +101,7 @@ export class BrowserPasskeyProvider implements PasskeyProvider {
98
101
  export class PasskeyKeypair extends Signer {
99
102
  private publicKey: Uint8Array;
100
103
  private provider: PasskeyProvider;
104
+ private credentialId?: Uint8Array;
101
105
 
102
106
  /**
103
107
  * Get the key scheme of passkey,
@@ -120,10 +124,20 @@ export class PasskeyKeypair extends Signer {
120
124
  * If there are existing passkey wallet, use `signAndRecover` to identify the correct
121
125
  * public key and then initialize the instance. See usage in `signAndRecover`.
122
126
  */
123
- constructor(publicKey: Uint8Array, provider: PasskeyProvider) {
127
+ constructor(publicKey: Uint8Array, provider: PasskeyProvider, credentialId?: Uint8Array) {
124
128
  super();
125
129
  this.publicKey = publicKey;
126
130
  this.provider = provider;
131
+ this.credentialId = credentialId;
132
+ }
133
+
134
+ /**
135
+ * Return the credential ID for this passkey, if available.
136
+ * The credential ID is captured when creating a new passkey via `getPasskeyInstance`
137
+ * and can be used to constrain which credential the browser selects during signing.
138
+ */
139
+ getCredentialId(): Uint8Array | undefined {
140
+ return this.credentialId;
127
141
  }
128
142
 
129
143
  /**
@@ -145,7 +159,7 @@ export class PasskeyKeypair extends Signer {
145
159
  const pubkeyUncompressed = parseDerSPKI(new Uint8Array(derSPKI));
146
160
  const pubkey = secp256r1.Point.fromBytes(pubkeyUncompressed);
147
161
  const pubkeyCompressed = pubkey.toBytes(true);
148
- return new PasskeyKeypair(pubkeyCompressed, provider);
162
+ return new PasskeyKeypair(pubkeyCompressed, provider, new Uint8Array(credential.rawId));
149
163
  }
150
164
  }
151
165
 
@@ -162,7 +176,7 @@ export class PasskeyKeypair extends Signer {
162
176
  */
163
177
  async sign(data: Uint8Array) {
164
178
  // asks the passkey to sign over challenge as the data.
165
- const credential = await this.provider.get(data);
179
+ const credential = await this.provider.get(data, this.credentialId);
166
180
 
167
181
  // parse authenticatorData (as bytes), clientDataJSON (decoded as string).
168
182
  const authenticatorData = new Uint8Array(credential.response.authenticatorData);
@@ -245,7 +259,7 @@ export class PasskeyKeypair extends Signer {
245
259
  * const testMessage2 = new TextEncoder().encode('Hello world 2!');
246
260
  * const possiblePks2 = await PasskeyKeypair.signAndRecover(provider, testMessage2);
247
261
  * const commonPk = findCommonPublicKey(possiblePks, possiblePks2);
248
- * const signer = new PasskeyKeypair(provider, commonPk.toRawBytes());
262
+ * const signer = new PasskeyKeypair(commonPk.toRawBytes(), provider);
249
263
  * ```
250
264
  *
251
265
  * @param provider - the passkey provider.
package/src/version.ts CHANGED
@@ -3,5 +3,5 @@
3
3
 
4
4
  // This file is generated by genversion.mjs. Do not edit it directly.
5
5
 
6
- export const PACKAGE_VERSION = '2.6.0';
7
- export const TARGETED_RPC_VERSION = '1.68.0';
6
+ export const PACKAGE_VERSION = '2.8.0';
7
+ export const TARGETED_RPC_VERSION = '1.69.0';