Skip to content

Commit

Permalink
Merge pull request #271 from multiversx/scripts-fixes
Browse files Browse the repository at this point in the history
Minor script fixes on v3.0 & v3.1
  • Loading branch information
iulianpascalau authored Jan 27, 2025
2 parents 55a4e89 + bb4bb99 commit fdedd78
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 6 deletions.
5 changes: 4 additions & 1 deletion multisig/interaction/config/menu_functions.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,6 @@ function remove-whitelist-token {
confirmation-with-skip removeWrappedToken
confirmation-with-skip wrapper-blacklistToken
confirmation-with-skip unsetLocalRolesEsdtSafe
confirmation-with-skip unsetLocalRolesMultiTransferEsdt
confirmation-with-skip clearMapping
confirmation-with-skip removeTokenFromWhitelist
}
Expand Down Expand Up @@ -220,3 +219,7 @@ function pause-v2-contracts {
confirmation-with-skip pauseAggregatorV2
confirmation-with-skip wrapper-pauseV2
}

function sync-value-with-eth-denom {
syncValueWithEthereumDenom
}
29 changes: 26 additions & 3 deletions multisig/interaction/config/multisig-snippets.sh
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,11 @@ addMapping() {
addTokenToWhitelist() {
CHECK_VARIABLES CHAIN_SPECIFIC_TOKEN CHAIN_SPECIFIC_TOKEN_TICKER MULTISIG MINTBURN_WHITELIST NATIVE_TOKEN

BALANCE=$(echo "$TOTAL_BALANCE*10^$NR_DECIMALS_CHAIN_SPECIFIC" | bc)
MINT=$(echo "$MINT_BALANCE*10^$NR_DECIMALS_CHAIN_SPECIFIC" | bc)
BURN=$(echo "$BURN_BALANCE*10^$NR_DECIMALS_CHAIN_SPECIFIC" | bc)
# bc will apply the scale value if a division operation is present in the expression
# we need scaling as to avoid passing to mxpy values as 4624157209902.000000 (which will error) but instead 4624157209902
BALANCE=$(echo "scale=0; $TOTAL_BALANCE*10^$NR_DECIMALS_CHAIN_SPECIFIC/1" | bc)
MINT=$(echo "scale=0; $MINT_BALANCE*10^$NR_DECIMALS_CHAIN_SPECIFIC/1" | bc)
BURN=$(echo "scale=0; $BURN_BALANCE*10^$NR_DECIMALS_CHAIN_SPECIFIC/1" | bc)

mxpy contract call ${MULTISIG} --recall-nonce "${MXPY_SIGN[@]}" \
--gas-limit=60000000 --function="esdtSafeAddTokenToWhitelist" \
Expand Down Expand Up @@ -248,6 +250,27 @@ initSupplyMintBurn() {
--send --proxy=${PROXY} --chain=${CHAIN_ID}
}

syncValueWithEthereumDenom() {
CHECK_VARIABLES MULTISIG SAFE

read -p "Chain specific token (human readable): " TOKEN
read -p "Denominated value on Ethereum (should contain all digits): " ETH_VALUE

EXISTING_BURN=$(mxpy contract query ${SAFE} --proxy=${PROXY} --function getBurnBalances --arguments str:$TOKEN | jq '.[0].number')
EXISTING_MINT=$(mxpy contract query ${SAFE} --proxy=${PROXY} --function getMintBalances --arguments str:$TOKEN | jq '.[0].number')
NEW_MINT=$(echo "$ETH_VALUE+$EXISTING_BURN" | bc)
DIFF=$(echo "$EXISTING_MINT-$EXISTING_BURN" | bc)
NEW_DIFF=$(echo "$NEW_MINT-$EXISTING_BURN" | bc)

echo "For token ${TOKEN} the existing mint is ${EXISTING_MINT} and existing burn is ${EXISTING_BURN}. The minted value will be replaced with ${NEW_MINT}"
echo "Existing diff ${DIFF}, new diff will be ${NEW_DIFF}"

mxpy contract call ${MULTISIG} --recall-nonce "${MXPY_SIGN[@]}" \
--gas-limit=60000000 --function="initSupplyMintBurnEsdtSafe" \
--arguments str:${TOKEN} ${NEW_MINT} ${EXISTING_BURN} \
--send --proxy=${PROXY} --chain=${CHAIN_ID}
}

upgradeMultisig() {
CHECK_VARIABLES SAFE MULTI_TRANSFER BRIDGE_PROXY MULTISIG_WASM

Expand Down
2 changes: 1 addition & 1 deletion multisig/interaction/release-v3/menu_functions.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -184,4 +184,4 @@ function set-roles-on-esdt-safe-bsc {

function unpause-wrapper {
confirmation-with-skip wrapper-unpause
}
}
6 changes: 5 additions & 1 deletion multisig/interaction/script.sh
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,10 @@ case "$1" in
confirmation pause-v2-contracts
;;

'sync-value-with-eth-denom')
confirmation sync-value-with-eth-denom
;;

*)
echo "Usage: Invalid choice: '"$1"'"
echo -e
Expand All @@ -136,7 +140,7 @@ case "$1" in
echo " \"pause-contracts\", \"unpause-contracts\", \"add-relayer\", \"remove-relayer\", \"pause-v2-contracts\", "
echo " \"set-safe-max-tx\", \"set-safe-batch-block-duration\", \"change-quorum\", \"set-swap-fee\", "
echo " \"whitelist-token\", \"whitelist-native-token\", \"remove-whitelist-token\", \"upgrade-wrapper-universal-token\", \"upgrade-wrapper-chain-specific-token\", "
echo " \"mint-chain-specific\", \"init-supply-mint-burn\", "
echo " \"mint-chain-specific\", \"init-supply-mint-burn\", \"sync-value-with-eth-denom\", "
echo " \"faucet-deposit\", \"deploy-test-caller\""
echo " } "
;;
Expand Down

0 comments on commit fdedd78

Please sign in to comment.