Helios API/ API Reference/ Classes/
Assets
Represents a list of non-Ada tokens.
Hierarchy
-
↳
Assets
Index
Constructors
constructor
• new Assets(props?
)
Note: the assets are normalized by removing entries with 0 tokens, and merging all entries with the same MintingPolicyHash and token name.
Parameters
Name | Type | Description |
---|---|---|
props? | AssetsProps | Either a list of AssetClass /quantity pairs, or a list of MintingPolicyHash /tokens pairs (where each tokens entry is a bytearray/quantity pair). |
Overrides
Accessors
mintingPolicies
• get
mintingPolicies(): MintingPolicyHash
[]
Returns a list of all the minting policies.
Returns
nTokenTypes
• get
nTokenTypes(): number
Returns
number
Methods
_toUplcData
▸ _toUplcData(): MapData
Used when generating script contexts for running programs
Returns
add
▸ add(other
): Assets
Parameters
Name | Type |
---|---|
other | Assets |
Returns
addComponent
▸ addComponent(mph
, tokenName
, qty
): void
Mutates 'this'.
Parameters
Name | Type |
---|---|
mph | HashProps | MintingPolicyHash |
tokenName | ByteArray | ByteArrayProps |
qty | HInt | HIntProps |
Returns
void
addTokens
▸ addTokens(mph
, tokens
): void
Mutates 'this'. Throws error if mph is already contained in 'this'.
Parameters
Name | Type |
---|---|
mph | HashProps | MintingPolicyHash |
tokens | [ByteArray | ByteArrayProps , HInt | HIntProps ][] |
Returns
void
allPositive
▸ allPositive(): boolean
Returns
boolean
assertAllPositive
▸ assertAllPositive(): void
Throws an error if any contained quantity <= 0n
Returns
void
assertSorted
▸ assertSorted(): void
Returns
void
dump
▸ dump(): any
Returns
any
eq
▸ eq(other
): boolean
Parameters
Name | Type |
---|---|
other | Assets |
Returns
boolean
ge
▸ ge(other
): boolean
Parameters
Name | Type |
---|---|
other | Assets |
Returns
boolean
get
▸ get(mph
, tokenName
): bigint
Parameters
Name | Type |
---|---|
mph | HashProps | MintingPolicyHash |
tokenName | ByteArray | ByteArrayProps |
Returns
bigint
getTokenNames
▸ getTokenNames(mph
): ByteArray
[]
Parameters
Name | Type |
---|---|
mph | HashProps | MintingPolicyHash |
Returns
getTokens
▸ getTokens(mph
): [ByteArray
, HInt
][]
Returns empty if mph not found
Parameters
Name | Type |
---|---|
mph | MintingPolicyHash |
Returns
gt
▸ gt(other
): boolean
Strict gt, if other contains assets this one doesn't contain => return false
Parameters
Name | Type |
---|---|
other | Assets |
Returns
boolean
has
▸ has(mph
, tokenName
): boolean
Parameters
Name | Type |
---|---|
mph | HashProps | MintingPolicyHash |
tokenName | ByteArray | ByteArrayProps |
Returns
boolean
isZero
▸ isZero(): boolean
Returns
boolean
mul
▸ mul(scalar
): Assets
Parameters
Returns
normalize
▸ normalize(): void
Removes zeros and merges duplicates. In-place algorithm. Keeps the same order as much as possible.
Returns
void
removeZeroes
▸ removeZeroes(): void
Mutates 'this'
Returns
void
sort
▸ sort(): void
Makes sure minting policies are in correct order, and for each minting policy make sure the tokens are in the correct order Mutates 'this'
Returns
void
sub
▸ sub(other
): Assets
Parameters
Name | Type |
---|---|
other | Assets |
Returns
toCbor
▸ toCbor(): number
[]
Returns
number
[]
Inherited from
toCborHex
▸ toCborHex(): string
Returns
string
Inherited from
fromCbor
▸ Static
fromCbor(bytes
): Assets
Parameters
Name | Type |
---|---|
bytes | number [] |
Returns
fromProps
▸ Static
fromProps(props
): Assets
Parameters
Name | Type |
---|---|
props | Assets | AssetsProps |