diff --git a/interaction/devnet.snippets.sh b/interaction/devnet.snippets.sh index ca8b466..a567a4c 100644 --- a/interaction/devnet.snippets.sh +++ b/interaction/devnet.snippets.sh @@ -10,7 +10,7 @@ DEPLOY_TRANSACTION=$(mxpy data load --key=deployTransaction-devnet) TOKEN="ITHEUM-fce905" TOKEN_HEX="0x$(echo -n ${TOKEN} | xxd -p -u | tr -d '\n')" -# to deploy from last reprodubible build, we need to change +# to deploy from last reprodubible build, we need to change or vice versa # --bytecode output/datanftmint.wasm \ # to # --bytecode output-docker/datanftmint/datanftmint.wasm \ @@ -35,6 +35,24 @@ deploy(){ mxpy data store --key=deployTransaction-devnet --value=${TRANSACTION} } +# any change to code or property requires a full upgrade +# always check if you are deploy via a reprodubible build and that the code hash is the same before and after upgrade (that is if you are only changing props and not code.. for code, the RB will be different) +# if only changing props, you can't just "append" new props. you have to add the old ones again and then add a new prop you need. i.e. it's not append, it's a whole reset +# for upgrade, --outfile deployOutput is not needed +# in below code example we added --metadata-payable to add PAYABLE to the prop of the SC and removed --metadata-not-readable to make it READABLE +upgrade(){ + mxpy --verbose contract upgrade ${ADDRESS} \ + --bytecode output-docker/datanftmint/datanftmint.wasm \ + --metadata-payable-by-sc \ + --metadata-payable \ + --pem ${WALLET} \ + --proxy ${PROXY} \ + --chain ${CHAIN_ID} \ + --gas-limit 150000000 \ + --recall-nonce \ + --send || return +} + # if you interact without calling deploy(), then you need to 1st run this to restore the vars from data restoreDeployData() { TRANSACTION=$(mxpy data parse --file="./interaction/deploy-devnet.interaction.json" --expression="data['emittedTransactionHash']") diff --git a/interaction/mainnet.snippets.sh b/interaction/mainnet.snippets.sh index 804ac1c..1ac1add 100644 --- a/interaction/mainnet.snippets.sh +++ b/interaction/mainnet.snippets.sh @@ -7,6 +7,10 @@ DEPLOY_TRANSACTION=$(mxpy data load --key=deployTransaction-mainnet) TOKEN="ITHEUM-df6f26" TOKEN_HEX="0x$(echo -n ${TOKEN} | xxd -p -u | tr -d '\n')" +# to deploy from last reprodubible build, we need to change or vice versa +# --bytecode output/datanftmint.wasm \ +# to +# --bytecode output-docker/datanftmint/datanftmint.wasm deployLedgerMainnet(){ mxpy --verbose contract deploy \ --bytecode output-docker/datanftmint/datanftmint.wasm \ @@ -29,10 +33,33 @@ deployLedgerMainnet(){ mxpy data store --key=deployTransaction-mainnet --value=${TRANSACTION} } +# any change to code or property requires a full upgrade +# always check if you are deploy via a reprodubible build and that the code hash is the same before and after upgrade (that is if you are only changing props and not code.. for code, the RB will be different) +# if only changing props, you can't just "append" new props. you have to add the old ones again and then add a new prop you need. i.e. it's not append, it's a whole reset +# for upgrade, --outfile deployOutput is not needed +# in below code example we added --metadata-payable to add PAYABLE to the prop of the SC and removed --metadata-not-readable to make it READABLE +upgrade(){ + mxpy --verbose contract upgrade ${ADDRESS} \ + --bytecode output-docker/datanftmint/datanftmint.wasm \ + --metadata-payable-by-sc \ + --metadata-payable \ + --proxy ${PROXY} \ + --chain ${CHAIN_ID} \ + --gas-limit 150000000 \ + --recall-nonce \ + --ledger \ + --ledger-address-index 0 \ + --send || return +} + # if you interact without calling deploy(), then you need to 1st run this to restore the vars from data restoreDeployDataLedgerMainnet() { TRANSACTION=$(mxpy data parse --file="./interaction/deploy-mainnet.interaction.json" --expression="data['emittedTransactionHash']") ADDRESS=$(mxpy data parse --file="./interaction/deploy-mainnet.interaction.json" --expression="data['contractAddress']") + + # after we upgraded to mxpy 8.1.2, mxpy data parse seems to load the ADDRESS correctly but it breaks when used below with a weird "Bad address" error + # so, we just hardcode the ADDRESS here. Just make sure you use the "data['contractAddress'] from the latest deploy-devnet.interaction.json file + ADDRESS="erd1qqqqqqqqqqqqqpgqmuzgkurn657afd3r2aldqy2snsknwvrhc77q3lj8l6" } initializeContractMainnet(){