Skip to content

Commit aa1aa00

Browse files
ioannischtzclaude
andauthored
docs: Setup.md accuracy fixes and architecture context (#70)
* docs: Setup.md accuracy fixes and architecture context Reconciled with the merged Sui Documentation Style Guide pass (#68). - Add "Architecture at a glance" and "Prerequisites" sections so the doc surfaces the multi-service stack (Sui RPC, relayer, Seal key servers, Walrus publisher/aggregator) and the running-relayer prerequisite. - Fix stale factory name: createMessagingGroupsClient -> createSuiStackMessagingClient. - Session-key tiers: Tier 1 references @mysten/dapp-kit, Tier 2 drops dapp-kit framing, Tier 3 renamed Consumer-managed; add DEK-cache-TTL note. - Split packageConfig shape (factory nested vs manual flat). - Add "Where to go next" cross-links. Style follows the guide: sentence-case headings, Testnet/Mainnet, "through", no horizontal rules, no inline bold labels. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> * docs: apply review feedback on Setup.md - Drop Where-to-go-next footer nav (inline suggestion). - Capitalize Localnet in prose (style-guide audit). - Tier 1 heading to sentence case; move signer list to body. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
1 parent e29b3f5 commit aa1aa00

1 file changed

Lines changed: 57 additions & 25 deletions

File tree

docs/sui-stack-messaging/Setup.md

Lines changed: 57 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,35 @@
33

44
This SDK follows the [MystenLabs TS SDK building guidelines](https://sdk.mystenlabs.com/sui/sdk-building). It uses the client extension pattern: you extend a base Sui client with messaging, groups, and Seal extensions.
55

6-
## Quick setup with `createMessagingGroupsClient()`
6+
## Architecture at a glance
77

8-
This helper 'factory' function handles all three extensions automatically:
8+
The SDK is one client in a system that talks to four independent services. Encryption is end-to-end, so none of them see plaintext.
9+
10+
| Service | What it does | Who runs it |
11+
| ----------------------------------------------------------- | ------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
12+
| Sui RPC (fullnode / gRPC) | Chain reads and transaction submission | Public endpoint or your own |
13+
| Relayer | Accepts ciphertext, indexes membership, serves messages back | You run it. No public canonical relayer exists, so fork the reference at [`relayer/`](../../relayer/). See [Relayer](./Relayer.md). |
14+
| Seal key servers | Threshold-encrypt and decrypt DEKs | Mysten Labs operates the canonical allowlist; you reference their objectIds in `seal.serverConfigs`. See [Seal docs](https://github.com/MystenLabs/seal). |
15+
| Walrus publisher and aggregator (optional, attachments only) | Stores encrypted file bytes | Public Testnet endpoints, your own, or skip them entirely and talk to Walrus through the [`@mysten/walrus`](https://www.npmjs.com/package/@mysten/walrus) SDK (see [Extending](./Extending.md)). |
16+
17+
## Prerequisites
18+
19+
Before writing SDK code, confirm:
20+
21+
- A running relayer reachable from your app. For development, see [`relayer/README.md`](../../relayer/README.md); for production, fork the reference and operate your own.
22+
- Seal `serverConfigs`, the canonical key-server object IDs for your network. See [Seal docs](https://github.com/MystenLabs/seal) for the current allowlist.
23+
- A Sui RPC URL for the right network (Testnet, Mainnet, or Localnet).
24+
- (Optional) A Walrus publisher and aggregator if you need attachments, or commit to the `@mysten/walrus` SDK path (see [Attachments](./Attachments.md), [Extending](./Extending.md)).
25+
26+
## Quick setup with `createSuiStackMessagingClient()`
27+
28+
This factory function composes all three extensions for you:
929

1030
```typescript
1131
import { SuiGrpcClient } from '@mysten/sui/grpc';
12-
import { createMessagingGroupsClient } from '@mysten/sui-stack-messaging';
32+
import { createSuiStackMessagingClient } from '@mysten/sui-stack-messaging';
1333

14-
const client = createMessagingGroupsClient(
34+
const client = createSuiStackMessagingClient(
1535
new SuiGrpcClient({
1636
baseUrl: 'https://fullnode.testnet.sui.io:443',
1737
network: 'testnet',
@@ -39,12 +59,12 @@ After creation, the client exposes four namespaces:
3959
| ------------------ | ------------------------------------------------------------------------------ |
4060
| `client.messaging` | E2EE messaging, group creation, key rotation |
4161
| `client.groups` | Permission management ([Sui Groups docs](https://github.com/MystenLabs/sui-groups)) |
42-
| `client.seal` | Seal encryption/decryption (utilized by `messaging`) |
62+
| `client.seal` | Seal encryption/decryption (used by `messaging`) |
4363
| `client.core` | Base Sui RPC methods |
4464

4565
## Manual extension chain (advanced)
4666

47-
For full control over each extension, use `$extend()` directly:
67+
For custom extension names or full control, use `$extend()` directly:
4868

4969
```typescript
5070
import { SuiGrpcClient } from '@mysten/sui/grpc';
@@ -92,7 +112,9 @@ Controls how the SDK obtains Seal session keys and encrypts/decrypts messages.
92112

93113
#### Session key tiers
94114

95-
##### Tier 1: Signer-based (recommended for dapp-kit-next, Keypair, Enoki):
115+
##### Tier 1: Signer-based (recommended)
116+
117+
Works with `@mysten/dapp-kit`'s `CurrentAccountSigner`, a `Keypair`, or Enoki.
96118

97119
```typescript
98120
encryption: {
@@ -102,7 +124,7 @@ encryption: {
102124

103125
The SDK derives the address through `signer.toSuiAddress()`, creates a `SessionKey`, and handles certification automatically.
104126

105-
##### Tier 2: Callback-based (for current dapp-kit without Signer abstraction):
127+
##### Tier 2: Callback-based (when you only have a `signPersonalMessage` surface, not a full `Signer`):
106128

107129
```typescript
108130
encryption: {
@@ -116,9 +138,9 @@ encryption: {
116138
}
117139
```
118140

119-
The SDK creates the session key, then calls `onSign()` with the personal message bytes.
141+
The SDK creates the session key, then calls `onSign()` with the personal-message bytes.
120142

121-
##### Tier 3: Manual (full control over session key lifecycle):
143+
##### Tier 3: Consumer-managed (full control over the `SessionKey` lifecycle):
122144

123145
```typescript
124146
encryption: {
@@ -130,11 +152,13 @@ encryption: {
130152

131153
#### Session key options (Tier 1 and 2)
132154

133-
| Option | Default | Description |
134-
| ----------------- | ------- | ---------------------------------- |
135-
| `ttlMin` | 10 | Session key TTL in minutes |
136-
| `refreshBufferMs` | 60000 | Refresh this many ms before expiry |
137-
| `mvrName` | (none) | MVR name for Seal policy resolution |
155+
| Option | Default | Description |
156+
| ----------------- | ------- | ------------------------------------------------------- |
157+
| `ttlMin` | 10 | Session-key TTL in minutes; also sets the DEK cache TTL |
158+
| `refreshBufferMs` | 60000 | Refresh this many ms before expiry |
159+
| `mvrName` | (none) | MVR name for Seal package resolution |
160+
161+
Tier 3's variant excludes these options; its DEK cache falls back to the 10-minute default regardless of your `SessionKey`'s own TTL.
138162

139163
#### Encryption options
140164

@@ -146,14 +170,16 @@ encryption: {
146170

147171
### `relayer` (required)
148172

149-
Either provide a URL for the built-in HTTP transport or a custom transport instance:
173+
The relayer must be running and reachable before any message operation succeeds. `sendMessage`, `getMessages`, `subscribe`, and friends all go through it. No public canonical relayer exists, so see [`relayer/README.md`](../../relayer/README.md) to spin up the reference for development, or fork it for production.
174+
175+
Either provide a URL for the built-in HTTP transport, or supply a custom transport instance:
150176

151177
```typescript
152178
// Built-in HTTP transport
153179
relayer: {
154180
relayerUrl: 'https://your-relayer.example.com',
155181
pollingIntervalMs: 3000, // default
156-
timeout: 30000, // default
182+
timeout: 30_000, // default (ms)
157183
onError: (err) => console.error(err),
158184
}
159185

@@ -163,7 +189,7 @@ relayer: {
163189
}
164190
```
165191

166-
See [Relayer](./Relayer.md) for the `RelayerTransport` interface.
192+
See [Relayer](./Relayer.md) for the wire protocol and `RelayerTransport` interface.
167193

168194
### `attachments` (optional)
169195

@@ -178,23 +204,25 @@ attachments: {
178204
aggregatorUrl: 'https://aggregator.walrus-testnet.walrus.space',
179205
epochs: 5,
180206
}),
181-
maxAttachments: 10, // default
182-
maxFileSizeBytes: 10_485_760, // 10 MB default
207+
maxAttachments: 10, // default
208+
maxFileSizeBytes: 10_485_760, // 10 MB default
183209
maxTotalFileSizeBytes: 52_428_800, // 50 MB default
184210
}
185211
```
186212

187-
When omitted, `sendMessage` cannot include files and received attachment metadata is not resolvable. See [Attachments](./Attachments.md).
213+
When omitted, `sendMessage` cannot include files and received attachment metadata is not resolvable. See [Attachments](./Attachments.md), and [Extending](./Extending.md) for non-HTTP and `@mysten/walrus`-SDK adapters.
188214

189215
### `packageConfig` (optional)
190216

191-
Auto-detected for Testnet and Mainnet. Required for localnet or custom deployments:
217+
Auto-detected for Testnet and Mainnet. Required for Localnet or custom deployments. The shape differs between the factory and the manual chain.
218+
219+
Factory (`createSuiStackMessagingClient`):
192220

193221
```typescript
194222
packageConfig: {
195223
messaging: {
196-
originalPackageId: '0x...', // First published package ID (type names, BCS, Seal)
197-
latestPackageId: '0x...', // Current package ID (moveCall targets)
224+
originalPackageId: '0x...', // First published: type names, BCS, Seal namespace
225+
latestPackageId: '0x...', // Current: moveCall targets
198226
namespaceId: '0x...', // MessagingNamespace shared object
199227
versionId: '0x...', // Version shared object
200228
},
@@ -205,13 +233,15 @@ packageConfig: {
205233
}
206234
```
207235

236+
Manual (`suiStackMessaging({...})`): a flat `SuiStackMessagingPackageConfig`, just the four messaging fields above. The `permissionedGroups` config is passed separately into `suiGroups({ packageConfig })` within the same `$extend` call.
237+
208238
### `suinsConfig` (optional)
209239

210240
Auto-detected for Testnet and Mainnet. Only needed for SuiNS reverse lookup operations (`setSuinsReverseLookup`, `unsetSuinsReverseLookup`).
211241

212242
### `seal` (factory only)
213243

214-
When using `createMessagingGroupsClient`, pass either a pre-built `SealClient` or Seal config options:
244+
When using `createSuiStackMessagingClient`, pass either a pre-built `SealClient` or Seal config options:
215245

216246
```typescript
217247
// Config options (SealClient created internally)
@@ -226,6 +256,8 @@ seal: {
226256
seal: existingSealClient,
227257
```
228258

259+
In the manual chain you construct the `SealClient` directly inside the `$extend` `register` callback (see the example above).
260+
229261
## Sub-modules
230262

231263
The `client.messaging` object exposes several sub-modules:

0 commit comments

Comments
 (0)