Client
Class: Client
Client class initiates connection to the XMTP network.
Should be created with await Client.create(options)
Constructors
constructor
new Client(keys
, apiClient
)
Parameters
Name | Type |
---|---|
keys | PrivateKeyBundleV1 |
apiClient | default |
Defined in
Properties
_codecs
Private
_codecs: Map
<string
, ContentCodec
<any
>>
Defined in
_conversations
Private
_conversations: Conversations
Defined in
_maxContentSize
Private
_maxContentSize: number
Defined in
address
address: string
Defined in
apiClient
apiClient: default
Defined in
contacts
contacts: Set
<string
>
Defined in
keys
keys: PrivateKeyBundleV2
Defined in
knownPublicKeyBundles
Private
knownPublicKeyBundles: Map
<string
, SignedPublicKeyBundle
| PublicKeyBundle
>
Defined in
legacyKeys
legacyKeys: PrivateKeyBundleV1
Defined in
Accessors
conversations
get
conversations(): Conversations
Returns
Defined in
Methods
canMessage
canMessage(peerAddress
): Promise
<boolean
>
Check if
Peer Address
can be messaged, specifically it checks that a PublicKeyBundle can be found for the given address
Parameters
Name | Type |
---|---|
peerAddress | string |
Returns
Promise
<boolean
>
Defined in
close
close(): Promise
<void
>
Returns
Promise
<void
>
Defined in
codecFor
codecFor(contentType
): undefined
| ContentCodec
<any
>
Parameters
Name | Type |
---|---|
contentType | ContentTypeId |
Returns
undefined
| ContentCodec
<any
>
Defined in
encodeContent
encodeContent(content
, options?
): Promise
<Uint8Array
>
Parameters
Name | Type |
---|---|
content | any |
options? | SendOptions |
Returns
Promise
<Uint8Array
>
Defined in
ensureUserContactPublished
Private
ensureUserContactPublished(legacy?
): Promise
<void
>
Parameters
Name | Type | Default value |
---|---|---|
legacy | boolean | false |
Returns
Promise
<void
>
Defined in
forgetContact
forgetContact(peerAddress
): void
Used to force getUserContact fetch contact from the network.
Parameters
Name | Type |
---|---|
peerAddress | string |
Returns
void
Defined in
getUserContact
getUserContact(peerAddress
): Promise
<undefined
| SignedPublicKeyBundle
| PublicKeyBundle
>
Returns the cached PublicKeyBundle if one is known for the given address or fetches one from the network
Parameters
Name | Type |
---|---|
peerAddress | string |
Returns
Promise
<undefined
| SignedPublicKeyBundle
| PublicKeyBundle
>
Defined in
init
Private
init(options
): Promise
<void
>
Parameters
Name | Type |
---|---|
options | ClientOptions |
Returns
Promise
<void
>
Defined in
listEnvelopes
listEnvelopes<Out
>(topics
, mapper
, opts?
): Promise
<Out
[]>
Type parameters
Name |
---|
Out |
Parameters
Name | Type |
---|---|
topics | string [] |
mapper | EnvelopeMapper <Out > |
opts? | ListMessagesOptions |
Returns
Promise
<Out
[]>
Defined in
listEnvelopesPaginated
listEnvelopesPaginated<Out
>(contentTopics
, mapper
, opts?
): AsyncGenerator
<Out
[], any
, unknown
>
List messages on a given set of content topics, yielding one page at a time
Type parameters
Name |
---|
Out |
Parameters
Name | Type |
---|---|
contentTopics | string [] |
mapper | EnvelopeMapper <Out > |
opts? | ListMessagesPaginatedOptions |
Returns
AsyncGenerator
<Out
[], any
, unknown
>
Defined in
listInvitations
listInvitations(opts?
): Promise
<SealedInvitation
[]>
Parameters
Name | Type |
---|---|
opts? | ListMessagesOptions |
Returns
Promise
<SealedInvitation
[]>
Defined in
publishEnvelopes
publishEnvelopes(envelopes
): Promise
<void
>
Parameters
Name | Type |
---|---|
envelopes | PublishParams [] |
Returns
Promise
<void
>
Defined in
publishUserContact
publishUserContact(legacy?
): Promise
<void
>
Parameters
Name | Type | Default value |
---|---|---|
legacy | boolean | false |
Returns
Promise
<void
>
Defined in
registerCodec
registerCodec(codec
): void
Parameters
Name | Type |
---|---|
codec | ContentCodec <any > |
Returns
void
Defined in
validateEnvelope
Private
validateEnvelope(env
): void
Parameters
Name | Type |
---|---|
env | PublishParams |
Returns
void
Defined in
canMessage
Static
canMessage(peerAddress
, opts?
): Promise
<boolean
>
Parameters
Name | Type |
---|---|
peerAddress | string |
opts? | Partial <NetworkOptions > |
Returns
Promise
<boolean
>
Defined in
create
Static
create(wallet
, opts?
): Promise
<Client
>
Create and start a client associated with given wallet.
Parameters
Name | Type | Description |
---|---|---|
wallet | null | Signer | the wallet as a Signer instance |
opts? | Partial <ClientOptions > | specify how to to connect to the network |
Returns
Promise
<Client
>
Defined in
getKeys
Static
getKeys(wallet
, opts?
): Promise
<Uint8Array
>
Parameters
Name | Type |
---|---|
wallet | null | Signer |
opts? | Partial <ClientOptions > |
Returns
Promise
<Uint8Array
>