From 69ea46cabd80b00b51ee0b5a1865ea69ff2bd58a Mon Sep 17 00:00:00 2001 From: logicalmechanism Date: Sat, 20 Jan 2024 16:29:16 -0800 Subject: [PATCH 1/2] staked contracts should now work properly --- README.md | 1 + requirements.txt | 1 + tests/test_run_bech32.py | 18 ++++++++++++++++ tx_simulation.py | 44 +++++++++++++++++++++++++++++++++++++--- 4 files changed, 61 insertions(+), 3 deletions(-) create mode 100644 tests/test_run_bech32.py diff --git a/README.md b/README.md index 72d2695..4601bc7 100644 --- a/README.md +++ b/README.md @@ -76,3 +76,4 @@ Inside the `tests` folder are pytest tests for `tx_simulation`. The tests can be ```bash pytest ``` + diff --git a/requirements.txt b/requirements.txt index ea74514..d5ba62f 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,3 +1,4 @@ +bech32==1.2.0 cbor2==5.4.6 certifi==2023.7.22 charset-normalizer==3.2.0 diff --git a/tests/test_run_bech32.py b/tests/test_run_bech32.py new file mode 100644 index 0000000..73bdfca --- /dev/null +++ b/tests/test_run_bech32.py @@ -0,0 +1,18 @@ +import pytest + +from tx_simulation import run_bech32 + + +def test_to_bytes_with_invalid_hex2(): + # Test with an invalid hexadecimal string + with pytest.raises(TypeError) as excinfo: + run_bech32("") + assert "non-standard format in run_bech32() arg at position 1" in str(excinfo.value), "Incorrect error message for invalid input" + + +def test_stake_run_bech32(): + assert run_bech32("stake_test1uzl65wzu364hh0wxex94qsf5xkeaq2mnmc7xgnsnsjuqr4qruvxwu") == "bfaa385c8eab7bbdc6c98b50413435b3d02b73de3c644e1384b801d4" + + +def test_address_run_bech32(): + assert run_bech32("addr_test1qrvnxkaylr4upwxfxctpxpcumj0fl6fdujdc72j8sgpraa9l4gu9er4t0w7udjvt2pqngddn6q4h8h3uv38p8p9cq82qav4lmp") == "d9335ba4f8ebc0b8c9361613071cdc9e9fe92de49b8f2a4782023ef4bfaa385c8eab7bbdc6c98b50413435b3d02b73de3c644e1384b801d4" diff --git a/tx_simulation.py b/tx_simulation.py index adeecec..e4daf04 100644 --- a/tx_simulation.py +++ b/tx_simulation.py @@ -5,6 +5,31 @@ import cbor2 import requests +from bech32 import bech32_decode, convertbits + + +def run_bech32(key: str) -> str: + """Run bech 32 on some key and return the raw hash. + + Args: + key (str): The key to decode. + + Returns: + str: The decoded raw hash. + """ + try: + # Bech32 decode + _, data5 = bech32_decode(key) + + # Convert 5-bit array back to 8-bit + data8 = convertbits(data5, 5, 8, False) + + hex_string = ''.join(format(x, '02x') for x in data8) + + # remove the network tag + return hex_string[2:] + except TypeError: + raise TypeError("non-standard format in run_bech32() arg at position 1") def to_bytes(s: str) -> bytes: @@ -189,8 +214,15 @@ def build_resolved_output(tx_id: str, tx_idx: int, outputs: list[dict], network: # one index must exist # 2 and 3 are optional if txo['inline_datum'] is not None: - network_flag = "71" if network is True else "70" - pkh = network_flag + txo['payment_addr']['cred'] + # smart contract + if txo["stake_addr"] is None: + network_flag = "71" if network is True else "70" + pkh = network_flag + txo['payment_addr']['cred'] + else: + network_flag = "11" if network is True else "10" + stake_key = run_bech32(txo["stake_addr"]) + pkh = network_flag + txo['payment_addr']['cred'] + stake_key + # correct format pkh = to_bytes(pkh) resolved[0] = pkh @@ -199,7 +231,13 @@ def build_resolved_output(tx_id: str, tx_idx: int, outputs: list[dict], network: resolved[2] = [1, cbor2.CBORTag(24, cbor_datum)] else: # simple payment - network_flag = "61" if network is True else "60" + if txo["stake_addr"] is None: + network_flag = "61" if network is True else "60" + pkh = network_flag + txo['payment_addr']['cred'] + else: + network_flag = "01" if network is True else "00" + stake_key = run_bech32(txo["stake_addr"]) + pkh = network_flag + txo['payment_addr']['cred'] + stake_key pkh = network_flag + txo['payment_addr']['cred'] pkh = to_bytes(pkh) resolved[0] = pkh From ddafb4b406daeaf88035c9c5ce1535a5d027c930 Mon Sep 17 00:00:00 2001 From: logicalmechanism Date: Sat, 20 Jan 2024 16:59:17 -0800 Subject: [PATCH 2/2] added in contract stake example --- example-contracts/certs/de-stake.cert | 5 -- example-contracts/certs/deleg.cert | 5 -- example-contracts/certs/stake.cert | 5 -- example-contracts/complete_build.sh | 10 ---- .../contracts/stake_contract.plutus | 5 -- example-contracts/hashes/stake.hash | 1 - example-contracts/plutus.json | 48 ------------------- example-contracts/scripts/01_utxoSetUp.sh | 8 ++-- example-contracts/scripts/02_generateCBOR.sh | 6 +-- example-contracts/scripts/all_balances.sh | 5 ++ .../scripts/cbor/always_false.cbor | 2 +- .../scripts/cbor/always_true.cbor | 2 +- example-contracts/scripts/cbor/lock.cbor | 2 +- example-contracts/scripts/cbor/multi.cbor | 2 +- .../scripts/cbor/single_shot.cbor | 2 +- .../scripts/cbor/subtract_fee.cbor | 2 +- tests/test_from_cbor.py | 4 +- 17 files changed, 20 insertions(+), 94 deletions(-) delete mode 100644 example-contracts/certs/de-stake.cert delete mode 100644 example-contracts/certs/deleg.cert delete mode 100644 example-contracts/certs/stake.cert delete mode 100644 example-contracts/contracts/stake_contract.plutus delete mode 100644 example-contracts/hashes/stake.hash diff --git a/example-contracts/certs/de-stake.cert b/example-contracts/certs/de-stake.cert deleted file mode 100644 index d934958..0000000 --- a/example-contracts/certs/de-stake.cert +++ /dev/null @@ -1,5 +0,0 @@ -{ - "type": "CertificateShelley", - "description": "Stake Address Deregistration Certificate", - "cborHex": "82018201581ce8ed8ae9868fb47cf9233ed463ccea7aff9f61b91eda596ad46d19ae" -} diff --git a/example-contracts/certs/deleg.cert b/example-contracts/certs/deleg.cert deleted file mode 100644 index 9e580cc..0000000 --- a/example-contracts/certs/deleg.cert +++ /dev/null @@ -1,5 +0,0 @@ -{ - "type": "CertificateShelley", - "description": "Stake Delegation Certificate", - "cborHex": "83028201581ce8ed8ae9868fb47cf9233ed463ccea7aff9f61b91eda596ad46d19ae581c1e3105f23f2ac91b3fb4c35fa4fe301421028e356e114944e902005b" -} diff --git a/example-contracts/certs/stake.cert b/example-contracts/certs/stake.cert deleted file mode 100644 index 983cfb4..0000000 --- a/example-contracts/certs/stake.cert +++ /dev/null @@ -1,5 +0,0 @@ -{ - "type": "CertificateShelley", - "description": "Stake Address Registration Certificate", - "cborHex": "82008201581ce8ed8ae9868fb47cf9233ed463ccea7aff9f61b91eda596ad46d19ae" -} diff --git a/example-contracts/complete_build.sh b/example-contracts/complete_build.sh index 950e859..98b89f7 100755 --- a/example-contracts/complete_build.sh +++ b/example-contracts/complete_build.sh @@ -42,16 +42,6 @@ aiken blueprint convert -v single_shot.params > contracts/single_shot_contract.p cardano-cli transaction policyid --script-file contracts/single_shot_contract.plutus > hashes/single_shot.hash echo -e "\033[1;33m Single Shot Hash: $(cat hashes/single_shot.hash) \033[0m" -# build the stake contract -echo -e "\033[1;33m\nBuilding Stake Contract \033[0m" -poolId="1e3105f23f2ac91b3fb4c35fa4fe301421028e356e114944e902005b" -aiken blueprint convert -v staking.params > contracts/stake_contract.plutus -cardano-cli stake-address registration-certificate --stake-script-file contracts/stake_contract.plutus --out-file certs/stake.cert -cardano-cli stake-address deregistration-certificate --stake-script-file contracts/stake_contract.plutus --out-file certs/de-stake.cert -cardano-cli stake-address delegation-certificate --stake-script-file contracts/stake_contract.plutus --stake-pool-id ${poolId} --out-file certs/deleg.cert -cardano-cli transaction policyid --script-file contracts/stake_contract.plutus > hashes/stake.hash -echo -e "\033[1;33m Staking Hash: $(cat hashes/stake.hash) \033[0m" - echo -e "\033[1;33m\nBuilding Subtract Fee Contract \033[0m" aiken blueprint convert -v subtract_fee.params > contracts/subtract_fee_contract.plutus cardano-cli transaction policyid --script-file contracts/subtract_fee_contract.plutus > hashes/subtract_fee.hash diff --git a/example-contracts/contracts/stake_contract.plutus b/example-contracts/contracts/stake_contract.plutus deleted file mode 100644 index e811537..0000000 --- a/example-contracts/contracts/stake_contract.plutus +++ /dev/null @@ -1,5 +0,0 @@ -{ - "type": "PlutusScriptV2", - "description": "Generated by Aiken", - "cborHex": "58d358d1010000323232323232323222325333006323253330083370e9002000899299980499b87480000045288a503007005153330083370e9003000899299980499b87480080045288a50300700514a0600c00260146016600800429309b2b19299980319b874800000454ccc024c01000c52616153330063370e9001000899192999805980680109924c64a66601266e1d200000113232533300e3010002149858dd7180700098038010b18038008b180580098020018b1802001118029baa001230033754002ae6955ceaab9e5573eae855d11" -} diff --git a/example-contracts/hashes/stake.hash b/example-contracts/hashes/stake.hash deleted file mode 100644 index 9517701..0000000 --- a/example-contracts/hashes/stake.hash +++ /dev/null @@ -1 +0,0 @@ -e8ed8ae9868fb47cf9233ed463ccea7aff9f61b91eda596ad46d19ae diff --git a/example-contracts/plutus.json b/example-contracts/plutus.json index db5491d..29cd2a6 100644 --- a/example-contracts/plutus.json +++ b/example-contracts/plutus.json @@ -73,17 +73,6 @@ "compiledCode": "59022f0100003332323232323232322322322253330083232533300a3370e9000000899191919191919299980899191980080080111299980b8008b09919299980b19baf300a301500200614a2266008008002603600460320026eb0c014c0400104c8cc004004010894ccc058004528099191919191919299980d299980d299980d19b8f00500f1533301a3371e006016266e1c005200214a02940528899980d2514a09445288998048048031bad301e001301e002375c603800260380066eb8c068008c068008dd6180c0008a503374a90001980a19ba548000cc050dd4806a5eb80cc050dd4005a5eb80ccdc62400066e00cdc0a407c90002400466e2922100337160146e4c030c8c8c8cc004004008894ccc05400452f5c0264666444646600200200644a66603600220062646603a6e9ccc074dd48031980e9ba9375c60340026603a6ea0dd6980d800a5eb80cc00c00cc07c008c074004dd7180a0009bab30150013300300330190023017001323300100100222533301400114bd6f7b630099191919299980a99b8f4881000021003133019337606ea4008dd3000998030030019bab3016003375c60280046030004602c0026eacc04cc050c050c050c050c034004c004c0300188c048004dd7180800098048010a50300a3754002601a601c600e00229309b2b1bad001375c002460086ea80055cd2ab9d5573caae7d5d02ba1574498012258209a599de7cc3cccc06922e5d08d218d99699b1220e96b664a1c0303a9810cb465004c0101000001", "hash": "4939777c7e2e5a4b4d4890dd677883b14aa9d3a27e77613b3ae80fd7" }, - { - "title": "staking.params", - "redeemer": { - "title": "redeemer", - "schema": { - "$ref": "#/definitions/staking~1WithdrawRedeemer" - } - }, - "compiledCode": "58d1010000323232323232323222325333006323253330083370e9002000899299980499b87480000045288a503007005153330083370e9003000899299980499b87480080045288a50300700514a0600c00260146016600800429309b2b19299980319b874800000454ccc024c01000c52616153330063370e9001000899192999805980680109924c64a66601266e1d200000113232533300e3010002149858dd7180700098038010b18038008b180580098020018b1802001118029baa001230033754002ae6955ceaab9e5573eae855d11", - "hash": "e8ed8ae9868fb47cf9233ed463ccea7aff9f61b91eda596ad46d19ae" - }, { "title": "subtract_fee.params", "datum": { @@ -157,43 +146,6 @@ } ] }, - "staking/StakeData": { - "title": "StakeData", - "anyOf": [ - { - "title": "StakeData", - "dataType": "constructor", - "index": 0, - "fields": [ - { - "title": "stake_cred", - "$ref": "#/definitions/ByteArray" - } - ] - } - ] - }, - "staking/WithdrawRedeemer": { - "title": "WithdrawRedeemer", - "anyOf": [ - { - "title": "Withdraw", - "dataType": "constructor", - "index": 0, - "fields": [] - }, - { - "title": "Delegate", - "dataType": "constructor", - "index": 1, - "fields": [ - { - "$ref": "#/definitions/staking~1StakeData" - } - ] - } - ] - }, "subtract_fee/Datum": { "title": "Datum", "anyOf": [ diff --git a/example-contracts/scripts/01_utxoSetUp.sh b/example-contracts/scripts/01_utxoSetUp.sh index 421d23a..c7b9e2f 100755 --- a/example-contracts/scripts/01_utxoSetUp.sh +++ b/example-contracts/scripts/01_utxoSetUp.sh @@ -7,6 +7,8 @@ source .env # get params ${cli} query protocol-parameters ${network} --out-file tmp/protocol.json +stake_key="stake_test1uzl65wzu364hh0wxex94qsf5xkeaq2mnmc7xgnsnsjuqr4qruvxwu" + # contracts always_false_script_path="../contracts/always_false_contract.plutus" always_false_script_address=$(${cli} address build --payment-script-file ${always_false_script_path} ${network}) @@ -15,7 +17,7 @@ always_true_script_path="../contracts/always_true_contract.plutus" always_true_script_address=$(${cli} address build --payment-script-file ${always_true_script_path} ${network}) lock_script_path="../contracts/lock_contract.plutus" -lock_script_address=$(${cli} address build --payment-script-file ${lock_script_path} ${network}) +lock_script_address=$(${cli} address build --payment-script-file ${lock_script_path} --stake-address ${stake_key} ${network}) subtract_fee_script_path="../contracts/subtract_fee_contract.plutus" subtract_fee_script_address=$(${cli} address build --payment-script-file ${subtract_fee_script_path} ${network}) @@ -63,7 +65,7 @@ IFS=' ' read -ra FEE <<< "${VALUE[1]}" FEE=${FEE[1]} echo -e "\033[1;32m Fee: \033[0m" $FEE # -exit +# exit # echo -e "\033[0;36m Signing \033[0m" ${cli} transaction sign \ @@ -72,7 +74,7 @@ ${cli} transaction sign \ --out-file tmp/tx.signed \ ${network} # -exit +# exit # echo -e "\033[0;36m Submitting \033[0m" ${cli} transaction submit \ diff --git a/example-contracts/scripts/02_generateCBOR.sh b/example-contracts/scripts/02_generateCBOR.sh index ba63f12..fc7257c 100755 --- a/example-contracts/scripts/02_generateCBOR.sh +++ b/example-contracts/scripts/02_generateCBOR.sh @@ -7,6 +7,7 @@ source .env # get params ${cli} query protocol-parameters ${network} --out-file tmp/protocol.json +stake_key="stake_test1uzl65wzu364hh0wxex94qsf5xkeaq2mnmc7xgnsnsjuqr4qruvxwu" # contracts always_false_script_path="../contracts/always_false_contract.plutus" @@ -16,7 +17,7 @@ always_true_script_path="../contracts/always_true_contract.plutus" always_true_script_address=$(${cli} address build --payment-script-file ${always_true_script_path} ${network}) lock_script_path="../contracts/lock_contract.plutus" -lock_script_address=$(${cli} address build --payment-script-file ${lock_script_path} ${network}) +lock_script_address=$(${cli} address build --payment-script-file ${lock_script_path} --stake-address ${stake_key} ${network}) subtract_fee_script_path="../contracts/subtract_fee_contract.plutus" subtract_fee_script_address=$(${cli} address build --payment-script-file ${subtract_fee_script_path} ${network}) @@ -24,9 +25,6 @@ subtract_fee_script_address=$(${cli} address build --payment-script-file ${subtr single_shot_script_path="../contracts/single_shot_contract.plutus" single_shot_script_address=$(${cli} address build --payment-script-file ${single_shot_script_path} ${network}) -staking_script_path="../contracts/stake_contract.plutus" -staking_script_address=$(${cli} address build --payment-script-file ${staking_script_path} ${network}) - # get script utxo echo -e "\033[0;36m Gathering Always False UTxO Information \033[0m" ${cli} query utxo \ diff --git a/example-contracts/scripts/all_balances.sh b/example-contracts/scripts/all_balances.sh index 050cc29..e303943 100755 --- a/example-contracts/scripts/all_balances.sh +++ b/example-contracts/scripts/all_balances.sh @@ -9,6 +9,7 @@ mkdir -p ./tmp ${cli} query protocol-parameters ${network} --out-file ./tmp/protocol.json ${cli} query tip ${network} | jq +stake_key="stake_test1uzl65wzu364hh0wxex94qsf5xkeaq2mnmc7xgnsnsjuqr4qruvxwu" # Loop through each file in the directory for contract in "../contracts"/* @@ -16,10 +17,14 @@ do echo -e "\033[1;37m --------------------------------------------------------------------------------\033[0m" echo -e "\033[1;35m ${contract}\033[0m" script_address=$(${cli} address build --payment-script-file ${contract} ${network}) + script_address_base=$(${cli} address build --payment-script-file ${contract} --stake-address ${stake_key} ${network}) echo -e "\n \033[1;35m ${script_address} \033[0m \n"; file_name=$(basename "$contract") ${cli} query utxo --address ${script_address} ${network} + echo -e "\n \033[1;35m ${script_address_base} \033[0m \n"; + ${cli} query utxo --address ${script_address_base} ${network} ${cli} query utxo --address ${script_address} ${network} --out-file ./tmp/current_${file_name}.utxo + ${cli} query utxo --address ${script_address_base} ${network} --out-file ./tmp/current_${file_name}_base.utxo baseLovelace=$(jq '[.. | objects | .lovelace] | add' ./tmp/current_${file_name}.utxo) echo -e "\033[0m" diff --git a/example-contracts/scripts/cbor/always_false.cbor b/example-contracts/scripts/cbor/always_false.cbor index 193ef8d..c625b60 100644 --- a/example-contracts/scripts/cbor/always_false.cbor +++ b/example-contracts/scripts/cbor/always_false.cbor @@ -1 +1 @@ -84a7008282582038edc7ac2955256c91095817e9202653c2a5a433450dbaa62c57d721d9c50cd90082582038edc7ac2955256c91095817e9202653c2a5a433450dbaa62c57d721d9c50cd9040d81825820779ffadaaeb39aecb6837c34db101b1af61a0e00c522ff7b4720fa8003587d89001281825820f893e5378a8af8d63936d1536c7b8b17bad191e7f44539f72be481f0aaa9c56901018182581d60fe2e583e1f27d5af0b318eaccd11286da4caaba7dcaa92776549971b1a002dc6c0021a00061a800e81581c6e34d0d52a408b8d1fa2b056100bfa6f0195cdeaaa66dadc97705f560b5820c3c76419d765b91c4ac7f024f2b1f535ccbf4a1bd07c2d7016d4ae818c826e61a10581840000d87980820000f5f6 +84a7008282582038edc7ac2955256c91095817e9202653c2a5a433450dbaa62c57d721d9c50cd9008258204f456c9f7d6eb3d1550b4e5a1bbd7bb2c779a826e1cb393fd17ea1d735799e71040d81825820779ffadaaeb39aecb6837c34db101b1af61a0e00c522ff7b4720fa8003587d89001281825820100afa03dd03d782614c39aa5535c914df0755ce3b2837804895565e43aca1cd01018182581d60fe2e583e1f27d5af0b318eaccd11286da4caaba7dcaa92776549971b1a002dc6c0021a00061a800e81581c6e34d0d52a408b8d1fa2b056100bfa6f0195cdeaaa66dadc97705f560b5820c3c76419d765b91c4ac7f024f2b1f535ccbf4a1bd07c2d7016d4ae818c826e61a10581840000d87980820000f5f6 diff --git a/example-contracts/scripts/cbor/always_true.cbor b/example-contracts/scripts/cbor/always_true.cbor index 9e595c1..8a79f42 100644 --- a/example-contracts/scripts/cbor/always_true.cbor +++ b/example-contracts/scripts/cbor/always_true.cbor @@ -1 +1 @@ -84a9008282582038edc7ac2955256c91095817e9202653c2a5a433450dbaa62c57d721d9c50cd90182582038edc7ac2955256c91095817e9202653c2a5a433450dbaa62c57d721d9c50cd9040d81825820779ffadaaeb39aecb6837c34db101b1af61a0e00c522ff7b4720fa8003587d89001281825820e9c2faba789e866c10cbde14333c8219fd1b5b6faedbcd8be26503efb629684401018182581d60fe2e583e1f27d5af0b318eaccd11286da4caaba7dcaa92776549971b1a00ee8fdf1082581d60fe2e583e1f27d5af0b318eaccd11286da4caaba7dcaa92776549971b1a00481460111a000436e0021a0002cf400e81581c6e34d0d52a408b8d1fa2b056100bfa6f0195cdeaaa66dadc97705f560b58200461c73c320e7448ee76a1e712321c2a184751df91aec219d2bfd87353c75dd6a10581840000d8798082191c7f1a00230a0ff5f6 +84a900828258204f456c9f7d6eb3d1550b4e5a1bbd7bb2c779a826e1cb393fd17ea1d735799e71018258204f456c9f7d6eb3d1550b4e5a1bbd7bb2c779a826e1cb393fd17ea1d735799e71040d81825820779ffadaaeb39aecb6837c34db101b1af61a0e00c522ff7b4720fa8003587d8900128182582066991b37b2f4812170261c9c9ab2b02c9748c9882dec48a9c14a73310ccc271201018182581d60fe2e583e1f27d5af0b318eaccd11286da4caaba7dcaa92776549971b1a01b20be21082581d60fe2e583e1f27d5af0b318eaccd11286da4caaba7dcaa92776549971b1a00481460111a000436e0021a0002cf400e81581c6e34d0d52a408b8d1fa2b056100bfa6f0195cdeaaa66dadc97705f560b58200461c73c320e7448ee76a1e712321c2a184751df91aec219d2bfd87353c75dd6a10581840000d8798082191c7f1a00230a0ff5f6 diff --git a/example-contracts/scripts/cbor/lock.cbor b/example-contracts/scripts/cbor/lock.cbor index a6e001e..0a47009 100644 --- a/example-contracts/scripts/cbor/lock.cbor +++ b/example-contracts/scripts/cbor/lock.cbor @@ -1 +1 @@ -84a9008282582038edc7ac2955256c91095817e9202653c2a5a433450dbaa62c57d721d9c50cd90282582038edc7ac2955256c91095817e9202653c2a5a433450dbaa62c57d721d9c50cd9040d81825820779ffadaaeb39aecb6837c34db101b1af61a0e00c522ff7b4720fa8003587d890012818258207b59aec02fb4ce75432cf68f5c7e73501b340a33a303a8aa14dd2744b83e7b5801018282581d60fe2e583e1f27d5af0b318eaccd11286da4caaba7dcaa92776549971b1a002dc6c082581d60fe2e583e1f27d5af0b318eaccd11286da4caaba7dcaa92776549971b1a00c0880a1082581d60fe2e583e1f27d5af0b318eaccd11286da4caaba7dcaa92776549971b1a0047b2c0111a00049880021a000310550e82581c6e34d0d52a408b8d1fa2b056100bfa6f0195cdeaaa66dadc97705f56581cfe2e583e1f27d5af0b318eaccd11286da4caaba7dcaa92776549971b0b58201e412b0d1b4ed3e32139fca4123ca15236a8ca5dbf9e27e1f12b1a2a3aaa190ea10581840000d87980821a0001b2e01a02c3b547f5f6 +84a900828258204f456c9f7d6eb3d1550b4e5a1bbd7bb2c779a826e1cb393fd17ea1d735799e71028258204f456c9f7d6eb3d1550b4e5a1bbd7bb2c779a826e1cb393fd17ea1d735799e71040d81825820779ffadaaeb39aecb6837c34db101b1af61a0e00c522ff7b4720fa8003587d890012818258205835384960876f61d1564b62210ef4bf6accdca1f13aac3b80354afd6d3ef54601018282581d60fe2e583e1f27d5af0b318eaccd11286da4caaba7dcaa92776549971b1a002dc6c082581d60fe2e583e1f27d5af0b318eaccd11286da4caaba7dcaa92776549971b1a018403fe1082581d60fe2e583e1f27d5af0b318eaccd11286da4caaba7dcaa92776549971b1a0047b2aa111a00049896021a000310640e82581c6e34d0d52a408b8d1fa2b056100bfa6f0195cdeaaa66dadc97705f56581cfe2e583e1f27d5af0b318eaccd11286da4caaba7dcaa92776549971b0b582082d5e5445d1d0bd5b41ee400ab5fb73b1b4d98911496da6a48418e4e866b8627a10581840000d87980821a0001b2e01a02c6c7e7f5f6 diff --git a/example-contracts/scripts/cbor/multi.cbor b/example-contracts/scripts/cbor/multi.cbor index 213294a..0ff9f27 100644 --- a/example-contracts/scripts/cbor/multi.cbor +++ b/example-contracts/scripts/cbor/multi.cbor @@ -1 +1 @@ -84aa008482582038edc7ac2955256c91095817e9202653c2a5a433450dbaa62c57d721d9c50cd90182582038edc7ac2955256c91095817e9202653c2a5a433450dbaa62c57d721d9c50cd90282582038edc7ac2955256c91095817e9202653c2a5a433450dbaa62c57d721d9c50cd9048258209a599de7cc3cccc06922e5d08d218d99699b1220e96b664a1c0303a9810cb465000d81825820779ffadaaeb39aecb6837c34db101b1af61a0e00c522ff7b4720fa8003587d890012838258207b59aec02fb4ce75432cf68f5c7e73501b340a33a303a8aa14dd2744b83e7b5801825820a6e082cf68c865c30b96c0c8b9fe5fdaac61653c510744a7945fd8168a304b3801825820e9c2faba789e866c10cbde14333c8219fd1b5b6faedbcd8be26503efb629684401018282581d60fe2e583e1f27d5af0b318eaccd11286da4caaba7dcaa92776549971b1a002dc6c082581d60fe2e583e1f27d5af0b318eaccd11286da4caaba7dcaa92776549971b821a013a0656a1581c4939777c7e2e5a4b4d4890dd677883b14aa9d3a27e77613b3ae80fd7a1582000195132a3ab313102d81720d2099c2fddb2dd121fb00f206894c72c702d931f011082581d60fe2e583e1f27d5af0b318eaccd11286da4caaba7dcaa92776549971b1a0046d532111a0005760e021a0003a4090e83581c6e34d0d52a408b8d1fa2b056100bfa6f0195cdeaaa66dadc97705f56581cbbcade5bda4093958813b08555e3584fd982e6902fb00db361767c6d581cfe2e583e1f27d5af0b318eaccd11286da4caaba7dcaa92776549971b09a1581c4939777c7e2e5a4b4d4890dd677883b14aa9d3a27e77613b3ae80fd7a1582000195132a3ab313102d81720d2099c2fddb2dd121fb00f206894c72c702d931f010b5820b9d4b9621085af8f5680f79c705b4d658eedf765b069615ef09775c801261119a10583840000d8798082191c7f1a00230a0f840001d87980821a00020b081a0371ef9b840100d87980821a000125441a01f97f79f5f6 +84aa00848258204f456c9f7d6eb3d1550b4e5a1bbd7bb2c779a826e1cb393fd17ea1d735799e71018258204f456c9f7d6eb3d1550b4e5a1bbd7bb2c779a826e1cb393fd17ea1d735799e71028258204f456c9f7d6eb3d1550b4e5a1bbd7bb2c779a826e1cb393fd17ea1d735799e71048258209a599de7cc3cccc06922e5d08d218d99699b1220e96b664a1c0303a9810cb465000d81825820779ffadaaeb39aecb6837c34db101b1af61a0e00c522ff7b4720fa8003587d890012838258205835384960876f61d1564b62210ef4bf6accdca1f13aac3b80354afd6d3ef5460182582066991b37b2f4812170261c9c9ab2b02c9748c9882dec48a9c14a73310ccc271201825820c4b9df7c4b19ed8c7a97fcb7b658279fd55650f3bf549a3be5ef51dbf49363e801018282581d60fe2e583e1f27d5af0b318eaccd11286da4caaba7dcaa92776549971b1a002dc6c082581d60fe2e583e1f27d5af0b318eaccd11286da4caaba7dcaa92776549971b821a01fd824aa1581c4939777c7e2e5a4b4d4890dd677883b14aa9d3a27e77613b3ae80fd7a1582000195132a3ab313102d81720d2099c2fddb2dd121fb00f206894c72c702d931f011082581d60fe2e583e1f27d5af0b318eaccd11286da4caaba7dcaa92776549971b1a0046d51c111a00057624021a0003a4180e83581c6e34d0d52a408b8d1fa2b056100bfa6f0195cdeaaa66dadc97705f56581cbbcade5bda4093958813b08555e3584fd982e6902fb00db361767c6d581cfe2e583e1f27d5af0b318eaccd11286da4caaba7dcaa92776549971b09a1581c4939777c7e2e5a4b4d4890dd677883b14aa9d3a27e77613b3ae80fd7a1582000195132a3ab313102d81720d2099c2fddb2dd121fb00f206894c72c702d931f010b5820bdf92ccc6de061dae74540f520ce11da05d3e17ce6b2028ed914ce51ceea1a7fa10583840000d8798082191c7f1a00230a0f840001d87980821a00020b081a0375023b840100d87980821a000125441a01f97f79f5f6 diff --git a/example-contracts/scripts/cbor/single_shot.cbor b/example-contracts/scripts/cbor/single_shot.cbor index e352502..7a6d5a6 100644 --- a/example-contracts/scripts/cbor/single_shot.cbor +++ b/example-contracts/scripts/cbor/single_shot.cbor @@ -1 +1 @@ -84aa00818258209a599de7cc3cccc06922e5d08d218d99699b1220e96b664a1c0303a9810cb465000d81825820779ffadaaeb39aecb6837c34db101b1af61a0e00c522ff7b4720fa8003587d89001281825820a6e082cf68c865c30b96c0c8b9fe5fdaac61653c510744a7945fd8168a304b3801018182581d60bbcade5bda4093958813b08555e3584fd982e6902fb00db361767c6d821a004958b4a1581c4939777c7e2e5a4b4d4890dd677883b14aa9d3a27e77613b3ae80fd7a1582000195132a3ab313102d81720d2099c2fddb2dd121fb00f206894c72c702d931f011082581d60bbcade5bda4093958813b08555e3584fd982e6902fb00db361767c6d1a0047df6e111a00046bd2021a0002f28c0e81581c6e34d0d52a408b8d1fa2b056100bfa6f0195cdeaaa66dadc97705f5609a1581c4939777c7e2e5a4b4d4890dd677883b14aa9d3a27e77613b3ae80fd7a1582000195132a3ab313102d81720d2099c2fddb2dd121fb00f206894c72c702d931f010b5820f0f08c95af7695a6ec71c60cfd75ef201d018201c943f29c78a61dc119e638ffa10581840100d879808219eabe1a0173551bf5f6 +84aa00818258209a599de7cc3cccc06922e5d08d218d99699b1220e96b664a1c0303a9810cb465000d81825820779ffadaaeb39aecb6837c34db101b1af61a0e00c522ff7b4720fa8003587d89001281825820c4b9df7c4b19ed8c7a97fcb7b658279fd55650f3bf549a3be5ef51dbf49363e801018182581d60bbcade5bda4093958813b08555e3584fd982e6902fb00db361767c6d821a004958b4a1581c4939777c7e2e5a4b4d4890dd677883b14aa9d3a27e77613b3ae80fd7a1582000195132a3ab313102d81720d2099c2fddb2dd121fb00f206894c72c702d931f011082581d60bbcade5bda4093958813b08555e3584fd982e6902fb00db361767c6d1a0047df6e111a00046bd2021a0002f28c0e81581c6e34d0d52a408b8d1fa2b056100bfa6f0195cdeaaa66dadc97705f5609a1581c4939777c7e2e5a4b4d4890dd677883b14aa9d3a27e77613b3ae80fd7a1582000195132a3ab313102d81720d2099c2fddb2dd121fb00f206894c72c702d931f010b5820f0f08c95af7695a6ec71c60cfd75ef201d018201c943f29c78a61dc119e638ffa10581840100d879808219eabe1a0173551bf5f6 diff --git a/example-contracts/scripts/cbor/subtract_fee.cbor b/example-contracts/scripts/cbor/subtract_fee.cbor index 66cd953..977e70e 100644 --- a/example-contracts/scripts/cbor/subtract_fee.cbor +++ b/example-contracts/scripts/cbor/subtract_fee.cbor @@ -1 +1 @@ -84a7008282582038edc7ac2955256c91095817e9202653c2a5a433450dbaa62c57d721d9c50cd90382582038edc7ac2955256c91095817e9202653c2a5a433450dbaa62c57d721d9c50cd9040d81825820779ffadaaeb39aecb6837c34db101b1af61a0e00c522ff7b4720fa8003587d8900128182582041668ef54353746e3ae58b06f49612acaf44971d222cdec4a212509704432c1a01018182581d60fe2e583e1f27d5af0b318eaccd11286da4caaba7dcaa92776549971b1a001e8480021a000f42400e82581c6e34d0d52a408b8d1fa2b056100bfa6f0195cdeaaa66dadc97705f56581cfe2e583e1f27d5af0b318eaccd11286da4caaba7dcaa92776549971b0b5820c3c76419d765b91c4ac7f024f2b1f535ccbf4a1bd07c2d7016d4ae818c826e61a10581840000d87980820000f5f6 +84a7008282582038edc7ac2955256c91095817e9202653c2a5a433450dbaa62c57d721d9c50cd9038258204f456c9f7d6eb3d1550b4e5a1bbd7bb2c779a826e1cb393fd17ea1d735799e71040d81825820779ffadaaeb39aecb6837c34db101b1af61a0e00c522ff7b4720fa8003587d890012818258200c8f1c438e28eb5c74d723ceae415dc27b460823be7e936ab2a63b3aeb7766e901018182581d60fe2e583e1f27d5af0b318eaccd11286da4caaba7dcaa92776549971b1a001e8480021a000f42400e82581c6e34d0d52a408b8d1fa2b056100bfa6f0195cdeaaa66dadc97705f56581cfe2e583e1f27d5af0b318eaccd11286da4caaba7dcaa92776549971b0b5820c3c76419d765b91c4ac7f024f2b1f535ccbf4a1bd07c2d7016d4ae818c826e61a10581840000d87980820000f5f6 diff --git a/tests/test_from_cbor.py b/tests/test_from_cbor.py index 5d6c172..fcc581d 100644 --- a/tests/test_from_cbor.py +++ b/tests/test_from_cbor.py @@ -28,7 +28,7 @@ def test_from_cbor_lock(): valid_hex_cbor = get_first_line("./example-contracts/scripts/cbor/lock.cbor") output = from_cbor(valid_hex_cbor, False) # print('output', output) - expected_output = [{'mem': 111328, 'cpu': 46380359}] + expected_output = [{'mem': 111328, 'cpu': 46581735}] assert output == expected_output @@ -63,5 +63,5 @@ def test_from_cbor_multi(): valid_hex_cbor = get_first_line("./example-contracts/scripts/cbor/multi.cbor") output = from_cbor(valid_hex_cbor, False) # print('output', output) - expected_output = [{'mem': 7295, 'cpu': 2296335}, {'mem': 133896, 'cpu': 57798555}, {'mem': 75076, 'cpu': 33128313}] + expected_output = [{'mem': 7295, 'cpu': 2296335}, {'mem': 133896, 'cpu': 57999931}, {'mem': 75076, 'cpu': 33128313}] assert output == expected_output