Skip to content

Comments

feat(ts-sdk): add SuiNS and channel name resolution for human-readable identifiers#58

Open
arbuthnot-eth wants to merge 3 commits intoMystenLabs:mainfrom
arbuthnot-eth:feature/suins-display-names
Open

feat(ts-sdk): add SuiNS and channel name resolution for human-readable identifiers#58
arbuthnot-eth wants to merge 3 commits intoMystenLabs:mainfrom
arbuthnot-eth:feature/suins-display-names

Conversation

@arbuthnot-eth
Copy link

Summary

This PR adds human-readable naming support to the Sui Stack Messaging SDK, enabling users to reference addresses and channels by name instead of raw object IDs.

Features

  • SuiNS Integration (@user.sui): Resolve SuiNS names to Sui addresses
  • Channel Names (#channel): Map human-readable names to channel object IDs

Changes

New Files

File Description
src/utils/addressResolution.ts SuiNS resolver interface and implementation
src/utils/channelResolution.ts Channel name registry interface and implementations
test/unit/addressResolution.test.ts 21 unit tests for address resolution
test/unit/channelResolution.test.ts 40 unit tests for channel resolution

Modified Files

File Changes
package.json Added @mysten/suins@^0.9.13 dependency
src/types.ts Added addressResolver and channelResolver options
src/client.ts Integrated resolvers into client methods
src/index.ts Exported new utilities

API

Address Resolution (SuiNS)

import { SuinsClient } from '@mysten/suins';
import { messaging, SuiNSResolver } from '@mysten/messaging';

const suinsClient = new SuinsClient({ client: suiClient, network: 'mainnet' });

const client = suiClient.$extend(messaging({
  addressResolver: new SuiNSResolver(suinsClient),
  // ...
}));

// Use SuiNS names directly
await client.messaging.executeCreateChannelTransaction({
  signer,
  initialMembers: ['alice.sui', 'bob.sui', '0x123...'],
});

Channel Name Resolution

import { messaging, LocalChannelRegistry } from '@mysten/messaging';

const channelRegistry = new LocalChannelRegistry();
await channelRegistry.register('general', '0xchannel123...');

const client = suiClient.$extend(messaging({
  channelResolver: channelRegistry,
  // ...
}));

// Use channel names
const members = await client.messaging.getChannelMembers('#general');
const messages = await client.messaging.getChannelMessages({
  channelId: '#general',
  userAddress: '0x...',
});

Exports

// Address resolution
export { SuiNSResolver, isSuiNSName } from '@mysten/messaging';
export type { AddressResolver } from '@mysten/messaging';

// Channel resolution
export { 
  LocalChannelRegistry, 
  PersistentChannelRegistry,
  isChannelName, 
  normalizeChannelName, 
  formatChannelName 
} from '@mysten/messaging';
export type { ChannelNameResolver } from '@mysten/messaging';

Breaking Changes

  • createChannelFlow() is now async (returns Promise<CreateChannelFlow>)

Test Plan

  • pnpm build - TypeScript compilation passes
  • pnpm test:typecheck - Type checking passes
  • pnpm test:unit - 61 unit tests passing (21 address + 40 channel)
  • Integration tests with SuiNS testnet names

Related

  • Enables human-readable UX for decentralized messaging
  • Foundation for agent addressing (e.g., @summarizer.sui)

Integrate @mysten/suins to enable human-readable name resolution in the
messaging SDK. Users can now use SuiNS names (e.g., "alice.sui") instead
of raw addresses when creating channels or adding members.

- Add @mysten/suins dependency
- Create AddressResolver interface and SuiNSResolver implementation
- Add optional addressResolver to client options
- Resolve names in createChannelFlow() and addMembers()
- Export SuiNSResolver, isSuiNSName, and AddressResolver type
Add comprehensive unit tests for the address resolution utilities:
- isSuiNSName() detection function
- SuiNSResolver.resolve() single name resolution
- SuiNSResolver.resolveMany() batch resolution
- Mixed arrays (names + addresses)
- Error handling for unresolvable names
- Custom AddressResolver implementation example

21 tests covering all edge cases.
Add human-readable channel name support to the messaging SDK. Users can
now reference channels by name (e.g., "#general") instead of raw object IDs.

## New Features

- `ChannelNameResolver` interface for pluggable name resolution
- `LocalChannelRegistry` for in-memory channel name mapping
- `PersistentChannelRegistry` for browser localStorage persistence
- Helper functions: `isChannelName()`, `normalizeChannelName()`, `formatChannelName()`

## SDK Integration

- Added optional `channelResolver` to client options
- Updated methods to accept channel names:
  - `getChannelMembers()`
  - `getChannelMessages()`
  - `getLatestMessages()`
  - `executeSendMessageTransaction()`
  - `executeAddMembersTransaction()`
  - `addMembers()`

## Usage

```typescript
import { messaging, LocalChannelRegistry } from '@mysten/messaging';

const channelRegistry = new LocalChannelRegistry();
await channelRegistry.register('general', '0xchannel123...');

const client = suiClient.$extend(messaging({
  channelResolver: channelRegistry,
  // ... other options
}));

// Use channel names directly
const members = await client.messaging.getChannelMembers('#general');
```

## Tests

- 40 unit tests for channel resolution utilities
- All 61 unit tests passing
@arbuthnot-eth
Copy link
Author

Closes #59

@ioannischtz ioannischtz self-requested a review January 28, 2026 16:29
@arbuthnot-eth
Copy link
Author

arbuthnot-eth commented Feb 16, 2026

Seeking a PR on my sui.ski project to add Sui Stack Messaging Sdk 0.4.0

Codename: Thunder

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant