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

smart contract: charge commission in the “resolving_disputes” function #37

Open
armandocodecr opened this issue Jan 22, 2025 · 9 comments
Assignees
Labels
enhancement New feature or request external-contributors Exclusively for contributors Maintainer - Caleb Loría ODBoost Issues for the ODBoost event

Comments

@armandocodecr
Copy link
Contributor

armandocodecr commented Jan 22, 2025

⚠️ You must apply through OnlyDust. If not, you'll be ignored ⚠️

⚠️ FOR THIS ISSUE YOU MUST ENSURE TO SUBMIT YOUR CHANGES TO THE “DEVELOP” BRANCH ⚠️

Description:

Currently, the “resolving_disputes” function does not charge any commissions. We require this function to charge the appropriate commissions, similar to what is already done in the “distribute_escrow_earnings” function.

Requirements:

  1. Charge the Trustless Work commission, which is 0.3%. This must be charged on the total funds to be distributed (client_funds + service_provider_funds) as part of the dispute resolution. Then it must be sent to the Trustless Work address (trustless_work_address).
  2. From the total amount to be transferred (client_funds + service_provider_funds), deduct the platform fee defined in the contract properties (platform_fee). This fee must be transferred to the platform’s address (platform_address).
  3. Deduct both commissions (the platform_fee and the 0.3% Trustless Work commission) from the amounts to be transferred to both the client and the service provider.

The function must receive the following parameters:

  1. dispute_resolver: Address
  2. client_funds: i128
  3. service_provider_funds: i128
  4. trustless_work_address: Address

Validations:

This function must handle the same validations it currently handles. Additionally, it must validate that the contract has sufficient balance to charge the commissions and transfer the amounts assigned to both the client and the service provider.

Errors:

We currently have a number of custom errors which we throw when executing some of the contract functions. An example of the above would be the following:

if escrow.balance != escrow.amount {
	return Err(ContractError::EscrowBalanceNotSufficienteToSendEarnings);
}

You only need to worry about throwing the error message, you don't need to handle custom errors. So if you need to return an error within the flow due to one of the validations, you can do it as follows:

if escrow.balance != escrow.amount {
	return Err("Your error message");
}

You must make sure that the message you are sending as an error is very clear and makes sense as to why the error is being sent.

Test:

To test your changes in the “resolving_disputes” function, you must modify and adapt all the tests that use this function in the file test.rs.

Additionally, ensure that the current tests validate the following due to your changes:

  1. The Trustless Work address receives its commission correctly.
  2. The platform address (platform_address) receives its commission correctly.
  3. The client receives the assigned amount correctly, with commissions deducted.
  4. The service provider receives the assigned amount correctly, with commissions deducted.

Ensure that all tests are successful to validate that your changes fulfill the function’s objectives.

To run the test you have just created you can use the command cargo test.

Recommendation:

Stellar people have in their discord a channel called “stella-help”, in that channel you can ask your technical questions about Stellar and its libraries (including the “soroban_sdk” library we use in the contract). This bot can help you a lot to solve your issues. Just remember that before submitting your query you must add the word “stella” at the beginning of the query. Otherwise the bot will not answer you.

The Stellar discord where you can find this channel is the following: Stellar Discord

⚠️ Please follow the guidelines for requesting an issue, launching commits and describing PR's. Otherwise they will be ignored. ⚠️

@armandocodecr armandocodecr added enhancement New feature or request external-contributors Exclusively for contributors Maintainer - Caleb Loría labels Jan 22, 2025
@JoelVR17 JoelVR17 changed the title Charge commission in the “resolving-disputes” function smart contract: charge commission in the “resolving-disputes” function Jan 22, 2025
@armandocodecr armandocodecr added the ODBoost Issues for the ODBoost event label Jan 22, 2025
@Bosun-Josh121
Copy link
Contributor

I am applying to this issue via OnlyDust platform.

My background and how it can be leveraged:

software engineering background, backend & smart contract dev with contribution to similar tasks(https://app.onlydust.com/u/Bosun-Josh121) . here's link to a contribution: #28

I have good experience in similar tasks & in codebase and i'm confident in delivering this if assigned.

I will work on feedback & recommendation ensuring contact. Can deliver within a day upon assignment

@caxtonacollins
Copy link

I'd be happy to do this. I am proficient in cairo, and will love to contribute to this project. ready to put in the work.

@ryzen-xp
Copy link

Hi,
I am proficient Blockchain developer expert in Cairo , Rust and Solidity and also in web development.
I have contributed many starknet project and more .
please /assign this issue .
Thank You !!

@juandiegocv27
Copy link

Can I take this issue?

@mimisavage
Copy link

Would love to tackle this!

@Jagadeeshftw
Copy link

Proposal to Work on the Issue

I am eager to contribute to this issue and believe I am well-suited for the task, given my extensive experience in Cairo programming and building decentralized applications on StarkNet. My expertise spans across multiple domains crucial for this implementation:

  • Smart Contracts & Blockchain Development: Proven expertise in StarkNet, Stellar, and Rust, with hands-on experience in developing secure and efficient smart contracts, blockchain integrations, and high-performance backend systems.
  • Backend Engineering: Strong background in designing and managing scalable APIs, handling server-side operations, and ensuring robust backend performance for blockchain applications.
  • Frontend Development: Proficient in building intuitive and responsive frontend interfaces using React and Next.js, ensuring seamless interaction between users and blockchain-based applications.

Why Assign This to Me?

I have a track record of delivering high-quality solutions efficiently, with a deep understanding of smart contract security, decentralized architectures, and full-stack development. My ability to bridge frontend, backend, and blockchain components ensures a well-rounded, optimized solution.

Estimated Timeline

I anticipate delivering a fully functional solution within 3 days. Please let me know if I can proceed.

I am excited about the opportunity to contribute and look forward to collaborating!

Best regards,
Jagadeesh B

@Wendyalbert
Copy link

Would love to tackle this!

@zkCaleb-dev
Copy link
Contributor

This issue is for you @Bosun-Josh121 ! 🚀
Remember to follow all the guidelines, both the ones inside the repository and the guideline to perform the PR.

Many thanks to all the other dev's who sent in their application. 🔥

@Bosun-Josh121
Copy link
Contributor

This issue is for you @Bosun-Josh121 ! 🚀 Remember to follow all the guidelines, both the ones inside the repository and the guideline to perform the PR.

Many thanks to all the other dev's who sent in their application. 🔥

Thanks ser. Noted 🚀

@armandocodecr armandocodecr changed the title smart contract: charge commission in the “resolving-disputes” function smart contract: charge commission in the “resolving_disputes” function Jan 22, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request external-contributors Exclusively for contributors Maintainer - Caleb Loría ODBoost Issues for the ODBoost event
Projects
None yet
Development

No branches or pull requests

9 participants