feat(ts-sdk): add SuiNS and channel name resolution for human-readable identifiers#58
Open
arbuthnot-eth wants to merge 3 commits intoMystenLabs:mainfrom
Open
feat(ts-sdk): add SuiNS and channel name resolution for human-readable identifiers#58arbuthnot-eth wants to merge 3 commits intoMystenLabs:mainfrom
arbuthnot-eth wants to merge 3 commits intoMystenLabs:mainfrom
Conversation
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
Author
|
Closes #59 |
Author
|
Seeking a PR on my sui.ski project to add Sui Stack Messaging Sdk 0.4.0 Codename: Thunder |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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
@user.sui): Resolve SuiNS names to Sui addresses#channel): Map human-readable names to channel object IDsChanges
New Files
src/utils/addressResolution.tssrc/utils/channelResolution.tstest/unit/addressResolution.test.tstest/unit/channelResolution.test.tsModified Files
package.json@mysten/suins@^0.9.13dependencysrc/types.tsaddressResolverandchannelResolveroptionssrc/client.tssrc/index.tsAPI
Address Resolution (SuiNS)
Channel Name Resolution
Exports
Breaking Changes
createChannelFlow()is nowasync(returnsPromise<CreateChannelFlow>)Test Plan
pnpm build- TypeScript compilation passespnpm test:typecheck- Type checking passespnpm test:unit- 61 unit tests passing (21 address + 40 channel)Related
@summarizer.sui)