@fuel-ts/program v0.94.1 • Docs
Class: ScriptRequest<TData, TResult>
ScriptRequest
provides functionality to encode and decode script data and results.
Type Parameters
Type Parameter | Default type | Description |
---|---|---|
TData | void | Type of the script data. |
TResult | void | Type of the script result. |
Constructors
new ScriptRequest()
new ScriptRequest<
TData
,TResult
>(bytes
,scriptDataEncoder
,scriptResultDecoder
):ScriptRequest
<TData
,TResult
>
Creates an instance of the ScriptRequest class.
Parameters
Parameter | Type | Description |
---|---|---|
bytes | BytesLike | The bytes of the script. |
scriptDataEncoder | (data ) => EncodedScriptCall | The script data encoder function. |
scriptResultDecoder | (scriptResult ) => TResult | The script result decoder function. |
Returns
ScriptRequest
<TData
, TResult
>
Defined in
script-request.ts:205
Properties
Property | Type | Description | Defined in |
---|---|---|---|
bytes | Uint8Array | The bytes of the script. | script-request.ts:186 |
scriptDataEncoder | (data : TData ) => EncodedScriptCall | A function to encode the script data. | script-request.ts:191 |
scriptResultDecoder | (scriptResult : ScriptResult ) => TResult | A function to decode the script result. | script-request.ts:196 |
Methods
decodeCallResult()
decodeCallResult(
callResult
,logs
):TResult
Decodes the result of a script call.
Parameters
Parameter | Type | Default value | Description |
---|---|---|---|
callResult | CallResult | undefined | The CallResult from the script call. |
logs | any [] | [] | Optional logs associated with the decoding. |
Returns
TResult
The decoded result.
Defined in
script-request.ts:262
encodeScriptData()
encodeScriptData(
data
):Uint8Array
Encodes the data for a script call.
Parameters
Parameter | Type | Description |
---|---|---|
data | TData | The script data. |
Returns
Uint8Array
The encoded data.
Defined in
script-request.ts:243
getScriptDataOffset()
getScriptDataOffset(
maxInputs
):number
Gets the script data offset.
Parameters
Parameter | Type | Description |
---|---|---|
maxInputs | number | The maxInputs value from the chain's consensus params. |
Returns
number
The script data offset.
Defined in
script-request.ts:233
getScriptDataOffsetWithScriptBytes()
static
getScriptDataOffsetWithScriptBytes(byteLength
,maxInputs
):number
Gets the script data offset for the given bytes.
Parameters
Parameter | Type | Description |
---|---|---|
byteLength | number | The byte length of the script. |
maxInputs | number | The maxInputs value from the chain's consensus params. |
Returns
number
The script data offset.
Defined in
script-request.ts:222