@helios-lang/ledger
Advanced tools
Comparing version 0.1.40 to 0.1.41
{ | ||
"name": "@helios-lang/ledger", | ||
"version": "0.1.40", | ||
"version": "0.1.41", | ||
"description": "Ledger types (eg. for building transactions)", | ||
@@ -5,0 +5,0 @@ "main": "src/index.js", |
@@ -7,3 +7,9 @@ import { | ||
} from "@helios-lang/cbor" | ||
import { ByteStream, bytesToHex, toBytes } from "@helios-lang/codec-utils" | ||
import { | ||
ByteStream, | ||
bytesToHex, | ||
compareBytes, | ||
equalsBytes, | ||
toBytes | ||
} from "@helios-lang/codec-utils" | ||
import { blake2b, encodeBech32 } from "@helios-lang/crypto" | ||
@@ -154,2 +160,37 @@ import { ByteArrayData, ConstrData, decodeUplcData } from "@helios-lang/uplc" | ||
/** | ||
* | ||
* @param {AssetClass} a | ||
* @param {AssetClass} b | ||
*/ | ||
static compare(a, b) { | ||
const i = MintingPolicyHash.compare(a.mph, b.mph) | ||
if (i != 0) { | ||
return i | ||
} | ||
return compareBytes(a.tokenName, b.tokenName) | ||
} | ||
/** | ||
* @param {AssetClass} other | ||
* @returns {boolean} | ||
*/ | ||
isEqual(other) { | ||
return ( | ||
this.mph.isEqual(other.mph) && | ||
equalsBytes(this.tokenName, other.tokenName) | ||
) | ||
} | ||
/** | ||
* | ||
* @param {AssetClass} other | ||
* @returns {boolean} | ||
*/ | ||
isGreaterThan(other) { | ||
return AssetClass.compare(this, other) > 0 | ||
} | ||
/** | ||
* Converts an `AssetClass` instance into its CBOR representation. | ||
@@ -156,0 +197,0 @@ * @returns {number[]} |
@@ -63,2 +63,8 @@ /** | ||
/** | ||
* | ||
* @param {AssetClass} a | ||
* @param {AssetClass} b | ||
*/ | ||
static compare(a: AssetClass, b: AssetClass): number; | ||
/** | ||
* @param {MintingPolicyHash<C>} mph - policy with optional context | ||
@@ -82,2 +88,13 @@ * @param {ByteArrayLike} tokenName | ||
/** | ||
* @param {AssetClass} other | ||
* @returns {boolean} | ||
*/ | ||
isEqual(other: AssetClass): boolean; | ||
/** | ||
* | ||
* @param {AssetClass} other | ||
* @returns {boolean} | ||
*/ | ||
isGreaterThan(other: AssetClass): boolean; | ||
/** | ||
* Converts an `AssetClass` instance into its CBOR representation. | ||
@@ -84,0 +101,0 @@ * @returns {number[]} |
Sorry, the diff of this file is not supported yet
698239
20065