Skip to content

Commit 7757ff0

Browse files
Merge pull request #11 from DripDropz/desugar-transaction
Desugar transaction
2 parents 52b02bf + 6eaa698 commit 7757ff0

16 files changed

+97
-195
lines changed

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,5 @@ docs/
77
aiken.lock
88
.github/
99
contracts/
10-
hashes/
10+
hashes/
11+
plutus.json

README.md

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,19 @@ The `Perma Lock NFT` contract is designed to permanently lock various types of t
1111

1212
## **Configuration**
1313

14-
Configuring the `Perma Lock FT` contract begins by specifying the token details inside `start_info.json`:
14+
Configuring the `Perma Lock FT` contract begins by specifying the required compile information inside `config.json`:
1515

1616
```json
1717
{
18-
"__comment1__": "This is the ft to lock for the perma lock ft contract",
19-
"lockingPid": "954fe5769e9eb8dad54c99f8d62015c813c24f229a4d98dbf05c28b9",
20-
"lockingNFT": "546869735f49735f415f566572795f4c6f6e675f537472696e675f5f5f5f5f5f",
21-
"__comment2__": "This is maximum amount of the ft in existence.",
22-
"maxTokenAmt": 9223372036854775807
18+
"__comment1__": "The FT compile information",
19+
"lockingPid": "d441227553a0f1a965fee7d60a0f724b368dd1bddbc208730fccebcf",
20+
"lockingTkn": "546869735f49735f415f566572795f4c6f6e675f537472696e675f5f5f5f5f5f",
21+
"maxTokenAmt": 9223372036854775807,
22+
"randomString1": "acab",
23+
"__comment2__": "The NFT compile information",
24+
"randomString2": "cafe",
25+
"__comment3__": "Place a static stake key here for testing",
26+
"stakeKey": "stake_test1uzl65wzu364hh0wxex94qsf5xkeaq2mnmc7xgnsnsjuqr4qruvxwu"
2327
}
2428
```
2529

@@ -65,7 +69,7 @@ To add tokens to the `Perma Lock FT` contract:
6569
./02_permaLockFT.sh 123456789
6670
```
6771

68-
The command above locks 123,456,789 tokens into the contract, as specified in the `start_info.json`.
72+
The command above locks 123,456,789 tokens into the contract, as specified in the `config.json`.
6973

7074
To add tokens to the `Perma Lock NFT` contract:
7175

@@ -81,6 +85,6 @@ The command above locks some amount of tokens into the contract, as specified by
8185

8286
Worst case for the nft lock is 64 unique policy ids. On pre-production, the UTxO `2981fdc49509b9cfc1c122b0dfc2563f29e49c2a07337ad55da3e2017a561124#0` is currently maxed out.
8387

84-
Worst case for the nft lock per transaction is 36. On pre-production, the UTxO `ff9b410414a5a5c0a2f63e9358b7299d296bb304ae579360dccf008357149809` shows the maximum amount of tokens for a single transaction.
88+
Worst case for the nft lock per transaction is 36. On pre-production, the transaction `ff9b410414a5a5c0a2f63e9358b7299d296bb304ae579360dccf008357149809` shows the maximum amount of tokens for a single transaction.
8589

8690
The max memory parameter would have to be increased at the protocol level to account for more unique policy ids on the UTxO.

aiken.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name = "dripdropz/perma-lock"
2-
version = "1.1.2"
2+
version = "1.1.3"
33
license = "GPL-3.0-or-later"
44
description = "Perma Lock Contract For Dripdropz"
55

complete_build.sh

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -27,18 +27,19 @@ aiken build --trace-level compact --filter-traces all
2727
echo -e "\033[1;34m\nBuilding FT Contract \033[0m"
2828

2929
# the locking token information
30-
locking_pid=$(jq -r '.lockingPid' start_info.json)
31-
locking_tkn=$(jq -r '.lockingTkn' start_info.json)
30+
locking_pid=$(jq -r '.lockingPid' config.json)
31+
locking_tkn=$(jq -r '.lockingTkn' config.json)
3232

3333
# convert token info into proper cbor
3434
locking_pid_cbor=$(python3 -c "import cbor2;hex_string='${locking_pid}';data = bytes.fromhex(hex_string);encoded = cbor2.dumps(data);print(encoded.hex())")
3535
locking_tkn_cbor=$(python3 -c "import cbor2;hex_string='${locking_tkn}';data = bytes.fromhex(hex_string);encoded = cbor2.dumps(data);print(encoded.hex())")
3636

3737
# randomly generate a length 32 hex string
38-
random_string=$(LC_ALL=C tr -dc a-f0-9 </dev/urandom | head -c 32)
39-
random_cbor=$(python3 -c "import cbor2;hex_string='${random_string}';data = bytes.fromhex(hex_string);encoded = cbor2.dumps(data);print(encoded.hex())")
38+
# random_string1=$(LC_ALL=C tr -dc a-f0-9 </dev/urandom | head -c 32)
39+
random_string1=$(jq -r '.randomString1' config.json)
40+
random_cbor=$(python3 -c "import cbor2;hex_string='${random_string1}';data = bytes.fromhex(hex_string);encoded = cbor2.dumps(data);print(encoded.hex())")
4041

41-
echo Random String 1: ${random_string}
42+
echo Random String 1: ${random_string1}
4243

4344
echo -e "\033[1;33m Convert Perma Lock FT Contract \033[0m"
4445

@@ -57,10 +58,11 @@ aiken blueprint convert -v perma_lock_ft.params > contracts/perma_lock_ft_contra
5758
echo -e "\033[1;34m\nBuilding NFT Contract \033[0m"
5859

5960
# randomly generate a length 32 hex string
60-
random_string=$(LC_ALL=C tr -dc a-f0-9 </dev/urandom | head -c 32)
61-
random_cbor=$(python3 -c "import cbor2;hex_string='${random_string}';data = bytes.fromhex(hex_string);encoded = cbor2.dumps(data);print(encoded.hex())")
61+
# random_string=$(LC_ALL=C tr -dc a-f0-9 </dev/urandom | head -c 32)
62+
random_string2=$(jq -r '.randomString2' config.json)
63+
random_cbor=$(python3 -c "import cbor2;hex_string='${random_string2}';data = bytes.fromhex(hex_string);encoded = cbor2.dumps(data);print(encoded.hex())")
6264

63-
echo Random String 2: ${random_string}
65+
echo Random String 2: ${random_string2}
6466

6567
echo -e "\033[1;33m Convert Perma Lock NFT Contract \033[0m"
6668

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
{
2-
"__comment1__": "This is the ft to lock for the perma lock ft contract",
2+
"__comment1__": "The FT compile information",
33
"lockingPid": "d441227553a0f1a965fee7d60a0f724b368dd1bddbc208730fccebcf",
44
"lockingTkn": "546869735f49735f415f566572795f4c6f6e675f537472696e675f5f5f5f5f5f",
5-
"__comment2__": "This is maximum amount of the ft in existence.",
65
"maxTokenAmt": 9223372036854775807,
7-
"__comment3__": "Place a static stake key here",
6+
"randomString1": "acab",
7+
"__comment2__": "The NFT compile information",
8+
"randomString2": "acab",
9+
"__comment3__": "Place a static stake key here for testing",
810
"stakeKey": "stake_test1uzl65wzu364hh0wxex94qsf5xkeaq2mnmc7xgnsnsjuqr4qruvxwu"
911
}

plutus.json

Lines changed: 0 additions & 99 deletions
This file was deleted.

scripts/all_balances.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ cli=$(cat ./data/path_to_cli.sh)
66
testnet_magic=$(cat ./data/testnet.magic)
77

88
# stake key
9-
stake_key=$(jq -r '.stakeKey' ../start_info.json)
9+
stake_key=$(jq -r '.stakeKey' ../config.json)
1010

1111
# perma lock ft contract
1212
perma_lock_ft_script_path="../contracts/perma_lock_ft_contract.plutus"

scripts/lock_ft/01_createPermaLockFTUTxO.sh

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ cli=$(cat ../data/path_to_cli.sh)
66
testnet_magic=$(cat ../data/testnet.magic)
77

88
# stake key
9-
stake_key=$(jq -r '.stakeKey' ../../start_info.json)
9+
stake_key=$(jq -r '.stakeKey' ../../config.json)
1010

1111
# perma lock contract
1212
perma_lock_ft_script_path="../../contracts/perma_lock_ft_contract.plutus"
@@ -18,9 +18,9 @@ user_address=$(cat ../wallets/${user_path}/payment.addr)
1818
user_pkh=$(${cli} address key-hash --payment-verification-key-file ../wallets/${user_path}/payment.vkey)
1919

2020
# this is the maximum amount of tokens that could possible exist
21-
locking_pid=$(jq -r '.lockingPid' ../../start_info.json)
22-
locking_tkn=$(jq -r '.lockingTkn' ../../start_info.json)
23-
max_tkn_amt=$(jq -r '.maxTokenAmt' ../../start_info.json)
21+
locking_pid=$(jq -r '.lockingPid' ../../config.json)
22+
locking_tkn=$(jq -r '.lockingTkn' ../../config.json)
23+
max_tkn_amt=$(jq -r '.maxTokenAmt' ../../config.json)
2424
worst_case_value="${max_tkn_amt} ${locking_pid}.${locking_tkn}"
2525

2626
# calc the min ada required for the worst case value and datum

scripts/lock_ft/02_permaLockFT.sh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ python -c "import json; data=json.load(open('../data/add-ft-redeemer.json', 'r')
2222
# python -c "import json; data=json.load(open('../data/add-ft-redeemer.json', 'r')); data['fields'][0]['int'] = $token_amt; json.dump(data, open('../data/add-ft-redeemer.json', 'w'), indent=2)"
2323

2424
# stake key
25-
stake_key=$(jq -r '.stakeKey' ../../start_info.json)
25+
stake_key=$(jq -r '.stakeKey' ../../config.json)
2626

2727
# perma lock contract
2828
perma_lock_ft_script_path="../../contracts/perma_lock_ft_contract.plutus"
@@ -53,8 +53,8 @@ TXIN=$(jq -r --arg alltxin "" 'keys[] | . + $alltxin + " --tx-in"' ../tmp/script
5353
script_tx_in=${TXIN::-8}
5454

5555

56-
locking_pid=$(jq -r '.lockingPid' ../../start_info.json)
57-
locking_tkn=$(jq -r '.lockingTkn' ../../start_info.json)
56+
locking_pid=$(jq -r '.lockingPid' ../../config.json)
57+
locking_tkn=$(jq -r '.lockingTkn' ../../config.json)
5858
# this should work for the min lovelace
5959
script_lovelace=$(jq '[.[] | .value.lovelace] | add' ../tmp/script_utxo.json)
6060
# get the current token amount but account for numbers below 2^63 -1

scripts/lock_nft/01_createPermaLockNFTUTxO.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ cli=$(cat ../data/path_to_cli.sh)
66
testnet_magic=$(cat ../data/testnet.magic)
77

88
# stake key
9-
stake_key=$(jq -r '.stakeKey' ../../start_info.json)
9+
stake_key=$(jq -r '.stakeKey' ../../config.json)
1010

1111
# perma lock contract
1212
perma_lock_nft_script_path="../../contracts/perma_lock_nft_contract.plutus"

0 commit comments

Comments
 (0)