@passes/reqs / Exports / RequestTopic
Class: RequestTopic<TRequestBody, TResultBody>
Builds an Envelope-v0x00 request topic interface.
Implements
Type parameters
Name |
---|
TRequestBody |
TResultBody |
Hierarchy
RequestTopic
Table of contents
Constructors
Properties
Methods
Constructors
constructor
• new RequestTopic<TRequestBody
, TResultBody
>(params
): RequestTopic
<TRequestBody
, TResultBody
>
Type parameters
Name |
---|
TRequestBody |
TResultBody |
Parameters
Name | Type |
---|---|
params | RequestTopicParams <TRequestBody , TResultBody > |
Returns
RequestTopic
<TRequestBody
, TResultBody
>
Defined in
Properties
abi
• abi: PassesABI
Defined in
id
• id: string
Defined in
requestBodyCodec
• requestBodyCodec: Codec
<TRequestBody
>
Defined in
resultBodyCodec
• resultBodyCodec: Codec
<TResultBody
>
Defined in
Errors
▪ Static
Errors: Object
Type declaration
Name | Type |
---|---|
ABI_NOT_AVAILABLE | typeof RequestTopicABINotAvailable |
INCORRECT_TOPIC | typeof RequestTopicIncorrectTopicError |
Defined in
Methods
decodeRequest
▸ decodeRequest(bytes
): Promise
<TRequestBody
>
Decodes an envelope-v0x00 request into a structured request body.
Parameters
Name | Type |
---|---|
bytes | Uint8Array |
Returns
Promise
<TRequestBody
>
Defined in
decodeResult
▸ decodeResult(bytes
): Promise
<RequestResult
<TResultBody
>>
Decodes an envelope-v0x00 request into a structured request body.
Parameters
Name | Type |
---|---|
bytes | Uint8Array |
Returns
Promise
<RequestResult
<TResultBody
>>
Defined in
encodeRequest
▸ encodeRequest(body
): Promise
<Uint8Array
>
Encodes a structured request body into an envelope-v0x00 request.
Parameters
Name | Type |
---|---|
body | TRequestBody |
Returns
Promise
<Uint8Array
>
Defined in
encodeResult
▸ encodeResult(result
): Promise
<Uint8Array
>
Encodes a structured result body into an envelope-v0x00 result.
Parameters
Name | Type |
---|---|
result | RequestResult <TResultBody > |
Returns
Promise
<Uint8Array
>
Defined in
resolveABI
▸ resolveABI(): PassesABI
A helper for resolving the PassesABI. If the instance has no abi property, it returns document.passes if it's available.
Returns
Throws
- document.passes must be available if
abi
is not passed.
Defined in
sendRequest
▸ sendRequest(reqBody
): Promise
<RequestResult
<TResultBody
>>
Sends a request.
Parameters
Name | Type |
---|---|
reqBody | TRequestBody |
Returns
Promise
<RequestResult
<TResultBody
>>
Defined in
toString
▸ toString(): string
Returns a string representation of the request topic.
Returns
string
Defined in
withABI
▸ withABI(abi
): RequestTopic
<TRequestBody
, TResultBody
>
Returns a new RequestTopic instance with the same id and codecs, but with a new ABI.
Parameters
Name | Type |
---|---|
abi | PassesABI |
Returns
RequestTopic
<TRequestBody
, TResultBody
>