Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Potlock contract #76

Open
wants to merge 52 commits into
base: main
Choose a base branch
from
Open

Add Potlock contract #76

wants to merge 52 commits into from

Conversation

CostinCarabas
Copy link
Contributor

No description provided.

contracts/potlock/src/potlock_admin_interactions.rs Outdated Show resolved Hide resolved
contracts/potlock/src/potlock_admin_interactions.rs Outdated Show resolved Hide resolved
contracts/potlock/src/potlock_admin_interactions.rs Outdated Show resolved Hide resolved
contracts/potlock/src/potlock_admin_interactions.rs Outdated Show resolved Hide resolved
contracts/potlock/src/potlock_interactions.rs Outdated Show resolved Hide resolved
@CostinCarabas CostinCarabas changed the base branch from main to fix-unit-tests June 20, 2024 10:07
contracts/potlock/src/potlock.rs Outdated Show resolved Hide resolved
contracts/potlock/src/potlock.rs Show resolved Hide resolved
contracts/potlock/src/potlock_admin_interactions.rs Outdated Show resolved Hide resolved
contracts/potlock/src/potlock_admin_interactions.rs Outdated Show resolved Hide resolved
contracts/potlock/src/potlock_admin_interactions.rs Outdated Show resolved Hide resolved
contracts/potlock/src/potlock_storage.rs Show resolved Hide resolved
fn project_donations(
&self,
project_id: ProjectId,
) -> MapMapper<ManagedAddress, EsdtTokenPayment>;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unless you've got no other choice, avoid MapMapper.

Comment on lines 42 to 45
let project_id = self.projects().len() + 1;
let owner = self.blockchain().get_caller();
let project = Project::new(project_id, potlock_id, project_name, description, owner);
self.projects().push(&project);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think this respects the specs. I don't see where an admin/owner can accept/reject an application. Docs say this:

ApplyForPot@potID@projectName@description - anyone can submit application, but an authority will review the submission and evaluate for eligibility and potential impact

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The new function for Project::new will create a Project with Status = Inactive.
An authority would have to call endpoint(acceptApplication) to set the project status to Active

Base automatically changed from fix-unit-tests to unified-syntax-refactor July 2, 2024 14:15
Base automatically changed from unified-syntax-refactor to framework-upgrade-0.50.4 July 2, 2024 14:28
Base automatically changed from framework-upgrade-0.50.4 to main July 3, 2024 06:31
Copy link

github-actions bot commented Jul 19, 2024

Coverage Summary

Totals

Count Covered %
Lines 22634 14780 65.30
Regions 6174 3188 51.64
Functions 2540 1497 58.94
Instantiations 8786 2522 28.70

Files

Expand
File Lines Regions Functions Instantiations
/contracts/adder/interact/src/basic_interact.rs 0.00% 0.00% 0.00% 0.00%
/contracts/adder/interact/src/basic_interact_cli.rs 0.00% 0.00% 0.00% 0.00%
/contracts/adder/interact/src/basic_interact_config.rs 0.00% 0.00% 0.00% 0.00%
/contracts/adder/interact/src/basic_interact_state.rs 0.00% 0.00% 0.00% 0.00%
/contracts/adder/meta/src/main.rs 0.00% 0.00% 0.00% 0.00%
/contracts/adder/src/adder.rs 100.00% 100.00% 100.00% 60.14%
/contracts/adder/src/adder_proxy.rs 100.00% 100.00% 100.00% 82.14%
/contracts/adder/tests/adder_blackbox_test.rs 100.00% 100.00% 100.00% 100.00%
/contracts/adder/tests/adder_scenario_go_test.rs 100.00% 100.00% 100.00% 100.00%
/contracts/adder/tests/adder_scenario_rs_test.rs 100.00% 100.00% 100.00% 100.00%
/contracts/adder/tests/adder_unit_test.rs 100.00% 100.00% 100.00% 100.00%
/contracts/adder/tests/adder_whitebox_test.rs 100.00% 100.00% 100.00% 100.00%
/contracts/bonding-curve-contract/meta/src/main.rs 0.00% 0.00% 0.00% 0.00%
/contracts/bonding-curve-contract/src/bonding_curve_contract.rs 82.61% 80.00% 75.00% 21.21%
/contracts/bonding-curve-contract/src/function_selector.rs 84.21% 52.63% 66.67% 36.36%
/contracts/bonding-curve-contract/tests/bonding_curve_scenario_go_test.rs 100.00% 100.00% 100.00% 100.00%
/contracts/bonding-curve-contract/tests/bonding_curve_scenario_rs_test.rs 100.00% 100.00% 100.00% 100.00%
/contracts/check-pause/meta/src/main.rs 0.00% 0.00% 0.00% 0.00%
/contracts/check-pause/src/check_pause.rs 100.00% 75.00% 100.00% 16.67%
/contracts/crowdfunding-esdt/meta/src/main.rs 0.00% 0.00% 0.00% 0.00%
/contracts/crowdfunding-esdt/src/crowdfunding_esdt.rs 96.97% 81.82% 81.82% 42.41%
/contracts/crowdfunding-esdt/src/crowdfunding_esdt_proxy.rs 62.64% 47.06% 53.85% 39.13%
/contracts/crowdfunding-esdt/tests/crowdfunding_esdt_blackbox_test.rs 100.00% 100.00% 100.00% 100.00%
/contracts/crowdfunding-esdt/tests/crowdfunding_esdt_scenario_go_test.rs 88.24% 88.24% 88.24% 88.24%
/contracts/crowdfunding-esdt/tests/crowdfunding_esdt_scenario_rs_test.rs 89.66% 88.24% 88.24% 88.24%
/contracts/crowdfunding-esdt/tests/crowdfunding_esdt_whitebox_legacy_test.rs 100.00% 100.00% 100.00% 100.00%
/contracts/crypto-bubbles/meta/src/main.rs 0.00% 0.00% 0.00% 0.00%
/contracts/crypto-bubbles/src/crypto_bubbles.rs 100.00% 100.00% 100.00% 32.91%
/contracts/crypto-bubbles/tests/crypto_bubbles_scenario_go_test.rs 100.00% 100.00% 100.00% 100.00%
/contracts/crypto-bubbles/tests/crypto_bubbles_scenario_rs_test.rs 100.00% 100.00% 100.00% 100.00%
/contracts/crypto-kitties/common/kitty/src/color.rs 77.78% 35.29% 50.00% 35.71%
/contracts/crypto-kitties/common/kitty/src/kitty.rs 91.38% 53.85% 75.00% 41.67%
/contracts/crypto-kitties/common/kitty/src/kitty_genes.rs 68.75% 56.25% 71.43% 39.29%
/contracts/crypto-kitties/common/random/src/lib.rs 64.71% 53.33% 50.00% 36.36%
/contracts/crypto-kitties/kitty-auction/meta/src/main.rs 0.00% 0.00% 0.00% 0.00%
/contracts/crypto-kitties/kitty-auction/src/auction.rs 85.19% 46.43% 63.64% 33.33%
/contracts/crypto-kitties/kitty-auction/src/kitty_ownership_proxy.rs 20.63% 21.74% 21.74% 17.86%
/contracts/crypto-kitties/kitty-auction/src/lib.rs 85.82% 79.17% 80.00% 30.25%
/contracts/crypto-kitties/kitty-auction/tests/kitty_auction_scenario_go_test.rs 100.00% 100.00% 100.00% 100.00%
/contracts/crypto-kitties/kitty-auction/tests/kitty_auction_scenario_rs_test.rs 100.00% 100.00% 100.00% 100.00%
/contracts/crypto-kitties/kitty-genetic-alg/meta/src/main.rs 0.00% 0.00% 0.00% 0.00%
/contracts/crypto-kitties/kitty-genetic-alg/src/lib.rs 100.00% 100.00% 100.00% 33.33%
/contracts/crypto-kitties/kitty-genetic-alg/tests/kitty_genetic_alg_scenario_go_test.rs 100.00% 100.00% 100.00% 100.00%
/contracts/crypto-kitties/kitty-genetic-alg/tests/kitty_genetic_alg_scenario_rs_test.rs 100.00% 100.00% 100.00% 100.00%
/contracts/crypto-kitties/kitty-ownership/meta/src/main.rs 0.00% 0.00% 0.00% 0.00%
/contracts/crypto-kitties/kitty-ownership/src/kitty_genetic_alg_proxy.rs 69.23% 66.67% 66.67% 28.57%
/contracts/crypto-kitties/kitty-ownership/src/lib.rs 83.91% 75.54% 89.47% 29.51%
/contracts/crypto-kitties/kitty-ownership/tests/kitty_ownership_scenario_go_test.rs 100.00% 100.00% 100.00% 100.00%
/contracts/crypto-kitties/kitty-ownership/tests/kitty_ownership_scenario_rs_test.rs 100.00% 100.00% 100.00% 100.00%
/contracts/crypto-zombies/meta/src/main.rs 0.00% 0.00% 0.00% 0.00%
/contracts/crypto-zombies/src/kitty_obj.rs 0.00% 0.00% 0.00% 0.00%
/contracts/crypto-zombies/src/kitty_ownership_proxy.rs 0.00% 0.00% 0.00% 0.00%
/contracts/crypto-zombies/src/lib.rs 0.00% 0.00% 0.00% 0.00%
/contracts/crypto-zombies/src/proxy_crypto_zombies.rs 0.00% 0.00% 0.00% 0.00%
/contracts/crypto-zombies/src/storage.rs 0.00% 0.00% 0.00% 0.00%
/contracts/crypto-zombies/src/zombie.rs 0.00% 0.00% 0.00% 0.00%
/contracts/crypto-zombies/src/zombie_attack.rs 0.00% 0.00% 0.00% 0.00%
/contracts/crypto-zombies/src/zombie_factory.rs 0.00% 0.00% 0.00% 0.00%
/contracts/crypto-zombies/src/zombie_feeding.rs 0.00% 0.00% 0.00% 0.00%
/contracts/crypto-zombies/src/zombie_helper.rs 0.00% 0.00% 0.00% 0.00%
/contracts/digital-cash/meta/src/main.rs 0.00% 0.00% 0.00% 0.00%
/contracts/digital-cash/src/deposit_info.rs 64.71% 37.50% 45.45% 26.32%
/contracts/digital-cash/src/digital_cash.rs 56.52% 53.33% 83.33% 22.00%
/contracts/digital-cash/src/digital_cash_proxy.rs 0.00% 0.00% 0.00% 0.00%
/contracts/digital-cash/src/helpers.rs 92.50% 92.59% 100.00% 35.71%
/contracts/digital-cash/src/pay_fee_and_fund.rs 100.00% 90.00% 100.00% 26.47%
/contracts/digital-cash/src/signature_operations.rs 95.73% 89.47% 100.00% 30.56%
/contracts/digital-cash/src/storage.rs 100.00% 66.67% 100.00% 25.00%
/contracts/digital-cash/tests/digital_cash_scenario_go_test.rs 100.00% 100.00% 100.00% 100.00%
/contracts/digital-cash/tests/digital_cash_scenario_rs_test.rs 100.00% 100.00% 100.00% 100.00%
/contracts/dn404/meta/src/main.rs 0.00% 0.00% 0.00% 0.00%
/contracts/dn404/src/available_tokens.rs 95.70% 74.00% 84.62% 20.69%
/contracts/dn404/src/fee.rs 65.38% 34.62% 50.00% 13.73%
/contracts/dn404/src/lib.rs 100.00% 60.00% 100.00% 6.67%
/contracts/dn404/src/price.rs 100.00% 77.78% 100.00% 15.79%
/contracts/dn404/tests/dn404_setup/mod.rs 100.00% 100.00% 100.00% 100.00%
/contracts/dn404/tests/dn404_test.rs 100.00% 100.00% 100.00% 100.00%
/contracts/empty/meta/src/main.rs 0.00% 0.00% 0.00% 0.00%
/contracts/empty/src/empty.rs 100.00% 100.00% 100.00% 17.39%
/contracts/empty/tests/empty_scenario_go_test.rs 100.00% 100.00% 100.00% 100.00%
/contracts/empty/tests/empty_scenario_rs_test.rs 100.00% 100.00% 100.00% 100.00%
/contracts/erc3643/meta/src/main.rs 0.00% 0.00% 0.00% 0.00%
/contracts/erc3643/src/exchange_actions.rs 0.00% 0.00% 0.00% 0.00%
/contracts/erc3643/src/hooks/call_hook.rs 0.00% 0.00% 0.00% 0.00%
/contracts/erc3643/src/hooks/change_hooks.rs 0.00% 0.00% 0.00% 0.00%
/contracts/erc3643/src/hooks/hook_type.rs 0.00% 0.00% 0.00% 0.00%
/contracts/erc3643/src/lib.rs 0.00% 0.00% 0.00% 0.00%
/contracts/erc3643/src/token.rs 0.00% 0.00% 0.00% 0.00%
/contracts/erc3643/src/transfer.rs 0.00% 0.00% 0.00% 0.00%
/contracts/erc3643/src/users.rs 0.00% 0.00% 0.00% 0.00%
/contracts/esdt-transfer-with-fee/meta/src/main.rs 0.00% 0.00% 0.00% 0.00%
/contracts/esdt-transfer-with-fee/src/esdt_transfer_with_fee.rs 97.26% 96.77% 100.00% 26.15%
/contracts/esdt-transfer-with-fee/src/fee.rs 66.67% 50.00% 66.67% 28.57%
/contracts/esdt-transfer-with-fee/tests/esdt_transfer_with_fee_scenario_go_test.rs 100.00% 100.00% 100.00% 100.00%
/contracts/esdt-transfer-with-fee/tests/esdt_transfer_with_fee_scenario_rs_test.rs 100.00% 100.00% 100.00% 100.00%
/contracts/factorial/meta/src/main.rs 0.00% 0.00% 0.00% 0.00%
/contracts/factorial/src/factorial.rs 100.00% 100.00% 100.00% 32.20%
/contracts/factorial/tests/factorial_scenario_go_test.rs 100.00% 100.00% 100.00% 100.00%
/contracts/factorial/tests/factorial_scenario_rs_test.rs 100.00% 100.00% 100.00% 100.00%
/contracts/factorial/tests/factorial_test.rs 100.00% 100.00% 100.00% 100.00%
/contracts/fair-launch/meta/src/main.rs 0.00% 0.00% 0.00% 0.00%
/contracts/fair-launch/src/common.rs 74.60% 47.06% 37.50% 13.33%
/contracts/fair-launch/src/exchange_actions.rs 72.65% 56.34% 58.33% 24.29%
/contracts/fair-launch/src/initial_launch.rs 95.51% 69.44% 85.71% 28.85%
/contracts/fair-launch/src/lib.rs 100.00% 90.00% 100.00% 16.67%
/contracts/fair-launch/src/pair_mock_proxy.rs 53.12% 66.67% 66.67% 40.00%
/contracts/fair-launch/src/token_info.rs 12.50% 25.00% 50.00% 7.14%
/contracts/fair-launch/src/transfer.rs 71.43% 62.86% 57.14% 9.76%
/contracts/fair-launch/tests/fair_launch_test.rs 100.00% 100.00% 100.00% 100.00%
/contracts/fair-launch/tests/tests_common.rs 100.00% 100.00% 100.00% 50.00%
/contracts/fractional-nfts/meta/src/main.rs 0.00% 0.00% 0.00% 0.00%
/contracts/fractional-nfts/src/fractional_nfts.rs 0.00% 0.00% 0.00% 0.00%
/contracts/fractional-nfts/src/fractional_uri_info.rs 0.00% 0.00% 0.00% 0.00%
/contracts/fractional-nfts/src/nft_marketplace_proxy.rs 0.00% 0.00% 0.00% 0.00%
/contracts/liquid-locking/meta/src/main.rs 0.00% 0.00% 0.00% 0.00%
/contracts/liquid-locking/src/lib.rs 77.12% 77.27% 68.75% 22.40%
/contracts/liquid-locking/src/liquid_locking_proxy.rs 35.15% 19.35% 27.27% 20.00%
/contracts/liquid-locking/src/unlocked_token.rs 0.00% 0.00% 0.00% 0.00%
/contracts/liquid-locking/tests/liquid_locking_test.rs 100.00% 100.00% 100.00% 100.00%
/contracts/lottery-esdt/meta/src/main.rs 0.00% 0.00% 0.00% 0.00%
/contracts/lottery-esdt/src/lottery.rs 92.89% 93.26% 100.00% 31.03%
/contracts/lottery-esdt/src/lottery_info.rs 40.00% 28.57% 40.00% 22.22%
/contracts/lottery-esdt/src/status.rs 33.33% 28.57% 33.33% 20.00%
/contracts/lottery-esdt/tests/lottery_esdt_scenario_go_test.rs 100.00% 100.00% 100.00% 100.00%
/contracts/lottery-esdt/tests/lottery_esdt_scenario_rs_test.rs 94.06% 93.55% 93.55% 93.55%
/contracts/multisig/interact/src/multisig_interact.rs 0.00% 0.00% 0.00% 0.00%
/contracts/multisig/interact/src/multisig_interact_cli.rs 0.00% 0.00% 0.00% 0.00%
/contracts/multisig/interact/src/multisig_interact_config.rs 0.00% 0.00% 0.00% 0.00%
/contracts/multisig/interact/src/multisig_interact_nfts.rs 0.00% 0.00% 0.00% 0.00%
/contracts/multisig/interact/src/multisig_interact_state.rs 0.00% 0.00% 0.00% 0.00%
/contracts/multisig/interact/src/multisig_interact_wegld.rs 0.00% 0.00% 0.00% 0.00%
/contracts/multisig/interact/src/wegld_proxy.rs 0.00% 0.00% 0.00% 0.00%
/contracts/multisig/meta/src/main.rs 0.00% 0.00% 0.00% 0.00%
/contracts/multisig/src/action.rs 90.00% 72.22% 83.33% 35.65%
/contracts/multisig/src/multisig.rs 76.84% 77.78% 90.91% 25.37%
/contracts/multisig/src/multisig_events.rs 100.00% 33.33% 100.00% 29.73%
/contracts/multisig/src/multisig_perform.rs 77.67% 69.47% 81.25% 31.40%
/contracts/multisig/src/multisig_propose.rs 83.33% 79.17% 92.86% 25.98%
/contracts/multisig/src/multisig_proxy.rs 47.13% 26.26% 35.38% 15.38%
/contracts/multisig/src/multisig_sign.rs 62.63% 54.24% 60.00% 11.88%
/contracts/multisig/src/multisig_state.rs 96.55% 77.78% 86.67% 25.85%
/contracts/multisig/src/user_role.rs 83.33% 71.43% 87.50% 50.00%
/contracts/multisig/tests/multisig_blackbox_test.rs 100.00% 100.00% 100.00% 100.00%
/contracts/multisig/tests/multisig_scenario_go_test.rs 78.95% 78.95% 78.95% 78.95%
/contracts/multisig/tests/multisig_scenario_rs_test.rs 77.22% 68.42% 68.42% 68.42%
/contracts/multisig/tests/multisig_whitebox_test.rs 99.88% 99.39% 100.00% 100.00%
/contracts/mvx-game-sc/meta/src/main.rs 0.00% 0.00% 0.00% 0.00%
/contracts/mvx-game-sc/src/game_proxy.rs 55.24% 28.85% 38.24% 22.73%
/contracts/mvx-game-sc/src/lib.rs 93.48% 80.00% 100.00% 25.00%
/contracts/mvx-game-sc/src/owner.rs 73.47% 58.82% 37.50% 9.62%
/contracts/mvx-game-sc/src/private.rs 92.37% 83.72% 85.71% 33.33%
/contracts/mvx-game-sc/src/storage.rs 33.33% 50.00% 50.00% 21.21%
/contracts/mvx-game-sc/src/types.rs 38.46% 32.26% 38.46% 17.95%
/contracts/mvx-game-sc/tests/game_sc_blackbox_tests.rs 96.30% 92.86% 100.00% 100.00%
/contracts/mystery-box/meta/src/main.rs 0.00% 0.00% 0.00% 0.00%
/contracts/mystery-box/src/config.rs 92.68% 58.33% 81.25% 35.71%
/contracts/mystery-box/src/events.rs 100.00% 60.00% 100.00% 22.22%
/contracts/mystery-box/src/lib.rs 100.00% 92.00% 100.00% 13.46%
/contracts/mystery-box/src/rewards.rs 85.71% 76.92% 75.00% 18.75%
/contracts/mystery-box/src/token_attributes.rs 97.14% 62.50% 66.67% 12.50%
/contracts/mystery-box/tests/mystery_box_setup/mod.rs 100.00% 100.00% 100.00% 100.00%
/contracts/mystery-box/tests/mystery_box_test.rs 100.00% 100.00% 100.00% 100.00%
/contracts/nft-escrow/meta/src/main.rs 0.00% 0.00% 0.00% 0.00%
/contracts/nft-escrow/src/lib.rs 0.00% 0.00% 0.00% 0.00%
/contracts/nft-escrow/tests/nft_escrow_scenario_go_test.rs 100.00% 100.00% 100.00% 100.00%
/contracts/nft-escrow/tests/nft_escrow_scenario_rs_test.rs 0.00% 0.00% 0.00% 0.00%
/contracts/nft-minter/meta/src/main.rs 0.00% 0.00% 0.00% 0.00%
/contracts/nft-minter/src/lib.rs 0.00% 0.00% 0.00% 0.00%
/contracts/nft-minter/src/nft_marketplace_proxy.rs 0.00% 0.00% 0.00% 0.00%
/contracts/nft-minter/src/nft_module.rs 0.00% 0.00% 0.00% 0.00%
/contracts/nft-minter/tests/nft_minter_scenario_rs_test.rs 0.00% 0.00% 0.00% 0.00%
/contracts/nft-minter/tests/scenario_go_test.rs 100.00% 100.00% 100.00% 100.00%
/contracts/nft-storage-prepay/meta/src/main.rs 0.00% 0.00% 0.00% 0.00%
/contracts/nft-storage-prepay/src/nft_storage_prepay.rs 0.00% 0.00% 0.00% 0.00%
/contracts/on-chain-claim/meta/src/main.rs 0.00% 0.00% 0.00% 0.00%
/contracts/on-chain-claim/src/address_info.rs 88.46% 37.50% 57.14% 25.00%
/contracts/on-chain-claim/src/config.rs 71.88% 57.14% 80.00% 8.93%
/contracts/on-chain-claim/src/contract.rs 80.51% 78.12% 66.67% 6.86%
/contracts/on-chain-claim/src/events.rs 100.00% 33.33% 100.00% 11.54%
/contracts/on-chain-claim/tests/tests.rs 100.00% 100.00% 100.00% 100.00%
/contracts/order-book/factory/meta/src/main.rs 0.00% 0.00% 0.00% 0.00%
/contracts/order-book/factory/src/lib.rs 0.00% 0.00% 0.00% 0.00%
/contracts/order-book/pair/meta/src/main.rs 0.00% 0.00% 0.00% 0.00%
/contracts/order-book/pair/src/common.rs 70.31% 45.00% 63.04% 40.00%
/contracts/order-book/pair/src/events.rs 100.00% 87.50% 100.00% 30.77%
/contracts/order-book/pair/src/global.rs 35.29% 42.86% 40.00% 10.71%
/contracts/order-book/pair/src/lib.rs 100.00% 100.00% 100.00% 27.42%
/contracts/order-book/pair/src/orders.rs 98.94% 88.89% 100.00% 37.50%
/contracts/order-book/pair/src/validation.rs 88.17% 77.78% 92.86% 36.11%
/contracts/order-book/pair/tests/pair_scenario_go_test.rs 100.00% 100.00% 100.00% 100.00%
/contracts/order-book/pair/tests/pair_scenario_rs_test.rs 100.00% 100.00% 100.00% 100.00%
/contracts/pair-mock/meta/src/main.rs 0.00% 0.00% 0.00% 0.00%
/contracts/pair-mock/src/pair_mock.rs 100.00% 90.00% 100.00% 22.86%
/contracts/paymaster/interactor/src/interactor_main.rs 0.00% 0.00% 0.00% 0.00%
/contracts/paymaster/interactor/src/paymaster_config.rs 0.00% 0.00% 0.00% 0.00%
/contracts/paymaster/interactor/src/proxy.rs 0.00% 0.00% 0.00% 0.00%
/contracts/paymaster/meta/src/main.rs 0.00% 0.00% 0.00% 0.00%
/contracts/paymaster/src/forward_call.rs 63.16% 69.23% 100.00% 18.75%
/contracts/paymaster/src/paymaster.rs 100.00% 100.00% 100.00% 15.38%
/contracts/paymaster/src/paymaster_proxy.rs 100.00% 100.00% 100.00% 50.00%
/contracts/paymaster/tests/paymaster_blackbox_test.rs 100.00% 100.00% 100.00% 100.00%
/contracts/ping-pong-egld/meta/src/main.rs 0.00% 0.00% 0.00% 0.00%
/contracts/ping-pong-egld/src/ping_pong.rs 86.02% 84.62% 87.50% 23.08%
/contracts/ping-pong-egld/src/user_status.rs 66.67% 57.14% 66.67% 28.57%
/contracts/ping-pong-egld/tests/ping_pong_egld_scenario_go_test.rs 100.00% 100.00% 100.00% 100.00%
/contracts/ping-pong-egld/tests/ping_pong_egld_scenario_rs_test.rs 90.00% 88.89% 88.89% 88.89%
/contracts/potlock/interact-rs/src/potlock_interactor_main.rs 0.00% 0.00% 0.00% 0.00%
/contracts/potlock/interact-rs/src/proxy.rs 0.00% 0.00% 0.00% 0.00%
/contracts/potlock/meta/src/main.rs 0.00% 0.00% 0.00% 0.00%
/contracts/potlock/src/potlock.rs 100.00% 100.00% 100.00% 16.67%
/contracts/potlock/src/potlock_admin_interactions.rs 78.05% 78.26% 75.00% 21.15%
/contracts/potlock/src/potlock_interactions.rs 90.48% 73.68% 100.00% 26.47%
/contracts/potlock/src/potlock_requirements.rs 100.00% 95.00% 100.00% 35.71%
/contracts/potlock/src/potlock_storage.rs 72.55% 26.67% 39.13% 23.17%
/contracts/potlock/tests/potlock_blackbox_tests.rs 100.00% 97.73% 100.00% 100.00%
/contracts/potlock/tests/potlock_proxy.rs 54.45% 32.08% 42.86% 21.79%
/contracts/price-aggregator/meta/src/main.rs 0.00% 0.00% 0.00% 0.00%
/contracts/price-aggregator/src/events.rs 93.33% 46.67% 71.43% 38.46%
/contracts/price-aggregator/src/lib.rs 74.45% 58.88% 61.54% 31.87%
/contracts/price-aggregator/src/median.rs 81.25% 53.33% 100.00% 75.00%
/contracts/price-aggregator/src/price_aggregator_data.rs 33.33% 24.00% 33.33% 36.96%
/contracts/price-aggregator/tests/price_aggregator_blackbox_test.rs 100.00% 100.00% 100.00% 100.00%
/contracts/price-aggregator/tests/price_aggregator_proxy.rs 40.61% 21.43% 30.00% 19.80%
/contracts/price-aggregator/tests/price_aggregator_scenario_go_test.rs 100.00% 100.00% 100.00% 100.00%
/contracts/price-aggregator/tests/price_aggregator_stress_blackbox.rs 100.00% 100.00% 100.00% 100.00%
/contracts/price-aggregator/tests/price_aggregator_whitebox_test.rs 100.00% 100.00% 100.00% 100.00%
/contracts/proxy-deployer/meta/src/main.rs 0.00% 0.00% 0.00% 0.00%
/contracts/proxy-deployer/src/config.rs 31.75% 14.71% 21.43% 11.93%
/contracts/proxy-deployer/src/contract_interactions.rs 70.98% 54.93% 80.00% 23.08%
/contracts/proxy-deployer/src/events.rs 47.54% 25.93% 38.46% 14.29%
/contracts/proxy-deployer/src/lib.rs 100.00% 100.00% 100.00% 20.00%
/contracts/proxy-deployer/src/proxy_deployer_proxy.rs 30.69% 11.67% 17.95% 15.38%
/contracts/proxy-deployer/tests/proxy_deployer_blackbox_test.rs 100.00% 100.00% 100.00% 100.00%
/contracts/proxy-pause/meta/src/main.rs 0.00% 0.00% 0.00% 0.00%
/contracts/proxy-pause/src/pause_sc_proxy.rs 100.00% 100.00% 100.00% 50.00%
/contracts/proxy-pause/src/proxy_pause.rs 74.29% 84.21% 75.00% 24.39%
/contracts/proxy-pause/tests/proxy_pause_scenario_go_test.rs 100.00% 100.00% 100.00% 100.00%
/contracts/proxy-pause/tests/proxy_pause_scenario_rs_test.rs 100.00% 100.00% 100.00% 100.00%
/contracts/rewards-distribution/meta/src/main.rs 0.00% 0.00% 0.00% 0.00%
/contracts/rewards-distribution/src/rewards_distribution.rs 91.09% 73.68% 79.49% 17.59%
/contracts/rewards-distribution/src/seed_nft_minter_proxy.rs 14.18% 14.29% 18.75% 6.67%
/contracts/rewards-distribution/tests/mock_seed_nft_minter.rs 100.00% 80.00% 100.00% 14.52%
/contracts/rewards-distribution/tests/test_compute_brackets_legacy_test.rs 100.00% 100.00% 100.00% 100.00%
/contracts/rewards-distribution/tests/test_raffle_and_claim_legacy_test.rs 100.00% 100.00% 100.00% 100.00%
/contracts/rewards-distribution/tests/utils.rs 100.00% 100.00% 100.00% 66.67%
/contracts/seed-nft-minter/meta/src/main.rs 0.00% 0.00% 0.00% 0.00%
/contracts/seed-nft-minter/src/distribution_module.rs 0.00% 0.00% 0.00% 0.00%
/contracts/seed-nft-minter/src/nft_marketplace_proxy.rs 0.00% 0.00% 0.00% 0.00%
/contracts/seed-nft-minter/src/nft_module.rs 0.00% 0.00% 0.00% 0.00%
/contracts/seed-nft-minter/src/seed_nft_minter.rs 0.00% 0.00% 0.00% 0.00%
/contracts/token-release/meta/src/main.rs 0.00% 0.00% 0.00% 0.00%
/contracts/token-release/src/contract_data.rs 40.00% 28.57% 40.00% 25.00%
/contracts/token-release/src/token_release.rs 66.38% 56.96% 72.00% 25.53%
/contracts/token-release/tests/token_release_scenario_go_test.rs 100.00% 100.00% 100.00% 100.00%
/contracts/token-release/tests/token_release_scenario_rs_test.rs 100.00% 100.00% 100.00% 100.00%
/contracts/wegld-swap/meta/src/main.rs 0.00% 0.00% 0.00% 0.00%
/contracts/wegld-swap/src/wegld.rs 100.00% 100.00% 100.00% 23.08%
/contracts/wegld-swap/src/wegld_proxy.rs 21.74% 22.22% 22.22% 18.18%
/contracts/wegld-swap/tests/scenario_go_test.rs 100.00% 100.00% 100.00% 100.00%
/contracts/wegld-swap/tests/wegld_swap_scenario_rs_test.rs 100.00% 100.00% 100.00% 100.00%

contracts/potlock/src/potlock.rs Outdated Show resolved Hide resolved
contracts/potlock/src/potlock.rs Outdated Show resolved Hide resolved
contracts/potlock/src/potlock_setup.rs Outdated Show resolved Hide resolved
);
let caller = self.blockchain().get_caller();

let potlock_id = self.potlocks().len() + 1;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think this is a good idea, as you also have a way to remove data from this storage (removePot endpoint) - which means it may overwrite already existing ids. So it will be better if you keep a separate storage for the lastId and increment that value each time a new pot is created.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removing the second element from a VecMapper that contains 4 elements (1, 2, 3, 4), we would get 1, 3, 4.
Removing the last element from a VecMapper that contains 4 elements (1, 2, 3, 4), we would get 1, 2, 3. By adding another element, we would get 1, 2, 3, 5.
There is no need for the lastId.

contracts/potlock/src/potlock_setup.rs Outdated Show resolved Hide resolved
contracts/potlock/src/potlock_setup.rs Outdated Show resolved Hide resolved
let caller = self.blockchain().get_caller();
self.require_potlock_exists(potlock_id);
self.require_potlock_is_active(potlock_id);
self.pot_donations(potlock_id).insert(caller, payment);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is a problem here if I donate twice. The old donation would be overwritten and I'll remain with that amount in the contract unregistered. There are a few ways around this:

  1. You take the output of the insert function and send back to the user
  2. You add a check if there is already a donation on behalf of that user.
  3. Instead of a EsdtTokenPayment per user, you save a PaymentsVec.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Accepted multiple payments but only with the same token_id.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This function is still the same. The payment token is not checked. And in case you only ask for a specific payment token, you would still need a check, to see if there is already some donation from the caller. If it isn't, then you add it, if there's already something, you accumulate it. But this works only if the accepted token_id is always the same and not changeable.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Now I see you did this update for the donateToProject endpoint, but it is needed here also.

contracts/potlock/src/potlock_admin_interactions.rs Outdated Show resolved Hide resolved
for pp in project_percentage {
let (project_id, percentage) = pp.into_tuple();
let mut output_payments = ManagedVec::new();
for (_, donation) in pot_donations.iter() {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There may be a few problems with this way of implementing (as Dorin also suggested), mostly concerning gas usage. If a malicious user donates values from 1000 addresses, the potlock will be blocked, with an outOfGas error.
Maybe rethink the architecture of the storages. One option would be instead of a mapMapper, to save under the potlock_id and user keys, a singleValueMapper of PaymentsVec. This allows you to quickly go to a specific user for donations and also, this endpoint would control the gasCost by clearly providing a list of users, besides the potlockId.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We are unable to iterated through all payments and distribute them if we have singleValueMapper.


#[view(getProjects)]
#[storage_mapper("projects")]
fn projects(&self) -> VecMapper<Project<Self::Api>>;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

UnorderedSetMapper here as well.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would get a different behavior as explained to potlocks.

Modify require_correct_percentages from distributePotToProjects
endpoint. The total may be lower than 100%.
This enables the caller to distribute part of the pot.
alyn509
alyn509 previously approved these changes Aug 6, 2024
self.send().direct_multi(&project_owner, &output_payments);
}

self.pot_donations(potlock_id).clear();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because you completely clear (instead of deduct each payment), the require_correct_percentages should check that the total percentage == 100%, instead of <= 100%.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, after the pot is distributed to the projects, it still remains active? So once accepted, the pot remains active indefinitely?
If not, maybe some extra storage clearing should be done for the potlocks mapper?

contracts/potlock/src/potlock_admin_interactions.rs Outdated Show resolved Hide resolved

#[view(feeAmountAcceptPots)]
#[storage_mapper("feeAmountAcceptedPots")]
fn fee_amount_accepted_pots(&self) -> SingleValueMapper<BigUint>;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's the usage of this storage? You only increment it in the acceptPot, so just to keep track of the total pot amounts over time? Do you need this in the SC stored?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed.

fn add_pot(&self, name: ManagedBuffer, description: ManagedBuffer) {
let payment_for_adding_pot = self.call_value().single_esdt();
require!(
self.fee_token_identifier().get() == payment_for_adding_pot.token_identifier,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Only one payment token for all pots? And an ESDT? So I guess it will be WEGLD?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the token paid by the pot initiator (from the specs: AddPot@potDescription - it sets the description and the name of the pot, the call requires a FEE in a defined tokenID.)

The fee token can be set to any token, probably WEGLD.
Another contract can be deployed for xExchange and the fee will probably be MEX.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The donations can be in any ESDT token.


#[only_admin]
#[endpoint(acceptApplication)]
fn accept_application(&self, project_id: ProjectId) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe also add another endpoint to reject and remove project applications? Like with the pot?

let pot_donations = self.pot_donations(potlock_id);

for pp in project_percentages {
let (project_id, percentage) = pp.into_tuple();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe add an extra check here, if the project_id indeed applied for the given pot? To not give the a part of the share to outside projects.

pub mod potlock_interactions;
pub mod potlock_storage;

/// An empty contract. To be used as a template when starting a new contract from scratch.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't mark as resolved if you don't fix it :nutu:

contracts/potlock/src/potlock_admin_interactions.rs Outdated Show resolved Hide resolved
contracts/potlock/src/potlock_admin_interactions.rs Outdated Show resolved Hide resolved

#[multiversx_sc::module]
pub trait PotlockStorage {
fn is_valid_potlock_id(&self, potlock_id: PotlockId) -> bool {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe move those "require" functions to a different file. PotlockStorage implies it only contains Storage, but there's a whole lot of other stuff here.

@CostinCarabas CostinCarabas self-assigned this Oct 13, 2024
donation_mapper.insert(caller, payment);
}

// match donation_mapper.get(&caller) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Delete comment.

self.require_potlock_exists(potlock_id);
self.require_potlock_is_active(potlock_id);

let payment = self.call_value().single_esdt();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you need to accept NFT payments? If not, I would change this to single_fungible_esdt.

#[payable("*")]
#[endpoint(addPot)]
fn add_pot(&self, name: ManagedBuffer, description: ManagedBuffer) {
let payment_for_adding_pot = self.call_value().single_esdt();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not mandatory, but you could add these 2 storages under a single one, that keeps a EsdtTokenPayment struct. And you can check here if the payments are equal.


#[only_admin]
#[endpoint(distributePotToProjects)]
fn distribute_pot_to_projects(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A few more questions here. Not mandatory but are good to be discussed.

  • Right now, there is no way to be sure all the projects that applied for this pot were covered in the provided array, is it ok for the owner to be able to give the amounts arbitrary and to not all projects?
  • Also, there is no check that the project applied to this specific pot, maybe add a check after you read each project from storage, that the project is active for this pot? If not, why even bother to approve a project for a pot?
  • And finally, how about a limit to the number of projects that can apply for a pot? Either here for the number of elements for project_percentages, or for when subscribing a project to a pot.

let (_, perc) = pp.into_tuple();
total_perc += perc;
}
require!(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would still enforce clear equality here.
total_perc == MAX_PERCENTAGE

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants