@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.
- package/CHANGELOG.md +22 -0
- package/dist/bcs/bcs.d.mts +6 -6
- package/dist/bcs/index.d.mts +20 -20
- package/dist/client/types.d.mts +17 -0
- package/dist/client/types.d.mts.map +1 -1
- package/dist/cryptography/signature.d.mts +14 -14
- package/dist/graphql/core.d.mts.map +1 -1
- package/dist/graphql/core.mjs +21 -8
- package/dist/graphql/core.mjs.map +1 -1
- package/dist/graphql/generated/queries.d.mts.map +1 -1
- package/dist/graphql/generated/queries.mjs +18 -3
- package/dist/graphql/generated/queries.mjs.map +1 -1
- package/dist/graphql/generated/tada-env.d.mts +703 -73
- package/dist/grpc/core.d.mts.map +1 -1
- package/dist/grpc/core.mjs +15 -2
- package/dist/grpc/core.mjs.map +1 -1
- package/dist/grpc/proto/sui/rpc/v2/move_package_service.client.d.mts +4 -4
- package/dist/grpc/proto/sui/rpc/v2/object.d.mts +38 -1
- package/dist/grpc/proto/sui/rpc/v2/object.d.mts.map +1 -1
- package/dist/grpc/proto/sui/rpc/v2/object.mjs +26 -1
- package/dist/grpc/proto/sui/rpc/v2/object.mjs.map +1 -1
- 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/grpc/proto/sui/rpc/v2/transaction_execution_service.d.mts +8 -0
- package/dist/grpc/proto/sui/rpc/v2/transaction_execution_service.d.mts.map +1 -1
- package/dist/grpc/proto/sui/rpc/v2/transaction_execution_service.mjs +23 -12
- package/dist/grpc/proto/sui/rpc/v2/transaction_execution_service.mjs.map +1 -1
- package/dist/grpc/proto/types.d.mts +2 -2
- package/dist/grpc/proto/types.mjs +2 -1
- package/dist/jsonRpc/core.d.mts.map +1 -1
- package/dist/jsonRpc/core.mjs +10 -3
- package/dist/jsonRpc/core.mjs.map +1 -1
- package/dist/keypairs/passkey/keypair.d.mts +11 -4
- package/dist/keypairs/passkey/keypair.d.mts.map +1 -1
- package/dist/keypairs/passkey/keypair.mjs +19 -6
- package/dist/keypairs/passkey/keypair.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 +2 -2
- package/dist/version.mjs.map +1 -1
- package/dist/zklogin/bcs.d.mts +14 -14
- package/docs/bcs.md +131 -0
- package/docs/clients/core.md +601 -0
- package/docs/clients/graphql.md +99 -0
- package/docs/clients/grpc.md +152 -0
- package/docs/clients/index.md +93 -0
- package/docs/clients/json-rpc.md +235 -0
- package/docs/cryptography/keypairs.md +258 -0
- package/docs/cryptography/multisig.md +192 -0
- package/docs/cryptography/passkey.md +111 -0
- package/docs/cryptography/webcrypto-signer.md +81 -0
- package/docs/executors.md +147 -0
- package/docs/faucet.md +26 -0
- package/docs/hello-sui.md +114 -0
- package/docs/index.md +54 -0
- package/docs/install.md +61 -0
- package/docs/llm-docs.md +32 -0
- package/docs/llms-index.md +60 -0
- package/docs/migrations/0.38.md +57 -0
- package/docs/migrations/sui-1.0.md +453 -0
- package/docs/migrations/sui-2.0/agent-prompt.md +42 -0
- package/docs/migrations/sui-2.0/dapp-kit.md +350 -0
- package/docs/migrations/sui-2.0/deepbook-v3.md +33 -0
- package/docs/migrations/sui-2.0/index.md +157 -0
- package/docs/migrations/sui-2.0/json-rpc-migration.md +383 -0
- package/docs/migrations/sui-2.0/kiosk.md +120 -0
- package/docs/migrations/sui-2.0/sdk-maintainers.md +90 -0
- package/docs/migrations/sui-2.0/seal.md +14 -0
- package/docs/migrations/sui-2.0/sui.md +341 -0
- package/docs/migrations/sui-2.0/suins.md +42 -0
- package/docs/migrations/sui-2.0/wallet-builders.md +66 -0
- package/docs/migrations/sui-2.0/walrus.md +41 -0
- package/docs/migrations/sui-2.0/zksend.md +94 -0
- package/docs/plugins.md +255 -0
- package/docs/sdk-building.md +340 -0
- package/docs/transaction-building/basics.md +297 -0
- package/docs/transaction-building/gas.md +62 -0
- package/docs/transaction-building/intents.md +61 -0
- package/docs/transaction-building/offline.md +71 -0
- package/docs/transaction-building/sponsored-transactions.md +22 -0
- package/docs/utils/derived_objects.md +59 -0
- package/docs/utils/index.md +52 -0
- package/docs/zklogin.md +78 -0
- package/package.json +5 -3
- package/src/client/types.ts +16 -0
- package/src/graphql/core.ts +34 -13
- package/src/graphql/generated/queries.ts +252 -14
- package/src/graphql/generated/schema.graphql +324 -8
- package/src/graphql/generated/tada-env.ts +844 -99
- package/src/graphql/queries/objects.graphql +10 -0
- package/src/graphql/queries/verifyZkLoginSignature.graphql +0 -1
- package/src/grpc/core.ts +34 -0
- package/src/grpc/proto/sui/rpc/v2/object.ts +44 -0
- package/src/grpc/proto/sui/rpc/v2/transaction_execution_service.ts +16 -0
- package/src/jsonRpc/core.ts +9 -0
- package/src/keypairs/passkey/keypair.ts +20 -6
- package/src/version.ts +2 -2
package/docs/zklogin.md
ADDED
|
@@ -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
|
+
"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/
|
|
172
|
-
"@mysten/
|
|
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",
|
package/src/client/types.ts
CHANGED
|
@@ -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 {
|
package/src/graphql/core.ts
CHANGED
|
@@ -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
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
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
|
-
|
|
570
|
-
);
|
|
579
|
+
});
|
|
571
580
|
|
|
572
581
|
return {
|
|
573
|
-
success:
|
|
574
|
-
errors:
|
|
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
|
|