diff --git a/CHANGELOG.md b/CHANGELOG.md index 12f5fce..83df831 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,8 @@ +# v0.3.4 + +- Improved the counting functions to account for datum hashes. +- Improved documentation. + # v0.3.3 - Added arithmetic circuit and boolean logic diff --git a/aiken.toml b/aiken.toml index 6e07713..6413967 100644 --- a/aiken.toml +++ b/aiken.toml @@ -1,5 +1,5 @@ name = "aiken-lang/assist" -version = "0.3.3" +version = "0.3.4" license = "Apache-2.0" description = "Aiken Assist Library" diff --git a/docs/assist/addresses.html b/docs/assist/addresses.html index d62baac..f602804 100644 --- a/docs/assist/addresses.html +++ b/docs/assist/addresses.html @@ -120,13 +120,13 @@

assist - v0.3.3 + v0.3.4 - + - + \ No newline at end of file diff --git a/docs/assist/boolean.html b/docs/assist/boolean.html index 621cfb2..c3e6745 100644 --- a/docs/assist/boolean.html +++ b/docs/assist/boolean.html @@ -120,13 +120,13 @@

assist - v0.3.3 + v0.3.4 - + - + \ No newline at end of file diff --git a/docs/assist/certificates.html b/docs/assist/certificates.html index 258d33e..fc7e5e7 100644 --- a/docs/assist/certificates.html +++ b/docs/assist/certificates.html @@ -120,13 +120,13 @@

assist - v0.3.3 + v0.3.4 - + - + \ No newline at end of file diff --git a/docs/assist/circuits.html b/docs/assist/circuits.html index 4b4ecfa..c7710b6 100644 --- a/docs/assist/circuits.html +++ b/docs/assist/circuits.html @@ -120,13 +120,13 @@

assist - v0.3.3 + v0.3.4 - + - + \ No newline at end of file diff --git a/docs/assist/count.html b/docs/assist/count.html index b7fdf19..6ec978a 100644 --- a/docs/assist/count.html +++ b/docs/assist/count.html @@ -120,13 +120,13 @@

assist - v0.3.3 + v0.3.4 - + - + \ No newline at end of file diff --git a/docs/assist/credentials.html b/docs/assist/credentials.html index a1f6fa6..5716998 100644 --- a/docs/assist/credentials.html +++ b/docs/assist/credentials.html @@ -120,13 +120,13 @@

assist - v0.3.3 + v0.3.4 - + - + \ No newline at end of file diff --git a/docs/assist/data.html b/docs/assist/data.html index 36ebb90..a4ae110 100644 --- a/docs/assist/data.html +++ b/docs/assist/data.html @@ -120,13 +120,13 @@

assist - v0.3.3 + v0.3.4 - + - + \ No newline at end of file diff --git a/docs/assist/find.html b/docs/assist/find.html index 4e16a63..b423290 100644 --- a/docs/assist/find.html +++ b/docs/assist/find.html @@ -120,13 +120,13 @@

assist - v0.3.3 + v0.3.4 - + - + \ No newline at end of file diff --git a/docs/assist/maths.html b/docs/assist/maths.html index 55784fb..1616639 100644 --- a/docs/assist/maths.html +++ b/docs/assist/maths.html @@ -120,13 +120,13 @@

assist - v0.3.3 + v0.3.4 - + - + \ No newline at end of file diff --git a/docs/assist/minting.html b/docs/assist/minting.html index 2fbe192..1aabec5 100644 --- a/docs/assist/minting.html +++ b/docs/assist/minting.html @@ -120,13 +120,13 @@

assist - v0.3.3 + v0.3.4 - + - + \ No newline at end of file diff --git a/docs/assist/payout.html b/docs/assist/payout.html index d18fcab..e7a3cc7 100644 --- a/docs/assist/payout.html +++ b/docs/assist/payout.html @@ -120,13 +120,13 @@

assist - v0.3.3 + v0.3.4 - + - + \ No newline at end of file diff --git a/docs/assist/prefixes.html b/docs/assist/prefixes.html index 9d3b92e..aabd742 100644 --- a/docs/assist/prefixes.html +++ b/docs/assist/prefixes.html @@ -120,13 +120,13 @@

assist - v0.3.3 + v0.3.4 - + - + \ No newline at end of file diff --git a/docs/assist/signing.html b/docs/assist/signing.html index 7ab7737..499a596 100644 --- a/docs/assist/signing.html +++ b/docs/assist/signing.html @@ -120,13 +120,13 @@

assist - v0.3.3 + v0.3.4 - + - + \ No newline at end of file diff --git a/docs/assist/std.html b/docs/assist/std.html index dbb6ca2..00e13ce 100644 --- a/docs/assist/std.html +++ b/docs/assist/std.html @@ -120,13 +120,13 @@

assist - v0.3.3 + v0.3.4 - + - + \ No newline at end of file diff --git a/docs/assist/values.html b/docs/assist/values.html index e092c09..81e89d7 100644 --- a/docs/assist/values.html +++ b/docs/assist/values.html @@ -120,13 +120,13 @@

assist - v0.3.3 + v0.3.4 - + - + \ No newline at end of file diff --git a/docs/index.html b/docs/index.html index a9b0b86..96fe216 100644 --- a/docs/index.html +++ b/docs/index.html @@ -120,13 +120,13 @@

assist - v0.3.3 + v0.3.4 - + - + \ No newline at end of file diff --git a/docs/search-data.js b/docs/search-data.js index 1baf286..f088040 100644 --- a/docs/search-data.js +++ b/docs/search-data.js @@ -1 +1 @@ -window.Aiken.initSearch([{"doc":"assist/count","title":"inputs_by_addr","content":"inputs_by_addr(inputs: List<Input>, addr: Address, amount: Int) -> Bool\n Verify that the number of inputs from a specific script is equal to the\n amount intended in the contract. The amount must be exactly the counter.\n\n ```aiken\n count.inputs_by_addr(tx.inputs, this_addr, 1)\n ```","url":"assist/count.html#inputs_by_addr"},{"doc":"assist/count","title":"inputs_by_datum","content":"inputs_by_datum(inputs: List<Input>, amount: Int) -> Bool\n Verify that the number of inputs with an inline datum is equal to the\n number intended in the contract. The amount must be exactly the counter.\n\n ```aiken\n count.inputs_by_datum(tx.inputs, 1)\n ```","url":"assist/count.html#inputs_by_datum"},{"doc":"assist/count","title":"outputs_by_addr","content":"outputs_by_addr(outputs: List<Output>, addr: Address, amount: Int) -> Bool\n Verify that the number of outputs from a specific script is equal the amount\n intended in the contract. The amount must be exact with the counter.\n\n ```aiken\n count.outputs_by_addr(tx.outputs, this_addr, 1)\n ```","url":"assist/count.html#outputs_by_addr"},{"doc":"assist/count","title":"outputs_by_datum","content":"outputs_by_datum(outputs: List<Output>, amount: Int) -> Bool\n Verify that the number of outputs with an inline datum is equal to the\n number intended in the contract. The amount must be exactly the counter.\n\n ```aiken\n count.outputs_by_datum(tx.outputs, 1)\n ```","url":"assist/count.html#outputs_by_datum"},{"doc":"assist/count","title":"assist/count","content":" This module contains code to accurately count the number of inputs and\n outputs in a transaction for a specific address, assuming precise amounts.\n","url":"assist/count.html"},{"doc":"assist/addresses","title":"create_address","content":"create_address(\n pkh: Hash<Blake2b_224, VerificationKey>,\n sc: Hash<Blake2b_224, VerificationKey>,\n) -> Address\n Creates a enterprise or base address from the public key hash and stake\n credential. An empty sc means enterpise address by default.\n\n ```aiken\n addresses.create_address(datum.wallet.pkh, datum.wallet.sc)\n ```","url":"assist/addresses.html#create_address"},{"doc":"assist/addresses","title":"create_script_address","content":"create_script_address(\n pkh: Hash<Blake2b_224, Script>,\n sc: Hash<Blake2b_224, Script>,\n) -> Address\n Creates a script address for a smart contract. The type does not mix address\n types. Staked smart contracts are contracts as well. An empty sc is\n assumed to be not staked.\n\n ```aiken\n addresses.create_script_address(datum.script.pkh, datum.script.sc)\n ```","url":"assist/addresses.html#create_script_address"},{"doc":"assist/addresses","title":"assist/addresses","content":" This module incorporates code for generating valid wallet and script \n addresses, ensuring their correctness. Empty keys are treated as \n intentional, and address subtypes are not combined or mixed.\n","url":"assist/addresses.html"},{"doc":"assist/std","title":"out_ref","content":"out_ref(tx_id_hash: ByteArray, idx: Int) -> OutputReference\n Create an `OutputReference` from the `TxId#Idx` information. This is useful\n for building correct output references of specific UTxOs. It can be combined\n with the `find` module for some very convenient requests.\n\n ```aiken\n std.out_ref(that_tx_id, that_tx_idx)\n ```","url":"assist/std.html#out_ref"},{"doc":"assist/std","title":"assist/std","content":" This module incorporates additional code that expands the\n functionality of the standard library.\n","url":"assist/std.html"},{"doc":"assist/boolean","title":"and_","content":"and_(x: Int, y: Int) -> Int\n Performs a logical AND operation on two integer values.\n Expects both inputs as binary (0 or 1) and returns 1 if both are 1, otherwise returns 0.\n\n ```aiken\n boolean.and_(1, 1)\n ```","url":"assist/boolean.html#and_"},{"doc":"assist/boolean","title":"imply_","content":"imply_(x: Int, y: Int) -> Int\n Performs a logical implication operation on two integer values.\n Returns 1 if the first input is false or both inputs are true, otherwise returns 0.\n \n ```aiken\n boolean.imply_(1, 0)\n ```","url":"assist/boolean.html#imply_"},{"doc":"assist/boolean","title":"nand_","content":"nand_(x: Int, y: Int) -> Int\n Performs a logical NAND operation on two integer values.\n Returns 1 if at least one input is 0, otherwise returns 0.\n \n ```aiken\n boolean.nand_(1, 1)\n ```","url":"assist/boolean.html#nand_"},{"doc":"assist/boolean","title":"nor_","content":"nor_(x: Int, y: Int) -> Int\n Performs a logical NOR operation on two integer values.\n Returns 1 if both inputs are 0, otherwise returns 0.\n \n ```aiken\n boolean.nor_(0, 0)\n ```","url":"assist/boolean.html#nor_"},{"doc":"assist/boolean","title":"not_","content":"not_(x: Int) -> Int\n Performs a logical NOT operation on an integer value.\n Expects the input as binary (0 or 1) and returns the inverse (1 becomes 0, 0 becomes 1).\n\n ```aiken\n boolean.not_(1)\n ```","url":"assist/boolean.html#not_"},{"doc":"assist/boolean","title":"or_","content":"or_(x: Int, y: Int) -> Int\n Performs a logical OR operation on two integer values.\n Expects both inputs as binary (0 or 1) and returns 1 if at least one input is 1, otherwise returns 0.\n \n ```aiken\n boolean.or_(0, 1)\n ```","url":"assist/boolean.html#or_"},{"doc":"assist/boolean","title":"xnor_","content":"xnor_(x: Int, y: Int) -> Int\n Performs a logical XNOR operation on two integer values.\n Returns 1 if the inputs are the same, otherwise returns 0.\n \n ```aiken\n boolean.xnor_(1, 1)\n ```","url":"assist/boolean.html#xnor_"},{"doc":"assist/boolean","title":"xor_","content":"xor_(x: Int, y: Int) -> Int\n Performs a logical XOR operation on two integer values.\n Expects both inputs as binary (0 or 1) and returns 1 if the inputs are different, otherwise returns 0.\n\n ```aiken\n boolean.xor_(0, 1)\n ```","url":"assist/boolean.html#xor_"},{"doc":"assist/boolean","title":"assist/boolean","content":" This module contains code to do boolean logic on integers.\n Boolean logic here is the special case of arithmetic circuit logic with p = 2.\n","url":"assist/boolean.html"},{"doc":"assist/payout","title":"at_least","content":"at_least(\n payout_address: Address,\n payout_value: Value,\n outputs: List<Output>,\n) -> Bool\n Find the first occurrence of an output that contains at least some specific\n value at some address. If nothing is found then return False. This function\n does not search for an exact UTxO match.\n\n ```aiken\n payout.at_least(wallet_addr, just_token_value, tx.outputs)\n ```","url":"assist/payout.html#at_least"},{"doc":"assist/payout","title":"cont","content":"cont(payout_address: Address, outputs: List<Output>) -> Bool\n Find the first occurrence of an output at some address. If nothing is \n found then return False. This function does not search by value.\n\n ```aiken\n payout.cont(that_script_addr, tx.outputs)\n ```","url":"assist/payout.html#cont"},{"doc":"assist/payout","title":"exact","content":"exact(\n payout_address: Address,\n payout_value: Value,\n outputs: List<Output>,\n) -> Bool\n Find the first occurrence of an exact output that matches a specific\n address and value. If nothing is found then return False.\n\n ```aiken\n payout.exact(wallet_addr, validating_value, tx.outputs)\n ```","url":"assist/payout.html#exact"},{"doc":"assist/payout","title":"assist/payout","content":" This module contains code that assists with payout logic. Payout\n functions are designed to return a boolean value instead of an error.\n","url":"assist/payout.html"},{"doc":"tests/fake_tx","title":"test_bad_input","content":"test_bad_input() -> Input\n A fake input without datum used for testing.","url":"tests/fake_tx.html#test_bad_input"},{"doc":"tests/fake_tx","title":"test_bad_out_ref","content":"test_bad_out_ref() -> OutputReference\n Creates an `OutputReference`","url":"tests/fake_tx.html#test_bad_out_ref"},{"doc":"tests/fake_tx","title":"test_bad_output","content":"test_bad_output() -> Output\n A fake output without datum used for testing.","url":"tests/fake_tx.html#test_bad_output"},{"doc":"tests/fake_tx","title":"test_input","content":"test_input() -> Input\n A fake input used for testing.","url":"tests/fake_tx.html#test_input"},{"doc":"tests/fake_tx","title":"test_input_with_datum_hash","content":"test_input_with_datum_hash() -> Input\n A fake input with a datum hash.","url":"tests/fake_tx.html#test_input_with_datum_hash"},{"doc":"tests/fake_tx","title":"test_inputs","content":"test_inputs(amt: Int) -> List<Input>\n A fake input used for testing.","url":"tests/fake_tx.html#test_inputs"},{"doc":"tests/fake_tx","title":"test_out_ref","content":"test_out_ref() -> OutputReference\n Creates an `OutputReference`","url":"tests/fake_tx.html#test_out_ref"},{"doc":"tests/fake_tx","title":"test_output","content":"test_output() -> Output\n A fake output used for testing.","url":"tests/fake_tx.html#test_output"},{"doc":"tests/fake_tx","title":"test_output_with_datum_hash","content":"test_output_with_datum_hash() -> Output\n","url":"tests/fake_tx.html#test_output_with_datum_hash"},{"doc":"tests/fake_tx","title":"test_signatories","content":"test_signatories() -> List<ByteArray>\n A fake list of tx signers","url":"tests/fake_tx.html#test_signatories"},{"doc":"tests/fake_tx","title":"test_tx","content":"test_tx() -> Transaction\n A fake transaction used for testing.","url":"tests/fake_tx.html#test_tx"},{"doc":"tests/fake_tx","title":"DataType","content":"DataType = Data\n A `Data`data type\n","url":"tests/fake_tx.html#DataType"},{"doc":"tests/fake_tx","title":"test_datum","content":"test_datum: ByteArray = #"acabbeeffacecafe"\n A test datum.","url":"tests/fake_tx.html#test_datum"},{"doc":"tests/fake_tx","title":"tests/fake_tx","content":" This is for testing only.\n","url":"tests/fake_tx.html"},{"doc":"assist/credentials","title":"create_stake_credential","content":"create_stake_credential(sc: Hash<Blake2b_224, Script>) -> Referenced<Credential>\n Creates a stake credential from the hex encoding of a stake key.\n This can be used to find the reward amount from the withdrawals \n information inside the transaction of the form Dict<StakeCredential, Int>\n\n ```aiken\n credentials.create_stake_credential(datum.contract_hash)\n ```","url":"assist/credentials.html#create_stake_credential"},{"doc":"assist/credentials","title":"assist/credentials","content":" This module incorporates code for generating valid credentials,\n ensuring their correctness. \n","url":"assist/credentials.html"},{"doc":"assist/minting","title":"by_prefix","content":"by_prefix(\n flat: List<(ByteArray, ByteArray, Int)>,\n pid: ByteArray,\n prefix: ByteArray,\n amt: Int,\n) -> Bool\n This checks if a specific policy id, prefix, and amount exist inside\n the flattened exact value. Instead of searching for exact match, it\n checks if the token name has the correct prefix. This works if\n every token name on the policy id is unique. If found then it returns\n True else False.\n\n ```aiken\n minting.by_prefix(flatten_mint_value, pid, tkn, 1)\n ```","url":"assist/minting.html#by_prefix"},{"doc":"assist/minting","title":"exact","content":"exact(\n flat: List<(ByteArray, ByteArray, Int)>,\n pid: ByteArray,\n tkn: ByteArray,\n amt: Int,\n) -> Bool\n This checks if a specific policy id, token name, and amount exist inside\n the flattened exact value. It is searching for an exact match. If found\n then it returns True else False.\n\n ```aiken\n minting.exact(flatten_mint_value, pid, tkn, 1)\n ```","url":"assist/minting.html#exact"},{"doc":"assist/minting","title":"is_occurring","content":"is_occurring(\n flat: List<(ByteArray, ByteArray, Int)>,\n pid: ByteArray,\n tkn: ByteArray,\n) -> Bool\n Prove that a transaction is minting something from a specific policy id \n and token name but the amount does not matter. This is great for lock-n-mint\n style contracts where some logic just needs to check if a mint is occuring\n but not the specifics of the amount being minted or burned. If a mint is\n occurring then it will return True else False.\n\n ```aiken\n minting.is_occurring(flatten_mint_value, pid, tkn)\n ```","url":"assist/minting.html#is_occurring"},{"doc":"assist/minting","title":"assist/minting","content":"","url":"assist/minting.html"},{"doc":"assist/values","title":"compute_hash","content":"compute_hash(target: Value) -> ByteArray\n Compute the sha3_256 hash of a value by merklizing the policy id, asset\n name, and quantity. Empty values return the empty by string.\n\n ```aiken\n values.compute_hash(validating_value)\n ```","url":"assist/values.html#compute_hash"},{"doc":"assist/values","title":"contains","content":"contains(target: Value, total: Value) -> Bool\n Prove that the target value is contained inside another value. Each token\n inside the target must exist inside the total value. The quantity of each\n token must be at least the target amount or greater.\n\n ```aiken\n values.contains(payment_value, output_value)\n ```","url":"assist/values.html#contains"},{"doc":"assist/values","title":"multiply","content":"multiply(val: Value, n: Int) -> Value\n Multiply some value by `n`. This is just a linear scaling to the quantity\n of each token.\n\n ```aiken\n values.multiply(bundle_value, bundle_size)\n ```","url":"assist/values.html#multiply"},{"doc":"assist/values","title":"prove_exact_nft","content":"prove_exact_nft(\n nft_pid: PolicyId,\n nft_tkn: AssetName,\n total_value: Value,\n) -> Bool\n Proves that inside some value there is a policy id with token\n name that has a quantity of 1. This will show that a value contains an\n NFT or something that is nft-like. Should be useful to prove that\n something is holding a token inside a transaction when the policy id and\n token name is known.\n\n ```aiken\n values.prove_exact_nft(pid, tkn, that_value)\n ```","url":"assist/values.html#prove_exact_nft"},{"doc":"assist/values","title":"prove_nft","content":"prove_nft(pid: PolicyId, total: Value) -> Bool\n Proves that inside some value there is a policy id with a single token\n name that has a quantity of 1. This will show that a value contains an\n NFT or something that is nft-like. Should be useful to prove that\n something is holding a token inside a transaction when the token name\n is assumed to be unique.\n\n ```aiken\n values.prove_nft(pid, this_value)\n ```","url":"assist/values.html#prove_nft"},{"doc":"assist/values","title":"total_token_amount","content":"total_token_amount(\n inputs: List<Input>,\n pid: PolicyId,\n tkn: AssetName,\n counter: Int,\n) -> Int\n Calculate the total amount of a token within the set of inputs for the \n transaction. This function is useful when needing to get a total amount\n of one token inside a given transaction, like estimating if a threshold\n has been met.\n\n ```aiken\n values.total_token_amount(tx.inputs, datum.pid, datum.tkn, 0)\n ```","url":"assist/values.html#total_token_amount"},{"doc":"assist/values","title":"unique_token_name","content":"unique_token_name(txid: ByteArray, idx: Int, prefix: ByteArray) -> ByteArray\n Calculate a unique token name from a `TxId#Idx` and prefix. Can be combined\n with the `find` module to create unique token names from the first input\n utxo inside the transaction.\n\n ```aiken\n values.unique_token_name(tx_id, tx_idx, prefixes.prefix_333)\n ```","url":"assist/values.html#unique_token_name"},{"doc":"assist/values","title":"assist/values","content":" This module contains code that aids in various value \n manipulations and comparisons.\n","url":"assist/values.html"},{"doc":"assist/certificates","title":"create_credential_delegation","content":"create_credential_delegation(\n sc: Hash<Blake2b_224, Script>,\n pool_id: PoolId,\n) -> Certificate\n Creates a credential delegation for changing the location of the stake.\n This certificate can be used to check if stake is being delegated to\n a specific pool.\n\n ```aiken\n certificates.create_credential_delegation(datum.contract_hash, datum.pool_id)\n ```","url":"assist/certificates.html#create_credential_delegation"},{"doc":"assist/certificates","title":"assist/certificates","content":"","url":"assist/certificates.html"},{"doc":"assist/circuits","title":"and_","content":"and_(x: Int, y: Int, p: Int) -> Int\n Performs a logical AND operation on two integer values within an arithmetic circuit.\n\n ```aiken\n circuits.and_(1, 1, p)\n ```","url":"assist/circuits.html#and_"},{"doc":"assist/circuits","title":"imply_","content":"imply_(x: Int, y: Int, p: Int) -> Int\n Performs a logical implication operation on two integer values within an arithmetic circuit.\n \n ```aiken\n circuits.imply_(1, 0, p)\n ```","url":"assist/circuits.html#imply_"},{"doc":"assist/circuits","title":"nand_","content":"nand_(x: Int, y: Int, p: Int) -> Int\n Performs a logical NAND operation on two integer values within an arithmetic circuit.\n \n ```aiken\n circuits.nand_(1, 1, p)\n ```","url":"assist/circuits.html#nand_"},{"doc":"assist/circuits","title":"nor_","content":"nor_(x: Int, y: Int, p: Int) -> Int\n Performs a logical NOR operation on two integer values within an arithmetic circuit.\n \n ```aiken\n circuits.nor_(0, 0, p)\n ```","url":"assist/circuits.html#nor_"},{"doc":"assist/circuits","title":"not_","content":"not_(x: Int, p: Int) -> Int\n Performs a logical NOT operation on an integer value within an arithmetic circuit.\n\n ```aiken\n circuits.not_(1, p)\n ```","url":"assist/circuits.html#not_"},{"doc":"assist/circuits","title":"or_","content":"or_(x: Int, y: Int, p: Int) -> Int\n Performs a logical OR operation on two integer values within an arithmetic circuit..\n \n ```aiken\n circuits.or_(0, 1, p)\n ```","url":"assist/circuits.html#or_"},{"doc":"assist/circuits","title":"xnor_","content":"xnor_(x: Int, y: Int, p: Int) -> Int\n Performs a logical XNOR operation on two integer values within an arithmetic circuit.\n \n ```aiken\n circuits.xnor_(1, 1, p)\n ```","url":"assist/circuits.html#xnor_"},{"doc":"assist/circuits","title":"xor_","content":"xor_(x: Int, y: Int, p: Int) -> Int\n Performs a logical XOR operation on two integer values within an arithmetic circuit.\n\n ```aiken\n circuits.xor_(0, 1, p)\n ```","url":"assist/circuits.html#xor_"},{"doc":"assist/circuits","title":"assist/circuits","content":" This module contains code to do arithmetic circuit logic on integers.\n All values are assumed to be positive and p is a prime.\n","url":"assist/circuits.html"},{"doc":"assist/maths","title":"base_q","content":"base_q(n: Int, q: Int) -> List<Int>\n Convert a integer `n` into some base `q`. This method\n should scale with any integer and any logical base.\n\n ```aiken\n maths.base_q(123, 7)\n ```","url":"assist/maths.html#base_q"},{"doc":"assist/maths","title":"decay","content":"decay(start_amt: Int, scale: Int, num: Int) -> Int\n Decay some starting amount logarithmically until zero. The function evaluates\n `y = a - log(n)` and when `n >= 2^a` the function equals zero but will return\n zero whenever the result is less than the scale. This is a great\n way to reduce some integer amount of something over time by incrementing `n`.\n\n ```aiken\n maths.decay(start_amount, lovelace_scaling, datum.current_int)\n ```","url":"assist/maths.html#decay"},{"doc":"assist/maths","title":"effective_ratio","content":"effective_ratio(amt: Int, pct: Int, scale: Int) -> Int\n Calculates the ratio of the amount `amt` multiplied by the scale by the\n percentage `pct`. The scale allows for finer calculations.\n\n ```aiken\n maths.effective_ratio(123456789, 40, 1000) == 3086419725\n ```","url":"assist/maths.html#effective_ratio"},{"doc":"assist/maths","title":"from_int","content":"from_int(self: Int) -> ByteArray\n Convert a integer into a hexadecimal bytearray. This works for all integers\n but odd length bytearrays will be prefixed with a zero. This function \n combined with the `to_int` function allows a string to represent a number\n and still be used for calculations, pushing the `2^64 - 1` integer boundary\n to `2^256 - 1`.\n\n ```aiken\n maths.from_int(44203)\n ```","url":"assist/maths.html#from_int"},{"doc":"assist/maths","title":"gcd","content":"gcd(a: Int, b: Int) -> Int\n Computes greatest common divisor of two numbers.\n\n ```aiken\n maths.gcd(20, 15)\n ```","url":"assist/maths.html#gcd"},{"doc":"assist/maths","title":"is_in_range","content":"is_in_range(n: Int, lb: Int, ub: Int) -> Bool\n Verify that some integer `n` is greater than the lower bound, `lb`, and\n less than or equal to the upper bound, `ub`. The function is exclusive\n for `lb` but inclusive for `lb + 1`.\n\n ```aiken\n maths.is_in_range(5, 0, 10)\n ```","url":"assist/maths.html#is_in_range"},{"doc":"assist/maths","title":"legendre_symbol","content":"legendre_symbol(a: Int, p: Int) -> Int\n Calculate the Legendre symbol `(a/p)` using the Euler's criterion.\n This implementation assumes that 'a' and 'p' are positive integers.\n\n ```aiken\n maths.legendre_symbol(10, 19)\n ```","url":"assist/maths.html#legendre_symbol"},{"doc":"assist/maths","title":"list_powmod","content":"list_powmod(lst: List<Int>, g: Int, q: Int) -> Int\n Computes the power mod product of a list of integers.\n\n ```aiken\n maths.list_pow_mod([1,2,3], 2, 19)\n ```","url":"assist/maths.html#list_powmod"},{"doc":"assist/maths","title":"list_product","content":"list_product(lst: List<Int>) -> Int\n Computes the product of a list of integers.\n\n ```aiken\n maths.list_product([1,2,3])\n ```","url":"assist/maths.html#list_product"},{"doc":"assist/maths","title":"list_sum","content":"list_sum(lst: List<Int>) -> Int\n Computes the sum of a list of integers.\n\n ```aiken\n maths.list_sum(list_of_integers)\n ```","url":"assist/maths.html#list_sum"},{"doc":"assist/maths","title":"powmod","content":"powmod(n: Int, e: Int, q: Int) -> Int\n Calculate `n` to the power of `e` modulo `q` using the exponentiation by \n squaring method. At each multiplication a modulo is calculated, allowing\n very large `n` and `e` values.\n\n ```aiken\n maths.powmod(3, 2, 5)\n ```","url":"assist/maths.html#powmod"},{"doc":"assist/maths","title":"ratio","content":"ratio(amt: Int, pct: Int) -> Int\n Calculates the ratio of the amount `amt` by a percentage `pct`. This can\n be used to calculate rough percentages. The function `ratio` is just a \n special case of the effective ratio function. \n\n ```aiken\n maths.ratio(123, 40)\n ```","url":"assist/maths.html#ratio"},{"doc":"assist/maths","title":"scaling","content":"scaling(amt: Int, pct: Int) -> Int\n Find the optimal scaling for a number such that it\n has three trailing zeros. This should be used in combination\n with the effective ratio for optimal calculations.\n\n ```aiken\n maths.scaling(123, 40)\n ```","url":"assist/maths.html#scaling"},{"doc":"assist/maths","title":"to_int","content":"to_int(self: ByteArray) -> Int\n Convert a hexadecimal bytearray into its base 10 representation. This\n only works with even length bytearrays so arbitrary numbers in hexadecimal\n form will not in general work.\n\n ```aiken\n maths.to_int(#"acab")\n ```","url":"assist/maths.html#to_int"},{"doc":"assist/maths","title":"assist/maths","content":" This module incorporates code for various mathematical operations.\n","url":"assist/maths.html"},{"doc":"assist/data","title":"input_datum","content":"input_datum(possible_input: Input) -> Data\n Find the datum data on an input or error. The data is assumed\n to be an inline datum.\n\n ```aiken\n expect datum: Datum = data.input_datum(this_input)\n ```","url":"assist/data.html#input_datum"},{"doc":"assist/data","title":"input_datum_by_hash","content":"input_datum_by_hash(\n possible_input: Input,\n datums: Dict<Hash<Blake2b_256, Data>, Data>,\n) -> Data\n Find the datum data on a input by the datum hash or error. The\n data is assumed to be embedded data and must be referenced by\n its hash.\n\n ```aiken\n expect datum: Datum = data.input_datum_by_hash(this_input, these_datums)\n ```","url":"assist/data.html#input_datum_by_hash"},{"doc":"assist/data","title":"output_datum","content":"output_datum(possible_output: Output) -> Data\n Find the datum data on an output or error. The data is assumed\n to be an inline datum.\n\n ```aiken\n expect datum: Datum = data.output_datum(that_output)\n ```","url":"assist/data.html#output_datum"},{"doc":"assist/data","title":"output_datum_by_hash","content":"output_datum_by_hash(\n possible_output: Output,\n datums: Dict<Hash<Blake2b_256, Data>, Data>,\n) -> Data\n Find the datum data on an output or error. The data is assumed\n to be embedded.\n\n ```aiken\n expect datum: Datum = data.output_datum_by_hash(that_output, these_datums)\n ```","url":"assist/data.html#output_datum_by_hash"},{"doc":"assist/data","title":"assist/data","content":" This module contains code for extracting data from a potential inline \n datum found in either an input or output.\n","url":"assist/data.html"},{"doc":"assist/find","title":"first_input_index","content":"first_input_index(inputs: List<Input>) -> Int\n Find the first input's output reference index.\n Output references have the form `TxId#Idx`, this function\n extracts the `Idx` part. If nothing is found then error.\n\n ```aiken\n find.first_input_index(tx.inputs)\n ```","url":"assist/find.html#first_input_index"},{"doc":"assist/find","title":"first_input_txid","content":"first_input_txid(inputs: List<Input>) -> ByteArray\n Find the first input's output reference transaction id hash.\n Output references have the form `TxId#Idx`, this function\n extracts the `TxId` part. If nothing is found then error.\n\n ```aiken\n find.first_input_txid(tx.inputs)\n ```","url":"assist/find.html#first_input_txid"},{"doc":"assist/find","title":"first_output_datum","content":"first_output_datum(outputs: List<Output>) -> Data\n Find the first output with an inline datum and return the data.\n If nothing is found then error. This works great for tx with a\n single output and datum or where ordering is irrelevant.\n\n ```aiken\n find.first_output_datum(tx.outputs)\n ```","url":"assist/find.html#first_output_datum"},{"doc":"assist/find","title":"input_by_addr","content":"input_by_addr(inputs: List<Input>, addr: Address) -> Input\n Find the first occurrence of an input by a specific address. If nothing\n is found then error. The address here is an exact match, so both the\n pkh and sc need to be correct.\n\n ```aiken\n find.input_by_addr(tx.reference_inputs, ref_addr)\n ```","url":"assist/find.html#input_by_addr"},{"doc":"assist/find","title":"input_by_ref","content":"input_by_ref(inputs: List<Input>, out_ref: OutputReference) -> Input\n Find an input by an output reference. If nothing is found then error. \n Similar to the builtin function in stdlib but auto errors instead of\n returning an `Option`.\n\n ```aiken\n find.input_by_ref(tx.inputs, out_ref)\n ```","url":"assist/find.html#input_by_ref"},{"doc":"assist/find","title":"output_by_addr","content":"output_by_addr(outputs: List<Output>, addr: Address) -> Output\n Find the first occurrence of an output by a specific address. If nothing\n is found then error. The address here is an exact match.\n\n ```aiken\n find.output_by_addr(tx.outputs, your_address)\n ```","url":"assist/find.html#output_by_addr"},{"doc":"assist/find","title":"output_by_addr_value","content":"output_by_addr_value(\n outputs: List<Output>,\n addr: Address,\n value: Value,\n) -> Output\n Return the first occurrence of an output that contains at least some specific\n value at some address. If nothing is found then error. This function\n does not search for an exact UTxO match.\n\n ```aiken\n find.output_by_addr_value(tx.outputs, wallet_addr, just_token_value)\n ```","url":"assist/find.html#output_by_addr_value"},{"doc":"assist/find","title":"output_by_value","content":"output_by_value(outputs: List<Output>, value: Value) -> Output\n Return the first occurrence of an output that contains at least some specific\n value. If nothing is found then error. This function\n does not search for an exact UTxO match.\n\n ```aiken\n find.output_by_value(tx.outputs, just_token_value)\n ```","url":"assist/find.html#output_by_value"},{"doc":"assist/find","title":"output_datum_by_addr","content":"output_datum_by_addr(outputs: List<Output>, addr: Address) -> Data\n Find the first occurence of output datum by some address. If nothing is\n found then error.\n\n ```aiken\n expect datum: Datum = find.output_datum_by_addr(tx.outputs, this_addr)\n ```","url":"assist/find.html#output_datum_by_addr"},{"doc":"assist/find","title":"redeemer_by_ref","content":"redeemer_by_ref(\n redeemers: Dict<ScriptPurpose, Redeemer>,\n out_ref: OutputReference,\n) -> Data\n Find a redeemer data by an output reference. This is good for checking\n if a specific redeemer is being used on some specific UTxO inside \n the transaction.\n\n ```aiken\n find.redeemer_by_ref(tx.redeemers, that_out_ref)\n ```","url":"assist/find.html#redeemer_by_ref"},{"doc":"assist/find","title":"stake_reward_by_sc","content":"stake_reward_by_sc(\n withdraws: Dict<StakeCredential, Int>,\n stake_credential: StakeCredential,\n) -> Int\n Find the staking reward amount in loveace for some stake credential.\n If no rewards are available then error. This is a great method for\n checking on-chain staking rewards and withdrawal validation.\n\n ```aiken\n find.stake_reward_by_sc(tx.withdrawals, datum.wallet.sc)\n ```","url":"assist/find.html#stake_reward_by_sc"},{"doc":"assist/find","title":"assist/find","content":" This module contains code for identifying various aspects of \n a validating transaction.\n","url":"assist/find.html"},{"doc":"assist/signing","title":"verify_multisig","content":"verify_multisig(\n sigs: List<Hash<Blake2b_224, VerificationKey>>,\n vks: List<Hash<Blake2b_224, VerificationKey>>,\n minimum: Int,\n) -> Bool\n This counts the number of signatures inside a transaction that are from \n the list of signers then checks if its at least the minimum amount.\n\n ```aiken\n signing.verify_multisig(context.transaction, lst_of_sigs, sig_threshold)\n ```","url":"assist/signing.html#verify_multisig"},{"doc":"assist/signing","title":"verify_sig","content":"verify_sig(\n vks: List<Hash<Blake2b_224, VerificationKey>>,\n vk: Hash<Blake2b_224, VerificationKey>,\n) -> Bool\n Check if the list of signatures inside a transaction contains the\n verification key.\n\n ```aiken\n signing.verify_sig(context.transaction, wallet_pkh)\n ```","url":"assist/signing.html#verify_sig"},{"doc":"assist/signing","title":"assist/signing","content":" This module contains code for verifying transaction signatures. \n It assumes that all signatures provided are verification keys.\n","url":"assist/signing.html"},{"doc":"assist/prefixes","title":"prefix_100","content":"prefix_100: ByteArray = #"000643b0"\n (100) Reference Token Prefix","url":"assist/prefixes.html#prefix_100"},{"doc":"assist/prefixes","title":"prefix_222","content":"prefix_222: ByteArray = #"000de140"\n (222) Non-Fungible Token Prefix","url":"assist/prefixes.html#prefix_222"},{"doc":"assist/prefixes","title":"prefix_333","content":"prefix_333: ByteArray = #"0014df10"\n (333) Fungible Token Prefix","url":"assist/prefixes.html#prefix_333"},{"doc":"assist/prefixes","title":"prefix_444","content":"prefix_444: ByteArray = #"001bc280"\n (444) Rich-Fungible Token Prefix","url":"assist/prefixes.html#prefix_444"},{"doc":"assist/prefixes","title":"prefix_callable","content":"prefix_callable: ByteArray = #"ca11ab1e"\n Callable Token Prefix","url":"assist/prefixes.html#prefix_callable"},{"doc":"assist/prefixes","title":"prefix_database","content":"prefix_database: ByteArray = #"da7aba5e"\n Database Token Prefix","url":"assist/prefixes.html#prefix_database"},{"doc":"assist/prefixes","title":"assist/prefixes","content":" This module provides the currently accepted token prefixes.\n","url":"assist/prefixes.html"}]); \ No newline at end of file +window.Aiken.initSearch([{"doc":"assist/credentials","title":"create_stake_credential","content":"create_stake_credential(sc: Hash<Blake2b_224, Script>) -> Referenced<Credential>\n Creates a stake credential from the hex encoding of a stake key.\n This can be used to find the reward amount from the withdrawals \n information inside the transaction of the form `Dict<StakeCredential, Int>`.\n\n ```aiken\n credentials.create_stake_credential(datum.contract_hash)\n ```","url":"assist/credentials.html#create_stake_credential"},{"doc":"assist/credentials","title":"assist/credentials","content":" This module incorporates code for generating valid credentials,\n ensuring their correctness. \n","url":"assist/credentials.html"},{"doc":"assist/std","title":"out_ref","content":"out_ref(tx_id_hash: ByteArray, idx: Int) -> OutputReference\n Create an `OutputReference` from the `TxId#Idx` information. This is useful\n for building correct output references of specific UTxOs. It can be combined\n with the `find` module for some very convenient requests.\n\n ```aiken\n std.out_ref(that_tx_id, that_tx_idx)\n ```","url":"assist/std.html#out_ref"},{"doc":"assist/std","title":"assist/std","content":" This module incorporates additional code that expands the\n functionality of the standard library.\n","url":"assist/std.html"},{"doc":"assist/values","title":"compute_hash","content":"compute_hash(target: Value) -> ByteArray\n Compute the sha3_256 hash of a value by merklizing the policy id, asset\n name, and quantity. Empty values return the empty by string.\n\n ```aiken\n values.compute_hash(validating_value)\n ```","url":"assist/values.html#compute_hash"},{"doc":"assist/values","title":"contains","content":"contains(target: Value, total: Value) -> Bool\n Prove that the target value is contained inside another value. Each token\n inside the target must exist inside the total value. The quantity of each\n token must be at least the target amount or greater.\n\n ```aiken\n values.contains(payment_value, output_value)\n ```","url":"assist/values.html#contains"},{"doc":"assist/values","title":"multiply","content":"multiply(val: Value, n: Int) -> Value\n Multiply some value by `n`. This is just a linear scaling to the quantity\n of each token.\n\n ```aiken\n values.multiply(bundle_value, bundle_size)\n ```","url":"assist/values.html#multiply"},{"doc":"assist/values","title":"prove_exact_nft","content":"prove_exact_nft(\n nft_pid: PolicyId,\n nft_tkn: AssetName,\n total_value: Value,\n) -> Bool\n Proves that inside some value there is a policy id with token\n name that has a quantity of 1. This will show that a value contains an\n NFT or something that is nft-like. Should be useful to prove that\n something is holding a token inside a transaction when the policy id and\n token name is known.\n\n ```aiken\n values.prove_exact_nft(pid, tkn, that_value)\n ```","url":"assist/values.html#prove_exact_nft"},{"doc":"assist/values","title":"prove_nft","content":"prove_nft(pid: PolicyId, total: Value) -> Bool\n Proves that inside some value there is a policy id with a single token\n name that has a quantity of 1. This will show that a value contains an\n NFT or something that is nft-like. Should be useful to prove that\n something is holding a token inside a transaction when the token name\n is assumed to be unique.\n\n ```aiken\n values.prove_nft(pid, this_value)\n ```","url":"assist/values.html#prove_nft"},{"doc":"assist/values","title":"total_token_amount","content":"total_token_amount(\n inputs: List<Input>,\n pid: PolicyId,\n tkn: AssetName,\n counter: Int,\n) -> Int\n Calculate the total amount of a token within the set of inputs for the \n transaction. This function is useful when needing to get a total amount\n of one token inside a given transaction, like estimating if a threshold\n has been met.\n\n ```aiken\n values.total_token_amount(tx.inputs, datum.pid, datum.tkn, 0)\n ```","url":"assist/values.html#total_token_amount"},{"doc":"assist/values","title":"unique_token_name","content":"unique_token_name(txid: ByteArray, idx: Int, prefix: ByteArray) -> ByteArray\n Calculate a unique token name from a `TxId#Idx` and prefix. Can be combined\n with the `find` module to create unique token names from the first input\n utxo inside the transaction.\n\n ```aiken\n values.unique_token_name(tx_id, tx_idx, prefixes.prefix_333)\n ```","url":"assist/values.html#unique_token_name"},{"doc":"assist/values","title":"assist/values","content":" This module contains code that aids in various value \n manipulations and comparisons.\n","url":"assist/values.html"},{"doc":"assist/data","title":"input_datum","content":"input_datum(possible_input: Input) -> Data\n Find the datum data on an input or error. The data is assumed\n to be an inline datum.\n\n ```aiken\n expect datum: Datum = data.input_datum(this_input)\n ```","url":"assist/data.html#input_datum"},{"doc":"assist/data","title":"input_datum_by_hash","content":"input_datum_by_hash(\n possible_input: Input,\n datums: Dict<Hash<Blake2b_256, Data>, Data>,\n) -> Data\n Find the datum data on a input by the datum hash or error. The\n data is assumed to be embedded data and must be referenced by\n its hash.\n\n ```aiken\n expect datum: Datum = data.input_datum_by_hash(this_input, these_datums)\n ```","url":"assist/data.html#input_datum_by_hash"},{"doc":"assist/data","title":"output_datum","content":"output_datum(possible_output: Output) -> Data\n Find the datum data on an output or error. The data is assumed\n to be an inline datum.\n\n ```aiken\n expect datum: Datum = data.output_datum(that_output)\n ```","url":"assist/data.html#output_datum"},{"doc":"assist/data","title":"output_datum_by_hash","content":"output_datum_by_hash(\n possible_output: Output,\n datums: Dict<Hash<Blake2b_256, Data>, Data>,\n) -> Data\n Find the datum data on an output or error. The data is assumed\n to be embedded.\n\n ```aiken\n expect datum: Datum = data.output_datum_by_hash(that_output, these_datums)\n ```","url":"assist/data.html#output_datum_by_hash"},{"doc":"assist/data","title":"assist/data","content":" This module contains code for extracting data from a potential inline \n datum found in either an input or output.\n","url":"assist/data.html"},{"doc":"assist/circuits","title":"and_","content":"and_(x: Int, y: Int, p: Int) -> Int\n Performs a logical `AND` operation on two integer values within an arithmetic circuit.\n\n ```aiken\n circuits.and_(1, 1, p)\n ```","url":"assist/circuits.html#and_"},{"doc":"assist/circuits","title":"imply_","content":"imply_(x: Int, y: Int, p: Int) -> Int\n Performs a logical implication operation on two integer values within an arithmetic circuit.\n \n ```aiken\n circuits.imply_(1, 0, p)\n ```","url":"assist/circuits.html#imply_"},{"doc":"assist/circuits","title":"nand_","content":"nand_(x: Int, y: Int, p: Int) -> Int\n Performs a logical `NAND` operation on two integer values within an arithmetic circuit.\n \n ```aiken\n circuits.nand_(1, 1, p)\n ```","url":"assist/circuits.html#nand_"},{"doc":"assist/circuits","title":"nor_","content":"nor_(x: Int, y: Int, p: Int) -> Int\n Performs a logical `NOR` operation on two integer values within an arithmetic circuit.\n \n ```aiken\n circuits.nor_(0, 0, p)\n ```","url":"assist/circuits.html#nor_"},{"doc":"assist/circuits","title":"not_","content":"not_(x: Int, p: Int) -> Int\n Performs a logical `NOT` operation on an integer value within an arithmetic circuit.\n\n ```aiken\n circuits.not_(1, p)\n ```","url":"assist/circuits.html#not_"},{"doc":"assist/circuits","title":"or_","content":"or_(x: Int, y: Int, p: Int) -> Int\n Performs a logical `OR` operation on two integer values within an arithmetic circuit..\n \n ```aiken\n circuits.or_(0, 1, p)\n ```","url":"assist/circuits.html#or_"},{"doc":"assist/circuits","title":"xnor_","content":"xnor_(x: Int, y: Int, p: Int) -> Int\n Performs a logical `XNOR` operation on two integer values within an arithmetic circuit.\n \n ```aiken\n circuits.xnor_(1, 1, p)\n ```","url":"assist/circuits.html#xnor_"},{"doc":"assist/circuits","title":"xor_","content":"xor_(x: Int, y: Int, p: Int) -> Int\n Performs a logical `XOR` operation on two integer values within an arithmetic circuit.\n\n ```aiken\n circuits.xor_(0, 1, p)\n ```","url":"assist/circuits.html#xor_"},{"doc":"assist/circuits","title":"assist/circuits","content":" This module contains code to do arithmetic circuit logic on integers.\n All values are assumed to be positive and p is a prime.\n","url":"assist/circuits.html"},{"doc":"tests/fake_tx","title":"test_bad_input","content":"test_bad_input() -> Input\n A fake input without datum used for testing.","url":"tests/fake_tx.html#test_bad_input"},{"doc":"tests/fake_tx","title":"test_bad_out_ref","content":"test_bad_out_ref() -> OutputReference\n Creates an `OutputReference`","url":"tests/fake_tx.html#test_bad_out_ref"},{"doc":"tests/fake_tx","title":"test_bad_output","content":"test_bad_output() -> Output\n A fake output without datum used for testing.","url":"tests/fake_tx.html#test_bad_output"},{"doc":"tests/fake_tx","title":"test_input","content":"test_input() -> Input\n A fake input used for testing.","url":"tests/fake_tx.html#test_input"},{"doc":"tests/fake_tx","title":"test_input_with_datum_hash","content":"test_input_with_datum_hash() -> Input\n A fake input with a datum hash.","url":"tests/fake_tx.html#test_input_with_datum_hash"},{"doc":"tests/fake_tx","title":"test_inputs","content":"test_inputs(amt: Int) -> List<Input>\n A fake input used for testing.","url":"tests/fake_tx.html#test_inputs"},{"doc":"tests/fake_tx","title":"test_out_ref","content":"test_out_ref() -> OutputReference\n Creates an `OutputReference`","url":"tests/fake_tx.html#test_out_ref"},{"doc":"tests/fake_tx","title":"test_output","content":"test_output() -> Output\n A fake output used for testing.","url":"tests/fake_tx.html#test_output"},{"doc":"tests/fake_tx","title":"test_output_with_datum_hash","content":"test_output_with_datum_hash() -> Output\n","url":"tests/fake_tx.html#test_output_with_datum_hash"},{"doc":"tests/fake_tx","title":"test_signatories","content":"test_signatories() -> List<ByteArray>\n A fake list of tx signers","url":"tests/fake_tx.html#test_signatories"},{"doc":"tests/fake_tx","title":"test_tx","content":"test_tx() -> Transaction\n A fake transaction used for testing.","url":"tests/fake_tx.html#test_tx"},{"doc":"tests/fake_tx","title":"DataType","content":"DataType = Data\n A `Data`data type\n","url":"tests/fake_tx.html#DataType"},{"doc":"tests/fake_tx","title":"test_datum","content":"test_datum: ByteArray = #"acabbeeffacecafe"\n A test datum.","url":"tests/fake_tx.html#test_datum"},{"doc":"tests/fake_tx","title":"tests/fake_tx","content":" This is for testing only.\n","url":"tests/fake_tx.html"},{"doc":"assist/prefixes","title":"prefix_100","content":"prefix_100: ByteArray = #"000643b0"\n (100) Reference Token Prefix","url":"assist/prefixes.html#prefix_100"},{"doc":"assist/prefixes","title":"prefix_222","content":"prefix_222: ByteArray = #"000de140"\n (222) Non-Fungible Token Prefix","url":"assist/prefixes.html#prefix_222"},{"doc":"assist/prefixes","title":"prefix_333","content":"prefix_333: ByteArray = #"0014df10"\n (333) Fungible Token Prefix","url":"assist/prefixes.html#prefix_333"},{"doc":"assist/prefixes","title":"prefix_444","content":"prefix_444: ByteArray = #"001bc280"\n (444) Rich-Fungible Token Prefix","url":"assist/prefixes.html#prefix_444"},{"doc":"assist/prefixes","title":"prefix_callable","content":"prefix_callable: ByteArray = #"ca11ab1e"\n Callable Token Prefix","url":"assist/prefixes.html#prefix_callable"},{"doc":"assist/prefixes","title":"prefix_database","content":"prefix_database: ByteArray = #"da7aba5e"\n Database Token Prefix","url":"assist/prefixes.html#prefix_database"},{"doc":"assist/prefixes","title":"assist/prefixes","content":" This module provides the currently accepted token prefixes.\n","url":"assist/prefixes.html"},{"doc":"assist/count","title":"inputs_by_addr","content":"inputs_by_addr(inputs: List<Input>, addr: Address, amount: Int) -> Bool\n Verify that the number of inputs from a specific script is equal to the\n amount intended in the contract. The amount must be exactly the counter.\n\n ```aiken\n count.inputs_by_addr(tx.inputs, this_addr, 1)\n ```","url":"assist/count.html#inputs_by_addr"},{"doc":"assist/count","title":"inputs_by_datum","content":"inputs_by_datum(inputs: List<Input>, amount: Int) -> Bool\n Verify that the number of inputs with an inline datum or datum hash is equal to the\n number intended in the contract. The amount must be exactly the counter.\n\n ```aiken\n count.inputs_by_datum(tx.inputs, 1)\n ```","url":"assist/count.html#inputs_by_datum"},{"doc":"assist/count","title":"outputs_by_addr","content":"outputs_by_addr(outputs: List<Output>, addr: Address, amount: Int) -> Bool\n Verify that the number of outputs from a specific script is equal the amount\n intended in the contract. The amount must be exact with the counter.\n\n ```aiken\n count.outputs_by_addr(tx.outputs, this_addr, 1)\n ```","url":"assist/count.html#outputs_by_addr"},{"doc":"assist/count","title":"outputs_by_datum","content":"outputs_by_datum(outputs: List<Output>, amount: Int) -> Bool\n Verify that the number of outputs with an inline datum or datum hash is equal to the\n number intended in the contract. The amount must be exactly the counter.\n\n ```aiken\n count.outputs_by_datum(tx.outputs, 1)\n ```","url":"assist/count.html#outputs_by_datum"},{"doc":"assist/count","title":"assist/count","content":" This module contains code to accurately count the number of inputs and\n outputs in a transaction containing an address or a datum.\n","url":"assist/count.html"},{"doc":"assist/boolean","title":"and_","content":"and_(x: Int, y: Int) -> Int\n Performs a logical `AND` operation on two integer values.\n Expects both inputs as binary (0 or 1) and returns 1 if both are 1, otherwise returns 0.\n\n ```aiken\n boolean.and_(1, 1)\n ```","url":"assist/boolean.html#and_"},{"doc":"assist/boolean","title":"imply_","content":"imply_(x: Int, y: Int) -> Int\n Performs a logical implication operation on two integer values.\n Returns 1 if the first input is false or both inputs are true, otherwise returns 0.\n \n ```aiken\n boolean.imply_(1, 0)\n ```","url":"assist/boolean.html#imply_"},{"doc":"assist/boolean","title":"nand_","content":"nand_(x: Int, y: Int) -> Int\n Performs a logical `NAND` operation on two integer values.\n Returns 1 if at least one input is 0, otherwise returns 0.\n \n ```aiken\n boolean.nand_(1, 1)\n ```","url":"assist/boolean.html#nand_"},{"doc":"assist/boolean","title":"nor_","content":"nor_(x: Int, y: Int) -> Int\n Performs a logical `NOR` operation on two integer values.\n Returns 1 if both inputs are 0, otherwise returns 0.\n \n ```aiken\n boolean.nor_(0, 0)\n ```","url":"assist/boolean.html#nor_"},{"doc":"assist/boolean","title":"not_","content":"not_(x: Int) -> Int\n Performs a logical `NOT` operation on an integer value.\n Expects the input as binary (0 or 1) and returns the inverse (1 becomes 0, 0 becomes 1).\n\n ```aiken\n boolean.not_(1)\n ```","url":"assist/boolean.html#not_"},{"doc":"assist/boolean","title":"or_","content":"or_(x: Int, y: Int) -> Int\n Performs a logical `OR` operation on two integer values.\n Expects both inputs as binary (0 or 1) and returns 1 if at least one input is 1, otherwise returns 0.\n \n ```aiken\n boolean.or_(0, 1)\n ```","url":"assist/boolean.html#or_"},{"doc":"assist/boolean","title":"xnor_","content":"xnor_(x: Int, y: Int) -> Int\n Performs a logical `XNOR` operation on two integer values.\n Returns 1 if the inputs are the same, otherwise returns 0.\n \n ```aiken\n boolean.xnor_(1, 1)\n ```","url":"assist/boolean.html#xnor_"},{"doc":"assist/boolean","title":"xor_","content":"xor_(x: Int, y: Int) -> Int\n Performs a logical `XOR` operation on two integer values.\n Expects both inputs as binary (0 or 1) and returns 1 if the inputs are different, otherwise returns 0.\n\n ```aiken\n boolean.xor_(0, 1)\n ```","url":"assist/boolean.html#xor_"},{"doc":"assist/boolean","title":"assist/boolean","content":" This module contains code to do boolean logic on integers.\n Boolean logic here is the special case of arithmetic circuit logic with p = 2.\n","url":"assist/boolean.html"},{"doc":"assist/signing","title":"verify_multisig","content":"verify_multisig(\n sigs: List<Hash<Blake2b_224, VerificationKey>>,\n vks: List<Hash<Blake2b_224, VerificationKey>>,\n minimum: Int,\n) -> Bool\n This counts the number of signatures inside a transaction that are from \n the list of signers then checks if its at least the minimum amount.\n\n ```aiken\n signing.verify_multisig(context.transaction, lst_of_sigs, sig_threshold)\n ```","url":"assist/signing.html#verify_multisig"},{"doc":"assist/signing","title":"verify_sig","content":"verify_sig(\n vks: List<Hash<Blake2b_224, VerificationKey>>,\n vk: Hash<Blake2b_224, VerificationKey>,\n) -> Bool\n Check if the list of signatures inside a transaction contains the\n verification key.\n\n ```aiken\n signing.verify_sig(context.transaction, wallet_pkh)\n ```","url":"assist/signing.html#verify_sig"},{"doc":"assist/signing","title":"assist/signing","content":" This module contains code for verifying transaction signatures. \n It assumes that all signatures provided are verification keys.\n","url":"assist/signing.html"},{"doc":"assist/minting","title":"by_prefix","content":"by_prefix(\n flat: List<(ByteArray, ByteArray, Int)>,\n pid: ByteArray,\n prefix: ByteArray,\n amt: Int,\n) -> Bool\n This checks if a specific policy id, prefix, and amount exist inside\n the flattened exact value. Instead of searching for exact match, it\n checks if the token name has the correct prefix. This works if\n every token name on the policy id is unique. If found then it returns\n True else False.\n\n ```aiken\n minting.by_prefix(flatten_mint_value, pid, tkn, 1)\n ```","url":"assist/minting.html#by_prefix"},{"doc":"assist/minting","title":"exact","content":"exact(\n flat: List<(ByteArray, ByteArray, Int)>,\n pid: ByteArray,\n tkn: ByteArray,\n amt: Int,\n) -> Bool\n This checks if a specific policy id, token name, and amount exist inside\n the flattened exact value. It is searching for an exact match. If found\n then it returns True else False.\n\n ```aiken\n minting.exact(flatten_mint_value, pid, tkn, 1)\n ```","url":"assist/minting.html#exact"},{"doc":"assist/minting","title":"is_occurring","content":"is_occurring(\n flat: List<(ByteArray, ByteArray, Int)>,\n pid: ByteArray,\n tkn: ByteArray,\n) -> Bool\n Prove that a transaction is minting something from a specific policy id \n and token name but the amount does not matter. This is great for lock-n-mint\n style contracts where some logic just needs to check if a mint is occuring\n but not the specifics of the amount being minted or burned. If a mint is\n occurring then it will return True else False.\n\n ```aiken\n minting.is_occurring(flatten_mint_value, pid, tkn)\n ```","url":"assist/minting.html#is_occurring"},{"doc":"assist/minting","title":"assist/minting","content":" This module incorporates code for various minting and burning validations.\n","url":"assist/minting.html"},{"doc":"assist/addresses","title":"create_address","content":"create_address(\n pkh: Hash<Blake2b_224, VerificationKey>,\n sc: Hash<Blake2b_224, VerificationKey>,\n) -> Address\n Creates a enterprise or base address from the public key hash and stake\n credential. An empty sc means enterpise address by default.\n\n ```aiken\n addresses.create_address(datum.wallet.pkh, datum.wallet.sc)\n ```","url":"assist/addresses.html#create_address"},{"doc":"assist/addresses","title":"create_script_address","content":"create_script_address(\n pkh: Hash<Blake2b_224, Script>,\n sc: Hash<Blake2b_224, Script>,\n) -> Address\n Creates a script address for a smart contract. The type does not mix address\n types. Staked smart contracts are contracts as well. An empty sc is\n assumed to be not staked.\n\n ```aiken\n addresses.create_script_address(datum.script.pkh, datum.script.sc)\n ```","url":"assist/addresses.html#create_script_address"},{"doc":"assist/addresses","title":"assist/addresses","content":" This module incorporates code for generating valid wallet and script \n addresses, ensuring their correctness. Empty keys are treated as \n intentional, and address subtypes are not combined nor mixed.\n","url":"assist/addresses.html"},{"doc":"assist/maths","title":"base_q","content":"base_q(n: Int, q: Int) -> List<Int>\n Convert a integer `n` into some base `q`. This method\n should scale with any integer and any logical base.\n\n ```aiken\n maths.base_q(123, 7)\n ```","url":"assist/maths.html#base_q"},{"doc":"assist/maths","title":"decay","content":"decay(start_amt: Int, scale: Int, num: Int) -> Int\n Decay some starting amount logarithmically until zero. The function evaluates\n `y = a - log(n)` and when `n >= 2^a` the function equals zero but will return\n zero whenever the result is less than the scale. This is a great\n way to reduce some integer amount of something over time by incrementing `n`.\n\n ```aiken\n maths.decay(start_amount, lovelace_scaling, datum.current_int)\n ```","url":"assist/maths.html#decay"},{"doc":"assist/maths","title":"effective_ratio","content":"effective_ratio(amt: Int, pct: Int, scale: Int) -> Int\n Calculates the ratio of the amount `amt` multiplied by the scale by the\n percentage `pct`. The scale allows for finer calculations.\n\n ```aiken\n maths.effective_ratio(123456789, 40, 1000) == 3086419725\n ```","url":"assist/maths.html#effective_ratio"},{"doc":"assist/maths","title":"from_int","content":"from_int(self: Int) -> ByteArray\n Convert a integer into a hexadecimal bytearray. This works for all integers\n but odd length bytearrays will be prefixed with a zero. This function \n combined with the `to_int` function allows a string to represent a number\n and still be used for calculations, pushing the `2^64 - 1` integer boundary.\n\n ```aiken\n maths.from_int(44203)\n ```","url":"assist/maths.html#from_int"},{"doc":"assist/maths","title":"gcd","content":"gcd(a: Int, b: Int) -> Int\n Computes greatest common divisor of two numbers.\n\n ```aiken\n maths.gcd(20, 15)\n ```","url":"assist/maths.html#gcd"},{"doc":"assist/maths","title":"is_in_range","content":"is_in_range(n: Int, lb: Int, ub: Int) -> Bool\n Verify that some integer `n` is greater than the lower bound, `lb`, and\n less than or equal to the upper bound, `ub`. The function is exclusive\n for `lb` but inclusive for `lb + 1`.\n\n ```aiken\n maths.is_in_range(5, 0, 10)\n ```","url":"assist/maths.html#is_in_range"},{"doc":"assist/maths","title":"legendre_symbol","content":"legendre_symbol(a: Int, p: Int) -> Int\n Calculate the Legendre symbol `(a/p)` using the Euler's criterion.\n This implementation assumes that 'a' and 'p' are positive integers.\n\n ```aiken\n maths.legendre_symbol(10, 19)\n ```","url":"assist/maths.html#legendre_symbol"},{"doc":"assist/maths","title":"list_powmod","content":"list_powmod(lst: List<Int>, g: Int, q: Int) -> Int\n Computes the power mod product of a list of integers.\n\n ```aiken\n maths.list_pow_mod([1,2,3], 2, 19)\n ```","url":"assist/maths.html#list_powmod"},{"doc":"assist/maths","title":"list_product","content":"list_product(lst: List<Int>) -> Int\n Computes the product of a list of integers.\n\n ```aiken\n maths.list_product([1,2,3])\n ```","url":"assist/maths.html#list_product"},{"doc":"assist/maths","title":"list_sum","content":"list_sum(lst: List<Int>) -> Int\n Computes the sum of a list of integers.\n\n ```aiken\n maths.list_sum(list_of_integers)\n ```","url":"assist/maths.html#list_sum"},{"doc":"assist/maths","title":"powmod","content":"powmod(n: Int, e: Int, q: Int) -> Int\n Calculate `n` to the power of `e` modulo `q` using the exponentiation by \n squaring method. At each multiplication a modulo is calculated, allowing\n very large `n` and `e` values.\n\n ```aiken\n maths.powmod(3, 2, 5)\n ```","url":"assist/maths.html#powmod"},{"doc":"assist/maths","title":"ratio","content":"ratio(amt: Int, pct: Int) -> Int\n Calculates the ratio of the amount `amt` by a percentage `pct`. This can\n be used to calculate rough percentages. The function `ratio` is just a \n special case of the effective ratio function. \n\n ```aiken\n maths.ratio(123, 40)\n ```","url":"assist/maths.html#ratio"},{"doc":"assist/maths","title":"scaling","content":"scaling(amt: Int, pct: Int) -> Int\n Find the optimal scaling for a number such that it\n has three trailing zeros. This should be used in combination\n with the effective ratio for optimal calculations.\n\n ```aiken\n maths.scaling(123, 40)\n ```","url":"assist/maths.html#scaling"},{"doc":"assist/maths","title":"to_int","content":"to_int(self: ByteArray) -> Int\n Convert a hexadecimal bytearray into its base 10 representation. This\n only works with even length bytearrays so arbitrary numbers in hexadecimal\n form will not in general work.\n\n ```aiken\n maths.to_int(#"acab")\n ```","url":"assist/maths.html#to_int"},{"doc":"assist/maths","title":"assist/maths","content":" This module incorporates code for various mathematical operations.\n","url":"assist/maths.html"},{"doc":"assist/find","title":"first_input_index","content":"first_input_index(inputs: List<Input>) -> Int\n Find the first input's output reference index.\n Output references have the form `TxId#Idx`, this function\n extracts the `Idx` part. If nothing is found then error.\n\n ```aiken\n find.first_input_index(tx.inputs)\n ```","url":"assist/find.html#first_input_index"},{"doc":"assist/find","title":"first_input_txid","content":"first_input_txid(inputs: List<Input>) -> ByteArray\n Find the first input's output reference transaction id hash.\n Output references have the form `TxId#Idx`, this function\n extracts the `TxId` part. If nothing is found then error.\n\n ```aiken\n find.first_input_txid(tx.inputs)\n ```","url":"assist/find.html#first_input_txid"},{"doc":"assist/find","title":"first_output_datum","content":"first_output_datum(outputs: List<Output>) -> Data\n Find the first output with an inline datum and return the data.\n If nothing is found then error. This works great for tx with a\n single output and datum or where ordering is irrelevant.\n\n ```aiken\n find.first_output_datum(tx.outputs)\n ```","url":"assist/find.html#first_output_datum"},{"doc":"assist/find","title":"input_by_addr","content":"input_by_addr(inputs: List<Input>, addr: Address) -> Input\n Find the first occurrence of an input by a specific address. If nothing\n is found then error. The address here is an exact match, so both the\n pkh and sc need to be correct.\n\n ```aiken\n find.input_by_addr(tx.reference_inputs, ref_addr)\n ```","url":"assist/find.html#input_by_addr"},{"doc":"assist/find","title":"input_by_ref","content":"input_by_ref(inputs: List<Input>, out_ref: OutputReference) -> Input\n Find an input by an output reference. If nothing is found then error. \n Similar to the builtin function in stdlib but auto errors instead of\n returning an `Option`.\n\n ```aiken\n find.input_by_ref(tx.inputs, out_ref)\n ```","url":"assist/find.html#input_by_ref"},{"doc":"assist/find","title":"output_by_addr","content":"output_by_addr(outputs: List<Output>, addr: Address) -> Output\n Find the first occurrence of an output by a specific address. If nothing\n is found then error. The address here is an exact match.\n\n ```aiken\n find.output_by_addr(tx.outputs, your_address)\n ```","url":"assist/find.html#output_by_addr"},{"doc":"assist/find","title":"output_by_addr_value","content":"output_by_addr_value(\n outputs: List<Output>,\n addr: Address,\n value: Value,\n) -> Output\n Return the first occurrence of an output that contains at least some specific\n value at some address. If nothing is found then error. This function\n does not search for an exact UTxO match.\n\n ```aiken\n find.output_by_addr_value(tx.outputs, wallet_addr, just_token_value)\n ```","url":"assist/find.html#output_by_addr_value"},{"doc":"assist/find","title":"output_by_value","content":"output_by_value(outputs: List<Output>, value: Value) -> Output\n Return the first occurrence of an output that contains at least some specific\n value. If nothing is found then error. This function\n does not search for an exact UTxO match.\n\n ```aiken\n find.output_by_value(tx.outputs, just_token_value)\n ```","url":"assist/find.html#output_by_value"},{"doc":"assist/find","title":"output_datum_by_addr","content":"output_datum_by_addr(outputs: List<Output>, addr: Address) -> Data\n Find the first occurence of output datum by some address. If nothing is\n found then error.\n\n ```aiken\n expect datum: Datum = find.output_datum_by_addr(tx.outputs, this_addr)\n ```","url":"assist/find.html#output_datum_by_addr"},{"doc":"assist/find","title":"redeemer_by_ref","content":"redeemer_by_ref(\n redeemers: Dict<ScriptPurpose, Redeemer>,\n out_ref: OutputReference,\n) -> Data\n Find a redeemer data by an output reference. This is good for checking\n if a specific redeemer is being used on some specific UTxO inside \n the transaction.\n\n ```aiken\n find.redeemer_by_ref(tx.redeemers, that_out_ref)\n ```","url":"assist/find.html#redeemer_by_ref"},{"doc":"assist/find","title":"stake_reward_by_sc","content":"stake_reward_by_sc(\n withdraws: Dict<StakeCredential, Int>,\n stake_credential: StakeCredential,\n) -> Int\n Find the staking reward amount in loveace for some stake credential.\n If no rewards are available then error. This is a great method for\n checking on-chain staking rewards and withdrawal validation.\n\n ```aiken\n find.stake_reward_by_sc(tx.withdrawals, datum.wallet.sc)\n ```","url":"assist/find.html#stake_reward_by_sc"},{"doc":"assist/find","title":"assist/find","content":" This module contains code for finding various aspects of \n a validating transaction.\n","url":"assist/find.html"},{"doc":"assist/payout","title":"at_least","content":"at_least(\n payout_address: Address,\n payout_value: Value,\n outputs: List<Output>,\n) -> Bool\n Find the first occurrence of an output that contains at least some specific\n value at some address. If nothing is found then return False. This function\n does not search for an exact UTxO match.\n\n ```aiken\n payout.at_least(wallet_addr, just_token_value, tx.outputs)\n ```","url":"assist/payout.html#at_least"},{"doc":"assist/payout","title":"cont","content":"cont(payout_address: Address, outputs: List<Output>) -> Bool\n Find the first occurrence of an output at some address. If nothing is \n found then return False. This function does not search by value.\n\n ```aiken\n payout.cont(that_script_addr, tx.outputs)\n ```","url":"assist/payout.html#cont"},{"doc":"assist/payout","title":"exact","content":"exact(\n payout_address: Address,\n payout_value: Value,\n outputs: List<Output>,\n) -> Bool\n Find the first occurrence of an exact output that matches a specific\n address and value. If nothing is found then return False.\n\n ```aiken\n payout.exact(wallet_addr, validating_value, tx.outputs)\n ```","url":"assist/payout.html#exact"},{"doc":"assist/payout","title":"assist/payout","content":" This module contains code that assists with payout logic. Payout\n functions are designed to return a boolean value instead of an error.\n","url":"assist/payout.html"},{"doc":"assist/certificates","title":"create_credential_delegation","content":"create_credential_delegation(\n sc: Hash<Blake2b_224, Script>,\n pool_id: PoolId,\n) -> Certificate\n Creates a credential delegation for changing the location of the stake.\n This certificate can be used to check if stake is being delegated to\n a specific pool.\n\n ```aiken\n certificates.create_credential_delegation(datum.contract_hash, datum.pool_id)\n ```","url":"assist/certificates.html#create_credential_delegation"},{"doc":"assist/certificates","title":"assist/certificates","content":" This module incorporates code for generating valid certificates,\n ensuring their correctness. \n","url":"assist/certificates.html"}]); \ No newline at end of file diff --git a/docs/tests/fake_tx.html b/docs/tests/fake_tx.html index 171134c..567b8f3 100644 --- a/docs/tests/fake_tx.html +++ b/docs/tests/fake_tx.html @@ -120,13 +120,13 @@

assist - v0.3.3 + v0.3.4 - + - + \ No newline at end of file diff --git a/lib/assist/addresses.ak b/lib/assist/addresses.ak index 3714ad2..24eec96 100644 --- a/lib/assist/addresses.ak +++ b/lib/assist/addresses.ak @@ -1,6 +1,6 @@ //// This module incorporates code for generating valid wallet and script //// addresses, ensuring their correctness. Empty keys are treated as -//// intentional, and address subtypes are not combined or mixed. +//// intentional, and address subtypes are not combined nor mixed. //// use aiken/bytearray diff --git a/lib/assist/boolean.ak b/lib/assist/boolean.ak index a6874af..b71d086 100644 --- a/lib/assist/boolean.ak +++ b/lib/assist/boolean.ak @@ -4,7 +4,7 @@ use assist/circuits -/// Performs a logical AND operation on two integer values. +/// Performs a logical `AND` operation on two integer values. /// Expects both inputs as binary (0 or 1) and returns 1 if both are 1, otherwise returns 0. /// /// ```aiken @@ -30,7 +30,7 @@ test one_one_and() { and_(1, 1) == 1 } -/// Performs a logical OR operation on two integer values. +/// Performs a logical `OR` operation on two integer values. /// Expects both inputs as binary (0 or 1) and returns 1 if at least one input is 1, otherwise returns 0. /// /// ```aiken @@ -56,7 +56,7 @@ test one_one_or() { or_(1, 1) == 1 } -/// Performs a logical NOT operation on an integer value. +/// Performs a logical `NOT` operation on an integer value. /// Expects the input as binary (0 or 1) and returns the inverse (1 becomes 0, 0 becomes 1). /// /// ```aiken @@ -74,7 +74,7 @@ test one_not() { not_(1) == 0 } -/// Performs a logical XOR operation on two integer values. +/// Performs a logical `XOR` operation on two integer values. /// Expects both inputs as binary (0 or 1) and returns 1 if the inputs are different, otherwise returns 0. /// /// ```aiken @@ -100,7 +100,7 @@ test one_one_xor() { xor_(1, 1) == 0 } -/// Performs a logical NAND operation on two integer values. +/// Performs a logical `NAND` operation on two integer values. /// Returns 1 if at least one input is 0, otherwise returns 0. /// /// ```aiken @@ -126,7 +126,7 @@ test one_one_nand() { nand_(1, 1) == 0 } -/// Performs a logical NOR operation on two integer values. +/// Performs a logical `NOR` operation on two integer values. /// Returns 1 if both inputs are 0, otherwise returns 0. /// /// ```aiken @@ -152,7 +152,7 @@ test one_one_nor() { nor_(1, 1) == 0 } -/// Performs a logical XNOR operation on two integer values. +/// Performs a logical `XNOR` operation on two integer values. /// Returns 1 if the inputs are the same, otherwise returns 0. /// /// ```aiken diff --git a/lib/assist/certificates.ak b/lib/assist/certificates.ak index 09b1660..8bffcfe 100644 --- a/lib/assist/certificates.ak +++ b/lib/assist/certificates.ak @@ -1,3 +1,7 @@ +//// This module incorporates code for generating valid certificates, +//// ensuring their correctness. +//// + use aiken/hash.{Blake2b_224, Hash} use aiken/transaction/certificate.{Certificate, CredentialDelegation} use aiken/transaction/credential.{PoolId, Script} diff --git a/lib/assist/circuits.ak b/lib/assist/circuits.ak index 345f42d..64b9df0 100644 --- a/lib/assist/circuits.ak +++ b/lib/assist/circuits.ak @@ -2,10 +2,11 @@ //// All values are assumed to be positive and p is a prime. //// -/// The value must be between [0, p-1]. Sometimes the value is a large negative. -/// It takes the value r and keeps adding p until its greater than zero then -/// finishes by doing value mod p. -/// +// The value must be between [0, p-1]. Sometimes the value is a large negative. +// It takes the value r and keeps adding p until its greater than zero then +// finishes by doing value mod p. +// Internal only +// fn do_pos_shift(r: Int, p: Int) -> Int { if r < 0 { do_pos_shift(r + p, p) @@ -14,7 +15,7 @@ fn do_pos_shift(r: Int, p: Int) -> Int { } } -/// Performs a logical AND operation on two integer values within an arithmetic circuit. +/// Performs a logical `AND` operation on two integer values within an arithmetic circuit. /// /// ```aiken /// circuits.and_(1, 1, p) @@ -61,7 +62,7 @@ test boundary_and() { } } -/// Performs a logical OR operation on two integer values within an arithmetic circuit.. +/// Performs a logical `OR` operation on two integer values within an arithmetic circuit.. /// /// ```aiken /// circuits.or_(0, 1, p) @@ -121,7 +122,7 @@ test same_operands_or() { or_(x, x, p) == x + x - x * x + p } -/// Performs a logical NOT operation on an integer value within an arithmetic circuit. +/// Performs a logical `NOT` operation on an integer value within an arithmetic circuit. /// /// ```aiken /// circuits.not_(1, p) @@ -143,7 +144,7 @@ test not_inversion() { not_(not_(x, p), p) == x } -/// Performs a logical XOR operation on two integer values within an arithmetic circuit. +/// Performs a logical `XOR` operation on two integer values within an arithmetic circuit. /// /// ```aiken /// circuits.xor_(0, 1, p) @@ -168,7 +169,7 @@ test xor_inversion() { xor_(x, x, p) == x + x - 2 * x * x + p } -/// Performs a logical NAND operation on two integer values within an arithmetic circuit. +/// Performs a logical `NAND` operation on two integer values within an arithmetic circuit. /// /// ```aiken /// circuits.nand_(1, 1, p) @@ -208,7 +209,7 @@ test boundary_nand() { } } -/// Performs a logical NOR operation on two integer values within an arithmetic circuit. +/// Performs a logical `NOR` operation on two integer values within an arithmetic circuit. /// /// ```aiken /// circuits.nor_(0, 0, p) @@ -254,7 +255,7 @@ test same_operands_nor() { nor_(x, x, p) == not_(x + x - x * x + p, p) } -/// Performs a logical XNOR operation on two integer values within an arithmetic circuit. +/// Performs a logical `XNOR` operation on two integer values within an arithmetic circuit. /// /// ```aiken /// circuits.xnor_(1, 1, p) diff --git a/lib/assist/count.ak b/lib/assist/count.ak index 7f74deb..b6060b8 100644 --- a/lib/assist/count.ak +++ b/lib/assist/count.ak @@ -1,14 +1,14 @@ //// This module contains code to accurately count the number of inputs and -//// outputs in a transaction for a specific address, assuming precise amounts. +//// outputs in a transaction containing an address or a datum. //// -use aiken/transaction.{InlineDatum, Input, Output} +use aiken/transaction.{DatumHash, InlineDatum, Input, Output} use aiken/transaction/credential.{Address} use assist/addresses // for testing only use tests/fake_tx -/// Verify that the number of inputs with an inline datum is equal to the +/// Verify that the number of inputs with an inline datum or datum hash is equal to the /// number intended in the contract. The amount must be exactly the counter. /// /// ```aiken @@ -18,13 +18,16 @@ pub fn inputs_by_datum(inputs: List, amount: Int) -> Bool { do_inputs_by_datum(inputs, 0) == amount } +// Internal only fn do_inputs_by_datum(inputs: List, counter: Int) -> Int { when inputs is { [input, ..rest] -> when input.output.datum is { // the actual datum value isn't important here InlineDatum(_) -> do_inputs_by_datum(rest, counter + 1) - // only count inline datums + // the actual datum hash isn't important here + DatumHash(_) -> do_inputs_by_datum(rest, counter + 1) + // anything else just keep going _ -> do_inputs_by_datum(rest, counter) } // loop the list @@ -37,11 +40,31 @@ test single_input_datum() { inputs_by_datum(tx.inputs, 1) == True } +test single_input_datum_hash() { + let input = fake_tx.test_input_with_datum_hash() + inputs_by_datum([input], 1) == True +} + +test single_input_with_mixed_datums() { + let input1 = fake_tx.test_input_with_datum_hash() + let input2 = fake_tx.test_input() + inputs_by_datum([input1, input2], 2) == True +} + test not_enough_input_datums() { let tx = fake_tx.test_tx() inputs_by_datum(tx.inputs, 2) == False } +test not_enough_input_datum_hashes() { + let input = fake_tx.test_input_with_datum_hash() + inputs_by_datum([input], 2) == False +} + +test empty_input_datums() { + inputs_by_datum([], 0) == True +} + /// Verify that the number of inputs from a specific script is equal to the /// amount intended in the contract. The amount must be exactly the counter. /// @@ -52,6 +75,7 @@ pub fn inputs_by_addr(inputs: List, addr: Address, amount: Int) -> Bool { do_inputs_by_addr(inputs, addr, 0) == amount } +// Internal only fn do_inputs_by_addr(inputs: List, addr: Address, counter: Int) -> Int { when inputs is { [input, ..rest] -> @@ -83,6 +107,11 @@ test multiple_inputs_by_addr() { inputs_by_addr(tx.inputs, addr, 2) == True } +test empty_input_addr() { + let addr = addresses.create_address(#"acab", #"") + inputs_by_addr([], addr, 0) == True +} + /// Verify that the number of outputs from a specific script is equal the amount /// intended in the contract. The amount must be exact with the counter. /// @@ -97,6 +126,7 @@ pub fn outputs_by_addr( do_outputs_by_addr(outputs, addr, 0) == amount } +// Internal only fn do_outputs_by_addr(outputs: List, addr: Address, counter: Int) -> Int { when outputs is { [output, ..rest] -> @@ -129,7 +159,12 @@ test multiple_outputs_by_addr() { outputs_by_addr(tx.outputs, addr, 2) == True } -/// Verify that the number of outputs with an inline datum is equal to the +test empty_output_addr() { + let addr = addresses.create_address(#"acab", #"") + outputs_by_addr([], addr, 0) == True +} + +/// Verify that the number of outputs with an inline datum or datum hash is equal to the /// number intended in the contract. The amount must be exactly the counter. /// /// ```aiken @@ -139,13 +174,16 @@ pub fn outputs_by_datum(outputs: List, amount: Int) -> Bool { do_outputs_by_datum(outputs, 0) == amount } +// Internal only fn do_outputs_by_datum(outputs: List, counter: Int) -> Int { when outputs is { [output, ..rest] -> when output.datum is { // the actual datum value is not important here InlineDatum(_) -> do_outputs_by_datum(rest, counter + 1) - // only count inline datums + // the actual datum hash is not important here + DatumHash(_) -> do_outputs_by_datum(rest, counter + 1) + // anything else just keep going _ -> do_outputs_by_datum(rest, counter) } // loop entire list then return counter @@ -162,3 +200,23 @@ test not_enough_output_datums() { let tx = fake_tx.test_tx() outputs_by_datum(tx.outputs, 2) == False } + +test single_output_datum_hash() { + let output = fake_tx.test_output_with_datum_hash() + outputs_by_datum([output], 1) == True +} + +test single_output_with_mixed_datums() { + let output1 = fake_tx.test_output_with_datum_hash() + let output2 = fake_tx.test_output() + outputs_by_datum([output1, output2], 2) == True +} + +test not_enough_output_datum_hashes() { + let output = fake_tx.test_output_with_datum_hash() + outputs_by_datum([output], 2) == False +} + +test empty_output_datums() { + outputs_by_datum([], 0) == True +} diff --git a/lib/assist/credentials.ak b/lib/assist/credentials.ak index 1497cc7..7103196 100644 --- a/lib/assist/credentials.ak +++ b/lib/assist/credentials.ak @@ -9,7 +9,7 @@ use aiken/transaction/credential.{ /// Creates a stake credential from the hex encoding of a stake key. /// This can be used to find the reward amount from the withdrawals -/// information inside the transaction of the form Dict +/// information inside the transaction of the form `Dict`. /// /// ```aiken /// credentials.create_stake_credential(datum.contract_hash) diff --git a/lib/assist/find.ak b/lib/assist/find.ak index 6080813..3e66f5b 100644 --- a/lib/assist/find.ak +++ b/lib/assist/find.ak @@ -1,4 +1,4 @@ -//// This module contains code for identifying various aspects of +//// This module contains code for finding various aspects of //// a validating transaction. //// diff --git a/lib/assist/maths.ak b/lib/assist/maths.ak index fb0dff9..383604b 100644 --- a/lib/assist/maths.ak +++ b/lib/assist/maths.ak @@ -60,6 +60,7 @@ pub fn base_q(n: Int, q: Int) -> List { do_base_q(n, q, []) } +// Internal only fn do_base_q(number: Int, base: Int, holder: List) -> List { // if the number or base is zero return the holder list if number == 0 || base == 0 { @@ -108,8 +109,7 @@ test string_to_int() { /// Convert a integer into a hexadecimal bytearray. This works for all integers /// but odd length bytearrays will be prefixed with a zero. This function /// combined with the `to_int` function allows a string to represent a number -/// and still be used for calculations, pushing the `2^64 - 1` integer boundary -/// to `2^256 - 1`. +/// and still be used for calculations, pushing the `2^64 - 1` integer boundary. /// /// ```aiken /// maths.from_int(44203) @@ -431,6 +431,7 @@ test moderate_digit_count() { math.log(123456789, 10) == 9 - 1 } +// Internal only fn calculate_scale( amt: Int, pct: Int, @@ -473,6 +474,7 @@ test zero_calculate_scale() { } // count the number of zeros at the end of a number +// Internal only fn count_zeros(number: Int, counter: Int) -> Int { if number % 10 == 0 { count_zeros(number / 10, counter + 1) diff --git a/lib/assist/minting.ak b/lib/assist/minting.ak index abbb537..83cded5 100644 --- a/lib/assist/minting.ak +++ b/lib/assist/minting.ak @@ -1,3 +1,6 @@ +//// This module incorporates code for various minting and burning validations. +//// + use aiken/bytearray use aiken/transaction/value use assist/prefixes diff --git a/lib/assist/signing.ak b/lib/assist/signing.ak index f68cef2..448405f 100644 --- a/lib/assist/signing.ak +++ b/lib/assist/signing.ak @@ -56,6 +56,7 @@ pub fn verify_multisig( do_multisig(sigs, vks, 0) >= minimum } +// Internal only fn do_multisig( sigs: List>, vks: List>, diff --git a/lib/assist/values.ak b/lib/assist/values.ak index 9191a18..7bae6ef 100644 --- a/lib/assist/values.ak +++ b/lib/assist/values.ak @@ -22,6 +22,7 @@ pub fn multiply(val: Value, n: Int) -> Value { do_multiply(value.zero(), val, n) } +// Internal only fn do_multiply(total: Value, add_val: Value, n: Int) -> Value { // 4 * v = v + v + v + v if n <= 0 { @@ -56,6 +57,7 @@ pub fn contains(target: Value, total: Value) -> Bool { do_contains(flat, total) } +// Internal only fn do_contains(flat: List<(PolicyId, AssetName, Int)>, total: Value) -> Bool { when flat is { [(pid, tkn, amt), ..rest] -> @@ -113,6 +115,7 @@ pub fn compute_hash(target: Value) -> ByteArray { do_compute_hash(flat, #"") } +// Internal only fn do_compute_hash( flat: List<(PolicyId, AssetName, Int)>, total: ByteArray,