From 2380606be6dfcf065f3f01104f21fd334f80af95 Mon Sep 17 00:00:00 2001 From: Bucur David Date: Thu, 2 May 2024 13:15:31 +0300 Subject: [PATCH 1/6] fix: use same id for compensation --- src/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/lib.rs b/src/lib.rs index 47cb54c..a57fe11 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -116,7 +116,7 @@ pub trait LifeBondingContract: let compensation_id = self .compensations_ids() - .insert_new((token_identifier.clone(), nonce)); + .get_id_or_insert((token_identifier.clone(), nonce)); self.compensations().insert(compensation_id); From 4a902f8c42e53fbcdabe435d889ab181a1fd4c9c Mon Sep 17 00:00:00 2001 From: Bucur David Date: Thu, 2 May 2024 18:12:33 +0300 Subject: [PATCH 2/6] fix: address refund view --- src/storage.rs | 11 ++++++++++- src/views.rs | 37 +++++++++++++++++++++++-------------- tests/endpoints/proof.rs | 23 ++++++++++++----------- wasm/src/lib.rs | 5 +++-- 4 files changed, 48 insertions(+), 28 deletions(-) diff --git a/src/storage.rs b/src/storage.rs index b0e4e4f..6983bf6 100644 --- a/src/storage.rs +++ b/src/storage.rs @@ -81,7 +81,16 @@ pub struct Compensation { } #[derive( - TopEncode, TopDecode, NestedEncode, NestedDecode, TypeAbi, Clone, PartialEq, Eq, Debug, + TopEncode, + TopDecode, + NestedEncode, + NestedDecode, + TypeAbi, + Clone, + PartialEq, + Eq, + Debug, + ManagedVecItem, )] pub struct Refund { pub address: ManagedAddress, diff --git a/src/views.rs b/src/views.rs index b12f340..5afd276 100644 --- a/src/views.rs +++ b/src/views.rs @@ -76,30 +76,39 @@ pub trait ViewsModule: address: ManagedAddress, token_identifier: TokenIdentifier, nonce: u64, - ) -> Option<(Compensation, Option>)> { + ) -> Option> { let compensation_id = self.compensations_ids().get_id((token_identifier, nonce)); if compensation_id == 0 { None } else { - let compensation = Compensation { - compensation_id, - token_identifier: self.compensation_token_identifer(compensation_id).get(), - nonce: self.compensation_nonce(compensation_id).get(), - accumulated_amount: self.compensation_accumulated_amount(compensation_id).get(), - proof_amount: self.compensation_proof_amount(compensation_id).get(), - end_date: self.compensation_end_date(compensation_id).get(), - }; - - let refund = self.address_refund(&address, compensation_id).get(); - if self.address_refund(&address, compensation_id).is_empty() { - Some((compensation, None)) + None } else { - Some((compensation, Some(refund))) + self.address_refund(&address, compensation_id).get(); + let refund = self.address_refund(&address, compensation_id).get(); + Some(refund) } } } + #[view(getAddressRefundForCompensations)] + fn get_address_refund_for_compensations( + &self, + address: ManagedAddress, + compensation_ids: MultiValueEncoded, + ) -> ManagedVec> { + compensation_ids + .into_iter() + .filter_map(|compensation_id| { + if self.address_refund(&address, compensation_id).is_empty() { + None + } else { + Some(self.address_refund(&address, compensation_id).get()) + } + }) + .collect::>>() + } + #[view(getBondsByTokenIdentifierNonce)] fn get_bonds_by_token_identifier_nonce( &self, diff --git a/tests/endpoints/proof.rs b/tests/endpoints/proof.rs index b95d1c7..83b4b8c 100644 --- a/tests/endpoints/proof.rs +++ b/tests/endpoints/proof.rs @@ -1,5 +1,5 @@ use core_mx_life_bonding_sc::{ - storage::{Compensation, PenaltyType, Refund}, + storage::{PenaltyType, Refund}, views::ProxyTrait, }; use multiversx_sc::{codec::multi_types::OptionalValue, types::EsdtTokenPayment}; @@ -118,6 +118,16 @@ fn proof_test() { .world .set_state_step(SetStateStep::new().block_timestamp(12u64)); + state.world.sc_query( + ScQueryStep::new() + .call(state.contract.get_address_refund_for_compensation( + managed_address!(&first_user_address), + managed_token_id!(DATA_NFT_IDENTIFIER), + 1u64, + )) + .expect_value(None), + ); + state.proof( FIRST_USER_ADDRESS_EXPR, DATA_NFT_IDENTIFIER, @@ -138,15 +148,6 @@ fn proof_test() { ), )); - let compensation = Compensation { - compensation_id: 1u64, - token_identifier: managed_token_id!(DATA_NFT_IDENTIFIER), - nonce: 1u64, - accumulated_amount: 100u64.into(), - proof_amount: 2u64.into(), - end_date: 12u64, - }; - let refund = Refund { address: managed_address!(&first_user_address), proof_of_refund: EsdtTokenPayment { @@ -164,6 +165,6 @@ fn proof_test() { managed_token_id!(DATA_NFT_IDENTIFIER), 1u64, )) - .expect_value(Some((compensation, Some(refund)))), + .expect_value(Some(refund)), ); } diff --git a/wasm/src/lib.rs b/wasm/src/lib.rs index 3e55911..fc51246 100644 --- a/wasm/src/lib.rs +++ b/wasm/src/lib.rs @@ -5,9 +5,9 @@ //////////////////////////////////////////////////// // Init: 1 -// Endpoints: 47 +// Endpoints: 48 // Async Callback (empty): 1 -// Total number of exported functions: 49 +// Total number of exported functions: 50 #![no_std] #![allow(internal_features)] @@ -32,6 +32,7 @@ multiversx_sc_wasm_adapter::endpoints! { getCompensations => get_compensations getPagedCompensations => get_paged_compensations getAddressRefundForCompensation => get_address_refund_for_compensation + getAddressRefundForCompensations => get_address_refund_for_compensations getBondsByTokenIdentifierNonce => get_bonds_by_token_identifier_nonce getBonds => get_bonds getAddressBonds => get_address_bonds From ba89526e0b0daf5f166a115e9556c53557de7b22 Mon Sep 17 00:00:00 2001 From: Bucur David Date: Fri, 3 May 2024 09:20:24 +0300 Subject: [PATCH 3/6] test: view address refund --- tests/endpoints/proof.rs | 33 +++++++++++++++++++++++++++++++-- 1 file changed, 31 insertions(+), 2 deletions(-) diff --git a/tests/endpoints/proof.rs b/tests/endpoints/proof.rs index 83b4b8c..2bfa7ff 100644 --- a/tests/endpoints/proof.rs +++ b/tests/endpoints/proof.rs @@ -2,7 +2,10 @@ use core_mx_life_bonding_sc::{ storage::{PenaltyType, Refund}, views::ProxyTrait, }; -use multiversx_sc::{codec::multi_types::OptionalValue, types::EsdtTokenPayment}; +use multiversx_sc::{ + codec::multi_types::OptionalValue, + types::{EsdtTokenPayment, ManagedVec, MultiValueEncoded}, +}; use multiversx_sc_scenario::{ managed_address, managed_token_id, scenario_model::{ @@ -118,6 +121,19 @@ fn proof_test() { .world .set_state_step(SetStateStep::new().block_timestamp(12u64)); + let mut multiValue = MultiValueEncoded::new(); + + multiValue.push(1u64); + + state.world.sc_query( + ScQueryStep::new() + .call(state.contract.get_address_refund_for_compensations( + managed_address!(&first_user_address), + multiValue.clone(), + )) + .expect_value(ManagedVec::new()), + ); + state.world.sc_query( ScQueryStep::new() .call(state.contract.get_address_refund_for_compensation( @@ -165,6 +181,19 @@ fn proof_test() { managed_token_id!(DATA_NFT_IDENTIFIER), 1u64, )) - .expect_value(Some(refund)), + .expect_value(Some(refund.clone())), + ); + + let mut managedVec = ManagedVec::new(); + + managedVec.push(refund.clone()); + + state.world.sc_query( + ScQueryStep::new() + .call(state.contract.get_address_refund_for_compensations( + managed_address!(&first_user_address), + multiValue, + )) + .expect_value(managedVec), ); } From 418188912f9df81d72a517096bfb4ffe6e0422a5 Mon Sep 17 00:00:00 2001 From: Mark Paul Date: Tue, 7 May 2024 17:00:21 +1000 Subject: [PATCH 4/6] chore: as we deployed v2.0, updated docs and processes --- Cargo.lock | 4 +- Cargo.toml | 2 +- README.md | 6 +- interaction/devnet.snippets.sh | 25 ++- interaction/mainnet.snippets.sh | 310 ++++++++++++++++++++++++++++++++ meta/Cargo.toml | 2 +- src/config.rs | 2 +- wasm/Cargo.lock | 2 +- 8 files changed, 341 insertions(+), 12 deletions(-) create mode 100644 interaction/mainnet.snippets.sh diff --git a/Cargo.lock b/Cargo.lock index a2b7d18..4b132c5 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -319,7 +319,7 @@ checksum = "06ea2b9bc92be3c2baa9334a323ebca2d6f074ff852cd1d7b11064035cd3868f" [[package]] name = "core-mx-life-bonding-sc" -version = "1.0.0" +version = "2.0.0" dependencies = [ "multiversx-sc", "multiversx-sc-scenario", @@ -327,7 +327,7 @@ dependencies = [ [[package]] name = "core-mx-life-bonding-sc-meta" -version = "1.0.0" +version = "2.0.0" dependencies = [ "core-mx-life-bonding-sc", "multiversx-sc-meta", diff --git a/Cargo.toml b/Cargo.toml index 98f48c6..592b761 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "core-mx-life-bonding-sc" -version = "1.0.0" +version = "2.0.0" authors = ["Bucur David - Itheum"] edition = "2021" publish = false diff --git a/README.md b/README.md index 4e0d684..2cd1fd1 100644 --- a/README.md +++ b/README.md @@ -12,9 +12,9 @@ Understanding this document is also easier if one knows how [ESDT token transact ## Itheum deployed contract addresses -| Devnet | Mainnet | -| -------------------------------------------------------------- | ------- | -| erd1qqqqqqqqqqqqqpgq4xqxlq8p8zenrq4f0htgcwjzdlwmrhwdfsxsmavcuq | | +| Devnet | Mainnet | +| -------------------------------------------------------------- | -------------------------------------------------------------- | +| erd1qqqqqqqqqqqqqpgqhlyaj872kyh620zsfew64l2k4djerw2tfsxsmrxlan | erd1qqqqqqqqqqqqqpgq9yfa4vcmtmn55z0e5n84zphf2uuuxxw9c77qgqqwkn | ## Endpoints diff --git a/interaction/devnet.snippets.sh b/interaction/devnet.snippets.sh index cf311af..e7f0442 100644 --- a/interaction/devnet.snippets.sh +++ b/interaction/devnet.snippets.sh @@ -42,9 +42,9 @@ deploy(){ # 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/core-mx-life-bonding-sc.wasm \ + --bytecode output-docker/core-mx-life-bonding-sc/core-mx-life-bonding-sc.wasm \ + --metadata-not-readable \ --metadata-payable-by-sc \ - --metadata-payable \ --pem ${WALLET} \ --proxy ${PROXY} \ --chain ${CHAIN_ID} \ @@ -60,7 +60,7 @@ restoreDeployData() { # 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="erd1qqqqqqqqqqqqqpgq4xqxlq8p8zenrq4f0htgcwjzdlwmrhwdfsxsmavcuq" + ADDRESS="erd1qqqqqqqqqqqqqpgqhlyaj872kyh620zsfew64l2k4djerw2tfsxsmrxlan" } setAdministrator(){ @@ -275,3 +275,22 @@ renewWithNewLockPeriod(){ --chain ${CHAIN_ID} \ --send || return } + +initiateBond() { + # $1 = the address for who the bond is initiated + # $2 = token identifier + # $3 = nonce + + address="0x$(mxpy wallet bech32 --decode ${1})" + token_identifier="0x$(echo -n ${2} | xxd -p -u | tr -d '\n')" + + mxpy --verbose contract call ${ADDRESS} \ + --recall-nonce \ + --pem=${WALLET} \ + --gas-limit=20000000 \ + --function "initiateBond" \ + --arguments $address $token_identifier $3 \ + --proxy ${PROXY} \ + --chain ${CHAIN_ID} \ + --send || return +} \ No newline at end of file diff --git a/interaction/mainnet.snippets.sh b/interaction/mainnet.snippets.sh new file mode 100644 index 0000000..c70b6b3 --- /dev/null +++ b/interaction/mainnet.snippets.sh @@ -0,0 +1,310 @@ +PROXY=https://gateway.multiversx.com +CHAIN_ID="1" + +ADDRESS=$(mxpy data load --key=address-mainnet) +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/core-mx-life-bonding-sc.wasm \ +# to +# --bytecode output-docker/core-mx-life-bonding-sc/core-mx-life-bonding-sc.wasm \ +deployLedgerMainnet(){ + mxpy --verbose contract deploy \ + --bytecode output-docker/core-mx-life-bonding-sc/core-mx-life-bonding-sc.wasm \ + --outfile deployOutput \ + --metadata-not-readable \ + --metadata-payable-by-sc \ + --proxy ${PROXY} \ + --chain ${CHAIN_ID} \ + --gas-limit 150000000 \ + --send \ + --recall-nonce \ + --ledger \ + --ledger-address-index 0 \ + --outfile="./interaction/deploy-mainnet.interaction.json" || return + + 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']") + + mxpy data store --key=address-mainnet --value=${ADDRESS} + 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/core-mx-life-bonding-sc/core-mx-life-bonding-sc.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="erd1qqqqqqqqqqqqqpgq9yfa4vcmtmn55z0e5n84zphf2uuuxxw9c77qgqqwkn" +} + +setAdministratorMainnet(){ + # $1 = address + + address="0x$(mxpy wallet bech32 --decode ${1})" + + mxpy --verbose contract call ${ADDRESS} \ + --recall-nonce \ + --gas-limit=6000000 \ + --function "setAdministrator" \ + --arguments $address \ + --proxy ${PROXY} \ + --chain ${CHAIN_ID} \ + --ledger \ + --ledger-address-index 0 \ + --send || return +} + +setContractStateActiveMainnet(){ + mxpy --verbose contract call ${ADDRESS} \ + --recall-nonce \ + --gas-limit=6000000 \ + --function "setContractStateActive" \ + --proxy ${PROXY} \ + --chain ${CHAIN_ID} \ + --ledger \ + --ledger-address-index 0 \ + --send || return +} + +setContractStateInactiveMainnet(){ + mxpy --verbose contract call ${ADDRESS} \ + --recall-nonce \ + --gas-limit=6000000 \ + --function "setContractStateInactive" \ + --proxy ${PROXY} \ + --chain ${CHAIN_ID} \ + --ledger \ + --ledger-address-index 0 \ + --send || return +} + +setAcceptedCallersMainnet(){ + # $1 = address + + address="0x$(mxpy wallet bech32 --decode ${1})" + + mxpy --verbose contract call ${ADDRESS} \ + --recall-nonce \ + --gas-limit=6000000 \ + --function "setAcceptedCallers" \ + --arguments $address \ + --proxy ${PROXY} \ + --chain ${CHAIN_ID} \ + --ledger \ + --ledger-address-index 0 \ + --send || return +} + +setBondTokenMainnet(){ + mxpy --verbose contract call ${ADDRESS} \ + --recall-nonce \ + --gas-limit=6000000 \ + --function "setBondToken" \ + --arguments $TOKEN_HEX \ + --proxy ${PROXY} \ + --chain ${CHAIN_ID} \ + --ledger \ + --ledger-address-index 0 \ + --send || return +} + +setPeriodsBondsMainnet(){ + # $1 = lockPeriod + # $2 = bond + + mxpy --verbose contract call ${ADDRESS} \ + --recall-nonce \ + --gas-limit=6000000 \ + --function "setPeriodsBonds" \ + --arguments $1 $2 \ + --proxy ${PROXY} \ + --chain ${CHAIN_ID} \ + --ledger \ + --ledger-address-index 0 \ + --send || return +} + +setMinimumPenaltyMainnet(){ + # $1 = minimumPenalty + + mxpy --verbose contract call ${ADDRESS} \ + --recall-nonce \ + --gas-limit=6000000 \ + --function "setMinimumPenalty" \ + --arguments $1 \ + --proxy ${PROXY} \ + --chain ${CHAIN_ID} \ + --ledger \ + --ledger-address-index 0 \ + --send || return +} + +setMaximumPenaltyMainnet(){ + # $1 = maximumPenalty + + mxpy --verbose contract call ${ADDRESS} \ + --recall-nonce \ + --gas-limit=6000000 \ + --function "setMaximumPenalty" \ + --arguments $1 \ + --proxy ${PROXY} \ + --chain ${CHAIN_ID} \ + --ledger \ + --ledger-address-index 0 \ + --send || return +} + +setWithdrawPenaltyMainnet(){ + # $1 = withdrawPenalty + + mxpy --verbose contract call ${ADDRESS} \ + --recall-nonce \ + --gas-limit=6000000 \ + --function "setWithdrawPenalty" \ + --arguments $1 \ + --proxy ${PROXY} \ + --chain ${CHAIN_ID} \ + --ledger \ + --ledger-address-index 0 \ + --send || return +} + +sanctionMainnet(){ + # $1 = token identifier + # $2 = nonce + # $3 = penalty (0=minimum, 1=custom, 2=maximum) + # $4 = custom penalty (if $3=1) + + token_identifier="0x$(echo -n ${1} | xxd -p -u | tr -d '\n')" + penalty=$3 + custom_penalty=$4 + + mxpy --verbose contract call ${ADDRESS} \ + --recall-nonce \ + --gas-limit=6000000 \ + --function "sanction" \ + --arguments $token_identifier $2 $penalty $custom_penalty \ + --proxy ${PROXY} \ + --chain ${CHAIN_ID} \ + --ledger \ + --ledger-address-index 0 \ + --send || return +} + +modifyBondMainnet(){ + # $1 = token identifier + # $2 = nonce + + token_identifier="0x$(echo -n ${1} | xxd -p -u | tr -d '\n')" + + mxpy --verbose contract call ${ADDRESS} \ + --recall-nonce \ + --gas-limit=6000000 \ + --function "modifyBond" \ + --arguments $token_identifier $2 \ + --proxy ${PROXY} \ + --chain ${CHAIN_ID} \ + --ledger \ + --ledger-address-index 0 \ + --send || return +} + +withdrawMainnet(){ + # $1 = token identifier + # $2 = nonce + + token_identifier="0x$(echo -n ${1} | xxd -p -u | tr -d '\n')" + + mxpy --verbose contract call ${ADDRESS} \ + --recall-nonce \ + --gas-limit=20000000 \ + --function "withdraw" \ + --arguments $token_identifier $2 \ + --proxy ${PROXY} \ + --chain ${CHAIN_ID} \ + --ledger \ + --ledger-address-index 0 \ + --send || return +} + +renewMainnet(){ + # $1 = token identifier + # $2 = nonce + + token_identifier="0x$(echo -n ${1} | xxd -p -u | tr -d '\n')" + + mxpy --verbose contract call ${ADDRESS} \ + --recall-nonce \ + --gas-limit=6000000 \ + --function "renew" \ + --arguments $token_identifier $2 \ + --proxy ${PROXY} \ + --chain ${CHAIN_ID} \ + --ledger \ + --ledger-address-index 0 \ + --send || return +} + +renewWithNewLockPeriodMainnet(){ + # $1 = token identifier + # $2 = nonce + # $3 = lockPeriod + + token_identifier="0x$(echo -n ${1} | xxd -p -u | tr -d '\n')" + + mxpy --verbose contract call ${ADDRESS} \ + --recall-nonce \ + --gas-limit=6000000 \ + --function "renew" \ + --arguments $token_identifier $2 $3 \ + --proxy ${PROXY} \ + --chain ${CHAIN_ID} \ + --ledger \ + --ledger-address-index 0 \ + --send || return +} + +initiateBondMainnet() { + # $1 = the address for who the bond is initiated + # $2 = token identifier + # $3 = nonce + + address="0x$(mxpy wallet bech32 --decode ${1})" + token_identifier="0x$(echo -n ${2} | xxd -p -u | tr -d '\n')" + + mxpy --verbose contract call ${ADDRESS} \ + --recall-nonce \ + --gas-limit=20000000 \ + --function "initiateBond" \ + --arguments $address $token_identifier $3 \ + --proxy ${PROXY} \ + --chain ${CHAIN_ID} \ + --ledger \ + --ledger-address-index 0 \ + --send || return +} \ No newline at end of file diff --git a/meta/Cargo.toml b/meta/Cargo.toml index 51dfaaf..17ba42f 100644 --- a/meta/Cargo.toml +++ b/meta/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "core-mx-life-bonding-sc-meta" -version = "1.0.0" +version = "2.0.0" edition = "2021" publish = false diff --git a/src/config.rs b/src/config.rs index 0f55e5d..b132a0c 100644 --- a/src/config.rs +++ b/src/config.rs @@ -21,7 +21,7 @@ pub enum State { Active, } -pub const COMPENSATION_SAFE_PERIOD: u64 = 86_400; +pub const COMPENSATION_SAFE_PERIOD: u64 = 300; #[multiversx_sc::module] pub trait ConfigModule: storage::StorageModule + events::EventsModule { diff --git a/wasm/Cargo.lock b/wasm/Cargo.lock index e7d2212..3701001 100644 --- a/wasm/Cargo.lock +++ b/wasm/Cargo.lock @@ -22,7 +22,7 @@ checksum = "ed570934406eb16438a4e976b1b4500774099c13b8cb96eec99f620f05090ddf" [[package]] name = "core-mx-life-bonding-sc" -version = "1.0.0" +version = "2.0.0" dependencies = [ "multiversx-sc", ] From b2f0cb2261c39cd0ee54270b5c780432dea435d4 Mon Sep 17 00:00:00 2001 From: Mark Paul Date: Tue, 7 May 2024 17:02:55 +1000 Subject: [PATCH 5/6] fix: revert COMPENSATION_SAFE_PERIOD back to 86_400 --- src/config.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/config.rs b/src/config.rs index b132a0c..0f55e5d 100644 --- a/src/config.rs +++ b/src/config.rs @@ -21,7 +21,7 @@ pub enum State { Active, } -pub const COMPENSATION_SAFE_PERIOD: u64 = 300; +pub const COMPENSATION_SAFE_PERIOD: u64 = 86_400; #[multiversx_sc::module] pub trait ConfigModule: storage::StorageModule + events::EventsModule { From d6c11dfb907f4698bf79effd3a1b04143188e34e Mon Sep 17 00:00:00 2001 From: Mark Paul Date: Tue, 7 May 2024 17:17:22 +1000 Subject: [PATCH 6/6] chore: updated readme --- README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 2cd1fd1..46be4eb 100644 --- a/README.md +++ b/README.md @@ -24,9 +24,9 @@ See `devnet.snippets.sh` for list of available endpoints for user testing. ### Setting up dev environment (project development bootstrap) + how to build (and upgrade) -- Uses `multiversx-sc-* 0.47.5` (In v1.0.0, we used 0.47.5) SDK libs (see Cargo.toml) -- Building requires minimum **mxpy 9.5.1** (In v1.0.0, we used mxpy 9.5.1). Check version using `mxpy --version` -- To build the project, requires minimum Rust version `1.78.0-nightly` (In v1.0.0, we used 1.78.0-nightly). Check your Rust version by running `rustc --version`. To update your Rust, run `rustup update`. To set to nightly run `rustup default nightly`. Note that `mxpy deps install rust --overwrite` also brings in it's own compatible rust version so running `rustup default nightly` might have a higher rust version than what is used via `mxpy deps install rust --overwrite`. +- Uses `multiversx-sc-* 0.47.5` (In v2.0.0, we used 0.47.8) SDK libs (see Cargo.toml) +- Building requires minimum **mxpy 9.5.1** (In v2.0.0, we used mxpy 9.5.1). Check version using `mxpy --version` +- To build the project, requires minimum Rust version `1.78.0-nightly` (In v2.0.0, we used 1.78.0-nightly). Check your Rust version by running `rustc --version`. To update your Rust, run `rustup update`. To set to nightly run `rustup default nightly`. Note that `mxpy deps install rust --overwrite` also brings in it's own compatible rust version so running `rustup default nightly` might have a higher rust version than what is used via `mxpy deps install rust --overwrite`. - After you make sure you have the minimum Rust version you can then begin development. After you clone repo and before you run build, deploy or run the tests - follow these steps (most likely only needed the 1st time) - [Upgrades] Note that when we upgrade smart contract, we should again follow the steps below too as lib version may have changed (but for upgrade I skipped the rustup default nightly cmd and did the others)