Skip to content

Commit

Permalink
chore: small updates to code and mainly doc updates for v2.0.0 releas…
Browse files Browse the repository at this point in the history
…e. deployed via RB
  • Loading branch information
newbreedofgeek committed Apr 26, 2024
1 parent 1f0e888 commit 4000f39
Show file tree
Hide file tree
Showing 9 changed files with 107 additions and 329 deletions.
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "data_market"
version = "1.0.0"
version = "2.0.0"
edition = "2021"
publish = false
authors = [
Expand Down
332 changes: 20 additions & 312 deletions README.md

Large diffs are not rendered by default.

47 changes: 36 additions & 11 deletions interaction/devnet.snippets.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ PROXY=https://devnet-gateway.multiversx.com
CHAIN_ID="D"

WALLET="./wallet.pem"
SELLER="./wallet.pem"
BUYER="./wallet2.pem"
SELLER="./wallet2.pem"
BUYER="./wallet3.pem"

ADDRESS=$(mxpy data load --key=address-devnet)
DEPLOY_TRANSACTION=$(mxpy data load --key=deployTransaction-devnet)
Expand All @@ -17,7 +17,7 @@ TOKEN_HEX="0x$(echo -n ${TOKEN} | xxd -p -u | tr -d '\n')"
# --bytecode output-docker/data_market/data_market.wasm \
deploy(){
mxpy --verbose contract deploy \
--bytecode output/data_market.wasm \
--bytecode output-docker/data_market/data_market.wasm \
--outfile deployOutput \
--metadata-not-readable \
--metadata-payable-by-sc \
Expand All @@ -36,6 +36,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/data_market/data_market.wasm \
--metadata-not-readable \
--metadata-payable-by-sc \
--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']")
Expand Down Expand Up @@ -107,7 +125,6 @@ setTreasuryAddress(){
--send || return
}


setMaxDefaultQuantity(){

# $1 = max default quantity
Expand Down Expand Up @@ -174,7 +191,6 @@ addAcceptedToken(){

token_identifier="0x$(echo -n ${1} | xxd -p -u | tr -d '\n')"


mxpy --verbose contract call ${ADDRESS} \
--recall-nonce \
--pem=${WALLET} \
Expand All @@ -184,14 +200,28 @@ addAcceptedToken(){
--proxy ${PROXY} \
--chain ${CHAIN_ID} \
--send || return
}

removeAcceptedToken(){
# $1 = token identifier

token_identifier="0x$(echo -n ${1} | xxd -p -u | tr -d '\n')"

mxpy --verbose contract call ${ADDRESS} \
--recall-nonce \
--pem=${WALLET} \
--gas-limit=6000000 \
--function "removeAcceptedToken" \
--arguments $token_identifier \
--proxy ${PROXY} \
--chain ${CHAIN_ID} \
--send || return
}

addAcceptedPayment(){
# $1 = token identifier
# $2 = maximum payment fee per SFT


token_identifier="0x$(echo -n ${1} | xxd -p -u | tr -d '\n')"

mxpy --verbose contract call ${ADDRESS} \
Expand Down Expand Up @@ -221,7 +251,6 @@ removeAcceptedPayment(){
--send || return
}


setClaimsContract(){
# $1 = claims contract address

Expand All @@ -236,7 +265,6 @@ setClaimsContract(){
--proxy ${PROXY} \
--chain ${CHAIN_ID} \
--send || return

}

setRoyaltiesClaimToken(){
Expand All @@ -253,8 +281,6 @@ setRoyaltiesClaimToken(){
--proxy ${PROXY} \
--chain ${CHAIN_ID} \
--send || return


}

setClaimIsEnabled(){
Expand All @@ -281,7 +307,6 @@ setClaimIsDisabled(){
--send || return
}


addOffer(){
# $1 = token identifier
# $2 = sft nonce
Expand Down
44 changes: 44 additions & 0 deletions interaction/mainnet.snippets.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ ADDRESS=$(mxpy data load --key=address-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
# --bytecode output/data_market.wasm \
# to
# --bytecode output-docker/data_market/data_market.wasm \
deployLedgerMainnet(){
mxpy --verbose contract deploy \
--bytecode output-docker/data_market/data_market.wasm \
Expand All @@ -28,10 +32,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/data_market/data_market.wasm \
--metadata-not-readable \
--metadata-payable-by-sc \
--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
restoreDeployDataMainnet() {
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="erd1qqqqqqqqqqqqqpgqay2r64l9nhhvmaqw4qanywfd0954w2m3c77qm7drxc"
}

initializeContractMainnet(){
Expand Down Expand Up @@ -165,6 +192,23 @@ addAcceptedTokenMainnet(){
--send || return
}

removeAcceptedTokenMainnet(){
# $1 = token identifier

token_identifier="0x$(echo -n ${1} | xxd -p -u | tr -d '\n')"

mxpy --verbose contract call ${ADDRESS} \
--recall-nonce \
--gas-limit=6000000 \
--function "removeAcceptedToken" \
--arguments $token_identifier \
--proxy ${PROXY} \
--chain ${CHAIN_ID} \
--ledger \
--ledger-address-index 0 \
--send || return
}

addAcceptedPaymentMainnet(){
# $1 =token identifier
# $2 = maximum payment fee per SFT
Expand Down
4 changes: 2 additions & 2 deletions meta/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion meta/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "data_market-meta"
version = "1.0.0"
version = "2.0.0"
edition = "2021"
publish = false
authors = [
Expand Down
1 change: 1 addition & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ pub trait DataMarket:
#[upgrade]
fn upgrade(&self) {
self.is_paused().set(true);
self.pause_toggle_event(&true);
}

// Endpoint that will be used by the contract owner to initialize the contract.
Expand Down
2 changes: 1 addition & 1 deletion wasm/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 4000f39

Please sign in to comment.