Skip to content

Commit 31411ab

Browse files
committed
added support for "nameless" assets
- Added support to mint and burn Assets without Token-Names - Added support to send Assets without Token-Names - Added support to do transactions with nameless Tokens on the payment address We don't like those nameless Assets/Tokens, but we have to deal with it.
1 parent 6400c9e commit 31411ab

12 files changed

+77
-42
lines changed

Diff for: cardano/testnet/01_claimRewards.sh

+14-7
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
. "$(dirname "$0")"/00_common.sh
1111

1212
case $# in
13-
2|3 ) stakeAddr="$(dirname $1)/$(basename $1 .staking).staking"; stakeAddr=${stakeAddr/#.\//}
13+
2|3|4 ) stakeAddr="$(dirname $1)/$(basename $1 .staking).staking"; stakeAddr=${stakeAddr/#.\//}
1414
toAddr="$(dirname $2)/$(basename $2 .addr)"; toAddr=${toAddr/#.\//};;
1515
* ) cat >&2 <<EOF
1616
Usage: $(basename $0) <StakeAddressName> <To AddressName> [optional <FeePaymentAddressName>]
@@ -24,7 +24,7 @@ if [ ! -f "${toAddr}.addr" ]; then echo "$(basename ${toAddr})" > ${tempDir}/tem
2424

2525
#Check if an optional fee payment address is given and different to the receiver address
2626
fromAddr=${toAddr}
27-
if [[ $# -eq 3 ]]; then fromAddr="$(dirname $3)/$(basename $3 .addr)"; fi
27+
if [ $# -eq 3 ] && [ ! "${3^^}" == "ONLYADA" ]; then fromAddr="$(dirname $3)/$(basename $3 .addr)"; fi
2828
if [[ "${fromAddr}" == "${toAddr}" ]]; then rxcnt="1"; else rxcnt="2"; fi
2929

3030
#Checks for needed files
@@ -40,7 +40,8 @@ if ! [[ -f "${fromAddr}.skey" || -f "${fromAddr}.hwsfile" ]]; then echo -e "\n\e
4040

4141
echo -e "\e[0mClaim Staking Rewards from Address\e[32m ${stakeAddr}.addr\e[0m with funds from Address\e[32m ${fromAddr}.addr\e[0m"
4242
echo
43-
echo
43+
44+
lastCallParam=${@: -1};
4445

4546
#get live values
4647
currentTip=$(get_currentTip)
@@ -116,12 +117,17 @@ echo
116117
utxoJSON=$(jq -r ".address.\"${sendFromAddr}\".utxoJSON" <<< ${offlineJSON})
117118
if [[ "${utxoJSON}" == null ]]; then echo -e "\e[35mPayment-Address not included in the offline transferFile, please include it first online!\e[0m\n"; exit; fi
118119
fi
119-
txcnt=$(jq length <<< ${utxoJSON}) #Get number of UTXO entries (Hash#Idx), this is also the number of --tx-in for the transaction
120-
if [[ ${txcnt} == 0 ]]; then echo -e "\e[35mNo funds on the Source Address!\e[0m\n"; exit; else echo -e "\e[32m${txcnt} UTXOs\e[0m found on the Source Address!\n"; fi
121120

122121
#Convert UTXO into mary style if UTXO is shelley/allegra style
123122
if [[ ! "$(jq -r '[.[]][0].amount | type' <<< ${utxoJSON})" == "array" ]]; then utxoJSON=$(convert_UTXO "${utxoJSON}"); fi
124123

124+
#Only use UTXOs with lovelaces in it if Scripts was called with the last parameter keyword "ONLYADA"
125+
if [[ "${lastCallParam^^}" == "ONLYADA" ]]; then echo -e "\e[0mUTXO-Mode: \e[32mOnly UTXOs with ADA(lovelaces) on it, no Assets\e[0m\n"; utxoJSON=$(onlyLovelaces_UTXO "${utxoJSON}"); fi
126+
127+
txcnt=$(jq length <<< ${utxoJSON}) #Get number of UTXO entries (Hash#Idx), this is also the number of --tx-in for the transaction
128+
if [[ ${txcnt} == 0 ]]; then echo -e "\e[35mNo funds on the Source Address!\e[0m\n"; exit; else echo -e "\e[32m${txcnt} UTXOs\e[0m found on the Source Address!\n"; fi
129+
130+
125131
#Calculating the total amount of lovelaces in all utxos on this address
126132
totalLovelaces=$(jq '[.[].amount[0]] | add' <<< ${utxoJSON})
127133

@@ -152,9 +158,10 @@ echo
152158
do
153159
assetName=$(jq -r ".[${tmpCnt2}][1][${tmpCnt3}][0]" <<< ${assetsJSON})
154160
assetAmount=$(jq -r ".[${tmpCnt2}][1][${tmpCnt3}][1]" <<< ${assetsJSON})
155-
oldValue=$(jq -r ".\"${assetHash}.${assetName}\".amount" <<< ${totalAssetsJSON})
161+
if [[ "${assetName}" == "" ]]; then point=""; else point="."; fi
162+
oldValue=$(jq -r ".\"${assetHash}${point}${assetName}\".amount" <<< ${totalAssetsJSON})
156163
newValue=$((${oldValue}+${assetAmount}))
157-
totalAssetsJSON=$( jq ". += {\"${assetHash}.${assetName}\":{amount: ${newValue}, name: \"${assetName}\"}}" <<< ${totalAssetsJSON})
164+
totalAssetsJSON=$( jq ". += {\"${assetHash}${point}${assetName}\":{amount: ${newValue}, name: \"${assetName}\"}}" <<< ${totalAssetsJSON})
158165
echo -e "\e[90m PolID: ${assetHash}\tAmount: ${assetAmount} ${assetName}\e[0m"
159166
done
160167
done

Diff for: cardano/testnet/01_queryAddress.sh

+3-2
Original file line numberDiff line numberDiff line change
@@ -80,9 +80,10 @@ if [[ ${typeOfAddr} == ${addrTypePayment} ]]; then #Enterprise and Base UTXO ad
8080
do
8181
assetName=$(jq -r ".[${tmpCnt2}][1][${tmpCnt3}][0]" <<< ${assetsJSON})
8282
assetAmount=$(jq -r ".[${tmpCnt2}][1][${tmpCnt3}][1]" <<< ${assetsJSON})
83-
oldValue=$(jq -r ".\"${assetHash}.${assetName}\".amount" <<< ${totalAssetsJSON})
83+
if [[ "${assetName}" == "" ]]; then point=""; else point="."; fi
84+
oldValue=$(jq -r ".\"${assetHash}${point}${assetName}\".amount" <<< ${totalAssetsJSON})
8485
newValue=$((${oldValue}+${assetAmount}))
85-
totalAssetsJSON=$( jq ". += {\"${assetHash}.${assetName}\":{amount: ${newValue}, name: \"${assetName}\"}}" <<< ${totalAssetsJSON})
86+
totalAssetsJSON=$( jq ". += {\"${assetHash}${point}${assetName}\":{amount: ${newValue}, name: \"${assetName}\"}}" <<< ${totalAssetsJSON})
8687
echo -e "\e[90m PolID: ${assetHash}\tAmount: ${assetAmount} ${assetName}\e[0m"
8788
done
8889
done

Diff for: cardano/testnet/01_sendAssets.sh

+10-4
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,13 @@ if [ ! -f "${fromAddr}.skey" ]; then echo -e "\n\e[35mERROR - \"${fromAddr}.skey
2929
if [ ! -f "${toAddr}.addr" ]; then echo "$(basename ${toAddr})" > ${tempDir}/tempTo.addr; toAddr="${tempDir}/tempTo"; fi
3030

3131
#Check if the assetToSend is a file xxx.asset then read out the data from the file instead
32-
assetFile="$(dirname ${assetToSend})/$(basename ${assetToSend} .asset).asset"
33-
if [ -f "${assetFile}" ]; then assetToSend="$(jq -r .policyID < ${assetFile}).$(jq -r .name < ${assetFile})"; fi
32+
assetFile="$(dirname ${assetToSend})/$(basename "${assetToSend}" .asset).asset"
33+
34+
if [ -f "${assetFile}" ]; then
35+
tmpAssetPolicy="$(jq -r .policyID < ${assetFile})"
36+
tmpAssetName="$(jq -r .name < ${assetFile})"
37+
if [[ "${tmpAssetName}" == "" ]]; then assetToSend="${tmpAssetPolicy}"; else assetToSend="${tmpAssetPolicy}.${tmpAssetName}"; fi
38+
fi
3439

3540
echo -e "\e[0mSending assets from Address\e[32m ${fromAddr}.addr\e[0m to Address\e[32m ${toAddr}.addr\e[0m:"
3641
echo
@@ -98,9 +103,10 @@ echo
98103
do
99104
assetName=$(jq -r ".[${tmpCnt2}][1][${tmpCnt3}][0]" <<< ${assetsJSON})
100105
assetAmount=$(jq -r ".[${tmpCnt2}][1][${tmpCnt3}][1]" <<< ${assetsJSON})
101-
oldValue=$(jq -r ".\"${assetHash}.${assetName}\".amount" <<< ${totalAssetsJSON})
106+
if [[ "${assetName}" == "" ]]; then point=""; else point="."; fi
107+
oldValue=$(jq -r ".\"${assetHash}${point}${assetName}\".amount" <<< ${totalAssetsJSON})
102108
newValue=$((${oldValue}+${assetAmount}))
103-
totalAssetsJSON=$( jq ". += {\"${assetHash}.${assetName}\":{amount: ${newValue}, name: \"${assetName}\"}}" <<< ${totalAssetsJSON})
109+
totalAssetsJSON=$( jq ". += {\"${assetHash}${point}${assetName}\":{amount: ${newValue}, name: \"${assetName}\"}}" <<< ${totalAssetsJSON})
104110
echo -e "\e[90m PolID: ${assetHash}\tAmount: ${assetAmount} ${assetName}\e[0m"
105111
done
106112
done

Diff for: cardano/testnet/01_sendLovelaces.sh

+3-2
Original file line numberDiff line numberDiff line change
@@ -95,9 +95,10 @@ echo
9595
do
9696
assetName=$(jq -r ".[${tmpCnt2}][1][${tmpCnt3}][0]" <<< ${assetsJSON})
9797
assetAmount=$(jq -r ".[${tmpCnt2}][1][${tmpCnt3}][1]" <<< ${assetsJSON})
98-
oldValue=$(jq -r ".\"${assetHash}.${assetName}\".amount" <<< ${totalAssetsJSON})
98+
if [[ "${assetName}" == "" ]]; then point=""; else point="."; fi
99+
oldValue=$(jq -r ".\"${assetHash}${point}${assetName}\".amount" <<< ${totalAssetsJSON})
99100
newValue=$((${oldValue}+${assetAmount}))
100-
totalAssetsJSON=$( jq ". += {\"${assetHash}.${assetName}\":{amount: ${newValue}, name: \"${assetName}\"}}" <<< ${totalAssetsJSON})
101+
totalAssetsJSON=$( jq ". += {\"${assetHash}${point}${assetName}\":{amount: ${newValue}, name: \"${assetName}\"}}" <<< ${totalAssetsJSON})
101102
echo -e "\e[90m PolID: ${assetHash}\tAmount: ${assetAmount} ${assetName}\e[0m"
102103
done
103104
done

Diff for: cardano/testnet/01_sendVoteMeta.sh

+3-2
Original file line numberDiff line numberDiff line change
@@ -133,9 +133,10 @@ echo
133133
do
134134
assetName=$(jq -r ".[${tmpCnt2}][1][${tmpCnt3}][0]" <<< ${assetsJSON})
135135
assetAmount=$(jq -r ".[${tmpCnt2}][1][${tmpCnt3}][1]" <<< ${assetsJSON})
136-
oldValue=$(jq -r ".\"${assetHash}.${assetName}\".amount" <<< ${totalAssetsJSON})
136+
if [[ "${assetName}" == "" ]]; then point=""; else point="."; fi
137+
oldValue=$(jq -r ".\"${assetHash}${point}${assetName}\".amount" <<< ${totalAssetsJSON})
137138
newValue=$((${oldValue}+${assetAmount}))
138-
totalAssetsJSON=$( jq ". += {\"${assetHash}.${assetName}\":{amount: ${newValue}, name: \"${assetName}\"}}" <<< ${totalAssetsJSON})
139+
totalAssetsJSON=$( jq ". += {\"${assetHash}${point}${assetName}\":{amount: ${newValue}, name: \"${assetName}\"}}" <<< ${totalAssetsJSON})
139140
echo -e "\e[90m PolID: ${assetHash}\tAmount: ${assetAmount} ${assetName}\e[0m"
140141
done
141142
done

Diff for: cardano/testnet/03b_regStakingAddrCert.sh

+3-2
Original file line numberDiff line numberDiff line change
@@ -99,9 +99,10 @@ echo
9999
do
100100
assetName=$(jq -r ".[${tmpCnt2}][1][${tmpCnt3}][0]" <<< ${assetsJSON})
101101
assetAmount=$(jq -r ".[${tmpCnt2}][1][${tmpCnt3}][1]" <<< ${assetsJSON})
102-
oldValue=$(jq -r ".\"${assetHash}.${assetName}\".amount" <<< ${totalAssetsJSON})
102+
if [[ "${assetName}" == "" ]]; then point=""; else point="."; fi
103+
oldValue=$(jq -r ".\"${assetHash}${point}${assetName}\".amount" <<< ${totalAssetsJSON})
103104
newValue=$((${oldValue}+${assetAmount}))
104-
totalAssetsJSON=$( jq ". += {\"${assetHash}.${assetName}\":{amount: ${newValue}, name: \"${assetName}\"}}" <<< ${totalAssetsJSON})
105+
totalAssetsJSON=$( jq ". += {\"${assetHash}${point}${assetName}\":{amount: ${newValue}, name: \"${assetName}\"}}" <<< ${totalAssetsJSON})
105106
echo -e "\e[90m PolID: ${assetHash}\tAmount: ${assetAmount} ${assetName}\e[0m"
106107
done
107108
done

Diff for: cardano/testnet/05c_regStakepoolCert.sh

+3-2
Original file line numberDiff line numberDiff line change
@@ -278,9 +278,10 @@ if [[ "${regWitnessID}" == "" ]]; then
278278
do
279279
assetName=$(jq -r ".[${tmpCnt2}][1][${tmpCnt3}][0]" <<< ${assetsJSON})
280280
assetAmount=$(jq -r ".[${tmpCnt2}][1][${tmpCnt3}][1]" <<< ${assetsJSON})
281-
oldValue=$(jq -r ".\"${assetHash}.${assetName}\".amount" <<< ${totalAssetsJSON})
281+
if [[ "${assetName}" == "" ]]; then point=""; else point="."; fi
282+
oldValue=$(jq -r ".\"${assetHash}${point}${assetName}\".amount" <<< ${totalAssetsJSON})
282283
newValue=$((${oldValue}+${assetAmount}))
283-
totalAssetsJSON=$( jq ". += {\"${assetHash}.${assetName}\":{amount: ${newValue}, name: \"${assetName}\"}}" <<< ${totalAssetsJSON})
284+
totalAssetsJSON=$( jq ". += {\"${assetHash}${point}${assetName}\":{amount: ${newValue}, name: \"${assetName}\"}}" <<< ${totalAssetsJSON})
284285
echo -e "\e[90m PolID: ${assetHash}\tAmount: ${assetAmount} ${assetName}\e[0m"
285286
done
286287
done

Diff for: cardano/testnet/06_regDelegationCert.sh

+3-2
Original file line numberDiff line numberDiff line change
@@ -97,9 +97,10 @@ echo
9797
do
9898
assetName=$(jq -r ".[${tmpCnt2}][1][${tmpCnt3}][0]" <<< ${assetsJSON})
9999
assetAmount=$(jq -r ".[${tmpCnt2}][1][${tmpCnt3}][1]" <<< ${assetsJSON})
100-
oldValue=$(jq -r ".\"${assetHash}.${assetName}\".amount" <<< ${totalAssetsJSON})
100+
if [[ "${assetName}" == "" ]]; then point=""; else point="."; fi
101+
oldValue=$(jq -r ".\"${assetHash}${point}${assetName}\".amount" <<< ${totalAssetsJSON})
101102
newValue=$((${oldValue}+${assetAmount}))
102-
totalAssetsJSON=$( jq ". += {\"${assetHash}.${assetName}\":{amount: ${newValue}, name: \"${assetName}\"}}" <<< ${totalAssetsJSON})
103+
totalAssetsJSON=$( jq ". += {\"${assetHash}${point}${assetName}\":{amount: ${newValue}, name: \"${assetName}\"}}" <<< ${totalAssetsJSON})
103104
echo -e "\e[90m PolID: ${assetHash}\tAmount: ${assetAmount} ${assetName}\e[0m"
104105
done
105106
done

Diff for: cardano/testnet/07b_deregStakepoolCert.sh

+3-2
Original file line numberDiff line numberDiff line change
@@ -113,9 +113,10 @@ echo
113113
do
114114
assetName=$(jq -r ".[${tmpCnt2}][1][${tmpCnt3}][0]" <<< ${assetsJSON})
115115
assetAmount=$(jq -r ".[${tmpCnt2}][1][${tmpCnt3}][1]" <<< ${assetsJSON})
116-
oldValue=$(jq -r ".\"${assetHash}.${assetName}\".amount" <<< ${totalAssetsJSON})
116+
if [[ "${assetName}" == "" ]]; then point=""; else point="."; fi
117+
oldValue=$(jq -r ".\"${assetHash}${point}${assetName}\".amount" <<< ${totalAssetsJSON})
117118
newValue=$((${oldValue}+${assetAmount}))
118-
totalAssetsJSON=$( jq ". += {\"${assetHash}.${assetName}\":{amount: ${newValue}, name: \"${assetName}\"}}" <<< ${totalAssetsJSON})
119+
totalAssetsJSON=$( jq ". += {\"${assetHash}${point}${assetName}\":{amount: ${newValue}, name: \"${assetName}\"}}" <<< ${totalAssetsJSON})
119120
echo -e "\e[90m PolID: ${assetHash}\tAmount: ${assetAmount} ${assetName}\e[0m"
120121
done
121122
done

Diff for: cardano/testnet/08b_deregStakingAddrCert.sh

+3-2
Original file line numberDiff line numberDiff line change
@@ -98,9 +98,10 @@ echo
9898
do
9999
assetName=$(jq -r ".[${tmpCnt2}][1][${tmpCnt3}][0]" <<< ${assetsJSON})
100100
assetAmount=$(jq -r ".[${tmpCnt2}][1][${tmpCnt3}][1]" <<< ${assetsJSON})
101-
oldValue=$(jq -r ".\"${assetHash}.${assetName}\".amount" <<< ${totalAssetsJSON})
101+
if [[ "${assetName}" == "" ]]; then point=""; else point="."; fi
102+
oldValue=$(jq -r ".\"${assetHash}${point}${assetName}\".amount" <<< ${totalAssetsJSON})
102103
newValue=$((${oldValue}+${assetAmount}))
103-
totalAssetsJSON=$( jq ". += {\"${assetHash}.${assetName}\":{amount: ${newValue}, name: \"${assetName}\"}}" <<< ${totalAssetsJSON})
104+
totalAssetsJSON=$( jq ". += {\"${assetHash}${point}${assetName}\":{amount: ${newValue}, name: \"${assetName}\"}}" <<< ${totalAssetsJSON})
104105
echo -e "\e[90m PolID: ${assetHash}\tAmount: ${assetAmount} ${assetName}\e[0m"
105106
done
106107
done

0 commit comments

Comments
 (0)