diff --git a/CHANGELOG.md b/CHANGELOG.md index 05dc28e..9299fe8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +# v0.2.2 + +Minting functions for exact mints and by_prefix mints. A experimental cip68 prefix has been added to prefixes. + # v0.2.1 CIP68 prefixes have been fixed. The unique token name function still produces correct names but any length checks needs to be adjusted. New prefix length is now 4. diff --git a/aiken.toml b/aiken.toml index d08dd2c..9300c70 100644 --- a/aiken.toml +++ b/aiken.toml @@ -1,5 +1,5 @@ name = "aiken-lang/assist" -version = "0.2.1" +version = "0.2.2" license = "Apache-2.0" description = "Aiken Assist Library" diff --git a/docs/assist/addresses.html b/docs/assist/addresses.html index b5623a8..ad086de 100644 --- a/docs/assist/addresses.html +++ b/docs/assist/addresses.html @@ -120,13 +120,13 @@

assist - v0.2.1 + v0.2.2 - + - + \ No newline at end of file diff --git a/docs/assist/certificates.html b/docs/assist/certificates.html index ebc2aee..39659a0 100644 --- a/docs/assist/certificates.html +++ b/docs/assist/certificates.html @@ -120,13 +120,13 @@

assist - v0.2.1 + v0.2.2 - + - + \ No newline at end of file diff --git a/docs/assist/count.html b/docs/assist/count.html index 03f35f9..c3631b4 100644 --- a/docs/assist/count.html +++ b/docs/assist/count.html @@ -120,13 +120,13 @@

assist - v0.2.1 + v0.2.2 - + - + \ No newline at end of file diff --git a/docs/assist/credentials.html b/docs/assist/credentials.html index 961dca3..637567d 100644 --- a/docs/assist/credentials.html +++ b/docs/assist/credentials.html @@ -120,13 +120,13 @@

assist - v0.2.1 + v0.2.2 - + - + \ No newline at end of file diff --git a/docs/assist/data.html b/docs/assist/data.html index 2127091..97ab55a 100644 --- a/docs/assist/data.html +++ b/docs/assist/data.html @@ -120,13 +120,13 @@

assist - v0.2.1 + v0.2.2 - + - + \ No newline at end of file diff --git a/docs/assist/find.html b/docs/assist/find.html index ea73aad..76fcd0b 100644 --- a/docs/assist/find.html +++ b/docs/assist/find.html @@ -120,13 +120,13 @@

assist - v0.2.1 + v0.2.2 - + - + \ No newline at end of file diff --git a/docs/assist/maths.html b/docs/assist/maths.html index 5dc3da1..96f00fb 100644 --- a/docs/assist/maths.html +++ b/docs/assist/maths.html @@ -120,13 +120,13 @@

assist - v0.2.1 + v0.2.2 - + - + \ No newline at end of file diff --git a/docs/assist/minting.html b/docs/assist/minting.html new file mode 100644 index 0000000..c81341d --- /dev/null +++ b/docs/assist/minting.html @@ -0,0 +1,437 @@ + + + + + + assist/minting - aiken-lang/assist + + + + + + + + + + + + + +
+ + +
+ +

+ assist/minting +

+ + + + + + + +
+

+ Functions +

+ +
+
+

by_prefix(
+  flat: List<(ByteArray, ByteArray, Int)>,
+  pid: ByteArray,
+  prefix: ByteArray,
+  amt: Int,
+) -> Bool

+ + + +
+

This checks if a specific policy id, prefix, and amount exist inside +the flattened exact value. Instead of searching for exact match, it +checks if the token name has the correct prefix. This works if +every token name on the policy id is unique. If found then it returns +True else False.

+
+
+ +
+
+

exact(
+  flat: List<(ByteArray, ByteArray, Int)>,
+  pid: ByteArray,
+  tkn: ByteArray,
+  amt: Int,
+) -> Bool

+ + + +
+

This checks if a specific policy id, token name, and amount exist inside +the flattened exact value. It is searching for an exact match. If found +then it returns True else False.

+
+
+ +
+ + +
+
+
+ + + + + + + + + + + + + + + + + + + + + + + Search + + + + + + + Document + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/docs/assist/payout.html b/docs/assist/payout.html index c95815c..9cafc4e 100644 --- a/docs/assist/payout.html +++ b/docs/assist/payout.html @@ -120,13 +120,13 @@

assist - v0.2.1 + v0.2.2 - + - + \ No newline at end of file diff --git a/docs/assist/prefixes.html b/docs/assist/prefixes.html index 42b196e..ad88efd 100644 --- a/docs/assist/prefixes.html +++ b/docs/assist/prefixes.html @@ -120,13 +120,13 @@

assist - v0.2.1 + v0.2.2 - + - + \ No newline at end of file diff --git a/docs/assist/signing.html b/docs/assist/signing.html index aa0ba03..52e7b9a 100644 --- a/docs/assist/signing.html +++ b/docs/assist/signing.html @@ -120,13 +120,13 @@

assist - v0.2.1 + v0.2.2 - + - + \ No newline at end of file diff --git a/docs/assist/std.html b/docs/assist/std.html index 6f66fc8..7e1ede8 100644 --- a/docs/assist/std.html +++ b/docs/assist/std.html @@ -120,13 +120,13 @@

assist - v0.2.1 + v0.2.2 - + - + \ No newline at end of file diff --git a/docs/assist/values.html b/docs/assist/values.html index 756f222..d5ea8e1 100644 --- a/docs/assist/values.html +++ b/docs/assist/values.html @@ -120,13 +120,13 @@

assist - v0.2.1 + v0.2.2 - + - + \ No newline at end of file diff --git a/docs/index.html b/docs/index.html index c0843cc..789b949 100644 --- a/docs/index.html +++ b/docs/index.html @@ -120,13 +120,13 @@

assist - v0.2.1 + v0.2.2 - + - + \ No newline at end of file diff --git a/docs/search-data.js b/docs/search-data.js index 5e223c0..277b7c0 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/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.contain(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":"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/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/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":"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":"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/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/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_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/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/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/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/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/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":"assist/prefixes","content":" This module provides the currently accepted token prefixes.\n","url":"assist/prefixes.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":"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_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_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"}]); \ No newline at end of file +window.Aiken.initSearch([{"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":"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_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_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_555","content":"prefix_555: ByteArray = #"0022bfb0"\n (555) Pointer Token Prefix, NOT IMPLEMENTED IN CIP68","url":"assist/prefixes.html#prefix_555"},{"doc":"assist/prefixes","title":"assist/prefixes","content":" This module provides the currently accepted token prefixes.\n","url":"assist/prefixes.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/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","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","url":"assist/minting.html#exact"},{"doc":"assist/minting","title":"assist/minting","content":"","url":"assist/minting.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 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/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/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/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/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.contain(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":"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/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/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_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/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":"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":"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"}]); \ No newline at end of file diff --git a/docs/tests/fake_tx.html b/docs/tests/fake_tx.html index c6993fc..9710d38 100644 --- a/docs/tests/fake_tx.html +++ b/docs/tests/fake_tx.html @@ -120,13 +120,13 @@

assist - v0.2.1 + v0.2.2 - + - + \ No newline at end of file diff --git a/lib/assist/minting.ak b/lib/assist/minting.ak new file mode 100644 index 0000000..4ba6ee5 --- /dev/null +++ b/lib/assist/minting.ak @@ -0,0 +1,118 @@ +use aiken/bytearray +use aiken/list +use aiken/transaction/value +use assist/prefixes + +/// This checks if a specific policy id, token name, and amount exist inside +/// the flattened exact value. It is searching for an exact match. If found +/// then it returns True else False. +/// +pub fn exact( + flat: List<(ByteArray, ByteArray, Int)>, + pid: ByteArray, + tkn: ByteArray, + amt: Int, +) -> Bool { + when flat is { + // loop the minted value + [(policy, token_name, quantity), ..rest] -> + if list.and([policy == pid, token_name == tkn, quantity == amt]) == True { + True + } else { + exact(rest, pid, tkn, amt) + } + // something wasn't found + [] -> False + } +} + +test good_exact_mint() { + let flat = + value.from_asset(#"acab", #"beef", 1) + |> value.merge(value.from_asset(#"fade", #"cafe", -1)) + |> value.flatten() + exact(flat, #"acab", #"beef", 1) == True +} + +test bad_exact_mint() { + let flat = value.from_asset(#"acab", #"beef", 1) |> value.flatten() + exact(flat, #"acab", #"face", 1) == False +} + +test good_exact_burn() { + let flat = + value.from_asset(#"acab", #"beef", 1) + |> value.merge(value.from_asset(#"fade", #"cafe", -1)) + |> value.flatten() + exact(flat, #"fade", #"cafe", -1) == True +} + +test bad_exact_burn() { + let flat = + value.from_asset(#"acab", #"beef", 1) + |> value.merge(value.from_asset(#"fade", #"cafe", -1)) + |> value.flatten() + exact(flat, #"acab", #"beef", -1) == False +} + +test empty_exact_mint() { + let flat = value.zero() |> value.flatten() + exact(flat, #"", #"", 0) == False +} + +/// This checks if a specific policy id, prefix, and amount exist inside +/// the flattened exact value. Instead of searching for exact match, it +/// checks if the token name has the correct prefix. This works if +/// every token name on the policy id is unique. If found then it returns +/// True else False. +/// +pub fn by_prefix( + flat: List<(ByteArray, ByteArray, Int)>, + pid: ByteArray, + prefix: ByteArray, + amt: Int, +) -> Bool { + when flat is { + // loop all the value for the flat value + [(policy, token_name, quantity), ..rest] -> { + // all cip68 prefixes have the same length + let p = bytearray.take(token_name, 4) + if list.and([policy == pid, prefix == p, quantity == amt]) == True { + True + } else { + by_prefix(rest, pid, prefix, amt) + } + } + // something wasn't found + [] -> False + } +} + +test good_by_prefix_mint() { + let flat = + value.from_asset(#"acab", prefixes.prefix_222, 1) |> value.flatten() + by_prefix(flat, #"acab", prefixes.prefix_222, 1) == True +} + +test good_by_prefix_burn() { + let flat = + value.from_asset(#"acab", prefixes.prefix_222, -1) |> value.flatten() + by_prefix(flat, #"acab", prefixes.prefix_222, -1) == True +} + +test bad_by_prefix_mint() { + let flat = + value.from_asset(#"acab", prefixes.prefix_333, 1) |> value.flatten() + by_prefix(flat, #"acab", prefixes.prefix_222, 1) == False +} + +test bad_by_prefix_burn() { + let flat = + value.from_asset(#"acab", prefixes.prefix_333, -1) |> value.flatten() + by_prefix(flat, #"acab", prefixes.prefix_222, -1) == False +} + +test empty_by_prefix_mint() { + let flat = value.zero() |> value.flatten() + by_prefix(flat, #"", #"", 0) == False +} diff --git a/lib/assist/prefixes.ak b/lib/assist/prefixes.ak index 283ef73..4aea5e6 100644 --- a/lib/assist/prefixes.ak +++ b/lib/assist/prefixes.ak @@ -12,3 +12,6 @@ pub const prefix_333 = #"0014df10" /// (444) Rich-Fungible Token Prefix pub const prefix_444 = #"001bc280" + +/// (555) Pointer Token Prefix, NOT IMPLEMENTED IN CIP68 +pub const prefix_555 = #"0022bfb0" \ No newline at end of file