XdrLargeInt

XdrLargeInt

A wrapper class to represent large XDR-encodable integers.

This operates at a lower level than ScInt by forcing you to specify the type / width / size in bits of the integer you're targeting, regardless of the input value(s) you provide.

Constructor

new XdrLargeInt(type, values)

Source:
Parameters:
Name Type Description
type string

force a specific data type. the type choices are: 'i64', 'u64', 'i128', 'u128', 'i256', and 'u256' (default: the smallest one that fits the value) (see XdrLargeInt.isType)

values number | bigint | string | Array.<(number|bigint|string)>

a list of integer-like values interpreted in big-endian order

Classes

XdrLargeInt

Members

int :xdr.LargeInt

Source:
Type:
  • xdr.LargeInt

type :string

Source:
Type:
  • string

Methods

toBigInt() → {bigint}

Source:
Returns:
Type:
bigint

toI128() → {xdr.ScVal}

Source:
Throws:

if the value cannot fit in 128 bits

Type
RangeError
Returns:
Type:
xdr.ScVal

the integer encoded with ScValType = I128

toI256() → {xdr.ScVal}

Source:
Returns:
Type:
xdr.ScVal

the integer encoded with ScValType = I256

toI64() → {xdr.ScVal}

Source:
Returns:
Type:
xdr.ScVal

the integer encoded with ScValType = I64

toNumber() → {number}

Source:
Throws:

if the value can't fit into a Number

Type
RangeError
Returns:
Type:
number

toScVal() → {xdr.ScVal}

Source:
Returns:
Type:
xdr.ScVal

the smallest interpretation of the stored value

toU128() → {xdr.ScVal}

Source:
Throws:

if the value cannot fit in 128 bits

Type
RangeError
Returns:
Type:
xdr.ScVal

the integer encoded with ScValType = U128

toU256() → {xdr.ScVal}

Source:
Returns:
Type:
xdr.ScVal

the integer encoded with ScValType = U256

toU64() → {xdr.ScVal}

Source:
Returns:
Type:
xdr.ScVal

the integer encoded with ScValType = U64

(static) getType(scvType) → {string}

Convert the raw ScValType string (e.g. 'scvI128', generated by the XDR) to a type description for XdrLargeInt construction (e.g. 'i128')

Source:
Parameters:
Name Type Description
scvType string

the xdr.ScValType as a string

Returns:
Type:
string

a suitable equivalent type to construct this object