Skip to content

Commit 33a68c1

Browse files
Merge pull request #5 from projectNEWM/candidate-for-v1.0.0
Candidate for v1.0.0
2 parents 111b308 + 9cbb5f8 commit 33a68c1

17 files changed

+80
-105
lines changed

.github/workflows/tests.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ jobs:
1313

1414
- uses: aiken-lang/setup-aiken@v0.1.0
1515
with:
16-
version: v1.0.29-alpha
16+
version: v1.0.28-alpha
1717

1818
- run: aiken fmt --check
1919
- run: aiken check -D

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# NEWM Minter
1+
# Project NEWM's Fractional Minting Contract"
22

33
Fractionalization refers to the process of dividing the ownership of streaming rights of a piece of art into 100 million pieces. The resulting fractions are given to the artist, who has the freedom to sell or trade them as they wish, or can be sold on the NEWM marketplace with the proceeds going directly to the artist.
44

aiken.toml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
name = "projectnewm/newm-minter"
2-
version = "0.0.1"
1+
name = "projectNEWM/newm-minter"
2+
version = "1.0.0"
33
compiler = "v1.0.29-alpha"
44
plutus = "v2"
55
license = "GPL-3.0-or-later"
6-
description = "Aiken contracts for project NEWM"
6+
description = "Project NEWM's Fractional Minting Contract"
77

88
[repository]
99
user = "projectNEWM"

complete_build.sh

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ function cat_file_or_empty() {
1313
mkdir -p contracts
1414
mkdir -p hashes
1515
mkdir -p certs
16+
mkdir -p scripts/tmp
1617

1718
# remove old files
1819
rm contracts/* || true
@@ -29,21 +30,25 @@ aiken build --trace-level silent --filter-traces user-defined
2930
# keep the traces
3031
# aiken build --trace-level verbose --filter-traces all
3132

33+
# the reference token
34+
pid=$(jq -r '.starterPid' config.json)
35+
tkn=$(jq -r '.starterTkn' config.json)
36+
37+
# cbor representation
38+
pid_cbor=$(python3 -c "import cbor2;hex_string='${pid}';data = bytes.fromhex(hex_string);encoded = cbor2.dumps(data);print(encoded.hex())")
39+
tkn_cbor=$(python3 -c "import cbor2;hex_string='${tkn}';data = bytes.fromhex(hex_string);encoded = cbor2.dumps(data);print(encoded.hex())")
40+
3241
echo -e "\033[1;33m Convert Reference Contract \033[0m"
42+
aiken blueprint apply -o plutus.json -v reference.params "${pid_cbor}"
43+
aiken blueprint apply -o plutus.json -v reference.params "${tkn_cbor}"
3344
aiken blueprint convert -v reference.params > contracts/reference_contract.plutus
3445
cardano-cli transaction policyid --script-file contracts/reference_contract.plutus > hashes/reference_contract.hash
3546

3647
# reference hash
3748
ref=$(cat hashes/reference_contract.hash)
3849

39-
# the reference token
40-
pid=$(jq -r '.starterPid' config.json)
41-
tkn=$(jq -r '.starterTkn' config.json)
42-
4350
# cbor representation
4451
ref_cbor=$(python3 -c "import cbor2;hex_string='${ref}';data = bytes.fromhex(hex_string);encoded = cbor2.dumps(data);print(encoded.hex())")
45-
pid_cbor=$(python3 -c "import cbor2;hex_string='${pid}';data = bytes.fromhex(hex_string);encoded = cbor2.dumps(data);print(encoded.hex())")
46-
tkn_cbor=$(python3 -c "import cbor2;hex_string='${tkn}';data = bytes.fromhex(hex_string);encoded = cbor2.dumps(data);print(encoded.hex())")
4752

4853
# The pool to stake at
4954
poolId=$(jq -r '.poolId' config.json)
@@ -66,9 +71,14 @@ aiken blueprint convert -v storage.params > contracts/storage_contract.plutus
6671
cardano-cli transaction policyid --script-file contracts/storage_contract.plutus > hashes/storage.hash
6772

6873
echo -e "\033[1;33m Convert Minting Contract \033[0m"
74+
75+
ran=$(jq -r '.random' config.json)
76+
ran_cbor=$(python3 -c "import cbor2;hex_string='${ran}';data = bytes.fromhex(hex_string);encoded = cbor2.dumps(data);print(encoded.hex())")
77+
6978
aiken blueprint apply -o plutus.json -v minter.params "${pid_cbor}"
7079
aiken blueprint apply -o plutus.json -v minter.params "${tkn_cbor}"
7180
aiken blueprint apply -o plutus.json -v minter.params "${ref_cbor}"
81+
aiken blueprint apply -o plutus.json -v minter.params "${ran_cbor}"
7282
aiken blueprint convert -v minter.params > contracts/mint_contract.plutus
7383
cardano-cli transaction policyid --script-file contracts/mint_contract.plutus > hashes/policy.hash
7484

config.json

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
{
22
"__comment1__": "This is the starter token for the data reference contract",
3-
"starterPid": "4d6d1192d39a48f4c80edbe52a5c480bec0a4e0711a998ca016b81a5",
4-
"starterTkn": "000643b00103289c658acdbc1f19516855e2d043c379195afbe4dcba5381c836",
3+
"starterPid": "b88cdb6d77bcb6ca9a227bab5d0b6a3b4a47960b41cbab4ede0c8b00",
4+
"starterTkn": "6ca2a0f0d17ec1732611675702ba9672ab033a6bf7fffb1aaf35cf3caf8b5cc4",
55
"__comment2__": "The change address for the starter token transaction",
66
"starterChangeAddr": "addr_test1qrvnxkaylr4upwxfxctpxpcumj0fl6fdujdc72j8sgpraa9l4gu9er4t0w7udjvt2pqngddn6q4h8h3uv38p8p9cq82qav4lmp",
77
"__comment3__": "This is the initial pool id for staking",
88
"poolId": "1e3105f23f2ac91b3fb4c35fa4fe301421028e356e114944e902005b",
99
"__comment4__": "The NEWM hot key",
10-
"hotKey": "f4a78bbff6d5e7e492915986abc495382247af659018451a25cec92c"
10+
"hotKey": "f4a78bbff6d5e7e492915986abc495382247af659018451a25cec92c",
11+
"__comment5__": "A random bytestring",
12+
"random": "00112233445566778899aabbccddeeff"
1113
}

lib/py/getTokenName.py

Lines changed: 25 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,29 @@
22
import hashlib
33

44

5-
def token_name(txHash, index, prefix):
5+
def token_name(txHash: str, index: int, prefix: str) -> str:
6+
"""
7+
Generates a token name based on the transaction hash, index, and prefix.
8+
This function follows the assist library's unique_token_name function.
9+
10+
Args:
11+
txHash (str): Transaction hash
12+
index (int): Transaction Index
13+
prefix (str): CIP 68 standard prefix
14+
15+
Returns:
16+
str: The token name.
17+
18+
Examples:
19+
>>> token_name("1FA3625AC5DABFBEDFD80EEDFB5BEA37D8E8D66362C22300C2E4C00951449B18", 0, "000643b0")
20+
'000643b000a6bf2d5e45c1b7c91e6f0028c0af7ecedd131367e06d923e7d2819'
21+
22+
>>> token_name("1FA3625AC5DABFBEDFD80EEDFB5BEA37D8E8D66362C22300C2E4C00951449B18", 24, "001bc280")
23+
'001bc28018a6bf2d5e45c1b7c91e6f0028c0af7ecedd131367e06d923e7d2819'
24+
25+
>>> token_name("AB69AAB2EFE96149CA2FC045F8CDFADAA2213E5F71F7F427632AC1216BD6106D", 0, "000643b0")
26+
'000643b00001f1ca8bb6ed0bd798019448bf8b5b9a539958477b53fd86c6d27e'
27+
"""
628
txBytes = binascii.unhexlify(txHash)
729
h = hashlib.new('sha3_256')
830
h.update(txBytes)
@@ -11,19 +33,9 @@ def token_name(txHash, index, prefix):
1133
if "x" in x:
1234
x = x.replace("x", "0")
1335
txHash = prefix + x + txHash
14-
print(txHash[0:64])
1536
return txHash[0:64]
1637

1738

1839
if __name__ == "__main__":
19-
prefix_100 = "000643b0"
20-
21-
prefix_444 = "001bc280"
22-
23-
print('reference', token_name(
24-
"1FA3625AC5DABFBEDFD80EEDFB5BEA37D8E8D66362C22300C2E4C00951449B18", 0, prefix_100))
25-
26-
print('fractions', token_name(
27-
"1FA3625AC5DABFBEDFD80EEDFB5BEA37D8E8D66362C22300C2E4C00951449B18", 0, prefix_444))
28-
29-
print(token_name("AB69AAB2EFE96149CA2FC045F8CDFADAA2213E5F71F7F427632AC1216BD6106D", 0, prefix_100) == "000643b00001f1ca8bb6ed0bd798019448bf8b5b9a539958477b53fd86c6d27e")
40+
import doctest
41+
doctest.testmod()

scripts/00_createScriptReferences.sh

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@ mkdir -p ./tmp
1212
${cli} query protocol-parameters ${network} --out-file ./tmp/protocol.json
1313

1414
# Addresses
15-
reference_address=$(cat ./wallets/reference-wallet/payment.addr)
15+
reference_path="./wallets/reference-wallet"
16+
reference_address=$(cat ${reference_path}/payment.addr)
1617
script_reference_address=$(cat ./wallets/reference-wallet/payment.addr)
1718

1819
echo -e "\033[0;35m\nGathering UTxO Information \033[0m"
@@ -29,6 +30,10 @@ fi
2930
alltxin=""
3031
txin=$(jq -r --arg alltxin "" 'to_entries[] | select(.value.value | length < 2) | .key | . + $alltxin + " --tx-in"' ./tmp/reference_utxo.json)
3132
ref_tx_in=${txin::-8}
33+
34+
echo -e "\033[0;36mFirst UTxO:\033[0m"
35+
echo -e "\033[0;36m$ref_tx_in \033[0m"
36+
3237
changeAmount=$(jq '[.. | objects | .lovelace] | add' ./tmp/reference_utxo.json)
3338

3439
counter=0
@@ -86,7 +91,7 @@ do
8691
--fee ${fee}
8792

8893
${cli} transaction sign \
89-
--signing-key-file ./wallets/reference-wallet/payment.skey \
94+
--signing-key-file ${reference_path}/payment.skey \
9095
--tx-body-file ./tmp/tx.draft \
9196
--out-file ./tmp/${first_word}-reference-utxo.signed \
9297
${network}

scripts/data/reference/backup-reference-datum.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,10 +48,10 @@
4848
"constructor": 0,
4949
"fields": [
5050
{
51-
"bytes": "1fd64c0c748222ac229e9d697ecffa699e0c67008950c507ff43ae6c"
51+
"bytes": "9716578e980be10a47ecb36a0a2c6a71e6142be10cdc15e1e286396a"
5252
},
5353
{
54-
"bytes": "53f58f16bf228ecc7c3e2ff2a6887767d914e1b726e1e551eac5172b"
54+
"bytes": "3106ac51de4266a08f73099f20627d8749bb7f495ffecd93b9f50cfe"
5555
}
5656
]
5757
}
Lines changed: 0 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -1,59 +0,0 @@
1-
{
2-
"constructor": 0,
3-
"fields": [
4-
{
5-
"bytes": "f4a78bbff6d5e7e492915986abc495382247af659018451a25cec92c"
6-
},
7-
{
8-
"constructor": 0,
9-
"fields": [
10-
{
11-
"list": [
12-
{
13-
"bytes": "d858ecf3e73e18bef8383a16e856778e033cfd1c8867c70dc9b68b42"
14-
},
15-
{
16-
"bytes": "10a20db9464d89dab407b3397e67facf83db8d442e601b627c0a351f"
17-
},
18-
{
19-
"bytes": "121ce13907d40c7a598d182ed751d39279cf30d50decb17151b3a587"
20-
}
21-
]
22-
},
23-
{
24-
"int": 2
25-
}
26-
]
27-
},
28-
{
29-
"constructor": 0,
30-
"fields": [
31-
{
32-
"bytes": "1e3105f23f2ac91b3fb4c35fa4fe301421028e356e114944e902005b"
33-
},
34-
{
35-
"constructor": 0,
36-
"fields": [
37-
{
38-
"bytes": "8f7b0ce283a92df9a3b69ac0b8f10d8bc8bcf8fbd1fe72596ee8bd6c"
39-
},
40-
{
41-
"bytes": ""
42-
}
43-
]
44-
}
45-
]
46-
},
47-
{
48-
"constructor": 0,
49-
"fields": [
50-
{
51-
"bytes": "1fd64c0c748222ac229e9d697ecffa699e0c67008950c507ff43ae6c"
52-
},
53-
{
54-
"bytes": "53f58f16bf228ecc7c3e2ff2a6887767d914e1b726e1e551eac5172b"
55-
}
56-
]
57-
}
58-
]
59-
}

scripts/data/reference/reference-datum.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,10 +48,10 @@
4848
"constructor": 0,
4949
"fields": [
5050
{
51-
"bytes": "1fd64c0c748222ac229e9d697ecffa699e0c67008950c507ff43ae6c"
51+
"bytes": "9716578e980be10a47ecb36a0a2c6a71e6142be10cdc15e1e286396a"
5252
},
5353
{
54-
"bytes": "53f58f16bf228ecc7c3e2ff2a6887767d914e1b726e1e551eac5172b"
54+
"bytes": "3106ac51de4266a08f73099f20627d8749bb7f495ffecd93b9f50cfe"
5555
}
5656
]
5757
}

0 commit comments

Comments
 (0)