@hyperionbt/helios
Advanced tools
Comparing version 0.13.8 to 0.13.9
{ | ||
"name": "@hyperionbt/helios", | ||
"type": "module", | ||
"version": "0.13.8", | ||
"version": "0.13.9", | ||
"description": "Helios is a Domain Specific Language that compiles to Plutus-Core (i.e. Cardano on-chain validator scripts). Helios is a non-Haskell alternative to Plutus. With this library you can compile Helios scripts and build Cardano transactions, all you need to build 100% client-side DApps for Cardano.", | ||
@@ -6,0 +6,0 @@ "main": "helios.js", |
@@ -1822,2 +1822,5 @@ //@ts-check | ||
this.#assets.push([mph, tokens.slice()]); | ||
// sort immediately | ||
this.sort(); | ||
} | ||
@@ -2048,2 +2051,12 @@ | ||
} | ||
assertSorted() { | ||
this.#assets.forEach((b, i) => { | ||
if (i > 0) { | ||
const a = this.#assets[i-1]; | ||
assert(Hash.compare(a[0], b[0]) == -1, "assets not sorted") | ||
} | ||
}) | ||
} | ||
} | ||
@@ -2050,0 +2063,0 @@ |
@@ -163,3 +163,4 @@ #!/usr/bin/env node | ||
Tx: Tx, | ||
TxBody: TxBody, | ||
TxInput: TxInput, | ||
TxBody: TxBody | ||
};` | ||
@@ -166,0 +167,0 @@ } |
@@ -322,2 +322,4 @@ //@ts-check | ||
* Bytearray comparison, which can be used for sorting bytearrays | ||
* @example | ||
* ByteArrayData.comp(hexToBytes("0101010101010101010101010101010101010101010101010101010101010101"), hexToBytes("0202020202020202020202020202020202020202020202020202020202020202")) => -1 | ||
* @param {number[]} a | ||
@@ -324,0 +326,0 @@ * @param {number[]} b |
@@ -566,2 +566,41 @@ #!/usr/bin/env node | ||
async function sortInputs() { | ||
const input1 = new helios.UTxO( | ||
new helios.TxId("a66564e90416a3c3ed89350108799ab122bdbfd098624d0f43f955207ace8eda"), | ||
1n, | ||
new helios.TxOutput( | ||
new helios.Address("addr_test1wpcwnce7k66ldmduhkqdrgamxmnytekhr2hyp8ncsdcg0aqufrga4"), | ||
new helios.Value(2000000n, new helios.Assets([[ | ||
"324bcb5a0968a69ddc8c6b12bbd0d301d166852f23deb3e88bc2891d", [["304b61747a", 1n]] | ||
]])) | ||
) | ||
); | ||
const input2 = new helios.UTxO( | ||
new helios.TxId("fed1bb855c77efd1fa209a1b35c447b13d4b09671f7d682263b9f3af1089f58c"), | ||
1n, | ||
new helios.TxOutput( | ||
new helios.Address("addr_test1qruk42fdnsvvyuha6z23dagxq5966h68ta8d42cdsa6e05muqmq4j86269r4ckhjsvmapapl24fazrtl22yg9sn9pvfsz4vr2h"), | ||
new helios.Value(1172320n, new helios.Assets([[ | ||
"5e2f416b455dc4e5f9a7c7e58919e9a12a1db15e14ed08f8776b7594", [["48656c6c6f20776f726c6421", 1n]] | ||
]])) | ||
) | ||
); | ||
const input3 = new helios.UTxO( | ||
new helios.TxId("45991e08acd7be985161ddc58a3fd5885221d4a4b8a65d1e9f0c6af4f38efe22"), | ||
1n, | ||
new helios.TxOutput( | ||
new helios.Address("addr_test1qruk42fdnsvvyuha6z23dagxq5966h68ta8d42cdsa6e05muqmq4j86269r4ckhjsvmapapl24fazrtl22yg9sn9pvfsz4vr2h"), | ||
new helios.Value(6846240194n) | ||
) | ||
); | ||
const inputs = [input1, input2, input3]; | ||
inputs.sort((a, b) => helios_.TxInput.comp(a.asTxInput, b.asTxInput)); | ||
console.log(inputs.map(i => i.txId.hex)); | ||
} | ||
export default async function main() { | ||
@@ -597,4 +636,6 @@ await assetsCompare(); | ||
await testEmulatorPrivateKeyGen(); | ||
await sortInputs(); | ||
} | ||
runIfEntryPoint(main, "tx-building.js"); |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
4824914
90784